Home | History | Annotate | Line # | Download | only in lib
biosmemx.S revision 1.9
      1  1.9        ad /*	$NetBSD: biosmemx.S,v 1.9 2008/10/14 14:18:11 ad 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.6       dsl 	pushf
     54  1.1  drochner 
     55  1.6       dsl 	movw	%si, %ax
     56  1.6       dsl 	orw	%si, %bx
     57  1.6       dsl 	jz	1f		/* if zero use configured values */
     58  1.6       dsl 	movw	%cx, %ax	/* k below 16M (max 0x3c00 = 15MB) */
     59  1.6       dsl 	movw	%dx, %bx	/* 64k above 16M */
     60  1.6       dsl 1:
     61  1.6       dsl 	popf
     62  1.6       dsl 	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.6       dsl 	movl	8(%ebp), %edi
     68  1.6       dsl 	xorl	%eax, %eax
     69  1.6       dsl 	movw	%cx, %ax
     70  1.6       dsl 	stosl
     71  1.6       dsl 	movw	%dx, %ax
     72  1.6       dsl 	stosl
     73  1.6       dsl 	movb	%bl, %al
     74  1.6       dsl 	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.6       dsl 	movl	0(%eax), %ebx		/* index */
    101  1.6       dsl 	movl	$20, %ecx		/* Buffer size */
    102  1.6       dsl 	movl	$0x534d4150, %edx	/* "SMAP" */
    103  1.6       dsl 	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.6       dsl 	and	$0xf, %di		/* buffer addres now in ES:DI */
    115  1.1  drochner 
    116  1.6       dsl 	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.6       dsl 	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  1.9        ad 
    137  1.9        ad /* int biosA20(void)
    138  1.9        ad    return: 0=ok, else error
    139  1.9        ad */
    140  1.9        ad ENTRY(biosA20)
    141  1.9        ad 	pushl	%ebp
    142  1.9        ad 	movl	%esp,%ebp
    143  1.9        ad 	pushl	%ebx
    144  1.9        ad 	pushl	%ecx
    145  1.9        ad 	pushl	%edx
    146  1.9        ad 	push	%esi
    147  1.9        ad 	push	%edi
    148  1.9        ad 
    149  1.9        ad 	call	_C_LABEL(prot_to_real)
    150  1.9        ad 	.code16
    151  1.9        ad 
    152  1.9        ad 	movl	$0x2401, %eax
    153  1.9        ad 	int	$0x15
    154  1.9        ad 	setc	%cl
    155  1.9        ad 
    156  1.9        ad 	calll	_C_LABEL(real_to_prot)
    157  1.9        ad 	.code32
    158  1.9        ad 
    159  1.9        ad 	movzbl	%cl, %eax
    160  1.9        ad 
    161  1.9        ad 	pop	%edi
    162  1.9        ad 	pop	%esi
    163  1.9        ad 	popl	%edx
    164  1.9        ad 	popl	%ecx
    165  1.9        ad 	popl	%ebx
    166  1.9        ad 	popl	%ebp
    167  1.9        ad 	ret
    168