1/* $NetBSD: biosmemx.S,v 1.2 1999/03/08 21:38:28 drochner 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#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*/ 46ENTRY(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 65err2: 66 data32 67 movl $-1, %ecx 68ok2: 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: 0=ok, else error 91 buffer[0]: start of memory chunk 92 buffer[2]: length (bytes) 93 buffer[4]: type 94*/ 95ENTRY(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), %eax 105 movl 0(%eax), %ebx 106 movl $20, %ecx 107 movl $0x534d4150, %edx # "SMAP" 108 movl 12(%ebp), %edi 109 110 call _C_LABEL(prot_to_real) 111 112 data32 113 movl $0xe820, %eax 114 int $0x15 115 116 setc %cl 117 118 data32 119 call _C_LABEL(real_to_prot) 120 121 movl 8(%ebp), %eax 122 movl %ebx, 0(%eax) 123 xorl %eax, %eax 124 movb %cl, %al 125 126 pop %edi 127 pop %esi 128 popl %edx 129 popl %ecx 130 popl %ebx 131 popl %ebp 132 ret 133