]> git.saurik.com Git - apple/libc.git/blob - ppc/sys/genassym.h
409770341402e9ba73a0dd0123a3ff106ca1be13
[apple/libc.git] / ppc / sys / genassym.h
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 /*
24 * genassym.h -- macros of use with genassym.c and assymdefs.c
25 */
26
27 #import <architecture/ppc/reg_help.h>
28 #import <architecture/ppc/macro_help.h>
29
30 #define PRINT_OFFSET(ptr_type, field) \
31 MACRO_BEGIN \
32 print_define("", #ptr_type, #field); \
33 print_hex((unsigned) &(((ptr_type)0)->field)); \
34 MACRO_END
35
36 #define PRINT_BIT_FIELD(reg_type, field) \
37 MACRO_BEGIN \
38 reg_type __reg; \
39 CONTENTS(__reg) = 0; \
40 __reg.field = (typeof (__reg.field)) -1; \
41 print_define("", #reg_type, #field); \
42 print_hex(CONTENTS(__reg)); \
43 MACRO_END
44
45 #define PRINT_ENUM(item) \
46 MACRO_BEGIN \
47 print_define("", "", #item); \
48 print_hex((unsigned)item); \
49 MACRO_END
50
51 #define PRINT_DEFINE(macro) \
52 MACRO_BEGIN \
53 print_define("", "", #macro); \
54 print_str(STRINGIFY(macro)); \
55 MACRO_END
56
57 #define PRINT_CONSTANT(macro) \
58 MACRO_BEGIN \
59 print_define("", "", #macro); \
60 print_hex((unsigned)macro); \
61 MACRO_END
62
63 #define PRINT_REGADDR(macro) \
64 MACRO_BEGIN \
65 print_define("", "", #macro); \
66 print_hex((unsigned) &macro); \
67 MACRO_END
68
69 #define PRINT_REG_PAIR(struct_ptr, name0, name1) \
70 MACRO_BEGIN \
71 print_define("", #struct_ptr, #name0 "_" #name1); \
72 print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
73 MACRO_END
74
75 #define PRINT_BIT_POS(reg_type, field) \
76 MACRO_BEGIN \
77 reg_type __reg; \
78 CONTENTS(__reg) = 0; \
79 __reg.field = 1; \
80 print_define("", #reg_type, #field "_BIT"); \
81 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
82 MACRO_END
83
84 #define PRINT_FIELD_INFO(reg_type, field) \
85 MACRO_BEGIN \
86 reg_type __reg; \
87 CONTENTS(__reg) = 0; \
88 __reg.field = -1; \
89 print_define("", #reg_type, #field "_OFF"); \
90 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
91 print_define("", #reg_type, #field "_WIDTH"); \
92 print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\
93 MACRO_END
94
95 #define PRINT_L2_SIZE(type) \
96 MACRO_BEGIN \
97 print_define("L2_SIZEOF", #type, ""); \
98 print_dec((int) log2(sizeof(type), #type)); \
99 MACRO_END
100
101 #define PRINT_SIZEOF(type) \
102 MACRO_BEGIN \
103 print_define("SIZEOF", #type, ""); \
104 print_dec((int) sizeof(type)); \
105 MACRO_END
106
107 #define PRINT_L2_CONSTANT(macro) \
108 MACRO_BEGIN \
109 print_define("L2", "", #macro); \
110 print_dec((int) log2(macro, #macro)); \
111 MACRO_END
112
113 typedef enum {
114 MAJOR, MINOR
115 } cmt_level_t;
116
117 extern void comment(cmt_level_t level, const char *cmt);
118 extern void print_define(const char *prefix, const char *type_name,
119 const char *field);
120 extern void print_dec(int val);
121 extern void print_hex(unsigned val);
122 extern void print_str(const char *str);
123 extern unsigned bit_num(char *reg_type, char *field, unsigned bits);
124 extern unsigned field_width(char *reg_type, char *field, unsigned bits);
125 extern unsigned log2(unsigned val, char *type);
126 extern void assymdefs(void);
127