long *param, long min, long max) );
_PROTOTYPE( void env_panic, (char *env) );
_PROTOTYPE( int env_prefix, (char *env, char *prefix) );
+_PROTOTYPE( int env_memory_parse, (struct memory *chunks, int nchunks) );
+
}
-printf("pci_set_acl: before cpf_grant_direct\n");
gid= cpf_grant_direct(pci_procnr, (vir_bytes)rs_pci, sizeof(*rs_pci),
CPF_READ);
-printf("pci_set_acl: after cpf_grant_direct: gid %d\n", gid);
if (gid == -1)
{
printf("pci_set_acl: cpf_grant_direct failed: %d\n",
m.m_type= BUSC_PCI_ACL;
m.m1_i1= gid;
-printf("pci_set_acl: before sendrec to %d\n", pci_procnr);
r= sendrec(pci_procnr, &m);
-printf("pci_set_acl: after sendrec to %d\n", pci_procnr);
cpf_revoke(gid);
-printf("pci_set_acl: after cpf_revoke\n");
if (r != 0)
panic("pci", "pci_set_acl: can't talk to PCI", r);
#include "sysutil.h"
#include <stdlib.h>
+#include <env.h>
#include <string.h>
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;
+}