biosmemx.S revision 1.6 1 /* $NetBSD: biosmemx.S,v 1.6 2003/11/07 11:34:28 dsl Exp $ */
2
3 /*
4 * Copyright (c) 1997, 1999
5 * Matthias Drochner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the NetBSD Project
18 * by Matthias Drochner.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35 #include <machine/asm.h>
36
37 .text
38
39 /* int getextmem2(int buffer[2])
40 return: 0=OK, -1=error
41 buffer[0]: extmem kBytes below 16M (max 15M/1024)
42 buffer[1]: extmem above 16M, in 64k units
43 */
44 ENTRY(getextmem2)
45 pushl %ebp
46 movl %esp,%ebp
47 pushl %ebx
48 pushl %ecx
49 pushl %edx
50 push %esi
51 push %edi
52
53 call _C_LABEL(prot_to_real)
54 .code16
55
56 xorl %ebx, %ebx
57 movl $0xe801, %eax
58 int $0x15
59 pushf
60
61 movw %si, %ax
62 orw %si, %bx
63 jz 1f /* if zero use configured values */
64 movw %cx, %ax /* k below 16M (max 0x3c00 = 15MB) */
65 movw %dx, %bx /* 64k above 16M */
66 1:
67 popf
68 setc %bl
69
70 calll _C_LABEL(real_to_prot)
71 .code32
72
73 movl 8(%ebp), %edi
74 xorl %eax, %eax
75 movw %cx, %ax
76 stosl
77 movw %dx, %ax
78 stosl
79 movb %bl, %al
80 cbw
81
82 pop %edi
83 pop %esi
84 popl %edx
85 popl %ecx
86 popl %ebx
87 popl %ebp
88 ret
89
90 /* int getmementry(int *iterator, buffer[5])
91 return: 0=ok, else error
92 buffer[0]: start of memory chunk
93 buffer[2]: length (bytes)
94 buffer[4]: type
95 */
96 ENTRY(getmementry)
97 pushl %ebp
98 movl %esp,%ebp
99 pushl %ebx
100 pushl %ecx
101 pushl %edx
102 push %esi
103 push %edi
104
105 movl 8(%ebp), %eax
106 movl 0(%eax), %ebx /* index */
107 movl $20, %ecx /* Buffer size */
108 movl $0x534d4150, %edx /* "SMAP" */
109 movl 12(%ebp), %edi /* buffer address */
110
111 call _C_LABEL(prot_to_real)
112 .code16
113
114 push %di
115 shrl $4, %edi
116 mov %ds, %ax
117 add %di, %ax
118 mov %ax, %es
119 pop %di
120 and $0xf, %di /* buffer addres now in ES:DI */
121
122 movl $0xe820, %eax /* Some BIOS check EAX value */
123 int $0x15
124
125 setc %cl
126
127 calll _C_LABEL(real_to_prot)
128 .code32
129
130 movl 8(%ebp), %eax
131 movl %ebx, 0(%eax) /* updated index */
132 xorl %eax, %eax
133 movb %cl, %al
134
135 pop %edi
136 pop %esi
137 popl %edx
138 popl %ecx
139 popl %ebx
140 popl %ebp
141 ret
142