PatchworkOS
Loading...
Searching...
No Matches
port.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
15#define ICW1_ICW4 0x01 // Indicates that ICW4 will be present
16#define ICW1_SINGLE 0x02 // Single (cascade) mode
17#define ICW1_INTERVAL4 0x04 // Call address interval 4 (8)
18#define ICW1_LEVEL 0x08 // Level triggered (edge) mode
19#define ICW1_INIT 0x10 // Initialization - required!
20
21#define ICW4_8086 0x01 // 8086/88 (MCS-80/85) mode
22#define ICW4_AUTO 0x02 // Auto (normal) EOI
23#define ICW4_BUF_SLAVE 0x08 // Buffered mode/slave
24#define ICW4_BUF_MASTER 0x0C // Buffered mode/master
25#define ICW4_SFNM 0x10 // Special fully nested (not)
26
27#define QEMU_ISA_DEBUG_EXIT_PORT 0x501
28
29static inline void port_outb(uint16_t port, uint8_t val)
30{
31 asm volatile("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
32}
33
34static inline uint8_t port_inb(uint16_t port)
35{
36 uint8_t ret;
37 asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
38 return ret;
39}
40
41static inline void port_outw(uint16_t port, uint16_t val)
42{
43 asm volatile("outw %0, %1" : : "a"(val), "Nd"(port) : "memory");
44}
45
46static inline uint16_t port_inw(uint16_t port)
47{
48 uint16_t ret;
49 asm volatile("inw %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
50 return ret;
51}
52
53static inline uint32_t port_inl(uint16_t port)
54{
55 uint32_t ret;
56 asm volatile("inl %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
57 return ret;
58}
59
60static inline void port_outl(uint16_t port, uint32_t val)
61{
62 asm volatile("outl %0, %1" : : "a"(val), "Nd"(port) : "memory");
63}
64
65static inline void port_wait(void)
66{
67 port_outb(0x80, 0);
68}
69
static uint8_t port_inb(uint16_t port)
Definition port.h:34
static void port_outl(uint16_t port, uint32_t val)
Definition port.h:60
static void port_wait(void)
Definition port.h:65
static uint16_t port_inw(uint16_t port)
Definition port.h:46
static void port_outb(uint16_t port, uint8_t val)
Definition port.h:29
static void port_outw(uint16_t port, uint16_t val)
Definition port.h:41
static uint32_t port_inl(uint16_t port)
Definition port.h:53
__UINT32_TYPE__ uint32_t
Definition stdint.h:15
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
__UINT16_TYPE__ uint16_t
Definition stdint.h:13