summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2000-08-17 20:15:41 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2000-08-17 20:15:41 +0000
commit1e70b280d824eb2effad54d6a1674d9f5ee4c4bc (patch)
tree0af02e86aa98936a133bde55403cff3b7de0b326 /sys/arch/i386
parent6a1696496f37d377d2cdfb30b4dc44eed02bba1b (diff)
pcibios0 at bios0 flags 0x0000
this is now a real device, which looks in flags for disabling address, interrupt or bus fixup. bios0's flags are to disable bios32 and pcibios probing. since boot_config support editing flags, it's posible to adjust pcibios functionality in the generic kernel upon boot time. man is coming.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/conf/GENERIC9
-rw-r--r--sys/arch/i386/conf/RAMDISK7
-rw-r--r--sys/arch/i386/conf/RAMDISKB7
-rw-r--r--sys/arch/i386/conf/RAMDISKC7
-rw-r--r--sys/arch/i386/conf/RAMDISK_CD7
-rw-r--r--sys/arch/i386/conf/files.i38631
-rw-r--r--sys/arch/i386/i386/autoconf.c15
-rw-r--r--sys/arch/i386/i386/bios.c93
-rw-r--r--sys/arch/i386/i386/bios32.c180
-rw-r--r--sys/arch/i386/include/biosvar.h25
-rw-r--r--sys/arch/i386/pci/pcibios.c127
-rw-r--r--sys/arch/i386/pci/pcibios.h6
12 files changed, 221 insertions, 293 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 40cf2e8e9bf..d6b9670d839 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.201 2000/08/08 19:23:43 deraadt Exp $
+# $OpenBSD: GENERIC,v 1.202 2000/08/17 20:15:32 mickey Exp $
# $NetBSD: GENERIC,v 1.48 1996/05/20 18:17:23 mrg Exp $
#
# GENERIC -- everything that's currently supported
@@ -39,6 +39,7 @@ mainbus0 at root
bios0 at mainbus0
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
+pcibios0 at bios0 flags 0x0000
isa0 at mainbus0
isa0 at pcib?
@@ -49,7 +50,7 @@ option PCIVERBOSE
option EISAVERBOSE
#option PCMCIAVERBOSE
#option USBVERBOSE
-
+#option PCIBIOSVERBOSE
pchb* at pci? dev ? function ? # PCI-Host bridges
ppb* at pci? dev ? function ? # PCI-PCI bridges
@@ -76,10 +77,6 @@ pcmcia* at cardslot?
cbb* at pci? dev ? function ?
cardslot* at cbb?
-# NOTE: You may need to uncomment the following line for CardBus to work
-option BIOS32,PCIBIOS
-option PCIBIOS_INTR_FIXUP,PCIBIOS_BUS_FIXUP,PCIBIOS_ADDR_FIXUP
-
# PCI USB Controllers
#uhci* at pci? # Universal Host Controller (Intel)
#ohci* at pci? # Open Host Controller
diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK
index a3988bb049a..09e395479f2 100644
--- a/sys/arch/i386/conf/RAMDISK
+++ b/sys/arch/i386/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.91 2000/08/08 19:23:44 deraadt Exp $
+# $OpenBSD: RAMDISK,v 1.92 2000/08/17 20:15:33 mickey Exp $
# from: OpenBSD: INST,v 1.19 1996/11/05 03:49:13 tholo Exp
#
# Install kernels no longer support X.
@@ -52,6 +52,7 @@ mainbus0 at root
bios0 at mainbus0
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
#option APMDEBUG
+pcibios0 at bios0 flags 0x0000
isa0 at mainbus0
eisa0 at mainbus0
@@ -76,10 +77,6 @@ pcic* at pci? dev? function ?
# PCMCIA bus support
pcmcia* at pcic? controller ? socket ?
-# NOTE: You may need to uncomment the following line for CardBus to work
-option BIOS32,PCIBIOS
-option PCIBIOS_INTR_FIXUP,PCIBIOS_BUS_FIXUP,PCIBIOS_ADDR_FIXUP
-
npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?
diff --git a/sys/arch/i386/conf/RAMDISKB b/sys/arch/i386/conf/RAMDISKB
index 17becaf8c7c..71c76657255 100644
--- a/sys/arch/i386/conf/RAMDISKB
+++ b/sys/arch/i386/conf/RAMDISKB
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISKB,v 1.19 2000/08/08 19:23:44 deraadt Exp $
+# $OpenBSD: RAMDISKB,v 1.20 2000/08/17 20:15:33 mickey Exp $
# from: OpenBSD: INST,v 1.19 1996/11/05 03:49:13 tholo Exp
#
# Install kernels no longer support X.
@@ -52,6 +52,7 @@ mainbus0 at root
bios0 at mainbus0
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
#option APMDEBUG
+pcibios0 at bios0 flags 0x0000
isa0 at mainbus0
eisa0 at mainbus0
@@ -76,10 +77,6 @@ pcic* at pci? dev? function ?
# PCMCIA bus support
pcmcia* at pcic? controller ? socket ?
-# NOTE: You may need to uncomment the following line for CardBus to work
-option BIOS32,PCIBIOS
-option PCIBIOS_INTR_FIXUP,PCIBIOS_BUS_FIXUP,PCIBIOS_ADDR_FIXUP
-
npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?
diff --git a/sys/arch/i386/conf/RAMDISKC b/sys/arch/i386/conf/RAMDISKC
index 0a668a45797..eaa814d79a9 100644
--- a/sys/arch/i386/conf/RAMDISKC
+++ b/sys/arch/i386/conf/RAMDISKC
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISKC,v 1.4 2000/08/08 19:23:44 deraadt Exp $
+# $OpenBSD: RAMDISKC,v 1.5 2000/08/17 20:15:33 mickey Exp $
# from: OpenBSD: INST,v 1.19 1996/11/05 03:49:13 tholo Exp
#
# Install kernels no longer support X.
@@ -52,6 +52,7 @@ mainbus0 at root
bios0 at mainbus0
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
#option APMDEBUG
+pcibios0 at bios0 flags 0x0000
isa0 at mainbus0
eisa0 at mainbus0
@@ -82,10 +83,6 @@ pcmcia* at cardslot?
cbb* at pci? dev ? function ?
cardslot* at cbb?
-# NOTE: You may need to uncomment the following line for CardBus to work
-option BIOS32,PCIBIOS
-option PCIBIOS_INTR_FIXUP,PCIBIOS_BUS_FIXUP,PCIBIOS_ADDR_FIXUP
-
npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?
diff --git a/sys/arch/i386/conf/RAMDISK_CD b/sys/arch/i386/conf/RAMDISK_CD
index 5ff30c42a7c..2afbe0ac6cb 100644
--- a/sys/arch/i386/conf/RAMDISK_CD
+++ b/sys/arch/i386/conf/RAMDISK_CD
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK_CD,v 1.18 2000/08/08 19:23:44 deraadt Exp $
+# $OpenBSD: RAMDISK_CD,v 1.19 2000/08/17 20:15:33 mickey Exp $
# from: OpenBSD: INST,v 1.19 1996/11/05 03:49:13 tholo Exp
#
# Install kernels no longer support X.
@@ -52,6 +52,7 @@ mainbus0 at root
bios0 at mainbus0
apm0 at bios0 flags 0x0000 # flags 0x0101 to force protocol version 1.1
#option APMDEBUG
+pcibios0 at bios0 flags 0x0000
isa0 at mainbus0
eisa0 at mainbus0
@@ -76,10 +77,6 @@ pcic* at pci? dev? function ?
# PCMCIA bus support
pcmcia* at pcic? controller ? socket ?
-# NOTE: You may need to uncomment the following line for CardBus to work
-option BIOS32,PCIBIOS
-option PCIBIOS_INTR_FIXUP,PCIBIOS_BUS_FIXUP,PCIBIOS_ADDR_FIXUP
-
npx0 at isa? port 0xf0 irq 13 # math coprocessor
isadma0 at isa?
isapnp0 at isa?
diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386
index 728f3c55199..3652a1ae64a 100644
--- a/sys/arch/i386/conf/files.i386
+++ b/sys/arch/i386/conf/files.i386
@@ -1,4 +1,4 @@
-# $OpenBSD: files.i386,v 1.69 2000/08/08 19:12:38 mickey Exp $
+# $OpenBSD: files.i386,v 1.70 2000/08/17 20:15:33 mickey Exp $
# $NetBSD: files.i386,v 1.73 1996/05/07 00:58:36 thorpej Exp $
#
# new style config file for i386 architecture
@@ -86,15 +86,6 @@ file arch/i386/i386/mainbus.c mainbus
include "../../../dev/pci/files.pci"
file arch/i386/pci/pci_machdep.c pci
file arch/i386/pci/pci_compat.c pci # XXX compatibility
-file arch/i386/pci/pcibios.c pcibios
-file arch/i386/pci/pci_intr_fixup.c pcibios & pcibios_intr_fixup
-file arch/i386/pci/piix.c pcibios & pcibios_intr_fixup
-file arch/i386/pci/opti82c558.c pcibios & pcibios_intr_fixup
-file arch/i386/pci/opti82c700.c pcibios & pcibios_intr_fixup
-file arch/i386/pci/sis85c503.c pcibios & pcibios_intr_fixup
-file arch/i386/pci/via82c586.c pcibios & pcibios_intr_fixup
-file arch/i386/pci/pci_bus_fixup.c pcibios & pcibios_bus_fixup
-file arch/i386/pci/pci_addr_fixup.c pcibios & pcibios_addr_fixup
file arch/i386/pci/pciide_machdep.c pciide
file arch/i386/pci/pcic_pci_machdep.c pcic_pci
@@ -246,16 +237,26 @@ file arch/i386/i386/freebsd_machdep.c compat_freebsd
# OSS audio driver compatibility
include "../../../compat/ossaudio/files.ossaudio"
-device bios {}
-attach bios at mainbus
+device bios {}
+attach bios at mainbus
file arch/i386/i386/bios.c bios needs-count
-device apm
-attach apm at bios
+device apm
+attach apm at bios
file arch/i386/i386/apm.c apm needs-count
file arch/i386/i386/apmcall.S apm
-file arch/i386/i386/bios32.c bios32
+device pcibios
+attach pcibios at bios
+file arch/i386/pci/pcibios.c pcibios needs-count
+file arch/i386/pci/pci_intr_fixup.c pcibios
+file arch/i386/pci/pci_bus_fixup.c pcibios
+file arch/i386/pci/pci_addr_fixup.c pcibios
+file arch/i386/pci/opti82c558.c pcibios
+file arch/i386/pci/opti82c700.c pcibios
+file arch/i386/pci/piix.c pcibios
+file arch/i386/pci/sis85c503.c pcibios
+file arch/i386/pci/via82c586.c pcibios
#
# CARDBUS
diff --git a/sys/arch/i386/i386/autoconf.c b/sys/arch/i386/i386/autoconf.c
index 55cd8540169..13657604bc4 100644
--- a/sys/arch/i386/i386/autoconf.c
+++ b/sys/arch/i386/i386/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.32 2000/08/08 19:12:44 mickey Exp $ */
+/* $OpenBSD: autoconf.c,v 1.33 2000/08/17 20:15:39 mickey Exp $ */
/* $NetBSD: autoconf.c,v 1.20 1996/05/03 19:41:56 christos Exp $ */
/*-
@@ -61,9 +61,6 @@
#include <machine/cpu.h>
#include <machine/biosvar.h>
-#include <dev/pci/pcivar.h>
-#include <i386/pci/pcibios.h>
-
#include <dev/cons.h>
void rootconf __P((void));
@@ -88,14 +85,6 @@ configure()
startrtclock();
-#ifdef BIOS32
- bios32_init();
-#endif
-
-#ifdef PCIBIOS
- pcibios_init();
-#endif
-
if (config_rootfound("mainbus", NULL) == NULL)
panic("configure: mainbus not configured");
@@ -379,7 +368,9 @@ noask:
}
doswap:
+#ifndef DISKLESS
mountroot = dk_mountroot;
+#endif
swdevt[0].sw_dev = argdev = dumpdev =
makedev(major(rootdev), minor(rootdev) + 1);
/* swap size and dumplo set during autoconfigure */
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c
index 47192ff07ec..0a2c1ce8499 100644
--- a/sys/arch/i386/i386/bios.c
+++ b/sys/arch/i386/i386/bios.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: bios.c,v 1.29 2000/07/27 20:38:10 mickey Exp $ */
+/* $OpenBSD: bios.c,v 1.30 2000/08/17 20:15:39 mickey Exp $ */
/*
- * Copyright (c) 1997-1999 Michael Shalayeff
+ * Copyright (c) 1997-2000 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@
#include <i386/isa/isa_machdep.h>
#include "apm.h"
+#include "pcibios.h"
#include "pci.h"
struct bios_softc {
@@ -90,6 +91,7 @@ bios_pciinfo_t *bios_pciinfo;
bios_diskinfo_t *bios_diskinfo;
bios_memmap_t *bios_memmap;
u_int32_t bios_cksumlen;
+struct bios32_entry bios32_entry;
bios_diskinfo_t *bios_getdiskinfo __P((dev_t));
@@ -120,13 +122,16 @@ biosattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
- /* struct bios_softc *sc = (void *) self; */
-#if NAPM > 0
+ struct bios_softc *sc = (struct bios_softc *) self;
struct bios_attach_args *bia = aux;
-#endif
- u_int8_t *va = ISA_HOLE_VADDR(0xffff0);
+ u_int8_t *va;
char *str;
+ int flags;
+ /* remember flags */
+ flags = sc->sc_dev.dv_cfdata->cf_flags;
+
+ va = ISA_HOLE_VADDR(0xffff0);
switch (va[14]) {
default:
case 0xff: str = "PC"; break;
@@ -138,9 +143,38 @@ biosattach(parent, self, aux)
case 0xf9: str = "PC Convertible";break;
case 0xf8: str = "PS/2 386+"; break;
}
- printf(": %s(%02x) BIOS, date %c%c/%c%c/%c%c\n",
+ printf(": %s(%02x) BIOS, date %c%c/%c%c/%c%c",
str, va[15], va[5], va[6], va[8], va[9], va[11], va[12]);
+ /* see if we have BIOS32 extensions */
+ if (!(flags & BIOSF_BIOS32)) {
+ for (va = ISA_HOLE_VADDR(BIOS32_START);
+ va < (u_int8_t *)ISA_HOLE_VADDR(BIOS32_END); va += 16) {
+ bios32_header_t h = (bios32_header_t)va;
+ u_int8_t cksum;
+ int i;
+
+ if (h->signature != BIOS32_SIGNATURE)
+ continue;
+
+ /* verify checksum */
+ for (cksum = 0, i = h->length * 16; i--; cksum += va[i])
+ ;
+ if (cksum != 0)
+ continue;
+
+ if (h->entry <= BIOS32_START || h->entry >= BIOS32_END)
+ continue;
+
+ bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL);
+ bios32_entry.offset = (u_int32_t)ISA_HOLE_VADDR(h->entry);
+ printf(", BIOS32 rev. %d @ 0x%lx", h->rev, h->entry);
+ break;
+ }
+ }
+
+ printf("\n");
+
#if NAPM > 0
if (apm) {
struct bios_attach_args ba;
@@ -159,6 +193,17 @@ biosattach(parent, self, aux)
config_found(self, &ba, bios_print);
}
#endif
+#if NPCI > 0 && NPCIBIOS > 0
+ if (!(flags & BIOSF_PCIBIOS)) {
+ struct bios_attach_args ba;
+
+ ba.bios_dev = "pcibios";
+ ba.bios_func = 0x1A;
+ ba.bios_memt = bia->bios_memt;
+ ba.bios_iot = bia->bios_iot;
+ config_found(self, &ba, bios_print);
+ }
+#endif
}
void
@@ -265,6 +310,40 @@ bios_print(aux, pnp)
}
int
+bios32_service(service, e, ei)
+ u_int32_t service;
+ bios32_entry_t e;
+ bios32_entry_info_t ei;
+{
+ u_int32_t base, count, off, ent;
+
+ if (bios32_entry.offset == 0)
+ return 0;
+
+ base = 0;
+ __asm __volatile("lcall (%4)"
+ : "+a" (service), "+b" (base), "=c" (count), "=d" (off)
+ : "D" (&bios32_entry)
+ : "%esi", "cc", "memory");
+
+ if (service & 0xff)
+ return 0; /* not found */
+
+ ent = base + off;
+ if (ent <= BIOS32_START || ent >= BIOS32_END)
+ return 0;
+
+ e->offset = (vaddr_t)ISA_HOLE_VADDR(ent);
+ e->segment = GSEL(GCODE_SEL, SEL_KPL);
+
+ ei->bei_base = base;
+ ei->bei_size = count;
+ ei->bei_entry = ent;
+
+ return 1;
+}
+
+int
biosopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
diff --git a/sys/arch/i386/i386/bios32.c b/sys/arch/i386/i386/bios32.c
deleted file mode 100644
index 75a0d47b239..00000000000
--- a/sys/arch/i386/i386/bios32.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* $NetBSD: bios32.c,v 1.1 1999/11/17 00:55:50 thorpej Exp $ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1999, by UCHIYAMA Yasushi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. The name of the developer may NOT be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Basic interface to BIOS32 services.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-
-#include <dev/isa/isareg.h>
-#ifdef __NetBSD__
-#include <machine/isa_machdep.h>
-#include <machine/bios32.h>
-#elif defined(__OpenBSD__)
-#include <i386/isa/isa_machdep.h>
-#include <machine/biosvar.h>
-#endif
-
-#include <machine/segments.h>
-
-#define BIOS32_START 0xe0000
-#define BIOS32_SIZE 0x20000
-#define BIOS32_END (BIOS32_START + BIOS32_SIZE - 0x10)
-
-struct bios32_entry bios32_entry;
-
-/*
- * Initialize the BIOS32 interface.
- */
-void
-bios32_init()
-{
- paddr_t entry = 0;
- caddr_t p;
- unsigned char cksum;
- int i;
-
- for (p = (caddr_t)ISA_HOLE_VADDR(BIOS32_START);
- p < (caddr_t)ISA_HOLE_VADDR(BIOS32_END);
- p += 16) {
- if (*(int *)p != BIOS32_MAKESIG('_', '3', '2', '_'))
- continue;
-
- cksum = 0;
- for (i = 0; i < 16; i++)
- cksum += *(unsigned char *)(p + i);
- if (cksum != 0)
- continue;
-
- if (*(p + 9) != 1)
- continue;
-
- entry = *(u_int32_t *)(p + 4);
-
- printf("BIOS32 rev. %d found at 0x%lx\n",
- *(p + 8), entry);
-
- if (entry < BIOS32_START ||
- entry >= BIOS32_END) {
- printf("BIOS32 entry point outside "
- "allowable range\n");
- entry = 0;
- }
- break;
- }
-
- if (entry != 0) {
- bios32_entry.offset = (caddr_t)ISA_HOLE_VADDR(entry);
- bios32_entry.segment = GSEL(GCODE_SEL, SEL_KPL);
- }
-}
-
-/*
- * Call BIOS32 to locate the specified BIOS32 service, and fill
- * in the entry point information.
- */
-int
-bios32_service(service, e, ei)
- u_int32_t service;
- bios32_entry_t e;
- bios32_entry_info_t ei;
-{
- u_int32_t eax, ebx, ecx, edx;
- paddr_t entry;
-
- if (bios32_entry.offset == 0)
- return (0); /* BIOS32 not present */
-
- __asm __volatile("lcall (%%edi)"
- : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
- : "0" (service), "1" (0), "D" (&bios32_entry));
-
- if ((eax & 0xff) != 0)
- return (0); /* service not found */
-
- entry = ebx + edx;
-
- if (entry < BIOS32_START || entry >= BIOS32_END) {
- printf("bios32: entry point for service %c%c%c%c is outside "
- "allowable range\n",
- service & 0xff,
- (service >> 8) & 0xff,
- (service >> 16) & 0xff,
- (service >> 24) & 0xff);
- return (0);
- }
-
- e->offset = (caddr_t)ISA_HOLE_VADDR(entry);
- e->segment = GSEL(GCODE_SEL, SEL_KPL);
-
- ei->bei_base = ebx;
- ei->bei_size = ecx;
- ei->bei_entry = entry;
-
- return (1);
-}
diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h
index a80bf2f4a2d..f2d2b5231e0 100644
--- a/sys/arch/i386/include/biosvar.h
+++ b/sys/arch/i386/include/biosvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosvar.h,v 1.35 2000/03/26 22:38:33 mickey Exp $ */
+/* $OpenBSD: biosvar.h,v 1.36 2000/08/17 20:15:39 mickey Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -39,6 +39,10 @@
#define BOOTARG_LEN (NBPG*1)
#define BOOTBIOS_ADDR (0x7c00)
+ /* BIOS configure flags */
+#define BIOSF_BIOS32 0x0001
+#define BIOSF_PCIBIOS 0x0002
+
/* BIOS media ID */
#define BIOSM_F320K 0xff /* floppy ds/sd 8 spt */
#define BIOSM_F160K 0xfe /* floppy ss/sd 8 spt */
@@ -64,6 +68,16 @@
* BIOS32
*/
typedef
+struct bios32_header {
+ u_int32_t signature; /* 00: signature "_32_" */
+ u_int32_t entry; /* 04: entry point */
+ u_int8_t rev; /* 08: revision */
+ u_int8_t length; /* 09: header length */
+ u_int8_t cksum; /* 0a: modulo 256 checksum */
+ u_int8_t reserved[5];
+} *bios32_header_t;
+
+typedef
struct bios32_entry_info {
paddr_t bei_base;
psize_t bei_size;
@@ -72,12 +86,18 @@ struct bios32_entry_info {
typedef
struct bios32_entry {
- caddr_t offset;
+ u_int32_t offset;
u_int16_t segment;
} __attribute__((__packed__)) *bios32_entry_t;
+#define BIOS32_START 0xe0000
+#define BIOS32_SIZE 0x20000
+#define BIOS32_END (BIOS32_START + BIOS32_SIZE - 0x10)
+
#define BIOS32_MAKESIG(a, b, c, d) \
((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
+#define BIOS32_SIGNATURE BIOS32_MAKESIG('_', '3', '2', '_')
+#define PCIBIOS_SIGNATURE BIOS32_MAKESIG('$', 'P', 'C', 'I')
/*
* CTL_BIOS definitions.
@@ -212,7 +232,6 @@ void bioscnpollc __P((dev_t, int));
void bios_getopt __P((void));
/* bios32.c */
-void bios32_init __P((void));
int bios32_service __P((u_int32_t, bios32_entry_t, bios32_entry_info_t));
extern u_int bootapiver;
diff --git a/sys/arch/i386/pci/pcibios.c b/sys/arch/i386/pci/pcibios.c
index 48981281083..1f54eb77463 100644
--- a/sys/arch/i386/pci/pcibios.c
+++ b/sys/arch/i386/pci/pcibios.c
@@ -1,6 +1,36 @@
-/* $OpenBSD: pcibios.c,v 1.6 2000/08/08 19:12:48 mickey Exp $ */
+/* $OpenBSD: pcibios.c,v 1.7 2000/08/17 20:15:40 mickey Exp $ */
/* $NetBSD: pcibios.c,v 1.4 2000/07/18 11:15:25 soda Exp $ */
+/*
+ * Copyright (c) 2000 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -80,21 +110,11 @@
#include <dev/pci/pcidevs.h>
#include <i386/pci/pcibios.h>
-#ifdef PCIBIOS_INTR_FIXUP
#include <i386/pci/pci_intr_fixup.h>
-#endif
-#ifdef PCIBIOS_BUS_FIXUP
#include <i386/pci/pci_bus_fixup.h>
-#endif
-#ifdef PCIBIOS_ADDR_FIXUP
#include <i386/pci/pci_addr_fixup.h>
-#endif
-#ifdef __NetBSD__
-#include <machine/bios32.h>
-#elif __OpenBSD__
#include <machine/biosvar.h>
-#endif
#ifdef PCIBIOSVERBOSE
int pcibiosverbose = 1;
@@ -126,45 +146,58 @@ void pcibios_print_pir_table __P((void));
#define PCI_IRQ_TABLE_START 0xf0000
#define PCI_IRQ_TABLE_END 0xfffff
+struct pcibios_softc {
+ struct device sc_dev;
+};
+
+struct cfdriver pcibios_cd = {
+ NULL, "pcibios", DV_DULL
+};
+
+int pcibiosprobe __P((struct device *, void *, void *));
+void pcibiosattach __P((struct device *, struct device *, void *));
+
+struct cfattach pcibios_ca = {
+ sizeof(struct pcibios_softc), pcibiosprobe, pcibiosattach
+};
+
+int
+pcibiosprobe(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct bios32_entry_info ei;
+ u_int32_t rev_maj, rev_min, mech1, mech2, scmech1, scmech2, maxbus;
+
+ return (bios32_service(PCIBIOS_SIGNATURE, &pcibios_entry, &ei) &&
+ pcibios_get_status(&rev_maj, &rev_min, &mech1, &mech2,
+ &scmech1, &scmech2, &maxbus) == PCIBIOS_SUCCESS);
+}
+
void
-pcibios_init()
+pcibiosattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
+ struct pcibios_softc *sc = (struct pcibios_softc *)self;
struct bios32_entry_info ei;
u_int32_t rev_maj, rev_min, mech1, mech2, scmech1, scmech2;
+ int flags = sc->sc_dev.dv_cfdata->cf_flags;
- if (bios32_service(BIOS32_MAKESIG('$', 'P', 'C', 'I'),
- &pcibios_entry, &ei) == 0) {
- /*
- * No PCI BIOS found; will fall back on old
- * mechanism.
- */
- return;
- }
-
- /*
- * We've located the PCI BIOS service; get some information
- * about it.
- */
- if (pcibios_get_status(&rev_maj, &rev_min, &mech1, &mech2,
- &scmech1, &scmech2, &pcibios_max_bus) != PCIBIOS_SUCCESS) {
- /*
- * We can't use the PCI BIOS; will fall back on old
- * mechanism.
- */
- return;
- }
+ bios32_service(PCIBIOS_SIGNATURE, &pcibios_entry, &ei);
+ pcibios_get_status(&rev_maj, &rev_min, &mech1, &mech2,
+ &scmech1, &scmech2, &pcibios_max_bus);
- printf("PCI BIOS rev. %d.%d found at 0x%lx\n", rev_maj, rev_min >> 4,
+ printf(": rev. %d.%d found at 0x%lx\n", rev_maj, rev_min >> 4,
ei.bei_entry);
#ifdef PCIBIOSVERBOSE
- printf("pcibios: config mechanism %s%s, special cycles %s%s, "
- "last bus %d\n",
+ printf("%s: config mechanism %s%s, special cycles %s%s, last bus %d\n",
+ sc->sc_dev.dv_xname,
mech1 ? "[1]" : "[x]",
mech2 ? "[2]" : "[x]",
scmech1 ? "[1]" : "[x]",
scmech2 ? "[2]" : "[x]",
pcibios_max_bus);
-
#endif
/*
@@ -180,8 +213,8 @@ pcibios_init()
*/
pcibios_pir_init();
-#ifdef PCIBIOS_INTR_FIXUP
- if (pcibios_pir_table != NULL) {
+ if (!(flags & PCIBIOS_INTR_FIXUP) &&
+ pcibios_pir_table != NULL) {
int rv;
u_int16_t pciirq;
@@ -207,18 +240,14 @@ pcibios_init()
* XXX mask.
*/
}
-#endif
-#ifdef PCIBIOS_BUS_FIXUP
- pcibios_max_bus = pci_bus_fixup(NULL, 0);
-#ifdef PCIBIOSVERBOSE
- printf("PCI bus #%d is the last bus\n", pcibios_max_bus);
-#endif
-#endif
+ if (!(flags & PCIBIOS_BUS_FIXUP)) {
+ pcibios_max_bus = pci_bus_fixup(NULL, 0);
+ printf("PCI bus #%d is the last bus\n", pcibios_max_bus);
+ }
-#ifdef PCIBIOS_ADDR_FIXUP
- pci_addr_fixup(NULL, pcibios_max_bus);
-#endif
+ if (!(flags & PCIBIOS_ADDR_FIXUP))
+ pci_addr_fixup(NULL, pcibios_max_bus);
}
void
diff --git a/sys/arch/i386/pci/pcibios.h b/sys/arch/i386/pci/pcibios.h
index 20738558942..1949811a319 100644
--- a/sys/arch/i386/pci/pcibios.h
+++ b/sys/arch/i386/pci/pcibios.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcibios.h,v 1.4 2000/08/08 19:12:48 mickey Exp $ */
+/* $OpenBSD: pcibios.h,v 1.5 2000/08/17 20:15:40 mickey Exp $ */
/* $NetBSD: pcibios.h,v 1.2 2000/04/28 17:15:16 uch Exp $ */
/*
@@ -30,6 +30,10 @@
* Data structure definitions for the PCI BIOS interface.
*/
+#define PCIBIOS_ADDR_FIXUP 0x001
+#define PCIBIOS_BUS_FIXUP 0x002
+#define PCIBIOS_INTR_FIXUP 0x004
+
/*
* PCI BIOS return codes.
*/