implement disk parameter reading, tho needs bug fixing
This commit is contained in:
parent
ac89fe8c32
commit
c1277230ce
3 changed files with 66 additions and 2 deletions
2
Makefile
2
Makefile
|
|
@ -97,7 +97,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
|
||||||
$(AS) $(ASFLAGS) -o $@ $<
|
$(AS) $(ASFLAGS) -o $@ $<
|
||||||
$(OBJCOPY) --remove-section .note.gnu.property $@
|
$(OBJCOPY) --remove-section .note.gnu.property $@
|
||||||
|
|
||||||
MBR_TEST_OBJ = obj/mbr_test.o obj/serial.o obj/itoa.o obj/util.o obj/test_disk_enum.o
|
MBR_TEST_OBJ = obj/mbr_test.o obj/serial.o obj/itoa.o obj/util.o obj/test_disk_params.o
|
||||||
|
|
||||||
mbr_test: $(MBR_TEST_OBJ) $(DISK)
|
mbr_test: $(MBR_TEST_OBJ) $(DISK)
|
||||||
$(LD) -T src/mbr_test.ld -o $(BIN_DIR)/mbr_test.bin $(MBR_TEST_OBJ)
|
$(LD) -T src/mbr_test.ld -o $(BIN_DIR)/mbr_test.bin $(MBR_TEST_OBJ)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ entry:
|
||||||
.bootloader:
|
.bootloader:
|
||||||
call serial_init
|
call serial_init
|
||||||
|
|
||||||
call test_disk_enum
|
mov $0x01, %al # disk 1
|
||||||
|
call test_disk_params
|
||||||
.halt:
|
.halt:
|
||||||
jmp .halt
|
jmp .halt
|
||||||
|
|
|
||||||
63
src/test_disk_params.s
Normal file
63
src/test_disk_params.s
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
.section .text
|
||||||
|
.code16
|
||||||
|
|
||||||
|
.globl test_disk_params
|
||||||
|
|
||||||
|
# al - drive number
|
||||||
|
test_disk_params:
|
||||||
|
mov %al, %dl
|
||||||
|
and $128, %dl
|
||||||
|
|
||||||
|
mov $0x08, %al
|
||||||
|
int $0x13
|
||||||
|
|
||||||
|
xor %ax, %ax
|
||||||
|
# write slaves
|
||||||
|
mov %dl, %al
|
||||||
|
movw %ax, disk_slaves
|
||||||
|
# write heads
|
||||||
|
mov %dh, %al
|
||||||
|
movw %ax, disk_heads
|
||||||
|
# write cylinders
|
||||||
|
# write lower part
|
||||||
|
mov %ch, %al
|
||||||
|
# write higher part
|
||||||
|
mov %cl, %ah
|
||||||
|
shr $3, %ah # shift 6 bits to right, because cylinder num's high part is in high 2 bits
|
||||||
|
mov %ax, disk_cylinders
|
||||||
|
# write sectors per cylinder
|
||||||
|
xor %ax, %ax
|
||||||
|
mov %cl, %al
|
||||||
|
and $0b00111111, %al # 6 lower bits are sector count
|
||||||
|
mov %ax, disk_sectors
|
||||||
|
|
||||||
|
# now we can print all this info
|
||||||
|
movw disk_slaves, %ax
|
||||||
|
mov $str_slaves, %si
|
||||||
|
call prints_number
|
||||||
|
|
||||||
|
movw disk_heads, %ax
|
||||||
|
mov $str_heads, %si
|
||||||
|
call prints_number
|
||||||
|
|
||||||
|
movw disk_cylinders, %ax
|
||||||
|
mov $str_cylinders, %si
|
||||||
|
call prints_number
|
||||||
|
|
||||||
|
movw disk_sectors, %ax
|
||||||
|
mov $str_sectors, %si
|
||||||
|
call prints_number
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
.section .rodata
|
||||||
|
str_slaves: .asciz "Disk slaves: "
|
||||||
|
str_heads: .asciz "Disk heads: "
|
||||||
|
str_cylinders: .asciz "Disk cylinders: "
|
||||||
|
str_sectors: .asciz "Disk sectors per cylinder: "
|
||||||
|
|
||||||
|
.section .bss
|
||||||
|
disk_slaves: .word # disk attached slaves
|
||||||
|
disk_heads: .word # number of heads
|
||||||
|
disk_cylinders: .word # number of cylinders
|
||||||
|
disk_sectors: .word # sectors in cylinder
|
||||||
Loading…
Add table
Reference in a new issue