correct non8086 division in bootcode, add boot drive option to sys

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1034 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2004-09-11 13:42:30 +00:00
parent 7aaf2cae37
commit 6eff2f4bb2
2 changed files with 41 additions and 13 deletions

View File

@ -122,7 +122,7 @@ Entry: jmp short real_start
%define READADDR_SEG BP-0x60-0x1802 %define READADDR_SEG BP-0x60-0x1802
%define PARAMS LBA_PACKET+0x10 %define PARAMS LBA_PACKET+0x10
%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses ;%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses
%define fat_start PARAMS+0x2 ; first FAT sector %define fat_start PARAMS+0x2 ; first FAT sector
@ -210,7 +210,8 @@ dont_use_dl: ; no, rely on [drive] written by SYS
xor dx, dx xor dx, dx
div bx div bx
mov word [RootDirSecs], ax ; AX = sectors per root directory ; mov word [RootDirSecs], ax ; AX = sectors per root directory
push ax
add si, ax add si, ax
adc di, byte 0 ; DI:SI = first data sector adc di, byte 0 ; DI:SI = first data sector
@ -229,7 +230,7 @@ dont_use_dl: ; no, rely on [drive] written by SYS
mov ax, word [root_dir_start] mov ax, word [root_dir_start]
mov dx, word [root_dir_start+2] mov dx, word [root_dir_start+2]
mov di, word [RootDirSecs] pop di ; mov di, word [RootDirSecs]
les bx, [loadsegoff_60] ; es:bx = 60:0 les bx, [loadsegoff_60] ; es:bx = 60:0
call readDisk call readDisk
les di, [loadsegoff_60] ; es:di = 60:0 les di, [loadsegoff_60] ; es:di = 60:0
@ -366,7 +367,7 @@ show: pop si
boot_error: call show boot_error: call show
; db "Error! Hit a key to reboot." ; db "Error! Hit a key to reboot."
db "Err." db "Error!."
xor ah,ah xor ah,ah
int 0x13 ; reset floppy int 0x13 ; reset floppy
@ -487,7 +488,9 @@ do_int13_read:
rep movsb rep movsb
pop di pop di
shr ax, 4 ; adjust segment pointer by increasing ; div byte[LBA_PACKET] ; luckily 16 !!
mov cl, 4
shr ax, cl ; adjust segment pointer by increasing
add word [READADDR_SEG], ax ; by paragraphs read in (per sector) add word [READADDR_SEG], ax ; by paragraphs read in (per sector)
add LBA_SECTOR_0, byte 1 add LBA_SECTOR_0, byte 1

View File

