MOS Source Code
Loading...
Searching...
No Matches
port.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/mos_global.h>
6#include <mos/types.h>
7
8typedef u16 x86_port_t;
9
11{
12 u8 value;
13 __asm__ volatile("inb %1, %0" : "=a"(value) : "dN"(port));
14 return value;
15}
16
18{
19 u16 value;
20 __asm__ volatile("inw %1, %0" : "=a"(value) : "dN"(port));
21 return value;
22}
23
25{
26 u32 value;
27 __asm__ volatile("inl %1, %0" : "=a"(value) : "dN"(port));
28 return value;
29}
30
31should_inline void port_outb(u16 port, u8 value)
32{
33 __asm__ volatile("outb %1, %0" : : "dN"(port), "a"(value));
34}
35
37{
38 __asm__ volatile("outw %1, %0" : : "dN"(port), "a"(value));
39}
40
42{
43 __asm__ volatile("outl %1, %0" : : "dN"(port), "a"(value));
44}
#define should_inline
Definition mos_global.h:37
should_inline void port_outl(x86_port_t port, u32 value)
Definition port.h:41
should_inline void port_outw(x86_port_t port, u16 value)
Definition port.h:36
should_inline u32 port_inl(x86_port_t port)
Definition port.h:24
u16 x86_port_t
Definition port.h:8
should_inline void port_outb(u16 port, u8 value)
Definition port.h:31
should_inline u8 port_inb(u16 port)
Definition port.h:10
should_inline u16 port_inw(x86_port_t port)
Definition port.h:17
unsigned int u32
Definition types.h:21
unsigned short u16
Definition types.h:20
unsigned char u8
Definition types.h:19