Add harware reading and writing functions

This commit is contained in:
Jenny Curle 2019-04-03 09:51:46 +01:00
parent 94c1eb2279
commit 904cb38128
2 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,10 @@
#pragma once
#include <stddef.h>
/* A temporary file, to get the system compiling. */
size_t strlen(const char*);
size_t strlen(const char*);
unsigned char inb(unsigned short);
void outb(unsigned short, unsigned char);

View File

@ -1,3 +1,4 @@
#include <stddef.h>
size_t strlen(const char* string) {
@ -5,4 +6,14 @@ size_t strlen(const char* string) {
while (string[size])
size++;
return size;
}
}
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));
}