@ -186,7 +186,7 @@ char *getenv(const char *name)
BYTE pgm[] = "SYS"; BYTE pgm[] = "SYS";
void put_boot(int, char *, char *, int, int, int); void put_boot(int, char *, char *, int, int, int, int);
BOOL check_space(COUNT, ULONG); BOOL check_space(COUNT, ULONG);
BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source); BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source);
BOOL copy(BYTE *source, COUNT drive, BYTE * filename); BOOL copy(BYTE *source, COUNT drive, BYTE * filename);
@ -303,6 +303,7 @@ int main(int argc, char **argv)
int argno = 0; int argno = 0;
int bootonly = 0; int bootonly = 0;
int both = 0; int both = 0;
int bootdrive = -1; /* -1 means default processing, else value to use */
char *kernel_name = FDKERNEL; char *kernel_name = FDKERNEL;
int load_segment = FDLOADSEG; int load_segment = FDLOADSEG;
int altkern = NO_OEMKERN; /* use OEM kernel values instead of FD ones */ int altkern = NO_OEMKERN; /* use OEM kernel values instead of FD ones */
@ -388,6 +389,24 @@ int main(int argc, char **argv)
{ {
load_segment = (int)strtol(argv[argno], NULL, 16); load_segment = (int)strtol(argv[argno], NULL, 16);
} }
else if (memicmp(argp, "B", 2) == 0) /* set boot drive # */
{
/* BIOS drive number to put in boot sector, normally this is
0 for A, 80 for 1st hard drive, 81 2nd hd, etc, and
FF for FreeDOS bootsector will force use of value passed
in DL by BIOS. */
bootdrive = (BYTE)strtol(argv[argno], NULL, 16);
}
else /* unknown option */
{
drivearg = 0;
break;
}
}
else /* invalid option or missing value portion */
{
drivearg = 0;
break;
} }
} }
else if (drivearg != argno) else if (drivearg != argno)
@ -396,7 +415,7 @@ int main(int argc, char **argv)
{ {
bsFile = argp; bsFile = argp;
} }
else else /* invalid usage */
{ {
drivearg = 0; drivearg = 0;
break; break;
@ -417,12 +436,13 @@ int main(int argc, char **argv)
" /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n"
" /OEM : indicates kernel is IBMBIO.COM/IBMDOS.COM loaded at 0x70\n" " /OEM : indicates kernel is IBMBIO.COM/IBMDOS.COM loaded at 0x70\n"
#ifdef WITHOEMCOMPATBS #ifdef WITHOEMCOMPATBS
" /OEM:DR use IBMBIO.COM/IBMDOS.SYS and FD boot sector (default)\n" " /OEM:DR use IBMBIO.COM/IBMDOS.COM and FD boot sector (default)\n"
" /OEM:PC use PC-DOS compatible boot sector\n" " /OEM:PC use PC-DOS compatible boot sector\n"
" /OEM:MS use PC-DOS compatible boot sector with IO.SYS/MSDOS.SYS\n" " /OEM:MS use PC-DOS compatible boot sector with IO.SYS/MSDOS.SYS\n"
#endif #endif
" /K name : name of kernel to use instead of KERNEL.SYS\n" " /K name : name of kernel to use instead of KERNEL.SYS\n"
" /L segm : hex load segment to use instead of 60\n" " /L segm : hex load segment to use instead of 60\n"
" /B btdrv : hex BIOS # of boot drive, FF=BIOS provided, 0=A:, 80=1st hd,...\n"
"%s CONFIG /help\n", pgm, pgm); "%s CONFIG /help\n", pgm, pgm);
exit(1); exit(1);
} }
@ -489,7 +509,7 @@ int main(int argc, char **argv)
} }
printf("Processing boot sector...\n"); printf("Processing boot sector...\n");
put_boot(drive, bsFile, kernel_name, load_segment, both, altkern); put_boot(drive, bsFile, kernel_name, load_segment, both, altkern, bootdrive);
if (!bootonly) if (!bootonly)
{ {
@ -814,7 +834,9 @@ void correct_bpb(struct bootsectortype *default_bpb,
oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs; oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs;
} }
void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both, int altkern) void put_boot(int drive, char *bsFile,
char *kernel_name, int load_seg, int both,
int altkern, int bootdrive)
{ {
#ifdef WITHFAT32 #ifdef WITHFAT32
struct bootsectortype32 *bs32; struct bootsectortype32 *bs32;
@ -900,7 +922,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both
if (altkern >= 2) /* MS or PC compatible BS requested */ if (altkern >= 2) /* MS or PC compatible BS requested */
{ {
printf("%s: FAT32 versions of PC/MS DOS compatible boot sectors\n" printf("%s: FAT32 versions of PC/MS DOS compatible boot sectors\n"
"are not supported [yet].\n"); "are not supported [yet].\n", pgm);
exit(1); exit(1);
} }
#endif #endif
@ -948,12 +970,15 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both
/* originally OemName was "FreeDOS", changed for better compatibility */ /* originally OemName was "FreeDOS", changed for better compatibility */
memcpy(bs->OemName, "FRDOS4.1", 8); memcpy(bs->OemName, "FRDOS4.1", 8);
/* allow user to override default of use BIOS provided boot drive # */
bootdrive = (bootdrive < 0)? (drive < 2 ? 0 : 0xff) : bootdrive;
#ifdef WITHFAT32 #ifdef WITHFAT32
if (fs == FAT32) if (fs == FAT32)
{ {
bs32 = (struct bootsectortype32 *)&newboot; bs32 = (struct bootsectortype32 *)&newboot;
/* put 0 for A: or B: (force booting from A:), otherwise use DL */ /* put 0 for A: or B: (force booting from A:), otherwise use DL */
bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; bs32->bsDriveNumber = bootdrive;
/* the location of the "0060" segment portion of the far pointer /* the location of the "0060" segment portion of the far pointer
in the boot sector is just before cont: in boot*.asm. in the boot sector is just before cont: in boot*.asm.
This happens to be offset 0x78 (=0x3c * 2) for FAT32 and This happens to be offset 0x78 (=0x3c * 2) for FAT32 and
@ -972,7 +997,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both
#endif #endif
{ {
/* put 0 for A: or B: (force booting from A:), otherwise use DL */ /* put 0 for A: or B: (force booting from A:), otherwise use DL */
bs->bsDriveNumber = drive < 2 ? 0 : 0xff; bs->bsDriveNumber = bootdrive;
#ifdef WITHOEMCOMPATBS #ifdef WITHOEMCOMPATBS
if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */ if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */
#endif #endif