diff --git a/include/kernel/utils.h b/include/kernel/utils.h index eb23480..0bd8ba1 100755 --- a/include/kernel/utils.h +++ b/include/kernel/utils.h @@ -1,5 +1,10 @@ +#pragma once #include /* A temporary file, to get the system compiling. */ -size_t strlen(const char*); \ No newline at end of file +size_t strlen(const char*); + +unsigned char inb(unsigned short); + +void outb(unsigned short, unsigned char); \ No newline at end of file diff --git a/kernel/utils.c b/kernel/utils.c index 739d608..8040f47 100755 --- a/kernel/utils.c +++ b/kernel/utils.c @@ -1,3 +1,4 @@ + #include size_t strlen(const char* string) { @@ -5,4 +6,14 @@ size_t strlen(const char* string) { while (string[size]) size++; return size; -} \ No newline at end of file +} + +unsigned char inb(unsigned short port) { + unsigned char ptr; + asm volatile("inb %1, %0" : "=a" (ptr) : "dN" (port)); + return ptr; +} + +void outb(unsigned short port, unsigned char data) { + asm volatile("outb %1, %0" : : "dN" (port), "a" (data)); +}