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