Hi I'm doing boot loader with LBA addressing on Bochs.
When executing int 13h with AH = 42h, the terminal displayed the following information.
00017480939i[BIOS ] int13_diskette: unsupported AH=42
00017481022i[XGUI ] charmap update. Font is 9 x 16
Next at t=17481022
The registers before int 13h instruction are as follow:
<bochs:3> reg
CPU0:
rax: 00000000_00004200 rcx: 00000000_00090001
rdx: 00000000_00000000 rbx: 00000000_00008000
rsp: 00000000_00007be8 rbp: 00000000_00000000
rsi: 00000000_000e7be8 rdi: 00000000_00007fe0
r8 : 00000000_00000000 r9 : 00000000_00000000
r10: 00000000_00000000 r11: 00000000_00000000
r12: 00000000_00000000 r13: 00000000_00000000
r14: 00000000_00000000 r15: 00000000_00000000
rip: 00000000_00007d94
eflags 0x00000202: id vip vif ac vm rf nt IOPL=0 of df IF tf sf zf af pf cf
<bochs:4> sreg
es:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
cs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ss:0x0000, dh=0x00009300, dl=0x0000ffff, valid=7
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ds:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
fs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
gs:0x0000, dh=0x00009300, dl=0x0000ffff, valid=1
Data segment, base=0x00000000, limit=0x0000ffff, Read/Write, Accessed
ldtr:0x0000, dh=0x00008200, dl=0x0000ffff, valid=1
tr:0x0000, dh=0x00008b00, dl=0x0000ffff, valid=1
gdtr:base=0x00000000000f9a37, limit=0x30
idtr:base=0x0000000000000000, limit=0x3ff
And the 16 Bytes DS:SI pointing at are:
<bochs:6> xp /16b 0x7be8
[bochs]:
0x0000000000007be8 <bogus+ 0>: 0x10 0x00 0x01 0x00 0x00 0x80 0x00 0x00
0x0000000000007bf0 <bogus+ 8>: 0x19 0x00 0x00 0x00 0x00 0x00 0x00 0x00
The return value on AH is 0x01, and the CF has been set.
I'm using disk as my boot option, and created a disk image file, part of my bochs configuration are as follow:
boot: disk
floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, path="Boot.img", mode=flat, cylinders=0, heads=0, spt=0, model="Generic 1234", biosdetect=auto, translation=auto
ata0-slave: type=none
My platform is Ubuntu 18.4, Bochs 2.6.9, and the following is my configuration option:
./configure --enable-plugins --enable-debugger --enable-disasm --enable-readline --enable-cpu-level=6 --enable-smp --enable-x86-64 --enable-avx --enable-a20-pin --enable-fast-function-calls --enable-all-optimizations --enable-x86-debugger --enable-alignment-check --enable-sb16
Now my question would be how could I enable the AH=42h option for BIOS.
Thanks!
Most real computers and Bochs support "int 0x13 extensions" for most/larger devices (hard drives, CD/DVD, etc), but don't support it for floppy disks.
The registers before int 13h instruction are as follow:
rdx: 00000000_00000000
This means "DL
= drive number = 0x00 = first floppy disk".
Now my question would be how could I enable the AH=42h option for BIOS.
If you intended to access the first floppy disk using "int 0x13 extensions"; then don't (you'd want to write your own "LBA->CHS" routine that takes the "inserted after boot" floppy disk's geometry into account).
If you intended to access the hard drive you booted from, then very early during the boot loader's startup you want to store the value in DL
("device number for where boot loader came from") that was passed to the boot loader so that you can load it back into DL
for later disk read/writes. Note that this value may not be 0x80 (e.g. any kind of boot manager decided to boot an OS on the second hard drive) and (for partitioned hard disks) a boot loader would also want to store information about the partition it came from (so it can do "LBA = block in my partition + LBA for first sector of my partition" and limit checks).