]> git.saurik.com Git - apple/libc.git/blame - ppc/sys/genassym.h
Libc-320.tar.gz
[apple/libc.git] / ppc / sys / genassym.h
CommitLineData
e9ce8d39
A
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
734aad71 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
e9ce8d39 7 *
734aad71
A
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
e9ce8d39
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
734aad71
A
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.
e9ce8d39
A
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) \
33MACRO_BEGIN \
34 print_define("", #ptr_type, #field); \
35 print_hex((unsigned) &(((ptr_type)0)->field)); \
36MACRO_END
37
38#define PRINT_BIT_FIELD(reg_type, field) \
39MACRO_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)); \
45MACRO_END
46
47#define PRINT_ENUM(item) \
48MACRO_BEGIN \
49 print_define("", "", #item); \
50 print_hex((unsigned)item); \
51MACRO_END
52
53#define PRINT_DEFINE(macro) \
54MACRO_BEGIN \
55 print_define("", "", #macro); \
56 print_str(STRINGIFY(macro)); \
57MACRO_END
58
59#define PRINT_CONSTANT(macro) \
60MACRO_BEGIN \
61 print_define("", "", #macro); \
62 print_hex((unsigned)macro); \
63MACRO_END
64
65#define PRINT_REGADDR(macro) \
66MACRO_BEGIN \
67 print_define("", "", #macro); \
68 print_hex((unsigned) &macro); \
69MACRO_END
70
71#define PRINT_REG_PAIR(struct_ptr, name0, name1) \
72MACRO_BEGIN \
73 print_define("", #struct_ptr, #name0 "_" #name1); \
74 print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
75MACRO_END
76
77#define PRINT_BIT_POS(reg_type, field) \
78MACRO_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))); \
84MACRO_END
85
86#define PRINT_FIELD_INFO(reg_type, field) \
87MACRO_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)));\
95MACRO_END
96
97#define PRINT_L2_SIZE(type) \
98MACRO_BEGIN \
99 print_define("L2_SIZEOF", #type, ""); \
100 print_dec((int) log2(sizeof(type), #type)); \
101MACRO_END
102
103#define PRINT_SIZEOF(type) \
104MACRO_BEGIN \
105 print_define("SIZEOF", #type, ""); \
106 print_dec((int) sizeof(type)); \
107MACRO_END
108
109#define PRINT_L2_CONSTANT(macro) \
110MACRO_BEGIN \
111 print_define("L2", "", #macro); \
112 print_dec((int) log2(macro, #macro)); \
113MACRO_END
114
115typedef enum {
116 MAJOR, MINOR
117} cmt_level_t;
118
119extern void comment(cmt_level_t level, const char *cmt);
120extern void print_define(const char *prefix, const char *type_name,
121 const char *field);
122extern void print_dec(int val);
123extern void print_hex(unsigned val);
124extern void print_str(const char *str);
125extern unsigned bit_num(char *reg_type, char *field, unsigned bits);
126extern unsigned field_width(char *reg_type, char *field, unsigned bits);
127extern unsigned log2(unsigned val, char *type);
128extern void assymdefs(void);
129