Home | History | Annotate | Line # | Download | only in lib
biosmemx.S revision 1.1
      1 /*	$NetBSD: biosmemx.S,v 1.1 1997/08/14 15:22:00 drochner Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997
      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 
     57 	data32
     58 	movl	$0xe801, %eax
     59 	int	$0x15
     60 	jc	err2
     61 
     62 	data32
     63 	movl	$0, %ecx
     64 	jmp ok2
     65 err2:
     66 	data32
     67 	movl	$-1, %ecx
     68 ok2:
     69 	data32
     70 	movl	%eax, %edx
     71 
     72 	data32
     73 	call	_C_LABEL(real_to_prot)
     74 
     75 	movl	8(%ebp), %eax
     76 	movl	%edx, (%eax)
     77 	movl	%ebx, 4(%eax)
     78 
     79 	movl	%ecx, %eax
     80 
     81 	pop	%edi
     82 	pop	%esi
     83 	popl	%edx
     84 	popl	%ecx
     85 	popl	%ebx
     86 	popl	%ebp
     87 	ret
     88 
     89 /* int getmementry(int iterator, buffer[5])
     90    return: new iterator, 0=end of list or error
     91    buffer[0]: start of memory chunk
     92    buffer[2]: length (bytes)
     93    buffer[4]: type
     94 */
     95 ENTRY(getmementry)
     96 	pushl	%ebp
     97 	movl	%esp,%ebp
     98 	pushl	%ebx
     99 	pushl	%ecx
    100 	pushl	%edx
    101 	push	%esi
    102 	push	%edi
    103 
    104 	movl	8(%ebp), %ebx
    105 	movl	$20, %ecx
    106 	movl	$0x534d4150, %edx	# "SMAP"
    107 	movl	12(%ebp), %edi
    108 
    109 	call	_C_LABEL(prot_to_real)
    110 
    111 	data32
    112 	movl	$0xe820, %eax
    113 	int	$0x15
    114 
    115 	jnc	ok
    116 	data32
    117 	movl	$0, %ebx
    118 
    119 ok:
    120 	data32
    121 	call	_C_LABEL(real_to_prot)
    122 
    123 	movl	%ebx, %eax
    124 
    125 	pop	%edi
    126 	pop	%esi
    127 	popl	%edx
    128 	popl	%ecx
    129 	popl	%ebx
    130 	popl	%ebp
    131 	ret
    132