blob: 1b35f71fbe5bc8a610a5af2e0bfc85af768e6029 [file] [log] [blame]
swissChili9b3584b2021-02-18 13:57:27 -08001#include "io.h"
swissChilid8137922021-02-17 15:34:07 -08002
3
4void outb(ushort port, uchar val)
5{
6 asm volatile("outb %1, %0" : : "dN" (port), "a" (val));
7}
8
9uchar inb(ushort port)
10{
11 uchar ret;
12 asm volatile("inb %1, %0" : "=a" (ret) : "dN" (port));
13 return ret;
14}
15
16ushort inw(ushort port)
17{
18 ushort ret;
19 asm volatile("inw %1, %0" : "=a" (ret) : "dN" (port));
20 return ret;
21}
22
23void *memset(void *s, int c, size_t n)
24{
25 for (size_t i = 0; i < n; i++)
26 {
27 ((uchar *)s)[i] = c;
28 }
29}
30
31void *memcpy(void *dest, const void *src, size_t n)
32{
33 for (size_t i = 0; i < n; i++)
34 {
35 ((uchar *)dest)[i] = ((uchar *)src)[i];
36 }
37}
swissChili9b3584b2021-02-18 13:57:27 -080038
39void io_wait()
40{
41 asm volatile("outb %0, $0x80" :: "a"(0));
42}