Home | History | Annotate | Line # | Download | only in lib
biosmemx.S revision 1.5
      1 /*	$NetBSD: biosmemx.S,v 1.5 2003/02/14 14:39:24 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 	.text
     38 
     39 /* int getextmem2(int buffer[2])
     40    return: 0=OK, -1=error
     41    buffer[0]: extmem kBytes below 16M (max 15M/1024)
     42    buffer[1]: extmem above 16M, in 64k units
     43 */
     44 ENTRY(getextmem2)
     45 	pushl	%ebp
     46 	movl	%esp,%ebp
     47 	pushl	%ebx
     48 	pushl	%ecx
     49 	pushl	%edx
     50 	push	%esi
     51 	push	%edi
     52 
     53 	call	_C_LABEL(prot_to_real)
     54 	.code16
     55 
     56 	xorl	%ebx, %ebx
     57 	movl	$0xe801, %eax
     58 	int	$0x15
     59 	jc	err2
     60 
     61 	movl	$0, %ecx
     62 	jmp ok2
     63 err2:
     64 	movl	$-1, %ecx
     65 ok2:
     66 	movl	%eax, %edx
     67 
     68 	calll	_C_LABEL(real_to_prot)
     69 	.code32
     70 
     71 	movl	8(%ebp), %eax
     72 	movl	%edx, (%eax)
     73 	movl	%ebx, 4(%eax)
     74 
     75 	movl	%ecx, %eax
     76 
     77 	pop	%edi
     78 	pop	%esi
     79 	popl	%edx
     80 	popl	%ecx
     81 	popl	%ebx
     82 	popl	%ebp
     83 	ret
     84 
     85 /* int getmementry(int *iterator, buffer[5])
     86    return: 0=ok, else error
     87    buffer[0]: start of memory chunk
     88    buffer[2]: length (bytes)
     89    buffer[4]: type
     90 */
     91 ENTRY(getmementry)
     92 	pushl	%ebp
     93 	movl	%esp,%ebp
     94 	pushl	%ebx
     95 	pushl	%ecx
     96 	pushl	%edx
     97 	push	%esi
     98 	push	%edi
     99 
    100 	movl	8(%ebp), %eax
    101 	movl	0(%eax), %ebx
    102 	movl	$20, %ecx
    103 	movl	$0x534d4150, %edx	# "SMAP"
    104 	movl	12(%ebp), %edi
    105 
    106 	call	_C_LABEL(prot_to_real)
    107 	.code16
    108 
    109 	push	%di
    110 	shrl	$4, %edi
    111 	mov	%ds, %ax
    112 	add	%di, %ax
    113 	mov	%ax, %es
    114 	pop	%di
    115 	and	$0xf, %di
    116 
    117 	movw	$0xe820, %ax
    118 	int	$0x15
    119 
    120 	setc	%cl
    121 
    122 	calll	_C_LABEL(real_to_prot)
    123 	.code32
    124 
    125 	movl	8(%ebp), %eax
    126 	movl	%ebx, 0(%eax)
    127 	xorl	%eax, %eax
    128 	movb	%cl, %al
    129 
    130 	pop	%edi
    131 	pop	%esi
    132 	popl	%edx
    133 	popl	%ecx
    134 	popl	%ebx
    135 	popl	%ebp
    136 	ret
    137