#import <architecture/ppc/reg_help.h>
#import <architecture/ppc/macro_help.h>
#define PRINT_OFFSET(ptr_type, field) \
MACRO_BEGIN \
print_define("", #ptr_type, #field); \
print_hex((unsigned) &(((ptr_type)0)->field)); \
MACRO_END
#define PRINT_BIT_FIELD(reg_type, field) \
MACRO_BEGIN \
reg_type __reg; \
CONTENTS(__reg) = 0; \
__reg.field = (typeof (__reg.field)) -1; \
print_define("", #reg_type, #field); \
print_hex(CONTENTS(__reg)); \
MACRO_END
#define PRINT_ENUM(item) \
MACRO_BEGIN \
print_define("", "", #item); \
print_hex((unsigned)item); \
MACRO_END
#define PRINT_DEFINE(macro) \
MACRO_BEGIN \
print_define("", "", #macro); \
print_str(STRINGIFY(macro)); \
MACRO_END
#define PRINT_CONSTANT(macro) \
MACRO_BEGIN \
print_define("", "", #macro); \
print_hex((unsigned)macro); \
MACRO_END
#define PRINT_REGADDR(macro) \
MACRO_BEGIN \
print_define("", "", #macro); \
print_hex((unsigned) ¯o); \
MACRO_END
#define PRINT_REG_PAIR(struct_ptr, name0, name1) \
MACRO_BEGIN \
print_define("", #struct_ptr, #name0 "_" #name1); \
print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
MACRO_END
#define PRINT_BIT_POS(reg_type, field) \
MACRO_BEGIN \
reg_type __reg; \
CONTENTS(__reg) = 0; \
__reg.field = 1; \
print_define("", #reg_type, #field "_BIT"); \
print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
MACRO_END
#define PRINT_FIELD_INFO(reg_type, field) \
MACRO_BEGIN \
reg_type __reg; \
CONTENTS(__reg) = 0; \
__reg.field = -1; \
print_define("", #reg_type, #field "_OFF"); \
print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
print_define("", #reg_type, #field "_WIDTH"); \
print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\
MACRO_END
#define PRINT_L2_SIZE(type) \
MACRO_BEGIN \
print_define("L2_SIZEOF", #type, ""); \
print_dec((int) log2(sizeof(type), #type)); \
MACRO_END
#define PRINT_SIZEOF(type) \
MACRO_BEGIN \
print_define("SIZEOF", #type, ""); \
print_dec((int) sizeof(type)); \
MACRO_END
#define PRINT_L2_CONSTANT(macro) \
MACRO_BEGIN \
print_define("L2", "", #macro); \
print_dec((int) log2(macro, #macro)); \
MACRO_END
typedef enum {
MAJOR, MINOR
} cmt_level_t;
extern void comment(cmt_level_t level, const char *cmt);
extern void print_define(const char *prefix, const char *type_name,
const char *field);
extern void print_dec(int val);
extern void print_hex(unsigned val);
extern void print_str(const char *str);
extern unsigned bit_num(char *reg_type, char *field, unsigned bits);
extern unsigned field_width(char *reg_type, char *field, unsigned bits);
extern unsigned log2(unsigned val, char *type);
extern void assymdefs(void);