2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Copyright 1993 NeXT Computer, Inc.
26 * All rights reserved.
28 * Harness for calling real-mode BIOS functions.
31 #include <architecture/i386/asm_help.h>
34 #define data32 .byte 0x66
35 #define addr32 .byte 0x67
61 /*============================================================================
62 * Call real-mode BIOS INT functions.
69 movl 8(%ebp), %edx // address of save area
70 movb O_INT(%edx), %al // save int number
73 movl O_EBX(%edx), %ebx
74 movl O_ECX(%edx), %ecx
75 movl O_EDI(%edx), %edi
76 movl O_ESI(%edx), %esi
77 movl O_EBP(%edx), %ebp
79 movl O_EAX(%edx), %eax
81 movl O_EDX(%edx), %eax
90 mov OFFSET16(new_eax), %eax
93 mov OFFSET16(new_edx), %edx
96 mov OFFSET16(new_es), %es
103 movl %eax, OFFSET16(save_eax)
104 popl %eax // actually pop %ax
106 movl %eax, OFFSET16(save_flag) // actually movw
109 movl %eax, OFFSET16(save_es) // actually movw
113 movl %edx, new_edx // save new edx before clobbering
115 movl new_edx, %eax // now move it into buffer
116 movl %eax, O_EDX(%edx)
118 movl %eax, O_EAX(%edx)
122 movw %ax, O_FLG(%edx)
123 movl %ebx, O_EBX(%edx)
124 movl %ecx, O_ECX(%edx)
125 movl %edi, O_EDI(%edx)
126 movl %esi, O_ESI(%edx)
127 movl %ebp, O_EBP(%edx)
134 /*============================================================================
135 * Determines the total system memory size using various BIOS Int 15 calls.
139 enter $0, $0 # create frame pointer (32 bit operand/stack)
140 pushal # save all registers
142 movl 8(%ebp), %ebx # push input structure pointer to stack
145 call __prot_to_real # switch to real mode
147 ##################################################################
149 # Do not forget the opcode overrides, since the assembler
150 # does not know we have made a transition to 16-bit operation.
151 ##################################################################
154 movl $0xE801, %eax # Get memory size
161 movl $0xDA88, %eax # Get memory size
167 movb $0x8A, %ah # Get memory size
173 movb $0x88, %ah # Get memory size
179 xorl %edx, %edx # Error, cannot get memory size
185 pushl %eax # Push EAX to 32-bit stack
188 call __real_to_prot # Back to protected mode. EAX is modified.
190 ##################################################################
191 # Back to protected mode.
192 ##################################################################
194 popl %eax # Pop EAX from stack
195 popl %ebx # Pop pointer to register structure
197 # Copy the result to the input structure pointed to by a pointer
198 # which is on top of the stack. Write register EAX and EDX to the
201 movl %eax, O_EAX(%ebx)
202 movl %edx, O_EDX(%ebx)
204 popal # restore all registers
205 leave # undo enter operator
216 movl $1024, %ebx # Add in 1M