annotate boot/arch.h @ 12:19d073459374

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