diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-09-21 04:28:01 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-09-21 04:28:01 +0000 |
commit | 2b8c7888cf060cc6c33d738b2aed5bd76b9ec749 (patch) | |
tree | edef0ae33d1c627061199a5b3fff9eb09e2baafd /sys | |
parent | daac31c7d27c4b339b96b96f2089613d7c2ae443 (diff) |
support new boots
add to your config:
bios0 at mainbus0
apm0 at mainbus0 # (if you are using APM)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/Makefile.i386 | 6 | ||||
-rw-r--r-- | sys/arch/i386/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/i386/conf/files.i386 | 7 | ||||
-rw-r--r-- | sys/arch/i386/i386/apm.c | 25 | ||||
-rw-r--r-- | sys/arch/i386/i386/bios.c | 345 | ||||
-rw-r--r-- | sys/arch/i386/i386/conf.c | 7 | ||||
-rw-r--r-- | sys/arch/i386/i386/genassym.cf | 15 | ||||
-rw-r--r-- | sys/arch/i386/i386/locore.s | 148 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 39 | ||||
-rw-r--r-- | sys/arch/i386/i386/mainbus.c | 29 | ||||
-rw-r--r-- | sys/arch/i386/include/apmvar.h | 29 | ||||
-rw-r--r-- | sys/arch/i386/include/conf.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 10 | ||||
-rw-r--r-- | sys/arch/i386/stand/Makefile.inc | 4 |
15 files changed, 442 insertions, 239 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 65b65f66a67..0ca300f8060 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.46 1997/09/19 09:45:01 deraadt Exp $ +# $OpenBSD: GENERIC,v 1.47 1997/09/21 04:27:32 mickey Exp $ # $NetBSD: GENERIC,v 1.48 1996/05/20 18:17:23 mrg Exp $ # # GENERIC -- everything that's currently supported @@ -35,6 +35,8 @@ config bsd swap generic mainbus0 at root +bios0 at mainbus0 +apm0 at mainbus0 isa0 at mainbus0 eisa0 at mainbus0 pci0 at mainbus0 bus ? diff --git a/sys/arch/i386/conf/Makefile.i386 b/sys/arch/i386/conf/Makefile.i386 index 2502d6abc98..885674ef2bf 100644 --- a/sys/arch/i386/conf/Makefile.i386 +++ b/sys/arch/i386/conf/Makefile.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.i386,v 1.20 1997/09/15 02:40:29 deraadt Exp $ +# $OpenBSD: Makefile.i386,v 1.21 1997/09/21 04:27:33 mickey Exp $ # $NetBSD: Makefile.i386,v 1.67 1996/05/11 16:12:11 mycroft Exp $ # Makefile for OpenBSD @@ -161,10 +161,6 @@ links: sed 's,.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks sh makelinks && rm -f dontlink makelinks -# depend on APM -.include "${I386}/apm_init/Makefile.inc" -locore.o: ${APMINC} - SRCS= ${I386}/i386/locore.s \ param.c ioconf.c ${CFILES} ${SFILES} depend:: .depend diff --git a/sys/arch/i386/conf/RAMDISK b/sys/arch/i386/conf/RAMDISK index 3017a8ee750..05f780f3d5a 100644 --- a/sys/arch/i386/conf/RAMDISK +++ b/sys/arch/i386/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.12 1997/09/15 03:12:26 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.13 1997/09/21 04:27:33 mickey Exp $ # from: OpenBSD: INST,v 1.19 1996/11/05 03:49:13 tholo Exp # # Install kernels no longer support X. @@ -50,6 +50,8 @@ config bsd root on rd0a swap on rd0b mainbus0 at root +bios0 at mainbus0 +apm0 at mainbus0 isa0 at mainbus0 eisa0 at mainbus0 pci0 at mainbus0 diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index 704fe2f8760..1cb36de3b37 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: files.i386,v 1.32 1997/09/02 08:48:12 downsj Exp $ +# $OpenBSD: files.i386,v 1.33 1997/09/21 04:27:34 mickey Exp $ # $NetBSD: files.i386,v 1.73 1996/05/07 00:58:36 thorpej Exp $ # # new style config file for i386 architecture @@ -218,3 +218,8 @@ file arch/i386/i386/freebsd_machdep.c compat_freebsd device apm attach apm at mainbus file arch/i386/i386/apm.c apm needs-count + +device bios +attach bios at mainbus +file arch/i386/i386/bios.c bios needs-count + diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index c33b895fcdb..22b4e2ad1b0 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.6 1997/08/19 20:09:04 angelos Exp $ */ +/* $OpenBSD: apm.c,v 1.7 1997/09/21 04:27:52 mickey Exp $ */ /*- * Copyright (c) 1995 John T. Kohl. All rights reserved. @@ -610,34 +610,13 @@ apmattach(parent, self, aux) */ if (apminfo.apm_detail & APM_32BIT_SUPPORTED) { apminfo.apm_segsel = GSEL(GAPM32CODE_SEL,SEL_KPL); - apminfo.apm_code32_seg_base <<= 4; - apminfo.apm_code16_seg_base <<= 4; - apminfo.apm_data_seg_base <<= 4; - /* something is still amiss in the limit-fetch in the boot - loader; it returns incorrect (too small) limits. - for now, force them to max size. */ - apminfo.apm_code32_seg_len = 65536; - apminfo.apm_data_seg_len = 65536; -#if 0 - switch ((APM_MAJOR_VERS(apminfo.apm_detail) << 8) + - APM_MINOR_VERS(apminfo.apm_detail)) { - case 0x0100: - apminfo.apm_code32_seg_len = 65536; - apminfo.apm_data_seg_len = 65536; - break; - default: - if (apminfo.apm_data_seg_len == 0) - apminfo.apm_data_seg_len = 65536; - break; - } -#endif setsegment(&dynamic_gdt[GAPM32CODE_SEL].sd, (void *)ISA_HOLE_VADDR(apminfo.apm_code32_seg_base), apminfo.apm_code32_seg_len-1, SDT_MEMERA, SEL_KPL, 1, 0); setsegment(&dynamic_gdt[GAPM16CODE_SEL].sd, (void *)ISA_HOLE_VADDR(apminfo.apm_code16_seg_base), - 65536-1, /* just in case */ + apminfo.apm_code32_seg_len-1, SDT_MEMERA, SEL_KPL, 0, 0); setsegment(&dynamic_gdt[GAPMDATA_SEL].sd, (void *)ISA_HOLE_VADDR(apminfo.apm_data_seg_base), diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c new file mode 100644 index 00000000000..ccb22586d82 --- /dev/null +++ b/sys/arch/i386/i386/bios.c @@ -0,0 +1,345 @@ +/* $OpenBSD: bios.c,v 1.1 1997/09/21 04:27:53 mickey Exp $ */ + +/* + * Copyright (c) 1997 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 REGENTS 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. + * + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/device.h> +#include <sys/errno.h> +#include <sys/proc.h> + +#include <vm/vm.h> +#include <sys/sysctl.h> + +#include <dev/cons.h> + +#include <machine/cpu.h> +#include <machine/pio.h> +#include <machine/cpufunc.h> +#include <machine/conf.h> +#include <machine/gdt.h> +#include <machine/pcb.h> +#include <machine/biosvar.h> +#include <machine/apmvar.h> + +#include <dev/isa/isareg.h> +#include <i386/isa/isa_machdep.h> + +#include "apm.h" + +#define LMVAS (1024*1024-NBPG) +#define LMVOF NBPG + +int gdt_get_slot __P((void)); + +struct bios_softc { + struct device sc_dev; + + bus_space_handle_t bt; +}; + +int biosprobe __P((struct device *, void *, void *)); +void biosattach __P((struct device *, struct device *, void *)); +void bios_init __P((bus_space_handle_t)); +static __inline int bios_call __P((u_int cmd, u_int arg)); + +struct cfattach bios_ca = { + sizeof(struct bios_softc), biosprobe, biosattach +}; + +struct cfdriver bios_cd = { + NULL, "bios", DV_DULL +}; + +int bios_initted = 0; +int bios_ds, bios_cs16; +bus_space_handle_t bios_lmva; +struct { + u_int32_t ip; + u_int16_t cs; +} bios_kentry; +struct BIOS_vars BIOS_vars; + +static __inline int +bios_call(cmd, arg) + u_int cmd; + u_int arg; +{ + int rv; + __asm volatile ("pushl %1\n\t" + "pushl %2\n\t" + "pushl %%ds\n\t" + "movl %4, %%ds\n\t" + "movl %4, %%es\n\t" + "movl %4, %%gs\n\t" + "movl %4, %%fs\n\t" + "lcall %%cs:(%3)\n\t" + "popl %%ds\n\t" + "addl $8, %%esp" + : "=a" (rv) + : "id" (cmd), "r" (arg), + "r" (&bios_kentry), "r" (bios_ds)); + return rv; +} + +void +bios_init(bt) + bus_space_handle_t bt; +{ + if (bios_initted) + return; + + if (bus_space_map(bt, LMVOF, LMVAS, 0, &bios_lmva) == 0) { + extern union descriptor *dynamic_gdt; + + setsegment(&dynamic_gdt[bios_kentry.cs = gdt_get_slot()].sd, + (void*)bios_lmva, LMVAS, SDT_MEMERA, SEL_KPL, 1, 0); + setsegment(&dynamic_gdt[bios_ds = gdt_get_slot()].sd, + (void*)bios_lmva, LMVAS, SDT_MEMRWA, SEL_KPL, 1, 0); + setsegment(&dynamic_gdt[bios_cs16 = gdt_get_slot()].sd, + (void*)bios_lmva, LMVAS, SDT_MEMERA, SEL_KPL, 0, 0); + + bios_initted++; + } +} + +int +biosprobe(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct bios_attach_args *bia = aux; + extern int bootapiver; /* locore.s */ + + if (bootapiver == 0) + return 0; + +#if 0 + if (!bios_initted) { + bus_space_handle_t hsp; + + if (bus_space_map(bia->bios_memt, LMVOF, LMVAS, 0, &hsp) != 0) + return 0; + bus_space_unmap(bia->bios_memt, hsp, LMVAS); + } +#endif + return !bios_cd.cd_ndevs && !strcmp(bia->bios_busname, "bios"); +} + +void +biosattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct bios_softc *sc = (void *) self; + struct bios_attach_args *bia = aux; + + u_int8_t *va = ISA_HOLE_VADDR(0xffff0); + char *p; + + sc->bt = bia->bios_memt; + /* bios_init(sc->bt); */ +#if NAPM > 0 + apminfo.apm_detail = BIOS_vars.apm_detail; + apminfo.apm_code32_seg_base = BIOS_vars.apm_code32_base; + apminfo.apm_code16_seg_base = BIOS_vars.apm_code16_base; + apminfo.apm_code32_seg_len = BIOS_vars.apm_code_len; + apminfo.apm_data_seg_base = BIOS_vars.apm_data_base; + apminfo.apm_data_seg_len = BIOS_vars.apm_data_len; + apminfo.apm_entrypt = BIOS_vars.apm_entry; +#endif + switch (va[14]) { + default: + case 0xff: p = "PC"; break; + case 0xfe: p = "PC/XT"; break; + case 0xfd: p = "PCjr"; break; + case 0xfc: p = "AT/286+"; break; + case 0xfb: p = "PC/XT+"; break; + case 0xfa: p = "PS/2 25/30"; break; + case 0xf9: p = "PC Convertible";break; + case 0xf8: p = "PS/2 386+"; break; + } + printf(": %s(%02x) BIOS, date %c%c/%c%c/%c%c; entry %x:%x\n", + p, va[15], va[5], va[6], va[8], va[9], va[11], va[12], + bios_kentry.cs, bios_kentry.ip); +#ifdef DEBUG + printf("apminfo: %x, code %x/%x[%x], data %x[%x], entry %x\n", + BIOS_vars.apm_detail, BIOS_vars.apm_code32_base, + BIOS_vars.apm_code16_base, BIOS_vars.apm_code_len, + BIOS_vars.apm_data_base, BIOS_vars.apm_data_len, + BIOS_vars.apm_entry); +#endif +} + +int +biosopen(dev, flag, mode, p) + dev_t dev; + int flag, mode; + struct proc *p; +{ + struct bios_softc *sc = bios_cd.cd_devs[0]; + + if (minor(dev)) + return (ENXIO); + + (void)sc; + + return 0; +} + +int +biosclose(dev, flag, mode, p) + dev_t dev; + int flag, mode; + struct proc *p; +{ + struct bios_softc *sc = bios_cd.cd_devs[0]; + + if (minor(dev)) + return (ENXIO); + + (void)sc; + + return 0; +} + +int +biosioctl(dev, cmd, data, flag, p) + dev_t dev; + u_long cmd; + caddr_t data; + int flag; + struct proc *p; +{ + struct bios_softc *sc = bios_cd.cd_devs[0]; + + if (minor(dev)) + return (ENXIO); + + switch (cmd) { + default: + return ENXIO; + } + + (void)sc; + + return 0; +} + +void +bioscnprobe(cn) + struct consdev *cn; +{ +#if 0 + bios_init(I386_BUS_SPACE_MEM); /* XXX */ + if (!bios_initted) + return; + + if (0 && bios_call(BOOTC_CHECK, NULL)) + return; + + cn->cn_pri = CN_NORMAL; + cn->cn_dev = makedev(48, 0); +#endif +} + +void +bioscninit(cn) + struct consdev *cn; +{ + +} + +void +bioscnputc(dev, ch) + dev_t dev; + int ch; +{ + +} + +int +bioscngetc(dev) + dev_t dev; +{ + return -1; +} + +void +bioscnpollc(dev, on) + dev_t dev; + int on; +{ +} + +/* + * machine dependent system variables. + */ +int +cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) + int *name; + u_int namelen; + void *oldp; + size_t *oldlenp; + void *newp; + size_t newlen; + struct proc *p; +{ + extern u_int cnvmem, extmem; + dev_t consdev; + + /* all sysctl names at this level are terminal */ + if (namelen != 1) + return (ENOTDIR); /* overloaded */ + + switch (name[0]) { + case CPU_CONSDEV: + if (cn_tab != NULL) + consdev = cn_tab->cn_dev; + else + consdev = NODEV; + return sysctl_rdstruct(oldp, oldlenp, newp, &consdev, sizeof consdev); + case CPU_BIOSDEV: + return sysctl_rdint(oldp, oldlenp, newp, BIOS_vars.bios_dev); + case CPU_BIOSGEOMETRY: + return sysctl_rdint(oldp, oldlenp, newp, BIOS_vars.bios_geometry); + case CPU_CNVMEM: + return sysctl_rdint(oldp, oldlenp, newp, cnvmem); + case CPU_EXTMEM: + return sysctl_rdint(oldp, oldlenp, newp, extmem); + default: + return EOPNOTSUPP; + } + /* NOTREACHED */ +} diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c index bdc39a82d3a..f76aac4a2c4 100644 --- a/sys/arch/i386/i386/conf.c +++ b/sys/arch/i386/i386/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.33 1997/07/04 17:01:07 downsj Exp $ */ +/* $OpenBSD: conf.c,v 1.34 1997/09/21 04:27:54 mickey Exp $ */ /* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */ /* @@ -35,8 +35,8 @@ #include <sys/buf.h> #include <sys/ioctl.h> #include <sys/tty.h> -#include <sys/conf.h> #include <sys/vnode.h> +#include <machine/conf.h> #include "wdc.h" #include "wd.h" @@ -159,11 +159,11 @@ cdev_decl(mcd); cdev_decl(audio); cdev_decl(svr4_net); #include "joy.h" -cdev_decl(joy); #include "apm.h" cdev_decl(apm); #include "pctr.h" cdev_decl(pctr); +#include "bios.h" cdev_decl(ipl); #ifdef IPFILTER @@ -239,6 +239,7 @@ struct cdevsw cdevsw[] = cdev_random_init(1,random), /* 45: random data source */ cdev_uk_init(NPCTR,pctr), /* 46: pentium performance counters */ cdev_disk_init(NRD,rd), /* 47: ram disk driver */ + cdev_bios_init(NBIOS,bios), /* 48: onboard BIOS PROM */ }; int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]); diff --git a/sys/arch/i386/i386/genassym.cf b/sys/arch/i386/i386/genassym.cf index ca2414fb54f..80760498058 100644 --- a/sys/arch/i386/i386/genassym.cf +++ b/sys/arch/i386/i386/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.1 1997/03/29 07:12:07 tholo Exp $ +# $OpenBSD: genassym.cf,v 1.2 1997/09/21 04:27:54 mickey Exp $ # # Copyright (c) 1982, 1990 The Regents of the University of California. # All rights reserved. @@ -54,6 +54,11 @@ if NAPM > 0 include <machine/apmvar.h> endif +include "bios.h" +if NBIOS > 0 +include <machine/biosvar.h> +endif + if COMPAT_SVR4 > 0 include <compat/svr4/svr4_ucontext.h> endif @@ -164,15 +169,7 @@ endif # Advanced Power Management information if NAPM > 0 -define APM_CODE32 offsetof(struct apm_connect_info, apm_code32_seg_base) -define APM_CODE16 offsetof(struct apm_connect_info, apm_code16_seg_base) -define APM_DATA offsetof(struct apm_connect_info, apm_data_seg_base) -define APM_CODE32_LEN offsetof(struct apm_connect_info, apm_code32_seg_len) -define APM_DATA_LEN offsetof(struct apm_connect_info, apm_data_seg_len) -define APM_ENTRY offsetof(struct apm_connect_info, apm_entrypt) -define APM_DETAIL offsetof(struct apm_connect_info, apm_detail) define APM_CALL offsetof(struct apm_connect_info, apm_entrypt) -define APM_SIZE sizeof(struct apm_connect_info) define APMREG_AX offsetof(struct apmregs, ax) define APMREG_BX offsetof(struct apmregs, bx) define APMREG_CX offsetof(struct apmregs, cx) diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 66f41ca8ede..6bc88832850 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.30 1997/09/11 10:45:43 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.31 1997/09/21 04:27:55 mickey Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -43,6 +43,7 @@ #include "npx.h" #include "assym.h" #include "apm.h" +#include "bios.h" #include "pctr.h" #include <sys/errno.h> @@ -153,16 +154,9 @@ .globl _cpu,_cpu_vendor,_cold,_cnvmem,_extmem,_esym .globl _boothowto,_bootdev,_atdevbase - .globl _cyloffset,_proc0paddr,_curpcb,_PTDpaddr,_dynamic_gdt -#if NAPM > 0 -#include <machine/apmvar.h> - .globl _apminfo - .globl _apm_current_gdt_pdesc /* current GDT pseudo desc. */ - .globl _bootstrap_gdt -_apm_current_gdt_pdesc: - .word 0, 0, 0 -_bootstrap_gdt: - .space SIZEOF_GDTE * BOOTSTRAP_GDT_NUM + .globl _bootapiver,_proc0paddr,_curpcb,_PTDpaddr,_dynamic_gdt +#if NBIOS > 0 + .globl _BIOS_vars #endif _cpu: .long 0 # are we 386, 386sx, 486, 586 or 686 _cpu_vendor: .space 16 # vendor string returned by `cpuid' instruction @@ -171,7 +165,7 @@ _esym: .long 0 # ptr to end of syms _cnvmem: .long 0 # conventional memory size _extmem: .long 0 # extended memory size _atdevbase: .long 0 # location of start of iomem in virtual -_cyloffset: .long 0 +_bootapiver: .long 0 _proc0paddr: .long 0 _PTDpaddr: .long 0 # paddr of PTD, for libkvm @@ -188,7 +182,7 @@ tmpstk: start: movw $0x1234,0x472 # warm boot /* - * Load parameters from stack (howto, bootdev, unit, cyloffset, esym). + * Load parameters from stack (howto, bootdev, unit, bootapiver, esym). * note: (%esp) is return address of boot * (If we want to hold onto /boot, it's physical %esp up to _end.) */ @@ -196,8 +190,6 @@ start: movw $0x1234,0x472 # warm boot movl %eax,RELOC(_boothowto) movl 8(%esp),%eax movl %eax,RELOC(_bootdev) - movl 12(%esp),%eax - movl %eax,RELOC(_cyloffset) movl 16(%esp),%eax testl %eax,%eax jz 1f @@ -209,100 +201,17 @@ start: movw $0x1234,0x472 # warm boot movl 24(%esp),%eax movl %eax,RELOC(_cnvmem) -#if NAPM > 0 - - /* - * Setup APM BIOS: - * - * APM BIOS initialization should be done from real mode or V86 mode. - * - * (by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>) - */ - - /* - * Cleanup %fs and %gs: - * - * Some BIOS bootstrap routine store junk value into %fs - * and %gs. - */ - - xorl %eax, %eax - movw %ax, %fs - movw %ax, %gs - - /* get GDT base */ - sgdt RELOC(_apm_current_gdt_pdesc) - - /* copy GDT to _bootstrap_gdt */ - xorl %ecx, %ecx - movw RELOC(_apm_current_gdt_pdesc), %cx - movl RELOC(_apm_current_gdt_pdesc)+2, %esi - lea RELOC(_bootstrap_gdt), %edi - cld - rep - movsb - - /* setup GDT pseudo descriptor */ - movw $(SIZEOF_GDTE*BOOTSTRAP_GDT_NUM), %ax - movw %ax, RELOC(_apm_current_gdt_pdesc) - leal RELOC(_bootstrap_gdt), %eax - movl %eax, RELOC(_apm_current_gdt_pdesc)+2 - - /* load new GDTR */ - lgdt RELOC(_apm_current_gdt_pdesc) - - /* - * Copy APM initializer under 1MB boundary: - * - * APM initializer program must switch the CPU to real mode. - * But NetBSD kernel runs above 1MB boundary. So we must - * copy the initializer code to conventional memory. - */ - movl RELOC(_apm_init_image_size), %ecx /* size */ - lea RELOC(_apm_init_image), %esi /* source */ - movl $ APM_OURADDR, %edi /* destination */ + movl 12(%esp),%eax + movl %eax,RELOC(_bootapiver) +#if NBIOS > 0 + orl %eax, %eax + jz 1f /* old boots */ + movl 28(%esp), %esi + movl $RELOC(_BIOS_vars), %edi + movl 32(%esp), %ecx cld - rep - movsb - - /* setup GDT for APM initializer */ - lea RELOC(_bootstrap_gdt), %ecx - movl $(APM_OURADDR), %eax /* use %ax for 15..0 */ - movl %eax, %ebx - shrl $16, %ebx /* use %bl for 23..16 */ - /* use %bh for 31..24 */ -#define APM_SETUP_GDT(index, attrib) \ - movl $(index), %si ; \ - lea 0(%ecx,%esi,8), %edx ; \ - movw $0xffff, (%edx) ; \ - movw %ax, 2(%edx) ; \ - movb %bl, 4(%edx) ; \ - movw $(attrib), 5(%edx) ; \ - movb %bh, 7(%edx) - - APM_SETUP_GDT(APM_INIT_CS_INDEX , CS32_ATTRIB) - APM_SETUP_GDT(APM_INIT_DS_INDEX , DS32_ATTRIB) - APM_SETUP_GDT(APM_INIT_CS16_INDEX, CS16_ATTRIB) - - /* - * Call the initializer: - * - * direct intersegment call to conventional memory code - */ - .byte 0x9a /* actually, lcall $APM_INIT_CS_SEL, $0 */ - .long 0 - .word APM_INIT_CS_SEL - - movw %ax,RELOC(_apminfo+APM_DETAIL) - movw %di,RELOC(_apminfo+APM_DETAIL)+2 - movl %ebx,RELOC(_apminfo+APM_ENTRY) - movw %cx,RELOC(_apminfo+APM_CODE32) - shrl $16, %ecx - movw %cx,RELOC(_apminfo+APM_CODE16) - movw %dx,RELOC(_apminfo+APM_DATA) - movw %si,RELOC(_apminfo+APM_CODE32_LEN) - shrl $16, %esi - movw %si,RELOC(_apminfo+APM_DATA_LEN) + rep; movsb +1: #endif /* APM */ /* First, reset the PSL. */ @@ -2265,7 +2174,10 @@ ENTRY(bzero) * Fills in *regs with registers as returned by APM. * returns nonzero if error returned by APM. */ + .data + .globl _apminfo apmstatus: .long 0 + .text ENTRY(apmcall) pushl %ebp movl %esp,%ebp @@ -2278,8 +2190,11 @@ ENTRY(apmcall) pushl %es pushl %fs pushl %gs + pushfl + cli + pushl %ds xorl %ax,%ax -/* movl %ax,%ds # can't toss %ds, we need it for apmstatus*/ + movl %ax,%ds movl %ax,%es movl %ax,%fs movl %ax,%gs @@ -2290,9 +2205,6 @@ ENTRY(apmcall) movw %cs:APMREG_CX(%ebx),%cx movw %cs:APMREG_DX(%ebx),%dx movw %cs:APMREG_BX(%ebx),%bx - pushfl - cli - pushl %ds lcall %cs:(_apminfo+APM_CALL) popl %ds setc apmstatus @@ -2319,16 +2231,6 @@ ENTRY(apmcall) popl %esi popl %ebp ret - -_apm_init_image: - .globl _apm_init_image - -8: -#include "lib/apm_init/apm_init.inc" -9: +#endif /* APM */ -_apm_init_image_size: - .globl _apm_init_image_size - .long 9b - 8b -#endif /* APM */ diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 9f4cabca211..c577698ca55 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.47 1997/09/02 08:50:30 downsj Exp $ */ +/* $OpenBSD: machdep.c,v 1.48 1997/09/21 04:27:55 mickey Exp $ */ /* $NetBSD: machdep.c,v 1.202 1996/05/18 15:54:59 christos Exp $ */ /*- @@ -180,8 +180,8 @@ void consinit __P((void)); int bus_mem_add_mapping __P((bus_addr_t, bus_size_t, int, bus_space_handle_t *)); -extern long cnvmem; /* BIOS's conventional memory size */ -extern long extmem; /* BIOS's extended memory size */ +extern u_int cnvmem; /* BIOS's conventional memory size */ +extern u_int extmem; /* BIOS's extended memory size */ /* * Machine-dependent startup code @@ -533,39 +533,6 @@ identifycpu() #endif } -/* - * machine dependent system variables. - */ -int -cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) - int *name; - u_int namelen; - void *oldp; - size_t *oldlenp; - void *newp; - size_t newlen; - struct proc *p; -{ - dev_t consdev; - - /* all sysctl names at this level are terminal */ - if (namelen != 1) - return (ENOTDIR); /* overloaded */ - - switch (name[0]) { - case CPU_CONSDEV: - if (cn_tab != NULL) - consdev = cn_tab->cn_dev; - else - consdev = NODEV; - return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev, - sizeof consdev)); - default: - return (EOPNOTSUPP); - } - /* NOTREACHED */ -} - #ifdef COMPAT_IBCS2 void ibcs2_sendsig __P((sig_t, int, int, u_long, int, union sigval)); diff --git a/sys/arch/i386/i386/mainbus.c b/sys/arch/i386/i386/mainbus.c index a6623888a55..0aaea20903a 100644 --- a/sys/arch/i386/i386/mainbus.c +++ b/sys/arch/i386/i386/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.8 1996/11/28 23:37:37 niklas Exp $ */ +/* $OpenBSD: mainbus.c,v 1.9 1997/09/21 04:27:56 mickey Exp $ */ /* $NetBSD: mainbus.c,v 1.8 1996/04/11 22:13:37 cgd Exp $ */ /* @@ -46,10 +46,14 @@ #include "pci.h" #include "apm.h" +#include "bios.h" #if NAPM > 0 #include <machine/apmvar.h> #endif +#if NBIOS > 0 +#include <machine/biosvar.h> +#endif int mainbus_match __P((struct device *, void *, void *)); void mainbus_attach __P((struct device *, struct device *, void *)); @@ -72,6 +76,9 @@ union mainbus_attach_args { #if NAPM > 0 struct apm_attach_args mba_aaa; #endif +#if NBIOS > 0 + struct bios_attach_args mba_bios; +#endif }; /* @@ -98,6 +105,20 @@ mainbus_attach(parent, self, aux) printf("\n"); +#if NBIOS > 0 + { + mba.mba_bios.bios_busname = "bios"; + mba.mba_bios.bios_iot = I386_BUS_SPACE_IO; + mba.mba_bios.bios_memt = I386_BUS_SPACE_MEM; + config_found(self, &mba.mba_bios, mainbus_print); + } +#endif +#if NAPM > 0 + { + mba.mba_aaa.aaa_busname = "apm"; + config_found(self, &mba.mba_aaa, mainbus_print); + } +#endif if (1 /* XXX ISA NOT YET SEEN */) { mba.mba_iba.iba_busname = "isa"; mba.mba_iba.iba_iot = I386_BUS_SPACE_IO; @@ -127,12 +148,6 @@ mainbus_attach(parent, self, aux) config_found(self, &mba.mba_pba, mainbus_print); } #endif -#if NAPM > 0 - { - mba.mba_aaa.aaa_busname = "apm"; - config_found(self, &mba.mba_aaa, mainbus_print); - } -#endif } int diff --git a/sys/arch/i386/include/apmvar.h b/sys/arch/i386/include/apmvar.h index 05ae5cbb721..b960bb3ad5e 100644 --- a/sys/arch/i386/include/apmvar.h +++ b/sys/arch/i386/include/apmvar.h @@ -1,4 +1,5 @@ /* $NetBSD$ */ + /* * Copyright (c) 1995 John T. Kohl * All rights reserved. @@ -157,7 +158,7 @@ #define APM_OEM 0x80 -#ifdef _LOCORE +#ifndef _LOCORE /* * LP (Laptop Package) * @@ -173,32 +174,6 @@ * Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) */ -/* Error code of APM initializer */ -#define APMINI_CANTFIND 0xffffffff -#define APMINI_NOT32BIT 0xfffffffe -#define APMINI_CONNECTERR 0xfffffffd - -#define SIZEOF_GDTE 8 -#define BOOTSTRAP_GDT_NUM 9 /* see i386/boot/table.c */ - -#define APM_INIT_CS_INDEX (BOOTSTRAP_GDT_NUM - 3) -#define APM_INIT_DS_INDEX (BOOTSTRAP_GDT_NUM - 2) -#define APM_INIT_CS16_INDEX (BOOTSTRAP_GDT_NUM - 1) -#define APM_INIT_CS_SEL (APM_INIT_CS_INDEX << 3) -#define APM_INIT_DS_SEL (APM_INIT_DS_INDEX << 3) -#define APM_INIT_CS16_SEL (APM_INIT_CS16_INDEX << 3) - -#define CS32_ATTRIB 0xCF9e -#define CS16_ATTRIB 0x0F9e -#define DS32_ATTRIB 0xCF92 - -#define BOOTSTRAP_DS_SEL 0x10 -/* APM initializer physical address */ -#define APM_OURADDR 0x00080000 -#define APM_RELOC(x) ((x) - _apm_init_image) - -#else /* !_LOCORE */ - /* filled in by apmcall */ struct apmregs { u_short ax; diff --git a/sys/arch/i386/include/conf.h b/sys/arch/i386/include/conf.h index 34d1559c9a6..5c791b14abf 100644 --- a/sys/arch/i386/include/conf.h +++ b/sys/arch/i386/include/conf.h @@ -62,3 +62,12 @@ cdev_decl(lms); cdev_decl(pms); cdev_decl(joy); + +/* open, close, ioctl, mmap */ +#define cdev_bios_init(c,n) { \ + dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ + (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ + (dev_type_stop((*))) enodev, \ + 0, seltrue, (dev_type_mmap((*))) enodev } + +cdev_decl(bios); diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 02ab0b02ca9..cbe03dbb86d 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -206,11 +206,19 @@ void setconf __P((void)); * CTL_MACHDEP definitions. */ #define CPU_CONSDEV 1 /* dev_t: console terminal device */ -#define CPU_MAXID 2 /* number of valid machdep ids */ +#define CPU_BIOSDEV 2 /* int: BIOS boot device */ +#define CPU_BIOSGEOMETRY 3 /* int: BIOS boot device geometry */ +#define CPU_CNVMEM 4 /* int: amount of conventional memory */ +#define CPU_EXTMEM 5 /* int: amount of extended memory */ +#define CPU_MAXID 6 /* number of valid machdep ids */ #define CTL_MACHDEP_NAMES { \ { 0, 0 }, \ { "console_device", CTLTYPE_STRUCT }, \ + { "biosdev", CTLTYPE_INT }, \ + { "biosgeo", CTLTYPE_INT }, \ + { "cnvmem", CTLTYPE_INT }, \ + { "extmem", CTLTYPE_INT }, \ } #endif /* !_I386_CPU_H_ */ diff --git a/sys/arch/i386/stand/Makefile.inc b/sys/arch/i386/stand/Makefile.inc index 9ba16008078..78c3a4934a9 100644 --- a/sys/arch/i386/stand/Makefile.inc +++ b/sys/arch/i386/stand/Makefile.inc @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile.inc,v 1.14 1997/08/13 04:03:27 mickey Exp $ +# $OpenBSD: Makefile.inc,v 1.15 1997/09/21 04:28:00 mickey Exp $ CFLAGS=-O2 -Wall -Werror CPPFLAGS=-I${S} -I${SADIR}/libsa -I. -I${.CURDIR} SACFLAGS=-nostdinc -fpack-struct -fno-builtin -fomit-frame-pointer SACFLAGS+=-D_STANDALONE -# SACFLAGS+=-DBOOT_APM +SACFLAGS+=-DBOOT_APM # CPPFLAGS+=-DSAVE_MEMORY # DEBUGFLAGS=-DDEBUG # DEBUGFLAGS+=-DGIDT_DEBUG |