summaryrefslogtreecommitdiff
path: root/include/nrvn.h
blob: 98b4c78ba7398fca1ce0c15aa12022b6e49999f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef _NRVN_H_
#define _NRVN_H_

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

static inline void outb(uint16_t port, uint8_t val) {
	__asm__ volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
}

static inline void outl(uint32_t port, uint32_t val) {
	__asm__ volatile ("outl %0, %1" : : "a"(val), "Nd"(port) : "memory");
}

static inline void outw(uint16_t port, uint16_t val) {
	__asm__ volatile ("outw %0, %1" : : "a"(val), "Nd"(port) : "memory");
}

static inline uint8_t inb(uint16_t port) {
	uint8_t ret;
	__asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
	return ret;
}

static inline uint32_t inl(uint16_t port) {
	uint32_t ret;
	__asm__ volatile ("inl %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
	return ret;
}

static inline void io_wait(void) {
    outb(0x80, 0);
}

#endif