]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/cpu_capabilities.h
xnu-1504.15.3.tar.gz
[apple/xnu.git] / osfmk / i386 / cpu_capabilities.h
index 6270145f1d699c1bbb52a4779b27b6fd0e4b6456..470e8a3e73cdbb347f21c606f32d0ecb03989144 100644 (file)
@@ -1,23 +1,29 @@
 /*
- * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2009 Apple Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 #ifdef PRIVATE
 
 #define        kCache64                        0x00000020
 #define        kCache128                       0x00000040
 #define        kFastThreadLocalStorage         0x00000080      /* TLS ptr is kept in a user-mode-readable register */
-#define kHasSupplementalSSE3   0x00000100
-#define kHasMNI                                kHasSupplementalSSE3
+#define kHasSupplementalSSE3           0x00000100
 #define        k64Bit                          0x00000200      /* processor supports EM64T (not what mode you're running in) */
-
+#define        kHasSSE4_1                      0x00000400
+#define        kHasSSE4_2                      0x00000800
+#define        kHasAES                         0x00001000
+#define        kInOrderPipeline                0x00002000      /* in-order execution */
+#define        kSlow                           0x00004000      /* tsc < nanosecond */
 #define        kUP                             0x00008000      /* set if (kNumCPUs == 1) */
 #define        kNumCPUs                        0x00FF0000      /* number of CPUs (see _NumCPUs() below) */
 
@@ -78,15 +87,32 @@ int _NumCPUs( void )
  */
  
 #define        _COMM_PAGE32_AREA_LENGTH        ( 19 * 4096 )                           /* reserved length of entire comm area */
-#define _COMM_PAGE32_BASE_ADDRESS      ( -20 * 4096 )                          /* base address of allocated memory */
-#define _COMM_PAGE32_START_ADDRESS     ( -16 * 4096 )                          /* address traditional commpage code starts on */
+#define _COMM_PAGE32_BASE_ADDRESS      ( 0xfffec000 )                          /* base address of allocated memory, -20 pages */
+#define _COMM_PAGE32_START_ADDRESS     ( 0xffff0000 )                          /* address traditional commpage code starts on, -16 pages */
 #define _COMM_PAGE32_AREA_USED         ( 19 * 4096 )                           /* this is the amt actually allocated */
+#define _COMM_PAGE32_SIGS_OFFSET       0x8000                                  /* offset to routine signatures */
 
 #define        _COMM_PAGE64_AREA_LENGTH        ( 2 * 1024 * 1024 )                     /* reserved length of entire comm area (2MB) */
 #define _COMM_PAGE64_BASE_ADDRESS      ( 0x00007fffffe00000ULL )               /* base address of allocated memory */
 #define _COMM_PAGE64_START_ADDRESS     ( _COMM_PAGE64_BASE_ADDRESS )           /* address traditional commpage code starts on */
 #define _COMM_PAGE64_AREA_USED         ( 2 * 4096 )                            /* this is the amt actually populated */
 
+/* no need for an Objective-C area on Intel */
+#define _COMM_PAGE32_OBJC_SIZE         0ULL
+#define _COMM_PAGE32_OBJC_BASE         0ULL
+#define _COMM_PAGE64_OBJC_SIZE         0ULL
+#define _COMM_PAGE64_OBJC_BASE         0ULL
+
+#ifdef KERNEL_PRIVATE
+
+/* Inside the kernel, comm page addresses are absolute addresses
+ * assuming they are a part of the 32-bit commpage. They may
+ * be mapped somewhere else, especially for the 64-bit commpage.
+ */
+#define _COMM_PAGE_START_ADDRESS       _COMM_PAGE32_START_ADDRESS
+#define _COMM_PAGE_SIGS_OFFSET         _COMM_PAGE32_SIGS_OFFSET
+
+#else /* !KERNEL_PRIVATE */
 
 #if defined(__i386__)
 
@@ -94,7 +120,7 @@ int _NumCPUs( void )
 #define _COMM_PAGE_BASE_ADDRESS                _COMM_PAGE32_BASE_ADDRESS
 #define _COMM_PAGE_START_ADDRESS       _COMM_PAGE32_START_ADDRESS
 #define _COMM_PAGE_AREA_USED           _COMM_PAGE32_AREA_USED
