add 32-bit register support to BIOSCALL interface

This commit is contained in:
jtk 1998-08-31 23:52:40 +00:00
parent 4dc0e91e12
commit 10ec6359b5
4 changed files with 101 additions and 175 deletions

View File

@ -1,7 +1,10 @@
# $NetBSD: Makefile,v 1.6 1996/09/13 02:24:30 jtk Exp $
# $NetBSD: Makefile,v 1.7 1998/08/31 23:52:40 jtk Exp $
CPPFLAGS= ${APMCPPFLAGS}
CFLAGS+= -I${.CURDIR}/../.. -I${.CURDIR}/../../..
KSRC=${.CURDIR}/../../..
ARCHSRC=${.CURDIR}/../..
I386=${KSRC}/arch/i386
CFLAGS+= -I${ARCHSRC} -I${KSRC} -D_LKM
SRCS= biostramp.S
OBJS= biostramp.o
@ -25,15 +28,17 @@ biostramp: ${OBJS} ${DEPS}
@sh ${.CURDIR}/rmaouthdr biostramp biostramp.tmp
@mv -f biostramp.tmp biostramp
assym.h: genassym
./genassym > assym.h
assym.h: ${KSRC}/kern/genassym.sh genassym.cf
sh ${KSRC}/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
< genassym.cf > assym.h.tmp && \
mv -f assym.h.tmp assym.h
biostramp.S: assym.h
biostramp.o: biostramp.S
${CC} ${CFLAGS} -DASM -D_LOCORE -c biostramp.S
clean:
rm -f *.o biostramp biostramp.sym biostramp.inc genassym assym.h
rm -f *.o biostramp biostramp.sym biostramp.inc assym.h
.include <bsd.dep.mk>
.include <bsd.subdir.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: biostramp.S,v 1.6 1997/10/09 08:55:29 jtc Exp $ */
/* $NetBSD: biostramp.S,v 1.7 1998/08/31 23:52:40 jtk Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -83,21 +83,21 @@
.set BASE_PTR_ADDR,STACK_PTR_ADDR-4
.set FUNCTION_ADDR,(BASE_PTR_ADDR-2)
.set GDT_COPY_ADDR,(FUNCTION_ADDR-NGDT*8)
.set AX_REGADDR,(GDT_COPY_ADDR-2)
.set BX_REGADDR,(AX_REGADDR-2)
.set CX_REGADDR,(BX_REGADDR-2)
.set DX_REGADDR,(CX_REGADDR-2)
.set SI_REGADDR,(DX_REGADDR-2)
.set DI_REGADDR,(SI_REGADDR-2)
.set FLAGS_REGADDR,(DI_REGADDR-2)
.set ENDREGADDR,(FLAGS_REGADDR-2)
.set EAX_REGADDR,(GDT_COPY_ADDR-4)
.set EBX_REGADDR,(EAX_REGADDR-4)
.set ECX_REGADDR,(EBX_REGADDR-4)
.set EDX_REGADDR,(ECX_REGADDR-4)
.set ESI_REGADDR,(EDX_REGADDR-4)
.set EDI_REGADDR,(ESI_REGADDR-4)
.set EFLAGS_REGADDR,(EDI_REGADDR-4)
.set ENDREGADDR,(EFLAGS_REGADDR-4)
.set REALSTACK,ENDREGADDR-16 # leave a red zone?
#define COPY_FLAGS (PSL_C|PSL_PF|PSL_AF|PSL_Z|PSL_N|PSL_D|PSL_V)
/*
* do_bios_call(int function, struct apmregs *regs)
* do_bios_call(int function, struct bioscall *regs)
*/
ENTRY(do_bios_call)
@ -115,26 +115,26 @@ ENTRY(do_bios_call)
movl 8(%ebp),%eax
movw %ax,FUNCTION_ADDR
movl 12(%ebp),%ebx
movw APMREG_AX(%ebx),%ax
movw %ax,AX_REGADDR
movw APMREG_BX(%ebx),%ax
movw %ax,BX_REGADDR
movw APMREG_CX(%ebx),%ax
movw %ax,CX_REGADDR
movw APMREG_DX(%ebx),%ax
movw %ax,DX_REGADDR
movw APMREG_SI(%ebx),%ax
movw %ax,SI_REGADDR
movw APMREG_DI(%ebx),%ax
movw %ax,DI_REGADDR
movl BIOSCALLREG_EAX(%ebx),%eax
movl %eax,EAX_REGADDR
movl BIOSCALLREG_EBX(%ebx),%eax
movl %eax,EBX_REGADDR
movl BIOSCALLREG_ECX(%ebx),%eax
movl %eax,ECX_REGADDR
movl BIOSCALLREG_EDX(%ebx),%eax
movl %eax,EDX_REGADDR
movl BIOSCALLREG_ESI(%ebx),%eax
movl %eax,ESI_REGADDR
movl BIOSCALLREG_EDI(%ebx),%eax
movl %eax,EDI_REGADDR
# merge current flags with certain provided flags
movw APMREG_FLAGS(%ebx),%cx
movl BIOSCALLREG_EFLAGS(%ebx),%ecx
pushfl
popl %eax
andl $~(COPY_FLAGS|PSL_I),%eax
andl $COPY_FLAGS,%ecx
orl %ecx,%eax
movw %ax,FLAGS_REGADDR
movl %eax,EFLAGS_REGADDR
# save flags, disable interrupts, do real mode stuff
pushfl
@ -217,17 +217,17 @@ xreal: # really in real mode now
lidt IDT_bios
# Don't forget that we're in real mode, with 16-bit default data.
# all these movl's are really movw's !
# all these movl's are really movw's, and movw's are movl's!
addr32
movl DI_REGADDR-MYBASE,%edi
movw EDI_REGADDR-MYBASE,%edi
addr32
movl SI_REGADDR-MYBASE,%esi
movw ESI_REGADDR-MYBASE,%esi
addr32
movl DX_REGADDR-MYBASE,%edx
movw EDX_REGADDR-MYBASE,%edx
addr32
movl CX_REGADDR-MYBASE,%ecx
movw ECX_REGADDR-MYBASE,%ecx
addr32
movl BX_REGADDR-MYBASE,%ebx
movw EBX_REGADDR-MYBASE,%ebx
addr32
movb FUNCTION_ADDR-MYBASE,%al
addr32
@ -237,11 +237,11 @@ xreal: # really in real mode now
ljmp $(MYBASE>>4),$flushit
flushit:
addr32
movl FLAGS_REGADDR-MYBASE,%eax
movw EFLAGS_REGADDR-MYBASE,%eax
pushl %eax
popfl
addr32
movl AX_REGADDR-MYBASE,%eax
movw EAX_REGADDR-MYBASE,%eax
intaddr:
int $0xff
@ -249,20 +249,20 @@ intaddr:
# save results
pushf
addr32
movl %eax,AX_REGADDR-MYBASE
movw %eax,EAX_REGADDR-MYBASE
addr32
movl %ebx,BX_REGADDR-MYBASE
movw %ebx,EBX_REGADDR-MYBASE
addr32
movl %ecx,CX_REGADDR-MYBASE
movw %ecx,ECX_REGADDR-MYBASE
addr32
movl %edx,DX_REGADDR-MYBASE
movw %edx,EDX_REGADDR-MYBASE
addr32
movl %esi,SI_REGADDR-MYBASE
movw %esi,ESI_REGADDR-MYBASE
addr32
movl %edi,DI_REGADDR-MYBASE
movw %edi,EDI_REGADDR-MYBASE
pop %eax
addr32
movl %eax,FLAGS_REGADDR-MYBASE
movw %eax,EFLAGS_REGADDR-MYBASE
# and return to protected mode
cli # just to be sure
@ -304,20 +304,20 @@ x32:
# copy back arguments from holding pen
movl 12(%ebp),%ebx
movw AX_REGADDR,%ax
movw %ax,APMREG_AX(%ebx)
movw BX_REGADDR,%ax
movw %ax,APMREG_BX(%ebx)
movw CX_REGADDR,%ax
movw %ax,APMREG_CX(%ebx)
movw DX_REGADDR,%ax
movw %ax,APMREG_DX(%ebx)
movw SI_REGADDR,%ax
movw %ax,APMREG_SI(%ebx)
movw DI_REGADDR,%ax
movw %ax,APMREG_DI(%ebx)
movw FLAGS_REGADDR,%ax
movw %ax,APMREG_FLAGS(%ebx)
movl EAX_REGADDR,%eax
movl %eax,BIOSCALLREG_EAX(%ebx)
movl EBX_REGADDR,%eax
movl %eax,BIOSCALLREG_EBX(%ebx)
movl ECX_REGADDR,%eax
movl %eax,BIOSCALLREG_ECX(%ebx)
movl EDX_REGADDR,%eax
movl %eax,BIOSCALLREG_EDX(%ebx)
movl ESI_REGADDR,%eax
movl %eax,BIOSCALLREG_ESI(%ebx)
movl EDI_REGADDR,%eax
movl %eax,BIOSCALLREG_EDI(%ebx)
movl EFLAGS_REGADDR,%eax
movl %eax,BIOSCALLREG_EFLAGS(%ebx)
# finish up, restore registers, and return
popfl

