aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorMarvin Borner2020-06-20 19:26:17 +0200
committerMarvin Borner2020-06-20 19:26:17 +0200
commite2a264fa749bcf7a332b0d474eb527d988531472 (patch)
treeae38a384cda40451d6919f3d1a09efa1fda85e9c /src/main.c
parentcdea72777ae088e865b1100436a7ece7d5877347 (diff)
Added static binary kernel loading
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 88bcde0..21ad290 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,37 @@
+unsigned char inb(unsigned short port)
+{
+ unsigned char value;
+ __asm__ volatile("inb %1, %0" : "=a"(value) : "Nd"(port));
+ return value;
+}
+
+void outb(unsigned short port, unsigned char 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, (unsigned char)ch);
+}
+
int main(int argc, char *argv[])
{
+ outb(0x3f8 + 1, 0x00);
+ outb(0x3f8 + 3, 0x80);
+ outb(0x3f8 + 0, 0x03);
+ outb(0x3f8 + 1, 0x00);
+ outb(0x3f8 + 3, 0x03);
+ outb(0x3f8 + 2, 0xC7);
+ outb(0x3f8 + 4, 0x0B);
+ serial_put('a');
while (1) {
};
return 0;