hdprefix.S revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/****************************************************************\
hdprefix.S Copyright (C) 2005 Per Dalgas Jakobsen
This software may be used and distributed according to the terms
of the GNU Public License (GPL), incorporated herein by reference.
hdprefix.S is loaded at 0x0000:0x7c00 by the bios-startup routines.
Actions performed by hdprefix:
1) Load the MBR to LOADSEG:0
2) Check which partition is active (or try first partition if none active)
3) Check wether LBA is supported.
3a) LBA
3a1) Load PAYLOAD_SECTS sectors from chosen partition to LOADSEG:0
3b) CHS (standard)
3b1) Load PAYLOAD_SECTS sectors from chosen partition to LOADSEG:0
4) Check loaded bootsector for BOOTMAGIC code.
5) Jump to payload LOADSEG:ENTRYPOINT.
Output with failure points (!#):
---
Loading (!1)partition #
Std. BIOS(!2) | Ext. BIOS(!3)
Booting...(!4)
(!5)
---
!1: Failed to load MBR with Int13,ah=2.
!2: Failed to load bootrecord+payload with Int13,ah=2.
!3: Failed to load bootrecord+payload with Int13,ah=42.
!4: Invalid BOOTMAGIC in loaded bootrecord.
!5: Jumping to payload.
\*****************************************************************/
/-------------------------------------------------------------
.text
/****************************************************************/
/* support routines. */
/*--------------------------------------------------------------*/
/* stop execution - should probably have option to auto-reboot after delay. */
/*--------------------------------------------------------------*/
/* cx = count, ds:si = string. */
int $0x10
/*--------------------------------------------------------------*/
/* al = char. */
int $0x10
/*--------------------------------------------------------------*/
/* - */
/*--------------------------------------------------------------*/
/* dx = value */
/* fall through */
int $0x10
/****************************************************************/
_go:
/*--- load MBR so we can use its partition table. ---*/
int $0x13
/*--- find the active partition ---*/
/*- no partitions marked active - use 1. partition. */
/*--- check for lba support ---*/
int $0x13
/*--- use lba bios calls to read sectors ---*/
_lba:
int $0x13
/*--- use standard bios calls to read sectors ---*/
int $0x13
/* check if it has a valid bootrecord. */
/* call the payload. */
pushl $0 /* No parameters to preserve for exit path */
pushw $0 /* Use prefix exit path mechanism */
int $0x19 /* should try to boot machine */
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
.byte 0 /* reserved */
_bios_lba_low: .word 0
_bios_lba_high: .word 0
.word 0
.word 0
.rept 32
.byte 0
.endr
/*--- Partition table ------------------------------------------*/
.org 446, 0
.rept 64
.byte 0
.endr
/*--- Magic code -----------------------------------------------*/
.org 510, 0
/*** END ********************************************************/