-#define _COMM_PAGE_SIGS_OFFSET         0x8000                                  /* offset to routine signatures */
+#define _COMM_PAGE_SIGS_OFFSET         _COMM_PAGE32_SIGS_OFFSET
 
 #elif defined(__x86_64__)
 
@@ -107,18 +133,32 @@ int _NumCPUs( void )
 #error architecture not supported
 #endif
  
+#endif /* !KERNEL_PRIVATE */
+
 /* data in the comm page */
  
 #define _COMM_PAGE_SIGNATURE           (_COMM_PAGE_START_ADDRESS+0x000)        /* first few bytes are a signature */
 #define _COMM_PAGE_VERSION             (_COMM_PAGE_START_ADDRESS+0x01E)        /* 16-bit version# */
-#define        _COMM_PAGE_THIS_VERSION         6                                       /* version of the commarea format */
+#define _COMM_PAGE_THIS_VERSION                11                                      /* version of the commarea format */
   
 #define _COMM_PAGE_CPU_CAPABILITIES    (_COMM_PAGE_START_ADDRESS+0x020)        /* uint32_t _cpu_capabilities */
 #define _COMM_PAGE_NCPUS               (_COMM_PAGE_START_ADDRESS+0x022)        /* uint8_t number of configured CPUs */
 #define _COMM_PAGE_CACHE_LINESIZE      (_COMM_PAGE_START_ADDRESS+0x026)        /* uint16_t cache line size */
 
-#define _COMM_PAGE_UNUSED1             (_COMM_PAGE_START_ADDRESS+0x028)        /* 24 unused bytes */
+#define _COMM_PAGE_SCHED_GEN           (_COMM_PAGE_START_ADDRESS+0x028)        /* uint32_t scheduler generation number (count of pre-emptions) */
+#define _COMM_PAGE_MEMORY_PRESSURE     (_COMM_PAGE_START_ADDRESS+0x02c)        /* uint32_t copy of vm_memory_pressure */
+#define        _COMM_PAGE_SPIN_COUNT           (_COMM_PAGE_START_ADDRESS+0x030)        /* uint32_t max spin count for mutex's */
+
+#define _COMM_PAGE_UNUSED1             (_COMM_PAGE_START_ADDRESS+0x034)        /* 12 unused bytes */
+
+#ifdef KERNEL_PRIVATE
+
+/* slots defined in all cases, but commpage setup code must not populate for 64-bit commpage */
+#define _COMM_PAGE_2_TO_52             (_COMM_PAGE_START_ADDRESS+0x040)        /* double float constant 2**52 */
+#define _COMM_PAGE_10_TO_6             (_COMM_PAGE_START_ADDRESS+0x048)        /* double float constant 10**6 */
+
+#else /* !KERNEL_PRIVATE */
+
 #if defined(__i386__)                                                          /* following are not defined in 64-bit */
 #define _COMM_PAGE_2_TO_52             (_COMM_PAGE_START_ADDRESS+0x040)        /* double float constant 2**52 */
 #define _COMM_PAGE_10_TO_6             (_COMM_PAGE_START_ADDRESS+0x048)        /* double float constant 10**6 */
@@ -126,26 +166,34 @@ int _NumCPUs( void )
 #define _COMM_PAGE_UNUSED2             (_COMM_PAGE_START_ADDRESS+0x040)        /* 16 unused bytes */
 #endif
 
+#endif /* !KERNEL_PRIVATE */
+
+#define        _COMM_PAGE_TIME_DATA_START      (_COMM_PAGE_START_ADDRESS+0x050)        /* base of offsets below (_NT_SCALE etc) */
 #define _COMM_PAGE_NT_TSC_BASE         (_COMM_PAGE_START_ADDRESS+0x050)        /* used by nanotime() */
 #define _COMM_PAGE_NT_SCALE            (_COMM_PAGE_START_ADDRESS+0x058)        /* used by nanotime() */
 #define _COMM_PAGE_NT_SHIFT            (_COMM_PAGE_START_ADDRESS+0x05c)        /* used by nanotime() */
 #define _COMM_PAGE_NT_NS_BASE          (_COMM_PAGE_START_ADDRESS+0x060)        /* used by nanotime() */
