]>
Commit | Line | Data |
---|---|---|
e9ce8d39 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This 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 OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * genassym.h -- macros of use with genassym.c and assymdefs.c | |
24 | */ | |
25 | ||
26 | #import <architecture/ppc/reg_help.h> | |
27 | #import <architecture/ppc/macro_help.h> | |
28 | ||
29 | #define PRINT_OFFSET(ptr_type, field) \ | |
30 | MACRO_BEGIN \ | |
31 | print_define("", #ptr_type, #field); \ | |
32 | print_hex((unsigned) &(((ptr_type)0)->field)); \ | |
33 | MACRO_END | |
34 | ||
35 | #define PRINT_BIT_FIELD(reg_type, field) \ | |
36 | MACRO_BEGIN \ | |
37 | reg_type __reg; \ | |
38 | CONTENTS(__reg) = 0; \ | |
39 | __reg.field = (typeof (__reg.field)) -1; \ | |
40 | print_define("", #reg_type, #field); \ | |
41 | print_hex(CONTENTS(__reg)); \ | |
42 | MACRO_END | |
43 | ||
44 | #define PRINT_ENUM(item) \ | |
45 | MACRO_BEGIN \ | |
46 | print_define("", "", #item); \ | |
47 | print_hex((unsigned)item); \ | |
48 | MACRO_END | |
49 | ||
50 | #define PRINT_DEFINE(macro) \ | |
51 | MACRO_BEGIN \ | |
52 | print_define("", "", #macro); \ | |
53 | print_str(STRINGIFY(macro)); \ | |
54 | MACRO_END | |
55 | ||
56 | #define PRINT_CONSTANT(macro) \ | |
57 | MACRO_BEGIN \ | |
58 | print_define("", "", #macro); \ | |
59 | print_hex((unsigned)macro); \ | |
60 | MACRO_END | |
61 | ||
62 | #define PRINT_REGADDR(macro) \ | |
63 | MACRO_BEGIN \ | |
64 | print_define("", "", #macro); \ | |
65 | print_hex((unsigned) ¯o); \ | |
66 | MACRO_END | |
67 | ||
68 | #define PRINT_REG_PAIR(struct_ptr, name0, name1) \ | |
69 | MACRO_BEGIN \ | |
70 | print_define("", #struct_ptr, #name0 "_" #name1); \ | |
71 | print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \ | |
72 | MACRO_END | |
73 | ||
74 | #define PRINT_BIT_POS(reg_type, field) \ | |
75 | MACRO_BEGIN \ | |
76 | reg_type __reg; \ | |
77 | CONTENTS(__reg) = 0; \ | |
78 | __reg.field = 1; \ | |
79 | print_define("", #reg_type, #field "_BIT"); \ | |
80 | print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \ | |
81 | MACRO_END | |
82 | ||
83 | #define PRINT_FIELD_INFO(reg_type, field) \ | |
84 | MACRO_BEGIN \ | |
85 | reg_type __reg; \ | |
86 | CONTENTS(__reg) = 0; \ | |
87 | __reg.field = -1; \ | |
88 | print_define("", #reg_type, #field "_OFF"); \ | |
89 | print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \ | |
90 | print_define("", #reg_type, #field "_WIDTH"); \ | |
91 | print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\ | |
92 | MACRO_END | |
93 | ||
94 | #define PRINT_L2_SIZE(type) \ | |
95 | MACRO_BEGIN \ | |
96 | print_define("L2_SIZEOF", #type, ""); \ | |
97 | print_dec((int) log2(sizeof(type), #type)); \ | |
98 | MACRO_END | |
99 | ||
100 | #define PRINT_SIZEOF(type) \ | |
101 | MACRO_BEGIN \ | |
102 | print_define("SIZEOF", #type, ""); \ | |
103 | print_dec((int) sizeof(type)); \ | |
104 | MACRO_END | |
105 | ||
106 | #define PRINT_L2_CONSTANT(macro) \ | |
107 | MACRO_BEGIN \ | |
108 | print_define("L2", "", #macro); \ | |
109 | print_dec((int) log2(macro, #macro)); \ | |
110 | MACRO_END | |
111 | ||
112 | typedef enum { | |
113 | MAJOR, MINOR | |
114 | } cmt_level_t; | |
115 | ||
116 | extern void comment(cmt_level_t level, const char *cmt); | |
117 | extern void print_define(const char *prefix, const char *type_name, | |
118 | const char *field); | |
119 | extern void print_dec(int val); | |
120 | extern void print_hex(unsigned val); | |
121 | extern void print_str(const char *str); | |
122 | extern unsigned bit_num(char *reg_type, char *field, unsigned bits); | |
123 | extern unsigned field_width(char *reg_type, char *field, unsigned bits); | |
124 | extern unsigned log2(unsigned val, char *type); | |
125 | extern void assymdefs(void); | |
126 |