aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c')
-rw-r--r--drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c b/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c
index f1f448dff56..fcd357872b4 100644
--- a/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c
+++ b/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.c
@@ -77,6 +77,7 @@ symbol_create(char *name)
77 if (new_symbol->name == NULL) 77 if (new_symbol->name == NULL)
78 stop("Unable to strdup symbol name", EX_SOFTWARE); 78 stop("Unable to strdup symbol name", EX_SOFTWARE);
79 new_symbol->type = UNINITIALIZED; 79 new_symbol->type = UNINITIALIZED;
80 new_symbol->count = 1;
80 return (new_symbol); 81 return (new_symbol);
81} 82}
82 83
@@ -198,6 +199,12 @@ symtable_get(char *name)
198 } 199 }
199 } 200 }
200 memcpy(&stored_ptr, data.data, sizeof(stored_ptr)); 201 memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
202 stored_ptr->count++;
203 data.data = &stored_ptr;
204 if (symtable->put(symtable, &key, &data, /*flags*/0) !=0) {
205 perror("Symtable put failed");
206 exit(EX_SOFTWARE);
207 }
201 return (stored_ptr); 208 return (stored_ptr);
202} 209}
203 210
@@ -256,7 +263,7 @@ symlist_add(symlist_t *symlist, symbol_t *symbol, int how)
256 && (curnode->symbol->info.finfo->value > 263 && (curnode->symbol->info.finfo->value >
257 newnode->symbol->info.finfo->value)))) 264 newnode->symbol->info.finfo->value))))
258 || (!field && (curnode->symbol->info.rinfo->address > 265 || (!field && (curnode->symbol->info.rinfo->address >
259 newnode->symbol->info.rinfo->address))) { 266 newnode->symbol->info.rinfo->address))) {
260 SLIST_INSERT_HEAD(symlist, newnode, links); 267 SLIST_INSERT_HEAD(symlist, newnode, links);
261 return; 268 return;
262 } 269 }
@@ -271,7 +278,7 @@ symlist_add(symlist_t *symlist, symbol_t *symbol, int how)
271 278
272 cursymbol = SLIST_NEXT(curnode, links)->symbol; 279 cursymbol = SLIST_NEXT(curnode, links)->symbol;
273 if ((field 280 if ((field
274 && (cursymbol->type > symbol->type 281 && (cursymbol->type > symbol->type
275 || (cursymbol->type == symbol->type 282 || (cursymbol->type == symbol->type
276 && (cursymbol->info.finfo->value > 283 && (cursymbol->info.finfo->value >
277 symbol->info.finfo->value)))) 284 symbol->info.finfo->value))))
@@ -351,7 +358,7 @@ aic_print_reg_dump_types(FILE *ofile)
351{ 358{
352 if (ofile == NULL) 359 if (ofile == NULL)
353 return; 360 return;
354 361
355 fprintf(ofile, 362 fprintf(ofile,
356"typedef int (%sreg_print_t)(u_int, u_int *, u_int);\n" 363"typedef int (%sreg_print_t)(u_int, u_int *, u_int);\n"
357"typedef struct %sreg_parse_entry {\n" 364"typedef struct %sreg_parse_entry {\n"
@@ -370,7 +377,7 @@ aic_print_reg_dump_start(FILE *dfile, symbol_node_t *regnode)
370 return; 377 return;
371 378
372 fprintf(dfile, 379 fprintf(dfile,
373"static %sreg_parse_entry_t %s_parse_table[] = {\n", 380"static const %sreg_parse_entry_t %s_parse_table[] = {\n",
374 prefix, 381 prefix,
375 regnode->symbol->name); 382 regnode->symbol->name);
376} 383}
@@ -385,7 +392,7 @@ aic_print_reg_dump_end(FILE *ofile, FILE *dfile,
385 lower_name = strdup(regnode->symbol->name); 392 lower_name = strdup(regnode->symbol->name);
386 if (lower_name == NULL) 393 if (lower_name == NULL)
387 stop("Unable to strdup symbol name", EX_SOFTWARE); 394 stop("Unable to strdup symbol name", EX_SOFTWARE);
388 395
389 for (letter = lower_name; *letter != '\0'; letter++) 396 for (letter = lower_name; *letter != '\0'; letter++)
390 *letter = tolower(*letter); 397 *letter = tolower(*letter);
391 398
@@ -472,6 +479,7 @@ symtable_dump(FILE *ofile, FILE *dfile)
472 DBT key; 479 DBT key;
473 DBT data; 480 DBT data;
474 int flag; 481 int flag;
482 int reg_count = 0, reg_used = 0;
475 u_int i; 483 u_int i;
476 484
477 if (symtable == NULL) 485 if (symtable == NULL)
@@ -541,6 +549,9 @@ symtable_dump(FILE *ofile, FILE *dfile)
541 int num_entries; 549 int num_entries;
542 550
543 num_entries = 0; 551 num_entries = 0;
552 reg_count++;
553 if (curnode->symbol->count == 1)
554 break;
544 fields = &curnode->symbol->info.rinfo->fields; 555 fields = &curnode->symbol->info.rinfo->fields;
545 SLIST_FOREACH(fieldnode, fields, links) { 556 SLIST_FOREACH(fieldnode, fields, links) {
546 if (num_entries == 0) 557 if (num_entries == 0)
@@ -553,11 +564,14 @@ symtable_dump(FILE *ofile, FILE *dfile)
553 } 564 }
554 aic_print_reg_dump_end(ofile, dfile, 565 aic_print_reg_dump_end(ofile, dfile,
555 curnode, num_entries); 566 curnode, num_entries);
567 reg_used++;
556 } 568 }
557 default: 569 default:
558 break; 570 break;
559 } 571 }
560 } 572 }
573 fprintf(stderr, "%s: %d of %d register definitions used\n", appname,
574 reg_used, reg_count);
561 575
562 /* Fold in the masks and bits */ 576 /* Fold in the masks and bits */
563 while (SLIST_FIRST(&masks) != NULL) { 577 while (SLIST_FIRST(&masks) != NULL) {
@@ -646,7 +660,6 @@ symtable_dump(FILE *ofile, FILE *dfile)
646 free(curnode); 660 free(curnode);
647 } 661 }
648 662
649
650 fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n"); 663 fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
651 664
652 for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) { 665 for (i = 0; SLIST_FIRST(&download_constants) != NULL; i++) {