summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/libsa/diskprobe.c
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-22 23:34:42 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-22 23:34:42 +0000
commit75ff2b524f49004c6afee07d65b8dfa530bf747d (patch)
treee13109ca012cc4313c16dbcbc5585a2cb1bed8b9 /sys/arch/i386/stand/libsa/diskprobe.c
parent0acb196dd2eff01035465ba82dbfe4ee14f19107 (diff)
newer, better stuff; some parts by toby@
Diffstat (limited to 'sys/arch/i386/stand/libsa/diskprobe.c')
-rw-r--r--sys/arch/i386/stand/libsa/diskprobe.c133
1 files changed, 79 insertions, 54 deletions
diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c
index d59ad4a5ed7..66d7f6fd83d 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.2 1997/10/18 00:33:15 weingart Exp $ */
+/* $OpenBSD: diskprobe.c,v 1.3 1997/10/22 23:34:38 mickey Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -34,91 +34,116 @@
#include <sys/param.h>
#include <sys/reboot.h>
+#include <sys/disklabel.h>
+#include <stand/boot/bootarg.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;
+#if notyet
+/* Checksum given buffer */
+static u_int32_t
+bufsum(buf, len)
+ void *buf;
+ int len;
{
- int i;
+ u_int32_t sum = 0;
+ u_int8_t *p = buf;
- for(i = 0; bios_diskinfo[i].bios_number != -1; i++)
- if(bios_diskinfo[i].bios_number == dev)
- return(&bios_diskinfo[i]);
+ while(len--){
+ sum += p[len];
+ }
+ return(sum);
+}
- return(NULL);
+/* Checksum given drive until different */
+void
+disksum(pos)
+ int pos;
+{
+ u_int32_t sum;
+ int len, i;
}
+#endif
/* Probe for all BIOS disks */
void
diskprobe()
{
- int drive, i = 0;
+ u_int drive, i = 0, rv;
+ struct disklabel label;
+ u_int unit, type;
printf("Probing disks:");
/* Floppies */
- for(drive = 0; drive < 4; drive++){
- u_int32_t p = biosdinfo(drive);
-
- if(BIOSNSECTS(p) < 2) continue;
- if(p){
- u_int32_t t = biosdprobe(drive);
- if(t & 0x00FF) continue;
- if(!(t & 0xFF00)) continue;
+ for(drive = 0; drive < 4; drive++) {
+ rv = bios_getinfo(drive, &bios_diskinfo[i]);
- printf(" fd%d", drive);
+ if( (rv & 0x00FF)) continue;
+ if(!(rv & 0xFF00)) continue;
- /* Fill out best we can */
- 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);
- bios_diskinfo[i].bios_sectors = BIOSNSECTS(p);
+ printf(" fd%u", drive);
- i++;
- }
+ /* Fill out best we can - (fd?) */
+ bios_diskinfo[i].bsd_dev = MAKEBOOTDEV(2, 0, 0, drive, 0);
+#if 0
+ disksum(&bios_diskinfo[i]);
+#endif
+ i++;
}
/* Hard disks */
- for(drive = 0x80; drive < 0x88; drive++){
- u_int32_t p = biosdinfo(drive);
-
- if(BIOSNSECTS(p) < 2) continue;
- if(p){
- u_int32_t t = biosdprobe(drive);
- if(t & 0x00FF) continue;
- if(!(t & 0xFF00)) continue;
-
- printf(" hd%d", drive - 128);
-
- /* Fill out best we can */
- 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);
- bios_diskinfo[i].bios_sectors = BIOSNSECTS(p);
-
- i++;
+ for(drive = 0x80; drive < 0x88; drive++) {
+ rv = bios_getinfo(drive, &bios_diskinfo[i]);
+
+ if( (rv & 0x00FF)) continue;
+ if(!(rv & 0xFF00)) continue;
+
+ unit = drive - 0x80;
+ printf(" hd%u%s", unit, (bios_diskinfo[i].bios_edd > 0?"+":""));
+
+ /* Try to find the label, to figure out device type */
+ if((bios_getdisklabel(drive, &label)) ) {
+ printf("*");
+ type = 0; /* XXX let it be IDE */
+ } else {
+ /* Best guess */
+ if (label.d_type == DTYPE_SCSI)
+ type = 4;
+ else
+ type = 0;
}
+
+ /* Fill out best we can */
+ bios_diskinfo[i].bsd_dev = MAKEBOOTDEV(type, 0, 0, unit, 0);
+#if 0
+ disksum(&bios_diskinfo[i]);
+#endif
+ i++;
}
/* End of list */
bios_diskinfo[i].bios_number = -1;
-
- /* XXX - This needs a better place! */
- BIOS_vars.boot_data = bios_diskinfo;
+ addbootarg(BOOTARG_DISKINFO,
+ (i + 1) * sizeof(bios_diskinfo[0]), bios_diskinfo);
printf("\n");
}
+/* Find info on given BIOS disk */
+bios_diskinfo_t *
+bios_dklookup(dev)
+ register int dev;
+{
+ register 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);
+}