diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-08-25 00:54:20 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-08-25 00:54:20 +0000 |
commit | 79c093d4cfc66c062513625d0ecda5e4d56f4707 (patch) | |
tree | 8fef19f48e7ca74c0631d10c3e0bae6ab7fdf2c5 | |
parent | 1c8832cd15a434f03fb1afa10d86c968b50da9b5 (diff) |
give better support to the bios memory maps.
provide memory maps editing through the machine memory command.
rearrange probing in machdep, so it provides less output,
also giving a shot for apm to fix the memory maps.
changes to kernel are minimal, only that is required due
to the api version bits addition and such cosmetic changes.
tested on all critical kernel,boot combinations; niklas@ ok
-rw-r--r-- | sys/arch/i386/i386/bios.c | 37 | ||||
-rw-r--r-- | sys/arch/i386/include/biosvar.h | 35 | ||||
-rw-r--r-- | sys/arch/i386/stand/Makefile.inc | 12 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/boot.8 | 54 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/apmprobe.c | 79 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/bioscons.c | 36 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 103 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/dev_i386.c | 33 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/libsa.h | 38 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/machdep.c | 44 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 193 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/pciprobe.c | 4 | ||||
-rw-r--r-- | sys/stand/boot/bootarg.h | 31 |
14 files changed, 428 insertions, 275 deletions
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c index 822211ec5de..e530b419064 100644 --- a/sys/arch/i386/i386/bios.c +++ b/sys/arch/i386/i386/bios.c @@ -1,7 +1,7 @@ -/* $OpenBSD: bios.c,v 1.23 1998/11/15 16:33:01 art Exp $ */ +/* $OpenBSD: bios.c,v 1.24 1999/08/25 00:54:18 mickey Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,22 +14,21 @@ * 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. + * 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. - * + * 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. */ /* #define BIOS_DEBUG */ @@ -100,13 +99,13 @@ 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, BOOT_APIVER, bootargp, bootargc); + bootapiver, BOOTARG_APIVER, bootargp, bootargc); #endif /* there could be only one */ if (bios_cd.cd_ndevs || strcmp(bia->bios_dev, bios_cd.cd_name)) return 0; - if (bootapiver < BOOT_APIVER || bootargp == NULL ) + if (bootapiver < BOOTARG_APIVER || bootargp == NULL ) return 0; return 1; @@ -330,7 +329,7 @@ bios_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) switch (name[0]) { case BIOS_DEV: - if (bootapiver < BOOT_APIVER) + if (bootapiver < BOOTARG_APIVER) return EOPNOTSUPP; if ((pdi = bios_getdiskinfo(bootdev)) == NULL) return ENXIO; @@ -339,7 +338,7 @@ bios_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) case BIOS_DISKINFO: if (namelen != 2) return ENOTDIR; - if (bootapiver < BOOT_APIVER) + if (bootapiver < BOOTARG_APIVER) return EOPNOTSUPP; if ((pdi = bios_getdiskinfo(name[1])) == NULL) return ENXIO; diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h index 6109c9b5509..1779fe843f9 100644 --- a/sys/arch/i386/include/biosvar.h +++ b/sys/arch/i386/include/biosvar.h @@ -1,7 +1,7 @@ -/* $OpenBSD: biosvar.h,v 1.29 1999/05/09 15:09:05 mickey Exp $ */ +/* $OpenBSD: biosvar.h,v 1.30 1999/08/25 00:54:18 mickey Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,30 +14,30 @@ * 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. + * 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. - * + * 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. */ #ifndef _I386_BIOSVAR_H_ #define _I386_BIOSVAR_H_ -#define BOOT_APIVER 0x00000002 -#define BOOTARG_LEN (NBPG*1) + /* some boxes put apm data seg in the 2nd page */ #define BOOTARG_OFF (NBPG*2) +#define BOOTARG_LEN (NBPG*1) +#define BOOTBIOS_ADDR (0x7c00) /* BIOS media ID */ #define BIOSM_F320K 0xff /* floppy ds/sd 8 spt */ @@ -128,6 +128,7 @@ typedef struct _bios_apminfo { u_int apm_data_base; u_int apm_data_len; u_int apm_entry; + u_int apm_code16_len; } bios_apminfo_t; #define BOOTARG_CKSUMLEN 3 /* u_int32_t */ diff --git a/sys/arch/i386/stand/Makefile.inc b/sys/arch/i386/stand/Makefile.inc index bf78d2dc248..f7f563d99c8 100644 --- a/sys/arch/i386/stand/Makefile.inc +++ b/sys/arch/i386/stand/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.25 1999/08/12 19:27:15 millert Exp $ +# $OpenBSD: Makefile.inc,v 1.26 1999/08/25 00:54:18 mickey Exp $ CFLAGS=${DEBUG} -Os -Wall -Werror CPPFLAGS+=-I${S} -I${SADIR}/libsa -I. -I${.CURDIR} @@ -9,15 +9,15 @@ DEBUGFLAGS= # DEBUGFLAGS+=-DBIOS_DEBUG # DEBUGFLAGS+=-DEXEC_DEBUG # DEBUGFLAGS+=-DALLOC_TRACE -# DEBUGFLAGS+=-D_TEST +# DEBUGFLAGS+=-g -D_TEST # DEBUGFLAGS+=-DUNIX_DEBUG # DEBUGFLAGS+=-DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG # DEBUGFLAGS+=-DNFS_DEBUG -DRPC_DEBUG -DRARP_DEBUG -LINKADDR=0x10000 -LOADADDR=0x10000 -HEAP_LIMIT=0x60000 +LINKADDR=0x40000 +LOADADDR=0x40000 +HEAP_LIMIT=0x90000 BOOTREL=0x60000 -BOOTMAGIC=0xdeadbeef +BOOTMAGIC=0xc00ld00d #ROM_SIZE=32768 CLEANFILES+= machine diff --git a/sys/arch/i386/stand/boot/boot.8 b/sys/arch/i386/stand/boot/boot.8 index 0aca9b8cf98..f90d8b2e49c 100644 --- a/sys/arch/i386/stand/boot/boot.8 +++ b/sys/arch/i386/stand/boot/boot.8 @@ -1,6 +1,6 @@ -.\" $OpenBSD: boot.8,v 1.13 1999/07/09 19:00:48 weingart Exp $ +.\" $OpenBSD: boot.8,v 1.14 1999/08/25 00:54:18 mickey Exp $ .\" -.\" Copyright (c) 1997 Michael Shalayeff +.\" Copyright (c) 1997-1999 Michael Shalayeff .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -13,21 +13,22 @@ .\" 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. +.\" 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. +.\" 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. +.\" .\" .Dd September 1, 1997 .Dt BOOT 8 i386 @@ -122,7 +123,7 @@ timeout period has expired. The following commands are accepted at the .Nm prompt: -.Bl -tag -width stty_device_baudrate_____ +.Bl -tag -width stty_device_speed_____ .It boot Op Ar image Op Fl abcds Boots kernel image specified by the .Ar image @@ -139,18 +140,25 @@ on the console device. .It help Prints a list of available commands and machine dependant commands, if any. -.It machine Op Ar subcommand +.It machine Op Ar command Issues machine-dependant commands. These are defined for i386 architecture: .Bl -tag -width diskinfo_ -.It Nm cnvmem -Prints/sets the amount of conventional memory. .It Nm diskinfo Prints list of hard disks installed on your system including: BIOS device number, and the BIOS geometry. -.It Nm extmem -Prints/sets the amount of extended memory. .It Nm memory -Prints physical memory map. +If used without any arguments this commad will print out +the memory configuration as determined through BIOS routines. +Otherwise the arguments would specify the expressions to modify the +memory configuration. The expression would have a form of: +.Pp +.Dl [+-]<size>@<address> +.Pp +Meaning to add(+) or exempt(-) the specified by the +.Ar <size> +amount of memory at the location specified by the +.Ar <address> +argument. .It Nm regs Prints contents of processor registers if compiled with .Em DEBUG . @@ -190,12 +198,12 @@ Active console device name. .It Nm image File name containing the kernel image. .El -.It stty Op Ar device Op Ar baudrate +.It stty Op Ar device Op Ar speed Displays or sets the -.Ar baudrate +.Ar speed for a console .Ar device . -If changing speed for the currently +If changing baudrate for the currently active console, gives you five seconds of pause before changing the baud rate to allow you to change your terminal's speed to match. If changing speed diff --git a/sys/arch/i386/stand/libsa/Makefile b/sys/arch/i386/stand/libsa/Makefile index 6809b6705f3..e35d35faaea 100644 --- a/sys/arch/i386/stand/libsa/Makefile +++ b/sys/arch/i386/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.35 1998/07/20 18:14:55 mickey Exp $ +# $OpenBSD: Makefile,v 1.36 1999/08/25 00:54:19 mickey Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -13,7 +13,7 @@ DIR_KERN=$S/lib/libkern SRCS+= machdep.c dev_i386.c exec_i386.c cmd_i386.c .if defined(DEBUGFLAGS) && !empty(DEBUGFLAGS:M-D_TEST) -SRCS+= unixdev.c unixsys.S nullfs.c +SRCS+= unixdev.c unixsys.S nullfs.c memprobe.c CLEANFILES+= gidt.o debug_i386.o alloca.o \ biosdev.o bioscons.o gateA20.o apmprobe.o \ memprobe.o diskprobe.o pciprobe.o smpprobe.o \ diff --git a/sys/arch/i386/stand/libsa/apmprobe.c b/sys/arch/i386/stand/libsa/apmprobe.c index 0760c376563..22dc4d10e89 100644 --- a/sys/arch/i386/stand/libsa/apmprobe.c +++ b/sys/arch/i386/stand/libsa/apmprobe.c @@ -1,7 +1,7 @@ -/* $OpenBSD: apmprobe.c,v 1.6 1999/05/09 15:09:05 mickey Exp $ */ +/* $OpenBSD: apmprobe.c,v 1.7 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,22 +14,21 @@ * 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. + * 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. - * + * 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. */ /* * APM derived from: apm_init.S, LP (Laptop Package) @@ -125,9 +124,32 @@ apm_connect(ai) if (f & 0xff) return f >> 8; - ai->apm_entry = BIOS_regs.biosr_bx; - ai->apm_data_len = 0x10000; - ai->apm_code_len = 0x10000 - (ai->apm_code16_base & 0xffff); + ai->apm_entry = BIOS_regs.biosr_bx; + ai->apm_code_len = BIOS_regs.biosr_si; + ai->apm_code16_len = BIOS_regs.biosr_si; + ai->apm_data_len = BIOS_regs.biosr_di; +#ifdef DEBUG + if (debug) + printf ("cs=%x:%x, ds=%x:%x\n", + ai->apm_code32_base, ai->apm_code_len, + ai->apm_data_base, ai->apm_data_len); +#endif + ai->apm_code_len &= 0xffff; + ai->apm_code16_len &= 0xffff; + ai->apm_data_len &= 0xffff; + + /* inform apm bios about our driver version */ + __asm __volatile (DOINT(0x15) "\n\t" + "setc %b1\n\t" + "movb %%ah, %h1" + : "=b" (f) + : "a" (APM_DRIVER_VERSION), + "0" (APM_DEV_APM_BIOS), + "c" (APM_VERSION) + : "cc"); + + ai->apm_code_len = 0x10000 - (ai->apm_code32_base & 0xffff); + ai->apm_code16_len = 0x10000 - (ai->apm_code16_base & 0xffff); /* * this is a hack to make all those weird boxes keeping @@ -146,11 +168,11 @@ apm_connect(ai) return 0; } +static bios_apminfo_t ai; + void apmprobe() { - bios_apminfo_t ai; - if ((ai.apm_detail = apm_check())) { apm_disconnect(); @@ -158,9 +180,10 @@ apmprobe() printf(": connect error\n"); #ifdef DEBUG if (debug) - printf(": %x text=%x/%x[%x] data=%x[%x] @ %x", - ai.apm_detail, ai.apm_code32_base, - ai.apm_code16_base, ai.apm_code_len, + printf("apm[%x cs=%x[%x]/%x[%x] ds=%x[%x] @ %x]", + ai.apm_detail, + ai.apm_code32_base, ai.apm_code_len, + ai.apm_code16_base, ai.apm_code16_len, ai.apm_data_base, ai.apm_data_len, ai.apm_entry); else @@ -172,3 +195,13 @@ apmprobe() } } +void +apmcheck() +{ +#ifdef DEBUG + printf("apm"); +#endif + mem_delete(i386_trunc_page(ai.apm_data_base), + i386_round_page(ai.apm_data_base + ai.apm_data_len)); +} + diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c index 8bb6cea7698..cf8db53580d 100644 --- a/sys/arch/i386/stand/libsa/bioscons.c +++ b/sys/arch/i386/stand/libsa/bioscons.c @@ -1,7 +1,7 @@ -/* $OpenBSD: bioscons.c,v 1.16 1998/05/28 20:52:39 mickey Exp $ */ +/* $OpenBSD: bioscons.c,v 1.17 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,22 +14,21 @@ * 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. + * 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. - * + * 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. */ #include <sys/types.h> @@ -70,7 +69,7 @@ pc_probe(cn) { cn->cn_pri = CN_INTERNAL; cn->cn_dev = makedev(12, 0); - printf("pc%d ", minor(cn->cn_dev)); + printf(" pc%d", minor(cn->cn_dev)); #if 0 outb(IO_RTC, NVRAM_EQUIPMENT); @@ -78,7 +77,7 @@ pc_probe(cn) cn->cn_pri = CN_INTERNAL; /* XXX from i386/conf.c */ cn->cn_dev = makedev(12, 0); - printf("pc%d ", minor(cn->cn_dev)); + printf(" pc%d", minor(cn->cn_dev)); } #endif } @@ -87,7 +86,6 @@ void pc_init(cn) struct consdev *cn; { - printf("\nusing pc%d console\n", minor(cn->cn_dev)); } int @@ -129,7 +127,7 @@ com_probe(cn) n >>= 9; n &= 7; for (i = 0; i < n; i++) - printf("com%d ", i); + printf(" com%d", i); if (n) { cn->cn_pri = CN_NORMAL; /* XXX from i386/conf.c */ diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index ecf23fba8d9..69927bd91f4 100644 --- a/sys/arch/i386/stand/libsa/cmd_i386.c +++ b/sys/arch/i386/stand/libsa/cmd_i386.c @@ -1,7 +1,8 @@ -/* $OpenBSD: cmd_i386.c,v 1.21 1998/05/25 19:20:51 mickey Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.22 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff, Tobias Weingartner + * Copyright (c) 1997-1999 Michael Shalayeff + * Copyright (c) 1997 Tobias Weingartner * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +33,6 @@ * */ -#ifndef _TEST #include <sys/param.h> #include <sys/reboot.h> #include <machine/biosvar.h> @@ -46,12 +46,10 @@ extern const char version[]; -static int Xboot __P((void)); -static int Xdiskinfo __P((void)); -static int Xmemory __P((void)); -static int Xregs __P((void)); -static int Xcnvmem __P((void)); -static int Xextmem __P((void)); +int Xboot __P((void)); +int Xdiskinfo __P((void)); +int Xmemory __P((void)); +int Xregs __P((void)); /* From gidt.S */ int bootbuf __P((void*, int)); @@ -60,57 +58,36 @@ const struct cmd_table cmd_machine[] = { { "boot", CMDT_CMD, Xboot }, { "diskinfo", CMDT_CMD, Xdiskinfo }, { "memory", CMDT_CMD, Xmemory }, +#ifdef DEBUG { "regs", CMDT_CMD, Xregs }, - { "cnvmem", CMDT_CMD, Xcnvmem}, - { "extmem", CMDT_CMD, Xextmem}, +#endif { NULL, 0 } }; - -/* Set size of conventional ram */ -static int -Xcnvmem() -{ - if (cmd.argc != 2) - printf("cnvmem %d\n", cnvmem); - else - cnvmem = strtol(cmd.argv[1], NULL, 0); - - return 0; -} - -/* Set size of extended ram */ -static int -Xextmem() -{ - if (cmd.argc != 2) - printf("extmem %d\n", extmem); - else - extmem = strtol(cmd.argv[1], NULL, 0); - - return 0; -} - -static int +int Xdiskinfo() { +#ifndef _TEST dump_diskinfo(); - +#endif return 0; } -static int +#ifdef DEBUG +int Xregs() { DUMP_REGS; return 0; } +#endif -static int +int Xboot() { +#ifndef _TEST int dev, part, st; - char buf[DEV_BSIZE], *dest = (void*)0x7c00; + char buf[DEV_BSIZE], *dest = (void*)BOOTBIOS_ADDR; if(cmd.argc != 2) { printf("machine boot {fd,hd}<0123>[abcd]\n"); @@ -161,26 +138,48 @@ Xboot() bad: printf("Invalid device!\n"); +#endif return 0; } -static int +int Xmemory() { - bios_memmap_t *tm = memory_map; - int count, total = 0; + if (cmd.argc >= 2) { + int i; + /* parse the memory specs */ - for(count = 0; tm[count].type != BIOS_MAP_END; count++){ - printf("Region %d: type %u at 0x%lx for %luKB\n", count, - tm[count].type, (long)tm[count].addr, (long)tm[count].size); + for (i = 1; i < cmd.argc; i++) { + char *p; + long addr, size; - if(tm[count].type == BIOS_MAP_FREE) - total += tm[count].size; + p = cmd.argv[i]; + + size = strtol(p + 1, &p, 0); + if (*p && *p == '@') + addr = strtol(p + 1, NULL, 0); + else + addr = 0; + if (addr == 0 && (*p != '@' || size == 0)) { + printf ("bad language\n"); + return 0; + } else { + switch (cmd.argv[i][0]) { + case '-': + mem_delete(addr, addr + size); + break; + case '+': + mem_add(addr, addr + size); + break; + default : + printf ("bad OP\n"); + return 0; + } + } + } } - printf("Low ram: %dKB High ram: %dKB\n", cnvmem, extmem); - printf("Total free memory: %dKB\n", total); + dump_biosmem(NULL); return 0; } -#endif diff --git a/sys/arch/i386/stand/libsa/dev_i386.c b/sys/arch/i386/stand/libsa/dev_i386.c index 5f1868a80fa..82c7468f096 100644 --- a/sys/arch/i386/stand/libsa/dev_i386.c +++ b/sys/arch/i386/stand/libsa/dev_i386.c @@ -1,7 +1,7 @@ -/* $OpenBSD: dev_i386.c,v 1.21 1998/05/25 19:20:53 mickey Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.22 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1996 Michael Shalayeff + * Copyright (c) 1996-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,22 +14,21 @@ * 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. + * 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. - * + * 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. */ #include "libsa.h" @@ -69,7 +68,7 @@ devopen(struct open_file *f, const char *fname, char **file) for (i = 0; i < ndevs && rc != 0; dp++, i++) { #ifdef DEBUG if (debug) - printf(" %s", dp->dv_name); + printf(" %s: ", dp->dv_name); #endif if ((rc = (*dp->dv_open)(f, file)) == 0) { f->f_dev = dp; @@ -77,7 +76,7 @@ devopen(struct open_file *f, const char *fname, char **file) } #ifdef DEBUG else if (debug) - printf(":%d", rc); + printf("%d", rc); #endif } diff --git a/sys/arch/i386/stand/libsa/libsa.h b/sys/arch/i386/stand/libsa/libsa.h index ce2890d083e..29064a0a707 100644 --- a/sys/arch/i386/stand/libsa/libsa.h +++ b/sys/arch/i386/stand/libsa/libsa.h @@ -1,7 +1,7 @@ -/* $OpenBSD: libsa.h,v 1.28 1998/07/20 18:14:57 mickey Exp $ */ +/* $OpenBSD: libsa.h,v 1.29 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1996 Michael Shalayeff + * Copyright (c) 1996-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,22 +14,21 @@ * 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. + * 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. - * + * 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. */ #include <lib/libsa/stand.h> @@ -45,7 +44,11 @@ void smpprobe __P((void)); void memprobe __P((void)); void diskprobe __P((void)); void apmprobe __P((void)); +void apmcheck __P((void)); void pciprobe __P((void)); +void dump_biosmem __P((bios_memmap_t *)); +int mem_delete __P((long, long)); +int mem_add __P((long, long)); void devboot __P((dev_t, char *)); void machdep __P((void)); @@ -58,9 +61,4 @@ extern u_int cnvmem, extmem; /* XXX global pass memprobe()->machdep_start() */ extern bios_diskinfo_t bios_diskinfo[]; extern u_int32_t bios_cksumlen; -/* memprobe.c */ -extern bios_memmap_t *memory_map; - -#ifndef _TEST #define MACHINE_CMD cmd_machine /* we have i386 specific sommands */ -#endif diff --git a/sys/arch/i386/stand/libsa/machdep.c b/sys/arch/i386/stand/libsa/machdep.c index 99bacc0eee7..76e61e5c572 100644 --- a/sys/arch/i386/stand/libsa/machdep.c +++ b/sys/arch/i386/stand/libsa/machdep.c @@ -1,7 +1,7 @@ -/* $OpenBSD: machdep.c,v 1.27 1998/05/25 19:20:57 mickey Exp $ */ +/* $OpenBSD: machdep.c,v 1.28 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,22 +14,21 @@ * 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. + * 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. - * + * 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. */ #include "libsa.h" @@ -56,17 +55,16 @@ machdep() debug_init(); CKPT('2'); #endif /* call console init before doing any io */ - printf("devices: "); + printf("probing:"); cninit(); CKPT('3'); #ifndef _TEST - memprobe(); CKPT('4'); - diskprobe(); CKPT('5'); - - printf("bios:"); - apmprobe(); CKPT('6'); - pciprobe(); CKPT('7'); - smpprobe(); CKPT('8'); + apmprobe(); CKPT('4'); + pciprobe(); CKPT('5'); +/* smpprobe(); CKPT('6'); */ + memprobe(); CKPT('7'); printf("\n"); + + diskprobe(); CKPT('8'); #endif CKPT('Z'); } diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c index df484e871d5..287ebba51a8 100644 --- a/sys/arch/i386/stand/libsa/memprobe.c +++ b/sys/arch/i386/stand/libsa/memprobe.c @@ -1,7 +1,8 @@ -/* $OpenBSD: memprobe.c,v 1.31 1999/01/24 16:07:39 niklas Exp $ */ +/* $OpenBSD: memprobe.c,v 1.32 1999/08/25 00:54:19 mickey Exp $ */ /* - * Copyright (c) 1997 Tobias Weingartner, Michael Shalayeff + * Copyright (c) 1997-1999 Michael Shalayeff + * Copyright (c) 1997 Tobias Weingartner * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +40,6 @@ #include "libsa.h" u_int cnvmem, extmem; /* XXX - compatibility */ -bios_memmap_t *memory_map; /* Check gateA20 @@ -49,8 +49,8 @@ bios_memmap_t *memory_map; static __inline int checkA20(void) { - char *p = (char *)0x100000; - char *q = (char *)0x000000; + register char *p = (char *)0x100000; + register char *q = (char *)0x000000; int st; /* Simple check */ @@ -87,8 +87,7 @@ bios_E820(mp) if (rc & 0xff || sig != 0x534d4150) break; gotcha++; - mp->size >>= 10; /* / 1024 */ - if (mp->type == 0) + if (!mp->type) mp->type = BIOS_MAP_RES; mp++; } while (off); @@ -96,7 +95,7 @@ bios_E820(mp) if (!gotcha) return (NULL); #ifdef DEBUG - printf(" 0x15[E820]"); + printf("0x15[E820] "); #endif return (mp); } @@ -125,16 +124,16 @@ bios_E801(mp) if(rc & 0xff) return (NULL); #ifdef DEBUG - printf(" 0x15[E801]"); + printf("0x15[E801] "); #endif /* Fill out BIOS map */ mp->addr = (1024 * 1024); /* 1MB */ - mp->size = (m1 & 0xffff); + mp->size = (m1 & 0xffff) * 1024; mp->type = BIOS_MAP_FREE; mp++; mp->addr = (1024 * 1024) * 16; /* 16MB */ - mp->size = (m2 & 0xffff) * 64; + mp->size = (m2 & 0xffff) * 64 * 1024; mp->type = BIOS_MAP_FREE; return ++mp; @@ -158,11 +157,11 @@ bios_8800(mp) if(rc & 0xff) return (NULL); #ifdef DEBUG - printf(" 0x15[8800]"); + printf("0x15[8800] "); #endif /* Fill out a BIOS_MAP */ mp->addr = 1024 * 1024; /* 1MB */ - mp->size = mem & 0xffff; + mp->size = (mem & 0xffff) * 1024; mp->type = BIOS_MAP_FREE; return ++mp; @@ -178,13 +177,13 @@ bios_int12(mp) { int mem; #ifdef DEBUG - printf(" 0x12"); + printf("0x12 "); #endif __asm __volatile(DOINT(0x12) : "=a" (mem) :: "%ecx", "%edx", "cc"); /* Fill out a bios_memmap_t */ mp->addr = 0; - mp->size = mem & 0xffff; + mp->size = (mem & 0xffff) * 1024; mp->type = BIOS_MAP_FREE; return ++mp; @@ -262,7 +261,7 @@ badprobe(mp) { int ram; #ifdef DEBUG - printf(" Scan"); + printf("scan "); #endif /* probe extended memory * @@ -274,19 +273,23 @@ badprobe(mp) break; mp->addr = 1024 * 1024; - mp->size = ram - 1024; + mp->size = (ram - 1024) * 1024; mp->type = BIOS_MAP_FREE; return ++mp; } bios_memmap_t bios_memmap[32]; /* This is easier */ +#ifndef _TEST void memprobe() { bios_memmap_t *pm = bios_memmap, *im; + #ifdef DEBUG - printf("Probing memory:"); + printf(" mem("); +#else + printf(" mem["); #endif if(!(pm = bios_E820(bios_memmap))) { im = bios_int12(bios_memmap); @@ -302,36 +305,154 @@ memprobe() pm = im; } } -#ifdef DEBUG - printf("\n"); -#endif + pm->type = BIOS_MAP_END; + /* gotta peephole optimize the list */ + + apmcheck(); + /* Register in global var */ addbootarg(BOOTARG_MEMMAP, (pm - bios_memmap + 1) * sizeof(*bios_memmap), bios_memmap); - memory_map = bios_memmap; /* XXX for 'machine mem' command only */ - printf("memory:"); - /* XXX - Compatibility, remove later */ +#ifdef DEBUG + printf(")["); +#endif + + /* XXX - Compatibility, remove later (smpprobe() relies on it) */ extmem = cnvmem = 0; for(im = bios_memmap; im->type != BIOS_MAP_END; im++) { /* Count only "good" memory chunks 4K and up in size */ - if ((im->type == BIOS_MAP_FREE) && (im->size >= 4)) { - printf(" %luK", (u_long)im->size); - - /* We ignore "good" memory in the 640K-1M hole */ + if ((im->type == BIOS_MAP_FREE) && (im->size >= 12*1024)) { + if (im->size > 1024 * 1024) + printf("%uM ", (u_int)im->size / (1024 * 1024)); + else + printf("%uK ", (u_int)im->size / 1024); + + /* + * Compute compatibility values: + * cnvmem -- is the upper boundary of conventional + * memory (below IOM_BEGIN (=640k)) + * extmem -- is the size of the contignous extended + * memory segment starting at 1M + * + * We ignore "good" memory in the 640K-1M hole. + * We drop "machine {cnvmem,extmem}" commands. + */ if(im->addr < IOM_BEGIN) - cnvmem += im->size; - if(im->addr >= IOM_END) - extmem += im->size; + cnvmem = max(cnvmem, im->addr + im->size); + if(im->addr == IOM_END) + extmem = im->size; } } + cnvmem /= 1024; + extmem /= 1024; /* Check if gate A20 is on */ - if(checkA20()) - printf(" [A20 on]"); - else - printf(" [A20 off!]"); + printf("a20=o%s] ", checkA20()? "n" : "ff!"); +} +#endif - printf("\n"); +void +dump_biosmem(tm) + bios_memmap_t *tm; +{ + register bios_memmap_t *p; + register u_int total = 0; + + if (!tm) + tm = bios_memmap; + + for(p = tm; p->type != BIOS_MAP_END; p++) { + printf("Region %d: type %u at 0x%x for %uKB\n", p - tm, + p->type, (u_int)p->addr, (u_int)p->size / 1024); + + if(p->type == BIOS_MAP_FREE) + total += p->size / 1024; + } + + printf("Low ram: %dKB High ram: %dKB\n", cnvmem, extmem); + printf("Total free memory: %uKB\n", total); } + +int +mem_delete(sa, ea) + long sa, ea; +{ + register bios_memmap_t *p; + + for (p = bios_memmap; p->type != BIOS_MAP_END; p++) { + if (p->type == BIOS_MAP_FREE) { + register int32_t sp = p->addr, ep = p->addr + p->size; + + /* can we eat it as a whole? */ + if ((sa - sp) <= NBPG && (ep - ea) <= NBPG) { + bcopy (p + 1, p, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p); + break; + /* eat head or legs */ + } else if (sa <= sp && sp < ea) { + p->addr = ea; + p->size = ep - ea; + break; + } else if (sa < ep && ep <= ea) { + p->size = sa - sp; + break; + } else if (sp < sa && ea < ep) { + /* bite in half */ + bcopy (p, p + 1, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)p - + sizeof(bios_memmap[0])); + p[1].addr = ea; + p[1].size = ep - ea; + p->size = sa - sp; + break; + } + } + } + return 0; +} + +int +mem_add(sa, ea) + long sa, ea; +{ + register bios_memmap_t *p; + + for (p = bios_memmap; p->type != BIOS_MAP_END; p++) { + if (p->type == BIOS_MAP_FREE) { + register int32_t sp = p->addr, ep = p->addr + p->size; + + /* is it already there? */ + if (sp <= sa && ea <= ep) { + break; + /* join head or legs */ + } else if (sa < sp && sp <= ea) { + p->addr = sa; + p->size = ep - sa; + break; + } else if (sa <= ep && ep < ea) { + p->size = ea - sp; + break; + } else if (ea < sp) { + /* insert before */ + bcopy (p, p + 1, (char *)bios_memmap + + sizeof(bios_memmap) - (char *)(p - 1)); + p->addr = sa; + p->size = ea - sa; + break; + } + } + } + + /* meaning add new item at the end of the list */ + if (p->type == BIOS_MAP_END) { + p[1] = p[0]; + p->type = BIOS_MAP_FREE; + p->addr = sa; + p->size = ea - sa; + } + + return 0; +} + diff --git a/sys/arch/i386/stand/libsa/pciprobe.c b/sys/arch/i386/stand/libsa/pciprobe.c index bef46384944..3a586f88399 100644 --- a/sys/arch/i386/stand/libsa/pciprobe.c +++ b/sys/arch/i386/stand/libsa/pciprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pciprobe.c,v 1.2 1999/01/31 14:56:01 espie Exp $ */ +/* $OpenBSD: pciprobe.c,v 1.3 1999/08/25 00:54:19 mickey Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -60,7 +60,7 @@ pciprobe() printf(" pci"); #ifdef DEBUG - printf("[ver %d.%d, %x 0x%x %d]", (rev>>8)&0xFF, (rev&0xFF), + printf("[V%d.%d, %x 0x%x %d]", (rev>>8)&0xFF, (rev&0xFF), hw_chars, entry32, (rc>>8)&0xFF); #endif diff --git a/sys/stand/boot/bootarg.h b/sys/stand/boot/bootarg.h index e7bdad2c928..8202c57a591 100644 --- a/sys/stand/boot/bootarg.h +++ b/sys/stand/boot/bootarg.h @@ -1,7 +1,7 @@ -/* $OpenBSD: bootarg.h,v 1.7 1998/12/19 11:35:48 mickey Exp $ */ +/* $OpenBSD: bootarg.h,v 1.8 1999/08/25 00:54:18 mickey Exp $ */ /* - * Copyright (c) 1996-1998 Michael Shalayeff + * Copyright (c) 1996-1999 Michael Shalayeff * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -14,25 +14,24 @@ * 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. + * 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. - * + * 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. */ -#define BOOTARG_APIVER (BAPIV_VECTOR|BAPIV_ENV) +#define BOOTARG_APIVER (BAPIV_VECTOR|BAPIV_ENV|BAPIV_BMEMMAP) #define BAPIV_ANCIENT 0x00000000 /* MD old i386 bootblocks */ #define BAPIV_VARS 0x00000001 /* MD structure w/ add info passed */ #define BAPIV_VECTOR 0x00000002 /* MI vector of MD structures passed */ |