]> git.saurik.com Git - apple/libc.git/blob - ppc/sys/genassym.h
Libc-262.2.12.tar.gz
[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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * genassym.h -- macros of use with genassym.c and assymdefs.c
27 */
28
29 #import <architecture/ppc/reg_help.h>
30 #import <architecture/ppc/macro_help.h>
31
32 #define PRINT_OFFSET(ptr_type, field) \
33 MACRO_BEGIN \
34 print_define("", #ptr_type, #field); \
35 print_hex((unsigned) &(((ptr_type)0)->field)); \
36 MACRO_END
37
38 #define PRINT_BIT_FIELD(reg_type, field) \
39 MACRO_BEGIN \
40 reg_type __reg; \
41 CONTENTS(__reg) = 0; \
42 __reg.field = (typeof (__reg.field)) -1; \
43 print_define("", #reg_type, #field); \
44 print_hex(CONTENTS(__reg)); \
45 MACRO_END
46
47 #define PRINT_ENUM(item) \
48 MACRO_BEGIN \
49 print_define("", "", #item); \
50 print_hex((unsigned)item); \
51 MACRO_END
52
53 #define PRINT_DEFINE(macro) \
54 MACRO_BEGIN \
55 print_define("", "", #macro); \
56 print_str(STRINGIFY(macro)); \
57 MACRO_END
58
59 #define PRINT_CONSTANT(macro) \
60 MACRO_BEGIN \
61 print_define("", "", #macro); \
62 print_hex((unsigned)macro); \
63 MACRO_END
64
65 #define PRINT_REGADDR(macro) \
66 MACRO_BEGIN \
67 print_define("", "", #macro); \
68 print_hex((unsigned) &macro); \
69 MACRO_END
70
71 #define PRINT_REG_PAIR(struct_ptr, name0, name1) \
72 MACRO_BEGIN \
73 print_define("", #struct_ptr, #name0 "_" #name1); \
74 print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
75 MACRO_END
76
77 #define PRINT_BIT_POS(reg_type, field) \
78 MACRO_BEGIN \
79 reg_type __reg; \
80 CONTENTS(__reg) = 0; \
81 __reg.field = 1; \
82 print_define("", #reg_type, #field "_BIT"); \
83 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
84 MACRO_END
85
86 #define PRINT_FIELD_INFO(reg_type, field) \
87 MACRO_BEGIN \
88 reg_type __reg; \
89 CONTENTS(__reg) = 0; \
90 __reg.field = -1; \
91 print_define("", #reg_type, #field "_OFF"); \
92 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
93 print_define("", #reg_type, #field "_WIDTH"); \
94 print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\
95 MACRO_END
96
97 #define PRINT_L2_SIZE(type) \
98 MACRO_BEGIN \
99 print_define("L2_SIZEOF", #type, ""); \
100 print_dec((int) log2(sizeof(type), #type)); \
101 MACRO_END
102
103 #define PRINT_SIZEOF(type) \
104 MACRO_BEGIN \
105 print_define("SIZEOF", #type, ""); \
106 print_dec((int) sizeof(type)); \
107 MACRO_END
108
109 #define PRINT_L2_CONSTANT(macro) \
110 MACRO_BEGIN \
111 print_define("L2", "", #macro); \
112 print_dec((int) log2(macro, #macro)); \
113 MACRO_END
114
115 typedef enum {
116 MAJOR, MINOR
117 } cmt_level_t;
118
119 extern void comment(cmt_level_t level, const char *cmt);
120 extern void print_define(const char *prefix, const char *type_name,
121 const char *field);
122 extern void print_dec(int val);
123 extern void print_hex(unsigned val);
124 extern void print_str(const char *str);
125 extern unsigned bit_num(char *reg_type, char *field, unsigned bits);
126 extern unsigned field_width(char *reg_type, char *field, unsigned bits);
127 extern unsigned log2(unsigned val, char *type);
128 extern void assymdefs(void);
129