The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/osfmk/ppc/cpu_capabilities.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2003-2006 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
    5  * 
    6  * This file contains Original Code and/or Modifications of Original Code
    7  * as defined in and that are subject to the Apple Public Source License
    8  * Version 2.0 (the 'License'). You may not use this file except in
    9  * compliance with the License. The rights granted to you under the License
   10  * may not be used to create, or enable the creation or redistribution of,
   11  * unlawful or unlicensed copies of an Apple operating system, or to
   12  * circumvent, violate, or enable the circumvention or violation of, any
   13  * terms of an Apple operating system software license agreement.
   14  * 
   15  * Please obtain a copy of the License at
   16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
   17  * 
   18  * The Original Code and all software distributed under the License are
   19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   23  * Please see the License for the specific language governing rights and
   24  * limitations under the License.
   25  * 
   26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
   27  */
   28 #ifdef  PRIVATE
   29 
   30 #ifndef _PPC_CPU_CAPABILITIES_H
   31 #define _PPC_CPU_CAPABILITIES_H
   32 
   33 /* _cpu_capabilities
   34  *
   35  * This is the authoritative way to determine from user mode what
   36  * implementation-specific processor features are available.
   37  * This API is only supported for Apple internal use.
   38  */
   39 
   40 #ifndef __ASSEMBLER__
   41  
   42 extern int _cpu_capabilities;
   43  
   44 #endif /* __ASSEMBLER__ */
   45 
   46 /* Bit definitions for _cpu_capabilities: */
   47 
   48 #define kHasAltivec                             0x00000001
   49 #define k64Bit                                  0x00000002      // 64-bit GPRs
   50 #define kCache32                                0x00000004      // cache line size is 32 bytes
   51 #define kCache64                                0x00000008
   52 #define kCache128                               0x00000010
   53 #define kDcbaRecommended                0x00000020      // PPC: dcba is available and recommended
   54 #define kDcbaAvailable                  0x00000040      // PPC: dcba is available (but may or may not be recommended)
   55 #define kDataStreamsRecommended 0x00000080      // PPC: dst, dstt, dstst, dss, and dssall instructions available and recommended
   56 #define kDataStreamsAvailable   0x00000100      // PPC: dst, dstt, dstst, dss, and dssall instructions available (may or may not be rec'd)
   57 #define kDcbtStreamsRecommended 0x00000200      // PPC: enhanced dcbt instruction available and recommended
   58 #define kDcbtStreamsAvailable   0x00000400      // PPC: enhanced dcbt instruction available (but may or may not be recommended)
   59 #define kFastThreadLocalStorage 0x00000800      // TLS ptr is kept in a user-mode-readable register
   60 
   61 #define kUP                                             0x00008000      // set if (kNumCPUs == 1)
   62 #define kNumCPUs                                0x00FF0000      // number of CPUs (see _NumCPUs() below)
   63 
   64 #define kNumCPUsShift                   16                      // see _NumCPUs() below
   65 
   66 #define kHasGraphicsOps                 0x08000000      // PPC: has fres, frsqrte, and fsel instructions
   67 #define kHasStfiwx                              0x10000000      // PPC: has stfiwx instruction
   68 #define kHasFsqrt                               0x20000000      // PPC: has fsqrt and fsqrts instructions
   69 
   70 #ifndef __ASSEMBLER__
   71  
   72 static __inline__ int _NumCPUs( void ) { return (_cpu_capabilities & kNumCPUs) >> kNumCPUsShift; }
   73 
   74 #endif /* __ASSEMBLER__ */
   75 
   76 
   77 /*
   78  * The shared kernel/user "comm page(s)":
   79  *
   80  * The last eight pages of every address space are reserved for the kernel/user
   81  * "comm area".  Because they can be addressed via a sign-extended 16-bit field,
   82  * it is particularly efficient to access code or data in the comm area with
   83  * absolute branches (ba, bla, bca) or absolute load/stores ("lwz r0,-4096(0)").
   84  * Because the comm area can be reached from anywhere, dyld is not needed.
   85  * Although eight pages are reserved, presently only two are populated and mapped.
   86  *
   87  * Routines on the comm page(s) can be thought of as the firmware for extended processor
   88  * instructions, whose opcodes are special forms of "bla".  Ie, they are cpu
   89  * capabilities.  During system initialization, the kernel populates the comm page with
   90  * code customized for the particular processor and platform.
   91  *
   92  * Because Mach VM cannot map the last page of an address space, the max length of
   93  * the comm area is seven pages.
   94  */
   95  
   96 #define _COMM_PAGE_BASE_ADDRESS                 (-8*4096)                                               // start at page -8, ie 0xFFFF8000
   97 #define _COMM_PAGE_AREA_LENGTH                  ( 7*4096)                                               // reserved length of entire comm area
   98 #define _COMM_PAGE_AREA_USED                    ( 2*4096)                                               // we use two pages so far
   99 
  100 /* The following set of definitions are used in the kernel, which needs to distinguish between
  101  * the 32 and 64-bit commpage addresses and lengths.  On PPC they are the same, but on Imtel
  102  * they are not.
  103  */
  104 #define _COMM_PAGE32_BASE_ADDRESS               ( _COMM_PAGE_BASE_ADDRESS )
  105 #define _COMM_PAGE64_BASE_ADDRESS               ( _COMM_PAGE_BASE_ADDRESS )
  106 #define _COMM_PAGE32_AREA_LENGTH                ( _COMM_PAGE_AREA_LENGTH )
  107 #define _COMM_PAGE64_AREA_LENGTH                ( _COMM_PAGE_AREA_LENGTH )
  108 #define _COMM_PAGE32_AREA_USED                  ( _COMM_PAGE_AREA_USED )
  109 #define _COMM_PAGE64_AREA_USED                  ( _COMM_PAGE_AREA_USED )
  110 
  111 /* The Objective-C runtime fixed address page to optimize message dispatch */
  112 #define _OBJC_PAGE_BASE_ADDRESS                 (-20*4096)                                              // start at page -20, ie 0xFFFEC000
  113  
  114 /*
  115  * Objective-C needs an "absolute" area all the way up to the top of the
  116  * address space.
  117  * For a ppc32 task, that area gets allocated at runtime from user space.
  118  * For a ppc64 task, that area is not within the user-accessible address range,
  119  * so we pre-allocate it at exec time (see vm_map_exec()) along with the
  120  * comm page.
  121  * 
  122  * NOTE: that means we can't "nest" the 64-bit comm page...
  123  */
  124 #define _COMM_PAGE32_OBJC_SIZE  0ULL
  125 #define _COMM_PAGE32_OBJC_BASE  0ULL
  126 #if 0
  127 #define _COMM_PAGE64_OBJC_SIZE  (4 * 4096)
  128 #define _COMM_PAGE64_OBJC_BASE  (_OBJC_PAGE_BASE_ADDRESS)
  129 #else
  130 /*
  131  * PPC51: ppc64 is limited to 51-bit addresses.
  132  * PPC64 has a 51-bit address space limit, so we can't just go and
  133  * map the Obj-C area up there.  We would have to create a nested pmap
  134  * and make a special mapping that redirects the large virtual addresses to
  135  * that other address space with lower addresses that fit within the 51-bit
  136  * limit.
  137  * VM would then have to handle this redirection when we fault one
  138  * of these pages in but it doesn't do that at this point, so no
  139  * Obj-C area for ppc64 for now :-(
  140  */
  141 #define _COMM_PAGE64_OBJC_SIZE  0ULL
  142 #define _COMM_PAGE64_OBJC_BASE  0ULL
  143 #endif
  144 
  145 /* data in the comm page */
  146  
  147 #define _COMM_PAGE_SIGNATURE                    (_COMM_PAGE_BASE_ADDRESS+0x000) // first few bytes are a signature
  148 #define _COMM_PAGE_VERSION                              (_COMM_PAGE_BASE_ADDRESS+0x01E) // 16-bit version#
  149 #define _COMM_PAGE_THIS_VERSION                 2                                                               // this is version 2 of the commarea format
  150   
  151 #define _COMM_PAGE_CPU_CAPABILITIES             (_COMM_PAGE_BASE_ADDRESS+0x020) // mirror of extern int _cpu_capabilities
  152 #define _COMM_PAGE_NCPUS                                (_COMM_PAGE_BASE_ADDRESS+0x021) // number of configured CPUs
  153 #define _COMM_PAGE_ALTIVEC                              (_COMM_PAGE_BASE_ADDRESS+0x024) // nonzero if Altivec available
  154 #define _COMM_PAGE_64_BIT                               (_COMM_PAGE_BASE_ADDRESS+0x025) // nonzero if 64-bit processor
  155 #define _COMM_PAGE_CACHE_LINESIZE               (_COMM_PAGE_BASE_ADDRESS+0x026) // cache line size (16-bit field)
  156  
  157 #define _COMM_PAGE_UNUSED1                              (_COMM_PAGE_BASE_ADDRESS+0x028) // 24 unused bytes
  158  
  159 #define _COMM_PAGE_2_TO_52                              (_COMM_PAGE_BASE_ADDRESS+0x040) // double float constant 2**52
  160 #define _COMM_PAGE_10_TO_6                              (_COMM_PAGE_BASE_ADDRESS+0x048) // double float constant 10**6
  161 #define _COMM_PAGE_MAGIC_FE             (_COMM_PAGE_BASE_ADDRESS+0x050) // magic constant 0xFEFEFEFEFEFEFEFF (to find 0s)
  162 #define _COMM_PAGE_MAGIC_80             (_COMM_PAGE_BASE_ADDRESS+0x058) // magic constant 0x8080808080808080 (to find 0s)
  163  
  164 #define _COMM_PAGE_TIMEBASE                             (_COMM_PAGE_BASE_ADDRESS+0x060) // used by gettimeofday()
  165 #define _COMM_PAGE_TIMESTAMP                    (_COMM_PAGE_BASE_ADDRESS+0x068) // used by gettimeofday()
  166 #define _COMM_PAGE_SEC_PER_TICK                 (_COMM_PAGE_BASE_ADDRESS+0x070) // used by gettimeofday()
  167  
  168  /* jump table (bla to this address, which may be a branch to the actual code somewhere else) */
  169  /* When new jump table entries are added, corresponding symbols should be added below         */
  170  
  171 #define _COMM_PAGE_COMPARE_AND_SWAP32   (_COMM_PAGE_BASE_ADDRESS+0x080) // compare-and-swap word, no barrier
  172 #define _COMM_PAGE_COMPARE_AND_SWAP64   (_COMM_PAGE_BASE_ADDRESS+0x0c0) // compare-and-swap doubleword, no barrier
  173 #define _COMM_PAGE_ENQUEUE                              (_COMM_PAGE_BASE_ADDRESS+0x100) // enqueue
  174 #define _COMM_PAGE_DEQUEUE                              (_COMM_PAGE_BASE_ADDRESS+0x140) // dequeue
  175 #define _COMM_PAGE_MEMORY_BARRIER               (_COMM_PAGE_BASE_ADDRESS+0x180) // memory barrier
  176 #define _COMM_PAGE_ATOMIC_ADD32                 (_COMM_PAGE_BASE_ADDRESS+0x1a0) // add atomic word
  177 #define _COMM_PAGE_ATOMIC_ADD64                 (_COMM_PAGE_BASE_ADDRESS+0x1c0) // add atomic doubleword
  178 
  179 #define _COMM_PAGE_UNUSED3                              (_COMM_PAGE_BASE_ADDRESS+0x1e0) // 32 unused bytes
  180 
  181 #define _COMM_PAGE_ABSOLUTE_TIME                (_COMM_PAGE_BASE_ADDRESS+0x200) // mach_absolute_time()
  182 #define _COMM_PAGE_SPINLOCK_TRY                 (_COMM_PAGE_BASE_ADDRESS+0x220) // spinlock_try()
  183 #define _COMM_PAGE_SPINLOCK_LOCK                (_COMM_PAGE_BASE_ADDRESS+0x260) // spinlock_lock()
  184 #define _COMM_PAGE_SPINLOCK_UNLOCK              (_COMM_PAGE_BASE_ADDRESS+0x2a0) // spinlock_unlock()
  185 #define _COMM_PAGE_PTHREAD_GETSPECIFIC  (_COMM_PAGE_BASE_ADDRESS+0x2c0) // pthread_getspecific()
  186 #define _COMM_PAGE_GETTIMEOFDAY                 (_COMM_PAGE_BASE_ADDRESS+0x2e0) // used by gettimeofday()
  187 #define _COMM_PAGE_FLUSH_DCACHE                 (_COMM_PAGE_BASE_ADDRESS+0x4e0) // sys_dcache_flush()
  188 #define _COMM_PAGE_FLUSH_ICACHE                 (_COMM_PAGE_BASE_ADDRESS+0x520) // sys_icache_invalidate()
  189 #define _COMM_PAGE_PTHREAD_SELF                 (_COMM_PAGE_BASE_ADDRESS+0x580) // pthread_self()
  190 
  191 #define _COMM_PAGE_UNUSED4                              (_COMM_PAGE_BASE_ADDRESS+0x5a0) // 32 unused bytes
  192 
  193 #define _COMM_PAGE_RELINQUISH                   (_COMM_PAGE_BASE_ADDRESS+0x5c0) // used by spinlocks
  194  
  195 #define _COMM_PAGE_UNUSED5                              (_COMM_PAGE_BASE_ADDRESS+0x5e0) // 32 unused bytes
  196  
  197 #define _COMM_PAGE_BZERO                                (_COMM_PAGE_BASE_ADDRESS+0x600) // bzero()
  198 #define _COMM_PAGE_BCOPY                                (_COMM_PAGE_BASE_ADDRESS+0x780) // bcopy()
  199 #define _COMM_PAGE_MEMCPY                               (_COMM_PAGE_BASE_ADDRESS+0x7a0) // memcpy()
  200 #define _COMM_PAGE_MEMMOVE                              (_COMM_PAGE_BASE_ADDRESS+0x7a0) // memmove()
  201 
  202 #define _COMM_PAGE_COMPARE_AND_SWAP32B  (_COMM_PAGE_BASE_ADDRESS+0xf80) // compare-and-swap word w barrier
  203 #define _COMM_PAGE_COMPARE_AND_SWAP64B  (_COMM_PAGE_BASE_ADDRESS+0xfc0) // compare-and-swap doubleword w barrier
  204 
  205 #define _COMM_PAGE_MEMSET_PATTERN       (_COMM_PAGE_BASE_ADDRESS+0x1000)// used by nonzero memset()
  206 #define _COMM_PAGE_BIGCOPY                              (_COMM_PAGE_BASE_ADDRESS+0x1140)// very-long-operand copies
  207 
  208 #define _COMM_PAGE_END                                  (_COMM_PAGE_BASE_ADDRESS+0x1700)// end of commpage area
  209 
  210 #ifdef __ASSEMBLER__
  211 #ifdef __COMM_PAGE_SYMBOLS
  212 
  213 #define CREATE_COMM_PAGE_SYMBOL(symbol_name, symbol_address)            \
  214                                 .org    (symbol_address - _COMM_PAGE_BASE_ADDRESS) @\
  215 symbol_name: nop
  216 
  217         .text           // Required to make a well behaved symbol file
  218 
  219         CREATE_COMM_PAGE_SYMBOL(___compare_and_swap32, _COMM_PAGE_COMPARE_AND_SWAP32)
  220         CREATE_COMM_PAGE_SYMBOL(___compare_and_swap64, _COMM_PAGE_COMPARE_AND_SWAP64)
  221         CREATE_COMM_PAGE_SYMBOL(___atomic_enqueue, _COMM_PAGE_ENQUEUE)
  222         CREATE_COMM_PAGE_SYMBOL(___atomic_dequeue, _COMM_PAGE_DEQUEUE)
  223         CREATE_COMM_PAGE_SYMBOL(___memory_barrier, _COMM_PAGE_MEMORY_BARRIER)
  224         CREATE_COMM_PAGE_SYMBOL(___atomic_add32, _COMM_PAGE_ATOMIC_ADD32)
  225         CREATE_COMM_PAGE_SYMBOL(___atomic_add64, _COMM_PAGE_ATOMIC_ADD64)
  226         CREATE_COMM_PAGE_SYMBOL(___mach_absolute_time, _COMM_PAGE_ABSOLUTE_TIME)
  227         CREATE_COMM_PAGE_SYMBOL(___spin_lock_try, _COMM_PAGE_SPINLOCK_TRY)
  228         CREATE_COMM_PAGE_SYMBOL(___spin_lock, _COMM_PAGE_SPINLOCK_LOCK)
  229         CREATE_COMM_PAGE_SYMBOL(___spin_unlock, _COMM_PAGE_SPINLOCK_UNLOCK)
  230         CREATE_COMM_PAGE_SYMBOL(___pthread_getspecific, _COMM_PAGE_PTHREAD_GETSPECIFIC)
  231         CREATE_COMM_PAGE_SYMBOL(___gettimeofday, _COMM_PAGE_GETTIMEOFDAY)
  232         CREATE_COMM_PAGE_SYMBOL(___sys_dcache_flush, _COMM_PAGE_FLUSH_DCACHE)
  233         CREATE_COMM_PAGE_SYMBOL(___sys_icache_invalidate, _COMM_PAGE_FLUSH_ICACHE)
  234         CREATE_COMM_PAGE_SYMBOL(___pthread_self, _COMM_PAGE_PTHREAD_SELF)
  235         CREATE_COMM_PAGE_SYMBOL(___spin_lock_relinquish, _COMM_PAGE_RELINQUISH)
  236         CREATE_COMM_PAGE_SYMBOL(___bzero, _COMM_PAGE_BZERO)
  237         CREATE_COMM_PAGE_SYMBOL(___bcopy, _COMM_PAGE_BCOPY)
  238         CREATE_COMM_PAGE_SYMBOL(___memcpy, _COMM_PAGE_MEMCPY)
  239 //      CREATE_COMM_PAGE_SYMBOL(___memmove, _COMM_PAGE_MEMMOVE)
  240         CREATE_COMM_PAGE_SYMBOL(___compare_and_swap32b, _COMM_PAGE_COMPARE_AND_SWAP32B)
  241         CREATE_COMM_PAGE_SYMBOL(___compare_and_swap64b, _COMM_PAGE_COMPARE_AND_SWAP64B)
  242     CREATE_COMM_PAGE_SYMBOL(___memset_pattern, _COMM_PAGE_MEMSET_PATTERN)
  243         CREATE_COMM_PAGE_SYMBOL(___bigcopy, _COMM_PAGE_BIGCOPY)
  244         
  245         CREATE_COMM_PAGE_SYMBOL(___end_comm_page, _COMM_PAGE_END)
  246 
  247         .data           // Required to make a well behaved symbol file
  248         .long   0       // Required to make a well behaved symbol file
  249 
  250 #endif /* __COMM_PAGE_SYMBOLS */
  251 #endif /* __ASSEMBLER__ */
  252 
  253 #endif /* _PPC_CPU_CAPABILITIES_H */
  254 #endif /* PRIVATE */

Cache object: ff8d365f0d15b1529d135faa01d80530


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.