From: Ben Gras Date: Fri, 16 Feb 2007 15:55:20 +0000 (+0000) Subject: . use library function to parse memory string X-Git-Tag: v3.1.3~74 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=448376ee7e350c4385cc708b017152ccc53219fe;p=minix.git . use library function to parse memory string . remove unused variables and some other gcc warnings --- diff --git a/servers/pm/main.c b/servers/pm/main.c index 76e58ce5f..aba8fe67a 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -23,12 +24,12 @@ #include #include #include +#include #include "mproc.h" #include "param.h" #include "../../kernel/const.h" #include "../../kernel/config.h" -#include "../../kernel/type.h" #include "../../kernel/proc.h" #if ENABLE_SYSCALL_STATS @@ -233,7 +234,6 @@ PRIVATE void pm_init() static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT }; static char mess_sigs[] = { SIGTERM, SIGHUP, SIGABRT, SIGQUIT }; register struct mproc *rmp; - register int i; register char *sig_ptr; phys_clicks total_clicks, minix_clicks, free_clicks; message mess; @@ -379,16 +379,6 @@ int queue; /* store mem chunks here */ return nice_val; } -#if _WORD_SIZE == 2 -/* In real mode only 1M can be addressed, and in 16-bit protected we can go - * no further than we can count in clicks. (The 286 is further limited by - * its 24 bit address bus, but we can assume in that case that no more than - * 16M memory is reported by the BIOS.) - */ -#define MAX_REAL 0x00100000L -#define MAX_16BIT (0xFFF0L << CLICK_SHIFT) -#endif - /*===========================================================================* * get_mem_chunks * *===========================================================================*/ @@ -396,59 +386,30 @@ PRIVATE void get_mem_chunks(mem_chunks) struct memory *mem_chunks; /* store mem chunks here */ { /* Initialize the free memory list from the 'memory' boot variable. Translate - * the byte offsets and sizes in this list to clicks, properly truncated. Also - * make sure that we don't exceed the maximum address space of the 286 or the - * 8086, i.e. when running in 16-bit protected mode or real mode. + * the byte offsets and sizes in this list to clicks, properly truncated. */ long base, size, limit; - char *s, *end; /* use to parse boot variable */ - int i, done = 0; + int i; struct memory *memp; -#if _WORD_SIZE == 2 - unsigned long max_address; - struct machine machine; - if (OK != (i=sys_getmachine(&machine))) - panic(__FILE__, "sys_getmachine failed", i); -#endif + + /* Obtain and parse memory from system environment. */ + if(env_memory_parse(mem_chunks, NR_MEMS) != OK) + panic(__FILE__,"couldn't obtain memory chunks", NO_NUM); - /* Initialize everything to zero. */ + /* Round physical memory to clicks. */ for (i = 0; i < NR_MEMS; 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. - */ - s = find_param("memory"); /* get memory boot variable */ - for (i = 0; i < NR_MEMS && !done; i++) { - memp = &mem_chunks[i]; /* next mem chunk is stored here */ - base = size = 0; /* initialize next base:size pair */ - 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; - } + base = mem_chunks[i].base; + size = mem_chunks[i].size; limit = base + size; -#if _WORD_SIZE == 2 - max_address = machine.protected ? MAX_16BIT : MAX_REAL; - if (limit > max_address) limit = max_address; -#endif base = (base + CLICK_SIZE-1) & ~(long)(CLICK_SIZE-1); limit &= ~(long)(CLICK_SIZE-1); - if (limit <= base) continue; - memp->base = base >> CLICK_SHIFT; - memp->size = (limit - base) >> CLICK_SHIFT; + if (limit <= base) { + memp->base = memp->size = 0; + } else { + memp->base = base >> CLICK_SHIFT; + memp->size = (limit - base) >> CLICK_SHIFT; + } } } @@ -611,7 +572,7 @@ PRIVATE void send_work() case PM_FORK: { - int parent_e, parent_p; + int parent_p; struct mproc *parent_mp; parent_p = rmp->mp_parent; @@ -682,7 +643,7 @@ PRIVATE void send_work() case PM_FORK_NB: { - int parent_e, parent_p; + int parent_p; struct mproc *parent_mp; parent_p = rmp->mp_parent; diff --git a/servers/pm/misc.c b/servers/pm/misc.c index 998d87113..9aa6bdb2e 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -147,8 +147,8 @@ PUBLIC int do_sysuname() /* Set or get uname strings. */ int r; - size_t n, len; - char *string, *t; + size_t n; + char *string; #if 0 /* for updates */ char tmp[sizeof(uts_val.nodename)]; static short sizes[] = { @@ -287,7 +287,7 @@ PUBLIC int do_getsysinfo_up() vir_bytes src_addr, dst_addr; struct loadinfo loadinfo; size_t len, real_len; - int s, r; + int s; switch(m_in.SIU_WHAT) { case SIU_LOADINFO: /* loadinfo is obtained via PM */ diff --git a/servers/pm/profile.c b/servers/pm/profile.c index 471bf7692..585303991 100644 --- a/servers/pm/profile.c +++ b/servers/pm/profile.c @@ -34,7 +34,7 @@ PUBLIC int do_sprofile(void) switch(m_in.PROF_ACTION) { case PROF_START: - if (r = check_addrs(sizeof(sprof_info_inst))) /* check user pointers */ + if ((r = check_addrs(sizeof(sprof_info_inst)))) /* check pointers */ return r; return sys_sprof(PROF_START, m_in.PROF_MEM_SIZE, m_in.PROF_FREQ, diff --git a/servers/pm/signal.c b/servers/pm/signal.c index 63c3d9d18..26d1bcef5 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -359,7 +359,7 @@ int sec; /* how many seconds delay before the signal */ PRIVATE void cause_sigalrm(tp) struct timer *tp; { - int proc_nr_e, proc_nr_n; + int proc_nr_n; register struct mproc *rmp; /* get process from timer */ @@ -765,7 +765,7 @@ register struct mproc *rmp; /* whose core is to be dumped */ else { printf("PM: FS died\n"); - return; + return SUSPEND; } /* Pending reply messages for the dead process cannot be delivered. */ diff --git a/servers/pm/utility.c b/servers/pm/utility.c index 0aaf59b86..23adbdcfe 100644 --- a/servers/pm/utility.c +++ b/servers/pm/utility.c @@ -76,10 +76,6 @@ int num; /* number to go with it */ * inconsistency is detected, e.g., a programming error or illegal value of a * defined constant. The process manager decides to exit. */ - message m; - int s; - - /* Switch to primary console and print panic message. */ printf("PM panic (%s): %s", who, mess); if (num != NO_NUM) printf(": %d",num); printf("\n");