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