From 8a782434de5926486d2bcae6bfda5b4d274268f9 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 25 Dec 2011 00:27:40 +0800 Subject: [PATCH] x86_64: Add setidt(), which setup an IDT entry on the specified cpu --- sys/platform/pc64/include/md_var.h | 2 ++ sys/platform/pc64/x86_64/machdep.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/sys/platform/pc64/include/md_var.h b/sys/platform/pc64/include/md_var.h index 7bc3747af8..cffe7c9d99 100644 --- a/sys/platform/pc64/include/md_var.h +++ b/sys/platform/pc64/include/md_var.h @@ -83,6 +83,8 @@ void pagezero(void *addr); void pagecopy(void *from, void *to); void setidt_global(int idx, alias_for_inthand_t *func, int typ, int dpl, int ist); +void setidt(int idx, alias_for_inthand_t *func, + int typ, int dpl, int ist, int cpu); int user_dbreg_trap(void); void fpstate_drop(struct thread *td); diff --git a/sys/platform/pc64/x86_64/machdep.c b/sys/platform/pc64/x86_64/machdep.c index e8e046dc83..2857edb187 100644 --- a/sys/platform/pc64/x86_64/machdep.c +++ b/sys/platform/pc64/x86_64/machdep.c @@ -1294,6 +1294,24 @@ setidt_global(int idx, inthand_t *func, int typ, int dpl, int ist) } } +void +setidt(int idx, inthand_t *func, int typ, int dpl, int ist, int cpu) +{ + struct gate_descriptor *ip; + + KASSERT(cpu >= 0 && cpu < ncpus, ("invalid cpu %d\n", cpu)); + + ip = &idt_arr[cpu][idx]; + ip->gd_looffset = (uintptr_t)func; + ip->gd_selector = GSEL(GCODE_SEL, SEL_KPL); + ip->gd_ist = ist; + ip->gd_xx = 0; + ip->gd_type = typ; + ip->gd_dpl = dpl; + ip->gd_p = 1; + ip->gd_hioffset = ((uintptr_t)func)>>16 ; +} + #define IDTVEC(name) __CONCAT(X,name) extern inthand_t -- 2.41.0