diff options
author | Marvin Borner | 2020-08-05 18:28:26 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-05 18:28:26 +0200 |
commit | 4af62bb53676b7f721b46cabee78cac3a557e924 (patch) | |
tree | b9c7e615c3226d9822c22cdb6cdb326f379db73f /apps/init.c | |
parent | b7f59b28b380d55f9e7abd8e450f1f9c7f050221 (diff) |
Some proc things
Diffstat (limited to 'apps/init.c')
-rw-r--r-- | apps/init.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/apps/init.c b/apps/init.c new file mode 100644 index 0000000..bd33033 --- /dev/null +++ b/apps/init.c @@ -0,0 +1,49 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#include <def.h> + +u32 strlen(const char *s) +{ + const char *ss = s; + while (*ss) + ss++; + return ss - s; +} + +u8 inb(u16 port) +{ + u8 value; + __asm__ volatile("inb %1, %0" : "=a"(value) : "Nd"(port)); + return value; +} + +void outb(u16 port, u8 data) +{ + __asm__ volatile("outb %0, %1" ::"a"(data), "Nd"(port)); +} + +int is_transmit_empty() +{ + return inb(0x3f8 + 5) & 0x20; +} + +void serial_put(char ch) +{ + while (is_transmit_empty() == 0) + ; + outb(0x3f8, (u8)ch); +} + +void serial_print(const char *data) +{ + for (u32 i = 0; i < strlen(data); i++) + serial_put(data[i]); +} + +void main() +{ + serial_print("Init loaded\n"); + __asm__ volatile("int $0x80"); + while (1) { + }; +} |