floppyprefix.S revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* NOTE: this boot sector contains instructions that need at least an 80186.
* Yes, as86 has a bug somewhere in the valid instruction set checks.
*
* SYS_SIZE is the number of clicks (16 bytes) to be loaded. For Etherboot
* purposes, we need to load everything but the boot sector itself, i.e. 32
* clicks less than the size of the entire (verbatim) image. The image size
* is practically limited only by the available base memory size.
*/
/* floppyload.S Copyright (C) 1991, 1992 Linus Torvalds
* modified by Drew Eckhardt
* modified by Bruce Evans (bde)
*
* floppyprefix.S is loaded at 0x0000:0x7c00 by the bios-startup routines.
*
* It then loads the system at SYSSEG<<4, using BIOS interrupts.
*
* The loader has been made as simple as possible, and continuous read errors
* will result in a unbreakable loop. Reboot by hand. It loads pretty fast by
* getting whole tracks at a time whenever possible.
*/
.org 0
.text
go:
/* of bootsect + room for stack + 12 for */
/* saved disk parm block */
/* Many BIOS's default disk parameter tables will not recognize multi-sector
* reads beyond the maximum sector number specified in the default diskette
* parameter tables - this may mean 7 sectors in some cases.
*
* Since single sector reads are slow and out of the question, we must take care
* of this by creating new parameter tables (for the first disk) in RAM. We
* will set the maximum sector count to 36 - the most we will encounter on an
* ED 2.88. High doesn't hurt. Low does.
*
* Segments are as follows: ds=es=ss=cs - BOOTSEG
*/
/* 0:bx is parameter table address */
movsw /* ds:si is source, es:di is dest */
/* Note that es is already set up. Also cx is 0 from rep movsw above. */
int $0x13
*
* It seems that there is no BIOS call to get the number of sectors. Guess
* 36 sectors if sector 36 can be read, 18 sectors if sector 18 can be read,
* 15 if sector 15 can be read. Otherwise guess 9.
*/
cbtw /* extend to word */
/* (512 bytes from origin, es = cs) */
int $0x13
/* ok, we've written the Loading... message, now we want to load the system */
/* This turns off the floppy drive motor, so that we enter the kernel in a
* known state, and don't have to worry about it later.
*/
/* Restore original disk parameters */
/* after that (everything loaded), we call to the .ROM file loaded. */
pushl $0 /* No parameters to preserve for exit path */
pushw $0 /* Use prefix exit path mechanism */
int $0x18 /* should try to boot machine */
/* This routine loads the system at address SYSSEG<<4, making sure no 64kB
* boundaries are crossed. We try to load it as fast as possible, loading whole
* tracks whenever we can.
*
* in: es - starting address segment (normally SYSSEG)
*/
int $0x10
int $0x13
int $0x13
/* print_all is for debugging purposes. It will print out all of the registers.
* The assumption is that this is called from a routine, with a stack frame like
* dx
* cx
* bx
* ax
* error
* ret <- sp
*/
int $0x10
int $0x10
int $0x10
int $0x10
int $0x10
int $0x10
int $0x10
/* print_hex prints the word pointed to by ss:bp in hexadecimal. */
/* fall through */
int $0x10
.word 0
msg1:
.ascii "Loading ROM image"
.org 510, 0
.word 0xAA55