diff options
| author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-02-03 06:24:31 +0100 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-02-03 06:24:31 +0100 |
| commit | 6a55790197d8eed5b7e020a7b964ae260d0d205b (patch) | |
| tree | b416de84487c8bf1ceda846412c9bb29cf80c1fc | |
| parent | c3028fb924d4d112293a885733da60e2e9a730f4 (diff) | |
| download | plan9front-6a55790197d8eed5b7e020a7b964ae260d0d205b.tar.xz | |
pc/pc64: move common code to pc/devarch.c
| -rw-r--r-- | sys/src/9/pc/devarch.c | 59 | ||||
| -rw-r--r-- | sys/src/9/pc/main.c | 106 | ||||
| -rw-r--r-- | sys/src/9/pc64/main.c | 46 |
3 files changed, 59 insertions, 152 deletions
diff --git a/sys/src/9/pc/devarch.c b/sys/src/9/pc/devarch.c index 71824f631..4c1ecb691 100644 --- a/sys/src/9/pc/devarch.c +++ b/sys/src/9/pc/devarch.c @@ -1133,3 +1133,62 @@ timerset(Tval x) if(doi8253set) (*arch->timerset)(x); } + +/* + * put the processor in the halt state if we've no processes to run. + * an interrupt will get us going again. + * + * halting in an smp system can result in a startup latency for + * processes that become ready. + * if idle_spin is zero, we care more about saving energy + * than reducing this latency. + * + * the performance loss with idle_spin == 0 seems to be slight + * and it reduces lock contention (thus system time and real time) + * on many-core systems with large values of NPROC. + */ +void +idlehands(void) +{ + extern int nrdy, idle_spin; + + if(conf.nmach == 1) + halt(); + else if(m->cpuidcx & Monitor) + mwait(&nrdy); + else if(idle_spin == 0) + halt(); +} + +int +isaconfig(char *class, int ctlrno, ISAConf *isa) +{ + char cc[32], *p; + int i; + + snprint(cc, sizeof cc, "%s%d", class, ctlrno); + p = getconf(cc); + if(p == nil) + return 0; + + isa->type = ""; + isa->nopt = tokenize(p, isa->opt, NISAOPT); + for(i = 0; i < isa->nopt; i++){ + p = isa->opt[i]; + if(cistrncmp(p, "type=", 5) == 0) + isa->type = p + 5; + else if(cistrncmp(p, "port=", 5) == 0) + isa->port = strtoul(p+5, &p, 0); + else if(cistrncmp(p, "irq=", 4) == 0) + isa->irq = strtoul(p+4, &p, 0); + else if(cistrncmp(p, "dma=", 4) == 0) + isa->dma = strtoul(p+4, &p, 0); + else if(cistrncmp(p, "mem=", 4) == 0) + isa->mem = strtoul(p+4, &p, 0); + else if(cistrncmp(p, "size=", 5) == 0) + isa->size = strtoul(p+5, &p, 0); + else if(cistrncmp(p, "freq=", 5) == 0) + isa->freq = strtoul(p+5, &p, 0); + } + return 1; +} diff --git a/sys/src/9/pc/main.c b/sys/src/9/pc/main.c index bc12d5608..d9fa45648 100644 --- a/sys/src/9/pc/main.c +++ b/sys/src/9/pc/main.c @@ -1000,109 +1000,3 @@ exit(int ispanic) shutdown(ispanic); arch->reset(); } - -int -isaconfig(char *class, int ctlrno, ISAConf *isa) -{ - char cc[32], *p; - int i; - - snprint(cc, sizeof cc, "%s%d", class, ctlrno); - p = getconf(cc); - if(p == nil) - return 0; - - isa->type = ""; - isa->nopt = tokenize(p, isa->opt, NISAOPT); - for(i = 0; i < isa->nopt; i++){ - p = isa->opt[i]; - if(cistrncmp(p, "type=", 5) == 0) - isa->type = p + 5; - else if(cistrncmp(p, "port=", 5) == 0) - isa->port = strtoul(p+5, &p, 0); - else if(cistrncmp(p, "irq=", 4) == 0) - isa->irq = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "dma=", 4) == 0) - isa->dma = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "mem=", 4) == 0) - isa->mem = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "size=", 5) == 0) - isa->size = strtoul(p+5, &p, 0); - else if(cistrncmp(p, "freq=", 5) == 0) - isa->freq = strtoul(p+5, &p, 0); - } - return 1; -} - -int -cistrcmp(char *a, char *b) -{ - int ac, bc; - - for(;;){ - ac = *a++; - bc = *b++; - - if(ac >= 'A' && ac <= 'Z') - ac = 'a' + (ac - 'A'); - if(bc >= 'A' && bc <= 'Z') - bc = 'a' + (bc - 'A'); - ac -= bc; - if(ac) - return ac; - if(bc == 0) - break; - } - return 0; -} - -int -cistrncmp(char *a, char *b, int n) -{ - unsigned ac, bc; - - while(n > 0){ - ac = *a++; - bc = *b++; - n--; - - if(ac >= 'A' && ac <= 'Z') - ac = 'a' + (ac - 'A'); - if(bc >= 'A' && bc <= 'Z') - bc = 'a' + (bc - 'A'); - - ac -= bc; - if(ac) - return ac; - if(bc == 0) - break; - } - - return 0; -} - -/* - * put the processor in the halt state if we've no processes to run. - * an interrupt will get us going again. - * - * halting in an smp system can result in a startup latency for - * processes that become ready. - * if idle_spin is zero, we care more about saving energy - * than reducing this latency. - * - * the performance loss with idle_spin == 0 seems to be slight - * and it reduces lock contention (thus system time and real time) - * on many-core systems with large values of NPROC. - */ -void -idlehands(void) -{ - extern int nrdy; - - if(conf.nmach == 1) - halt(); - else if(m->cpuidcx & Monitor) - mwait(&nrdy); - else if(idle_spin == 0) - halt(); -} diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c index 8ad503288..596aa0c48 100644 --- a/sys/src/9/pc64/main.c +++ b/sys/src/9/pc64/main.c @@ -479,19 +479,6 @@ reboot(void*, void*, ulong) exit(0); } -void -idlehands(void) -{ - extern int nrdy; - - if(conf.nmach == 1) - halt(); - else if(m->cpuidcx & Monitor) - mwait(&nrdy); - else if(idle_spin == 0) - halt(); -} - /* * SIMD Floating Point. * Assembler support to get at the individual instructions @@ -760,36 +747,3 @@ procsave(Proc *p) */ mmuflushtlb(); } - -int -isaconfig(char *class, int ctlrno, ISAConf *isa) -{ - char cc[32], *p; - int i; - - snprint(cc, sizeof cc, "%s%d", class, ctlrno); - p = getconf(cc); - if(p == nil) - return 0; - - isa->type = ""; - isa->nopt = tokenize(p, isa->opt, NISAOPT); - for(i = 0; i < isa->nopt; i++){ - p = isa->opt[i]; - if(cistrncmp(p, "type=", 5) == 0) - isa->type = p + 5; - else if(cistrncmp(p, "port=", 5) == 0) - isa->port = strtoul(p+5, &p, 0); - else if(cistrncmp(p, "irq=", 4) == 0) - isa->irq = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "dma=", 4) == 0) - isa->dma = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "mem=", 4) == 0) - isa->mem = strtoul(p+4, &p, 0); - else if(cistrncmp(p, "size=", 5) == 0) - isa->size = strtoul(p+5, &p, 0); - else if(cistrncmp(p, "freq=", 5) == 0) - isa->freq = strtoul(p+5, &p, 0); - } - return 1; -} |
