Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3347f002
authored
Nov 02, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make asm wrapper functions for inl and outl
parent
5113d83c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
src/asm.h
src/asm.h
View file @
3347f002
...
@@ -2,24 +2,39 @@
...
@@ -2,24 +2,39 @@
asm.h contains x86 specific functions for executing low level code
asm.h contains x86 specific functions for executing low level code
*/
*/
#pragma once
#ifndef _ASM_INC
#define _ASM_INC
#include <stdint.h>
#include <stdint.h>
// Wrapper for outb
// Wrapper for outb
// Stolen from http://wiki.osdev.org/Inline_Assembly/Examples
// Stolen from http://wiki.osdev.org/Inline_Assembly/Examples
inline
void
outb
(
uint16_t
port
,
uint8_t
val
)
inline
void
outb
(
uint16_t
port
,
uint8_t
val
)
{
{
asm
volatile
(
"outb %0, %1"
:
:
"a"
(
val
),
"Nd"
(
port
));
asm
volatile
(
"outb %0, %1"
:
:
"a"
(
val
),
"Nd"
(
port
));
}
}
// Wrapper for inb
// Wrapper for inb
inline
uint8_t
inb
(
uint16_t
port
)
inline
uint8_t
inb
(
uint16_t
port
)
{
{
uint8_t
ret
;
uint8_t
ret
;
asm
volatile
(
"inb %1, %0"
:
"=a"
(
ret
)
:
"Nd"
(
port
));
asm
volatile
(
"inb %1, %0"
:
"=a"
(
ret
)
:
"Nd"
(
port
));
return
ret
;
return
ret
;
}
}
// Wrapper for outl
inline
void
outl
(
uint16_t
port
,
uint32_t
val
)
{
asm
volatile
(
"outl %0, %1"
:
:
"a"
(
val
),
"Nd"
(
port
));
}
// Wrapper for inl
inline
uint32_t
inl
(
uint16_t
port
)
{
uint32_t
ret
;
asm
volatile
(
"inl %1, %0"
:
"=a"
(
ret
)
:
"Nd"
(
port
));
return
ret
;
}
inline
void
disable_int
()
inline
void
disable_int
()
{
{
asm
volatile
(
"cli"
);
asm
volatile
(
"cli"
);
...
@@ -29,3 +44,5 @@ inline void enable_int()
...
@@ -29,3 +44,5 @@ inline void enable_int()
{
{
asm
volatile
(
"sti"
);
asm
volatile
(
"sti"
);
}
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment