summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2001-02-28 16:45:26 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2001-02-28 16:45:26 +0000
commit376b77d2c33785ca85d81399a19566d16a431be2 (patch)
treed1e50abbff3a80d1854f79d47b3fa88e731cc35d /sys
parent24daa8647d28565f00227f1b42403a26a9c862bb (diff)
scan the isa hole for `optional rom's.
found proms are excluded from the iomem_ex such that devices cannot map on the same memory. next step would be for pcic and similar devices to choose memory windows from unused spots in the iomem_ex. currently prom checksum test is not enforced due to broken stinkpad bioses, which do not pass the checksum test. testing from aaron@, fgsch@, fries@, millert@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/bios.c60
-rw-r--r--sys/arch/i386/include/biosvar.h23
2 files changed, 73 insertions, 10 deletions
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c
index 102271112ef..a4427b60e24 100644
--- a/sys/arch/i386/i386/bios.c
+++ b/sys/arch/i386/i386/bios.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: bios.c,v 1.39 2001/01/21 20:23:22 mickey Exp $ */
+/* $OpenBSD: bios.c,v 1.40 2001/02/28 16:45:25 mickey Exp $ */
/*
- * Copyright (c) 1997-2000 Michael Shalayeff
+ * Copyright (c) 1997-2001 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/reboot.h>
+#include <sys/extent.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
@@ -105,8 +106,8 @@ biosprobe(parent, match, aux)
#ifdef BIOS_DEBUG
printf("%s%d: boot API ver %x, %x; args %p[%d]\n",
- bia->bios_dev, bios_cd.cd_ndevs,
- bootapiver, BOOTARG_APIVER, bootargp, bootargc);
+ bia->bios_dev, bios_cd.cd_ndevs,
+ bootapiver, BOOTARG_APIVER, bootargp, bootargc);
#endif
/* there could be only one */
if (bios_cd.cd_ndevs || strcmp(bia->bios_dev, bios_cd.cd_name))
@@ -127,7 +128,7 @@ biosattach(parent, self, aux)
#if (NPCI > 0 && NPCIBIOS > 0) || NAPM > 0
struct bios_attach_args *bia = aux;
#endif
- u_int8_t *va;
+ volatile u_int8_t *va;
char *str;
int flags;
@@ -165,7 +166,7 @@ biosattach(parent, self, aux)
;
if (cksum != 0)
continue;
-
+
if (h->entry <= BIOS32_START || h->entry >= BIOS32_END)
continue;
@@ -207,6 +208,53 @@ biosattach(parent, self, aux)
config_found(self, &ba, bios_print);
}
#endif
+
+ /*
+ * now, that we've gave 'em a chance to attach,
+ * scan and map all the proms we can find
+ */
+ if (!(flags & BIOSF_PROMSCAN)) {
+ volatile u_int8_t *eva;
+
+ for (str = NULL, va = ISA_HOLE_VADDR(0xc0000),
+ eva = ISA_HOLE_VADDR(0xf0000);
+ va < eva; va += 512) {
+ extern struct extent *iomem_ex;
+ bios_romheader_t romh = (bios_romheader_t)va;
+ u_int32_t off, len;
+ u_int8_t cksum;
+ int i;
+
+ if (romh->signature != 0xaa55)
+ continue;
+
+ if (!romh->len || romh->len == 0xff)
+ continue;
+
+ len = romh->len * 512;
+ off = 0xc0000 + (va - (u_int8_t *)
+ ISA_HOLE_VADDR(0xc0000));
+
+ for (cksum = 0, i = len; i--; cksum += va[i])
+ ;
+ if (cksum != 0)
+ printf("!"); /* stinking x20 again */
+
+ if (!str)
+ printf("%s: PROM list:",
+ str = sc->sc_dev.dv_xname);
+ printf(" %05x[%04x]", off, len);
+
+ if ((i = extent_alloc_region(iomem_ex,
+ (paddr_t)off, len, EX_NOWAIT)))
+ printf(":%d", i);
+
+ va += len - 512;
+ }
+ }
+
+ if (str)
+ printf("\n");
}
void
diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h
index 0447d196af4..69dab76cdfd 100644
--- a/sys/arch/i386/include/biosvar.h
+++ b/sys/arch/i386/include/biosvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosvar.h,v 1.37 2000/08/17 22:08:11 mickey Exp $ */
+/* $OpenBSD: biosvar.h,v 1.38 2001/02/28 16:45:25 mickey Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -33,6 +33,7 @@
#ifndef _I386_BIOSVAR_H_
#define _I386_BIOSVAR_H_
+#pragma pack(1)
/* some boxes put apm data seg in the 2nd page */
#define BOOTARG_OFF (NBPG*2)
@@ -40,8 +41,9 @@
#define BOOTBIOS_ADDR (0x7c00)
/* BIOS configure flags */
-#define BIOSF_BIOS32 0x0001
-#define BIOSF_PCIBIOS 0x0002
+#define BIOSF_BIOS32 0x0001
+#define BIOSF_PCIBIOS 0x0002
+#define BIOSF_PROMSCAN 0x0004
/* BIOS media ID */
#define BIOSM_F320K 0xff /* floppy ds/sd 8 spt */
@@ -65,6 +67,18 @@
#define BIOS_MAP_NVS 0x04 /* ACPI NVS memory */
/*
+ * Optional ROM header
+ */
+typedef
+struct bios_romheader {
+ u_int16_t signature; /* 0xaa55 */
+ u_int8_t len; /* length in pages (512 bytes) */
+ u_int32_t entry; /* initialization entry point */
+ u_int8_t reserved[19];
+ u_int16_t pnpheaader; /* offset to PnP expansion header */
+} *bios_romheader_t;
+
+/*
* BIOS32
*/
typedef
@@ -88,7 +102,7 @@ typedef
struct bios32_entry {
u_int32_t offset;
u_int16_t segment;
-} __attribute__((__packed__)) *bios32_entry_t;
+} *bios32_entry_t;
#define BIOS32_START 0xe0000
#define BIOS32_SIZE 0x20000
@@ -241,4 +255,5 @@ extern bios_memmap_t *bios_memmap;
#endif /* _LOCORE */
#endif /* _KERNEL || _STANDALONE */
+#pragma pack()
#endif /* _I386_BIOSVAR_H_ */