-#define _COMM_PAGE_TIMEBASE            (_COMM_PAGE_START_ADDRESS+0x068)        /* used by gettimeofday() */
-#define _COMM_PAGE_TIMESTAMP           (_COMM_PAGE_START_ADDRESS+0x070)        /* used by gettimeofday() */
-#define _COMM_PAGE_TIMEENABLE          (_COMM_PAGE_START_ADDRESS+0x078)        /* used by gettimeofday() */
+#define _COMM_PAGE_NT_GENERATION       (_COMM_PAGE_START_ADDRESS+0x068)        /* used by nanotime() */
+#define _COMM_PAGE_GTOD_GENERATION     (_COMM_PAGE_START_ADDRESS+0x06c)        /* used by gettimeofday() */
+#define _COMM_PAGE_GTOD_NS_BASE                (_COMM_PAGE_START_ADDRESS+0x070)        /* used by gettimeofday() */
+#define _COMM_PAGE_GTOD_SEC_BASE       (_COMM_PAGE_START_ADDRESS+0x078)        /* used by gettimeofday() */
+
+/* Warning: kernel commpage.h has a matching c typedef for the following.  They must be kept in sync.  */
+/* These offsets are from _COMM_PAGE_TIME_DATA_START */
 
-#define        _NT_TSC_BASE                    0                                       /* offsets into nanotime data */
+#define        _NT_TSC_BASE                    0
 #define        _NT_SCALE                       8
 #define        _NT_SHIFT                       12
 #define        _NT_NS_BASE                     16
-#define        _TIMEBASE                       0                                       /* offsets into gettimeofday data */
-#define        _TIMESTAMP                      8
-#define        _TIMEENABLE                     16
+#define        _NT_GENERATION                  24
+#define        _GTOD_GENERATION                28
+#define        _GTOD_NS_BASE                   32
+#define        _GTOD_SEC_BASE                  40
  
  /* jump table (jmp to this address, which may be a branch to the actual code somewhere else) */
- /* When new jump table entries are added, corresponding symbols should be added below         */
-
+ /* When new jump table entries are added, corresponding symbols should be added below        */
+ /* New slots should be allocated with at least 16-byte alignment. Some like bcopy require    */
+ /* 32-byte alignment, and should be aligned as such in the assembly source before they are relocated */
 #define _COMM_PAGE_COMPARE_AND_SWAP32   (_COMM_PAGE_START_ADDRESS+0x080)       /* compare-and-swap word */
 #define _COMM_PAGE_COMPARE_AND_SWAP64   (_COMM_PAGE_START_ADDRESS+0x0c0)       /* compare-and-swap doubleword */
 #define _COMM_PAGE_ENQUEUE              (_COMM_PAGE_START_ADDRESS+0x100)       /* enqueue */
@@ -154,7 +202,7 @@ int _NumCPUs( void )
 #define _COMM_PAGE_ATOMIC_ADD32         (_COMM_PAGE_START_ADDRESS+0x1a0)       /* add atomic word */
 #define _COMM_PAGE_ATOMIC_ADD64         (_COMM_PAGE_START_ADDRESS+0x1c0)       /* add atomic doubleword */
 
-#define        _COMM_PAGE_UNUSED3              (_COMM_PAGE_START_ADDRESS+0x1e0)        /* 32 unused bytes */
+#define        _COMM_PAGE_CPU_NUMBER           (_COMM_PAGE_START_ADDRESS+0x1e0)        /* user-level cpu_number() */
 
 #define _COMM_PAGE_ABSOLUTE_TIME       (_COMM_PAGE_START_ADDRESS+0x200)        /* mach_absolute_time() */
 #define _COMM_PAGE_SPINLOCK_TRY                (_COMM_PAGE_START_ADDRESS+0x220)        /* spinlock_try() */
@@ -166,7 +214,7 @@ int _NumCPUs( void )
 #define _COMM_PAGE_FLUSH_ICACHE                (_COMM_PAGE_START_ADDRESS+0x520)        /* sys_icache_invalidate() */
 #define _COMM_PAGE_PTHREAD_SELF                (_COMM_PAGE_START_ADDRESS+0x580)        /* pthread_self() */
 
