From e552b31989dbb36f780428332be1b4958d26a37b Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 14 Apr 2018 09:28:47 +0300 Subject: [PATCH] fixed partial loading bug --- Makefile | 2 +- src/boot/boot.s | 36 +++++++++--------------------------- src/boot/boot2.s | 54 +++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 500acb6..7e0f1b0 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ $(elf): $(obj) .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(obj) $(bin) floppy.img .PHONY: cleandep cleandep: diff --git a/src/boot/boot.s b/src/boot/boot.s index 4ab605c..b9e1a76 100644 --- a/src/boot/boot.s +++ b/src/boot/boot.s @@ -63,10 +63,7 @@ read_sectors: ret .set VAR_ATTEMPTS, -2 -str_rdsec_msg: .asciz "rdsec: " -str_cyl_msg: .asciz " C " -str_head_msg: .asciz " H " -str_sec_msg: .asciz " S " +#str_rdsec_msg: .asciz "rdsec: " # read_sector(sidx) read_sector: @@ -81,8 +78,8 @@ read_sector: .Lread_try: # calculate the track (sidx / sectors_per_track) mov 4(%bp), %ax - mov $str_rdsec_msg, %si - call print_str_num16 +# mov $str_rdsec_msg, %si +# call print_str_num16 xor %dx, %dx mov $SECT_PER_TRACK, %cx @@ -101,23 +98,6 @@ read_sector: inc %al or %al, %cl - mov $str_cyl_msg, %si - mov %cx, %ax - rol $2, %al - and $3, %al - ror $8, %ax - call print_str_num16 - - mov $str_head_msg, %si - xor %ax, %ax - mov %dh, %al - call print_str_num16 - - mov $str_sec_msg, %si - mov %cl, %al - and $0x3f, %ax - call print_str_num16 - # ah = 2 (read), al = 1 sectors mov $0x0201, %ax movb drive_number, %dl @@ -139,13 +119,13 @@ read_sector: .Lread_ok: # DBG print first dword - mov $str_read_error + 4, %si - mov %es:(%bx), %eax - call print_str_num +# mov $str_read_error + 4, %si +# mov %es:(%bx), %eax +# call print_str_num # increment es:bx accordingly (advance es if bx overflows) add $512, %bx - jno 0f + jnc 0f mov %es, %ax add $4096, %ax mov %ax, %es @@ -213,6 +193,7 @@ print_str: ret # expects number in eax + .global print_num print_num: # save registers push %es @@ -303,6 +284,7 @@ setup_serial: ret # expects a character in al + .global ser_putchar ser_putchar: push %dx diff --git a/src/boot/boot2.s b/src/boot/boot2.s index 7b8c7bb..86ee611 100644 --- a/src/boot/boot2.s +++ b/src/boot/boot2.s @@ -2,6 +2,9 @@ .code16 .section .boot2,"a" + .extern print_num + .extern ser_putchar + mov $0x13, %ax int $0x10 @@ -9,27 +12,58 @@ mov $logo_pal, %si xor %cl, %cl -0: mov $0x3c8, %dx +0: xor %eax, %eax + mov $0x3c8, %dx movb %cl, %al outb %al, %dx + #DBG + call print_num + mov $58, %al + call ser_putchar + mov $32, %al + call ser_putchar + xor %eax, %eax + #### inc %dx # red movb (%si), %al inc %si shr $2, %al outb %al, %dx + #DBG + call print_num + mov $32, %al + call ser_putchar + xor %eax, %eax + #### # green movb (%si), %al inc %si shr $2, %al outb %al, %dx + #DBG + call print_num + mov $32, %al + call ser_putchar + xor %eax, %eax + #### # blue movb (%si), %al inc %si shr $2, %al outb %al, %dx - inc %cl - jno 0b + #DBG + call print_num + mov $32, %al + call ser_putchar + mov $13, %al + call ser_putchar + mov $10, %al + call ser_putchar + xor %eax, %eax + #### + add $1, %cl + jnc 0b # copy pixels pushw $0xa000 @@ -45,20 +79,6 @@ cli hlt -set_palette: - mov %sp, %bp - mov $0x3c8, %dx - movw 2(%bp), %ax - outb %al, %dx - inc %dx - movw 4(%bp), %ax - outb %al, %dx - movw 6(%bp), %ax - outb %al, %dx - movw 8(%bp), %ax - outb %al, %dx - ret - logo_pal: .incbin "logo.pal" -- 1.7.10.4