45 #include <sys/types.h>
71 if (new_symbol ==
NULL) {
72 perror(
"Unable to create new symbol");
75 memset(new_symbol, 0,
sizeof(*new_symbol));
76 new_symbol->
name = strdup(name);
78 stop(
"Unable to strdup symbol name", EX_SOFTWARE);
80 new_symbol->
count = 1;
87 if (symtable !=
NULL) {
90 key.data = symbol->
name;
92 symtable->del(symtable, &key, 0);
94 switch(symbol->
type) {
134 symtable = dbopen(
NULL,
138 if (symtable ==
NULL) {
139 perror(
"Symbol table creation failed");
148 if (symtable !=
NULL) {
152 while (symtable->seq(symtable, &key, &data, R_FIRST) == 0) {
155 memcpy(&stored_ptr, data.data,
sizeof(stored_ptr));
158 symtable->close(symtable);
174 key.data = (
void *)name;
177 if ((retval = symtable->get(symtable, &key, &data, 0)) != 0) {
179 perror(
"Symbol table get operation failed");
182 }
else if (retval == 1) {
187 data.data = &new_symbol;
188 data.size =
sizeof(new_symbol);
189 if (symtable->put(symtable, &key, &data,
191 perror(
"Symtable put failed");
196 perror(
"Unexpected return value from db get routine");
201 memcpy(&stored_ptr, data.data,
sizeof(stored_ptr));
203 data.data = &stored_ptr;
204 if (symtable->put(symtable, &key, &data, 0) !=0) {
205 perror(
"Symtable put failed");
217 while(curnode !=
NULL) {
231 if (newnode ==
NULL) {
232 stop(
"symlist_add: Unable to malloc symbol_node", EX_SOFTWARE);
241 switch(symbol->
type) {
253 stop(
"symlist_add: Invalid symbol type for sorting",
279 cursymbol =
SLIST_NEXT(curnode, links)->symbol;
306 while (node1 !=
NULL) {
316 symlist_t *symlist_src2)
320 *symlist_dest = *symlist_src1;
340 " * DO NOT EDIT - This file is automatically generated\n"
341 " * from the following source files:\n"
353 fprintf(dfile,
"\n#include \"%s\"\n\n", include_file);
363 "typedef int (%sreg_print_t)(u_int, u_int *, u_int);\n"
364 "typedef struct %sreg_parse_entry {\n"
368 "} %sreg_parse_entry_t;\n"
374 aic_print_reg_dump_start(FILE *dfile,
symbol_node_t *regnode)
380 "static const %sreg_parse_entry_t %s_parse_table[] = {\n",
386 aic_print_reg_dump_end(FILE *ofile, FILE *dfile,
393 if (lower_name ==
NULL)
394 stop(
"Unable to strdup symbol name", EX_SOFTWARE);
396 for (letter = lower_name; *letter !=
'\0'; letter++)
400 if (num_entries != 0)
408 "%s%s_print(u_int regvalue, u_int *cur_col, u_int wrap)\n"
410 " return (%sprint_register(%s%s, %d, \"%s\",\n"
411 " 0x%02x, regvalue, cur_col, wrap));\n"
417 num_entries != 0 ? regnode->
symbol->
name :
"NULL",
418 num_entries != 0 ?
"_parse_table" :
"",
425 "#if AIC_DEBUG_REGISTERS\n"
426 "%sreg_print_t %s%s_print;\n"
428 "#define %s%s_print(regvalue, cur_col, wrap) \\\n"
429 " %sprint_register(NULL, 0, \"%s\", 0x%02x, regvalue, cur_col, wrap)\n"
443 aic_print_reg_dump_entry(FILE *dfile,
symbol_node_t *curnode)
456 while (num_tabs-- > 0)
458 fprintf(dfile,
"0x%02x, 0x%02x }",
474 symlist_t download_constants;
476 symlist_t exported_labels;
482 int reg_count = 0, reg_used = 0;
485 if (symtable ==
NULL)
495 while (symtable->seq(symtable, &key, &data, flag) == 0) {
498 memcpy(&cursym, data.data,
sizeof(cursym));
499 switch(cursym->
type) {
560 if (num_entries == 0)
561 aic_print_reg_dump_start(dfile,
563 else if (dfile !=
NULL)
566 aic_print_reg_dump_entry(dfile, fieldnode);
568 aic_print_reg_dump_end(ofile, dfile,
569 curnode, num_entries);
576 fprintf(stderr,
"%s: %d of %d register definitions used\n",
appname,
577 reg_used, reg_count);
644 stop(
"symtable_dump: Invalid symbol type "
645 "encountered", EX_SOFTWARE);
648 fprintf(ofile,
"#define%s%-16s%s0x%02x\n",
660 fprintf(ofile,
"#define\t%-8s\t0x%02x\n",
666 fprintf(ofile,
"\n\n/* Downloaded Constant Definitions */\n");
673 fprintf(ofile,
"#define\t%-8s\t0x%02x\n",
678 fprintf(ofile,
"#define\tDOWNLOAD_CONST_COUNT\t0x%02x\n", i);
680 fprintf(ofile,
"\n\n/* Exported Labels */\n");
687 fprintf(ofile,
"#define\tLABEL_%-8s\t0x%02x\n",