Home | History | Annotate | Line # | Download | only in lib
biosmemx.S revision 1.4
      1 /*	$NetBSD: biosmemx.S,v 1.4 2003/02/05 21:48:53 dsl Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997, 1999
      5  *	Matthias Drochner.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed for the NetBSD Project
     18  *	by Matthias Drochner.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  *
     33  */
     34 
     35 #include <machine/asm.h>
     36 
     37 #define	data32	.byte 0x66
     38 
     39 	.text
     40 
     41 /* int getextmem2(int buffer[2])
     42    return: 0=OK, -1=error
     43    buffer[0]: extmem kBytes below 16M (max 15M/1024)
     44    buffer[1]: extmem above 16M, in 64k units
     45 */
     46 ENTRY(getextmem2)
     47 	pushl	%ebp
     48 	movl	%esp,%ebp
     49 	pushl	%ebx
     50 	pushl	%ecx
     51 	pushl	%edx
     52 	push	%esi
     53 	push	%edi
     54 
     55 	call	_C_LABEL(prot_to_real)
     56 	.code16
     57 
     58 	xorl	%ebx, %ebx
     59 	movl	$0xe801, %eax
     60 	int	$0x15
     61 	jc	err2
     62 
     63 	movl	$0, %ecx
     64 	jmp ok2
     65 err2:
     66 	movl	$-1, %ecx
     67 ok2:
     68 	movl	%eax, %edx
     69 
     70 	calll	_C_LABEL(real_to_prot)
     71 	.code32
     72 
     73 	movl	8(%ebp), %eax
     74 	movl	%edx, (%eax)
     75 	movl	%ebx, 4(%eax)
     76 
     77 	movl	%ecx, %eax
     78 
     79 	pop	%edi
     80 	pop	%esi
     81 	popl	%edx
     82 	popl	%ecx
     83 	popl	%ebx
     84 	popl	%ebp
     85 	ret
     86 
     87 /* int getmementry(int *iterator, buffer[5])
     88    return: 0=ok, else error
     89    buffer[0]: start of memory chunk
     90    buffer[2]: length (bytes)
     91    buffer[4]: type
     92 */
     93 ENTRY(getmementry)
     94 	pushl	%ebp
     95 	movl	%esp,%ebp
     96 	pushl	%ebx
     97 	pushl	%ecx
     98 	pushl	%edx
     99 	push	%esi
    100 	push	%edi
    101 
    102 	movl	8(%ebp), %eax
    103 	movl	0(%eax), %ebx
    104 	movl	$20, %ecx
    105 	movl	$0x534d4150, %edx	# "SMAP"
    106 	movl	12(%ebp), %edi
    107 
    108 	call	_C_LABEL(prot_to_real)
    109 	.code16
    110 
    111 	push	%di
    112 	shrl	$4, %edi
    113 	mov	%ds, %ax
    114 	add	%di, %ax
    115 	mov	%ax, %ds
    116 	pop	%di
    117 	and	$0xf, %di
    118 
    119 	movw	$0xe820, %ax
    120 	int	$0x15
    121 
    122 	setc	%cl
    123 
    124 	calll	_C_LABEL(real_to_prot)
    125 	.code32
    126 
    127 	movl	8(%ebp), %eax
    128 	movl	%ebx, 0(%eax)
    129 	xorl	%eax, %eax
    130 	movb	%cl, %al
    131 
    132 	pop	%edi
    133 	pop	%esi
    134 	popl	%edx
    135 	popl	%ecx
    136 	popl	%ebx
    137 	popl	%ebp
    138 	ret
    139