boot odds and ends. unfinished cd-detection work.

This commit is contained in:
Ben Gras 2005-05-03 08:52:41 +00:00
parent 544b225a44
commit ccd06c407c
4 changed files with 1676 additions and 2 deletions

View file

@ -11,7 +11,7 @@ LD86 = $(CC86) -.o
BIN = /usr/bin
MDEC = /usr/mdec
all: bootblock boot edparams masterboot jumpboot installboot addaout
all: bootblock boot edparams masterboot jumpboot installboot addaout bootcd
dos: boot.com mkfile.com
bootblock: bootblock.s
@ -40,6 +40,11 @@ boot: boothead.s boot.o bootimage.o rawfs86.o
boothead.s boot.o bootimage.o rawfs86.o $(LIBS)
install -S 16kb boot
bootcd: bootcdhead.s boot.o bootimage.o rawfs86.o
$(LD86) -o $@ \
boothead.s boot.o bootimage.o rawfs86.o $(LIBS)
install -S 16kb bootcd
edparams.o: boot.c
ln -f boot.c edparams.c
$(CC) $(CFLAGS) -DUNIX -c edparams.c
@ -112,5 +117,5 @@ $(BIN)/edparams: edparams
clean:
rm -f *.bak *.o
rm -f bootblock addaout installboot boot masterboot jumpboot edparams
rm -f bootblock addaout installboot boot masterboot jumpboot edparams bootcd
rm -f dosboot boot.com mkfile mkfile.com

View file

@ -49,6 +49,13 @@ int fsok= -1; /* File system state. Initially unknown. */
static int block_size;
#if BIOS
/* this data is reserved for BIOS int 0x13 to put the 'specification packet'
* in. It has a structure of course, but we don't define a struct because
* of compiler padding. We fiddle out the bytes ourselves later.
*/
unsigned char boot_spec[24];
char *bios_err(int err)
/* Translate BIOS error code to a readable string. (This is a rare trait
* known as error checking and reporting. Take a good look at it, you won't
@ -491,9 +498,11 @@ void initialize(void)
#if !DOS
u32_t dma64k= (memend - 1) & ~0x0FFFFL;
/* Check if data segment crosses a 64K boundary. */
if (newaddr + (daddr - caddr) < dma64k) newaddr= dma64k - runsize;
#endif
/* Set the new caddr for relocate. */
caddr= newaddr;
@ -1828,19 +1837,106 @@ void monitor(void)
#if BIOS
unsigned char cdspec[25];
void bootcdinfo(u32_t, int *, int drive);
void fixcdroot(void)
{
int i, d;
int ret;
char name[20];
u32_t addr;
char *bootcd;
/* Booting from CD? If so, add the cdroot in.. */
int driveno, termno;
char *drive, *term, *rid;
if((rid = b_value("ramimagedev"))) {
static int f = 0;
int i, j;
char ram[15];
ram[0] = 'c';
ram[1] = '0';
if(rid[0] == 'c' || rid[0] == 'C') j = 2;
else j = 0;
f++;
for(i = 2; i < sizeof(ram)-1; i++, j++) {
ram[i] = rid[j];
if(ram[i] == 'p') ram[i] = '\0';
if(ram[i] == '\0') break;
}
ram[sizeof(ram)-1] = '\0';
b_setvar(E_SPECIAL|E_VAR, "ramname", ram);
}
/* the rest of this code is.. not finished */
return;
if(!(bootcd = b_value("bootcd")) || bootcd[0] != '1') return;
if(!(drive = b_value("drive"))) return;
if(!(term = b_value("term"))) termno = 0;
else termno = term[0] - '0';
driveno = 100 * (drive[0] - '0') + 10 * (drive[1] - '0') + drive[2] - '0';
/* cdroot has to be derived from what the BIOS
* says the actual CD was.
*/
memset(cdspec, 0, sizeof(cdspec));
addr = mon2abs(cdspec);
ret = 0x38;
printf("bootcdinfo (%lx, drive %d, term %d)..\n", addr, driveno, termno);
bootcdinfo(addr, &ret, (termno << 8) | driveno);
i = 0;
printf("drive %02x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
driveno,
cdspec[i], cdspec[i+1], cdspec[i+2], cdspec[i+3],
cdspec[i+4], cdspec[i+5], cdspec[i+6], cdspec[i+7],
cdspec[i+8], cdspec[i+9], cdspec[i+10], cdspec[i+11]);
/* CD's are faked to be booting from partition 1
* (more to the point, that is their appropriate
* root partition to mount).
*/
strcpy(bootdev.name, "d0p1");
/* boot_spec[3] is the controller number (0 or 1),
* boot_spec[8] is the device specification. The
* below only works for IDE CD drives. boot_spec is
* filled in by BIOS after an int 0x13 call in boothead.s.
*/
bootdev.name[1] += boot_spec[3] * 2 + boot_spec[8];
bootdev.primary = 1; /* p1 */
b_setvar(E_SPECIAL|E_VAR, "cdroot", bootdev.name); /* dXp1 */
strcpy(name, "c0");
strcat(name, bootdev.name);
name[4] = '\0';
b_setvar(E_SPECIAL|E_VAR, "cddrive", name); /* c0dX */
return;
}
void boot(void)
/* Load Minix and start it, among other things. */
{
/* Initialize tables. */
initialize();
/* Get environment variables from the parameter sector. */
get_parameters();
fixcdroot();
while (1) {
/* While there are commands, execute them! */
while (cmds != nil) execute();
fixcdroot();
/* The "monitor" is just a "read one command" thing. */
monitor();
}

1535
boot/bootcdhead.s Normal file

File diff suppressed because it is too large Load diff

View file

@ -1204,6 +1204,44 @@ bcd: movb ah, al
.data1 0xD5,10 ! aad ! ax = (al >> 4) * 10 + (al & 0x0F)
ret ! (BUG: assembler messes up aad & aam!)
! void bootcdinfo(u32_t bufaddr, int *ret, int drive)
! If booted from CD, do BIOS int 0x13 call to obtain boot CD device.
.define _bootcdinfo
_bootcdinfo:
push bp
mov bp, sp
push ax
push bx
push cx
push dx
push si
push ds
mov bx, 10(bp) ! drive number
mov cx, 8(bp)
mov ax, 4(bp) ! buffer address from stack
mov dx, 6(bp)
call abs2seg
mov si, ax ! bios will put data in ds:si
mov ds, dx
! movb dl, #0x00
movb dh, #0x00
movb dl, bl
! mov ax, #0x4b01 ! command 0x4b, subcommand 0x01
movb ah, #0x4b
movb al, bh
int 0x13
mov bp, cx
mov (bp), ax
pop ds
pop si
pop dx
pop cx
pop bx
pop ax
pop bp
ret
! Support function for Minix-386 to make a BIOS int 13 call (disk I/O).
bios13:
mov bp, sp