summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/libsa
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/i386/stand/libsa')
-rw-r--r--sys/arch/i386/stand/libsa/bioscom.S7
-rw-r--r--sys/arch/i386/stand/libsa/biosdev.c4
-rw-r--r--sys/arch/i386/stand/libsa/biosdev.h12
-rw-r--r--sys/arch/i386/stand/libsa/biosdisk.S73
-rw-r--r--sys/arch/i386/stand/libsa/bioskbd.S74
-rw-r--r--sys/arch/i386/stand/libsa/biosmem.S97
-rw-r--r--sys/arch/i386/stand/libsa/biostime.S34
-rw-r--r--sys/arch/i386/stand/libsa/debug.c5
-rw-r--r--sys/arch/i386/stand/libsa/debug_i386.S35
-rw-r--r--sys/arch/i386/stand/libsa/debug_md.h11
-rw-r--r--sys/arch/i386/stand/libsa/exec_i386.c6
-rw-r--r--sys/arch/i386/stand/libsa/gidt.S76
-rw-r--r--sys/arch/i386/stand/libsa/memprobe.c5
-rw-r--r--sys/arch/i386/stand/libsa/real_prot.S26
14 files changed, 194 insertions, 271 deletions
diff --git a/sys/arch/i386/stand/libsa/bioscom.S b/sys/arch/i386/stand/libsa/bioscom.S
index db3386dc749..386d0574274 100644
--- a/sys/arch/i386/stand/libsa/bioscom.S
+++ b/sys/arch/i386/stand/libsa/bioscom.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioscom.S,v 1.3 1997/03/31 23:06:26 mickey Exp $ */
+/* $OpenBSD: bioscom.S,v 1.4 1997/04/09 08:39:12 mickey Exp $ */
/*
* Mach Operating System
@@ -26,7 +26,7 @@
* the rights to redistribute these changes.
*
* from: Mach, Revision 2.2 92/04/04 11:34:26 rpd
- * $Id: bioscom.S,v 1.3 1997/03/31 23:06:26 mickey Exp $
+ * $Id: bioscom.S,v 1.4 1997/04/09 08:39:12 mickey Exp $
*/
/*
@@ -70,6 +70,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.file "serial.s"
#include <machine/asm.h>
+#define _LOCORE
+#include "biosdev.h"
+#undef _LOCORE
.data
port:
diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c
index a2b3983fbb5..3c40b8ef344 100644
--- a/sys/arch/i386/stand/libsa/biosdev.c
+++ b/sys/arch/i386/stand/libsa/biosdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosdev.c,v 1.4 1997/04/08 22:48:27 mickey Exp $ */
+/* $OpenBSD: biosdev.c,v 1.5 1997/04/09 08:39:15 mickey Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -214,7 +214,7 @@ biosopen(struct open_file *f, ...)
}
/* BIOS disk errors translation table */
-static const struct bd_error {
+const struct bd_error {
u_int8_t bd_id;
int unix_id;
char *msg;
diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h
index 9ef4becc2af..198003f118a 100644
--- a/sys/arch/i386/stand/libsa/biosdev.h
+++ b/sys/arch/i386/stand/libsa/biosdev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosdev.h,v 1.3 1997/03/31 23:06:27 mickey Exp $ */
+/* $OpenBSD: biosdev.h,v 1.4 1997/04/09 08:39:17 mickey Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -36,6 +36,11 @@
#define BIOSNHEADS(d) (((d)>>8)+1)
#define BIOSNSECTS(d) ((d)&0xff) /* sectors are 1-based */
+#ifdef _LOCORE
+#define BIOSINT(n) int $0x20+(n)
+#else
+#define BIOSINT(n) __asm ((int $0x20+(n)))
+
/* biosdev.c */
extern const char *biosdevs[];
int biosstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
@@ -44,7 +49,7 @@ int biosclose __P((struct open_file *));
int biosioctl __P((struct open_file *, u_long, void *));
/* biosdisk.S */
-u_int biosdinfo __P((int dev));
+u_int16_t biosdinfo __P((int dev));
int biosread __P((int dev, int cyl, int hd, int sect, int nsect, void *));
int bioswrite __P((int dev, int cyl, int hd, int sect, int nsect, void *));
@@ -61,7 +66,8 @@ int com_getc __P((void));
int com_ischar __P((void));
/* biosmem.S */
-u_int biosmem __P((int));
+u_int biosmem __P((void));
/* biostime.S */
void usleep __P((u_long));
+#endif
diff --git a/sys/arch/i386/stand/libsa/biosdisk.S b/sys/arch/i386/stand/libsa/biosdisk.S
index 574d51fea9a..bd9e0c670ad 100644
--- a/sys/arch/i386/stand/libsa/biosdisk.S
+++ b/sys/arch/i386/stand/libsa/biosdisk.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: biosdisk.S,v 1.4 1997/04/05 23:49:07 mickey Exp $ */
+/* $OpenBSD: biosdisk.S,v 1.5 1997/04/09 08:39:20 mickey Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@@ -52,8 +52,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <machine/asm.h>
-#define addr32 .byte 0x67
-#define data32 .byte 0x66
+#define _LOCORE
+#include "debug_md.h"
+#include "biosdev.h"
+#undef _LOCORE
/*
# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
@@ -70,7 +72,10 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ENTRY(biosread)
pushl %ebp
movl %esp, %ebp
- pushal
+ pushl %ecx
+ pushl %ebx
+ pushl %edi
+ pushl %es
movb 8(%ebp), %dl # device
movw 12(%ebp), %cx
@@ -82,32 +87,24 @@ ENTRY(biosread)
incb %cl # sector; sec starts from 1, not 0
movb $0x2, %ah # subfunction
movb 24(%ebp), %al # number of sectors
- movl %eax, %esi # save this against mode switch
movl 28(%ebp), %ebx # offset
movl %ebx, %edi # spilt off for seg:off pair
- shrl $4, %edi
andl $0xf, %ebx # atomic read for up to 64k
+ shrl $4, %edi
- call _C_LABEL(prot_to_real) # enter real mode
-
- movl %di, %es
- movl %si, %ax
- int $0x13
- movb $0, %cl
+ BIOSINT(0x13)
+ movb $0, %al
jnc 1f
- movb %ah, %cl
+ movb %ah, %al
1:
- data32
- call _C_LABEL(real_to_prot) # back to protected mode
-
- movzbl %cl, %eax # return value in %ax
- movl %eax, 1f
+ movzbl %al, %eax # return value in %ax
- popal
- movl 1f, %eax
+ popl %es
+ popl %edi
+ popl %ebx
+ popl %ecx
popl %ebp
ret
-1: .long 0
ENTRY(bioswrite)
@@ -126,43 +123,19 @@ ENTRY(biosdinfo)
movl %esp, %ebp
pushl %ebx
pushl %ecx
- pushl %edx
movb 8(%ebp), %dl # diskinfo(drive #)
-
- call _C_LABEL(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.
- */
- xorl %bx, %bx # %bh = 0
- incl %bx; incl %bx # %bl bits 0-3 = drive type, 2 = 1.2M
- movb $79, %ch # max track
- movb $15, %cl # max sector
- xorl %dx, %dx
- incl %dx # floppy drives installed
- movb %dl, %dh # max head
- # es:di = parameter table
- # carry = 0
-
-ok:
- data32
- call _C_LABEL(real_to_prot) # back to protected mode
-
- xorl %eax, %eax
+ BIOSINT(0x13)
+ movb $1, %ah # max head
+ movb $18, %al # max sector
+ jc 1f
/* 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)
-
- popl %edx
+1:
popl %ecx
popl %ebx
popl %ebp
diff --git a/sys/arch/i386/stand/libsa/bioskbd.S b/sys/arch/i386/stand/libsa/bioskbd.S
index 83b5d283573..2b70ea39eb9 100644
--- a/sys/arch/i386/stand/libsa/bioskbd.S
+++ b/sys/arch/i386/stand/libsa/bioskbd.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: bioskbd.S,v 1.3 1997/03/31 23:06:28 mickey Exp $ */
+/* $OpenBSD: bioskbd.S,v 1.4 1997/04/09 08:39:23 mickey Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@@ -52,8 +52,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <machine/asm.h>
-#define addr32 .byte 0x67
-#define data32 .byte 0x66
+#define _LOCORE
+#include "biosdev.h"
+#undef _LOCORE
/*
* int kbd_probe();
@@ -141,26 +142,15 @@ gotack:
# %bl = foreground color
*/
ENTRY(kbd_putc)
- pushl %ebp
- movl %esp, %ebp
- pushal
-
- movb 8(%ebp), %cl
-
- call _C_LABEL(prot_to_real)
-
- movb %cl, %al
+ pushl %ebx
+ movb 8(%esp), %al
movb $0x0e, %ah
- xorl %bx, %bx
- incl %bx
- int $0x10 # display a byte
-
- data32
- call _C_LABEL(real_to_prot)
+ xorl %ebx, %ebx
+ incl %ebx
+ BIOSINT(0x10) # display a byte
- popal
- popl %ebp
+ popl %ebx
ret
@@ -171,28 +161,9 @@ ENTRY(kbd_putc)
# %al = ASCII character
*/
ENTRY(kbd_getc)
- pushl %ebp
- movl %esp, %ebp
- pushl %ebx
- pushl %esi
- pushl %edi
-
- call _C_LABEL(prot_to_real)
-
xorl %eax, %eax
- int $0x16
-
- movb %al, %bl # real_to_prot uses %eax
-
- data32
- call _C_LABEL(real_to_prot)
-
- movzbl %bl, %eax
-
- popl %edi
- popl %esi
- popl %ebx
- popl %ebp
+ BIOSINT(0x16)
+ movzbl %al, %eax
ret
@@ -208,24 +179,9 @@ ENTRY(kbd_getc)
# ZF = set
*/
ENTRY(kbd_ischar)
- pushal
-
- call _C_LABEL(prot_to_real)
-
movb $0x01, %ah
- int $0x16
- setnz %ah
-
- movb %ah, %bl # real_to_prot uses %eax
-
- data32
- call _C_LABEL(real_to_prot)
-
- movzbl %bl, %eax
- movl %eax, 1f
-
- popal
- movl 1f, %eax
+ BIOSINT(0x16)
+ setnz %al
+ movzbl %al, %eax
ret
-1: .long 0
diff --git a/sys/arch/i386/stand/libsa/biosmem.S b/sys/arch/i386/stand/libsa/biosmem.S
index a13f4cbf897..d2c700ee0da 100644
--- a/sys/arch/i386/stand/libsa/biosmem.S
+++ b/sys/arch/i386/stand/libsa/biosmem.S
@@ -1,97 +1,10 @@
-/* $OpenBSD: biosmem.S,v 1.1 1997/03/31 23:08:36 mickey 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.
-*/
+/* $OpenBSD: biosmem.S,v 1.2 1997/04/09 08:39:24 mickey Exp $ */
#include <machine/asm.h>
-#define data32 .byte 0x66
-
-/*
-#
-# biosmem(i) : return the memory size in KB. i == 0 for conventional memory,
-# i == 1 for extended memory
-# BIOS call "INT 12H" to get conventional memory size
-# BIOS call "INT 15H, AH=88H" to get extended memory size
-# Both have the return value in AX.
-#
-*/
+#define _LOCORE
+#include "biosdev.h"
+#undef _LOCORE
ENTRY(biosmem)
- pushl %ebp
- movl %esp, %ebp
- pushl %esi
- pushl %edi
-
- movl 8(%ebp), %edx
-
- call _C_LABEL(prot_to_real) # enter real mode
-
- testb %dl, %dl
- jnz 1f
-
- int $0x12
- jmp 2f
-
-1:
- movb $0x88, %ah
- int $0x15
-
-2:
- movl %eax, %edx
-
- data32
- call _C_LABEL(real_to_prot)
-
- movl %edx, %eax
- popl %edi
- popl %esi
- popl %ebp
+ BIOSINT(0x12)
ret
diff --git a/sys/arch/i386/stand/libsa/biostime.S b/sys/arch/i386/stand/libsa/biostime.S
index fbcc8c73fc9..ad0b31e2a4c 100644
--- a/sys/arch/i386/stand/libsa/biostime.S
+++ b/sys/arch/i386/stand/libsa/biostime.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: biostime.S,v 1.2 1997/03/31 03:12:12 weingart Exp $ */
+/* $OpenBSD: biostime.S,v 1.3 1997/04/09 08:39:27 mickey Exp $ */
/*
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
@@ -52,8 +52,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <machine/asm.h>
-#define addr32 .byte 0x67
-#define data32 .byte 0x66
+#define _LOCORE
+#include "biosdev.h"
+#undef _LOCORE
/*
# BIOS call "INT 15H Function 86H" to sleep for a set number of microseconds
@@ -67,28 +68,19 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# CF = clear
*/
ENTRY(usleep)
- pushl %ebp
- movl %esp, %ebp
- pushl %ebx
+ pushl %ecx
+ pushl %edx
- movw 8(%ebp), %dx
- movw 10(%ebp), %cx
-
- call _C_LABEL(prot_to_real)
+ movw 12(%esp), %dx
+ movw 14(%esp), %cx
movb $0x86, %ah
- int $0x15
- setnc %ah
-
- movb %ah, %bl # real_to_prot uses %eax
-
- data32
- call _C_LABEL(real_to_prot)
-
- movzbl %bl, %eax
+ BIOSINT(0x15)
+ setnc %al
+ movzbl %al, %eax
- popl %ebx
- popl %ebp
+ popl %edx
+ popl %ecx
ret
/*
diff --git a/sys/arch/i386/stand/libsa/debug.c b/sys/arch/i386/stand/libsa/debug.c
index d1ec26d31d5..8f1b6449582 100644
--- a/sys/arch/i386/stand/libsa/debug.c
+++ b/sys/arch/i386/stand/libsa/debug.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: debug.c,v 1.2 1997/04/05 18:56:24 mickey Exp $ */
+/* $OpenBSD: debug.c,v 1.3 1997/04/09 08:39:29 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -39,6 +39,7 @@ const char *reg_names[] = { REG_NAMES };
const int nreg = NENTS(reg_names);
struct reg reg;
const u_int32_t *reg_values[] = { REG_VALUES(reg) };
+const char *trap_names[] = { TRAP_NAMES };
int
debug_init()
@@ -52,7 +53,7 @@ dump_regs(trapno)
{
int i;
- printf("trap: %u\n", trapno);
+ printf("trap: %s\n", trap_names[trapno]);
for (i = 0; i < nreg; putchar((++i % 4)?' ':'\n'))
printf ("%s=0x%x", reg_names[i], *reg_values[i]);
if (i % 4)
diff --git a/sys/arch/i386/stand/libsa/debug_i386.S b/sys/arch/i386/stand/libsa/debug_i386.S
index 8c1db5c5b01..895ea75288f 100644
--- a/sys/arch/i386/stand/libsa/debug_i386.S
+++ b/sys/arch/i386/stand/libsa/debug_i386.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: debug_i386.S,v 1.3 1997/04/05 18:56:25 mickey Exp $ */
+/* $OpenBSD: debug_i386.S,v 1.4 1997/04/09 08:39:32 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -49,7 +49,10 @@ alltraps:
pushl %es
#ifdef DEBUG
movl $0xb8280, %edi
- movl $0x47314730, (%edi)
+ movl 0x0a*4(%esp), %eax # trapno
+ addb $'0', %al
+ movb $0x47, %ah
+ movl %eax, (%edi)
#endif
call _check_regs
1:
@@ -74,20 +77,20 @@ ENTRY(check_regs)
movl %ax, %ds
movl $_reg, %edi
cld
- movl 0x0a(%esp,4), %eax; stosl # %eax
- movl 0x09(%esp,4), %eax; stosl # %ecx
- movl 0x08(%esp,4), %eax; stosl # %edx
- movl 0x07(%esp,4), %eax; stosl # %ebx
- movl 0x06(%esp,4), %eax; stosl # %esp
- movl 0x05(%esp,4), %eax; stosl # %ebp
- movl 0x04(%esp,4), %eax; stosl # %esi
- movl 0x03(%esp,4), %eax; stosl # %edi
- movl 0x0d(%esp,4), %eax; stosl # %eip
- movl 0x0f(%esp,4), %eax; stosl # %eflags
- movl 0x0e(%esp,4), %eax; stosl # %cs
+ movl 0x0a*4(%esp), %eax; stosl # %eax
+ movl 0x09*4(%esp), %eax; stosl # %ecx
+ movl 0x08*4(%esp), %eax; stosl # %edx
+ movl 0x07*4(%esp), %eax; stosl # %ebx
+ movl 0x06*4(%esp), %eax; stosl # %esp
+ movl 0x05*4(%esp), %eax; stosl # %ebp
+ movl 0x04*4(%esp), %eax; stosl # %esi
+ movl 0x03*4(%esp), %eax; stosl # %edi
+ movl 0x0d*4(%esp), %eax; stosl # %eip
+ movl 0x0f*4(%esp), %eax; stosl # %eflags
+ movl 0x0e*4(%esp), %eax; stosl # %cs
movl %ss, %eax; stosl # %ss
- movl 0x02(%esp,4), %eax; stosl # %ds
- movl 0x01(%esp,4), %eax; stosl # %es
+ movl 0x02*4(%esp), %eax; stosl # %ds
+ movl 0x01*4(%esp), %eax; stosl # %es
movl %fs, %eax; stosl # %fs
movl %gs, %eax; stosl # %gs
@@ -95,7 +98,7 @@ ENTRY(check_regs)
movl $0xb8288, %edi
movl $0x47354734, (%edi)
#endif
- movl 0x0b(%esp,4), %eax # trapno
+ movl 0x0b*4(%esp), %eax # trapno
pushl %eax
call _C_LABEL(dump_regs)
popl %eax
diff --git a/sys/arch/i386/stand/libsa/debug_md.h b/sys/arch/i386/stand/libsa/debug_md.h
index 014839f1978..a6b82672440 100644
--- a/sys/arch/i386/stand/libsa/debug_md.h
+++ b/sys/arch/i386/stand/libsa/debug_md.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: debug_md.h,v 1.2 1997/04/04 04:47:47 mickey Exp $ */
+/* $OpenBSD: debug_md.h,v 1.3 1997/04/09 08:39:34 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -40,6 +40,15 @@
&(r).r_ebp, &(r).r_esi, &(r).r_edi, &(r).r_eip, &(r).r_eflags, \
&(r).r_cs , &(r).r_ss, &(r).r_ds, &(r).r_es, &(r).r_fs, \
&(r).r_gs
+#define TRAP_NAMES \
+ "privileged instruction", "breakpoint trap", "arithmetic trap", \
+ "asynchronous system trap", "protection fault", "trace trap", \
+ "page fault", "alignment fault", "integer divide fault", \
+ "non-maskable interrupt", "overflow trap", "bounds check fault", \
+ "device not available fault", "double fault", \
+ "fp coprocessor operand fetch fault (![P]Pro)", "invalid tss fault", \
+ "segment not present fault", "stack fault", "machine check ([P]Pro)", \
+ "reserved fault base"
#ifdef _LOCORE
.globl _reg
diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c
index 0cf8f40987a..f829a22ca39 100644
--- a/sys/arch/i386/stand/libsa/exec_i386.c
+++ b/sys/arch/i386/stand/libsa/exec_i386.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: exec_i386.c,v 1.4 1997/04/04 17:23:29 weingart Exp $ */
+/* $OpenBSD: exec_i386.c,v 1.5 1997/04/09 08:39:36 mickey Exp $ */
#include <sys/param.h>
#include <sys/exec.h>
@@ -58,8 +58,8 @@ machdep_start(startaddr, howto, loadaddr, ssym, esym)
argv[4] = (int)esym;
argv[5] = (int)startaddr;
argv[6] = 0;
- argv[7] = biosmem(0);
- argv[8] = biosmem(1);
+ argv[7] = cnvmem;
+ argv[8] = extmem;
#ifdef DEBUG
{ int i;
diff --git a/sys/arch/i386/stand/libsa/gidt.S b/sys/arch/i386/stand/libsa/gidt.S
index cf1810edb00..1653a0d21d9 100644
--- a/sys/arch/i386/stand/libsa/gidt.S
+++ b/sys/arch/i386/stand/libsa/gidt.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: gidt.S,v 1.2 1997/04/07 01:21:54 weingart Exp $ */
+/* $OpenBSD: gidt.S,v 1.3 1997/04/09 08:39:37 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -35,10 +35,13 @@
#include <machine/psl.h>
#define _LOCORE
#include <machine/segments.h>
+#include <machine/specialreg.h>
#include <machine/trap.h>
#include <debug_md.h>
#undef _LOCORE
+#define addr32 .byte 0x67
+#define data32 .byte 0x66
.data
.globl _Gdtr
@@ -52,7 +55,7 @@ gdt:
.word 0xFFFF # lolimit
.word 0 # lobase
.byte 0 # midbase
- .byte SDT_MEMERA | 0 | 0x80 # RWXA, dpl = 0, present
+ .byte SDT_MEMERAC | 0 | 0x80 # RXAC, dpl = 0, present
.byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity
.byte 0 # hibase
/* 0x10 : flat data */
@@ -66,8 +69,8 @@ gdt:
.word 0xFFFF # lolimit
.word 0 # lobase
.byte 0 # midbase
- .byte SDT_MEMERA | 0 | 0x80 # RWXA, dpl = 0, present
- .byte 0xf | 0 | 0 | 0 # hilimit, xx, 16bit, byte granularity
+ .byte SDT_MEMERA | 0 | 0x80 # RXAC, dpl = 0, present
+ .byte 0x0 | 0 | 0 | 0 # hilimit, xx, 16bit, byte granularity
.byte 0 # hibase
_Gdtr: .word . - gdt - 1
.long gdt
@@ -127,28 +130,36 @@ idt: /*
IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx)
IDTENTRY(xx)
/* Maskable interrupts(32-255) */
+ /* BIOS entry points (32-63) */
+#define IBIOS(n) IPROC(bios/**/n)
+#define IDTBIOS(n) IDTENTRY(bios/**/n)
+ IDTBIOS(0); IDTBIOS(1); IDTBIOS(2); IDTBIOS(3); IDTBIOS(4)
+ IDTBIOS(5); IDTBIOS(6); IDTBIOS(7); IDTBIOS(8); IDTBIOS(9)
+ IDTBIOS(10); IDTBIOS(11); IDTBIOS(12); IDTBIOS(13); IDTBIOS(14)
+ IDTBIOS(15); IDTBIOS(16); IDTBIOS(17); IDTBIOS(18); IDTBIOS(19)
+ IDTBIOS(20); IDTBIOS(21); IDTBIOS(22); IDTBIOS(23)
+ /* DOS entry points */
_Idtr_prot:
- .word . - idt
+ .word . - idt - 1
.long idt
.text
- .globl alltraps
#define IENTRY(name,type) \
IPROC(name): \
pushl $type ; \
- jmp alltraps
+ jmp 1f
#define IENTRY_ERR(name,err,type) \
IPROC(name): \
pushl $err ; \
pushl $type ; \
- jmp alltraps
+ jmp 1f
IPROC(xx):
pushl $1
pushl $256
- jmp alltraps
+ jmp 1f
IENTRY_ERR(de,0,T_DIVIDE)
IENTRY_ERR(db,0,T_TRCTRAP)
@@ -169,3 +180,50 @@ IENTRY_ERR(mf,0,T_ARITHTRAP)
IENTRY(ac,T_ALIGNFLT)
IENTRY(mc,T_MACHK)
+ .globl alltraps
+1: /* save on jumps */
+ jmp alltraps
+
+#define IBIOSENT(n) IBIOS(n): pushl %eax; movb $n, %al ; jmp 1f
+
+IBIOSENT(0); IBIOSENT(1); IBIOSENT(2); IBIOSENT(3)
+IBIOSENT(4); IBIOSENT(5); IBIOSENT(6); IBIOSENT(7)
+IBIOSENT(8); IBIOSENT(9); IBIOSENT(10); IBIOSENT(11)
+IBIOSENT(12); IBIOSENT(13); IBIOSENT(14); IBIOSENT(15)
+IBIOSENT(16); IBIOSENT(17); IBIOSENT(18); IBIOSENT(19)
+IBIOSENT(20); IBIOSENT(21); IBIOSENT(22); IBIOSENT(23)
+
+ .text
+ .globl _real_to_prot, _prot_to_real
+1:
+ movb %al, intno
+ popl %eax
+ pushal
+ pushl %ds
+ pushl %es
+
+ call _prot_to_real
+
+ movl %di, %es
+
+ int $0
+intno = . - 1
+
+ movb %ah, %bh
+ lahf
+ xchgb %ah, %bh
+
+ data32
+ call _real_to_prot
+
+ /* pass BIOS return values back to caller */
+ movl %eax, 0x9*4(%esp)
+ movl %ecx, 0x8*4(%esp)
+ movl %edx, 0x7*4(%esp)
+ movb %bh , 0xc*4(%esp)
+
+ popl %es
+ popl %ds
+ popal
+ iret
+
diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c
index a50cac42932..95d41fcb205 100644
--- a/sys/arch/i386/stand/libsa/memprobe.c
+++ b/sys/arch/i386/stand/libsa/memprobe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memprobe.c,v 1.2 1997/03/31 23:06:30 mickey Exp $ */
+/* $OpenBSD: memprobe.c,v 1.3 1997/04/09 08:39:39 mickey Exp $ */
#include <sys/param.h>
#include "libsa.h"
@@ -11,8 +11,7 @@ memprobe()
{
int ram;
- cnvmem = biosmem(0);
- extmem = biosmem(1);
+ cnvmem = biosmem();
/* probe extended memory
*
diff --git a/sys/arch/i386/stand/libsa/real_prot.S b/sys/arch/i386/stand/libsa/real_prot.S
index 04737039640..b04d5545335 100644
--- a/sys/arch/i386/stand/libsa/real_prot.S
+++ b/sys/arch/i386/stand/libsa/real_prot.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: real_prot.S,v 1.4 1997/04/05 18:56:28 mickey Exp $ */
+/* $OpenBSD: real_prot.S,v 1.5 1997/04/09 08:39:42 mickey Exp $ */
/*
* Mach Operating System
@@ -77,6 +77,9 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ENTRY(real_to_prot)
/* guarantee that interrupts are disabled when in prot mode */
cli
+ addr32
+ data32
+ movl %eax, 2f
/* load the gdtr */
addr32
@@ -104,11 +107,12 @@ ENTRY(real_to_prot)
movl %ax, %ds
movl %ax, %ss
movl %ax, %es
- movl %ax, %fs
- movl %ax, %gs
- /* load idtr so we can debug */
+ /* load idtr for debugger and BIOS iface */
lidt _Idtr_prot
+ # movl Leax, %eax
+ .byte 0xb8
+2: .long 0 /* eax */
ret
/*
@@ -120,8 +124,9 @@ ENTRY(real_to_prot)
ENTRY(prot_to_real)
+ movl %eax, 4f
movl _codeseg, %eax
- # movw %ax, 2f
+ movw %ax, 2f
/* Change to use16 mode. */
ljmp $0x18, $1f
@@ -143,13 +148,18 @@ ENTRY(prot_to_real)
movl %ax, %ds
movl %ax, %ss
movl %ax, %es
- movl %ax, %fs
- movl %ax, %gs
- /* load idtr so we can debug */
+
+ /* load idtr for BIOS operations */
addr32
data32
lidt _Idtr_real
+ addr32
+ data32
+ # movl Leax, %eax
+ .byte 0xb8
+4: .long 0 /* %eax */
+
sti
data32
ret