From 8c0b93a9c39340639cf57c7911ff69a42aaa97d4 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 23 Jan 2021 23:14:34 -0800 Subject: 7552 - I better understand a couple of things --- html/baremetal/boot.hex.html | 472 ++++++++++++++++++++++--------------------- 1 file changed, 242 insertions(+), 230 deletions(-) (limited to 'html/baremetal') diff --git a/html/baremetal/boot.hex.html b/html/baremetal/boot.hex.html index 7f666df4..7e72f177 100644 --- a/html/baremetal/boot.hex.html +++ b/html/baremetal/boot.hex.html @@ -254,173 +254,173 @@ if ('onhashchange' in window) { 199 0f 01 1d # lidt 00/mod/indirect 011/subop 101/rm32/use-disp32 200 f8 7d 00 00 # *idt_descriptor [label] 201 -202 # enable keyboard IRQ -203 b0 fd # al <- 0xfd # enable just IRQ1 -204 e6 21 # port 0x21 <- al -205 -206 # initialization is done; enable interrupts -207 fb -208 e9 01 13 00 00 # jump to 0x9000 [label] -209 -210 # padding -211 # ff: -212 00 -213 -214 # 100: -215 # null interrupt handler: -216 cf # iret -217 -218 # padding -219 # 101: -220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -221 -222 # 110: -223 # keyboard interrupt handler: -224 # prologue -225 fa # disable interrupts -226 60 # push all registers to stack -227 # acknowledge interrupt -228 b0 20 # al <- 0x20 -229 e6 20 # port 0x20 <- al -230 # read status into eax -231 31 c0 # eax <- xor eax; 11/direct 000/r32/eax 000/rm32/eax -232 e4 64 # al <- port 0x64 -233 # if (status & 0x1) == 0, return -234 24 01 # al <- and 0x1 -235 3c 00 # compare al, 0 -236 74 39 # jump to epilogue if = [label] -237 # 120: -238 # if keyboard buffer is full, return -239 31 c9 # ecx <- xor ecx; 11/direct 001/r32/ecx 001/rm32/ecx -240 # . var index/ecx: byte -241 8a # copy m8 at r32 to r8 -242 0d # 00/mod/indirect 001/r8/cl 101/rm32/use-disp32 -243 c8 7d 00 00 # disp32 [label] -244 # . al = *(keyboard buffer + index) -245 8a # copy m8 at r32 to r8 -246 81 # 10/mod/*+disp32 000/r8/al 001/rm32/ecx -247 d0 7d 00 00 # disp32 [label] -248 # . if (al != 0) return -249 3c 00 # compare al, 0 -250 # 130: -251 75 27 # jump to epilogue if != [label] -252 # read keycode into al -253 e4 60 # al <- port 0x60 -254 # if (al & 0x80) a key is being lifted; return -255 50 # push eax -256 24 80 # al <- and 0x80 -257 3c 00 # compare al, 0 -258 58 # pop to eax (without touching flags) -259 75 1d # jump to epilogue if != [label] -260 # 13c: -261 # al <- *(keyboard normal map + eax) -262 8a # copy m8 at rm32 to r8 -263 80 # 10/mod/*+disp32 000/r8/al 000/rm32/eax -264 00 80 00 00 # disp32 [label] -265 # if there's no character mapping, return +202 # For now, not bothering reprogramming the IRQ to not conflict with software +203 # exceptions. +204 # https://wiki.osdev.org/index.php?title=8259_PIC&oldid=24650#Protected_Mode +205 # +206 # Interrupt 1 (keyboard) conflicts with debugger faults. We don't use a +207 # debugger. +208 # Reference: +209 # https://wiki.osdev.org/Exceptions +210 +211 # enable keyboard IRQ (1) +212 b0 fd # al <- 0xfd # disable mask for IRQ1 +213 e6 21 # port 0x21 <- al +214 +215 # initialization is done; enable interrupts +216 fb +217 e9 01 13 00 00 # jump to 0x9000 [label] +218 +219 # padding +220 # ff: +221 00 +222 +223 # 100: +224 # null interrupt handler: +225 cf # iret +226 +227 # padding +228 # 101: +229 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +230 +231 # 110: +232 # keyboard interrupt handler: +233 # prologue +234 fa # disable interrupts +235 60 # push all registers to stack +236 # acknowledge interrupt +237 b0 20 # al <- 0x20 +238 e6 20 # port 0x20 <- al +239 # read status into eax +240 31 c0 # eax <- xor eax; 11/direct 000/r32/eax 000/rm32/eax +241 e4 64 # al <- port 0x64 +242 # if (status & 0x1) == 0, return +243 24 01 # al <- and 0x1 +244 3c 00 # compare al, 0 +245 74 39 # jump to epilogue if = [label] +246 # 120: +247 # if keyboard buffer is full, return +248 31 c9 # ecx <- xor ecx; 11/direct 001/r32/ecx 001/rm32/ecx +249 # . var index/ecx: byte +250 8a # copy m8 at r32 to r8 +251 0d # 00/mod/indirect 001/r8/cl 101/rm32/use-disp32 +252 c8 7d 00 00 # disp32 [label] +253 # . al = *(keyboard buffer + index) +254 8a # copy m8 at r32 to r8 +255 81 # 10/mod/*+disp32 000/r8/al 001/rm32/ecx +256 d0 7d 00 00 # disp32 [label] +257 # . if (al != 0) return +258 3c 00 # compare al, 0 +259 # 130: +260 75 27 # jump to epilogue if != [label] +261 # read keycode into al +262 e4 60 # al <- port 0x60 +263 # if (al & 0x80) a key is being lifted; return +264 50 # push eax +265 24 80 # al <- and 0x80 266 3c 00 # compare al, 0 -267 74 13 # jump to epilogue if = [label] -268 # 146: -269 # store al in keyboard buffer -270 88 # copy r8 to m8 at r32 -271 81 # 10/mod/*+disp32 000/r8/al 001/rm32/ecx -272 d0 7d 00 00 # disp32 [label] -273 # 14c: -274 # increment index -275 fe # increment byte -276 05 # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32 -277 c8 7d 00 00 # disp32 [label] -278 # clear top nibble of index (keyboard buffer is circular) -279 80 # and byte -280 25 # 00/mod/indirect 100/subop/and 101/rm32/use-disp32 -281 c8 7d 00 00 # disp32 [label] -282 0f # imm8 -283 # 159: -284 # epilogue -285 61 # pop all registers -286 fb # enable interrupts -287 cf # iret -288 -289 # padding -290 # 15c: -291 00 00 00 00 -292 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -293 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -294 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -295 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -296 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -297 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -298 00 00 00 00 00 00 00 00 -299 -300 # 1c8: -301 # var keyboard circular buffer -302 # write index: nibble -303 # still take up 4 bytes so SubX can handle it -304 00 00 00 00 -305 # 1cc: -306 # read index: nibble -307 # still take up 4 bytes so SubX can handle it -308 00 00 00 00 -309 # 1d0: -310 # circular buffer: byte[16] -311 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -312 -313 # padding -314 # 1e0: -315 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -316 00 00 00 00 00 00 00 00 -317 -318 # 1f8: -319 # idt_descriptor: -320 ff 00 # idt_end - idt_start - 1 -321 00 7e 00 00 # start = idt_start [label] -322 -323 # 1fe: -324 # final 2 bytes of boot sector -325 55 aa +267 58 # pop to eax (without touching flags) +268 75 1d # jump to epilogue if != [label] +269 # 13c: +270 # al <- *(keyboard normal map + eax) +271 8a # copy m8 at rm32 to r8 +272 80 # 10/mod/*+disp32 000/r8/al 000/rm32/eax +273 00 80 00 00 # disp32 [label] +274 # if there's no character mapping, return +275 3c 00 # compare al, 0 +276 74 13 # jump to epilogue if = [label] +277 # 146: +278 # store al in keyboard buffer +279 88 # copy r8 to m8 at r32 +280 81 # 10/mod/*+disp32 000/r8/al 001/rm32/ecx +281 d0 7d 00 00 # disp32 [label] +282 # 14c: +283 # increment index +284 fe # increment byte +285 05 # 00/mod/indirect 000/subop/increment 101/rm32/use-disp32 +286 c8 7d 00 00 # disp32 [label] +287 # clear top nibble of index (keyboard buffer is circular) +288 80 # and byte +289 25 # 00/mod/indirect 100/subop/and 101/rm32/use-disp32 +290 c8 7d 00 00 # disp32 [label] +291 0f # imm8 +292 # 159: +293 # epilogue +294 61 # pop all registers +295 fb # enable interrupts +296 cf # iret +297 +298 # padding +299 # 15c: +300 00 00 00 00 +301 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +302 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +303 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +304 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +305 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +306 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +307 00 00 00 00 00 00 00 00 +308 +309 # 1c8: +310 # var keyboard circular buffer +311 # write index: nibble +312 # still take up 4 bytes so SubX can handle it +313 00 00 00 00 +314 # 1cc: +315 # read index: nibble +316 # still take up 4 bytes so SubX can handle it +317 00 00 00 00 +318 # 1d0: +319 # circular buffer: byte[16] +320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +321 +322 # padding +323 # 1e0: +324 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +325 00 00 00 00 00 00 00 00 326 -327 ## sector 2 -328 # loaded by load_disk, not automatically on boot -329 -330 # offset 200 (address 0x7e00): interrupt descriptor table -331 # 32 entries * 8 bytes each = 256 bytes (0x100) -332 # idt_start: -333 -334 00 00 00 00 00 00 00 00 -335 00 00 00 00 00 00 00 00 -336 00 00 00 00 00 00 00 00 -337 00 00 00 00 00 00 00 00 -338 00 00 00 00 00 00 00 00 -339 00 00 00 00 00 00 00 00 -340 00 00 00 00 00 00 00 00 -341 00 00 00 00 00 00 00 00 +327 # 1f8: +328 # idt_descriptor: +329 ff 00 # idt_end - idt_start - 1 +330 00 7e 00 00 # start = idt_start [label] +331 +332 # 1fe: +333 # final 2 bytes of boot sector +334 55 aa +335 +336 ## sector 2 +337 # loaded by load_disk, not automatically on boot +338 +339 # offset 200 (address 0x7e00): interrupt descriptor table +340 # 32 entries * 8 bytes each = 256 bytes (0x100) +341 # idt_start: 342 -343 # entry 8: clock -344 00 7d # target[0:16] = null interrupt handler [label] -345 08 00 # segment selector (gdt_code) -346 00 # unused -347 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate -348 00 00 # target[16:32] -349 -350 # entry 9: keyboard -351 10 7d # target[0:16] = keyboard interrupt handler [label] -352 08 00 # segment selector (gdt_code) -353 00 # unused -354 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate -355 00 00 # target[16:32] -356 -357 00 00 00 00 00 00 00 00 -358 00 00 00 00 00 00 00 00 -359 00 00 00 00 00 00 00 00 -360 00 00 00 00 00 00 00 00 -361 00 00 00 00 00 00 00 00 -362 00 00 00 00 00 00 00 00 -363 00 00 00 00 00 00 00 00 -364 00 00 00 00 00 00 00 00 -365 00 00 00 00 00 00 00 00 -366 00 00 00 00 00 00 00 00 -367 00 00 00 00 00 00 00 00 -368 00 00 00 00 00 00 00 00 +343 00 00 00 00 00 00 00 00 +344 00 00 00 00 00 00 00 00 +345 00 00 00 00 00 00 00 00 +346 00 00 00 00 00 00 00 00 +347 00 00 00 00 00 00 00 00 +348 00 00 00 00 00 00 00 00 +349 00 00 00 00 00 00 00 00 +350 00 00 00 00 00 00 00 00 +351 +352 # By default, BIOS maps IRQ0-7 to interrupt vectors 8-15. +353 # https://wiki.osdev.org/index.php?title=Interrupts&oldid=25102#Default_PC_Interrupt_Vector_Assignment +354 +355 # entry 8: clock +356 00 7d # target[0:16] = null interrupt handler [label] +357 08 00 # segment selector (gdt_code) +358 00 # unused +359 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate +360 00 00 # target[16:32] +361 +362 # entry 9: keyboard +363 10 7d # target[0:16] = keyboard interrupt handler [label] +364 08 00 # segment selector (gdt_code) +365 00 # unused +366 8e # 1/p 00/dpl 0 1110/type/32-bit-interrupt-gate +367 00 00 # target[16:32] +368 369 00 00 00 00 00 00 00 00 370 00 00 00 00 00 00 00 00 371 00 00 00 00 00 00 00 00 @@ -431,73 +431,85 @@ if ('onhashchange' in window) { 376 00 00 00 00 00 00 00 00 377 00 00 00 00 00 00 00 00 378 00 00 00 00 00 00 00 00 -379 # idt_end: -380 -381 # offset 300 (address 0x7f00): -382 # video mode info: -383 00 00 # attributes -384 00 # winA -385 00 # winB -386 # 304 -387 00 00 # granularity -388 00 00 # winsize -389 # 308 -390 00 00 # segmentA -391 00 00 # segmentB -392 # 30c -393 00 00 00 00 # realFctPtr (who knows) -394 # 310 -395 00 00 # pitch -396 00 00 # Xres -397 # 314 -398 00 00 # Yres -399 00 00 # Wchar Ychar -400 # 318 -401 00 # planes -402 00 # bpp -403 00 # banks -404 00 # memory_model -405 # 31c -406 00 # bank_size -407 00 # image_pages -408 00 # reserved -409 # 31f -410 00 00 # red_mask red_position -411 00 00 # green_mask green_position -412 00 00 # blue_mask blue_position -413 00 00 # rsv_mask rsv_position -414 00 # directcolor_attributes -415 # 328 -416 00 00 00 00 # physbase <== linear frame buffer -417 -418 # 32c -419 # reserved for video mode info -420 00 00 00 00 -421 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -422 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -423 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -424 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -425 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -426 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -427 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -428 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -429 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -430 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -431 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -432 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +379 00 00 00 00 00 00 00 00 +380 00 00 00 00 00 00 00 00 +381 00 00 00 00 00 00 00 00 +382 00 00 00 00 00 00 00 00 +383 00 00 00 00 00 00 00 00 +384 00 00 00 00 00 00 00 00 +385 00 00 00 00 00 00 00 00 +386 00 00 00 00 00 00 00 00 +387 00 00 00 00 00 00 00 00 +388 00 00 00 00 00 00 00 00 +389 00 00 00 00 00 00 00 00 +390 00 00 00 00 00 00 00 00 +391 # idt_end: +392 +393 # offset 300 (address 0x7f00): +394 # video mode info: +395 00 00 # attributes +396 00 # winA +397 00 # winB +398 # 304 +399 00 00 # granularity +400 00 00 # winsize +401 # 308 +402 00 00 # segmentA +403 00 00 # segmentB +404 # 30c +405 00 00 00 00 # realFctPtr (who knows) +406 # 310 +407 00 00 # pitch +408 00 00 # Xres +409 # 314 +410 00 00 # Yres +411 00 00 # Wchar Ychar +412 # 318 +413 00 # planes +414 00 # bpp +415 00 # banks +416 00 # memory_model +417 # 31c +418 00 # bank_size +419 00 # image_pages +420 00 # reserved +421 # 31f +422 00 00 # red_mask red_position +423 00 00 # green_mask green_position +424 00 00 # blue_mask blue_position +425 00 00 # rsv_mask rsv_position +426 00 # directcolor_attributes +427 # 328 +428 00 00 00 00 # physbase <== linear frame buffer +429 +430 # 32c +431 # reserved for video mode info +432 00 00 00 00 433 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -434 -435 ## the rest of this file has data -436 -437 # offset 400 (address 0x8000): -438 +--161 lines: # translating keys to ASCII ----------------------------------------------------------------------------------------------------------------------------------------------- -599 -600 # offset c00 (address 0x8800) -601 +--236 lines: # Bitmaps for some ASCII characters (soon Unicode) ------------------------------------------------------------------------------------------------------------------------ -837 -838 # offset 1400 (address 0x9000) -839 -840 # vim:ft=subx +434 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +435 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +436 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +437 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +438 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +439 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +440 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +441 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +442 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +443 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +444 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +445 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +446 +447 ## the rest of this file has data +448 +449 # offset 400 (address 0x8000): +450 +--161 lines: # translating keys to ASCII ----------------------------------------------------------------------------------------------------------------------------------------------- +611 +612 # offset c00 (address 0x8800) +613 +--236 lines: # Bitmaps for some ASCII characters (soon Unicode) ------------------------------------------------------------------------------------------------------------------------ +849 +850 # offset 1400 (address 0x9000) +851 +852 # vim:ft=subx -- cgit 1.4.1-2-gfad0