-#define _COMM_PAGE_UNUSED4             (_COMM_PAGE_START_ADDRESS+0x5a0)        /* 32 unused bytes */
+#define _COMM_PAGE_PREEMPT             (_COMM_PAGE_START_ADDRESS+0x5a0)        /* used by PFZ code */
 
 #define _COMM_PAGE_RELINQUISH          (_COMM_PAGE_START_ADDRESS+0x5c0)        /* used by spinlocks */ 
 #define _COMM_PAGE_BTS                 (_COMM_PAGE_START_ADDRESS+0x5e0)        /* bit test-and-set */
@@ -176,16 +224,31 @@ int _NumCPUs( void )
 #define _COMM_PAGE_BCOPY               (_COMM_PAGE_START_ADDRESS+0x780)        /* bcopy() */
 #define        _COMM_PAGE_MEMCPY               (_COMM_PAGE_START_ADDRESS+0x7a0)        /* memcpy() */
 #define        _COMM_PAGE_MEMMOVE              (_COMM_PAGE_START_ADDRESS+0x7a0)        /* memmove() */
+#define        _COMM_PAGE_BCOPY_END            (_COMM_PAGE_START_ADDRESS+0xfff)        /* used by rosetta */
 
-#define        _COMM_PAGE_OLD_NANOTIME         (_COMM_PAGE_START_ADDRESS+0xf80)        /* old nanotime location (deprecated) */
 #define        _COMM_PAGE_MEMSET_PATTERN       (_COMM_PAGE_START_ADDRESS+0x1000)       /* used by nonzero memset() */
 #define        _COMM_PAGE_LONGCOPY             (_COMM_PAGE_START_ADDRESS+0x1200)       /* used by bcopy() for very long operands */
+#define        _COMM_PAGE_LONGCOPY_END         (_COMM_PAGE_START_ADDRESS+0x15ff)       /* used by rosetta */
 
-#define _COMM_PAGE_SYSTEM_INTEGRITY    (_COMM_PAGE_START_ADDRESS+0x1600)       /* system integrity data, 256 bytes */
-
+#define _COMM_PAGE_BACKOFF             (_COMM_PAGE_START_ADDRESS+0x1600)       /* called from PFZ */
+#define _COMM_PAGE_FIFO_ENQUEUE                (_COMM_PAGE_START_ADDRESS+0x1680)       /* FIFO enqueue */
+#define _COMM_PAGE_FIFO_DEQUEUE                (_COMM_PAGE_START_ADDRESS+0x16c0)       /* FIFO dequeue */
 #define        _COMM_PAGE_NANOTIME             (_COMM_PAGE_START_ADDRESS+0x1700)       /* nanotime() */
+#define        _COMM_PAGE_MUTEX_LOCK           (_COMM_PAGE_START_ADDRESS+0x1780)       /* pthread_mutex_lock() */
+
+#define        _COMM_PAGE_UNUSED5              (_COMM_PAGE_START_ADDRESS+0x17e0)       /* unused space for regular code up to 0x1c00 */
+
+#define _COMM_PAGE_PFZ_START           (_COMM_PAGE_START_ADDRESS+0x1c00)       /* start of Preemption Free Zone */
+
+#define _COMM_PAGE_PFZ_ENQUEUE         (_COMM_PAGE_START_ADDRESS+0x1c00)       /* internal routine for FIFO enqueue */
+#define _COMM_PAGE_PFZ_DEQUEUE         (_COMM_PAGE_START_ADDRESS+0x1c80)       /* internal routine for FIFO dequeue */
+#define        _COMM_PAGE_PFZ_MUTEX_LOCK       (_COMM_PAGE_START_ADDRESS+0x1d00)       /* internal routine for pthread_mutex_lock() */
+
+#define        _COMM_PAGE_UNUSED6              (_COMM_PAGE_START_ADDRESS+0x1d80)       /* unused space for PFZ code up to 0x1fff */
+
+#define _COMM_PAGE_PFZ_END             (_COMM_PAGE_START_ADDRESS+0x1fff)       /* end of Preemption Free Zone */
 
