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