OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
port_io.h
Go to the documentation of this file.
1
5#ifndef _HAL_PORT_IO_H
6#define _HAL_PORT_IO_H
7
8#include "stdint.h"
9
15static inline uint8_t inb(uint16_t port) {
16 uint8_t result;
17 __asm__ volatile(
18 "inb %1, %0"
19 : "=a" (result)
20 : "Nd" (port));
21 return result;
22}
23
29static inline void outb(uint16_t port, uint8_t val) {
30 __asm__ volatile(
31 "outb %0, %1"
32 :
33 : "a" (val), "Nd" (port));
34}
35
41static inline uint16_t inw(uint16_t port) {
42 uint16_t result;
43 __asm__ volatile(
44 "inw %1, %0"
45 : "=a" (result)
46 : "Nd" (port));
47 return result;
48}
49
55static inline void outw(uint16_t port, uint16_t val) {
56 __asm__ volatile(
57 "outw %0, %1"
58 :
59 : "a" (val), "Nd" (port));
60}
61
67static inline uint32_t inl(uint16_t port) {
68 uint32_t result;
69 __asm__ volatile(
70 "inl %1, %0"
71 : "=a" (result)
72 : "Nd" (port));
73 return result;
74}
75
81static inline void outl(uint16_t port, uint32_t val) {
82 __asm__ volatile(
83 "outl %0, %1"
84 :
85 : "a" (val), "Nd" (port));
86}
87
94static inline void io_wait(void) {
95 outb(0x80, 0);
96}
97
98#endif
static uint8_t inb(uint16_t port)
read byte from low level port
Definition port_io.h:15
static void io_wait(void)
perform a short wait (1-4 microseconds)
Definition port_io.h:94
static void outl(uint16_t port, uint32_t val)
write double word to low level port
Definition port_io.h:81
static uint32_t inl(uint16_t port)
read double word from low level port
Definition port_io.h:67
static void outb(uint16_t port, uint8_t val)
write byte to low level port
Definition port_io.h:29
static void outw(uint16_t port, uint16_t val)
write word to low level port
Definition port_io.h:55
static uint16_t inw(uint16_t port)
read word from low level port
Definition port_io.h:41