summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>1997-10-18 00:33:17 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>1997-10-18 00:33:17 +0000
commit471616d7beb9d52cf9822c2da7178f9b1e595954 (patch)
tree4adbd002eeb842d14d212078646f837175381216 /sys/arch/i386
parent885625daa00685cbe93848f489778e853656803c (diff)
Copy in bios_diskinfo array from /boot space.
Add length field for checksum to same. Start of making /boot deduce bsd dev_t for all BIOS drives.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/bios.c3
-rw-r--r--sys/arch/i386/i386/genassym.cf9
-rw-r--r--sys/arch/i386/i386/locore.s13
-rw-r--r--sys/arch/i386/include/biosvar.h5
-rw-r--r--sys/arch/i386/stand/libsa/biosdev.c64
-rw-r--r--sys/arch/i386/stand/libsa/diskprobe.c27
-rw-r--r--sys/arch/i386/stand/libsa/libsa.h8
7 files changed, 96 insertions, 33 deletions
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c
index 227ac592c24..178bef8d194 100644
--- a/sys/arch/i386/i386/bios.c
+++ b/sys/arch/i386/i386/bios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bios.c,v 1.8 1997/09/29 03:42:25 mickey Exp $ */
+/* $OpenBSD: bios.c,v 1.9 1997/10/18 00:33:11 weingart Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -91,6 +91,7 @@ struct {
u_int16_t cs;
} bios_kentry;
struct BIOS_vars BIOS_vars;
+bios_diskinfo_t bios_diskinfo[16]; /* XXX - For now */
static __inline int
bios_call(cmd, arg)
diff --git a/sys/arch/i386/i386/genassym.cf b/sys/arch/i386/i386/genassym.cf
index 977f15831da..6f3bfd6ad76 100644
--- a/sys/arch/i386/i386/genassym.cf
+++ b/sys/arch/i386/i386/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.3 1997/09/29 03:42:26 mickey Exp $
+# $OpenBSD: genassym.cf,v 1.4 1997/10/18 00:33:12 weingart Exp $
#
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@@ -157,3 +157,10 @@ define IH_COUNT offsetof(struct intrhand, ih_count)
define IH_NEXT offsetof(struct intrhand, ih_next)
endif
+include "bios.h"
+ifdef NBIOS
+include <machine/biosvar.h>
+define BOOT_DATA offsetof(struct BIOS_vars, boot_data)
+define BOOT_SIZE sizeof(bios_diskinfo_t)
+endif
+
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s
index 1811f215a8a..ec5c405bc3d 100644
--- a/sys/arch/i386/i386/locore.s
+++ b/sys/arch/i386/i386/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.33 1997/09/29 03:42:26 mickey Exp $ */
+/* $OpenBSD: locore.s,v 1.34 1997/10/18 00:33:13 weingart Exp $ */
/* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */
/*-
@@ -157,6 +157,7 @@
.globl _bootapiver,_proc0paddr,_curpcb,_PTDpaddr,_dynamic_gdt
#if NBIOS > 0
.globl _BIOS_vars
+ .globl _bios_diskinfo
#endif
_cpu: .long 0 # are we 386, 386sx, 486, 586 or 686
_cpu_vendor: .space 16 # vendor string returned by `cpuid' instruction
@@ -211,6 +212,16 @@ start: movw $0x1234,0x472 # warm boot
movl 32(%esp), %ecx
cld
rep; movsb
+
+ /* Copy bios_diskinfo as well */
+ clc
+ movl 28(%esp), %eax /* Get boot_data */
+ addl $BOOT_DATA, %eax
+ movl (%eax), %esi
+ movl $RELOC(_bios_diskinfo), %edi
+ movl $BOOT_SIZE*16, %ecx
+ cld
+ rep; movsb
1:
#endif /* NBIOS */
diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h
index f6876ed487a..1f3cb40d602 100644
--- a/sys/arch/i386/include/biosvar.h
+++ b/sys/arch/i386/include/biosvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosvar.h,v 1.18 1997/10/17 18:47:00 weingart Exp $ */
+/* $OpenBSD: biosvar.h,v 1.19 1997/10/18 00:33:14 weingart Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -146,10 +146,11 @@ typedef struct _bios_diskinfo {
unsigned int bios_sectors; /* BIOS sectors */
/* BSD section */
- signed int bsd_major; /* Major number of driver (or -1) */
+ dev_t bsd_dev; /* BSD device */
/* Checksum section */
u_int32_t checksum; /* Checksum for drive */
+ unsigned int checklen; /* Number of sectors done */
} bios_diskinfo_t;
diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c
index 8ba83e43fa9..dbb2f53bc49 100644
--- a/sys/arch/i386/stand/libsa/biosdev.c
+++ b/sys/arch/i386/stand/libsa/biosdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosdev.c,v 1.37 1997/10/17 15:03:21 weingart Exp $ */
+/* $OpenBSD: biosdev.c,v 1.38 1997/10/18 00:33:15 weingart Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -42,11 +42,10 @@
#include "biosdev.h"
extern int debug;
+extern bios_diskinfo_t bios_diskinfo[];
struct biosdisk {
- u_int32_t dinfo;
- dev_t bsddev;
- int biosdev;
+ bios_diskinfo_t *bios_info;
int edd_flags;
struct disklabel disklabel;
};
@@ -109,7 +108,10 @@ biosdreset(dev)
return (rv & 0xff)? rv >> 8 : 0;
}
-__inline int
+/*
+ * Read/Write a block from given place using the BIOS.
+ */
+int
biosd_rw(rw, dev, cyl, head, sect, nsect, buf)
int rw, dev, cyl, head;
int sect, nsect;
@@ -171,6 +173,20 @@ EDD_rw(rw, dev, daddr, nblk, buf)
return (rv & 0xff)? rv >> 8 : 0;
}
+char *
+bios_getdisklabel(dev, label)
+ int dev;
+ struct disklabel *label;
+{
+ char *st, buf[DEV_BSIZE];
+ struct dos_mbr mbr;
+ int error;
+
+ error = biosd_rw(F_READ, dev, 0, 0, 1, 1, &mbr);
+ st = getdisklabel(buf, label);
+ return(st);
+}
+
int
biosopen(struct open_file *f, ...)
{
@@ -180,7 +196,7 @@ biosopen(struct open_file *f, ...)
register struct biosdisk *bd;
daddr_t off = LABELSECTOR;
u_int8_t *buf;
- int i;
+ int i, biosdev;
va_start(ap, f);
cp = *(file = va_arg(ap, char **));
@@ -239,13 +255,13 @@ biosopen(struct open_file *f, ...)
case 0: /* wd */
case 4: /* sd */
case 17: /* hd */
- bd->biosdev = unit | 0x80;
+ biosdev = unit | 0x80;
if (maj == 17)
unit = 0;
maj = 17;
break;
case 2: /* fd */
- bd->biosdev = unit;
+ biosdev = unit;
break;
case 7: /* mcd */
case 15: /* scd */
@@ -264,17 +280,15 @@ biosopen(struct open_file *f, ...)
return ENXIO;
}
- bd->dinfo = biosdinfo(bd->biosdev);
- if (!bd->dinfo)
- bd->dinfo = 0x01014f12; /* fake geometry */
- /* pass c: geometry for floppy */
- BIOS_vars.bios_geometry = (bd->biosdev & 0x80)? bd->dinfo
- : biosdinfo(0x80);
- BIOS_vars.bios_dev = (bd->biosdev & 0x80)? bd->biosdev : 0x80;
-
+ bd->bios_info = diskfind(biosdev);
+ if (!bd->bios_info)
+ return ENXIO;
+
+ /* Get EDD stuff */
+ bd->edd_flags = EDDcheck(biosdev);
+
/* maj is fixed later w/ disklabel read */
- bootdev = bd->bsddev = MAKEBOOTDEV(maj, 0, 0, unit, part);
- bd->edd_flags = EDDcheck(bd->biosdev);
+ bootdev = MAKEBOOTDEV(maj, 0, 0, unit, part);
#ifdef BIOS_DEBUG
if (debug) {
@@ -361,7 +375,7 @@ biosopen(struct open_file *f, ...)
}
/* and again w/ fixed maj */
- bootdev = bd->bsddev = MAKEBOOTDEV(maj, 0, 0, unit, part);
+ bootdev = MAKEBOOTDEV(maj, 0, 0, unit, part);
f->f_devdata = bd;
@@ -461,9 +475,11 @@ biosstrategy(devdata, rw, blk, size, buf, rsize)
register size_t i, nsect, n, spt;
nsect = (size + DEV_BSIZE-1) / DEV_BSIZE;
+#if 0
if (rsize != NULL)
blk += bd->disklabel.
d_partitions[B_PARTITION(bd->bsddev)].p_offset;
+#endif
#ifdef BIOS_DEBUG
if (debug)
@@ -474,17 +490,17 @@ biosstrategy(devdata, rw, blk, size, buf, rsize)
#endif
/* handle floppies w/ different from drive geometry */
- if (!(bd->biosdev & 0x80) && bd->disklabel.d_nsectors != 0)
+ if (!(bd->bios_info->bios_number & 0x80) && bd->disklabel.d_nsectors != 0)
spt = bd->disklabel.d_nsectors;
else
- spt = BIOSNSECTS(bd->dinfo);
+ spt = bd->bios_info->bios_sectors;
for (i = 0; error == 0 && i < nsect;
i += n, blk += n, buf += n * DEV_BSIZE) {
register int cyl, hd, sect, j;
void *bb;
- btochs(blk, cyl, hd, sect, BIOSNHEADS(bd->dinfo), spt);
+ btochs(blk, cyl, hd, sect, (bd->bios_info->bios_heads), spt);
if ((sect + (nsect - i)) >= spt)
n = spt - sect;
else
@@ -508,7 +524,7 @@ biosstrategy(devdata, rw, blk, size, buf, rsize)
#endif
/* Try to do operation up to 5 times */
for (error = 1, j = 5; j-- && error;)
- switch (error = biosd_rw(rw, bd->biosdev,
+ switch (error = biosd_rw(rw, bd->bios_info->bios_number,
cyl, hd, sect, n, bb)) {
case 0x00: /* No errors */
case 0x11: /* ECC corrected */
@@ -518,7 +534,7 @@ biosstrategy(devdata, rw, blk, size, buf, rsize)
default: /* All other errors */
printf("\nBIOS error 0x%x (%s)\n", error,
biosdisk_err(error));
- biosdreset(bd->biosdev);
+ biosdreset(bd->bios_info->bios_number);
break;
}
diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c
index 4cc947f8d25..d59ad4a5ed7 100644
--- a/sys/arch/i386/stand/libsa/diskprobe.c
+++ b/sys/arch/i386/stand/libsa/diskprobe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diskprobe.c,v 1.1 1997/10/17 18:46:56 weingart Exp $ */
+/* $OpenBSD: diskprobe.c,v 1.2 1997/10/18 00:33:15 weingart Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -33,15 +33,33 @@
*/
#include <sys/param.h>
+#include <sys/reboot.h>
#include <machine/biosvar.h>
#include "biosdev.h"
#include "libsa.h"
+extern struct BIOS_vars BIOS_vars;
+
/* These get passed to kernel */
bios_diskinfo_t bios_diskinfo[16];
+/* Find info on given BIOS disk */
+bios_diskinfo_t *
+diskfind(dev)
+ int dev;
+{
+ int i;
+
+ for(i = 0; bios_diskinfo[i].bios_number != -1; i++)
+ if(bios_diskinfo[i].bios_number == dev)
+ return(&bios_diskinfo[i]);
+
+ return(NULL);
+}
+
+/* Probe for all BIOS disks */
void
diskprobe()
{
@@ -62,7 +80,7 @@ diskprobe()
printf(" fd%d", drive);
/* Fill out best we can */
- bios_diskinfo[i].bsd_major = 2; /* fd? */
+ bios_diskinfo[i].bsd_dev = MAKEBOOTDEV(2, 0, 0, 0, 0); /* fd? */
bios_diskinfo[i].bios_number = drive;
bios_diskinfo[i].bios_cylinders = BIOSNTRACKS(p);
bios_diskinfo[i].bios_heads = BIOSNHEADS(p);
@@ -85,7 +103,7 @@ diskprobe()
printf(" hd%d", drive - 128);
/* Fill out best we can */
- bios_diskinfo[i].bsd_major = -1; /* XXX - fill in */
+ bios_diskinfo[i].bsd_dev = -1; /* XXX - fill in */
bios_diskinfo[i].bios_number = drive;
bios_diskinfo[i].bios_cylinders = BIOSNTRACKS(p);
bios_diskinfo[i].bios_heads = BIOSNHEADS(p);
@@ -98,6 +116,9 @@ diskprobe()
/* End of list */
bios_diskinfo[i].bios_number = -1;
+ /* XXX - This needs a better place! */
+ BIOS_vars.boot_data = bios_diskinfo;
+
printf("\n");
}
diff --git a/sys/arch/i386/stand/libsa/libsa.h b/sys/arch/i386/stand/libsa/libsa.h
index e423af1810b..01b764dfc0b 100644
--- a/sys/arch/i386/stand/libsa/libsa.h
+++ b/sys/arch/i386/stand/libsa/libsa.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libsa.h,v 1.19 1997/10/17 18:46:57 weingart Exp $ */
+/* $OpenBSD: libsa.h,v 1.20 1997/10/18 00:33:16 weingart Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -33,17 +33,23 @@
*/
#include <lib/libsa/stand.h>
+#include <machine/biosvar.h>
void gateA20 __P((int));
+
void smpprobe __P((void));
void memprobe __P((void));
void diskprobe __P((void));
void apmprobe __P((void));
+
void devboot __P((dev_t, char *));
void *alloca __P((size_t));
void machdep __P((void));
void time_print __P((void));
+bios_diskinfo_t *diskfind __P((int));
+
+
extern const char bdevs[][4];
extern const int nbdevs;
extern int bootdev; /* XXX pass through the global to exec_i386 */