biosmca.S revision 1.4 1 1.4 dsl /* $NetBSD: biosmca.S,v 1.4 2003/02/01 14:48:18 dsl 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.2 jdolecek .data
59 1.2 jdolecek .globl _C_LABEL(biosmca_ps2model)
60 1.2 jdolecek _C_LABEL(biosmca_ps2model): .long 0
61 1.2 jdolecek
62 1.2 jdolecek .text
63 1.1 jdolecek /*
64 1.1 jdolecek # BIOS call "INT 0x15 Function 0xc0" to read extended sys config info on PS/2
65 1.2 jdolecek # Return: no return value
66 1.2 jdolecek #
67 1.2 jdolecek # This function initializes biosmca_ps2model with model number as
68 1.2 jdolecek # identified by BIOS, if the machine is a PS/2 box (i.e. has MCA bus
69 1.2 jdolecek # instead of ISA).
70 1.1 jdolecek */
71 1.1 jdolecek ENTRY(biosmca)
72 1.4 dsl .code32
73 1.1 jdolecek pushl %ebp
74 1.1 jdolecek movl %esp, %ebp
75 1.1 jdolecek pushl %ebx
76 1.1 jdolecek push %ecx
77 1.1 jdolecek push %edx
78 1.1 jdolecek push %esi
79 1.1 jdolecek push %edi
80 1.2 jdolecek push %eax
81 1.1 jdolecek
82 1.1 jdolecek call _C_LABEL(prot_to_real) # enter real mode
83 1.4 dsl .code16
84 1.1 jdolecek
85 1.3 jdolecek # zero %ecx
86 1.3 jdolecek xorl %ecx, %ecx
87 1.2 jdolecek
88 1.4 dsl xor %ax, %ax
89 1.4 dsl movb $0xc0, %ah # subfunction
90 1.1 jdolecek int $0x15
91 1.2 jdolecek jc back
92 1.1 jdolecek
93 1.2 jdolecek # check feature byte 1 if MCA bus present and replaces ISA
94 1.4 dsl movb %es:5(%bx), %al
95 1.3 jdolecek andb $0x02, %al # bit 1 set means MCA instead of ISA
96 1.3 jdolecek # see also arch/i386/mca/mca_machdep.c
97 1.3 jdolecek jnz back
98 1.2 jdolecek
99 1.2 jdolecek # save model and submodel bytes to %cx
100 1.4 dsl movb %es:2(%bx), %ch # model (1 byte)
101 1.4 dsl movb %es:3(%bx), %cl # submodel (1 byte)
102 1.1 jdolecek
103 1.1 jdolecek back:
104 1.4 dsl calll _C_LABEL(real_to_prot) # back to protected mode
105 1.4 dsl .code32
106 1.1 jdolecek
107 1.1 jdolecek # save model
108 1.2 jdolecek movl %ecx, _C_LABEL(biosmca_ps2model)
109 1.1 jdolecek
110 1.2 jdolecek pop %eax
111 1.1 jdolecek pop %edi
112 1.1 jdolecek pop %esi
113 1.1 jdolecek pop %edx
114 1.1 jdolecek pop %ecx
115 1.1 jdolecek popl %ebx
116 1.1 jdolecek popl %ebp
117 1.1 jdolecek ret
118