fix TLS again;
still not quite but a lot better.
This commit is contained in:
parent
57ae146362
commit
f8ab2079cd
2 changed files with 7 additions and 3 deletions
5
proc.c
5
proc.c
|
@ -70,12 +70,13 @@ ksegment(void)
|
||||||
c = &cpus[cpunum()];
|
c = &cpus[cpunum()];
|
||||||
c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0x100000 + 64*1024-1, 0);
|
c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0x100000 + 64*1024-1, 0);
|
||||||
c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
|
c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0);
|
||||||
c->gdt[SEG_KCPU] = SEG(STA_W, (uint)(&c->tls+1), 0xffffffff, 0);
|
c->gdt[SEG_KCPU] = SEG(STA_W, &c->tlsstruct, 0xffffffff, 0);
|
||||||
lgdt(c->gdt, sizeof(c->gdt));
|
lgdt(c->gdt, sizeof(c->gdt));
|
||||||
loadfsgs(SEG_KCPU << 3);
|
loadfsgs(SEG_KCPU << 3);
|
||||||
|
|
||||||
// Initialize cpu-local variables.
|
// Initialize cpu-local storage.
|
||||||
c->tlsstruct = &c->tlsstruct;
|
c->tlsstruct = &c->tlsstruct;
|
||||||
|
asm volatile(""); // Do not let gcc reorder across this line.
|
||||||
cpu = c;
|
cpu = c;
|
||||||
proc = 0;
|
proc = 0;
|
||||||
}
|
}
|
||||||
|
|
5
proc.h
5
proc.h
|
@ -58,7 +58,10 @@ struct cpu {
|
||||||
volatile uint booted; // Has the CPU started?
|
volatile uint booted; // Has the CPU started?
|
||||||
int ncli; // Depth of pushcli nesting.
|
int ncli; // Depth of pushcli nesting.
|
||||||
int intena; // Were interrupts enabled before pushcli?
|
int intena; // Were interrupts enabled before pushcli?
|
||||||
void *tls[2];
|
|
||||||
|
// "Thread"-local storage variables
|
||||||
|
struct cpu *cpu;
|
||||||
|
struct proc *proc;
|
||||||
void *tlsstruct;
|
void *tlsstruct;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue