From 9d33f23c9bbb0f308ca6dab3fca16a128247e283 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Mon, 16 Feb 2015 14:27:35 -0500 Subject: [PATCH] diag/geodsp: update Print drive number at start. Print '!' before data when an error is encountered (but continue). Several macros to change codesize. Code refactoring to reduce size. Signed-off-by: Gene Cumm --- diag/geodsp/geodsp1s.asm | 97 +++++++++++++++++++++++++++++------------------ diag/geodsp/geodsplib.inc | 61 ++++++++++++++++++++--------- diag/geodsp/geodspms.asm | 29 +++++--------- 3 files changed, 113 insertions(+), 74 deletions(-) diff --git a/diag/geodsp/geodsp1s.asm b/diag/geodsp/geodsp1s.asm index 4ea84c4a..741c51f8 100644 --- a/diag/geodsp/geodsp1s.asm +++ b/diag/geodsp/geodsp1s.asm @@ -1,6 +1,6 @@ ; ----------------------------------------------------------------------- ; -; Copyright 2010 Gene Cumm +; Copyright 2010-2014 Gene Cumm ; ; Portions from diskstart.inc: ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved @@ -55,7 +55,14 @@ retry_count equ 16 dbuf equ 8000h int13_ret equ 7e00h - +; Uncomment to test EDD +%define TEST_EDD 1 +; Uncomment to show errors (while it still continues) +%define SHOW_ERR 1 +; Uncomment to have room for a partition table +%define HAVE_PTABLE 1 +; Uncomment to force DL == 80h +; %define FORCE_80 1 ; extern real_mode_seg ; section .real_mode write nobits align=65536 @@ -82,24 +89,43 @@ start: xor cx,cx mov ss,cx mov sp,StackBuf-2 ; Just below BSS (-2 for alignment) +%ifdef FORCE_80 + mov dl,80h ; Should encode as B2h 80h +%else + nop ; Reserve the space for forcing DL + nop ; Should encode as 90h 90h +%endif ; FORCE_80 push dx ; Save drive number (in DL) ; Kill everything else and let the BIOS sort it out later mov es,cx mov ds,cx sti +; clc ; just in case it's not clear + +write_drivenum: +; mov al,[DriveNumber] + mov al,dl + call writehex2 get_geo: ; DL and ES ready mov ah,08h mov di,0 int 13h write_geo: - jc .bad_geo + jnc .ok_geo +%ifdef SHOW_ERR + mov al,'!' + call writechr +%endif ; SHOW_ERR + clc +.ok_geo: mov si,s_chs call writestr_early call write_chs - call crlf - jmp short .done -.bad_geo: + mov si,s_crlf + call writestr_early +; jmp short .done +; .bad_geo: .done: mov bx,dbuf @@ -117,8 +143,9 @@ get_c1c: ; 1,0,1 ; ; Do we have EBIOS (EDD)? ; -edd: -.check: +%ifdef TEST_EDD + edd: + .check: mov bx,55AAh mov ah,41h ; EDD existence query mov dl,[DriveNumber] @@ -134,21 +161,22 @@ edd: mov bx,dbuf xor edx,edx mov dword [s_chs],m_EDD_SP -.get_lba63: + .get_lba63: mov eax,63 ; Same length as mov al,64; movzx eax,al call getonesec_ebios jc .bad_edd ;read error call write_edd_lba -.get_lba16065: + .get_lba16065: mov eax,16065 call getonesec_ebios jc .bad_edd ;read error call write_edd_lba -.good_edd: + .good_edd: mov dword [s_type],m_EDD0 -.bad_edd: -.noedd: -.end: + .bad_edd: + .noedd: + .end: +%endif ; TEST_EDD write_final_type: mov si,s_typespec @@ -161,9 +189,10 @@ write_final_type: ; ; getonesec implementation for EBIOS (EDD) ; -getonesec_ebios: +%ifdef TEST_EDD + getonesec_ebios: mov cx,retry_count -.retry: + .retry: ; Form DAPA on stack push edx push eax @@ -180,7 +209,7 @@ getonesec_ebios: jc .error ret -.error: + .error: ; Some systems seem to get "stuck" in an error state when ; using EBIOS. Doesn't happen when using CBIOS, which is ; good, since some other systems get timeout failures @@ -195,6 +224,7 @@ getonesec_ebios: ; Total failure. stc ret +%endif ; TEST_EDD ; ; getonesec_chs: @@ -208,7 +238,13 @@ getonesec_chs: ; We could use an xchg and get a loop mov ax,0201h ; Read one sector call xint13 popad - jc .error + jnc .no_error +%ifdef SHOW_ERR + mov al,'!' + call writechr +%endif ; SHOW_ERR + clc +.no_error: ret .error: @@ -217,8 +253,8 @@ getonesec_chs: ; We could use an xchg and get a loop ; ; kaboom: write a message and bail out. ; - global kaboom disk_error: + global kaboom kaboom: .patch: mov si,bailmsg @@ -240,30 +276,19 @@ xint13: mov [int13_ret],ax ret -; -; -; writestr_early: write a null-terminated string to the console -; This assumes we're on page 0. This is only used for early -; messages, so it should be OK. -; -writestr_early: - pushad -.loop: lodsb - and al,al - jz .return - call writechr - jmp short .loop -.return: popad - ret - %include "geodsplib.inc" bailmsg equ s_end - ; This fails if the boot sector overflowsg +%ifdef HAVE_PTABLE + ; This fails if the boot sector overflows into the partition table zb 1BEh-($-$$) ptable zb 40h ; Partition table +%endif ; HAVE_PTABLE bootsignature dw 0xAA55 + ; This fails if the boot sector overflows + zb 200h-($-$$) + sector_2: diff --git a/diag/geodsp/geodsplib.inc b/diag/geodsp/geodsplib.inc index 5d6f7051..9f6eafcf 100644 --- a/diag/geodsp/geodsplib.inc +++ b/diag/geodsp/geodsplib.inc @@ -1,6 +1,6 @@ ; ----------------------------------------------------------------------- ; -; Copyright 2010 Gene Cumm +; Copyright 2010-2014 Gene Cumm ; ; Portions from diskstart.inc: ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved @@ -22,22 +22,18 @@ ; ES:BX points to the buffer with address ; DX,CX as they should be for INT13h,AH=02 - ; For now assume C<256 + ; Should work for C>=256 write_chs_lba: - pushad +; pushad mov si,s_atchs call writestr_early call write_chs - mov al,':' - call writechr - mov eax,[es:bx] - call writehex8 - call crlf - popad + call write_col_val_crlf +; popad ret ; DX,CX as they should be for INT13h,AH=02 - ; For now assume C<256 + ; Should work for C>=256 write_chs: pushad mov al,ch @@ -56,25 +52,54 @@ write_chs: popad ret -write_edd_lba: +%ifdef TEST_EDD + write_edd_lba: pushad mov si,s_atchs call writestr_early call writehex8 + call write_col_val_crlf + popad + ret +%endif ; TEST_EDD + +write_col_val_crlf: mov al,':' call writechr mov eax,[es:bx] call writehex8 - call crlf - popad + mov si,s_crlf + call writestr_early ret +; write_exc: +; ; push ax +; mov al,'!' +; call writechr +; ; pop ax +; ret -crlf: - push si - mov si,s_crlf - call writestr_early - pop si +; crlf: +; push si +; mov si,s_crlf +; call writestr_early +; pop si +; ret + +; +; +; writestr_early: write a null-terminated string to the console +; This assumes we're on page 0. This is only used for early +; messages, so it should be OK. +; +writestr_early: + pushad +.loop: lodsb + and al,al + jz .return + call writechr + jmp short .loop +.return: popad ret writechr: diff --git a/diag/geodsp/geodspms.asm b/diag/geodsp/geodspms.asm index bd411eb1..0bc46a7c 100644 --- a/diag/geodsp/geodspms.asm +++ b/diag/geodsp/geodspms.asm @@ -55,6 +55,12 @@ LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with Sect1Ptr0_VAL equ 1 Sect1Ptr1_VAL equ 0 + ; Uncomment to test EDD +%define TEST_EDD 1 + ; Uncomment to show errors (while it still continues) +%define SHOW_ERR 1 + + ; global STACK_LEN, STACK_TOP, STACK_BASE ; STACK_LEN equ 4096 STACK_TOP equ 7c00h @@ -86,7 +92,8 @@ write_geo: mov si,s_chs call writestr_early call write_chs - call crlf + mov si,s_crlf + call writestr_early jmp short .done .bad_geo: .done: @@ -166,27 +173,9 @@ getonesec_chs: ; We could use an xchg and get a loop %include "geodsplib.inc" -; -; -; writestr_early: write a null-terminated string to the console -; This assumes we're on page 0. This is only used for early -; messages, so it should be OK. -; -writestr_early: - pushad -.loop: lodsb - and al,al - jz .return - mov ah,0Eh ; Write to screen as TTY - mov bx,0007h ; Attribute - int 10h - jmp short .loop -.return: popad - ret - SuperInfo: zd 32 ; The first 16 bytes expanded 8 times - ; This fails if the sector overflowsg + ; This fails if the sector overflows zb 400h-($-$$) end: -- 2.11.4.GIT