about summary refs log tree commit diff stats
path: root/apps/boot.hex
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-12-23 08:41:53 -0800
committerKartik Agaram <vc@akkartik.com>2020-12-23 08:41:53 -0800
commitde7bd3998b60a26d9925a782c00c19ce17ea101d (patch)
treed2dd4650653db017a02b755b42300d4438e7187a /apps/boot.hex
parente82e7d644ce3836b5d674078ff1d57afc3d2247d (diff)
downloadmu-de7bd3998b60a26d9925a782c00c19ce17ea101d.tar.gz
7382 - snapshot
Turns out I've been "testing" with a stale file since commit 7373. We need
to go over everything since then.
Diffstat (limited to 'apps/boot.hex')
-rw-r--r--apps/boot.hex83
1 files changed, 62 insertions, 21 deletions
diff --git a/apps/boot.hex b/apps/boot.hex
index aa7328d0..49cea543 100644
--- a/apps/boot.hex
+++ b/apps/boot.hex
@@ -1,7 +1,8 @@
 # Bootable image that:
 #   - loads more sectors past the first boot sector (using BIOS primitives)
 #   - switches to 32-bit mode (giving up access to BIOS primitives)
-#   - as an example program, prints a letter from the second sector to the top-left of the screen (by writing to memory-mapped VGA memory)
+#   - sets up a handler for keyboard events
+#   - as an example program, prints alphabets to the top-left position on screen (by writing to memory-mapped VGA memory) as they're typed
 #
 # If the initial load fails, it prints 'D' to the top-left of the screen and
 # halts.
@@ -168,13 +169,17 @@ e9 fb ff  # loop forever
   8e e0  # fs <- ax
   8e e8  # gs <- ax
 
+  # load interrupt handlers
+  0f 01 1e  # lidt 00/mod/indirect 011/subop 110/rm32/TODO
+    00 7f  # *idt_descriptor
+
   # initialization is done; enable interrupts
   fb
   e9 2d 00 00 00  # jump to 0x7d00
 
 # padding
-# d4:
-            00 00 00 00 00 00 00 00 00 00 00 00
+# d9:
+                           00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 
@@ -198,6 +203,9 @@ e9 fb ff ff ff  # loop forever
 # padding
 # 111:
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+# 120:
+
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
@@ -219,24 +227,57 @@ e9 fb ff ff ff  # loop forever
 ## sector 2
 # not loaded on boot; loaded by load_disk
 
-# offset 200 (address 0x7e00):
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# offset 200 (address 0x7e00): interrupt descriptor table
+# 32 entries * 8 bytes each = 256 bytes (0x100)
+# idt_start:
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+
+# offset 9: keyboard, following https://alex.dzyoba.com/blog/os-interrupts
+  20 7d  # offset[0:16]
+  08 00  # segment selector (gdt_code)
+  00  # unused
+  8e  # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate
+  00 00  # offset[16:32]
+
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+# idt_end:
+
+# offset 300 (address 0x7f00):
+# idt_descriptor:
+  ff 00  # idt_end - idt_start - 1
+  00 7e 00 00  # start = idt_start
+
+# padding
+                  00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00