|
|
|
@ -21,13 +21,29 @@
|
|
|
|
|
|
|
|
|
|
#ifndef _ASM_SOURCE
|
|
|
|
|
|
|
|
|
|
#include <gay/cdefs.h>
|
|
|
|
|
|
|
|
|
|
/** @brief Induce a brief CPU delay by writing zero to I/O port 0x80. */
|
|
|
|
|
extern void x86_io_wait(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Read a byte from the I/O bus.
|
|
|
|
|
*
|
|
|
|
|
* @param port Port number
|
|
|
|
|
* @return The byte that was read
|
|
|
|
|
*/
|
|
|
|
|
extern u8 x86_inb(u16 port);
|
|
|
|
|
inline u8 x86_inb(u16 port)
|
|
|
|
|
{
|
|
|
|
|
u8 data;
|
|
|
|
|
|
|
|
|
|
__asm__ volatile(
|
|
|
|
|
" inb %1, %0 \n"
|
|
|
|
|
: "=a"(data)
|
|
|
|
|
: "Nd"(port)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Read a word from the I/O bus.
|
|
|
|
@ -35,7 +51,18 @@ extern u8 x86_inb(u16 port);
|
|
|
|
|
* @param port Port number
|
|
|
|
|
* @return The word that was read
|
|
|
|
|
*/
|
|
|
|
|
extern u16 x86_inw(u16 port);
|
|
|
|
|
inline u16 x86_inw(u16 port)
|
|
|
|
|
{
|
|
|
|
|
u16 data;
|
|
|
|
|
|
|
|
|
|
__asm__ volatile(
|
|
|
|
|
" inw %1, %0 \n"
|
|
|
|
|
: "=a"(data)
|
|
|
|
|
: "Nd"(port)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Read a longword from the I/O bus.
|
|
|
|
@ -43,7 +70,18 @@ extern u16 x86_inw(u16 port);
|
|
|
|
|
* @param port Port number
|
|
|
|
|
* @return The longword that was read
|
|
|
|
|
*/
|
|
|
|
|
extern u32 x86_inl(u16 port);
|
|
|
|
|
inline u32 x86_inl(u16 port)
|
|
|
|
|
{
|
|
|
|
|
u32 data;
|
|
|
|
|
|
|
|
|
|
__asm__ volatile(
|
|
|
|
|
" inl %1, %0 \n"
|
|
|
|
|
: "=a"(data)
|
|
|
|
|
: "Nd"(port)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Write a byte to the I/O bus.
|
|
|
|
@ -51,7 +89,14 @@ extern u32 x86_inl(u16 port);
|
|
|
|
|
* @param port Port number
|
|
|
|
|
* @param data Byte to send through the port
|
|
|
|
|
*/
|
|
|
|
|
extern void x86_outb(u16 port, u8 data);
|
|
|
|
|
inline void x86_outb(u16 port, u8 data)
|
|
|
|
|
{
|
|
|
|
|
__asm__ volatile(
|
|
|
|
|
" outb %0, %1 \n"
|
|
|
|
|
:
|
|
|
|
|
: "a"(data), "Nd"(port)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Write a word to the I/O bus.
|
|
|
|
@ -59,7 +104,14 @@ extern void x86_outb(u16 port, u8 data);
|
|
|
|
|
* @param port Port number
|
|
|
|
|
* @param data Word to send through the port
|
|
|
|
|
*/
|
|
|
|
|
extern void x86_outw(u16 port, u16 data);
|
|
|
|
|
inline void x86_outw(u16 port, u16 data)
|
|
|
|
|
{
|
|
|
|
|
__asm__ volatile(
|
|
|
|
|
" outw %0, %1 \n"
|
|
|
|
|
:
|
|
|
|
|
: "a"(data), "Nd"(port)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Write a longword to the I/O bus.
|
|
|
|
@ -67,7 +119,14 @@ extern void x86_outw(u16 port, u16 data);
|
|
|
|
|
* @param port Port number
|
|
|
|
|
* @param data Longword to send through the port
|
|
|
|
|
*/
|
|
|
|
|
extern void x86_outl(u16 port, u32 data);
|
|
|
|
|
inline void x86_outl(u16 port, u32 data)
|
|
|
|
|
{
|
|
|
|
|
__asm__ volatile(
|
|
|
|
|
" outl %0, %1 \n"
|
|
|
|
|
:
|
|
|
|
|
: "a"(data), "Nd"(port)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* not _ASM_SOURCE */
|
|
|
|
|
|
|
|
|
|