• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3  *
4  * @APPLE_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. Please obtain a copy of the License at
10  * http://www.opensource.apple.com/apsl/ and read it before using this
11  * file.
12  *
13  * The Original Code and all software distributed under the License are
14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18  * Please see the License for the specific language governing rights and
19  * limitations under the License.
20  *
21  * @APPLE_LICENSE_HEADER_END@
22  */
23 #ifndef _MACH_O_ARCH_H_
24 #define _MACH_O_ARCH_H_
25 /*
26  * Copyright (c) 1997 Apple Computer, Inc.
27  *
28  * Functions that deal with information about architectures.
29  *
30  */
31 
32 #include <stdint.h>
33 #include <mach/machine.h>
34 #include <architecture/byte_order.h>
35 
36 /* The NXArchInfo structs contain the architectures symbolic name
37  * (such as "ppc"), its CPU type and CPU subtype as defined in
38  * mach/machine.h, the byte order for the architecture, and a
39  * describing string (such as "PowerPC").
40  * There will both be entries for specific CPUs (such as ppc604e) as
41  * well as generic "family" entries (such as ppc).
42  */
43 typedef struct {
44     const char *name;
45     cpu_type_t cputype;
46     cpu_subtype_t cpusubtype;
47     enum NXByteOrder byteorder;
48     const char *description;
49 } NXArchInfo;
50 
51 #if __cplusplus
52 extern "C" {
53 #endif /* __cplusplus */
54 
55 /* NXGetAllArchInfos() returns a pointer to an array of all known
56  * NXArchInfo structures.  The last NXArchInfo is marked by a NULL name.
57  */
58 extern const NXArchInfo *NXGetAllArchInfos(void);
59 
60 /* NXGetLocalArchInfo() returns the NXArchInfo for the local host, or NULL
61  * if none is known.
62  */
63 extern const NXArchInfo *NXGetLocalArchInfo(void);
64 
65 /* NXGetArchInfoFromName() and NXGetArchInfoFromCpuType() return the
66  * NXArchInfo from the architecture's name or cputype/cpusubtype
67  * combination.  A cpusubtype of CPU_SUBTYPE_MULTIPLE can be used
68  * to request the most general NXArchInfo known for the given cputype.
69  * NULL is returned if no matching NXArchInfo can be found.
70  */
71 extern const NXArchInfo *NXGetArchInfoFromName(const char *name);
72 extern const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype,
73 						  cpu_subtype_t cpusubtype);
74 
75 /* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of
76  * fat_arch structs and selects the best one that matches (if any) and returns
77  * a pointer to that fat_arch struct (or NULL).  The fat_arch structs must be
78  * in the host byte order and correct such that the fat_archs really points to
79  * enough memory for nfat_arch structs.  It is possible that this routine could
80  * fail if new cputypes or cpusubtypes are added and an old version of this
81  * routine is used.  But if there is an exact match between the cputype and
82  * cpusubtype and one of the fat_arch structs this routine will always succeed.
83  */
84 extern struct fat_arch *NXFindBestFatArch(cpu_type_t cputype,
85 					  cpu_subtype_t cpusubtype,
86 					  struct fat_arch *fat_archs,
87 					  uint32_t nfat_archs);
88 
89 /* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two
90  * different cpusubtypes for the specified cputype.  If the two cpusubtypes
91  * can't be combined (the specific subtypes are mutually exclusive) -1 is
92  * returned indicating it is an error to combine them.  This can also fail and
93  * return -1 if new cputypes or cpusubtypes are added and an old version of
94  * this routine is used.  But if the cpusubtypes are the same they can always
95  * be combined and this routine will return the cpusubtype pass in.
96  */
97 extern cpu_subtype_t NXCombineCpuSubtypes(cpu_type_t cputype,
98 					  cpu_subtype_t cpusubtype1,
99 					  cpu_subtype_t cpusubtype2);
100 
101 #if __cplusplus
102 }
103 #endif /* __cplusplus */
104 
105 #endif /* _MACH_O_ARCH_H_ */
106