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