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