int tss_alloc(struct pcb *pcb) { int slot; struct sys_segment_descriptor *gdt; gdt = (struct sys_segment_descriptor *)&gdtstore[DYNSEL_START]; slot = gdt_get_slot(); #if 0 printf("tss_alloc: slot %d addr %p\n", slot, &gdt[slot]); #endif set_sys_gdt(&gdt[slot], &pcb->pcb_tss, sizeof (struct x86_64_tss)-1, SDT_SYS386TSS, SEL_KPL, 0); #if 0 printf("lolimit %lx lobase %lx type %lx dpl %lx p %lx hilimit %lx\n" "xx1 %lx gran %lx hibase %lx xx2 %lx zero %lx xx3 %lx pad %lx\n", (unsigned long)gdt[slot].sd_lolimit, (unsigned long)gdt[slot].sd_lobase, (unsigned long)gdt[slot].sd_type, (unsigned long)gdt[slot].sd_dpl, (unsigned long)gdt[slot].sd_p, (unsigned long)gdt[slot].sd_hilimit, (unsigned long)gdt[slot].sd_xx1, (unsigned long)gdt[slot].sd_gran, (unsigned long)gdt[slot].sd_hibase, (unsigned long)gdt[slot].sd_xx2, (unsigned long)gdt[slot].sd_zero, (unsigned long)gdt[slot].sd_xx3); #endif return GDYNSEL(slot, SEL_KPL); }
/* * Caller must have pmap locked for both of these functions. */ void ldt_alloc(struct pmap *pmap, union descriptor *ldt, size_t len) { int slot; slot = gdt_get_slot(); setgdt(slot, ldt, len - 1, SDT_SYSLDT, SEL_KPL, 0, 0); pmap->pm_ldt_sel = GSEL(slot, SEL_KPL); }
int tss_alloc(const struct i386tss *tss) { int slot; slot = gdt_get_slot(); setgdt(slot, tss, sizeof(struct i386tss) + IOMAPSIZE - 1, SDT_SYS386TSS, SEL_KPL, 0, 0); return GSEL(slot, SEL_KPL); }
int tss_alloc(struct pcb *pcb) { int slot; slot = gdt_get_slot(); setgdt(slot, &pcb->pcb_tss, sizeof(struct pcb) - 1, SDT_SYS386TSS, SEL_KPL, 0, 0); return GSEL(slot, SEL_KPL); }
void ldt_alloc(struct pmap *pmap, char *ldt, size_t len) { int slot; struct sys_segment_descriptor *gdt; gdt = (struct sys_segment_descriptor *)&gdtstore[DYNSEL_START]; slot = gdt_get_slot(); set_sys_gdt(&gdt[slot], ldt, len - 1, SDT_SYSLDT, SEL_KPL, 0); pmap->pm_ldt_sel = GSEL(slot, SEL_KPL); }
/* * Caller must have pmap locked for both of these functions. */ int ldt_alloc(union descriptor *ldtp, size_t len) { int slot; #ifndef XEN slot = gdt_get_slot(); setgdt(slot, ldtp, len - 1, SDT_SYSLDT, SEL_KPL, 0, 0); #else slot = gdt_get_slot1(1); cpu_info_primary.ci_gdt[slot].ld.ld_base = (uint32_t)ldtp; cpu_info_primary.ci_gdt[slot].ld.ld_entries = len / sizeof(union descriptor); #endif return GSEL(slot, SEL_KPL); }