|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1995-1994 The University of Utah and ! 3: * the Computer Systems Laboratory at the University of Utah (CSL). ! 4: * All rights reserved. ! 5: * ! 6: * Permission to use, copy, modify and distribute this software is hereby ! 7: * granted provided that (1) source code retains these copyright, permission, ! 8: * and disclaimer notices, and (2) redistributions including binaries ! 9: * reproduce the notices in supporting documentation, and (3) all advertising ! 10: * materials mentioning features or use of this software display the following ! 11: * acknowledgement: ``This product includes software developed by the ! 12: * Computer Systems Laboratory at the University of Utah.'' ! 13: * ! 14: * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS ! 15: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF ! 16: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ! 17: * ! 18: * CSL requests users of this software to return to [email protected] any ! 19: * improvements that they make and grant CSL redistribution rights. ! 20: * ! 21: * Author: Bryan Ford, University of Utah CSL ! 22: */ ! 23: ! 24: #include <mach/machine/code16.h> ! 25: #include <mach/machine/vm_types.h> ! 26: #include <mach/machine/far_ptr.h> ! 27: #include <mach/machine/proc_reg.h> ! 28: ! 29: #include "i16_bios.h" ! 30: #include "phys_mem.h" ! 31: #include "vm_param.h" ! 32: #include "debug.h" ! 33: ! 34: ! 35: static vm_offset_t ext_mem_phys_free_mem; ! 36: static vm_size_t ext_mem_phys_free_size; ! 37: ! 38: ! 39: CODE32 ! 40: ! 41: int ext_mem_collect(void) ! 42: { ! 43: if (ext_mem_phys_free_mem) ! 44: { ! 45: phys_mem_add(ext_mem_phys_free_mem, ext_mem_phys_free_size); ! 46: ext_mem_phys_free_mem = 0; ! 47: } ! 48: } ! 49: ! 50: CODE16 ! 51: ! 52: void i16_ext_mem_check() ! 53: { ! 54: vm_offset_t ext_mem_top, ext_mem_bot; ! 55: unsigned short ext_mem_k; ! 56: ! 57: /* Find the top of available extended memory. */ ! 58: asm volatile(" ! 59: int $0x15 ! 60: jnc 1f ! 61: xorw %%ax,%%ax ! 62: 1: ! 63: " : "=a" (ext_mem_k) ! 64: : "a" (0x8800)); ! 65: ext_mem_top = 0x100000 + (vm_offset_t)ext_mem_k * 1024; ! 66: ! 67: /* XXX check for >16MB memory using function 0xc7 */ ! 68: ! 69: ext_mem_bot = 0x100000; ! 70: ! 71: /* Check for extended memory allocated bottom-up: method 1. ! 72: This uses the technique (and, loosely, the code) ! 73: described in the VCPI spec, version 1.0. */ ! 74: if (ext_mem_top > ext_mem_bot) ! 75: { ! 76: asm volatile(" ! 77: pushw %%es ! 78: ! 79: xorw %%ax,%%ax ! 80: movw %%ax,%%es ! 81: movw %%es:0x19*4+2,%%ax ! 82: movw %%ax,%%es ! 83: ! 84: movw $0x12,%%di ! 85: movw $7,%%cx ! 86: rep ! 87: cmpsb ! 88: jne 1f ! 89: ! 90: xorl %%edx,%%edx ! 91: movb %%es:0x2e,%%dl ! 92: shll $16,%%edx ! 93: movw %%es:0x2c,%%dx ! 94: ! 95: 1: ! 96: popw %%es ! 97: " : "=d" (ext_mem_bot) ! 98: : "d" (ext_mem_bot), ! 99: "S" ((unsigned short)(vm_offset_t)"VDISK V") ! 100: : "eax", "ecx", "esi", "edi"); ! 101: } ! 102: i16_assert(ext_mem_bot >= 0x100000); ! 103: ! 104: /* Check for extended memory allocated bottom-up: method 2. ! 105: This uses the technique (and, loosely, the code) ! 106: described in the VCPI spec, version 1.0. */ ! 107: if (ext_mem_top > ext_mem_bot) ! 108: { ! 109: struct { ! 110: char pad1[3]; ! 111: char V; ! 112: long DISK; ! 113: char pad2[30-8]; ! 114: unsigned short addr; ! 115: } buf; ! 116: unsigned char rc; ! 117: ! 118: i16_assert(sizeof(buf) == 0x20); ! 119: rc = i16_bios_copy_ext_mem(0x100000, kvtolin((vm_offset_t)&buf), sizeof(buf)/2); ! 120: if ((rc == 0) && (buf.V == 'V') && (buf.DISK == 'DISK')) ! 121: { ! 122: vm_offset_t new_bot = (vm_offset_t)buf.addr << 10; ! 123: i16_assert(new_bot > 0x100000); ! 124: if (new_bot > ext_mem_bot) ! 125: ext_mem_bot = new_bot; ! 126: } ! 127: } ! 128: i16_assert(ext_mem_bot >= 0x100000); ! 129: ! 130: if (ext_mem_top > ext_mem_bot) ! 131: { ! 132: ext_mem_phys_free_mem = ext_mem_bot; ! 133: ext_mem_phys_free_size = ext_mem_top - ext_mem_bot; ! 134: ! 135: /* We need to update phys_mem_max here ! 136: instead of just letting phys_mem_add() do it ! 137: when the memory is collected with phys_mem_collect(), ! 138: because VCPI initialization needs to know the top of physical memory ! 139: before phys_mem_collect() is called. ! 140: See i16_vcpi.c for the gross details. */ ! 141: if (ext_mem_top > phys_mem_max) ! 142: phys_mem_max = ext_mem_top; ! 143: } ! 144: } ! 145: ! 146: void i16_ext_mem_shutdown() ! 147: { ! 148: /* We didn't actually allocate the memory, ! 149: so no need to deallocate it... */ ! 150: } ! 151:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.