- /*
- * Per-cpu GDT, IDT, LDT, KTSS descriptors are allocated in one
- * block (cpu_desc_table) and double-mapped into high shared space
- * in one page window.
- * Also, a transient stack for the fast sysenter path. The top of
- * which is set at context switch time to point to the PCB using
- * the high address.
- */
- cdi->cdi_gdt.ptr = (struct fake_descriptor *) (cpu_hi_desc +
- offsetof(cpu_desc_table_t, gdt[0]));
- cdi->cdi_idt.ptr = (struct fake_descriptor *) (cpu_hi_desc +
- offsetof(cpu_desc_table_t, idt[0]));
- cdi->cdi_ktss = (struct i386_tss *) (cpu_hi_desc +
- offsetof(cpu_desc_table_t, ktss));
- cdi->cdi_sstk = cpu_hi_desc + offsetof(cpu_desc_table_t, sstk.top);
-
- /*
- * LDT descriptors are mapped into a seperate area.
- */
- cdi->cdi_ldt = (struct fake_descriptor *)
- pmap_cpu_high_shared_remap(
- cdp->cpu_number,
- HIGH_CPU_LDT_BEGIN,
- (vm_offset_t) cdp->cpu_ldtp,
- HIGH_CPU_LDT_END - HIGH_CPU_LDT_BEGIN + 1);
-
- /*
- * Copy the tables
- */
- bcopy((char *)master_idt, (char *)cdt->idt, sizeof(master_idt));
- bcopy((char *)master_gdt, (char *)cdt->gdt, sizeof(master_gdt));
- bcopy((char *)master_ldt, (char *)cdp->cpu_ldtp, sizeof(master_ldt));
- bzero((char *)&cdt->ktss, sizeof(struct i386_tss));
-
- /*
- * Fix up the entries in the GDT to point to
- * this LDT and this TSS.
- */
- struct fake_descriptor temp_ldt = ldt_desc_pattern;
- temp_ldt.offset = (vm_offset_t)cdi->cdi_ldt;
- fix_desc(&temp_ldt, 1);
-
- cdt->gdt[sel_idx(KERNEL_LDT)] = temp_ldt;
- cdt->gdt[sel_idx(USER_LDT)] = temp_ldt;
-
- cdt->gdt[sel_idx(KERNEL_TSS)] = tss_desc_pattern;
- cdt->gdt[sel_idx(KERNEL_TSS)].offset = (vm_offset_t) cdi->cdi_ktss;
- fix_desc(&cdt->gdt[sel_idx(KERNEL_TSS)], 1);
-
- cdt->gdt[sel_idx(CPU_DATA_GS)] = cpudata_desc_pattern;
- cdt->gdt[sel_idx(CPU_DATA_GS)].offset = (vm_offset_t) cdp;
- fix_desc(&cdt->gdt[sel_idx(CPU_DATA_GS)], 1);
-
- cdt->ktss.ss0 = KERNEL_DS;
- cdt->ktss.io_bit_map_offset = 0x0FFF; /* no IO bitmap */
-
- cpu_userwindow_init(cdp->cpu_number);
- cpu_physwindow_init(cdp->cpu_number);
-
- }