-#define _COMM_PAGE_END                 (_COMM_PAGE_START_ADDRESS+0x1780)       /* end of common page - insert new stuff here */
+#define _COMM_PAGE_END                 (_COMM_PAGE_START_ADDRESS+0x1fff)       /* end of common page - insert new stuff here */
 
 /* _COMM_PAGE_COMPARE_AND_SWAP{32,64}B are not used on x86 and are
  * maintained here for source compatability.  These will be removed at
@@ -209,6 +272,7 @@ symbol_name: nop
        CREATE_COMM_PAGE_SYMBOL(___memory_barrier, _COMM_PAGE_MEMORY_BARRIER)
        CREATE_COMM_PAGE_SYMBOL(___atomic_add32, _COMM_PAGE_ATOMIC_ADD32)
        CREATE_COMM_PAGE_SYMBOL(___atomic_add64, _COMM_PAGE_ATOMIC_ADD64)
+       CREATE_COMM_PAGE_SYMBOL(___cpu_number, _COMM_PAGE_CPU_NUMBER)
        CREATE_COMM_PAGE_SYMBOL(___mach_absolute_time, _COMM_PAGE_ABSOLUTE_TIME)
        CREATE_COMM_PAGE_SYMBOL(___spin_lock_try, _COMM_PAGE_SPINLOCK_TRY)
        CREATE_COMM_PAGE_SYMBOL(___spin_lock, _COMM_PAGE_SPINLOCK_LOCK)
@@ -218,6 +282,7 @@ symbol_name: nop
        CREATE_COMM_PAGE_SYMBOL(___sys_dcache_flush, _COMM_PAGE_FLUSH_DCACHE)
        CREATE_COMM_PAGE_SYMBOL(___sys_icache_invalidate, _COMM_PAGE_FLUSH_ICACHE)
        CREATE_COMM_PAGE_SYMBOL(___pthread_self, _COMM_PAGE_PTHREAD_SELF)
+       CREATE_COMM_PAGE_SYMBOL(___pfz_preempt, _COMM_PAGE_PREEMPT)
        CREATE_COMM_PAGE_SYMBOL(___spin_lock_relinquish, _COMM_PAGE_RELINQUISH)
        CREATE_COMM_PAGE_SYMBOL(___bit_test_and_set, _COMM_PAGE_BTS)
        CREATE_COMM_PAGE_SYMBOL(___bit_test_and_clear, _COMM_PAGE_BTC)
@@ -225,10 +290,16 @@ symbol_name: nop
        CREATE_COMM_PAGE_SYMBOL(___bcopy, _COMM_PAGE_BCOPY)
        CREATE_COMM_PAGE_SYMBOL(___memcpy, _COMM_PAGE_MEMCPY)
 /*     CREATE_COMM_PAGE_SYMBOL(___memmove, _COMM_PAGE_MEMMOVE) */
-       CREATE_COMM_PAGE_SYMBOL(___old_nanotime, _COMM_PAGE_OLD_NANOTIME)
        CREATE_COMM_PAGE_SYMBOL(___memset_pattern, _COMM_PAGE_MEMSET_PATTERN)
        CREATE_COMM_PAGE_SYMBOL(___longcopy, _COMM_PAGE_LONGCOPY)
+       CREATE_COMM_PAGE_SYMBOL(___backoff, _COMM_PAGE_BACKOFF)
+       CREATE_COMM_PAGE_SYMBOL(___fifo_enqueue, _COMM_PAGE_FIFO_ENQUEUE)
+       CREATE_COMM_PAGE_SYMBOL(___fifo_dequeue, _COMM_PAGE_FIFO_DEQUEUE)
        CREATE_COMM_PAGE_SYMBOL(___nanotime, _COMM_PAGE_NANOTIME)
+       CREATE_COMM_PAGE_SYMBOL(___mutex_lock, _COMM_PAGE_MUTEX_LOCK)
+       CREATE_COMM_PAGE_SYMBOL(___pfz_enqueue, _COMM_PAGE_PFZ_ENQUEUE)
+       CREATE_COMM_PAGE_SYMBOL(___pfz_dequeue, _COMM_PAGE_PFZ_DEQUEUE)
+       CREATE_COMM_PAGE_SYMBOL(___pfz_mutex_lock, _COMM_PAGE_PFZ_MUTEX_LOCK)
        CREATE_COMM_PAGE_SYMBOL(___end_comm_page, _COMM_PAGE_END)
 
        .data           /* Required to make a well behaved symbol file */