Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | /* * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 1.1 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.apple.com/publicsource and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* * genassym.h -- macros of use with genassym.c and assymdefs.c */ #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); |