Debian grub-0.5-2 release.
This commit is contained in:
parent
b117211d4a
commit
6b874486ce
4 changed files with 150 additions and 193 deletions
|
@ -33,8 +33,8 @@ void (*debug_fs)(int) = NULL;
|
||||||
void (*debug_fs_func)(int) = NULL;
|
void (*debug_fs_func)(int) = NULL;
|
||||||
#endif /* NO_FANCY_STUFF */
|
#endif /* NO_FANCY_STUFF */
|
||||||
|
|
||||||
/* these have the same format as "boot_drive" and "install_partition", but
|
/* These have the same format as "boot_drive" and "install_partition", but
|
||||||
are meant to be working values */
|
are meant to be working values. */
|
||||||
unsigned long current_drive = 0xFF;
|
unsigned long current_drive = 0xFF;
|
||||||
unsigned long current_partition;
|
unsigned long current_partition;
|
||||||
|
|
||||||
|
@ -543,7 +543,13 @@ open_partition(void)
|
||||||
|
|
||||||
|
|
||||||
/* XX used for device completion in 'set_device' and 'print_completions' */
|
/* XX used for device completion in 'set_device' and 'print_completions' */
|
||||||
static int incomplete, disk_choice, part_choice;
|
static int incomplete, disk_choice;
|
||||||
|
static enum
|
||||||
|
{
|
||||||
|
PART_UNSPECIFIED = 0,
|
||||||
|
PART_DISK,
|
||||||
|
PART_CHOSEN,
|
||||||
|
} part_choice;
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -554,7 +560,7 @@ set_device(char *device)
|
||||||
|
|
||||||
incomplete = 0;
|
incomplete = 0;
|
||||||
disk_choice = 1;
|
disk_choice = 1;
|
||||||
part_choice = 0;
|
part_choice = PART_UNSPECIFIED;
|
||||||
current_drive = saved_drive;
|
current_drive = saved_drive;
|
||||||
current_partition = 0xFFFFFF;
|
current_partition = 0xFFFFFF;
|
||||||
|
|
||||||
|
@ -580,11 +586,12 @@ set_device(char *device)
|
||||||
|
|
||||||
if (*device == ')')
|
if (*device == ')')
|
||||||
{
|
{
|
||||||
part_choice = 2;
|
part_choice = PART_CHOSEN;
|
||||||
retval++;
|
retval++;
|
||||||
}
|
}
|
||||||
if (*device == ',')
|
if (*device == ',')
|
||||||
{
|
{
|
||||||
|
/* Either an absolute PC or BSD partition. */
|
||||||
disk_choice = 0;
|
disk_choice = 0;
|
||||||
part_choice++;
|
part_choice++;
|
||||||
device++;
|
device++;
|
||||||
|
@ -620,7 +627,7 @@ set_device(char *device)
|
||||||
|
|
||||||
if (*device == ')')
|
if (*device == ')')
|
||||||
{
|
{
|
||||||
if (part_choice == 1)
|
if (part_choice == PART_DISK)
|
||||||
{
|
{
|
||||||
current_partition = saved_partition;
|
current_partition = saved_partition;
|
||||||
part_choice++;
|
part_choice++;
|
||||||
|
@ -751,15 +758,14 @@ print_fsys_type(void)
|
||||||
printf(" Filesystem type ");
|
printf(" Filesystem type ");
|
||||||
|
|
||||||
if (fsys_type != NUM_FSYS)
|
if (fsys_type != NUM_FSYS)
|
||||||
printf("is %s\n", fsys_table[fsys_type].name);
|
printf("is %s, ", fsys_table[fsys_type].name);
|
||||||
else
|
else
|
||||||
{
|
printf("unknown, ");
|
||||||
printf("unknown, ");
|
|
||||||
if (current_partition == 0xFFFFFF)
|
if (current_partition == 0xFFFFFF)
|
||||||
printf("using whole disk\n");
|
printf("using whole disk\n");
|
||||||
else
|
else
|
||||||
printf("partition type 0x%x\n", current_slice);
|
printf("partition type 0x%x\n", current_slice);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -801,7 +807,7 @@ print_completions(char *filename)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* partition completions */
|
/* partition completions */
|
||||||
if (part_choice == 1)
|
if (part_choice == PART_DISK)
|
||||||
{
|
{
|
||||||
printf(" Possible partitions are:\n");
|
printf(" Possible partitions are:\n");
|
||||||
real_open_partition(1);
|
real_open_partition(1);
|
||||||
|
@ -1064,4 +1070,3 @@ dir(char *dirname)
|
||||||
|
|
||||||
return (*(fsys_table[fsys_type].dir_func))(dirname);
|
return (*(fsys_table[fsys_type].dir_func))(dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,22 @@
|
||||||
|
|
||||||
#define MAXINT 0x7FFFFFFF
|
#define MAXINT 0x7FFFFFFF
|
||||||
|
|
||||||
|
/* 512-byte scratch area */
|
||||||
|
#define SCRATCHADDR 0x77e00
|
||||||
|
#define SCRATCHSEG 0x77e0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the location of the raw device buffer. It is 31.5K
|
* This is the location of the raw device buffer. It is 31.5K
|
||||||
* in size.
|
* in size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BUFFERSEG 0x7000
|
#define BUFFERLEN 0x7e00
|
||||||
#define BUFFERADDR 0x70000
|
#define BUFFERADDR 0x70000
|
||||||
|
#define BUFFERSEG 0x7000
|
||||||
|
|
||||||
/* 512-byte scratch area */
|
#if (BUFFERADDR + BUFFERLEN) != SCRATCHADDR
|
||||||
#define SCRATCHSEG 0x77e0
|
# error "scratch area isn't at the end of the device buffer"
|
||||||
#define SCRATCHADDR 0x77e00
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BIOS disk defines
|
* BIOS disk defines
|
||||||
|
@ -47,12 +52,21 @@
|
||||||
#define BIOSDISK_ERROR_GEOMETRY 0x100
|
#define BIOSDISK_ERROR_GEOMETRY 0x100
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the location of the filesystem (not raw device) buffer.
|
* This is the filesystem (not raw device) buffer.
|
||||||
* It is 32K in size, do not overrun!
|
* It is 32K in size, do not overrun!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define FSYS_BUFLEN 0x8000
|
||||||
#define FSYS_BUF 0x68000
|
#define FSYS_BUF 0x68000
|
||||||
|
|
||||||
|
#if (FSYS_BUF % 16) != 0
|
||||||
|
# error "FSYS_BUF is not segment-aligned"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (FSYS_BUF + FSYS_BUFLEN) != BUFFERADDR
|
||||||
|
# error "device buffer buffer isn't at the end of the filesystem buffer"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Linux setup parameters
|
* Linux setup parameters
|
||||||
*/
|
*/
|
||||||
|
@ -119,8 +133,6 @@
|
||||||
* defines for use when switching between real and protected mode
|
* defines for use when switching between real and protected mode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define data32 .byte 0x66
|
|
||||||
#define addr32 .byte 0x67
|
|
||||||
#define CR0_PE_ON 0x1
|
#define CR0_PE_ON 0x1
|
||||||
#define CR0_PE_OFF 0xfffffffe
|
#define CR0_PE_OFF 0xfffffffe
|
||||||
#define PROT_MODE_CSEG 0x8
|
#define PROT_MODE_CSEG 0x8
|
||||||
|
|
|
@ -170,7 +170,7 @@ restart:
|
||||||
commands before booting, or \'c\' for a command-line.");
|
commands before booting, or \'c\' for a command-line.");
|
||||||
else
|
else
|
||||||
printf(
|
printf(
|
||||||
" Press \'b\' to boot, enter to edit the selected command in the
|
" Press \'b\' to boot, \'e\' to edit the selected command in the
|
||||||
boot sequence, \'c\' for a command-line, \'o\' to open a new line
|
boot sequence, \'c\' for a command-line, \'o\' to open a new line
|
||||||
after (\'O\' for before) the selected line, \'d\' to remove the
|
after (\'O\' for before) the selected line, \'d\' to remove the
|
||||||
selected line, or escape to go back to the main menu.");
|
selected line, or escape to go back to the main menu.");
|
||||||
|
@ -336,8 +336,7 @@ restart:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((config_entries && (c == 'e'))
|
if (c == 'e')
|
||||||
|| (!config_entries && ((c == '\n') || (c == '\r'))))
|
|
||||||
{
|
{
|
||||||
int num_entries = 0, i = 0;
|
int num_entries = 0, i = 0;
|
||||||
char *new_heap;
|
char *new_heap;
|
||||||
|
@ -435,14 +434,22 @@ restart:
|
||||||
|
|
||||||
if (!(c = enter_cmdline(cur_entry, heap)))
|
if (!(c = enter_cmdline(cur_entry, heap)))
|
||||||
{
|
{
|
||||||
cur_entry = NULL;
|
if (fallback < 0)
|
||||||
first_entry = 0;
|
break;
|
||||||
entryno = fallback;
|
else
|
||||||
fallback = -1;
|
{
|
||||||
|
cur_entry = NULL;
|
||||||
|
first_entry = 0;
|
||||||
|
entryno = fallback;
|
||||||
|
fallback = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!c);
|
while (!c);
|
||||||
|
|
||||||
|
/* Both the entry and the fallback failed, so wait for input. */
|
||||||
|
printf("Failed!\n Press any key to continue...");
|
||||||
|
getkey();
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
257
stage1/stage1.S
257
stage1/stage1.S
|
@ -36,28 +36,18 @@
|
||||||
|
|
||||||
/* Absolute addresses
|
/* Absolute addresses
|
||||||
This makes the assembler generate the address without support
|
This makes the assembler generate the address without support
|
||||||
from the linker. (ELF can't relocate 16bit addresses!) */
|
from the linker. (ELF can't relocate 16-bit addresses!) */
|
||||||
#define ABS(x) (x-_start+0x7c00)
|
#define ABS(x) (x-_start+0x7c00)
|
||||||
|
|
||||||
/* Relative addresses (for jumps)
|
/* Print message string */
|
||||||
These macros use the local label 0, so start with your local
|
#define MSG(x) movw $x, %si; call message
|
||||||
label at 1! */
|
|
||||||
#define REL(x) .word x-0f; 0:
|
|
||||||
#define RELB(x) .byte x-0f; 0:
|
|
||||||
|
|
||||||
/* Print message string
|
|
||||||
movw $x, %cx; call message */
|
|
||||||
#define MSG(x) movw $x, %aw; .byte 0xe8; REL(message)
|
|
||||||
|
|
||||||
.file "stage1.S"
|
.file "stage1.S"
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
/*
|
/* Tell GAS to generate 16-bit instructions so that this code works
|
||||||
* The ".code16" directive only works in GAS, the GNU assembler!
|
in real mode. */
|
||||||
* This adds 32-bit data or addressing directives so that this
|
|
||||||
* code will work in real mode!
|
|
||||||
*/
|
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
.globl _start; _start:
|
.globl _start; _start:
|
||||||
|
@ -70,8 +60,7 @@
|
||||||
* parameter block.
|
* parameter block.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jmp after_BPB */
|
jmp after_BPB
|
||||||
.byte 0xeb; RELB(after_BPB)
|
|
||||||
nop /* do I care about this ??? */
|
nop /* do I care about this ??? */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -115,13 +104,11 @@ after_BPB:
|
||||||
/*
|
/*
|
||||||
* Check if we have a forced disk reference here
|
* Check if we have a forced disk reference here
|
||||||
*/
|
*/
|
||||||
/* movb firstlist, %al */
|
movb firstlist, %al
|
||||||
.byte 0xa0; .word ABS(firstlist)
|
|
||||||
cmpb $0xff, %al
|
cmpb $0xff, %al
|
||||||
/* je 1f */
|
je 1f
|
||||||
.byte 0x74; RELB(1f)
|
|
||||||
movb %al, %dl
|
movb %al, %dl
|
||||||
1:
|
1:
|
||||||
/* save drive reference first thing! */
|
/* save drive reference first thing! */
|
||||||
pushw %dx
|
pushw %dx
|
||||||
|
|
||||||
|
@ -130,9 +117,7 @@ after_BPB:
|
||||||
*/
|
*/
|
||||||
movb %dl, %al
|
movb %dl, %al
|
||||||
andb $BIOS_HD_FLAG, %al
|
andb $BIOS_HD_FLAG, %al
|
||||||
|
jz floppy_probe
|
||||||
/* jz floppy_probe */
|
|
||||||
.byte 0x0f, 0x84; REL(floppy_probe)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the hard disk geometry from the BIOS!
|
* Determine the hard disk geometry from the BIOS!
|
||||||
|
@ -141,16 +126,14 @@ after_BPB:
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
/* if BIOS geometry call fails, display error and die! */
|
/* if BIOS geometry call fails, display error and die! */
|
||||||
/* jc hd_probe_error (16-bit)*/
|
jc hd_probe_error
|
||||||
.byte 0x0f, 0x82; REL(hd_probe_error)
|
|
||||||
|
|
||||||
final_init:
|
final_init:
|
||||||
|
/* save number of heads */
|
||||||
xorb %ah, %ah
|
xorb %ah, %ah
|
||||||
movb %dh, %al
|
movb %dh, %al
|
||||||
incw %ax
|
incw %ax
|
||||||
|
movw %ax, heads
|
||||||
/* movw %ax, heads */ /* save num heads */
|
|
||||||
.byte 0xA3; .word ABS(heads)
|
|
||||||
|
|
||||||
xorw %dx, %dx
|
xorw %dx, %dx
|
||||||
movb %cl, %dl
|
movb %cl, %dl
|
||||||
|
@ -158,20 +141,17 @@ final_init:
|
||||||
movb %ch, %al
|
movb %ch, %al
|
||||||
movb %dh, %ah
|
movb %dh, %ah
|
||||||
|
|
||||||
|
/* save number of cylinders */
|
||||||
incw %ax
|
incw %ax
|
||||||
|
movw %ax, cylinders
|
||||||
/* movw %ax, cylinders */ /* save num cylinders */
|
|
||||||
.byte 0xA3; .word ABS(cylinders)
|
|
||||||
|
|
||||||
xorw %ax, %ax
|
xorw %ax, %ax
|
||||||
movb %dl, %al
|
movb %dl, %al
|
||||||
shrb $2, %al
|
shrb $2, %al
|
||||||
|
|
||||||
/* save a byte on addressing by moving this forward ?? */
|
/* save number of sectors */
|
||||||
movw $ABS(sectors), %si
|
movw $ABS(sectors), %si
|
||||||
|
movw %ax, (%si)
|
||||||
/* movw %ax, (%si) */ /* save num sectors */
|
|
||||||
.byte 0x89, 0x04
|
|
||||||
|
|
||||||
/* this sets up for the first run through "bootloop" */
|
/* this sets up for the first run through "bootloop" */
|
||||||
movw $ABS(firstlist), %di
|
movw $ABS(firstlist), %di
|
||||||
|
@ -183,86 +163,80 @@ bootloop:
|
||||||
/* update position to load from */
|
/* update position to load from */
|
||||||
subw $LISTSIZ, %di
|
subw $LISTSIZ, %di
|
||||||
|
|
||||||
/* cmpw $0, 4(%di) */ /* check the number of sectors to read */
|
/* check the number of sectors to read */
|
||||||
.byte 0x81, 0x7d, 0x04; .word 0
|
cmpw $0, 4(%di)
|
||||||
|
|
||||||
/* je bootit (16-bit)*/ /* if zero, go to the start function */
|
/* if zero, go to the start function */
|
||||||
.byte 0x0f, 0x84; REL(bootit)
|
je bootit
|
||||||
|
|
||||||
/* movl (%di), %ax */ /* load logical sector start (bottom half) */
|
/* load logical sector start (bottom half) */
|
||||||
.byte 0x8b, 0x05
|
movw (%di), %ax
|
||||||
|
|
||||||
/* movl 2(%di), %dx */ /* load logical sector start (top half) */
|
/* load logical sector start (top half) */
|
||||||
.byte 0x8b, 0x55, 0x02
|
movw 2(%di), %dx
|
||||||
|
|
||||||
/* divw (%si), %dx:%ax */ /* divide by number of sectors */
|
/* divide by number of sectors */
|
||||||
.byte 0xf7, 0x34
|
divw (%si)
|
||||||
|
|
||||||
/* movb %dl, (%di) */ /* save sector start */
|
/* save sector start */
|
||||||
.byte 0x88, 0x15
|
movb %dl, (%di)
|
||||||
|
|
||||||
xorw %dx, %dx /* zero %dx */
|
xorw %dx, %dx /* zero %dx */
|
||||||
/* divw 2(%si), %dx:%ax */ /* divide by number of heads */
|
divw 2(%si) /* divide by number of heads */
|
||||||
.byte 0xf7, 0x74, 0x02
|
|
||||||
|
|
||||||
/* movb %dl, 1(%di) */ /* save head start */
|
/* save head start */
|
||||||
.byte 0x88, 0x55, 0x01
|
movb %dl, 1(%di)
|
||||||
|
|
||||||
/* movw %ax, 2(%di) */ /* save cylinder start */
|
/* save cylinder start */
|
||||||
.byte 0x89, 0x45, 0x02
|
movw %ax, 2(%di)
|
||||||
|
|
||||||
/* cmpw 4(%si), %ax */ /* do we need too many cylinders? */
|
/* do we need too many cylinders? */
|
||||||
.byte 0x3b, 0x44, 0x04
|
cmpw 4(%si), %ax
|
||||||
|
jge geometry_error
|
||||||
/* jge geometry_error (16-bit) */
|
|
||||||
.byte 0x0f, 0x8d; REL(geometry_error)
|
|
||||||
|
|
||||||
setup_sectors:
|
setup_sectors:
|
||||||
|
|
||||||
/* determine the maximum sector length of this read */
|
/* determine the maximum sector length of this read */
|
||||||
/* movw (%si), %ax */ /* get number of sectors per track/head */
|
movw (%si), %ax /* get number of sectors per track/head */
|
||||||
.byte 0x8b, 0x04
|
|
||||||
|
|
||||||
/* subb (%di), %al */ /* subtract sector start */
|
/* subtract sector start */
|
||||||
.byte 0x2a, 0x05
|
subb (%di), %al
|
||||||
|
|
||||||
/* how many do we really want to read? */
|
/* how many do we really want to read? */
|
||||||
/* cmpw %ax, 4(%di) */ /* compare against total number of sectors */
|
cmpw %ax, 4(%di) /* compare against total number of sectors */
|
||||||
.byte 0x39, 0x45, 0x04
|
|
||||||
|
|
||||||
/* jg more_sectors (8-bit)*/ /* which is greater? */
|
|
||||||
.byte 0x7f; RELB(more_sectors)
|
|
||||||
|
|
||||||
/* movw 4(%di), %ax */ /* if less than, set to total */
|
/* which is greater? */
|
||||||
.byte 0x8b, 0x45, 0x04
|
jg more_sectors
|
||||||
|
|
||||||
|
/* if less than, set to total */
|
||||||
|
movw 4(%di), %ax
|
||||||
|
|
||||||
more_sectors:
|
more_sectors:
|
||||||
/* subw %ax, 4(%di) */ /* subtract from total */
|
/* subtract from total */
|
||||||
.byte 0x29, 0x45, 0x04
|
subw %ax, 4(%di)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the loop for taking care of BIOS geometry translation (ugh!)
|
* This is the loop for taking care of BIOS geometry translation (ugh!)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* movb 3(%di), %dl */ /* get high bits of cylinder */
|
/* get high bits of cylinder */
|
||||||
.byte 0x8a, 0x55, 0x03
|
movb 3(%di), %dl
|
||||||
|
|
||||||
shlb $6, %dl /* shift left by 6 bits */
|
shlb $6, %dl /* shift left by 6 bits */
|
||||||
/* movw (%di), %cl */ /* get sector */
|
movb (%di), %cl /* get sector */
|
||||||
.byte 0x8b, 0x0d
|
|
||||||
|
|
||||||
incb %cl /* normalize sector (sectors go
|
incb %cl /* normalize sector (sectors go
|
||||||
from 1-N, not 0-(N-1) ) */
|
from 1-N, not 0-(N-1) ) */
|
||||||
orb %dl, %cl /* composite together */
|
orb %dl, %cl /* composite together */
|
||||||
/* movb 2(%di), %ch */ /* sector+hcyl in cl, cylinder in ch */
|
movb 2(%di), %ch /* sector+hcyl in cl, cylinder in ch */
|
||||||
.byte 0x8a, 0x6d, 0x02
|
|
||||||
|
|
||||||
/* restore %dx */
|
/* restore %dx */
|
||||||
popw %dx
|
popw %dx
|
||||||
pushw %dx
|
pushw %dx
|
||||||
|
|
||||||
/* movb 1(%di), %dh */ /* head num */
|
/* head number */
|
||||||
.byte 0x8a, 0x75, 0x01
|
movb 1(%di), %dh
|
||||||
|
|
||||||
pushw %ax /* save %ax from destruction! */
|
pushw %ax /* save %ax from destruction! */
|
||||||
|
|
||||||
|
@ -286,15 +260,13 @@ more_sectors:
|
||||||
movb $0x2, %ah /* function 2 */
|
movb $0x2, %ah /* function 2 */
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
/* jc read_error */
|
jc read_error
|
||||||
.byte 0x72; RELB(read_error)
|
|
||||||
|
|
||||||
movw %es, %ax
|
/* save source segment */
|
||||||
movw %ax, %fs /* load source segment */
|
movw %es, %dx
|
||||||
|
|
||||||
/* load addresses for copy from disk buffer to destination */
|
/* load addresses for copy from disk buffer to destination */
|
||||||
/* movw 6(%di), %es */ /* load destination segment */
|
movw 6(%di), %es /* load destination segment */
|
||||||
.byte 0x8e, 0x45, 0x06
|
|
||||||
|
|
||||||
/* restore %ax */
|
/* restore %ax */
|
||||||
popw %ax
|
popw %ax
|
||||||
|
@ -302,75 +274,63 @@ more_sectors:
|
||||||
/* determine the next possible destination address (presuming
|
/* determine the next possible destination address (presuming
|
||||||
512 byte sectors!) */
|
512 byte sectors!) */
|
||||||
shlw $5, %ax /* shift %ax five bits to the left */
|
shlw $5, %ax /* shift %ax five bits to the left */
|
||||||
/* addw %ax, 6(%di) */ /* add the corrected value to the destination
|
addw %ax, 6(%di) /* add the corrected value to the destination
|
||||||
address for next time */
|
address for next time */
|
||||||
.byte 0x01, 0x45, 0x06
|
|
||||||
|
|
||||||
/* get the copy length */
|
/* get the copy length */
|
||||||
shlw $4, %ax
|
shlw $4, %ax
|
||||||
movw %ax, %cx
|
movw %ax, %cx
|
||||||
|
|
||||||
/* save addressing regs */
|
/* save addressing regs */
|
||||||
|
pushw %ds
|
||||||
pushw %si
|
pushw %si
|
||||||
pushw %di
|
pushw %di
|
||||||
|
|
||||||
xorw %di, %di /* zero offset of destination addresses */
|
xorw %di, %di /* zero offset of destination addresses */
|
||||||
xorw %si, %si /* zero offset of source addresses */
|
xorw %si, %si /* zero offset of source addresses */
|
||||||
|
movw %dx, %ds /* restore the source segment */
|
||||||
|
|
||||||
cld /* sets the copy direction to forward */
|
cld /* sets the copy direction to forward */
|
||||||
|
|
||||||
/* perform copy */
|
/* perform copy */
|
||||||
rep /* sets a repeat */
|
rep /* sets a repeat */
|
||||||
fs /* this overrides the source segment from %ds to %fs */
|
|
||||||
movsb /* this runs the actual copy */
|
movsb /* this runs the actual copy */
|
||||||
|
|
||||||
/* restore addressing regs */
|
/* restore addressing regs */
|
||||||
popw %di
|
popw %di
|
||||||
popw %si
|
popw %si
|
||||||
|
popw %ds
|
||||||
|
|
||||||
/* check if finished with this dataset */
|
/* check if finished with this dataset */
|
||||||
/* cmpw $0, 4(%di) */
|
cmpw $0, 4(%di)
|
||||||
.byte 0x81, 0x7d, 0x04; .word 0
|
je bootloop
|
||||||
|
|
||||||
/* je bootloop */
|
|
||||||
.byte 0x0f, 0x84; REL(bootloop)
|
|
||||||
|
|
||||||
/* find out the next BIOS set to load in */
|
/* find out the next BIOS set to load in */
|
||||||
/* movb $0, (%di) */ /* set the sector start */
|
movb $0, (%di) /* set the sector start */
|
||||||
.byte 0xc6, 0x05, 0
|
|
||||||
|
|
||||||
xorb %ah, %ah /* zero %ah */
|
xorb %ah, %ah /* zero %ah */
|
||||||
/* movb 1(%di), %al */ /* load head number into %al */
|
movb 1(%di), %al /* load head number into %al */
|
||||||
.byte 0x8a, 0x45, 0x01
|
|
||||||
|
|
||||||
incw %ax /* increment current head number */
|
incw %ax /* increment current head number */
|
||||||
/* cmpw 2(%si), %ax */ /* compare to total number of heads */
|
cmpw 2(%si), %ax /* compare to total number of heads */
|
||||||
.byte 0x3b, 0x44, 0x02
|
jne update_heads
|
||||||
|
|
||||||
/* jne update_heads (8-bit)*/
|
movw 2(%di), %ax /* load cylinder number into %ax */
|
||||||
.byte 0x75; RELB(update_heads)
|
|
||||||
|
|
||||||
/* movw 2(%di), %ax */ /* load cylinder number into %ax */
|
|
||||||
.byte 0x8b, 0x45, 0x02
|
|
||||||
|
|
||||||
incw %ax /* increment current cylinder number */
|
incw %ax /* increment current cylinder number */
|
||||||
/* cmpw 4(%si), %ax */ /* compare to total number of cylinders */
|
cmpw 4(%si), %ax /* compare to total number of cylinders */
|
||||||
.byte 0x3b, 0x44, 0x04
|
|
||||||
|
|
||||||
/* je geometry_error */ /* display error and die if greater */
|
je geometry_error /* display error and die if greater */
|
||||||
.byte 0x74; RELB(geometry_error)
|
|
||||||
|
|
||||||
/* movw %ax, 2(%di) */ /* store new cylinder number */
|
movw %ax, 2(%di) /* store new cylinder number */
|
||||||
.byte 0x89, 0x45, 0x02
|
|
||||||
|
|
||||||
movb $0, %al /* for storing new head number */
|
movb $0, %al /* for storing new head number */
|
||||||
|
|
||||||
update_heads:
|
update_heads:
|
||||||
/* movb %al, 1(%di) */ /* store new head number */
|
movb %al, 1(%di) /* store new head number */
|
||||||
.byte 0x88, 0x45, 0x01
|
|
||||||
|
|
||||||
/* jump to "setup_sectors" to determine length of the new read */
|
/* jump to "setup_sectors" to determine length of the new read */
|
||||||
/* jmp setup_sectors */
|
jmp setup_sectors
|
||||||
.byte 0xe9; REL(setup_sectors)
|
|
||||||
|
|
||||||
/* END OF MAIN LOOP */
|
/* END OF MAIN LOOP */
|
||||||
|
|
||||||
|
@ -378,38 +338,27 @@ update_heads:
|
||||||
* BIOS Geometry translation error (past the end of the disk geometry!).
|
* BIOS Geometry translation error (past the end of the disk geometry!).
|
||||||
*/
|
*/
|
||||||
geometry_error:
|
geometry_error:
|
||||||
movw $geometry_error_string, %si
|
MSG(geometry_error_string)
|
||||||
/* call message */
|
jmp general_error
|
||||||
.byte 0xe8; REL(message)
|
|
||||||
/* jmp display_error (8-bit) */
|
|
||||||
.byte 0xeb; RELB(general_error)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disk probe failure.
|
* Disk probe failure.
|
||||||
*/
|
*/
|
||||||
hd_probe_error:
|
hd_probe_error:
|
||||||
movw $hd_probe_error_string, %si
|
MSG(hd_probe_error_string)
|
||||||
/* call message */
|
jmp general_error
|
||||||
.byte 0xe8; REL(message)
|
|
||||||
/* jmp display_error (8-bit) */
|
|
||||||
.byte 0xeb; RELB(general_error)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read error on the disk.
|
* Read error on the disk.
|
||||||
*/
|
*/
|
||||||
read_error:
|
read_error:
|
||||||
movw $read_error_string, %si
|
MSG(read_error_string)
|
||||||
/* call message */
|
|
||||||
.byte 0xe8; REL(message)
|
|
||||||
|
|
||||||
general_error:
|
general_error:
|
||||||
movw $general_error_string, %si
|
MSG(general_error_string)
|
||||||
/* call message */
|
|
||||||
.byte 0xe8; REL(message)
|
|
||||||
|
|
||||||
/* go here when you need to stop the machine hard after an error condition */
|
/* go here when you need to stop the machine hard after an error condition */
|
||||||
stop: /* jmp stop (8-bit) */
|
stop: jmp stop
|
||||||
.byte 0xeb; RELB(stop)
|
|
||||||
|
|
||||||
geometry_error_string: .string "Geom"
|
geometry_error_string: .string "Geom"
|
||||||
hd_probe_error_string: .string "Hard Disk"
|
hd_probe_error_string: .string "Hard Disk"
|
||||||
|
@ -434,14 +383,10 @@ general_error_string: .string " Error"
|
||||||
|
|
||||||
incw %si
|
incw %si
|
||||||
message:
|
message:
|
||||||
/* movb (%si), %al */
|
movb (%si), %al
|
||||||
.byte 0x8a, 0x4
|
|
||||||
cmpb $0, %al
|
cmpb $0, %al
|
||||||
/* jne 1b */
|
jne 1b /* if not end of string, jmp to display */
|
||||||
.byte 0x75; RELB(1b) /* if not end of string, jmp to display */
|
ret
|
||||||
|
|
||||||
/* ret */
|
|
||||||
.byte 0xc3
|
|
||||||
lastlist:
|
lastlist:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -489,16 +434,12 @@ firstlist: /* this label has to be after the list data!!! */
|
||||||
|
|
||||||
bootit:
|
bootit:
|
||||||
popw %dx /* this makes sure %dl is our "boot" drive */
|
popw %dx /* this makes sure %dl is our "boot" drive */
|
||||||
/* ljmp $myoffset, $myseg */
|
ljmp $0, $0x8000 /* FIXME: make 0x2000 for stage1_5 */
|
||||||
.byte 0xea
|
|
||||||
#ifdef STAGE1_5
|
|
||||||
.word 0x2000, 0
|
|
||||||
#else
|
|
||||||
.word 0x8000, 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the compatibility version number.
|
* This is the compatibility version number.
|
||||||
|
* See ../stage2/shared.h for COMPAT_VERSION_* definitions used
|
||||||
|
* in stage2 and stage1_5 modules.
|
||||||
*
|
*
|
||||||
* DO NOT MOVE THIS!!!
|
* DO NOT MOVE THIS!!!
|
||||||
*/
|
*/
|
||||||
|
@ -528,24 +469,18 @@ probe_loop:
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
incw %si
|
incw %si
|
||||||
|
movb (%si), %cl
|
||||||
/* movb (%si), %cl */
|
|
||||||
.byte 0x8a, 0x0c
|
|
||||||
|
|
||||||
/* if number of sectors is 0, display error and die */
|
/* if number of sectors is 0, display error and die */
|
||||||
cmpb $0, %cl
|
cmpb $0, %cl
|
||||||
|
jne 1f
|
||||||
/* jne 1f (8-bit) */
|
|
||||||
.byte 0x75; RELB(1f)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Floppy disk probe failure.
|
* Floppy disk probe failure.
|
||||||
*/
|
*/
|
||||||
movw $fd_probe_error_string, %si
|
movw $fd_probe_error_string, %si
|
||||||
/* call message */
|
call message
|
||||||
.byte 0xe8; REL(message)
|
jmp general_error
|
||||||
/* jmp display_error (16-bit) */
|
|
||||||
.byte 0xe9; REL(general_error)
|
|
||||||
|
|
||||||
fd_probe_error_string: .string "Floppy"
|
fd_probe_error_string: .string "Floppy"
|
||||||
|
|
||||||
|
@ -558,15 +493,13 @@ fd_probe_error_string: .string "Floppy"
|
||||||
int $0x13
|
int $0x13
|
||||||
|
|
||||||
/* if error, jump to "probe_loop" */
|
/* if error, jump to "probe_loop" */
|
||||||
/* jc probe_loop (8-bit)*/
|
jc probe_loop
|
||||||
.byte 0x72; RELB(probe_loop)
|
|
||||||
|
|
||||||
/* %cl is already the correct value! */
|
/* %cl is already the correct value! */
|
||||||
movb $1, %dh
|
movb $1, %dh
|
||||||
movb $79, %ch
|
movb $79, %ch
|
||||||
|
|
||||||
/* jmp final_init */
|
jmp final_init
|
||||||
.byte 0xe9; REL(final_init)
|
|
||||||
|
|
||||||
. = _start + PARTEND
|
. = _start + PARTEND
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue