about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-27 21:52:44 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-27 21:52:44 -0800
commit49badfb697fb06c5fa09aced3d05706f93b55938 (patch)
tree2abff187da680cbb8ac5089bff42a5ab04e0e7ca
parentca5ac5154e7a2fddb978ba14e83818498bdfb377 (diff)
downloadmu-49badfb697fb06c5fa09aced3d05706f93b55938.tar.gz
7672
-rw-r--r--baremetal/102keyboard.subx10
-rw-r--r--baremetal/boot.hex96
2 files changed, 55 insertions, 51 deletions
diff --git a/baremetal/102keyboard.subx b/baremetal/102keyboard.subx
index 8faa71e3..df74c8e7 100644
--- a/baremetal/102keyboard.subx
+++ b/baremetal/102keyboard.subx
@@ -20,9 +20,9 @@ read-key:  # kbd: (addr keyboard) -> result/eax: byte
     {
       75/jump-if-!= break/disp8
       # var read/ecx: byte = keyboard buffer's read index
-      8b/-> *0x7ee4 1/r32/CL  # keyboard-buffer-read
+      8b/-> *0x802c 1/r32/CL  # keyboard-buffer-read
       # var next-key/eax: byte = *(keyboard buffer + ecx)
-      8a/byte-> *(ecx+0x7ee8) 0/r32/AL  # keyboard-buffer-data
+      8a/byte-> *(ecx+0x8030) 0/r32/AL  # keyboard-buffer-data
       # if (next-key != 0) lock and remove from keyboard buffer
       81 7/subop/compare %eax 0/imm32
       {
@@ -30,9 +30,9 @@ read-key:  # kbd: (addr keyboard) -> result/eax: byte
         # TODO: add some instructions in this block to SubX if we ever want to
         # use bootstrap on baremetal programs
         fa/disable-interrupts
-        c6 0/subop/copy-byte *(ecx+0x7ee8) 0/imm8  # keyboard-buffer-data
-        ff 0/subop/increment *0x7ee4  # keyboard-buffer-read
-        81 4/subop/and *0x7ee4 0xf/imm32  # keyboard-buffer-read
+        c6 0/subop/copy-byte *(ecx+0x8030) 0/imm8  # keyboard-buffer-data
+        ff 0/subop/increment *0x802c  # keyboard-buffer-read
+        81 4/subop/and *0x802c 0xf/imm32  # keyboard-buffer-read
         fb/enable-interrupts
       }
       # return
diff --git a/baremetal/boot.hex b/baremetal/boot.hex
index 4261ecfe..08f89fe5 100644
--- a/baremetal/boot.hex
+++ b/baremetal/boot.hex
@@ -39,7 +39,7 @@
 # (really only in a couple of slightly higher-level places) only needs to know
 # a few magic constants:
 #   Video memory: start is stored at 0x8128
-#   Keyboard buffer: starts at 0x7ee0
+#   Keyboard buffer: starts at 0x8028
 
 # Outline of this file with offsets and the addresses they map to at run-time:
 # -- 16-bit mode code
@@ -52,8 +52,9 @@
 #           1fe (address 7dfe) boot sector marker (2 bytes)
 #   offset  200 (address 7e00): interrupt handler code
 # -- 32-bit mode data
-#           2e0 (address 7ee0) <== keyboard buffer
-#           2f8 (address 7ef8) <== idt_descriptor
+#   offset  400 (address 8000): handler data
+#           410 (address 8010): keyboard handler data
+#           428 (address 8028) <== keyboard buffer
 #   offset  500 (address 8100): video mode data (256 bytes)
 #           528 (address 8128) <== start of video RAM stored here
 #   offset  600 (address 8200): interrupt descriptor table (1KB)
@@ -238,7 +239,7 @@ e9 fd ff  # loop forever
 # 113:
   # load interrupt handlers
   0f 01 1d  # lidt 00/mod/indirect 011/subop 101/rm32/use-disp32
-    f8 7e 00 00  # *idt_descriptor [label]
+    00 80 00 00  # *idt_descriptor [label]
 
   # For now, not bothering reprogramming the IRQ to not conflict with software
   # exceptions.
@@ -311,11 +312,11 @@ e9 fd ff  # loop forever
   # var index/ecx: byte
   8a  # copy m8 at r32 to r8
     0d  # 00/mod/indirect 001/r8/cl 101/rm32/use-disp32
-    e0 7e 00 00  # disp32 [label]
+    28 80 00 00  # disp32 [label]
   # al = *(keyboard buffer + index)
   8a  # copy m8 at r32 to r8
     81  # 10/mod/*+disp32 000/r8/al 001/rm32/ecx
-    e8 7e 00 00  # disp32 [label]
+    30 80 00 00  # disp32 [label]
   # if (al != 0) return
   3c 00  # compare al, 0
 # 230:
@@ -331,7 +332,7 @@ e9 fd ff  # loop forever
   # *shift = 0
   c7  # copy imm32 to rm32
     05  # 00/mod/indirect 000/subop/copy 101/rm32/use-disp32
-    dc 7e 00 00  # disp32 [label]
+    10 80 00 00  # disp32 [label]
     00 00 00 00  # imm32
 # 242:
 # $1:
@@ -342,7 +343,7 @@ e9 fd ff  # loop forever
   # *shift = 0
   c7  # copy imm32 to rm32
     05  # 00/mod/indirect 000/subop/copy 101/rm32/use-disp32
-    dc 7e 00 00  # disp32 [label]
+    10 80 00 00  # disp32 [label]
     00 00 00 00  # imm32
 # 250:
 # $2:
@@ -360,7 +361,7 @@ e9 fd ff  # loop forever
   # *shift = 1
   c7  # copy imm32 to rm32
     05  # 00/mod/indirect 000/subop/copy 101/rm32/use-disp32
-    dc 7e 00 00  # disp32 [label]
+    10 80 00 00  # disp32 [label]
     01 00 00 00  # imm32
   eb 41 # jump to epilogue [label]
 # 268:
@@ -371,7 +372,7 @@ e9 fd ff  # loop forever
   # *shift = 1
   c7  # copy imm32 to rm32
     05  # 00/mod/indirect 000/subop/copy 101/rm32/use-disp32
-    dc 7e 00 00  # disp32 [label]
+    10 80 00 00  # disp32 [label]
     01 00 00 00  # imm32
   eb 31 # jump to epilogue [label]
 # $4:
@@ -380,7 +381,7 @@ e9 fd ff  # loop forever
   # if (shift) use keyboard normal map
   81  # operate on rm32 and imm32
     3d  # 00/mod/indirect 111/subop/compare 101/rm32/use-disp32
-    dc 7e 00 00  # disp32 = shift [label]
+    10 80 00 00  # disp32 = shift [label]
     00 00 00 00  # imm32
   74 08  # jump to $5 if = [label]
 # 284:
@@ -405,17 +406,17 @@ e9 fd ff  # loop forever
   # - store al in keyboard buffer
   88  # copy r8 to m8 at r32
     81  # 10/mod/*+disp32 000/r8/al 001/rm32/ecx
-    e8 7e 00 00  # disp32 [label]
+    30 80 00 00  # disp32 [label]
 # 29c:
   # increment index
   fe  # increment byte
     05  # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32
-    e0 7e 00 00  # disp32 [label]
+    28 80 00 00  # disp32 [label]
 # 2a2:
   # clear top nibble of index (keyboard buffer is circular)
   80  # and byte
     25  # 00/mod/indirect 100/subop/and 101/rm32/use-disp32
-    e0 7e 00 00  # disp32 [label]
+    28 80 00 00  # disp32 [label]
     0f  # imm8
 # 2a9:
   # epilogue
@@ -428,38 +429,10 @@ e9 fd ff  # loop forever
                                     00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-00 00 00 00 00 00 00 00 00 00 00 00
-
-# 2dc:
-# var shift: boolean
-  00 00 00 00
-
-# 2e0:
-# var keyboard circular buffer
-# write index: nibble
-# still take up 4 bytes so SubX can handle it
-  00 00 00 00
-# 2e4:
-# read index: nibble
-# still take up 4 bytes so SubX can handle it
-  00 00 00 00
-# 2e8:
-# circular buffer: byte[16]
-  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-
-# 2f8:
-# idt_descriptor:
-  ff 03  # idt_end - idt_start - 1
-  00 82 00 00  # start = idt_start [label]
-
-# padding
-# 2fe:
-                                          00 00
-
-# offset 300
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# 300:
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
@@ -473,12 +446,43 @@ e9 fd ff  # loop forever
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 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 400
-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 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 400 (address 0x8000): interrupt handler data
+# idt_descriptor:
+  ff 03  # idt_end - idt_start - 1
+  00 82 00 00  # start = idt_start [label]
+
+# padding
+# 406:
+                  00 00 00 00 00 00 00 00 00 00
+
+# 410:
+# var shift: boolean
+  00 00 00 00
+
+# padding
+# 414:
+            00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00
+
+# 428:
+# var keyboard circular buffer
+# write index: nibble
+# still take up 4 bytes so SubX can handle it
+  00 00 00 00
+# 42c:
+# read index: nibble
+# still take up 4 bytes so SubX can handle it
+  00 00 00 00
+# 430:
+# circular buffer: byte[16]
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+# padding
+# 440:
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00