. made memory parsing function into a library call
(moved 'struct memory' to <minix/type.h> for this library call) . removed some debugging messages from pci library
This commit is contained in:
parent
a47531cc97
commit
3275602598
5 changed files with 58 additions and 10 deletions
|
@ -2,3 +2,5 @@ _PROTOTYPE( int env_parse, (char *env, char *fmt, int field,
|
||||||
long *param, long min, long max) );
|
long *param, long min, long max) );
|
||||||
_PROTOTYPE( void env_panic, (char *env) );
|
_PROTOTYPE( void env_panic, (char *env) );
|
||||||
_PROTOTYPE( int env_prefix, (char *env, char *prefix) );
|
_PROTOTYPE( int env_prefix, (char *env, char *prefix) );
|
||||||
|
_PROTOTYPE( int env_memory_parse, (struct memory *chunks, int nchunks) );
|
||||||
|
|
||||||
|
|
|
@ -170,4 +170,10 @@ struct exec_newmem
|
||||||
char progname[16]; /* Should be at least PROC_NAME_LEN */
|
char progname[16]; /* Should be at least PROC_NAME_LEN */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Memory chunks. */
|
||||||
|
struct memory {
|
||||||
|
phys_bytes base;
|
||||||
|
phys_bytes size;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _TYPE_H */
|
#endif /* _TYPE_H */
|
||||||
|
|
|
@ -27,11 +27,6 @@ struct boot_image {
|
||||||
endpoint_t endpoint; /* endpoint number when started */
|
endpoint_t endpoint; /* endpoint number when started */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct memory {
|
|
||||||
phys_clicks base; /* start address of chunk */
|
|
||||||
phys_clicks size; /* size of memory chunk */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* The kernel outputs diagnostic messages in a circular buffer. */
|
/* The kernel outputs diagnostic messages in a circular buffer. */
|
||||||
struct kmessages {
|
struct kmessages {
|
||||||
int km_next; /* next index to write */
|
int km_next; /* next index to write */
|
||||||
|
|
|
@ -30,10 +30,8 @@ struct rs_pci *rs_pci;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("pci_set_acl: before cpf_grant_direct\n");
|
|
||||||
gid= cpf_grant_direct(pci_procnr, (vir_bytes)rs_pci, sizeof(*rs_pci),
|
gid= cpf_grant_direct(pci_procnr, (vir_bytes)rs_pci, sizeof(*rs_pci),
|
||||||
CPF_READ);
|
CPF_READ);
|
||||||
printf("pci_set_acl: after cpf_grant_direct: gid %d\n", gid);
|
|
||||||
if (gid == -1)
|
if (gid == -1)
|
||||||
{
|
{
|
||||||
printf("pci_set_acl: cpf_grant_direct failed: %d\n",
|
printf("pci_set_acl: cpf_grant_direct failed: %d\n",
|
||||||
|
@ -44,11 +42,8 @@ printf("pci_set_acl: after cpf_grant_direct: gid %d\n", gid);
|
||||||
m.m_type= BUSC_PCI_ACL;
|
m.m_type= BUSC_PCI_ACL;
|
||||||
m.m1_i1= gid;
|
m.m1_i1= gid;
|
||||||
|
|
||||||
printf("pci_set_acl: before sendrec to %d\n", pci_procnr);
|
|
||||||
r= sendrec(pci_procnr, &m);
|
r= sendrec(pci_procnr, &m);
|
||||||
printf("pci_set_acl: after sendrec to %d\n", pci_procnr);
|
|
||||||
cpf_revoke(gid);
|
cpf_revoke(gid);
|
||||||
printf("pci_set_acl: after cpf_revoke\n");
|
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
panic("pci", "pci_set_acl: can't talk to PCI", r);
|
panic("pci", "pci_set_acl: can't talk to PCI", r);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "sysutil.h"
|
#include "sysutil.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <env.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,4 +89,53 @@ badenv:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*=========================================================================*
|
||||||
|
* env_memory_parse *
|
||||||
|
*=========================================================================*/
|
||||||
|
|
||||||
|
PUBLIC int env_memory_parse(mem_chunks, maxchunks)
|
||||||
|
struct memory *mem_chunks; /* where to store the memory bits */
|
||||||
|
int maxchunks; /* how many were found */
|
||||||
|
{
|
||||||
|
int i, done = 0;
|
||||||
|
char *s;
|
||||||
|
struct memory *memp;
|
||||||
|
char memstr[100], *end;
|
||||||
|
|
||||||
|
/* Initialize everything to zero. */
|
||||||
|
for (i = 0; i < maxchunks; i++) {
|
||||||
|
memp = &mem_chunks[i]; /* next mem chunk is stored here */
|
||||||
|
memp->base = memp->size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The available memory is determined by MINIX' boot loader as a list of
|
||||||
|
* (base:size)-pairs in boothead.s. The 'memory' boot variable is set in
|
||||||
|
* in boot.s. The format is "b0:s0,b1:s1,b2:s2", where b0:s0 is low mem,
|
||||||
|
* b1:s1 is mem between 1M and 16M, b2:s2 is mem above 16M. Pairs b1:s1
|
||||||
|
* and b2:s2 are combined if the memory is adjacent.
|
||||||
|
*/
|
||||||
|
if(env_get_param("memory", memstr, sizeof(memstr)-1) != OK)
|
||||||
|
return -1;
|
||||||
|
s = memstr;
|
||||||
|
for (i = 0; i < maxchunks && !done; i++) {
|
||||||
|
phys_bytes base = 0, size = 0, limit;
|
||||||
|
memp = &mem_chunks[i]; /* next mem chunk is stored here */
|
||||||
|
if (*s != 0) { /* get fresh data, unless at end */
|
||||||
|
|
||||||
|
/* Read fresh base and expect colon as next char. */
|
||||||
|
base = strtoul(s, &end, 0x10); /* get number */
|
||||||
|
if (end != s && *end == ':') s = ++end; /* skip ':' */
|
||||||
|
else *s=0; /* terminate, should not happen */
|
||||||
|
|
||||||
|
/* Read fresh size and expect comma or assume end. */
|
||||||
|
size = strtoul(s, &end, 0x10); /* get number */
|
||||||
|
if (end != s && *end == ',') s = ++end; /* skip ',' */
|
||||||
|
else done = 1;
|
||||||
|
}
|
||||||
|
if (base + size <= base) continue;
|
||||||
|
memp->base = base;
|
||||||
|
memp->size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue