biosmca.S revision 1.4 1 /* $NetBSD: biosmca.S,v 1.4 2003/02/01 14:48:18 dsl Exp $ */
2
3 /*
4 * Ported to boot 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
5 *
6 * Mach Operating System
7 * Copyright (c) 1992, 1991 Carnegie Mellon University
8 * All Rights Reserved.
9 *
10 * Permission to use, copy, modify and distribute this software and its
11 * documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
18 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie Mellon
28 * the rights to redistribute these changes.
29 */
30
31 /*
32 Copyright 1988, 1989, 1990, 1991, 1992
33 by Intel Corporation, Santa Clara, California.
34
35 All Rights Reserved
36
37 Permission to use, copy, modify, and distribute this software and
38 its documentation for any purpose and without fee is hereby
39 granted, provided that the above copyright notice appears in all
40 copies and that both the copyright notice and this permission notice
41 appear in supporting documentation, and that the name of Intel
42 not be used in advertising or publicity pertaining to distribution
43 of the software without specific, written prior permission.
44
45 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
46 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
47 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
48 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
49 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
50 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
51 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 */
53
54 /* extracted from netbsd:sys/arch/i386/stand/bios_disk.S */
55
56 #include <machine/asm.h>
57
58 .data
59 .globl _C_LABEL(biosmca_ps2model)
60 _C_LABEL(biosmca_ps2model): .long 0
61
62 .text
63 /*
64 # BIOS call "INT 0x15 Function 0xc0" to read extended sys config info on PS/2
65 # Return: no return value
66 #
67 # This function initializes biosmca_ps2model with model number as
68 # identified by BIOS, if the machine is a PS/2 box (i.e. has MCA bus
69 # instead of ISA).
70 */
71 ENTRY(biosmca)
72 .code32
73 pushl %ebp
74 movl %esp, %ebp
75 pushl %ebx
76 push %ecx
77 push %edx
78 push %esi
79 push %edi
80 push %eax
81
82 call _C_LABEL(prot_to_real) # enter real mode
83 .code16
84
85 # zero %ecx
86 xorl %ecx, %ecx
87
88 xor %ax, %ax
89 movb $0xc0, %ah # subfunction
90 int $0x15
91 jc back
92
93 # check feature byte 1 if MCA bus present and replaces ISA
94 movb %es:5(%bx), %al
95 andb $0x02, %al # bit 1 set means MCA instead of ISA
96 # see also arch/i386/mca/mca_machdep.c
97 jnz back
98
99 # save model and submodel bytes to %cx
100 movb %es:2(%bx), %ch # model (1 byte)
101 movb %es:3(%bx), %cl # submodel (1 byte)
102
103 back:
104 calll _C_LABEL(real_to_prot) # back to protected mode
105 .code32
106
107 # save model
108 movl %ecx, _C_LABEL(biosmca_ps2model)
109
110 pop %eax
111 pop %edi
112 pop %esi
113 pop %edx
114 pop %ecx
115 popl %ebx
116 popl %ebp
117 ret
118