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