kernel: change active.machs from bitmap to char array to support up to 64 cpus on pc64
This commit is contained in:
parent
dd8908cff0
commit
41383ad012
|
@ -184,8 +184,8 @@ struct Mach
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
short machs;
|
||||
short exiting;
|
||||
char machs[MAXMACH];
|
||||
int exiting;
|
||||
}active;
|
||||
|
||||
/*
|
||||
|
|
|
@ -156,7 +156,7 @@ machinit(void)
|
|||
m->machno = n;
|
||||
|
||||
active.exiting = 0;
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
|
||||
cpu = (Hwcpu*) ((ulong)hwrpb + hwrpb->cpuoff + n*hwrpb->cpulen);
|
||||
cpu->state &= ~Cpubootinprog;
|
||||
|
|
|
@ -261,8 +261,8 @@ intr(Ureg *ur)
|
|||
*/
|
||||
iprint("cpu%d: spurious interrupt %d, last %d",
|
||||
m->machno, vno-VectorPIC, m->lastintr);
|
||||
for(i = 0; i < 32; i++){
|
||||
if(!(active.machs & (1<<i)))
|
||||
for(i = 0; i < MAXMACH; i++){
|
||||
if(active.machs[i] == 0)
|
||||
continue;
|
||||
mach = MACHP(i);
|
||||
if(m->machno == mach->machno)
|
||||
|
|
|
@ -223,7 +223,7 @@ typedef void KMap;
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
}active;
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ machinit(void)
|
|||
|
||||
conf.nmach = 1;
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
|
||||
up = nil;
|
||||
|
|
|
@ -178,7 +178,7 @@ typedef void KMap;
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
}active;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ main(void)
|
|||
memset(m, 0, sizeof(Mach));
|
||||
m->ticks = 1;
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
|
||||
rs232power(1);
|
||||
quotefmtinstall();
|
||||
|
|
|
@ -194,7 +194,7 @@ typedef void KMap;
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
}active;
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ machinit(void)
|
|||
|
||||
conf.nmach = 1;
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
|
||||
up = nil;
|
||||
|
|
|
@ -181,8 +181,8 @@ struct Mach
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
short machs;
|
||||
short exiting;
|
||||
char machs[MAXMACH];
|
||||
int exiting;
|
||||
}active;
|
||||
|
||||
/*
|
||||
|
|
|
@ -59,7 +59,7 @@ machinit(void)
|
|||
/* turn on caches */
|
||||
puthid0(gethid0() | BIT(16) | BIT(17));
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ typedef void KMap;
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
}active;
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ machinit(void)
|
|||
|
||||
conf.nmach = 1;
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
|
||||
up = nil;
|
||||
|
|
|
@ -270,7 +270,7 @@ void kunmap(KMap*);
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
int thunderbirdsarego; /* lets the added processors continue to schedinit */
|
||||
}active;
|
||||
|
|
|
@ -181,7 +181,7 @@ mach0init(void)
|
|||
|
||||
machinit();
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -685,7 +685,7 @@ vunmap(void *v, int size)
|
|||
for(i=0; i<conf.nmach; i++){
|
||||
nm = MACHP(i);
|
||||
if(nm != m)
|
||||
while((active.machs&(1<<nm->machno)) && nm->flushmmu)
|
||||
while(active.machs[nm->machno] && nm->flushmmu)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,6 +198,8 @@ mpinit(void)
|
|||
for(i=0; i<nelem(mpapic); i++){
|
||||
if((apic = mpapic[i]) == nil)
|
||||
continue;
|
||||
if(apic->machno >= MAXMACH)
|
||||
continue;
|
||||
if(ncpu <= 1)
|
||||
break;
|
||||
if((apic->flags & (PcmpBP|PcmpEN)) == PcmpEN){
|
||||
|
@ -574,7 +576,7 @@ mpshutdown(void)
|
|||
for(;;) idle();
|
||||
}
|
||||
|
||||
print("mpshutdown: active = %#8.8ux\n", active.machs);
|
||||
print("mpshutdown\n");
|
||||
delay(1000);
|
||||
splhi();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ squidboy(Apic* apic)
|
|||
fpoff();
|
||||
|
||||
lock(&active);
|
||||
active.machs |= 1<<m->machno;
|
||||
active.machs[m->machno] = 1;
|
||||
unlock(&active);
|
||||
|
||||
while(!active.thunderbirdsarego)
|
||||
|
|
|
@ -400,8 +400,8 @@ trap(Ureg* ureg)
|
|||
if(0)print("cpu%d: spurious interrupt %d, last %d\n",
|
||||
m->machno, vno, m->lastintr);
|
||||
if(0)if(conf.nmach > 1){
|
||||
for(i = 0; i < 32; i++){
|
||||
if(!(active.machs & (1<<i)))
|
||||
for(i = 0; i < MAXMACH; i++){
|
||||
if(active.machs[i] == 0)
|
||||
continue;
|
||||
mach = MACHP(i);
|
||||
if(m->machno == mach->machno)
|
||||
|
|
|
@ -233,7 +233,7 @@ typedef void KMap;
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* bitmap of active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
int thunderbirdsarego; /* lets the added processors continue to schedinit */
|
||||
}active;
|
||||
|
|
|
@ -326,7 +326,7 @@ mach0init(void)
|
|||
|
||||
machinit();
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define BLOCKALIGN 8
|
||||
#define FPalign 16
|
||||
|
||||
#define MAXMACH 32 /* max # cpus system can run */
|
||||
#define MAXMACH 64 /* max # cpus system can run */
|
||||
|
||||
#define KSTACK (16*KiB) /* Size of Proc kernel stack */
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ squidboy(Apic* apic)
|
|||
timersinit();
|
||||
|
||||
lock(&active);
|
||||
active.machs |= 1<<m->machno;
|
||||
active.machs[m->machno] = 1;
|
||||
unlock(&active);
|
||||
|
||||
while(!active.thunderbirdsarego)
|
||||
|
|
|
@ -394,8 +394,8 @@ trap(Ureg *ureg)
|
|||
if(0)print("cpu%d: spurious interrupt %d, last %d\n",
|
||||
m->machno, vno, m->lastintr);
|
||||
if(0)if(conf.nmach > 1){
|
||||
for(i = 0; i < 32; i++){
|
||||
if(!(active.machs & (1<<i)))
|
||||
for(i = 0; i < MAXMACH; i++){
|
||||
if(active.machs[i] == 0)
|
||||
continue;
|
||||
mach = MACHP(i);
|
||||
if(m->machno == mach->machno)
|
||||
|
|
|
@ -568,8 +568,8 @@ consread(Chan *c, void *buf, long n, vlong off)
|
|||
case Qsysstat:
|
||||
b = smalloc(conf.nmach*(NUMSIZE*11+1) + 1); /* +1 for NUL */
|
||||
bp = b;
|
||||
for(id = 0; id < 32; id++) {
|
||||
if(active.machs & (1<<id)) {
|
||||
for(id = 0; id < MAXMACH; id++) {
|
||||
if(active.machs[id]) {
|
||||
mp = MACHP(id);
|
||||
readnum(0, bp, NUMSIZE, id, NUMSIZE);
|
||||
bp += NUMSIZE;
|
||||
|
@ -767,8 +767,8 @@ conswrite(Chan *c, void *va, long n, vlong off)
|
|||
break;
|
||||
|
||||
case Qsysstat:
|
||||
for(id = 0; id < 32; id++) {
|
||||
if(active.machs & (1<<id)) {
|
||||
for(id = 0; id < MAXMACH; id++) {
|
||||
if(active.machs[id]) {
|
||||
mp = MACHP(id);
|
||||
mp->cs = 0;
|
||||
mp->intr = 0;
|
||||
|
@ -1051,8 +1051,8 @@ cpushutdown(void)
|
|||
int ms, once;
|
||||
|
||||
lock(&active);
|
||||
once = active.machs & (1<<m->machno);
|
||||
active.machs &= ~(1<<m->machno);
|
||||
once = active.machs[m->machno];
|
||||
active.machs[m->machno] = 0;
|
||||
active.exiting = 1;
|
||||
unlock(&active);
|
||||
|
||||
|
@ -1063,7 +1063,7 @@ cpushutdown(void)
|
|||
spllo();
|
||||
for(ms = 5*1000; ms > 0; ms -= TK2MS(2)){
|
||||
delay(TK2MS(2));
|
||||
if(active.machs == 0 && consactive() == 0)
|
||||
if(memchr(active.machs, 1, MAXMACH) == nil && consactive() == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ hzclock(Ureg *ur)
|
|||
if(kproftimer != nil)
|
||||
kproftimer(ur->pc);
|
||||
|
||||
if((active.machs&(1<<m->machno)) == 0)
|
||||
if(active.machs[m->machno] == 0)
|
||||
return;
|
||||
|
||||
if(active.exiting)
|
||||
|
|
|
@ -189,8 +189,8 @@ struct Mach
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
short machs;
|
||||
short exiting;
|
||||
char machs[MAXMACH];
|
||||
int exiting;
|
||||
}active;
|
||||
|
||||
/*
|
||||
|
|
|
@ -214,7 +214,7 @@ machinit(void)
|
|||
vco 198
|
||||
*/
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
|
||||
putmsr(getmsr() | MSR_ME);
|
||||
|
|
|
@ -140,7 +140,7 @@ machinit(void)
|
|||
m->cpuhz = 200000000; /* 750FX? */
|
||||
m->cyclefreq = m->bushz / 4;
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
|
||||
putmsr(getmsr() | MSR_ME);
|
||||
|
|
|
@ -204,7 +204,7 @@ struct Softtlb
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
long machs; /* bitmap of processors */
|
||||
char machs[MAXMACH]; /* active cpus */
|
||||
short exiting;
|
||||
}active;
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ main(void)
|
|||
confinit();
|
||||
machinit(); /* calls clockinit */
|
||||
active.exiting = 0;
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
print("\nPlan 9\n");
|
||||
|
||||
kmapinit();
|
||||
|
|
|
@ -676,7 +676,7 @@ cpustart(void)
|
|||
Power *pwr;
|
||||
|
||||
up = nil;
|
||||
if (active.machs & (1<<m->machno)) {
|
||||
if (active.machs[m->machno]) {
|
||||
serialputc('?');
|
||||
serialputc('r');
|
||||
panic("cpu%d: resetting after start", m->machno);
|
||||
|
|
|
@ -246,7 +246,7 @@ typedef void KMap;
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int wfi; /* bitmap of CPUs in WFI state */
|
||||
int stopped; /* bitmap of CPUs stopped */
|
||||
int exiting; /* shutdown */
|
||||
|
|
|
@ -208,13 +208,10 @@ getenv(char* name, char* buf, int n)
|
|||
void
|
||||
machon(uint cpu)
|
||||
{
|
||||
ulong cpubit;
|
||||
|
||||
cpubit = 1 << cpu;
|
||||
lock(&active);
|
||||
if ((active.machs & cpubit) == 0) { /* currently off? */
|
||||
if (active.machs[cpu] == 0) { /* currently off? */
|
||||
active.machs[cpu] = 1;
|
||||
conf.nmach++;
|
||||
active.machs |= cpubit;
|
||||
}
|
||||
unlock(&active);
|
||||
}
|
||||
|
@ -223,13 +220,10 @@ machon(uint cpu)
|
|||
void
|
||||
machoff(uint cpu)
|
||||
{
|
||||
ulong cpubit;
|
||||
|
||||
cpubit = 1 << cpu;
|
||||
lock(&active);
|
||||
if (active.machs & cpubit) { /* currently on? */
|
||||
if (active.machs[cpu]) { /* currently on? */
|
||||
active.machs[cpu] = 0;
|
||||
conf.nmach--;
|
||||
active.machs &= ~cpubit;
|
||||
}
|
||||
unlock(&active);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ mach0init(void)
|
|||
|
||||
machinit();
|
||||
|
||||
active.machs = 1;
|
||||
active.machs[0] = 1;
|
||||
active.exiting = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -393,8 +393,8 @@ trap(Ureg* ureg)
|
|||
iprint("cpu%d: spurious interrupt %d, last %d\n",
|
||||
m->machno, vno, m->lastintr);
|
||||
if(0)if(conf.nmach > 1){
|
||||
for(i = 0; i < 32; i++){
|
||||
if(!(active.machs & (1<<i)))
|
||||
for(i = 0; i < MAXMACH; i++){
|
||||
if(active.machs[i] == 0)
|
||||
continue;
|
||||
mach = MACHP(i);
|
||||
if(m->machno == mach->machno)
|
||||
|
|
|
@ -175,7 +175,7 @@ struct ISAConf
|
|||
struct
|
||||
{
|
||||
Lock;
|
||||
int machs; /* bitmap of active CPUs */
|
||||
char machs[MAXMACH]; /* active CPUs */
|
||||
int exiting; /* shutdown */
|
||||
}active;
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ mpinit(void)
|
|||
void
|
||||
main(void)
|
||||
{
|
||||
active.machs |= (1 << m->machno);
|
||||
active.machs[m->machno] = 1;
|
||||
if(m->machno != 0){
|
||||
uartputs("\n", 1);
|
||||
mmuinit();
|
||||
|
|
Loading…
Reference in a new issue