void meminit(void) { int i; Map *mp; Confmem *cm; ulong pa, *pte; ulong maxmem, lost; char *p; if(p = getconf("*maxmem")) maxmem = strtoul(p, 0, 0); else maxmem = 0; /* * Set special attributes for memory between 640KB and 1MB: * VGA memory is writethrough; * BIOS ROM's/UMB's are uncached; * then scan for useful memory. */ for(pa = 0xA0000; pa < 0xC0000; pa += BY2PG){ pte = mmuwalk(m->pdb, (ulong)KADDR(pa), 2, 0); *pte |= PTEWT; } for(pa = 0xC0000; pa < 0x100000; pa += BY2PG){ pte = mmuwalk(m->pdb, (ulong)KADDR(pa), 2, 0); *pte |= PTEUNCACHED; } mmuflushtlb(PADDR(m->pdb)); umbscan(); lowraminit(); if(e820scan() < 0) ramscan(maxmem); /* * Set the conf entries describing banks of allocatable memory. */ for(i=0; i<nelem(mapram) && i<nelem(conf.mem); i++){ mp = &rmapram.map[i]; cm = &conf.mem[i]; cm->base = mp->addr; cm->npage = mp->size/BY2PG; } lost = 0; for(; i<nelem(mapram); i++) lost += rmapram.map[i].size; if(lost) print("meminit - lost %lud bytes\n", lost); if(MEMDEBUG) memdebug(); }
void meminit(ulong) { /* A hack to initialize unbacked physical memory. It's assumed PCI space is assigned by the BIOS in the 0xF0000000 range and 9load never needs more than 0x2000... to run. These values leave ample space for memory allocations for uninitialized PCI cards (e.g. cardbus cards). (pb) */ ulong maxmem = 0x40000000; umbscan(); mapfree(&rmapupa, maxmem, 0x00000000-maxmem); if(MEMDEBUG) memdebug(); }
void meminit(u32int) { MMap *map; u32int modend; u64int addr, last, len; umbscan(); modend = PADDR(memstart); last = 0; for(map = mmap; map < &mmap[nmmap]; map++){ addr = (((u64int)map->base[1])<<32)|map->base[0]; len = (((u64int)map->length[1])<<32)|map->length[0]; switch(map->type){ default: case 2: /* reserved */ case 3: /* ACPI Reclaim Memory */ case 4: /* ACPI NVS Memory */ break; case 1: /* Memory */ if(addr < 1*MiB || addr+len < modend) break; if(addr < modend){ len -= modend - addr; addr = modend; } mapraminit(addr, len); break; } if(addr != last && addr > modend){ /* * See the comments in main about space < 1MiB. */ if(addr >= 1*MiB || addr < 0x000A0000) mapupainit(last, addr-last); } last = addr+len; } /* changeconf("*noe820scan=1\n"); */ if(MEMDEBUG) memdebug(); }