View File

@ -1,109 +0,0 @@
/* $NetBSD: genassym.c,v 1.3 1998/08/15 05:10:22 mycroft Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 1982, 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)genassym.c 5.11 (Berkeley) 5/10/91
*/
#include <sys/types.h>
#include <i386/include/bioscall.h>
#include <i386/include/apmvar.h>
#include <stdio.h>
#include <stddef.h>
int main __P((void));
int
main()
{
#define def(N,V) printf("#define\t%s %d\n", N, V)
#define off(N,S,M) def(N, (int)offsetof(S, M))
off("APM_CODE32", struct apm_connect_info, apm_code32_seg_base);
off("APM_CODE16", struct apm_connect_info, apm_code16_seg_base);
off("APM_DATA", struct apm_connect_info, apm_data_seg_base);
off("APM_CODE32_LEN", struct apm_connect_info, apm_code32_seg_len);
off("APM_DATA_LEN", struct apm_connect_info, apm_data_seg_len);
off("APM_ENTRY", struct apm_connect_info, apm_entrypt);
off("APM_DETAIL", struct apm_connect_info, apm_detail);
def("APM_SIZE", sizeof(struct apm_connect_info));
off("APMREG_AX", struct bioscallregs, ax);
off("APMREG_BX", struct bioscallregs, bx);
off("APMREG_CX", struct bioscallregs, cx);
off("APMREG_DX", struct bioscallregs, dx);
off("APMREG_SI", struct bioscallregs, si);
off("APMREG_DI", struct bioscallregs, di);
off("APMREG_FLAGS", struct bioscallregs, flags);
exit(0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: bioscall.h,v 1.2 1997/10/15 01:21:25 jtk Exp $ */
/* $NetBSD: bioscall.h,v 1.3 1998/08/31 23:52:40 jtk Exp $ */
/*
* Copyright (c) 1997 John T. Kohl
* All rights reserved.
@ -37,14 +37,44 @@
#define BIOSTRAMP_BASE NBPG
#ifndef _LOCORE
typedef union bios_register {
struct {
u_short hw_lo;
u_short hw_hi;
} halfword;
u_int longword;
} bios_reg;
struct bioscallregs {
u_short ax;
u_short bx;
u_short cx;
u_short dx;
u_short si;
u_short di;
u_short flags;
bios_reg r_ax;
bios_reg r_bx;
bios_reg r_cx;
bios_reg r_dx;
bios_reg r_si;
bios_reg r_di;
bios_reg r_flags;
};
#define AX r_ax.halfword.hw_lo
#define AX_HI r_ax.halfword.hw_hi
#define EAX r_ax.longword
#define BX r_bx.halfword.hw_lo
#define BX_HI r_bx.halfword.hw_hi
#define EBX r_bx.longword
#define CX r_cx.halfword.hw_lo
#define CX_HI r_cx.halfword.hw_hi
#define ECX r_cx.longword
#define DX r_dx.halfword.hw_lo
#define DX_HI r_dx.halfword.hw_hi
#define EDX r_dx.longword
#define SI r_si.halfword.hw_lo
#define SI_HI r_si.halfword.hw_hi
#define ESI r_si.longword
#define DI r_di.halfword.hw_lo
#define DI_HI r_di.halfword.hw_hi
#define EDI r_di.longword
#define FLAGS r_flags.halfword.hw_lo
#define FLAGS_HI r_flags.halfword.hw_hi
#define EFLAGS r_flags.longword
#endif
#endif /* __I386_BIOSCALL_H__ */