diff options
author | msmith <msmith@FreeBSD.org> | 1998-09-17 23:52:16 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-09-17 23:52:16 +0000 |
commit | f0b5ddae6f18f4e9b5ad66d339e2f6b10f5003fa (patch) | |
tree | 7fadd070d2d84c282103a99a4ea34ee576dfe81c /sys/boot/i386/libi386 | |
parent | 00163848c15519499c016ae12ed2a2a3aaf24a83 (diff) | |
download | FreeBSD-src-f0b5ddae6f18f4e9b5ad66d339e2f6b10f5003fa.zip FreeBSD-src-f0b5ddae6f18f4e9b5ad66d339e2f6b10f5003fa.tar.gz |
Initial integration of the i386 bootloader and BTX.
- Discard large amounts of BIOS-related code in favour of the more compact
BTX vm86 interface.
- Build the loader module as ELF, although the resulting object is a.out,
make gensetdefs 32/64-bit sensitive and use a single copy of it.
- Throw away installboot, as it's no longer required.
- Use direct bcopy operations in the i386_copy module, as BTX
maps the first 16M of memory. Check operations against the
detected size of actual memory.
Diffstat (limited to 'sys/boot/i386/libi386')
32 files changed, 392 insertions, 2198 deletions
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index e2cf0c4..d6525df 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -1,16 +1,13 @@ -# $Id: Makefile,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ +# $Id: Makefile,v 1.2 1998/08/31 21:10:43 msmith Exp $ # -SUBDIR= crt LIB= i386 NOPIC= NOPROFILE= -SRCS= aout_freebsd.c biosdelay.S biosdisk.c biosdisk_support.S biosgetrtc.S \ - biosmem.S biosreboot.S bootinfo.c comconsole.c comconsole_support.S \ - devicename.c gatea20.c getsecs.c i386_copy.c i386_module.c \ - startprog.S vidconsole.c vidconsole_support.S +SRCS= aout_freebsd.c biosdisk.c biosmem.c bootinfo.c comconsole.c \ + devicename.c gatea20.c i386_copy.c i386_module.c time.c vidconsole.c -CFLAGS+= -I${.CURDIR}/../../common +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib # Make the disk code more talkative #CFLAGS+= -DDISK_DEBUG diff --git a/sys/boot/i386/libi386/aout_freebsd.c b/sys/boot/i386/libi386/aout_freebsd.c index 7d570d3..674e243 100644 --- a/sys/boot/i386/libi386/aout_freebsd.c +++ b/sys/boot/i386/libi386/aout_freebsd.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aout_freebsd.c,v 1.2 1998/08/31 21:10:43 msmith Exp $ + * $Id: aout_freebsd.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include <sys/param.h> @@ -37,6 +37,7 @@ #include "bootstrap.h" #include "libi386.h" +#include "btxv86.h" static int aout_exec(struct loaded_module *amp); @@ -141,6 +142,8 @@ aout_exec(struct loaded_module *mp) printf("Start @ 0x%lx ...\n", entry); #endif - startprog(entry, 6, argv, (vm_offset_t)0x90000); + __exec(entry, argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); + +/* startprog(entry, 6, argv, (vm_offset_t)0x90000); */ panic("exec returned"); } diff --git a/sys/boot/i386/libi386/biosdelay.S b/sys/boot/i386/libi386/biosdelay.S deleted file mode 100644 index c04a57b..0000000 --- a/sys/boot/i386/libi386/biosdelay.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: biosdelay.S,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ */ - -/* - * Copyright (c) 1996, 1997 - * Perry E. Metzger. 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 acknowledgements: - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors 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 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 <machine/asm.h> - -#define data32 .byte 0x66 - - .text - -/* -# BIOS call "INT 15H Function 86H" to sleep for a set number of microseconds -# Call with %ah = 0x86 -# %cx = time interval (high) -# %dx = time interval (low) -# Return: -# If error -# CF = set -# else -# CF = clear -*/ -ENTRY(delay) - pushl %ebp - pushl %ebx - pushl %esi - pushl %edi - - movw 20(%esp), %dx - movw 22(%esp), %cx - - call CNAME(prot_to_real) - - movb $0x86, %ah - int $0x15 - setnc %ah - - movb %ah, %bl # real_to_prot uses %eax - - data32 - call CNAME(real_to_prot) - - xorl %eax, %eax - movb %bl, %al - - popl %edi - popl %esi - popl %ebx - popl %ebp - ret diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index a6bcbbe..ffb54b0 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: biosdisk.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ /* @@ -42,7 +42,8 @@ #include <sys/disklabel.h> #include <sys/diskslice.h> -#include "bootstrap.h" +#include <bootstrap.h> +#include <btxv86.h> #include "libi386.h" #include "crt/biosdisk_ll.h" @@ -55,21 +56,13 @@ # define D(x) #endif -/* biosdisk_support.S */ -extern u_long bd_int13fn8(int unit); - -static int bd_edd3probe(int unit); -static int bd_edd1probe(int unit); -static int bd_int13probe(int unit); - -static int bd_init(void); -static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); -static int bd_open(struct open_file *f, void *vdev); -static int bd_close(struct open_file *f); struct open_disk { - struct biosdisk_ll od_ll; /* contains bios unit, geometry (XXX absorb) */ - int od_unit; /* our unit number */ + int od_dkunit; /* disk unit number */ + int od_unit; /* BIOS unit number */ + int od_cyl; /* BIOS geometry */ + int od_hds; + int od_sec; int od_boff; /* block offset from beginning of BIOS disk */ int od_flags; #define BD_MODEMASK 0x3 @@ -80,6 +73,18 @@ struct open_disk { u_char od_buf[BUFSIZE]; /* transfer buffer (do we want/need this?) */ }; +static int bd_getgeom(struct open_disk *od); +static int bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest); + +static int bd_edd3probe(int unit); +static int bd_edd1probe(int unit); +static int bd_int13probe(int unit); + +static int bd_init(void); +static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int bd_open(struct open_file *f, void *vdev); +static int bd_close(struct open_file *f); + struct devsw biosdisk = { "disk", DEVT_DISK, @@ -162,12 +167,16 @@ bd_edd1probe(int unit) static int bd_int13probe(int unit) { - u_long geom; - - /* try int 0x13, function 8 */ - geom = bd_int13fn8(unit); - - return(geom != 0); + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = unit; + v86int(); + + if (!(v86.efl & 0x1) && /* carry clear */ + ((v86.edx & 0xff) > unit & 0x7f)) /* unit # OK */ + return(1); + return(0); } /* @@ -202,9 +211,9 @@ bd_open(struct open_file *f, void *vdev) } /* Look up BIOS unit number, intialise open_disk structure */ - od->od_unit = dev->d_kind.biosdisk.unit; - od->od_ll.dev = bdinfo[od->od_unit].bd_unit; - od->od_flags = bdinfo[od->od_unit].bd_flags; + od->od_dkunit = dev->d_kind.biosdisk.unit; + od->od_unit = bdinfo[od->od_dkunit].bd_unit; + od->od_flags = bdinfo[od->od_dkunit].bd_flags; od->od_boff = 0; error = 0; #if 0 @@ -214,7 +223,7 @@ bd_open(struct open_file *f, void *vdev) #endif /* Get geometry for this open (removable device may have changed) */ - if (set_geometry(&od->od_ll)) { + if (bd_getgeom(od)) { D(printf("bd_open: can't get geometry\n")); error = ENXIO; goto out; @@ -229,7 +238,7 @@ bd_open(struct open_file *f, void *vdev) /* * Find the slice in the DOS slice table. */ - if (readsects(&od->od_ll, 0, 1, od->od_buf, 0)) { + if (bd_read(od, 0, 1, od->od_buf)) { D(printf("bd_open: error reading MBR\n")); error = EIO; goto out; @@ -292,7 +301,7 @@ bd_open(struct open_file *f, void *vdev) D(printf("bd_open: opening raw slice\n")); } else { - if (readsects(&od->od_ll, sector + LABELSECTOR, 1, od->od_buf, 0)) { + if (bd_read(od, sector + LABELSECTOR, 1, od->od_buf)) { D(printf("bd_open: error reading disklabel\n")); error = EIO; goto out; @@ -348,11 +357,11 @@ bd_close(struct open_file *f) #if 0 D(printf("bd_close: open_disk %p\n", od)); #endif - +#if 0 /* XXX is this required? (especially if disk already open...) */ if (od->od_flags & BD_FLOPPY) delay(3000000); - +#endif free(od); return(0); } @@ -387,7 +396,7 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t if (rsize) *rsize = 0; - if (blks && readsects(&od->od_ll, dblk + od->od_boff, blks, buf, 0)) { + if (blks && bd_read(od, dblk + od->od_boff, blks, buf)) { D(printf("read error\n")); return (EIO); } @@ -396,7 +405,7 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t D(printf("bd_strategy: frag read %d from %d+%d+d to %p\n", #endif fragsize, od->od_boff, dblk, blks, buf + (blks * BIOSDISK_SECSIZE))); - if (fragsize && readsects(&od->od_ll, dblk + od->od_boff + blks, 1, fragsize, 0)) { + if (fragsize && bd_read(od, dblk + od->od_boff + blks, 1, fragsize)) { D(printf("frag read error\n")); return(EIO); } @@ -406,3 +415,64 @@ bd_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize = size; return (0); } + +static int +bd_read(struct open_disk *od, daddr_t dblk, int blks, caddr_t dest) +{ + int x, bpc, cyl, hd, sec; + + bpc = (od->od_sec * od->od_hds); /* blocks per cylinder */ + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + + while (blks != 0) { + x = dblk; + cyl = x / bpc; /* block # / blocks per cylinder */ + x %= bpc; /* block offset into cylinder */ + hd = x / od->od_sec; /* offset / blocks per track */ + sec = x % od->od_sec; /* offset into track */ + + /* play it safe and don't cross track boundaries */ + x = min (od->od_sec - sec, blks); + + /* correct sector number for 1-based BIOS numbering */ + sec++; + + /* build request XXX support EDD requests too */ + v86.eax = 0x200 | x; + v86.ecx = ((cyl & 0xff) << 8) | ((cyl & 0x300) >> 2) | sec; + v86.edx = (hd << 8) | od->od_unit; + v86.es = V86SEG(dest); + v86.ebx = V86OFS(dest); + v86int(); + if (v86.efl & 0x1) + return(-1); + + dest + (x * BIOSDISK_SECSIZE); + dblk += x; + blks -= x; + } + return(0); +} + +static int +bd_getgeom(struct open_disk *od) +{ + + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = od->od_unit; + v86int(); + + if ((v86.efl & 0x1) || /* carry set */ + ((v86.edx & 0xff) <= (od->od_unit & 0x7f))) /* unit # bad */ + return(1); + + /* convert max cyl # -> # of cylinders */ + od->od_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1; + /* convert max head # -> # of heads */ + od->od_hds = ((v86.edx & 0xff00) >> 8) + 1; + od->od_sec = v86.ecx & 0x3f; + return(0); +} diff --git a/sys/boot/i386/libi386/biosdisk_support.S b/sys/boot/i386/libi386/biosdisk_support.S deleted file mode 100644 index 52e2e0f..0000000 --- a/sys/boot/i386/libi386/biosdisk_support.S +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:34:26 rpd - * $Id: bios.S,v 1.12 1997/07/31 08:07:53 phk Exp $ - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <machine/asm.h> - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -/* - * - * get_diskinfo(): return a word that represents the - * max number of sectors and heads and drives for this device - * - */ - -ENTRY(bd_int13fn8) - push %ebp - mov %esp, %ebp - push %ebx - push %esi - push %edi - - movb 0x8(%ebp), %dl /* diskinfo(drive #) */ - call CNAME(prot_to_real) /* enter real mode */ - - movb $0x8, %ah /* ask for disk info */ - - sti - int $0x13 - cli - - jnc ok - /* call failed, return 0 */ - subb %cl, %cl - subb %ch, %ch - subb %dl, %dl - subb %dh, %dh -ok: - - data32 - call CNAME(real_to_prot) /* back to protected mode */ - - /* - * form a longword representing all this gunk: - * 6 bit zero - * 10 bit max cylinder (0 based) - * 8 bit max head (0 based) - * 2 bit zero - * 6 bit max sector (1 based) = # sectors - */ - movb %cl, %al /* Upper two bits of cylinder count */ - andl $0xc0,%eax - leal 0(,%eax,4),%eax /* << 2 */ - movb %ch, %al /* Lower 8 bits */ - sall $16,%eax /* << 16 */ - movb %dh, %ah /* max head */ - andb $0x3f, %cl /* mask of cylinder gunk */ - movb %cl, %al /* max sector (and # sectors) */ - - pop %edi - pop %esi - pop %ebx - pop %ebp - ret - diff --git a/sys/boot/i386/libi386/biosgetrtc.S b/sys/boot/i386/libi386/biosgetrtc.S deleted file mode 100644 index 5927a06..0000000 --- a/sys/boot/i386/libi386/biosgetrtc.S +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: biosgetrtc.S,v 1.2 1997/06/13 13:42:27 drochner Exp $ */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. 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 for the NetBSD Project - * by Matthias Drochner. - * 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 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 <machine/asm.h> - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -ENTRY(biosgetrtc) - pushl %ebp - movl %esp, %ebp - pushl %ebx - pushl %ecx - pushl %edx - push %esi - push %edi - - xorl %ebx, %ebx - - call CNAME(prot_to_real) # enter real mode - - movb $2, %ah - int $0x1a - jnc ok - data32 - movl $-1, %ebx - -ok: - data32 - call CNAME(real_to_prot) # back to protected mode - - movl 8(%ebp), %eax - movl $0, (%eax) - movb %ch, (%eax) - movb %cl, 1(%eax) - movb %dh, 2(%eax) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %edx - popl %ecx - popl %ebx - popl %ebp - ret diff --git a/sys/boot/i386/libi386/biosmem.S b/sys/boot/i386/libi386/biosmem.S deleted file mode 100644 index cb97672..0000000 --- a/sys/boot/i386/libi386/biosmem.S +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: biosmem.S,v 1.5 1997/08/18 22:44:01 hannken Exp $ */ - -/* - * Copyright (c) 1996 - * Perry E. Metzger. 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 acknowledgements: - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors 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 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 <machine/asm.h> - -#define data32 .byte 0x66 - - .text - -/* get mem below 1M, in kByte */ - -ENTRY(getbasemem) - pushl %ebp - movl %esp,%ebp - pushl %ebx - push %esi - push %edi - - call CNAME(prot_to_real) - - int $0x12 - # zero-extend 16-bit result to 32 bits. - data32 - movl $0, %ebx - mov %eax,%ebx # !!! at run time, it is mov %ax,%bx - - data32 - call CNAME(real_to_prot) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %ebx - popl %ebp - ret - -/* get mem above 1M, in kByte */ - -ENTRY(getextmem) - pushl %ebp - movl %esp,%ebp - pushl %ebx - push %esi - push %edi - - call CNAME(prot_to_real) - - movb $0x88,%ah - int $0x15 - - # zero-extend 16-bit result to 32 bits. - data32 - movl $0, %ebx - mov %eax,%ebx # !!! at run time, it is mov %ax,%bx - - data32 - call CNAME(real_to_prot) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %ebx - popl %ebp - ret - diff --git a/sys/boot/i386/libi386/biosmem.c b/sys/boot/i386/libi386/biosmem.c new file mode 100644 index 0000000..8322654 --- /dev/null +++ b/sys/boot/i386/libi386/biosmem.c @@ -0,0 +1,52 @@ +/* + * mjs copyright + */ + +/* + * Obtain memory configuration information from the BIOS + * + * Note that we don't try too hard here; knowing the size of + * base memory and extended memory out to 16 or 64M is enough for + * the requirements of the bootstrap. + * + * We also maintain a pointer to the top of physical memory + * once called to allow rangechecking of load/copy requests. + */ +#include <stand.h> +#include "btxv86.h" + +vm_offset_t memtop; + +/* + * Return base memory size in kB. + */ +int +getbasemem(void) +{ + v86.ctl = 0; + v86.addr = 0x1a; /* int 0x12 */ + v86int(); + + return(v86.eax & 0xffff); +} + +/* + * Return extended memory size in kB + */ +int +getextmem(void) +{ + int extkb; + + v86.ctl = 0; + v86.addr = 0x15; /* int 0x12 function 0x88*/ + v86.eax = 0x8800; + v86int(); + extkb = v86.eax & 0xffff; + + /* Set memtop to actual top or 16M, whicheve is less */ + memtop = min((0x100000 + (extkb + 1024)), (16 * 1024 * 1024)); + + return(extkb); +} + diff --git a/sys/boot/i386/libi386/biosreboot.S b/sys/boot/i386/libi386/biosreboot.S deleted file mode 100644 index f2bfe65..0000000 --- a/sys/boot/i386/libi386/biosreboot.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: biosreboot.S,v 1.1 1997/04/13 18:45:37 perry Exp $ */ - -/* - * Copyright (c) 1997 - * Perry E. Metzger. 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 acknowledgements: - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors 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 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 <machine/asm.h> - -#define data32 .byte 0x66 - - .text - -/* Call INT 19 to do the equivalent of CTL-ALT-DEL */ - -ENTRY(reboot) - pushl %ebp - movl %esp,%ebp - pushl %ebx - push %esi - push %edi - - call CNAME(prot_to_real) - - int $0x19 - - /* NOTE: We should never even get past this point. */ - - data32 - call CNAME(real_to_prot) - - movl %ebx, %eax - - pop %edi - pop %esi - popl %ebx - popl %ebp - ret diff --git a/sys/boot/i386/libi386/bootinfo.c b/sys/boot/i386/libi386/bootinfo.c index 02d217b..7870a5f 100644 --- a/sys/boot/i386/libi386/bootinfo.c +++ b/sys/boot/i386/libi386/bootinfo.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.c,v 1.2 1998/09/03 02:10:09 msmith Exp $ + * $Id: bootinfo.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include <sys/reboot.h> @@ -120,18 +120,18 @@ bi_copyenv(vm_offset_t addr) /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { - vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); - vpbcopy("=", addr, 1); + i386_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { - vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } @@ -152,9 +152,9 @@ bi_copyenv(vm_offset_t addr) */ #define MOD_STR(t, a, s) { \ u_int32_t ident = (t << 16) + strlen(s) + 1; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(s, a, strlen(s) + 1); \ + i386_copyin(s, a, strlen(s) + 1); \ a += strlen(s) + 1; \ } @@ -163,9 +163,9 @@ bi_copyenv(vm_offset_t addr) #define MOD_VAR(t, a, s) { \ u_int32_t ident = (t << 16) + sizeof(s); \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(&s, a, sizeof(s)); \ + i386_copyin(&s, a, sizeof(s)); \ a += sizeof(s); \ } @@ -174,18 +174,18 @@ bi_copyenv(vm_offset_t addr) #define MOD_METADATA(a, mm) { \ u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(mm->md_data, a, mm->md_size); \ + i386_copyin(mm->md_data, a, mm->md_size); \ a += mm->md_size; \ } -#define MOD_END(a) { \ - u_int32_t ident = 0; \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ +#define MOD_END(a) { \ + u_int32_t ident = 0; \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ } vm_offset_t diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c index 02d217b..7870a5f 100644 --- a/sys/boot/i386/libi386/bootinfo32.c +++ b/sys/boot/i386/libi386/bootinfo32.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.c,v 1.2 1998/09/03 02:10:09 msmith Exp $ + * $Id: bootinfo.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include <sys/reboot.h> @@ -120,18 +120,18 @@ bi_copyenv(vm_offset_t addr) /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { - vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); - vpbcopy("=", addr, 1); + i386_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { - vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } @@ -152,9 +152,9 @@ bi_copyenv(vm_offset_t addr) */ #define MOD_STR(t, a, s) { \ u_int32_t ident = (t << 16) + strlen(s) + 1; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(s, a, strlen(s) + 1); \ + i386_copyin(s, a, strlen(s) + 1); \ a += strlen(s) + 1; \ } @@ -163,9 +163,9 @@ bi_copyenv(vm_offset_t addr) #define MOD_VAR(t, a, s) { \ u_int32_t ident = (t << 16) + sizeof(s); \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(&s, a, sizeof(s)); \ + i386_copyin(&s, a, sizeof(s)); \ a += sizeof(s); \ } @@ -174,18 +174,18 @@ bi_copyenv(vm_offset_t addr) #define MOD_METADATA(a, mm) { \ u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(mm->md_data, a, mm->md_size); \ + i386_copyin(mm->md_data, a, mm->md_size); \ a += mm->md_size; \ } -#define MOD_END(a) { \ - u_int32_t ident = 0; \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ +#define MOD_END(a) { \ + u_int32_t ident = 0; \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ } vm_offset_t diff --git a/sys/boot/i386/libi386/bootinfo64.c b/sys/boot/i386/libi386/bootinfo64.c index 02d217b..7870a5f 100644 --- a/sys/boot/i386/libi386/bootinfo64.c +++ b/sys/boot/i386/libi386/bootinfo64.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bootinfo.c,v 1.2 1998/09/03 02:10:09 msmith Exp $ + * $Id: bootinfo.c,v 1.3 1998/09/14 18:27:05 msmith Exp $ */ #include <sys/reboot.h> @@ -120,18 +120,18 @@ bi_copyenv(vm_offset_t addr) /* traverse the environment */ for (ep = environ; ep != NULL; ep = ep->ev_next) { - vpbcopy(ep->ev_name, addr, strlen(ep->ev_name)); + i386_copyin(ep->ev_name, addr, strlen(ep->ev_name)); addr += strlen(ep->ev_name); - vpbcopy("=", addr, 1); + i386_copyin("=", addr, 1); addr++; if (ep->ev_value != NULL) { - vpbcopy(ep->ev_value, addr, strlen(ep->ev_value)); + i386_copyin(ep->ev_value, addr, strlen(ep->ev_value)); addr += strlen(ep->ev_value); } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } - vpbcopy("", addr, 1); + i386_copyin("", addr, 1); addr++; } @@ -152,9 +152,9 @@ bi_copyenv(vm_offset_t addr) */ #define MOD_STR(t, a, s) { \ u_int32_t ident = (t << 16) + strlen(s) + 1; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(s, a, strlen(s) + 1); \ + i386_copyin(s, a, strlen(s) + 1); \ a += strlen(s) + 1; \ } @@ -163,9 +163,9 @@ bi_copyenv(vm_offset_t addr) #define MOD_VAR(t, a, s) { \ u_int32_t ident = (t << 16) + sizeof(s); \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(&s, a, sizeof(s)); \ + i386_copyin(&s, a, sizeof(s)); \ a += sizeof(s); \ } @@ -174,18 +174,18 @@ bi_copyenv(vm_offset_t addr) #define MOD_METADATA(a, mm) { \ u_int32_t ident = ((MODINFO_METADATA | mm->md_type) << 16) + mm->md_size; \ - vpbcopy(&ident, a, sizeof(ident)); \ + i386_copyin(&ident, a, sizeof(ident)); \ a += sizeof(ident); \ - vpbcopy(mm->md_data, a, mm->md_size); \ + i386_copyin(mm->md_data, a, mm->md_size); \ a += mm->md_size; \ } -#define MOD_END(a) { \ - u_int32_t ident = 0; \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ - vpbcopy(&ident, a, sizeof(ident)); \ - a += sizeof(ident); \ +#define MOD_END(a) { \ + u_int32_t ident = 0; \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ + i386_copyin(&ident, a, sizeof(ident)); \ + a += sizeof(ident); \ } vm_offset_t diff --git a/sys/boot/i386/libi386/comconsole.c b/sys/boot/i386/libi386/comconsole.c index a75f92d..1d98585 100644 --- a/sys/boot/i386/libi386/comconsole.c +++ b/sys/boot/i386/libi386/comconsole.c @@ -24,22 +24,19 @@ * * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp * - * $Id$ + * $Id: comconsole.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ #include <stand.h> - -#include "bootstrap.h" - -/* in comconsole.S */ -extern void cominit(int s); -extern void computc(int c); -extern int comgetc(void); -extern int comiskey(void); +#include <bootstrap.h> +#include <btxv86.h> +#include "libi386.h" static void comc_probe(struct console *cp); static int comc_init(int arg); -static int comc_in(void); +static void comc_putchar(int c); +static int comc_getchar(void); +static int comc_ischar(void); struct console comconsole = { "comconsole", @@ -47,11 +44,13 @@ struct console comconsole = { 0, comc_probe, comc_init, - computc, - comc_in, - comiskey + comc_putchar, + comc_getchar, + comc_ischar }; +#define BIOS_COMPORT 0 + static void comc_probe(struct console *cp) { @@ -62,17 +61,43 @@ comc_probe(struct console *cp) static int comc_init(int arg) { - /* XXX arg is unit number, should we use variables instead? */ - cominit(arg); - return(0); + v86.ctl = V86_FLAGS; + v86.addr = 0x14; + v86.eax = 0xe3; /* 9600N81 */ + v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */ + v86int(); + return(v86.efl & 1); +} + +static void +comc_putchar(int c) +{ + v86.ctl = 0; + v86.addr = 0x14; + v86.eax = 0x100 | c; + v86int(); } static int -comc_in(void) +comc_getchar(void) { - if (comiskey()) { - return(comgetc()); + if (comc_ischar()) { + v86.ctl = 0; + v86.addr = 0x14; + v86.eax = 0x300; + v86int(); + return(v86.eax); } else { return(-1); } } + +static int +comc_ischar(void) +{ + v86.ctl = 0; + v86.addr = 0x14; + v86.eax = 0x200; + v86int(); + return(v86.eax & 0x1); +} diff --git a/sys/boot/i386/libi386/comconsole_support.S b/sys/boot/i386/libi386/comconsole_support.S deleted file mode 100644 index a6861dc..0000000 --- a/sys/boot/i386/libi386/comconsole_support.S +++ /dev/null @@ -1,147 +0,0 @@ -/* $NetBSD: comio.S,v 1.2 1997/10/27 19:51:18 drochner Exp $ */ - -/* serial console handling - modelled after code in FreeBSD:sys/i386/boot/netboot/start2.S - */ - -#include <machine/asm.h> - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - - .text - -/************************************************************************** -INIT - Initialization (com number) -**************************************************************************/ -ENTRY(cominit) - push %ebp - mov %esp,%ebp - push %ebx - push %edx - push %esi - push %edi - - movl 8(%ebp), %edx - - call CNAME(prot_to_real) # enter real mode - - # Initialize the serial port (dl) to 9600 baud, 8N1. - movb $0xe3, %al - movb $0, %ah - int $0x14 - mov %ax,%bx - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - mov %bx,%ax - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ebp - ret - -/************************************************************************** -PUTC - Print a character (char, com number) -**************************************************************************/ -ENTRY(computc) - push %ebp - mov %esp,%ebp - push %ecx - push %ebx - push %edx - push %esi - push %edi - - movb 8(%ebp),%cl - movl 12(%ebp),%edx - - call CNAME(prot_to_real) # enter real mode - - movb %cl,%al - movb $0x01, %ah - int $0x14 - - movb %ah,%bl - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - movb %bl,%al - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ecx - pop %ebp - ret - -/************************************************************************** -GETC - Get a character (com number) -**************************************************************************/ -ENTRY(comgetc) - push %ebp - mov %esp,%ebp - push %ebx - push %edx - push %esi - push %edi - - movl 8(%ebp),%edx - - call CNAME(prot_to_real) # enter real mode - - movb $0x02, %ah - int $0x14 - movl %eax,%ebx # at run time, it is mov %ax,%bx - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - mov %bx,%ax - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ebp - ret - -/************************************************************************** -ISKEY - Check for keyboard interrupt (com number) -**************************************************************************/ -ENTRY(comiskey) - push %ebp - mov %esp,%ebp - push %ebx - push %edx - push %esi - push %edi - - movl 8(%ebp),%edx - - call CNAME(prot_to_real) # enter real mode - - movb $0x03, %ah - int $0x14 - mov %ax,%bx - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - mov %bx,%ax - - pop %edi - pop %esi - pop %edx - pop %ebx - pop %ebp - ret diff --git a/sys/boot/i386/libi386/crt/Makefile b/sys/boot/i386/libi386/crt/Makefile deleted file mode 100644 index 400cae8..0000000 --- a/sys/boot/i386/libi386/crt/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIR= bootsect - -.include <bsd.subdir.mk> diff --git a/sys/boot/i386/libi386/crt/bios_disk.S b/sys/boot/i386/libi386/crt/bios_disk.S deleted file mode 100644 index 3e383c5..0000000 --- a/sys/boot/i386/libi386/crt/bios_disk.S +++ /dev/null @@ -1,176 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: bios_disk.S,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ - */ - -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/* extracted from netbsd:sys/arch/i386/boot/bios.S */ - -#include <machine/asm.h> - -#define addr32 .byte 0x67 -#define data32 .byte 0x66 - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ -ENTRY(biosread) - pushl %ebp - movl %esp, %ebp - pushl %ebx - push %ecx - push %edx - push %esi - push %edi - - movb 16(%ebp), %dh - movw 12(%ebp), %cx - xchgb %ch, %cl # cylinder; the highest 2 bits of cyl is in %cl - rorb $2, %cl - movb 20(%ebp), %al - orb %al, %cl - incb %cl # sector; sec starts from 1, not 0 - movb 8(%ebp), %dl # device - movl 28(%ebp), %ebx # offset - # prot_to_real will set %es to BOOTSEG - - call CNAME(prot_to_real) # enter real mode - - movb $0x2, %ah # subfunction - addr32 - movb 24(%ebp), %al # number of sectors - int $0x13 - setc %bl - - data32 - call CNAME(real_to_prot) # back to protected mode - - xorl %eax, %eax - movb %bl, %al # return value in %ax - - pop %edi - pop %esi - pop %edx - pop %ecx - popl %ebx - popl %ebp - ret - -/* -# -# get_diskinfo(): return a word that represents the -# max number of sectors and heads and drives for this device -# -*/ - -ENTRY(get_diskinfo) - pushl %ebp - movl %esp, %ebp - push %es - pushl %ebx - push %ecx - push %edx - push %esi - push %edi - - movb 8(%ebp), %dl # diskinfo(drive #) - - call CNAME(prot_to_real) # enter real mode - - movb $0x08, %ah # ask for disk info - int $0x13 - jnc ok - - /* - * Urk. Call failed. It is not supported for floppies by old BIOS's. - * Guess it's a 15-sector floppy. Initialize all the registers for - * documentation, although we only need head and sector counts. - */ -# subb %ah, %ah # %ax = 0 -# movb %ah, %bh # %bh = 0 -# movb $2, %bl # %bl bits 0-3 = drive type, 2 = 1.2M -# movb $79, %ch # max track - movb $15, %cl # max sector - movb $1, %dh # max head -# movb $1, %dl # # floppy drives installed - # es:di = parameter table - # carry = 0 - -ok: - data32 - call CNAME(real_to_prot) # back to protected mode - - xorl %eax, %eax - - /*form a longword representing all this gunk*/ - movb %dh, %ah # max head - andb $0x3f, %cl # mask of cylinder gunk - movb %cl, %al # max sector (and # sectors) - - pop %edi - pop %esi - pop %edx - pop %ecx - popl %ebx - pop %es - popl %ebp - ret diff --git a/sys/boot/i386/libi386/crt/biosdisk_ll.c b/sys/boot/i386/libi386/crt/biosdisk_ll.c deleted file mode 100644 index b7c77de..0000000 --- a/sys/boot/i386/libi386/crt/biosdisk_ll.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: biosdisk_ll.c,v 1.3 1997/06/13 13:36:06 drochner Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * Copyright (c) 1996 - * Perry E. Metzger. 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 acknowledgements: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors 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 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. - */ - -/* - * shared by bootsector startup (bootsectmain) and biosdisk.c - * needs lowlevel parts from bios_disk.S - */ - -#include <stand.h> - -#include "biosdisk_ll.h" -#include "diskbuf.h" - -/* XXX prototypes from export header? */ -extern int get_diskinfo(int); -extern int biosread(int, int, int, int, int, char *); - -#define SPT(di) ((di)&0xff) -#define HEADS(di) ((((di)>>8)&0xff)+1) - -int -set_geometry(d) - struct biosdisk_ll *d; -{ - int diskinfo; - - diskinfo = get_diskinfo(d->dev); - - d->spc = (d->spt = SPT(diskinfo)) * HEADS(diskinfo); - - /* - * get_diskinfo assumes floppy if BIOS call fails. Check at least - * "valid" geometry. - */ - return (!d->spc || !d->spt); -} - -/* - * Global shared "diskbuf" is used as read ahead buffer. For reading from - * floppies, the bootstrap has to be loaded on a 64K boundary to ensure that - * this buffer doesn't cross a 64K DMA boundary. - */ -static int ra_dev; -static int ra_end; -static int ra_first; - -int -readsects(d, dblk, num, buf, cold) /* reads ahead if (!cold) */ - struct biosdisk_ll *d; - int dblk, num; - char *buf; - int cold; /* don't use data segment or bss, don't call - * library functions */ -{ - while (num) { - int nsec; - - /* check for usable data in read-ahead buffer */ - if (cold || diskbuf_user != &ra_dev || d->dev != ra_dev - || dblk < ra_first || dblk >= ra_end) { - - /* no, read from disk */ - int cyl, head, sec; - char *trbuf; - - cyl = dblk / d->spc; - head = (dblk % d->spc) / d->spt; - sec = dblk % d->spt; - nsec = d->spt - sec; - - if (cold) { - /* transfer directly to buffer */ - trbuf = buf; - if (nsec > num) - nsec = num; - } else { - /* fill read-ahead buffer */ - trbuf = diskbuf; - if (nsec > diskbuf_size) - nsec = diskbuf_size; - - ra_dev = d->dev; - ra_first = dblk; - ra_end = dblk + nsec; - diskbuf_user = &ra_dev; - } - - if (biosread(d->dev, cyl, head, sec, nsec, trbuf)) { - if (!cold) - diskbuf_user = 0; /* mark invalid */ - return (-1); /* XXX cannot output here if - * (cold) */ - } - } else /* can take blocks from end of read-ahead - * buffer */ - nsec = ra_end - dblk; - - if (!cold) { - /* copy data from read-ahead to user buffer */ - if (nsec > num) - nsec = num; - bcopy(diskbuf + (dblk - ra_first) * BIOSDISK_SECSIZE, - buf, nsec * BIOSDISK_SECSIZE); - } - buf += nsec * BIOSDISK_SECSIZE; - num -= nsec; - dblk += nsec; - } - - return (0); -} diff --git a/sys/boot/i386/libi386/crt/biosdisk_ll.h b/sys/boot/i386/libi386/crt/biosdisk_ll.h deleted file mode 100644 index 7e0782a..0000000 --- a/sys/boot/i386/libi386/crt/biosdisk_ll.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: biosdisk_ll.h,v 1.2 1997/03/22 01:41:36 thorpej Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. All rights reserved. - * Copyright (c) 1996 - * Perry E. Metzger. 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 acknowledgements: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * This product includes software developed for the NetBSD Project - * by Perry E. Metzger. - * 4. The names of the authors 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 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. - */ - -/* - * shared by bootsector startup (bootsectmain) and biosdisk.c needs lowlevel - * parts from bios_disk.S - */ - -struct biosdisk_ll { - int dev; /* BIOS device number */ - int spt, spc; /* geometry */ -}; - -#define BIOSDISK_SECSIZE 512 - -extern int set_geometry(struct biosdisk_ll *); -extern int readsects(struct biosdisk_ll *, int, int, char *, int); diff --git a/sys/boot/i386/libi386/crt/bootsect/Makefile b/sys/boot/i386/libi386/crt/bootsect/Makefile deleted file mode 100644 index 1c04705..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# -# Build a startup module -# - -# Disk buffer size in sectors -CFLAGS+= -DDISKBUFSIZE=18 -# Stack size in bytes -CFLAGS+= -DSTACKSIZE=0x1000 - -PROG= bscrt.o -LDFLAGS= -static -nostartfiles -nostdlib -Xlinker -r -NOMAN= yes - -# Bootblock-specific sources -SRCS= start_bootsect.S fraglist.S bootsectmain.c - -# Includes for libsa support routines XXX fix path! -CFLAGS+= -I${.CURDIR}/../../../../../whole/lib/libstand - -# Common items across all startups -.PATH: ${.CURDIR}/.. -CFLAGS+= -I${.CURDIR}/.. -SRCS+= biosdisk_ll.c bios_disk.S buffers.S - -.include <bsd.prog.mk> diff --git a/sys/boot/i386/libi386/crt/bootsect/bbinfo.h b/sys/boot/i386/libi386/crt/bootsect/bbinfo.h deleted file mode 100644 index eb313ae..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/bbinfo.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * $Id: bbinfo.h,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ - * From: $NetBSD: bbinfo.h,v 1.3 1997/11/07 16:59:41 drochner Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. 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 for the NetBSD Project - * by Matthias Drochner. - * 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 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. - * - */ - -/* data structure shared by bootsector - and installboot - */ - -#ifndef __ASSEMBLER__ - -struct fraglist { - int magic; - int loadsz; /* blocks loaded by primary boot */ - int numentries, maxentries; - struct { - int offset, num; - } entries[1]; -}; - -#endif - -#define FRAGLISTVERSION 0 -#define FRAGLISTMAGIC (0xb00deda5 + FRAGLISTVERSION) - -/* only used by bootsect code (not by installboot) */ -#ifndef MAXFLENTRIES -#define MAXFLENTRIES 20 -#endif -#ifndef PRIM_LOADSZ -#define PRIM_LOADSZ 15 -#endif diff --git a/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c b/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c deleted file mode 100644 index 7c48506..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/bootsectmain.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: bootsectmain.c,v 1.1.1.1 1997/03/14 02:40:34 perry Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. 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 for the NetBSD Project - * by Matthias Drochner. - * 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 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. - * - */ - -/* load remainder of boot program - (blocks from fraglist), - start main() - needs lowlevel parts from biosdisk_ll.c - */ - -#include "biosdisk_ll.h" -#include "bbinfo.h" - -int boot_biosdev; /* exported */ - -extern struct fraglist fraglist; -extern char edata[], end[]; - -extern void main(void); - -void bootsectmain(biosdev) -int biosdev; -{ - struct biosdisk_ll d; - int i; - char *buf; - - /* - * load sectors from bootdev - */ - d.dev = biosdev; - set_geometry(&d); - - buf = (char*)(PRIM_LOADSZ * BIOSDISK_SECSIZE); - - for(i = 0; i < fraglist.numentries; i++) { - int dblk, num; - - dblk = fraglist.entries[i].offset; - num = fraglist.entries[i].num; - - if(readsects(&d, dblk, num, buf, 1)) - return; /* halts in start_bootsect.S */ - - buf += num * BIOSDISK_SECSIZE; - } - - /* clear BSS */ - buf = edata; - while(buf < end) *buf++ = 0; - - /* call main() */ - boot_biosdev = biosdev; -/* main(); */ -} diff --git a/sys/boot/i386/libi386/crt/bootsect/fraglist.S b/sys/boot/i386/libi386/crt/bootsect/fraglist.S deleted file mode 100644 index 72ddad4..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/fraglist.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: fraglist.S,v 1.1.1.1 1997/03/14 02:40:34 perry Exp $ */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. 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 for the NetBSD Project - * by Matthias Drochner. - * 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 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. - * - */ - -/* space for fragment list - goes to text section - must be loaded by primary boot - */ - -#include "bbinfo.h" - - .text - - .globl _fraglist -_fraglist: - .long FRAGLISTMAGIC - .long PRIM_LOADSZ /* blocks already in memory */ - .long 0 - .long MAXFLENTRIES - . = . + 2 * MAXFLENTRIES * 4 diff --git a/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S b/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S deleted file mode 100644 index 438ae69..0000000 --- a/sys/boot/i386/libi386/crt/bootsect/start_bootsect.S +++ /dev/null @@ -1,540 +0,0 @@ -/* $NetBSD: start_bootsect.S,v 1.3 1998/02/19 14:15:38 drochner Exp $ */ - -/* BIOS bootsector startup - parts from netbsd:sys/arch/i386/boot/start.S - and freebsd:sys/i386/boot/biosboot/boot2.S - */ - -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <machine/asm.h> -#define addr32 .byte 0x67 -#define data32 .byte 0x66 -/* #include <machine/disklabel.h> */ - -#include "bbinfo.h" - -BOOTSEG = 0x0100 # boot will be loaded here (below 640K) -BOOTSTACK = 0xfffc # boot stack -LOADSZ = PRIM_LOADSZ # size of first loaded chunk - -SIGNATURE = 0xaa55 -PARTSTART = 0x1be # starting address of partition table -NUMPART = 4 # number of partitions in partition table -PARTSZ = 16 # sizeof(struct dos_partition) -BSDPART = 0xA5 -BOOTABLE = 0x80 # value of dp_flag, means bootable partition - - .text -_boot1: -ENTRY(start) - # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0 - # ljmp to the next instruction to adjust %cs - data32 - ljmp $0x7c0, $start1 - -start1: - # set up %ds - movl %cs, %ax - movl %ax, %ds - - # temporary stack while we locate boot2 - # set up %ss and %esp - data32 - movl $BOOTSEG, %eax - movl %ax, %ss - data32 - movl $BOOTSTACK, %esp - - /*** set up %es, (where we will load boot2 to) ***/ - movl %ax, %es - - # bootstrap passes us drive number in %dl - cmpb $0x80, %dl - data32 - jae hd - -fd: -# reset the disk system - movb $0x00, %ah - int $0x13 - data32 - movl $0x0001, %ecx # cyl 0, sector 1 - movb $0x00, %dh # head - # XXX Override the drive number. - movb $0x00, %dl - data32 - jmp load - -hd: /**** load sector 0 (DOSBBSECTOR) into the BOOTSEG ****/ - data32 - movl $0x0201, %eax - xorl %ebx, %ebx # %bx = 0 - data32 - movl $0x0001, %ecx - data32 - andl $0xff, %edx - /*mov $0x0080, %edx*/ - int $0x13 - data32 - jb read_error - - /***# find the first BSD partition *****/ - data32 - movl $PARTSTART, %ebx - data32 - movl $NUMPART, %ecx -again: - addr32 - movb %es:4(%ebx), %al /* dp_typ */ - cmpb $BSDPART, %al - data32 - je found - data32 - addl $PARTSZ, %ebx - data32 - loop again - - /* didn't find either NetBSD or 386BSD partitions */ - data32 - movl $enoboot, %esi - data32 - jmp err_stop - - -/* -# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory -# Call with %ah = 0x2 -# %al = number of sectors -# %ch = cylinder -# %cl = sector -# %dh = head -# %dl = drive (0x80 for hard disk, 0x0 for floppy disk) -# %es:%bx = segment:offset of buffer -# Return: -# %al = 0x0 on success; err code on failure -*/ - -found: - addr32 - movb %es:1(%ebx), %dh /* head: dp_sdh */ - addr32 - movl %es:2(%ebx), %ecx /*sect, cyl: dp_ssect + (dp_scyl << 8)*/ - -load: - movb $0x2, %ah /* function 2 */ - movb $LOADSZ, %al /* number of blocks */ - xorl %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */ - int $0x13 - data32 - jb read_error - - # ljmp to the second stage boot loader (boot2). - # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used - # for stack space while we load boot3. - - data32 - ljmp $BOOTSEG, $CNAME(boot2) - -# -# read_error -# - -read_error: - data32 - movl $eread, %esi -err_stop: - data32 - call message - data32 - jmp stop - -# -# message: write the error message in %ds:%esi to console -# - -message: -/* -# BIOS call "INT 10H Function 0Eh" to write character to console -# Call with %ah = 0x0e -# %al = character -# %bh = page -# %bl = foreground color -*/ - data32 - pushl %eax - data32 - pushl %ebx - data32 - pushl %edx - -nextb: - cld - lodsb # load a byte into %al - testb %al, %al - data32 - jz done - - movb $0x0e, %ah - data32 - movl $0x0001, %ebx - int $0x10 - - data32 - jmp nextb - -done: - data32 - popl %edx - data32 - popl %ebx - data32 - popl %eax - data32 - ret - -_ourseg: - .long 0 - -/************************************************************************** -GLOBAL DESCRIPTOR TABLE -**************************************************************************/ - .align 4 -gdt: /* 0x0 */ - .word 0, 0 - .byte 0, 0x00, 0x00, 0 - -/* additional dummy for Linux support (?) */ /* 0x8 */ - .word 0, 0 - .byte 0, 0x00, 0x00, 0 - - /* kernel code segment */ - .globl flatcodeseg -flatcodeseg = . - gdt /* 0x10 */ - .word 0xffff, 0 - .byte 0, 0x9f, 0xcf, 0 - - /* kernel data segment */ - .globl flatdataseg -flatdataseg = . - gdt /* 0x18 */ - .word 0xffff, 0 - .byte 0, 0x93, 0xcf, 0 - - /* boot code segment, will be patched */ -bootcodeseg = . - gdt /* 0x20 */ - .word 0xffff, 0 - .byte 0, 0x9e, 0x40, 0 - - /* boot data segment, will be patched */ -bootdataseg = . - gdt /* 0x28 */ - .word 0xffff, 0 - .byte 0, 0x92, 0x0f, 0 - - /* 16 bit real mode, will be patched */ -bootrealseg = . - gdt /* 0x30 */ - .word 0xffff, 0 - .byte 0, 0x9e, 0x00, 0 -gdtlen = . - gdt - - .align 4 -gdtarg: - .word gdtlen-1 /* limit */ - .long 0 /* addr, will be inserted */ - -_boot2: - data32 - xorl %eax, %eax - movl %cs, %ax - movl %ax, %ds - movl %ax, %es - addr32 - data32 - movl %eax, CNAME(ourseg) - data32 - shll $4, %eax - - /* fix up GDT entries for bootstrap */ -#define FIXUP(gdt_index) \ - addr32; \ - movl %eax, gdt+gdt_index+2; /* actually movw %ax */ \ - addr32; \ - movb %bl, gdt+gdt_index+4 - - data32 - shldl $16, %eax, %ebx - - FIXUP(bootcodeseg) - FIXUP(bootrealseg) - FIXUP(bootdataseg) - - /* fix up GDT pointer */ - data32 - addl $gdt, %eax - addr32 - data32 - movl %eax, gdtarg+2 - - /* change to protected mode */ - data32 - call CNAME(real_to_prot) - - /* move the stack over the top of boot1 while we load */ - movl $_ourseg - 4, %eax - movl %eax, %esp - - movzbl %dl, %edx /* discard head (%dh) and random high bits */ - pushl %edx - call CNAME(bootsectmain) - - /* Go to internal stack */ - movl $CNAME(stacktop), %eax - movl %eax, %esp - call CNAME(main) - - -ENTRY(exit) -stop: - cli - hlt - -eread: .asciz "Read error\r\n" -enoboot: .asciz "No bootable partition\r\n" -endofcode: -/* throw in a partition in case we are block0 as well */ -/* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */ - . = CNAME(boot1) + PARTSTART - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte 0x0,0,0,0,0,0,0,0 - .long 0,0 - .byte BOOTABLE,0,1,0,BSDPART,255,255,255 - .long 0,50000 -/* the last 2 bytes in the sector 0 contain the signature */ - . = CNAME(boot1) + 0x1fe - .short SIGNATURE - . = CNAME(boot1) + 0x200 - .globl _disklabel -_disklabel: - . = CNAME(boot1) + 0x400 - - -CR0_PE = 0x1 -/* - * real_to_prot() - * transfer from real mode to protected mode. - */ -ENTRY(real_to_prot) - # guarantee that interrupt is disabled when in prot mode - cli - - # load the gdtr - addr32 - data32 - lgdt gdtarg - - # set the PE bit of CR0 - movl %cr0, %eax - - data32 - orl $CR0_PE, %eax - movl %eax, %cr0 - - # make intrasegment jump to flush the processor pipeline and - # reload CS register - data32 - ljmp $bootcodeseg, $xprot - -xprot: - # we are in USE32 mode now - # set up the protected mode segment registers : DS, SS, ES - movl $bootdataseg, %eax - movl %ax, %ds - movl %ax, %ss - movl %ax, %es - - ret - -/* - * prot_to_real() - * transfer from protected mode to real mode - */ -ENTRY(prot_to_real) - # set up a dummy stack frame for the second seg change. - # Adjust the intersegment jump instruction following - # the clearing of protected mode bit. - # This is self-modifying code, but we need a writable - # code segment, and an intersegment return does not give us that. - - movl _ourseg, %eax - movw %ax, xreal-2 - - # Change to use16 mode. - ljmp $bootrealseg, $x16 - -x16: - # clear the PE bit of CR0 - movl %cr0, %eax - data32 - andl $~CR0_PE, %eax - movl %eax, %cr0 - # Here we have an 16 bits intersegment jump. - .byte 0xea - .word xreal - .word 0 - -xreal: - # we are in real mode now - # set up the real mode segment registers : DS, SS, ES - movl %cs, %ax - movl %ax, %ds - movl %ax, %ss - movl %ax, %es - - sti - data32 - ret - -/* - * pbzero(dst, cnt) - * where dst is a physical address and cnt is the length - */ -ENTRY(pbzero) - pushl %ebp - movl %esp, %ebp - pushl %es - pushl %edi - - cld - - # set %es to point at the flat segment - movl $flatdataseg, %eax - movl %ax, %es - - movl 8(%ebp), %edi # destination - movl 12(%ebp), %ecx # count - xorl %eax, %eax # value - - rep - stosb - - popl %edi - popl %es - popl %ebp - ret - -/* - * vpbcopy(src, dst, cnt) - * where src is a virtual address and dst is a physical address - */ -ENTRY(vpbcopy) - pushl %ebp - movl %esp, %ebp - pushl %es - pushl %esi - pushl %edi - - cld - - # set %es to point at the flat segment - movl $flatdataseg, %eax - movl %ax, %es - - movl 8(%ebp), %esi # source - movl 12(%ebp), %edi # destination - movl 16(%ebp), %ecx # count - - rep - movsb - - popl %edi - popl %esi - popl %es - popl %ebp - ret - -/* - * pvbcopy(src, dst, cnt) - * where src is a physical address and dst is a virtual address - */ -ENTRY(pvbcopy) - pushl %ebp - movl %esp, %ebp - pushl %ds - pushl %esi - pushl %edi - - cld - - # set %ds to point at the flat segment - movl $flatdataseg, %eax - movl %ax, %ds - - movl 8(%ebp), %esi # source - movl 12(%ebp), %edi # destination - movl 16(%ebp), %ecx # count - - rep - movsb - - popl %edi - popl %esi - popl %ds - popl %ebp - ret - -ENTRY(vtophys) - movl _ourseg, %eax - shll $4, %eax - addl 4(%esp), %eax - ret diff --git a/sys/boot/i386/libi386/crt/buffers.S b/sys/boot/i386/libi386/crt/buffers.S deleted file mode 100644 index 9ded63c..0000000 --- a/sys/boot/i386/libi386/crt/buffers.S +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Provide buffer space for various items. - * - * We do this in the text segment so that we can control the location - * of the buffers at the link stage, and thus ensure that they are - * within reach of the real-mode support routines. - * - * It is especially important to have the stack down low so that - * it is reachable from both 32-bit and 16-bit code. - */ - -#include <machine/asm.h> - - .text - .align 4 -ENTRY(diskbuf) - . = CNAME(diskbuf) + (DISKBUFSIZE * 512) -ENTRY(diskbuf_user) - .long 0 -ENTRY(diskbuf_size) - .long DISKBUFSIZE - - .align 4 -ENTRY(stackbase) - . = CNAME(stackbase) + STACKSIZE -ENTRY(stacktop) - .long 0 diff --git a/sys/boot/i386/libi386/crt/diskbuf.h b/sys/boot/i386/libi386/crt/diskbuf.h deleted file mode 100644 index ad4949c..0000000 --- a/sys/boot/i386/libi386/crt/diskbuf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: diskbuf.h,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ - */ - -/* - * Copyright (c) 1996 - * Matthias Drochner. 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 for the NetBSD Project - * by Matthias Drochner. - * 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 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. - * - */ - -/* data buffer for BIOS disk / DOS I/O */ - -extern char diskbuf[]; /* client-supplied disk buffer */ -extern void *diskbuf_user; /* using function sets it to unique value to allow check if overwritten*/ -extern int diskbuf_size; /* size of client-supplied buffer in sectors */ diff --git a/sys/boot/i386/libi386/getsecs.c b/sys/boot/i386/libi386/getsecs.c deleted file mode 100644 index 3529c39..0000000 --- a/sys/boot/i386/libi386/getsecs.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * $Id$ - * From: $NetBSD: getsecs.c,v 1.1.1.1 1997/03/14 02:40:32 perry Exp $ - */ - -/* extracted from netbsd:sys/arch/i386/netboot/misc.c */ - -#include <sys/types.h> -#include <stand.h> - -#include "libi386.h" - -extern int biosgetrtc __P((u_long*)); - -time_t -time(time_t *tloc) { - /* - * Return the current time (of day) in seconds. - * XXX should be extended to do it "more right" perhaps? - * XXX uses undocumented BCD support from libstand. - */ - - u_long t; - time_t sec; - - if(biosgetrtc(&t)) - panic("RTC invalid"); - - sec = bcd2bin(t & 0xff); - sec *= 60; - t >>= 8; - sec += bcd2bin(t & 0xff); - sec *= 60; - t >>= 8; - sec += bcd2bin(t & 0xff); - - if (tloc != NULL) - *tloc = sec; - return(sec); -} diff --git a/sys/boot/i386/libi386/i386_copy.c b/sys/boot/i386/libi386/i386_copy.c index 53e1c79..0ff98ba 100644 --- a/sys/boot/i386/libi386/i386_copy.c +++ b/sys/boot/i386/libi386/i386_copy.c @@ -9,20 +9,27 @@ #include <stand.h> #include "libi386.h" +#include "btxv86.h" #define READIN_BUF 4096 int i386_copyin(void *src, vm_offset_t dest, size_t len) { - vpbcopy(src, dest, len); + if (dest + len >= memtop) + return(0); + + bcopy(src, PTOV(dest), len); return(len); } int i386_copyout(vm_offset_t src, void *dest, size_t len) { - pvbcopy(src, dest, len); + if (src + len >= memtop) + return(0); + + bcopy(PTOV(src), dest, len); return(len); } @@ -33,6 +40,9 @@ i386_readin(int fd, vm_offset_t dest, size_t len) void *buf; size_t resid, chunk, get, got; + if (dest + len >= memtop) + return(0); + chunk = min(READIN_BUF, len); buf = malloc(chunk); if (buf == NULL) @@ -43,7 +53,7 @@ i386_readin(int fd, vm_offset_t dest, size_t len) got = read(fd, buf, get); if (got <= 0) break; - vpbcopy(buf, dest, chunk); + bcopy(buf, PTOV(dest), chunk); } free(buf); return(len - resid); diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h index 02168fc..0fe5350 100644 --- a/sys/boot/i386/libi386/libi386.h +++ b/sys/boot/i386/libi386/libi386.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: libi386.h,v 1.3 1998/09/03 02:10:09 msmith Exp $ + * $Id: libi386.h,v 1.4 1998/09/14 18:27:05 msmith Exp $ */ @@ -64,24 +64,39 @@ extern struct devdesc currdev; /* our current device */ extern struct devsw biosdisk; /* from crt module */ +#if 0 /* BTX */ extern void vpbcopy(void *src, vm_offset_t dest, size_t size); extern void pvbcopy(vm_offset_t src, void *dest, size_t size); extern void pbzero(vm_offset_t dest, size_t size); extern vm_offset_t vtophys(void *addr); +#endif extern int i386_copyin(void *src, vm_offset_t dest, size_t len); extern int i386_copyout(vm_offset_t src, void *dest, size_t len); extern int i386_readin(int fd, vm_offset_t dest, size_t len); +#if 0 /* BTX */ extern void startprog(vm_offset_t entry, int argc, u_int32_t *argv, vm_offset_t stack); +#endif extern int getbasemem(void); extern int getextmem(void); +extern vm_offset_t memtop; -extern void reboot(void); extern void gateA20(void); extern int i386_autoload(void); extern int bi_getboothowto(char *kargs); extern vm_offset_t bi_copyenv(vm_offset_t addr); + +/* + * BIOS functions from bioscalls.c + */ +extern int BIOS_cominit(int port); +extern int BIOS_computc(int c, int port); +extern int BIOS_comgetc(int port); +extern int BIOS_comisc(int port); +extern int BIOS_diskinfo_old(int drive, int *param); + + diff --git a/sys/boot/i386/libi386/startprog.S b/sys/boot/i386/libi386/startprog.S deleted file mode 100644 index 348341f..0000000 --- a/sys/boot/i386/libi386/startprog.S +++ /dev/null @@ -1,120 +0,0 @@ -/* $NetBSD: startprog.S,v 1.1.1.1 1997/03/14 02:40:33 perry Exp $ */ - -/* starts program in protected mode / flat space - with given stackframe - needs global variables flatcodeseg and flatdataseg - (gdt offsets) - derivied from: NetBSD:sys/arch/i386/boot/asm.S - */ - -/* - * Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 - * - * Mach Operating System - * Copyright (c) 1992, 1991 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -/* - Copyright 1988, 1989, 1990, 1991, 1992 - by Intel Corporation, Santa Clara, California. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appears in all -copies and that both the copyright notice and this permission notice -appear in supporting documentation, and that the name of Intel -not be used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. - -INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, -IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, -NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION -WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#include <machine/asm.h> - -/* - * startprog(phyaddr,argc,argv,stack) - * start the program on protected mode where phyaddr is the entry point - */ -ENTRY(startprog) - pushl %ebp - movl %esp, %ebp - - # prepare a new stack - movl $flatdataseg, %ebx - movw %bx, %es # for arg copy - movl 20(%ebp), %eax # stack - subl $4,%eax - movl %eax, %edi - - # push some number of args onto the stack - movl 12(%ebp), %ecx # argc - - movl %ecx, %eax - decl %eax - shl $2, %eax - addl 16(%ebp), %eax # ptr to last arg - movl %eax, %esi - - std # backwards - rep - movsl - - cld # LynxOS depends on it - - movl 8(%ebp), %ecx # entry - - # set new stackptr (movsl decd sp 1 more -> dummy return address) - movw %bx, %ss - movl %edi, %esp - - # plug in a return address so that FreeBSD detects we are using - # bootinfo - movl $ourreturn, %eax - movl %eax, (%esp) - - # push on our entry address - movl $flatcodeseg, %ebx # segment - pushl %ebx - pushl %ecx #entry - - # convert over the other data segs - movl $flatdataseg, %ebx - movl %bx, %ds - movl %bx, %es - - # convert the PC (and code seg) - lret - -ourreturn: - /* For now there is not much we can do, just lock in a loop */ - jmp ourreturn - diff --git a/sys/boot/i386/libi386/time.c b/sys/boot/i386/libi386/time.c new file mode 100644 index 0000000..51150bd --- /dev/null +++ b/sys/boot/i386/libi386/time.c @@ -0,0 +1,56 @@ +/* + * mjs copyright + */ + +#include <stand.h> +#include <btxv86.h> + +/* + * Return the time in seconds since the beginning of the day. + * + * If we pass midnight, don't wrap back to 0. + * + * XXX uses undocumented BCD support from libstand. + */ + +time_t +time(time_t *t) +{ + static time_t lasttime, now; + int hr, min, sec; + + v86.ctl = 0; + v86.addr = 0x1a; /* int 0x1a, function 2 */ + v86.eax = 0x0200; + v86int(); + + hr = bcd2bin((v86.ecx & 0xff00) >> 8); /* hour in %ch */ + min = bcd2bin(v86.ecx & 0xff); /* minute in %cl */ + sec = bcd2bin((v86.edx & 0xff00) >> 8); /* second in %dh */ + + now = hr * 3600 + min * 60 + sec; + if (now < lasttime) + now += 24 * 3600; + lasttime = now; + + if (t != NULL) + *t = now; + return(now); +} + +/* + * Use the BIOS Wait function to pause for (period) microseconds. + * + * Resolution of this function is variable, but typically around + * 1ms. + */ +void +delay(int period) +{ + v86.ctl = 0; + v86.addr = 0x15; /* int 0x1a, function 0x86 */ + v86.eax = 0x8600; + v86.ecx = period >> 16; + v86.edx = period & 0xffff; + v86int(); +} diff --git a/sys/boot/i386/libi386/vidconsole.c b/sys/boot/i386/libi386/vidconsole.c index f8903a4..afd2a78 100644 --- a/sys/boot/i386/libi386/vidconsole.c +++ b/sys/boot/i386/libi386/vidconsole.c @@ -26,24 +26,24 @@ * * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp * - * $Id$ + * $Id: vidconsole.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ #include <stand.h> +#include <bootstrap.h> +#include <btxv86.h> +#include "libi386.h" +#if KEYBOARD_PROBE #include <machine/cpufunc.h> -#include "bootstrap.h" - -/* in vidconsole.S */ -extern void vidputc(int c); -extern int kbdgetc(void); -extern int kbdiskey(void); - static int probe_keyboard(void); +#endif static void vidc_probe(struct console *cp); static int vidc_init(int arg); -static int vidc_in(void); +static void vidc_putchar(int c); +static int vidc_getchar(void); +static int vidc_ischar(void); struct console vidconsole = { "vidconsole", @@ -51,9 +51,9 @@ struct console vidconsole = { 0, vidc_probe, vidc_init, - vidputc, - vidc_in, - kbdiskey + vidc_putchar, + vidc_getchar, + vidc_ischar }; static void @@ -61,11 +61,11 @@ vidc_probe(struct console *cp) { /* look for a keyboard */ -#if 0 - if (probe_keyboard()) { -#else - if (1) { +#if KEYBOARD_PROBE + if (probe_keyboard()) #endif + { + cp->c_flags |= C_PRESENTIN; } @@ -79,16 +79,42 @@ vidc_init(int arg) return(0); /* XXX reinit? */ } +static void +vidc_putchar(int c) +{ + v86.ctl = 0; + v86.addr = 0x10; + v86.eax = 0xe00 | c; + v86.ebx = 0x7; + v86int(); +} + static int -vidc_in(void) +vidc_getchar(void) { - if (kbdiskey()) { - return(kbdgetc()); + if (vidc_ischar()) { + v86.ctl = 0; + v86.addr = 0x16; + v86.eax = 0x0; + v86int(); + return(v86.eax); } else { return(-1); } } +static int +vidc_ischar(void) +{ + v86.ctl = 0; + v86.addr = 0x16; + v86.eax = 0x100; + v86int(); + return(v86.eax); +} + +#if KEYBOARD_PROBE + #define PROBE_MAXRETRY 5 #define PROBE_MAXWAIT 400 #define IO_DUMMY 0x84 @@ -197,3 +223,4 @@ probe_keyboard(void) return (1); } +#endif /* KEYBOARD_PROBE */ diff --git a/sys/boot/i386/libi386/vidconsole_support.S b/sys/boot/i386/libi386/vidconsole_support.S deleted file mode 100644 index 2b11171..0000000 --- a/sys/boot/i386/libi386/vidconsole_support.S +++ /dev/null @@ -1,103 +0,0 @@ -/* $Id$ */ - -/* - * PC console handling - * originally from: FreeBSD:sys/i386/boot/netboot/start2.S via NetBSD - */ - -#include <machine/asm.h> - -#define data32 .byte 0x66 - - .text - -/************************************************************************** -PUTC - Print a character -**************************************************************************/ -ENTRY(vidputc) - push %ebp - mov %esp,%ebp - push %ecx - push %ebx - push %esi - push %edi - - movb 8(%ebp),%cl - - call CNAME(prot_to_real) # enter real mode - - movb %cl,%al - data32 - mov $1,%ebx - movb $0x0e,%ah - int $0x10 - - data32 - call CNAME(real_to_prot) # back to protected mode - - pop %edi - pop %esi - pop %ebx - pop %ecx - pop %ebp - ret - -/************************************************************************** -GETC - Get a character -**************************************************************************/ -ENTRY(kbdgetc) - push %ebp - mov %esp,%ebp - push %ebx - push %esi - push %edi - - call CNAME(prot_to_real) # enter real mode - - movb $0x0,%ah - int $0x16 - movb %al,%bl - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - movb %bl,%al - - pop %edi - pop %esi - pop %ebx - pop %ebp - ret - -/************************************************************************** -ISKEY - Check for keyboard interrupt -**************************************************************************/ -ENTRY(kbdiskey) - push %ebp - mov %esp,%ebp - push %ebx - push %esi - push %edi - - call CNAME(prot_to_real) # enter real mode - - xor %ebx,%ebx - movb $0x1,%ah - int $0x16 - data32 - jz 1f - movb %al,%bl -1: - - data32 - call CNAME(real_to_prot) # back to protected mode - - xor %eax,%eax - movb %bl,%al - - pop %edi - pop %esi - pop %ebx - pop %ebp - ret |