本文整理汇总了C++中GSEL函数的典型用法代码示例。如果您正苦于以下问题:C++ GSEL函数的具体用法?C++ GSEL怎么用?C++ GSEL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GSEL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: linux_setregs
void
linux_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
{
struct trapframe *tf;
#ifdef USER_LDT
pmap_ldt_cleanup(l);
#endif
fpu_save_area_clear(l, __Linux_NPXCW__);
tf = l->l_md.md_regs;
tf->tf_gs = 0;
tf->tf_fs = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_edi = 0;
tf->tf_esi = 0;
tf->tf_ebp = 0;
tf->tf_ebx = l->l_proc->p_psstrp;
tf->tf_edx = 0;
tf->tf_ecx = 0;
tf->tf_eax = 0;
tf->tf_eip = epp->ep_entry;
tf->tf_cs = GSEL(GUCODEBIG_SEL, SEL_UPL);
tf->tf_eflags = PSL_USERSET;
tf->tf_esp = stack;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
示例2: cpu_fork
/*
* Finish a fork operation, with process p2 nearly set up.
* Copy and update the kernel stack and pcb, making the child
* ready to run, and marking it so that it can return differently
* than the parent. Returns 1 in the child process, 0 in the parent.
* We currently double-map the user area so that the stack is at the same
* address in each process; in the future we will probably relocate
* the frame pointers on the stack after copying.
*/
void
cpu_fork(struct proc *p1, struct proc *p2,
void *stack, size_t stacksize, void (*func)(void *), void *arg)
{
struct pcb *pcb = &p2->p_addr->u_pcb;
struct trapframe *tf;
struct switchframe *sf;
#if NNPX > 0
npxsave_proc(p1, 1);
#endif
p2->p_md.md_flags = p1->p_md.md_flags;
/* Copy pcb from proc p1 to p2. */
if (p1 == curproc) {
/* Sync the PCB before we copy it. */
savectx(curpcb);
}
#ifdef DIAGNOSTIC
else if (p1 != &proc0)
panic("cpu_fork: curproc");
#endif
*pcb = p1->p_addr->u_pcb;
/*
* Preset these so that gdt_compact() doesn't get confused if called
* during the allocations below.
*
* Note: pcb_ldt_sel is handled in the pmap_activate() call when
* we run the new process.
*/
p2->p_md.md_tss_sel = GSEL(GNULL_SEL, SEL_KPL);
/* Fix up the TSS. */
pcb->pcb_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
pcb->pcb_tss.tss_esp0 = (int)p2->p_addr + USPACE - 16;
p2->p_md.md_tss_sel = tss_alloc(pcb);
/*
* Copy the trapframe, and arrange for the child to return directly
* through rei().
*/
p2->p_md.md_regs = tf = (struct trapframe *)pcb->pcb_tss.tss_esp0 - 1;
*tf = *p1->p_md.md_regs;
/*
* If specified, give the child a different stack.
*/
if (stack != NULL)
tf->tf_esp = (u_int)stack + stacksize;
sf = (struct switchframe *)tf - 1;
sf->sf_ppl = 0;
sf->sf_esi = (int)func;
sf->sf_ebx = (int)arg;
sf->sf_eip = (int)proc_trampoline;
pcb->pcb_esp = (int)sf;
}
示例3: init_secondary
/*
* AP cpu's call this to sync up protected mode.
*
* WARNING! We must ensure that the cpu is sufficiently initialized to
* be able to use to the FP for our optimized bzero/bcopy code before
* we enter more mainstream C code.
*
* WARNING! %fs is not set up on entry. This routine sets up %fs.
*/
void
init_secondary(void)
{
int gsel_tss;
int x, myid = bootAP;
u_int cr0;
struct mdglobaldata *md;
struct privatespace *ps;
ps = &CPU_prvspace[myid];
gdt_segs[GPRIV_SEL].ssd_base = (int)ps;
gdt_segs[GPROC0_SEL].ssd_base =
(int) &ps->mdglobaldata.gd_common_tss;
ps->mdglobaldata.mi.gd_prvspace = ps;
for (x = 0; x < NGDT; x++) {
ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
}
r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
r_gdt.rd_base = (int) &gdt[myid * NGDT];
lgdt(&r_gdt); /* does magic intra-segment return */
lidt(&r_idt);
lldt(_default_ldt);
mdcpu->gd_currentldt = _default_ldt;
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
md = mdcpu; /* loaded through %fs:0 (mdglobaldata.mi.gd_prvspace)*/
md->gd_common_tss.tss_esp0 = 0; /* not used until after switch */
md->gd_common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
md->gd_common_tss.tss_ioopt = (sizeof md->gd_common_tss) << 16;
md->gd_tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
md->gd_common_tssd = *md->gd_tss_gdt;
ltr(gsel_tss);
/*
* Set to a known state:
* Set by mpboot.s: CR0_PG, CR0_PE
* Set by cpu_setregs: CR0_NE, CR0_MP, CR0_TS, CR0_WP, CR0_AM
*/
cr0 = rcr0();
cr0 &= ~(CR0_CD | CR0_NW | CR0_EM);
load_cr0(cr0);
pmap_set_opt(); /* PSE/4MB pages, etc */
/* set up CPU registers and state */
cpu_setregs();
/* set up FPU state on the AP */
npxinit(__INITIAL_NPXCW__);
/* set up SSE registers */
enable_sse();
}
示例4: cpu_set_tss_gates
void
cpu_set_tss_gates(struct cpu_info *ci)
{
struct segment_descriptor sd;
ci->ci_doubleflt_stack = (char *)uvm_km_alloc(kernel_map, USPACE);
cpu_init_tss(&ci->ci_doubleflt_tss, ci->ci_doubleflt_stack,
IDTVEC(tss_trap08));
setsegment(&sd, &ci->ci_doubleflt_tss, sizeof(struct i386tss) - 1,
SDT_SYS386TSS, SEL_KPL, 0, 0);
ci->ci_gdt[GTRAPTSS_SEL].sd = sd;
setgate(&idt[8], NULL, 0, SDT_SYSTASKGT, SEL_KPL,
GSEL(GTRAPTSS_SEL, SEL_KPL));
#if defined(DDB) && defined(MULTIPROCESSOR)
/*
* Set up separate handler for the DDB IPI, so that it doesn't
* stomp on a possibly corrupted stack.
*
* XXX overwriting the gate set in db_machine_init.
* Should rearrange the code so that it's set only once.
*/
ci->ci_ddbipi_stack = (char *)uvm_km_alloc(kernel_map, USPACE);
cpu_init_tss(&ci->ci_ddbipi_tss, ci->ci_ddbipi_stack,
Xintrddbipi);
setsegment(&sd, &ci->ci_ddbipi_tss, sizeof(struct i386tss) - 1,
SDT_SYS386TSS, SEL_KPL, 0, 0);
ci->ci_gdt[GIPITSS_SEL].sd = sd;
setgate(&idt[ddb_vec], NULL, 0, SDT_SYSTASKGT, SEL_KPL,
GSEL(GIPITSS_SEL, SEL_KPL));
#endif
}
示例5: init_reg_state
static void
init_reg_state(void)
{
vmm_write_register(HV_X86_RAX, 0);
vmm_write_register(HV_X86_RBX, 0);
vmm_write_register(HV_X86_RCX, 0);
vmm_write_register(HV_X86_RDX, 0);
vmm_write_register(HV_X86_RSI, 0);
vmm_write_register(HV_X86_RDI, 0);
vmm_write_register(HV_X86_R8, 0);
vmm_write_register(HV_X86_R9, 0);
vmm_write_register(HV_X86_R10, 0);
vmm_write_register(HV_X86_R11, 0);
vmm_write_register(HV_X86_R12, 0);
vmm_write_register(HV_X86_R13, 0);
vmm_write_register(HV_X86_R14, 0);
vmm_write_register(HV_X86_R15, 0);
vmm_write_vmcs(VMCS_GUEST_FS, 0);
vmm_write_vmcs(VMCS_GUEST_ES, 0);
vmm_write_vmcs(VMCS_GUEST_GS, 0);
vmm_write_vmcs(VMCS_GUEST_DS, 0);
vmm_write_vmcs(VMCS_GUEST_CS, GSEL(SEG_CODE, 0));
vmm_write_vmcs(VMCS_GUEST_DS, GSEL(SEG_DATA, 0));
vmm_write_vmcs(VMCS_GUEST_FS_BASE, 0);
vmm_write_vmcs(VMCS_GUEST_GS_BASE, 0);
vmm_write_vmcs(VMCS_GUEST_LDTR, 0);
init_fpu();
}
示例6: linux_buildcontext
static void
linux_buildcontext(struct lwp *l, void *catcher, void *f)
{
struct trapframe *tf = l->l_md.md_regs;
tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_rip = (u_int64_t)catcher;
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
tf->tf_rflags &= ~PSL_CLEARSIG;
tf->tf_rsp = (u_int64_t)f;
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
}
示例7: linux_setregs
void
linux_setregs(struct lwp *l, struct exec_package *epp, u_long stack)
{
struct pcb *pcb = &l->l_addr->u_pcb;
struct trapframe *tf;
/* If we were using the FPU, forget about it. */
if (l->l_addr->u_pcb.pcb_fpcpu != NULL)
fpusave_lwp(l, 0);
l->l_md.md_flags &= ~MDP_USEDFPU;
pcb->pcb_flags = 0;
pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__;
pcb->pcb_savefpu.fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__;
pcb->pcb_savefpu.fp_fxsave.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__;
pcb->pcb_fs = 0;
pcb->pcb_gs = 0;
l->l_proc->p_flag &= ~PK_32;
tf = l->l_md.md_regs;
tf->tf_rax = 0;
tf->tf_rbx = 0;
tf->tf_rcx = epp->ep_entry;
tf->tf_rdx = 0;
tf->tf_rsi = 0;
tf->tf_rdi = 0;
tf->tf_rbp = 0;
tf->tf_rsp = stack;
tf->tf_r8 = 0;
tf->tf_r9 = 0;
tf->tf_r10 = 0;
tf->tf_r11 = 0;
tf->tf_r12 = 0;
tf->tf_r13 = 0;
tf->tf_r14 = 0;
tf->tf_r15 = 0;
tf->tf_rip = epp->ep_entry;
tf->tf_rflags = PSL_USERSET;
tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
tf->tf_ds = 0;
tf->tf_es = 0;
tf->tf_fs = 0;
tf->tf_gs = 0;
return;
}
示例8: vmm_get_host_datasel
uint64_t
vmm_get_host_datasel(void)
{
return (GSEL(GDATA_SEL, SEL_KPL));
}
示例9: vmbus_vector_alloc
/**
* @brief Find a free IDT slot and setup the interrupt handler.
*/
static int
vmbus_vector_alloc(void)
{
int vector;
uintptr_t func;
struct gate_descriptor *ip;
/*
* Search backwards form the highest IDT vector available for use
* as vmbus channel callback vector. We install 'hv_vmbus_callback'
* handler at that vector and use it to interrupt vcpus.
*/
vector = APIC_SPURIOUS_INT;
while (--vector >= APIC_IPI_INTS) {
ip = &idt[vector];
func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset);
if (func == (uintptr_t)&IDTVEC(rsvd)) {
#ifdef __i386__
setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYS386IGT,
SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
#else
setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYSIGT,
SEL_KPL, 0);
#endif
return (vector);
}
}
return (0);
}
示例10: cpu_init_tss
void
cpu_init_tss(struct i386tss *tss, void *stack, void *func)
{
memset(tss, 0, sizeof *tss);
tss->tss_esp0 = tss->tss_esp = (int)((char *)stack + USPACE - 16);
tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
tss->__tss_cs = GSEL(GCODE_SEL, SEL_KPL);
tss->tss_fs = GSEL(GCPU_SEL, SEL_KPL);
tss->tss_gs = tss->__tss_es = tss->__tss_ds =
tss->__tss_ss = GSEL(GDATA_SEL, SEL_KPL);
tss->tss_cr3 = pmap_kernel()->pm_pdirpa;
tss->tss_esp = (int)((char *)stack + USPACE - 16);
tss->tss_ldt = 0;
tss->__tss_eflags = PSL_MBO | PSL_NT; /* XXX not needed? */
tss->__tss_eip = (int)func;
}
示例11: cpu_ptrace
int
cpu_ptrace(struct thread *td, int req, void *addr, int data)
{
struct segment_descriptor *sdp, sd;
register_t r;
int error;
switch (req) {
case PT_GETXMMREGS:
case PT_SETXMMREGS:
case PT_GETXSTATE_OLD:
case PT_SETXSTATE_OLD:
case PT_GETXSTATE_INFO:
case PT_GETXSTATE:
case PT_SETXSTATE:
error = cpu_ptrace_xmm(td, req, addr, data);
break;
case PT_GETFSBASE:
case PT_GETGSBASE:
sdp = req == PT_GETFSBASE ? &td->td_pcb->pcb_fsd :
&td->td_pcb->pcb_gsd;
r = sdp->sd_hibase << 24 | sdp->sd_lobase;
error = copyout(&r, addr, sizeof(r));
break;
case PT_SETFSBASE:
case PT_SETGSBASE:
error = copyin(addr, &r, sizeof(r));
if (error != 0)
break;
fill_based_sd(&sd, r);
if (req == PT_SETFSBASE) {
td->td_pcb->pcb_fsd = sd;
td->td_frame->tf_fs = GSEL(GUFS_SEL, SEL_UPL);
} else {
td->td_pcb->pcb_gsd = sd;
td->td_pcb->pcb_gs = GSEL(GUGS_SEL, SEL_UPL);
}
break;
default:
return (EINVAL);
}
return (error);
}
示例12: ldt_alloc
/*
* 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);
}
示例13: idt_vec_set
void
idt_vec_set(int vec, void (*function)(void))
{
KASSERT(mutex_owned(&cpu_lock) || !mp_online);
KASSERT(idt_allocmap[vec] == 1);
setgate(&idt[vec], function, 0, SDT_SYS386IGT, SEL_KPL,
GSEL(GCODE_SEL, SEL_KPL));
}
示例14: idt_vec_set
void
idt_vec_set(int vec, void (*function)(void))
{
/*
* Vector should be allocated, so no locking needed.
*/
KASSERT(idt_allocmap[vec] == 1);
setgate(&idt[vec], function, 0, SDT_SYS386IGT, SEL_KPL,
GSEL(GCODE_SEL, SEL_KPL));
}
示例15: tss_alloc
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);
}