;======================================================================= ; ; Emergency boot sector to boot from a floppy from a bootable partition ; marked on the harddrive ; ; Copyright 1999 by Sean Conner. All Rights Reserved. ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ; ; Comments, questions and criticisms can be sent to: sean@conman.org ; ;--------------------------------------------------------------------- ; ; To attempt to use: ; ; GenericOSPrompt> nasm htboot.a ; GenericOSPrompt> dd if=htboot of=/dev/fd0 ; ; If you have to ask, you probably can't use this. ; ;===================================================================== org $8000 ;final resting place entry: xor ax,ax mov ss,ax mov sp,$7c00 mov ax,cs mov ds,ax mov es,ax cld sti mov al,'A' call tag mov si,$7c00 ;move ourselves out mov di,$8000 ;of the way mov cx,256 rep movsw db $0ea dw resume dw $0000 resume: mov ah,0 ;which is here, were we mov dl,$80 ;reset the disk int $13 mov al,'B' call tag mov ax,$0201 ;read 1 sector mov bx,$7e00 mov cx,$0001 ;track 0, sector 1 mov dx,$0080 ;head 0, 1st hard drive int $13 jnc .okay mov ah,$0e mov bx,$0007 mov si,t_readerr1 call boot_display jmp reboot .okay mov si,$7e00+$01be mov cx,4 mov al,'C' call tag mov al,'1' .scantable test byte [si],$80 ;test bit instead of jnz .found ;direct compare call tag inc al add si,16 loop .scantable mov ah,$0e mov bx,$0007 mov si,t_nobootpart call boot_display jmp reboot .found push si mov ah,$00 mov dl,$80 int $13 pop si mov al,'D' call tag push si mov ax,$0201 mov cx,[si+2] mov dh,[si+1] mov dl,$80 mov bx,$7c00 int 13h pop si jnc .okay.10 mov ah,$0e mov bx,$0007 mov si,t_readerr2 call boot_display jmp reboot .okay.10 mov al,'E' call tag mov ax,$0201 mov cx,[si+2] mov dh,[si+1] mov dl,$80 jmp $7c00 ;db $0ea ;dw $7c00 ;dw $0000 ;------------------------------------------------------------- ; BOOT_DISPLAY display a message during boot phase ;Entry: SI - string ; AH - $0E ; BH - BIOS text page ; BL - attribute of character ;Exit: SI - end of string ; AL - 0 ; BP - may be destroyed (BIOS dependant) ;------------------------------------------------------------- boot_disp10: int $10 boot_display: lodsb or al,al jnz boot_disp10 ret ;------------------------------------------------------------- ; REBOOT Pause and reboot the machine ;Entry: none ;Exit: if there is, it's an error ;------------------------------------------------------------- reboot: mov ah,$0e mov bx,$0007 mov si,t_reboot call boot_display mov ah,0 int $16 int $19 .stop hlt jmp .stop ;------------------------------------------------------------ ; TAG note our location ;Entry: AL - character ;Exit: none ;------------------------------------------------------------ tag: push ax push bx mov ah,$0e mov bx,$0007 int $10 pop bx pop ax ret ;------------------------------------------------------------ t_readerr1 db 'Problem reading partition table',13,10,0 t_readerr2 db 'Problem reading boot sector',13,10,0 t_nobootpart db 'No active boot partition',13,10,0 t_reboot db 'Press a key to reboot system ...',0 times (510-($-$$)) db 0 db $055,$0aa end