xref: /netbsd/sys/arch/i386/stand/lib/biosmemps2.S (revision 6550d01e)
1/*	$NetBSD: biosmemps2.S,v 1.4 2009/11/21 11:52:57 dsl Exp $	*/
2
3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jaromir Dolecek.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include <machine/asm.h>
33
34	.text
35
36/* int getextmemp2(void buffer)
37   call int 15 function 0xc7 - later PS/2s - RETURN MEMORY-MAP INFORMATION
38   return: 0=OK, nonzero=error
39   buffer: filled with memory-map table structure
40*/
41ENTRY(getextmemps2)
42	.code32
43	pushl	%ebp
44	movl	%esp,%ebp
45	pushl	%ebx
46	pushl	%ecx
47	pushl	%edx
48	push	%esi
49	push	%edi
50
51	movl	8(%ebp), %edx	# parameter
52
53	call	_C_LABEL(prot_to_real)
54	.code16
55
56	# do int15, function 0xc0 call to discover if C7h is supported
57	movb	$0xc0, %ah
58	int	$0x15
59	setc	%bl
60	jc	out		# 0xc0 not supported if carry set
61
62	# check feature byte 2, bit 4 to see if return memory map is supported
63	movb	%es:6(%bx), %al
64	andb	$0x10, %al
65	jnz	getmem		# 0xc7 supported
66
67	# set %bl to indicate failure, and exit
68	movb	$2, %bl
69	jmp	out
70
71getmem:
72	# move the parameter to right register
73	push	%ds
74	movl	%edx, %esi
75	andl	$0xf, %esi
76	shrl	$4, %edx
77	mov	%ds, %ax
78	add	%dx, %ax
79	mov	%ax, %ds
80
81	# actually call int15, function 0xc7 now
82	movb	$0xc7, %ah
83	int	$0x15
84	setc	%bl		# save carry
85	pop	%ds
86
87out:
88	calll	_C_LABEL(real_to_prot)
89	.code32
90
91	xorl	%eax, %eax
92	movb	%bl, %al	# return value in %ax
93
94	pop	%edi
95	pop	%esi
96	popl	%edx
97	popl	%ecx
98	popl	%ebx
99	popl	%ebp
100	ret
101