Home | History | Annotate | Line # | Download | only in lib
biosmemx.S revision 1.10
      1  1.10      maxv /*	$NetBSD: biosmemx.S,v 1.10 2016/12/04 08:21:08 maxv 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.10      maxv /*
     34  1.10      maxv  * int getextmem2(int buffer[2])
     35  1.10      maxv  *
     36  1.10      maxv  * return: 0=OK, -1=error
     37  1.10      maxv  * buffer[0]: extmem kBytes below 16M (max 15M/1024)
     38  1.10      maxv  * buffer[1]: extmem above 16M, in 64k units
     39  1.10      maxv  */
     40   1.1  drochner ENTRY(getextmem2)
     41   1.1  drochner 	pushl	%ebp
     42   1.1  drochner 	movl	%esp,%ebp
     43   1.1  drochner 	pushl	%ebx
     44   1.1  drochner 	pushl	%ecx
     45   1.1  drochner 	pushl	%edx
     46   1.1  drochner 	push	%esi
     47   1.1  drochner 	push	%edi
     48   1.1  drochner 
     49   1.1  drochner 	call	_C_LABEL(prot_to_real)
     50   1.3       dsl 	.code16
     51   1.1  drochner 
     52  1.10      maxv 	xorl	%ebx,%ebx
     53  1.10      maxv 	movl	$0xe801,%eax
     54   1.1  drochner 	int	$0x15
     55   1.6       dsl 	pushf
     56   1.1  drochner 
     57  1.10      maxv 	movw	%si,%ax
     58  1.10      maxv 	orw	%si,%bx
     59   1.6       dsl 	jz	1f		/* if zero use configured values */
     60  1.10      maxv 	movw	%cx,%ax		/* k below 16M (max 0x3c00 = 15MB) */
     61  1.10      maxv 	movw	%dx,%bx		/* 64k above 16M */
     62   1.6       dsl 1:
     63   1.6       dsl 	popf
     64   1.6       dsl 	setc	%bl
     65   1.1  drochner 
     66   1.3       dsl 	calll	_C_LABEL(real_to_prot)
     67   1.3       dsl 	.code32
     68   1.1  drochner 
     69  1.10      maxv 	movl	8(%ebp),%edi
     70  1.10      maxv 	xorl	%eax,%eax
     71  1.10      maxv 	movw	%cx,%ax
     72   1.6       dsl 	stosl
     73  1.10      maxv 	movw	%dx,%ax
     74   1.6       dsl 	stosl
     75  1.10      maxv 	movb	%bl,%al
     76   1.6       dsl 	cbw
     77   1.1  drochner 
     78   1.1  drochner 	pop	%edi
     79   1.1  drochner 	pop	%esi
     80   1.1  drochner 	popl	%edx
     81   1.1  drochner 	popl	%ecx
     82   1.1  drochner 	popl	%ebx
     83   1.1  drochner 	popl	%ebp
     84   1.1  drochner 	ret
     85   1.1  drochner 
     86  1.10      maxv /*
     87  1.10      maxv  * int getmementry(int *iterator, int buffer[5])
     88  1.10      maxv  *
     89  1.10      maxv  * return: 0=ok, else error
     90  1.10      maxv  * buffer[0]: start of memory chunk
     91  1.10      maxv  * buffer[2]: length (bytes)
     92  1.10      maxv  * buffer[4]: type
     93  1.10      maxv  */
     94   1.1  drochner ENTRY(getmementry)
     95   1.1  drochner 	pushl	%ebp
     96   1.1  drochner 	movl	%esp,%ebp
     97   1.1  drochner 	pushl	%ebx
     98   1.1  drochner 	pushl	%ecx
     99   1.1  drochner 	pushl	%edx
    100   1.1  drochner 	push	%esi
    101   1.1  drochner 	push	%edi
    102   1.1  drochner 
    103  1.10      maxv 	movl	8(%ebp),%eax
    104  1.10      maxv 	movl	0(%eax),%ebx		/* index */
    105  1.10      maxv 	movl	$20,%ecx		/* Buffer size */
    106  1.10      maxv 	movl	$0x534d4150,%edx	/* "SMAP" */
    107  1.10      maxv 	movl	12(%ebp),%edi		/* buffer address */
    108   1.1  drochner 
    109   1.1  drochner 	call	_C_LABEL(prot_to_real)
    110   1.3       dsl 	.code16
    111   1.4       dsl 
    112   1.4       dsl 	push	%di
    113  1.10      maxv 	shrl	$4,%edi
    114  1.10      maxv 	mov	%ds,%ax
    115  1.10      maxv 	add	%di,%ax
    116  1.10      maxv 	mov	%ax,%es
    117   1.4       dsl 	pop	%di
    118  1.10      maxv 	and	$0xf,%di		/* buffer addres now in ES:DI */
    119   1.1  drochner 
    120  1.10      maxv 	movl	$0xe820,%eax		/* Some BIOS check EAX value */
    121   1.1  drochner 	int	$0x15
    122   1.1  drochner 
    123   1.2  drochner 	setc	%cl
    124   1.1  drochner 
    125   1.3       dsl 	calll	_C_LABEL(real_to_prot)
    126   1.3       dsl 	.code32
    127   1.1  drochner 
    128  1.10      maxv 	movl	8(%ebp),%eax
    129  1.10      maxv 	movl	%ebx,0(%eax)		/* updated index */
    130  1.10      maxv 	xorl	%eax,%eax
    131  1.10      maxv 	movb	%cl,%al
    132   1.1  drochner 
    133   1.1  drochner 	pop	%edi
    134   1.1  drochner 	pop	%esi
    135   1.1  drochner 	popl	%edx
    136   1.1  drochner 	popl	%ecx
    137   1.1  drochner 	popl	%ebx
    138   1.1  drochner 	popl	%ebp
    139   1.1  drochner 	ret
    140   1.9        ad 
    141  1.10      maxv /*
    142  1.10      maxv  * int biosA20(void)
    143  1.10      maxv  *
    144  1.10      maxv  * return: 0=ok, else error
    145  1.10      maxv  */
    146   1.9        ad ENTRY(biosA20)
    147   1.9        ad 	pushl	%ebp
    148   1.9        ad 	movl	%esp,%ebp
    149   1.9        ad 	pushl	%ebx
    150   1.9        ad 	pushl	%ecx
    151   1.9        ad 	pushl	%edx
    152   1.9        ad 	push	%esi
    153   1.9        ad 	push	%edi
    154   1.9        ad 
    155   1.9        ad 	call	_C_LABEL(prot_to_real)
    156   1.9        ad 	.code16
    157   1.9        ad 
    158  1.10      maxv 	movl	$0x2401,%eax
    159   1.9        ad 	int	$0x15
    160   1.9        ad 	setc	%cl
    161   1.9        ad 
    162   1.9        ad 	calll	_C_LABEL(real_to_prot)
    163   1.9        ad 	.code32
    164   1.9        ad 
    165  1.10      maxv 	movzbl	%cl,%eax
    166   1.9        ad 
    167   1.9        ad 	pop	%edi
    168   1.9        ad 	pop	%esi
    169   1.9        ad 	popl	%edx
    170   1.9        ad 	popl	%ecx
    171   1.9        ad 	popl	%ebx
    172   1.9        ad 	popl	%ebp
    173   1.9        ad 	ret
    174