diff options
author | Danny Holman <dholman@gymli.xyz> | 2021-01-20 21:31:23 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.xyz> | 2021-01-20 21:31:23 -0600 |
commit | 7a6cf86e4dd3094ed5aa41bf76d93c28c89e85e7 (patch) | |
tree | dd076e1a2307b8f2d5ee26b8df118ba45604ad1d /arch/i386/pic.h | |
parent | include: append "_H" to include guards (diff) | |
download | box-7a6cf86e4dd3094ed5aa41bf76d93c28c89e85e7.tar.gz box-7a6cf86e4dd3094ed5aa41bf76d93c28c89e85e7.tar.zst box-7a6cf86e4dd3094ed5aa41bf76d93c28c89e85e7.zip |
i386: add serial port support
Add support for serial communication in the i386 architecture.
Signed-off-by: Danny Holman <dholman@gymli.xyz>
Diffstat (limited to '')
-rw-r--r-- | arch/i386/pic.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/i386/pic.h b/arch/i386/pic.h new file mode 100644 index 0000000..da4a2ee --- /dev/null +++ b/arch/i386/pic.h @@ -0,0 +1,16 @@ +#ifndef PIC_H +#define PIC_H + +#include <stdint.h> + +static inline void outb(uint16_t port, uint8_t value) { + asm volatile("outb %0, %1" : : "a"(value), "Nd"(port)); +} + +static inline uint8_t inb(uint16_t port) { + uint8_t ret; + asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port)); + return ret; +} + +#endif |