Home | History | Annotate | Line # | Download | only in pnpbios
pnpbioscall.S revision 1.1
      1  1.1  fvdl /* $NetBSD: pnpbioscall.S,v 1.1 2002/11/22 15:02:12 fvdl Exp $ */
      2  1.1  fvdl /*
      3  1.1  fvdl  * Copyright (c) 1999
      4  1.1  fvdl  * 	Matthias Drochner.  All rights reserved.
      5  1.1  fvdl  *
      6  1.1  fvdl  * Redistribution and use in source and binary forms, with or without
      7  1.1  fvdl  * modification, are permitted provided that the following conditions
      8  1.1  fvdl  * are met:
      9  1.1  fvdl  * 1. Redistributions of source code must retain the above copyright
     10  1.1  fvdl  *    notice, this list of conditions, and the following disclaimer.
     11  1.1  fvdl  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  fvdl  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  fvdl  *    documentation and/or other materials provided with the distribution.
     14  1.1  fvdl  *
     15  1.1  fvdl  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  1.1  fvdl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  1.1  fvdl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  1.1  fvdl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.1  fvdl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.1  fvdl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  1.1  fvdl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1  fvdl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.1  fvdl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.1  fvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.1  fvdl  * SUCH DAMAGE.
     26  1.1  fvdl  */
     27  1.1  fvdl 
     28  1.1  fvdl #include "assym.h"
     29  1.1  fvdl #include <machine/asm.h>
     30  1.1  fvdl #include <machine/segments.h>
     31  1.1  fvdl 
     32  1.1  fvdl 	.data
     33  1.1  fvdl saveesp:
     34  1.1  fvdl 	.space	4
     35  1.1  fvdl 
     36  1.1  fvdl NENTRY(pnpbioscall)
     37  1.1  fvdl 	pushl	%ebp
     38  1.1  fvdl 	movl	%esp, %ebp
     39  1.1  fvdl 	/*
     40  1.1  fvdl 	 * disable interrupts - our handlers can't deal with frames of the
     41  1.1  fvdl 	 * segment we are calling, and the BIOS can't use our IDT anyway
     42  1.1  fvdl 	 */
     43  1.1  fvdl 	pushfl
     44  1.1  fvdl 	cli
     45  1.1  fvdl 
     46  1.1  fvdl 	/* call pnpbiostramp() */
     47  1.1  fvdl 	lcall	$GSEL(GPNPBIOSTRAMP_SEL, SEL_KPL), $0
     48  1.1  fvdl 
     49  1.1  fvdl 	popfl
     50  1.1  fvdl 	popl	%ebp
     51  1.1  fvdl 	ret
     52  1.1  fvdl 
     53  1.1  fvdl NENTRY(pnpbiostramp)
     54  1.1  fvdl 	pushl	%ebx
     55  1.1  fvdl 
     56  1.1  fvdl 	/* save current stack pointer */
     57  1.1  fvdl 	movl	%esp, %eax
     58  1.1  fvdl 	movl	%eax, saveesp
     59  1.1  fvdl 
     60  1.1  fvdl 	/* switch to new stack */
     61  1.1  fvdl 	movl	8(%ebp), %esp /* call argument */
     62  1.1  fvdl 	movl	$GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL), %eax
     63  1.1  fvdl 	mov	%ax, %ss
     64  1.1  fvdl 
     65  1.1  fvdl 	/* fake the call return address (16-bit frame) */
     66  1.1  fvdl 	mov	%cs, %ax
     67  1.1  fvdl 	push	%ax
     68  1.1  fvdl 	movl	$(1f - _C_LABEL(pnpbiostramp)), %eax
     69  1.1  fvdl 	push	%ax
     70  1.1  fvdl 
     71  1.1  fvdl 	/* do a long jump */
     72  1.1  fvdl 	pushl	$GSEL(GPNPBIOSCODE_SEL, SEL_KPL)
     73  1.1  fvdl 	pushl	(_C_LABEL(pnpbios_entry))
     74  1.1  fvdl #if 1
     75  1.1  fvdl 	/* paranoia: don't pass our ds */
     76  1.1  fvdl 	movl	$GSEL(GPNPBIOSSCRATCH_SEL, SEL_KPL), %eax
     77  1.1  fvdl 	mov	%ax, %ds
     78  1.1  fvdl #endif
     79  1.1  fvdl 	lret
     80  1.1  fvdl 
     81  1.1  fvdl 1:	/* returned from BIOS call */
     82  1.1  fvdl 	movl	$GSEL(GDATA_SEL, SEL_KPL), %ebx
     83  1.1  fvdl #if 1
     84  1.1  fvdl 	mov	%bx, %ds
     85  1.1  fvdl #endif
     86  1.1  fvdl 	/* back to old stack */
     87  1.1  fvdl 	mov	%bx, %ss
     88  1.1  fvdl 	movl	saveesp, %ebx
     89  1.1  fvdl 	movl	%ebx, %esp
     90  1.1  fvdl 
     91  1.1  fvdl 	popl	%ebx
     92  1.1  fvdl 	lret
     93  1.1  fvdl 	.globl _C_LABEL(epnpbiostramp)
     94  1.1  fvdl _C_LABEL(epnpbiostramp):
     95