MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getmemsize

Function getmemsize

freebsd/amd64/amd64/machdep.c:1220–1494  ·  view source on GitHub ↗

* Populate the (physmap) array with base/bound pairs describing the * available physical memory in the system, then test this memory and * build the phys_avail array describing the actually-available memory. * * Total memory size may be set by the kernel environment variable * hw.physmem or the compile-time define MAXMEM. * * XXX first should be vm_paddr_t. */

Source from the content-addressed store, hash-verified

1218 * XXX first should be vm_paddr_t.
1219 */
1220static void
1221getmemsize(caddr_t kmdp, u_int64_t first)
1222{
1223 int i, physmap_idx, pa_indx, da_indx;
1224 vm_paddr_t pa, physmap[PHYS_AVAIL_ENTRIES];
1225 u_long physmem_start, physmem_tunable, memtest;
1226 pt_entry_t *pte;
1227 quad_t dcons_addr, dcons_size;
1228 int page_counter;
1229
1230 /*
1231 * Tell the physical memory allocator about pages used to store
1232 * the kernel and preloaded data. See kmem_bootstrap_free().
1233 */
1234 vm_phys_early_add_seg((vm_paddr_t)kernphys, trunc_page(first));
1235
1236 bzero(physmap, sizeof(physmap));
1237 physmap_idx = 0;
1238
1239 init_ops.parse_memmap(kmdp, physmap, &physmap_idx);
1240 physmap_idx -= 2;
1241
1242 /*
1243 * Find the 'base memory' segment for SMP
1244 */
1245 basemem = 0;
1246 for (i = 0; i <= physmap_idx; i += 2) {
1247 if (physmap[i] <= 0xA0000) {
1248 basemem = physmap[i + 1] / 1024;
1249 break;
1250 }
1251 }
1252 if (basemem == 0 || basemem > 640) {
1253 if (bootverbose)
1254 printf(
1255 "Memory map doesn't contain a basemem segment, faking it");
1256 basemem = 640;
1257 }
1258
1259 /*
1260 * Maxmem isn't the "maximum memory", it's one larger than the
1261 * highest page of the physical address space. It should be
1262 * called something like "Maxphyspage". We may adjust this
1263 * based on ``hw.physmem'' and the results of the memory test.
1264 */
1265 Maxmem = atop(physmap[physmap_idx + 1]);
1266
1267#ifdef MAXMEM
1268 Maxmem = MAXMEM / 4;
1269#endif
1270
1271 if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable))
1272 Maxmem = atop(physmem_tunable);
1273
1274 /*
1275 * The boot memory test is disabled by default, as it takes a
1276 * significant amount of time on large-memory systems, and is
1277 * unfriendly to virtual machines as it unnecessarily touches all

Callers 1

hammer_timeFunction · 0.70

Calls 6

vm_phys_early_add_segFunction · 0.85
bzeroFunction · 0.85
pmap_bootstrapFunction · 0.70
printfFunction · 0.50
getenv_quadFunction · 0.50
invltlbFunction · 0.50

Tested by

no test coverage detected