]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/mp_desc.h
xnu-4570.1.46.tar.gz
[apple/xnu.git] / osfmk / i386 / mp_desc.h
index d9ada40cb7f58dc568a407992e155ec33aa4e807..ebc75cfb0a7a35ebd68042b51ebbf23ba420379a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -60,7 +60,6 @@
 #ifndef        _I386_MP_DESC_H_
 #define        _I386_MP_DESC_H_
 
-#include <mach_kdb.h>
 #include <sys/cdefs.h>
 
 __BEGIN_DECLS
@@ -80,108 +79,41 @@ __BEGIN_DECLS
 /*
  * The descriptor tables are together in a structure
  * allocated one per processor (except for the boot processor).
- * Note that dbtss could be conditionalized on MACH_KDB, but
- * doing so increases misconfiguration risk.
  */
-typedef struct cpu_desc_table {
-       struct fake_descriptor  idt[IDTSZ] __attribute__ ((aligned (16)));
-       struct fake_descriptor  gdt[GDTSZ] __attribute__ ((aligned (16)));
-       struct i386_tss         ktss       __attribute__ ((aligned (16)));
-       struct i386_tss         dbtss      __attribute__ ((aligned (16)));
-       struct sysenter_stack   sstk;
-} cpu_desc_table_t;
-
 typedef struct cpu_desc_table64 {
-       struct fake_descriptor64 idt[IDTSZ]      __attribute__ ((aligned (16)));
        struct fake_descriptor  gdt[GDTSZ]       __attribute__ ((aligned (16)));
        struct x86_64_tss       ktss             __attribute__ ((aligned (16)));
        struct sysenter_stack   sstk             __attribute__ ((aligned (16)));
-       uint8_t                 dfstk[PAGE_SIZE] __attribute__ ((aligned (16)));
+       uint8_t                 fstk[PAGE_SIZE]  __attribute__ ((aligned (16)));
 } cpu_desc_table64_t;
 
-#define        current_gdt()   (current_cpu_datap()->cpu_desc_index.cdi_gdt)
-#define        current_idt()   (current_cpu_datap()->cpu_desc_index.cdi_idt)
+#define        current_gdt()   (current_cpu_datap()->cpu_desc_index.cdi_gdt.ptr)
+#define        current_idt()   (current_cpu_datap()->cpu_desc_index.cdi_idt.ptr)
 #define        current_ldt()   (current_cpu_datap()->cpu_desc_index.cdi_ldt)
 #define        current_ktss()  (current_cpu_datap()->cpu_desc_index.cdi_ktss)
-#define        current_dbtss() (current_cpu_datap()->cpu_desc_index.cdi_dbtss)
 #define        current_sstk()  (current_cpu_datap()->cpu_desc_index.cdi_sstk)
 
 #define        current_ktss64() ((struct x86_64_tss *) current_ktss())
 #define        current_sstk64() ((addr64_t *) current_sstk())
 
 #define        gdt_desc_p(sel) \
-       ((struct real_descriptor *)&current_gdt()[sel_idx(sel)])
+       (&((struct real_descriptor *)current_gdt())[sel_idx(sel)])
 #define        ldt_desc_p(sel) \
-       ((struct real_descriptor *)&current_ldt()[sel_idx(sel)])
-
-extern void    cpu_desc_init(
-                       cpu_data_t      *cdp,
-                       boolean_t       is_boot_cpu);
-extern void    cpu_desc_init64(
-                       cpu_data_t      *cdp,
-                       boolean_t       is_boot_cpu);
-extern void    cpu_desc_load64(
-                       cpu_data_t      *cdp);
-extern void    cpu_mode_init(
-                       cpu_data_t      *cdp);
-
-static inline boolean_t
-valid_user_data_selector(uint16_t selector)
-{
-    sel_t      sel = selector_to_sel(selector);
-    
-    if (selector == 0)
-       return (TRUE);
-
-    if (sel.ti == SEL_LDT)
-       return (TRUE);
-    else if (sel.index < GDTSZ) {
-       if ((gdt_desc_p(selector)->access & ACC_PL_U) == ACC_PL_U)
-           return (TRUE);
-    }
-               
-    return (FALSE);
-}
-
-static inline boolean_t
-valid_user_code_selector(uint16_t selector)
-{
-    sel_t      sel = selector_to_sel(selector);
-    
-    if (selector == 0)
-       return (FALSE);
-
-    if (sel.ti == SEL_LDT) {
-       if (sel.rpl == USER_PRIV)
-           return (TRUE);
-    }
-    else if (sel.index < GDTSZ && sel.rpl == USER_PRIV) {
-       if ((gdt_desc_p(selector)->access & ACC_PL_U) == ACC_PL_U)
-           return (TRUE);
-    }
-
-    return (FALSE);
-}
-
-static inline boolean_t
-valid_user_stack_selector(uint16_t selector)
-{
-    sel_t      sel = selector_to_sel(selector);
-    
-    if (selector == 0)
-       return (FALSE);
-
-    if (sel.ti == SEL_LDT) {
-       if (sel.rpl == USER_PRIV)
-           return (TRUE);
-    }
-    else if (sel.index < GDTSZ && sel.rpl == USER_PRIV) {
-       if ((gdt_desc_p(selector)->access & ACC_PL_U) == ACC_PL_U)
-           return (TRUE);
-    }
-               
-    return (FALSE);
-}
+       (&((struct real_descriptor *)current_ldt())[sel_idx(sel)])
+
+extern void    cpu_syscall_init(cpu_data_t *cdp);
+
+extern void    cpu_desc_init(cpu_data_t *cdp);
+extern void    cpu_desc_load(cpu_data_t *cdp);
+
+extern boolean_t
+valid_user_data_selector(uint16_t selector);
+
+extern boolean_t
+valid_user_code_selector(uint16_t selector);
+
+extern boolean_t
+valid_user_stack_selector(uint16_t selector);
 
 extern boolean_t
 valid_user_segment_selectors(uint16_t cs,
@@ -193,4 +125,4 @@ valid_user_segment_selectors(uint16_t cs,
 
 __END_DECLS
 
-#endif /* _I386_MP_DESC_H_ */
+#endif /* _X86_64_MP_DESC_H_ */