From e3bc07db0d19f98ebb887e43335ddde6f9b37ed4 Mon Sep 17 00:00:00 2001 From: Nate Williams Date: Sun, 1 Sep 1996 02:16:07 +0000 Subject: If the basemem value supplied by the bootblocks, differs from the value returned by the RTC, use the bootblock supplied value. Also, map the 'stolen by BIOS' memory in the same manner as the ISA-hole memory, since it is really an extenstion of the BIOS. This is necessary for 32-bit BIOS functions such as APM support on laptops, and the loss of memory for non-necessary functions seems to be at most 4k. Reviewed by: phk Obtained from: email conversation with jtk@atria.com --- sys/amd64/amd64/machdep.c | 39 +++++++++++++++++++++++++++++++++------ sys/i386/i386/machdep.c | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 6d5a23b59f43..69190b76be3c 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.198 1996/08/12 20:03:16 wollman Exp $ + * $Id: machdep.c,v 1.199 1996/08/19 20:06:52 julian Exp $ */ #include "npx.h" @@ -1081,14 +1081,41 @@ init386(first) biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); /* - * Print a warning if the official BIOS interface disagrees - * with the hackish interface used above. Eventually only - * the official interface should be used. + * Print a warning and set it to the safest value if the official + * BIOS interface (bootblock supplied) disagrees with the + * hackish interface used above. Eventually only the official + * interface should be used. This is necessary for some machines + * who 'steal' memory from the basemem for use as BIOS memory. */ if (bootinfo.bi_memsizes_valid) { - if (bootinfo.bi_basemem != biosbasemem) - printf("BIOS basemem (%ldK) != RTC basemem (%dK)\n", + if (bootinfo.bi_basemem != biosbasemem) { + vm_offset_t pa, va, tmpva; + vm_size_t size; + unsigned *pte; + + printf("BIOS basemem (%ldK) != RTC basemem (%dK), ", bootinfo.bi_basemem, biosbasemem); + printf("setting to BIOS value.\n"); + biosbasemem = bootinfo.bi_basemem; + /* + * XXX - Map this 'hole' of memory in the same manner + * as the ISA_HOLE (read/write/non-cacheable), since + * the BIOS 'fudges' it to become part of the ISA_HOLE. + * This code is similar to the code used in + * pmap_mapdev, but since no memory needs to be + * allocated we simply change the mapping. + */ + pa = biosbasemem * 1024; + va = pa + KERNBASE; + size = roundup(ISA_HOLE_START - pa, PAGE_SIZE); + for (tmpva = va; size > 0;) { + pte = (unsigned *)vtopte(tmpva); + *pte = pa | PG_RW | PG_V | PG_N; + size -= PAGE_SIZE; + tmpva += PAGE_SIZE; + pa += PAGE_SIZE; + } + } if (bootinfo.bi_extmem != biosextmem) printf("BIOS extmem (%ldK) != RTC extmem (%dK)\n", bootinfo.bi_extmem, biosextmem); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 6d5a23b59f43..69190b76be3c 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.198 1996/08/12 20:03:16 wollman Exp $ + * $Id: machdep.c,v 1.199 1996/08/19 20:06:52 julian Exp $ */ #include "npx.h" @@ -1081,14 +1081,41 @@ init386(first) biosextmem = rtcin(RTC_EXTLO)+ (rtcin(RTC_EXTHI)<<8); /* - * Print a warning if the official BIOS interface disagrees - * with the hackish interface used above. Eventually only - * the official interface should be used. + * Print a warning and set it to the safest value if the official + * BIOS interface (bootblock supplied) disagrees with the + * hackish interface used above. Eventually only the official + * interface should be used. This is necessary for some machines + * who 'steal' memory from the basemem for use as BIOS memory. */ if (bootinfo.bi_memsizes_valid) { - if (bootinfo.bi_basemem != biosbasemem) - printf("BIOS basemem (%ldK) != RTC basemem (%dK)\n", + if (bootinfo.bi_basemem != biosbasemem) { + vm_offset_t pa, va, tmpva; + vm_size_t size; + unsigned *pte; + + printf("BIOS basemem (%ldK) != RTC basemem (%dK), ", bootinfo.bi_basemem, biosbasemem); + printf("setting to BIOS value.\n"); + biosbasemem = bootinfo.bi_basemem; + /* + * XXX - Map this 'hole' of memory in the same manner + * as the ISA_HOLE (read/write/non-cacheable), since + * the BIOS 'fudges' it to become part of the ISA_HOLE. + * This code is similar to the code used in + * pmap_mapdev, but since no memory needs to be + * allocated we simply change the mapping. + */ + pa = biosbasemem * 1024; + va = pa + KERNBASE; + size = roundup(ISA_HOLE_START - pa, PAGE_SIZE); + for (tmpva = va; size > 0;) { + pte = (unsigned *)vtopte(tmpva); + *pte = pa | PG_RW | PG_V | PG_N; + size -= PAGE_SIZE; + tmpva += PAGE_SIZE; + pa += PAGE_SIZE; + } + } if (bootinfo.bi_extmem != biosextmem) printf("BIOS extmem (%ldK) != RTC extmem (%dK)\n", bootinfo.bi_extmem, biosextmem); -- cgit v1.3