Env_memory_parse: move into VM
Only possible user of that function. While here, fix bug about NR_MEMS vs MAXMEMMAP NR_MEMS=16 is currently less than MAXMEMMAP=40; avoid overriding
This commit is contained in:
parent
cfc36e5fd3
commit
521de2a716
3 changed files with 13 additions and 33 deletions
|
@ -2,5 +2,3 @@ int env_parse(char *env, char *fmt, int field, long *param, long min,
|
||||||
long max);
|
long max);
|
||||||
void env_panic(char *env);
|
void env_panic(char *env);
|
||||||
int env_prefix(char *env, char *prefix);
|
int env_prefix(char *env, char *prefix);
|
||||||
int env_memory_parse(struct memory *chunks, int nchunks);
|
|
||||||
|
|
||||||
|
|
|
@ -89,27 +89,3 @@ badenv:
|
||||||
env_panic(env);
|
env_panic(env);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=========================================================================*
|
|
||||||
* env_memory_parse *
|
|
||||||
*=========================================================================*/
|
|
||||||
|
|
||||||
int env_memory_parse(mem_chunks, maxchunks)
|
|
||||||
struct memory *mem_chunks; /* where to store the memory bits */
|
|
||||||
int maxchunks; /* how many were found */
|
|
||||||
{
|
|
||||||
static kinfo_t kinfo;
|
|
||||||
int mm, r;
|
|
||||||
|
|
||||||
if((r=sys_getkinfo(&kinfo)) != OK) return r;
|
|
||||||
|
|
||||||
/* Initialize everything to zero. */
|
|
||||||
memset(mem_chunks, 0, maxchunks*sizeof(*mem_chunks));
|
|
||||||
|
|
||||||
for(mm = 0; mm < MAXMEMMAP; mm++) {
|
|
||||||
mem_chunks[mm].base = kinfo.memmap[mm].addr;
|
|
||||||
mem_chunks[mm].size = kinfo.memmap[mm].len;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,20 +40,26 @@
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_mem_chunks *
|
* get_mem_chunks *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
void get_mem_chunks(mem_chunks)
|
void get_mem_chunks(
|
||||||
struct memory *mem_chunks; /* store mem chunks here */
|
struct memory *mem_chunks) /* store mem chunks here */
|
||||||
{
|
{
|
||||||
/* Initialize the free memory list from the 'memory' boot variable. Translate
|
/* Initialize the free memory list from the kernel-provided memory map. Translate
|
||||||
* the byte offsets and sizes in this list to clicks, properly truncated.
|
* the byte offsets and sizes in this list to clicks, properly truncated.
|
||||||
*/
|
*/
|
||||||
phys_bytes base, size, limit;
|
phys_bytes base, size, limit;
|
||||||
int i;
|
int i;
|
||||||
struct memory *memp;
|
struct memory *memp;
|
||||||
|
|
||||||
/* Obtain and parse memory from system environment. */
|
/* Initialize everything to zero. */
|
||||||
if(env_memory_parse(mem_chunks, NR_MEMS) != OK)
|
memset(mem_chunks, 0, NR_MEMS*sizeof(*mem_chunks));
|
||||||
panic("couldn't obtain memory chunks");
|
|
||||||
|
/* Obtain and parse memory from kernel environment. */
|
||||||
|
/* XXX Any memory chunk in excess of NR_MEMS is silently ignored. */
|
||||||
|
for(i = 0; i < MIN(MAXMEMMAP, NR_MEMS); i++) {
|
||||||
|
mem_chunks[i].base = kernel_boot_info.memmap[i].addr;
|
||||||
|
mem_chunks[i].size = kernel_boot_info.memmap[i].len;
|
||||||
|
}
|
||||||
|
|
||||||
/* Round physical memory to clicks. Round start up, round end down. */
|
/* Round physical memory to clicks. Round start up, round end down. */
|
||||||
for (i = 0; i < NR_MEMS; i++) {
|
for (i = 0; i < NR_MEMS; i++) {
|
||||||
memp = &mem_chunks[i]; /* next mem chunk is stored here */
|
memp = &mem_chunks[i]; /* next mem chunk is stored here */
|
||||||
|
|
Loading…
Reference in a new issue