From 32da3127a31d0d6e1f0a0d7905c8258beba0a013 Mon Sep 17 00:00:00 2001 From: "Justin T. Gibbs" Date: Sat, 16 Sep 2000 20:02:39 +0000 Subject: [PATCH] Move aicasm to its own subdirectory. --- sys/dev/aic7xxx/aicasm/Makefile | 6 +- sys/dev/aic7xxx/aicasm/aicasm.c | 17 ++-- sys/dev/aic7xxx/aicasm/aicasm.h | 6 ++ sys/dev/aic7xxx/aicasm/aicasm_gram.y | 100 +++++++++------------- sys/dev/aic7xxx/aicasm/aicasm_insformat.h | 8 +- sys/dev/aic7xxx/aicasm/aicasm_scan.l | 25 ++++-- sys/dev/aic7xxx/aicasm/aicasm_symbol.c | 39 ++++----- sys/dev/aic7xxx/aicasm/aicasm_symbol.h | 14 ++- 8 files changed, 110 insertions(+), 105 deletions(-) diff --git a/sys/dev/aic7xxx/aicasm/Makefile b/sys/dev/aic7xxx/aicasm/Makefile index c5575a8e7e88..acd6a0cc5ba3 100644 --- a/sys/dev/aic7xxx/aicasm/Makefile +++ b/sys/dev/aic7xxx/aicasm/Makefile @@ -1,3 +1,5 @@ +# $Id$ +# # $FreeBSD$ PROG= aicasm @@ -19,12 +21,12 @@ LDADD+= -ll DEPENDFILE= .endif -CFLAGS+= -nostdinc -I${.CURDIR}/../.. -I. -I/usr/include +CFLAGS+= -nostdinc -I${.CURDIR}/../../.. -I. -I/usr/include NOMAN= noman .ifdef DEBUG CFLAGS+= -DDEBUG -g -YFLAGS+= -t +YFLAGS+= -t -v LFLAGS+= -d .endif diff --git a/sys/dev/aic7xxx/aicasm/aicasm.c b/sys/dev/aic7xxx/aicasm/aicasm.c index 374e86c79ca2..f17218fb3b26 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm.c +++ b/sys/dev/aic7xxx/aicasm/aicasm.c @@ -28,6 +28,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ #include @@ -82,12 +84,12 @@ extern int yy_flex_debug; extern int yydebug; #endif extern FILE *yyin; -extern int yyparse __P((void)); +extern int yyparse(void); + +int main(int argc, char *argv[]); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { extern char *optarg; extern int optind; @@ -350,7 +352,7 @@ ahc_patch%d_func(struct ahc_softc *ahc) } fprintf(ofile, -"typedef int patch_func_t __P((struct ahc_softc *)); +"typedef int patch_func_t (struct ahc_softc *); struct patch { patch_func_t *patch_func; uint32_t begin :10, @@ -462,6 +464,7 @@ output_listing(char *ifilename) cur_func = SLIST_NEXT(cur_func, links)) func_count++; + func_values = NULL; if (func_count != 0) { func_values = (int *)malloc(func_count * sizeof(int)); @@ -589,9 +592,7 @@ check_patch(patch_t **start_patch, int start_instr, * terminating the program. */ void -stop(string, err_code) - const char *string; - int err_code; +stop(const char *string, int err_code) { if (string != NULL) { fprintf(stderr, "%s: ", appname); diff --git a/sys/dev/aic7xxx/aicasm/aicasm.h b/sys/dev/aic7xxx/aicasm/aicasm.h index 9faecd0f4f02..6a3400fda64f 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm.h +++ b/sys/dev/aic7xxx/aicasm/aicasm.h @@ -28,10 +28,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ +#ifdef __linux__ +#include "../queue.h" +#else #include +#endif #ifndef TRUE #define TRUE 1 diff --git a/sys/dev/aic7xxx/aicasm/aicasm_gram.y b/sys/dev/aic7xxx/aicasm/aicasm_gram.y index 5731f674bcdf..8a602637145b 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm_gram.y +++ b/sys/dev/aic7xxx/aicasm/aicasm_gram.y @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ @@ -38,7 +40,11 @@ #include #include +#ifdef __linux__ +#include "../queue.h" +#else #include +#endif #include "aicasm.h" #include "aicasm_symbol.h" @@ -57,24 +63,21 @@ static int instruction_ptr; static int sram_or_scb_offset; static int download_constant_count; -static void process_bitmask __P((int mask_type, symbol_t *sym, int mask)); -static void initialize_symbol __P((symbol_t *symbol)); -static void process_register __P((symbol_t **p_symbol)); -static void format_1_instr __P((int opcode, symbol_ref_t *dest, - expression_t *immed, symbol_ref_t *src, - int ret)); -static void format_2_instr __P((int opcode, symbol_ref_t *dest, - expression_t *places, symbol_ref_t *src, - int ret)); -static void format_3_instr __P((int opcode, symbol_ref_t *src, - expression_t *immed, symbol_ref_t *address)); -static void test_readable_symbol __P((symbol_t *symbol)); -static void test_writable_symbol __P((symbol_t *symbol)); -static void type_check __P((symbol_t *symbol, expression_t *expression, - int and_op)); -static void make_expression __P((expression_t *immed, int value)); -static void add_conditional __P((symbol_t *symbol)); -static int is_download_const __P((expression_t *immed)); +static void process_bitmask(int mask_type, symbol_t *sym, int mask); +static void initialize_symbol(symbol_t *symbol); +static void process_register(symbol_t **p_symbol); +static void format_1_instr(int opcode, symbol_ref_t *dest, + expression_t *immed, symbol_ref_t *src, int ret); +static void format_2_instr(int opcode, symbol_ref_t *dest, + expression_t *places, symbol_ref_t *src, int ret); +static void format_3_instr(int opcode, symbol_ref_t *src, + expression_t *immed, symbol_ref_t *address); +static void test_readable_symbol(symbol_t *symbol); +static void test_writable_symbol(symbol_t *symbol); +static void type_check(symbol_t *symbol, expression_t *expression, int and_op); +static void make_expression(expression_t *immed, int value); +static void add_conditional(symbol_t *symbol); +static int is_download_const(expression_t *immed); #define YYDEBUG 1 #define SRAM_SYMNAME "SRAM_BASE" @@ -530,6 +533,8 @@ scb: } cur_symbol->type = SCBLOC; initialize_symbol(cur_symbol); + /* 64 bytes of SCB space */ + cur_symbol->info.rinfo->size = 64; } reg_address { @@ -750,7 +755,6 @@ conditional: '}' { scope_t *scope_context; - scope_t *last_scope; scope_context = SLIST_FIRST(&scope_stack); if (scope_context->type == SCOPE_ROOT) { @@ -999,10 +1003,7 @@ code: %% static void -process_bitmask(mask_type, sym, mask) - int mask_type; - symbol_t *sym; - int mask; +process_bitmask(int mask_type, symbol_t *sym, int mask) { /* * Add the current register to its @@ -1047,8 +1048,7 @@ process_bitmask(mask_type, sym, mask) } static void -initialize_symbol(symbol) - symbol_t *symbol; +initialize_symbol(symbol_t *symbol) { switch (symbol->type) { case UNINITIALIZED: @@ -1129,8 +1129,7 @@ initialize_symbol(symbol) } static void -process_register(p_symbol) - symbol_t **p_symbol; +process_register(symbol_t **p_symbol) { char buf[255]; symbol_t *symbol = *p_symbol; @@ -1153,12 +1152,8 @@ process_register(p_symbol) } static void -format_1_instr(opcode, dest, immed, src, ret) - int opcode; - symbol_ref_t *dest; - expression_t *immed; - symbol_ref_t *src; - int ret; +format_1_instr(int opcode, symbol_ref_t *dest, expression_t *immed, + symbol_ref_t *src, int ret) { struct instruction *instr; struct ins_format1 *f1_instr; @@ -1192,12 +1187,8 @@ format_1_instr(opcode, dest, immed, src, ret) } static void -format_2_instr(opcode, dest, places, src, ret) - int opcode; - symbol_ref_t *dest; - expression_t *places; - symbol_ref_t *src; - int ret; +format_2_instr(int opcode, symbol_ref_t *dest, expression_t *places, + symbol_ref_t *src, int ret) { struct instruction *instr; struct ins_format2 *f2_instr; @@ -1257,11 +1248,8 @@ format_2_instr(opcode, dest, places, src, ret) } static void -format_3_instr(opcode, src, immed, address) - int opcode; - symbol_ref_t *src; - expression_t *immed; - symbol_ref_t *address; +format_3_instr(int opcode, symbol_ref_t *src, + expression_t *immed, symbol_ref_t *address) { struct instruction *instr; struct ins_format3 *f3_instr; @@ -1299,8 +1287,7 @@ format_3_instr(opcode, src, immed, address) } static void -test_readable_symbol(symbol) - symbol_t *symbol; +test_readable_symbol(symbol_t *symbol) { if (symbol->info.rinfo->mode == WO) { stop("Write Only register specified as source", @@ -1310,8 +1297,7 @@ test_readable_symbol(symbol) } static void -test_writable_symbol(symbol) - symbol_t *symbol; +test_writable_symbol(symbol_t *symbol) { if (symbol->info.rinfo->mode == RO) { stop("Read Only register specified as destination", @@ -1321,10 +1307,7 @@ test_writable_symbol(symbol) } static void -type_check(symbol, expression, opcode) - symbol_t *symbol; - expression_t *expression; - int opcode; +type_check(symbol_t *symbol, expression_t *expression, int opcode) { symbol_node_t *node; int and_op; @@ -1373,17 +1356,14 @@ type_check(symbol, expression, opcode) } static void -make_expression(immed, value) - expression_t *immed; - int value; +make_expression(expression_t *immed, int value) { SLIST_INIT(&immed->referenced_syms); immed->value = value & 0xff; } static void -add_conditional(symbol) - symbol_t *symbol; +add_conditional(symbol_t *symbol) { static int numfuncs; @@ -1420,15 +1400,13 @@ add_conditional(symbol) } void -yyerror(string) - const char *string; +yyerror(const char *string) { stop(string, EX_DATAERR); } static int -is_download_const(immed) - expression_t *immed; +is_download_const(expression_t *immed) { if ((immed->referenced_syms.slh_first != NULL) && (immed->referenced_syms.slh_first->symbol->type == DOWNLOAD_CONST)) diff --git a/sys/dev/aic7xxx/aicasm/aicasm_insformat.h b/sys/dev/aic7xxx/aicasm/aicasm_insformat.h index 64667472b0ae..c729e573b4aa 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm_insformat.h +++ b/sys/dev/aic7xxx/aicasm/aicasm_insformat.h @@ -29,10 +29,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ +#if linux +#include +#else #include +#endif struct ins_format1 { #if BYTE_ORDER == LITTLE_ENDIAN @@ -90,7 +96,7 @@ union ins_formats { struct ins_format1 format1; struct ins_format2 format2; struct ins_format3 format3; - uint8_t bytes[4]; + uint8_t bytes[4]; uint32_t integer; }; struct instruction { diff --git a/sys/dev/aic7xxx/aicasm/aicasm_scan.l b/sys/dev/aic7xxx/aicasm/aicasm_scan.l index 48170d68154d..a7a72605d8ef 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm_scan.l +++ b/sys/dev/aic7xxx/aicasm/aicasm_scan.l @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ @@ -38,7 +40,11 @@ #include #include #include +#ifdef __linux__ +#include "../queue.h" +#else #include +#endif #include "aicasm.h" #include "aicasm_symbol.h" @@ -87,11 +93,20 @@ if[ \t]*\( { } } \n { ++yylineno; } -[^()\n]+ { +[^()\n]+ { char *yptr = yytext; - while (*yptr != '\0') - *string_buf_ptr++ = *yptr++; + while (*yptr != '\0') { + /* Remove duplicate spaces */ + if (*yptr == '\t') + *yptr = ' '; + if (*yptr == ' ' + && string_buf_ptr != string_buf + && string_buf_ptr[-1] == ' ') + yptr++; + else + *string_buf_ptr++ = *yptr++; + } } {SPACE} ; @@ -210,9 +225,7 @@ typedef struct include { SLIST_HEAD(, include) include_stack; void -include_file(file_name, type) - char *file_name; - include_type type; +include_file(char *file_name, include_type type) { FILE *newfile; include_t *include; diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c index 43440ea4f40f..4f5be1eccd65 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c +++ b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c @@ -28,13 +28,18 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ - #include +#ifdef __linux__ +#include +#else #include +#endif #include #include #include @@ -47,8 +52,7 @@ static DB *symtable; symbol_t * -symbol_create(name) - char *name; +symbol_create(char *name) { symbol_t *new_symbol; @@ -64,8 +68,7 @@ symbol_create(name) } void -symbol_delete(symbol) - symbol_t *symbol; +symbol_delete(symbol_t *symbol) { if (symtable != NULL) { DBT key; @@ -145,8 +148,7 @@ symtable_close() * if a lookup fails. */ symbol_t * -symtable_get(name) - char *name; +symtable_get(char *name) { symbol_t *stored_ptr; DBT key; @@ -185,9 +187,7 @@ symtable_get(name) } symbol_node_t * -symlist_search(symlist, symname) - symlist_t *symlist; - char *symname; +symlist_search(symlist_t *symlist, char *symname) { symbol_node_t *curnode; @@ -201,10 +201,7 @@ symlist_search(symlist, symname) } void -symlist_add(symlist, symbol, how) - symlist_t *symlist; - symbol_t *symbol; - int how; +symlist_add(symlist_t *symlist, symbol_t *symbol, int how) { symbol_node_t *newnode; @@ -270,8 +267,7 @@ symlist_add(symlist, symbol, how) } void -symlist_free(symlist) - symlist_t *symlist; +symlist_free(symlist_t *symlist) { symbol_node_t *node1, *node2; @@ -285,10 +281,8 @@ symlist_free(symlist) } void -symlist_merge(symlist_dest, symlist_src1, symlist_src2) - symlist_t *symlist_dest; - symlist_t *symlist_src1; - symlist_t *symlist_src2; +symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1, + symlist_t *symlist_src2) { symbol_node_t *node; @@ -304,8 +298,7 @@ symlist_merge(symlist_dest, symlist_src1, symlist_src2) } void -symtable_dump(ofile) - FILE *ofile; +symtable_dump(FILE *ofile) { /* * Sort the registers by address with a simple insertion sort. @@ -400,7 +393,7 @@ symtable_dump(ofile) */\n"); while (registers.slh_first != NULL) { symbol_node_t *curnode; - uint8_t value; + u_int8_t value; char *tab_str; char *tab_str2; diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h index 37f5e7f66664..8a904c9712a4 100644 --- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h +++ b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h @@ -28,10 +28,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $Id$ + * * $FreeBSD$ */ +#ifdef __linux__ +#include "../queue.h" +#else #include +#endif typedef enum { UNINITIALIZED, @@ -54,10 +60,10 @@ typedef enum { }amode_t; struct reg_info { - uint8_t address; + u_int8_t address; int size; amode_t mode; - uint8_t valid_bitmask; + u_int8_t valid_bitmask; int typecheck_masks; }; @@ -65,11 +71,11 @@ typedef SLIST_HEAD(symlist, symbol_node) symlist_t; struct mask_info { symlist_t symrefs; - uint8_t mask; + u_int8_t mask; }; struct const_info { - uint8_t value; + u_int8_t value; int define; };