Go back to statically allocating the GDT entries for proc0.

This commit is contained in:
mycroft 1995-10-11 19:32:31 +00:00
parent c9b339fcd1
commit 2765bc7b44
5 changed files with 24 additions and 18 deletions

View File

@ -12,7 +12,7 @@
#define MAXGDTSIZ 8192
union descriptor *dynamic_gdt = gdt;
int gdt_size = NGDT + 2;
int gdt_size = NGDT;
int gdt_next = NGDT;
int gdt_count = NGDT;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.178 1995/10/11 04:19:44 mycroft Exp $ */
/* $NetBSD: machdep.c,v 1.179 1995/10/11 19:32:37 mycroft Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
@ -934,7 +934,7 @@ setregs(p, pack, stack, retval)
* Initialize segments and descriptor tables
*/
union descriptor gdt[NGDT + 2];
union descriptor gdt[NGDT];
union descriptor ldt[NLDT];
struct gate_descriptor idt[NIDT];
@ -1009,18 +1009,23 @@ init386(first_avail)
extern void lgdt();
proc0.p_addr = proc0paddr;
curpcb = pcb = &proc0.p_addr->u_pcb;
consinit(); /* XXX SHOULD NOT BE DONE HERE */
/* make gdt gates memory segments */
/* make gdt gates and memory segments */
setsegment(&gdt[GCODE_SEL].sd, 0, 0xfffff, SDT_MEMERA, SEL_KPL, 1, 1);
setsegment(&gdt[GDATA_SEL].sd, 0, 0xfffff, SDT_MEMRWA, SEL_KPL, 1, 1);
setsegment(&gdt[GPROC0TSS_SEL].sd, &pcb->pcb_tss, sizeof(struct pcb) - 1,
SDT_SYS386TSS, SEL_KPL, 0, 0);
setsegment(&gdt[GUCODE_SEL].sd, 0, i386_btop(VM_MAXUSER_ADDRESS) - 1,
SDT_MEMERA, SEL_UPL, 1, 1);
setsegment(&gdt[GUDATA_SEL].sd, 0, i386_btop(VM_MAXUSER_ADDRESS) - 1,
SDT_MEMRWA, SEL_UPL, 1, 1);
setsegment(&gdt[GPROC0LDT_SEL].sd, ldt, sizeof(ldt) - 1, SDT_SYSLDT, SEL_KPL,
0, 0);
/* make ldt gates memory segments */
/* make ldt gates and memory segments */
setgate(&ldt[LSYS5CALLS_SEL].gd, &IDTVEC(osyscall), 1, SDT_SYS386CGT,
SEL_UPL);
ldt[LUCODE_SEL] = gdt[GUCODE_SEL];
@ -1055,7 +1060,6 @@ init386(first_avail)
lidt(&region);
/* Set up proc 0's PCB and TSS. */
curpcb = pcb = &proc0.p_addr->u_pcb;
pcb->pcb_flags = 0;
pcb->pcb_tss.tss_ioopt =
((caddr_t)pcb->pcb_iomap - (caddr_t)&pcb->pcb_tss) << 16;
@ -1063,9 +1067,9 @@ init386(first_avail)
pcb->pcb_iomap[x] = 0xffffffff;
pcb->pcb_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
pcb->pcb_tss.tss_esp0 = (int)proc0.p_addr + USPACE - 16;
tss_alloc(pcb);
pcb->pcb_tss_sel = GSEL(GPROC0TSS_SEL, SEL_KPL);
ltr(pcb->pcb_tss_sel);
ldt_alloc(pcb, ldt, sizeof(ldt));
pcb->pcb_ldt_sel = GSEL(GPROC0LDT_SEL, SEL_KPL);
lldt(pcb->pcb_ldt_sel);
proc0.p_md.md_regs = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_machdep.c,v 1.23 1995/10/11 04:19:48 mycroft Exp $ */
/* $NetBSD: sys_machdep.c,v 1.24 1995/10/11 19:32:46 mycroft Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -136,7 +136,7 @@ i386_user_cleanup(pcb)
{
ldt_free(pcb);
pcb->pcb_ldt_sel = proc0.p_addr->u_pcb.pcb_ldt_sel;
pcb->pcb_ldt_sel = GSEL(GPROC0LDT_SEL, SEL_KPL);
if (pcb == curpcb)
lldt(pcb->pcb_ldt_sel);
kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ldt,

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.52 1995/10/11 04:19:53 mycroft Exp $ */
/* $NetBSD: vm_machdep.c,v 1.53 1995/10/11 19:32:49 mycroft Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -105,10 +105,11 @@ cpu_fork(p1, p2)
pmap_activate(&p2->p_vmspace->vm_pmap, pcb);
/*
* Pre-zero these so that gdt_compact() doesn't get confused if called
* during the allocations below.
* Preset these so that gdt_compact() doesn't get confused if called during
* the allocations below.
*/
pcb->pcb_tss_sel = pcb->pcb_ldt_sel = GSEL(GNULL_SEL, SEL_KPL);
pcb->pcb_tss_sel = GSEL(GNULL_SEL, SEL_KPL);
pcb->pcb_ldt_sel = GSEL(GPROC0LDT_SEL, SEL_KPL);
/* Fix up the TSS, etc. */
pcb->pcb_cr0 |= CR0_TS;
@ -127,9 +128,8 @@ cpu_fork(p1, p2)
bcopy(pcb->pcb_ldt, new_ldt, len);
pcb->pcb_ldt = new_ldt;
ldt_alloc(pcb, new_ldt, len);
} else
}
#endif
pcb->pcb_ldt_sel = proc0.p_addr->u_pcb.pcb_ldt_sel;
/*
* Copy the trapframe, and arrange for the child to return directly

View File

@ -1,4 +1,4 @@
/* $NetBSD: segments.h,v 1.18 1995/10/11 06:24:28 mycroft Exp $ */
/* $NetBSD: segments.h,v 1.19 1995/10/11 19:33:06 mycroft Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -214,9 +214,11 @@ void setsegment __P((struct segment_descriptor *, void *, size_t, int, int,
#define GNULL_SEL 0 /* Null descriptor */
#define GCODE_SEL 1 /* Kernel code descriptor */
#define GDATA_SEL 2 /* Kernel data descriptor */
#define GPROC0TSS_SEL 3 /* proc0 TSS descriptor */
#define GUCODE_SEL 4 /* User code descriptor */
#define GUDATA_SEL 5 /* User data descriptor */
#define NGDT 6
#define GPROC0LDT_SEL 6 /* proc0 LDT descriptor */
#define NGDT 7
/*
* Entries in the Local Descriptor Table (LDT)