diff options
Diffstat (limited to 'sys/dev/microcode/aic7xxx')
-rw-r--r-- | sys/dev/microcode/aic7xxx/Makefile | 8 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aic7xxx.reg | 25 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aic7xxx.seq | 37 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aic7xxx_seq.h | 528 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm.c | 134 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm.h | 42 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm_gram.y | 564 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm_macro_gram.y | 160 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm_macro_scan.l | 150 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm_scan.l | 321 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm_symbol.c | 77 | ||||
-rw-r--r-- | sys/dev/microcode/aic7xxx/aicasm_symbol.h | 60 |
12 files changed, 1558 insertions, 548 deletions
diff --git a/sys/dev/microcode/aic7xxx/Makefile b/sys/dev/microcode/aic7xxx/Makefile index f4fa35493ee..1234df894d6 100644 --- a/sys/dev/microcode/aic7xxx/Makefile +++ b/sys/dev/microcode/aic7xxx/Makefile @@ -1,15 +1,15 @@ -# $OpenBSD: Makefile,v 1.4 2002/06/28 00:34:54 smurph Exp $ +# $OpenBSD: Makefile,v 1.5 2002/06/30 18:25:58 smurph Exp $ # $FreeBSD: src/sys/dev/aic7xxx/Makefile,v 1.6 1999/08/28 00:41:22 peter Exp $ PROG= aicasm CSRCS= aicasm.c aicasm_symbol.c -GENSRCS= aicasm_gram.c aicasm_scan.c +GENSRCS= aicasm_gram.c aicasm_scan.c aicasm_macro_gram.c aicasm_macro_scan.c GENHDRS= y.tab.h SRCS= ${GENSRCS} ${CSRCS} -CLEANFILES+= ${GENSRCS} ${GENHDRS} y.output +CLEANFILES+= ${GENSRCS} ${GENHDRS} y.output aic7xxxreg.h DPADD+= ${LIBL} LDADD+= -ll @@ -21,6 +21,8 @@ DEPENDFILE= .endif CFLAGS+= -I/usr/include -I. +YFLAGS= ${.TARGET:M*macro*:S/$(.TARGET)/-p mm/} -d +LFLAGS+= ${.TARGET:M*macro*:S/$(.TARGET)/-olex.yy.c/} ${.TARGET:M*macro*:S/$(.TARGET)/-Pmm/} NOMAN= noman .ifdef DEBUG diff --git a/sys/dev/microcode/aic7xxx/aic7xxx.reg b/sys/dev/microcode/aic7xxx/aic7xxx.reg index a4b50d7e075..481cb99aca0 100644 --- a/sys/dev/microcode/aic7xxx/aic7xxx.reg +++ b/sys/dev/microcode/aic7xxx/aic7xxx.reg @@ -1,4 +1,4 @@ -/* $OpenBSD: aic7xxx.reg,v 1.5 2002/06/28 00:34:54 smurph Exp $ */ +/* $OpenBSD: aic7xxx.reg,v 1.6 2002/06/30 18:25:58 smurph Exp $ */ /* * Aic7xxx register and scratch ram definitions. * @@ -32,7 +32,7 @@ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.reg,v 1.39 2001/07/18 21:39:47 gibbs Exp $ */ -VERSION = "$Id: aic7xxx.reg,v 1.5 2002/06/28 00:34:54 smurph Exp $" +VERSION = "$Id: aic7xxx.reg,v 1.6 2002/06/30 18:25:58 smurph Exp $" /* * This file is processed by the aic7xxx_asm utility for use in assembling @@ -1002,7 +1002,8 @@ register SFUNCT { * SCB Definition (p. 5-4) */ scb { - address 0x0a0 + address 0x0a0 + size 64 SCB_CDB_PTR { size 4 alias SCB_RESIDUAL_DATACNT @@ -1242,7 +1243,8 @@ register SG_CACHE_SHADOW { */ scratch_ram { - address 0x020 + address 0x020 + size 58 /* * 1 byte per target starting at this address for configuration values @@ -1304,7 +1306,7 @@ scratch_ram { bit SDMAENACK 0x10 bit HDMAEN 0x08 bit HDMAENACK 0x08 - bit DIRECTION 0x04 + bit DIRECTION 0x04 /* Set indicates PCI->SCSI */ bit FIFOFLUSH 0x02 bit FIFORESET 0x01 } @@ -1469,13 +1471,17 @@ scratch_ram { size 1 bit SCB_DMA 0x01 } +} + +scratch_ram { + address 0x05a + size 6 /* * These are reserved registers in the card's scratch ram. Some of * the values are specified in the AHA2742 technical reference manual * and are initialized by the BIOS at boot time. */ SCSICONF { - address 0x05a size 1 bit TERM_ENB 0x80 bit RESET_SCSI 0x40 @@ -1500,11 +1506,16 @@ scratch_ram { mask BIOSDISABLED 0x30 bit CHANNEL_B_PRIMARY 0x08 } +} + +scratch_ram { + address 0x070 + size 16 + /* * Per target SCSI offset values for Ultra2 controllers. */ TARG_OFFSET { - address 0x070 size 16 } } diff --git a/sys/dev/microcode/aic7xxx/aic7xxx.seq b/sys/dev/microcode/aic7xxx/aic7xxx.seq index e56367e36cd..66bdf6f42bf 100644 --- a/sys/dev/microcode/aic7xxx/aic7xxx.seq +++ b/sys/dev/microcode/aic7xxx/aic7xxx.seq @@ -1,4 +1,4 @@ -/* $OpenBSD: aic7xxx.seq,v 1.11 2002/06/28 00:34:55 smurph Exp $ */ +/* $OpenBSD: aic7xxx.seq,v 1.12 2002/06/30 18:25:58 smurph Exp $ */ /* * Adaptec 274x/284x/294x device driver firmware for Linux and FreeBSD. * @@ -32,7 +32,8 @@ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.seq,v 1.119 2001/08/05 22:20:12 gibbs Exp $ */ -VERSION = "$Id: aic7xxx.seq,v 1.11 2002/06/28 00:34:55 smurph Exp $" +VERSION = "$Id: aic7xxx.seq,v 1.12 2002/06/30 18:25:58 smurph Exp $" +PATCH_ARG_LIST = "struct ahc_softc *ahc" #include <dev/microcode/aic7xxx/aic7xxx.reg> #include <scsi/scsi_message.h> @@ -81,7 +82,7 @@ poll_for_work_loop: test SSTAT0, SELDO|SELDI jnz selection; test_queue: /* Has the driver posted any work for us? */ -BEGIN_CRITICAL +BEGIN_CRITICAL; if ((ahc->features & AHC_QUEUE_REGS) != 0) { test QOFF_CTLSTA, SCB_AVAIL jz poll_for_work_loop; } else { @@ -102,7 +103,7 @@ BEGIN_CRITICAL mov SCBPTR, ARG_1; } or SEQ_FLAGS2, SCB_DMA; -END_CRITICAL +END_CRITICAL; dma_queued_scb: /* * DMA the SCB from host ram into the current SCB location. @@ -116,7 +117,7 @@ dma_queued_scb: * value. */ mov A, ARG_1; -BEGIN_CRITICAL +BEGIN_CRITICAL; cmp NEXT_QUEUED_SCB, A jne abort_qinscb; if ((ahc->flags & AHC_SEQUENCER_DEBUG) != 0) { cmp SCB_TAG, A je . + 2; @@ -131,7 +132,7 @@ BEGIN_CRITICAL inc QINPOS; } and SEQ_FLAGS2, ~SCB_DMA; -END_CRITICAL +END_CRITICAL; start_waiting: /* * Start the first entry on the waiting SCB list. @@ -1372,7 +1373,7 @@ p_command_embedded: * The data fifo seems to require 4 byte aligned * transfers from the sequencer. Force this to * be the case by clearing HADDR[0] even though - * we aren't going to touch host memeory. + * we aren't going to touch host memory. */ clr HADDR[0]; if ((ahc->features & AHC_ULTRA2) != 0) { @@ -1978,7 +1979,7 @@ target_outb: * removal of the found SCB from the disconnected list. */ if ((ahc->flags & AHC_PAGESCBS) != 0) { -BEGIN_CRITICAL +BEGIN_CRITICAL; findSCB: mov A, SINDEX; /* Tag passed in SINDEX */ cmp DISCONNECTED_SCBH, SCB_LIST_NULL je findSCB_notFound; @@ -2000,7 +2001,7 @@ rem_scb_from_disc_list: mov SCBPTR, SINDEX ret; rHead: mov DISCONNECTED_SCBH,SCB_NEXT ret; -END_CRITICAL +END_CRITICAL; findSCB_notFound: /* * We didn't find it. Page in the SCB. @@ -2125,7 +2126,7 @@ set_1byte_addr: adc DINDIR, A, SINDIR ret; /* - * Either post or fetch and SCB from host memory based on the + * Either post or fetch an SCB from host memory based on the * DIRECTION bit in DMAPARAMS. The host SCB index is in SINDEX. */ dma_scb: @@ -2283,11 +2284,11 @@ cleanup_scb: } add_scb_to_free_list: if ((ahc->flags & AHC_PAGESCBS) != 0) { -BEGIN_CRITICAL +BEGIN_CRITICAL; mov SCB_NEXT, FREE_SCBH; mvi SCB_TAG, SCB_LIST_NULL; mov FREE_SCBH, SCBPTR ret; -END_CRITICAL +END_CRITICAL; } else { mvi SCB_TAG, SCB_LIST_NULL ret; } @@ -2301,7 +2302,7 @@ set_hhaddr: if ((ahc->flags & AHC_PAGESCBS) != 0) { get_free_or_disc_scb: -BEGIN_CRITICAL +BEGIN_CRITICAL; cmp FREE_SCBH, SCB_LIST_NULL jne dequeue_free_scb; cmp DISCONNECTED_SCBH, SCB_LIST_NULL jne dequeue_disc_scb; return_error: @@ -2310,14 +2311,14 @@ return_error: dequeue_disc_scb: mov SCBPTR, DISCONNECTED_SCBH; mov DISCONNECTED_SCBH, SCB_NEXT; -END_CRITICAL +END_CRITICAL; mvi DMAPARAMS, FIFORESET; mov SCB_TAG jmp dma_scb; -BEGIN_CRITICAL +BEGIN_CRITICAL; dequeue_free_scb: mov SCBPTR, FREE_SCBH; mov FREE_SCBH, SCB_NEXT ret; -END_CRITICAL +END_CRITICAL; add_scb_to_disc_list: /* @@ -2325,10 +2326,10 @@ add_scb_to_disc_list: * candidates for paging out an SCB if one is needed for a new command. * Modifying the disconnected list is a critical(pause dissabled) section. */ -BEGIN_CRITICAL +BEGIN_CRITICAL; mov SCB_NEXT, DISCONNECTED_SCBH; mov DISCONNECTED_SCBH, SCBPTR ret; -END_CRITICAL +END_CRITICAL; } set_seqint: mov INTSTAT, SINDEX; diff --git a/sys/dev/microcode/aic7xxx/aic7xxx_seq.h b/sys/dev/microcode/aic7xxx/aic7xxx_seq.h index 4bf7b3eb992..81359508043 100644 --- a/sys/dev/microcode/aic7xxx/aic7xxx_seq.h +++ b/sys/dev/microcode/aic7xxx/aic7xxx_seq.h @@ -1,10 +1,10 @@ -/* $OpenBSD: aic7xxx_seq.h,v 1.8 2002/06/28 00:34:55 smurph Exp $ */ +/* $OpenBSD: aic7xxx_seq.h,v 1.9 2002/06/30 18:25:58 smurph Exp $ */ /* * DO NOT EDIT - This file is automatically generated - * from the following source files: + * from the following source files: * - * $Id: aic7xxx_seq.h,v 1.8 2002/06/28 00:34:55 smurph Exp $ - * $Id: aic7xxx_seq.h,v 1.8 2002/06/28 00:34:55 smurph Exp $ + * $Id: aic7xxx_seq.h,v 1.9 2002/06/30 18:25:58 smurph Exp $ + * $Id: aic7xxx_seq.h,v 1.9 2002/06/30 18:25:58 smurph Exp $ */ static u_int8_t seqprog[] = { 0xb2, 0x00, 0x00, 0x08, @@ -875,412 +875,413 @@ static u_int8_t seqprog[] = { 0xff, 0x6a, 0xd4, 0x0c }; -static int ahc_patch23_func(struct ahc_softc *ahc); +static int aic_patch23_func(struct ahc_softc *ahc); static int -ahc_patch23_func(struct ahc_softc *ahc) +aic_patch23_func(struct ahc_softc *ahc) { return ((ahc->bugs & AHC_SCBCHAN_UPLOAD_BUG) != 0); } -static int ahc_patch22_func(struct ahc_softc *ahc); +static int aic_patch22_func(struct ahc_softc *ahc); static int -ahc_patch22_func(struct ahc_softc *ahc) +aic_patch22_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_CMD_CHAN) == 0); } -static int ahc_patch21_func(struct ahc_softc *ahc); +static int aic_patch21_func(struct ahc_softc *ahc); static int -ahc_patch21_func(struct ahc_softc *ahc) +aic_patch21_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_QUEUE_REGS) == 0); } -static int ahc_patch20_func(struct ahc_softc *ahc); +static int aic_patch20_func(struct ahc_softc *ahc); static int -ahc_patch20_func(struct ahc_softc *ahc) +aic_patch20_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_WIDE) != 0); } -static int ahc_patch19_func(struct ahc_softc *ahc); +static int aic_patch19_func(struct ahc_softc *ahc); static int -ahc_patch19_func(struct ahc_softc *ahc) +aic_patch19_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_SCB_BTT) != 0); } -static int ahc_patch18_func(struct ahc_softc *ahc); +static int aic_patch18_func(struct ahc_softc *ahc); static int -ahc_patch18_func(struct ahc_softc *ahc) +aic_patch18_func(struct ahc_softc *ahc) { return ((ahc->bugs & AHC_PCI_2_1_RETRY_BUG) != 0); } -static int ahc_patch17_func(struct ahc_softc *ahc); +static int aic_patch17_func(struct ahc_softc *ahc); static int -ahc_patch17_func(struct ahc_softc *ahc) +aic_patch17_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_TMODE_WIDEODD_BUG) != 0); } -static int ahc_patch16_func(struct ahc_softc *ahc); +static int aic_patch16_func(struct ahc_softc *ahc); static int -ahc_patch16_func(struct ahc_softc *ahc) +aic_patch16_func(struct ahc_softc *ahc) { return ((ahc->bugs & AHC_AUTOFLUSH_BUG) != 0); } -static int ahc_patch15_func(struct ahc_softc *ahc); +static int aic_patch15_func(struct ahc_softc *ahc); static int -ahc_patch15_func(struct ahc_softc *ahc) +aic_patch15_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_ULTRA2) == 0); } -static int ahc_patch14_func(struct ahc_softc *ahc); +static int aic_patch14_func(struct ahc_softc *ahc); static int -ahc_patch14_func(struct ahc_softc *ahc) +aic_patch14_func(struct ahc_softc *ahc) { return ((ahc->bugs & AHC_PCI_MWI_BUG) != 0 && ahc->pci_cachesize != 0); } -static int ahc_patch13_func(struct ahc_softc *ahc); +static int aic_patch13_func(struct ahc_softc *ahc); static int -ahc_patch13_func(struct ahc_softc *ahc) +aic_patch13_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_39BIT_ADDRESSING) != 0); } -static int ahc_patch12_func(struct ahc_softc *ahc); +static int aic_patch12_func(struct ahc_softc *ahc); static int -ahc_patch12_func(struct ahc_softc *ahc) +aic_patch12_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_ULTRA) != 0); } -static int ahc_patch11_func(struct ahc_softc *ahc); +static int aic_patch11_func(struct ahc_softc *ahc); static int -ahc_patch11_func(struct ahc_softc *ahc) +aic_patch11_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_HS_MAILBOX) != 0); } -static int ahc_patch10_func(struct ahc_softc *ahc); +static int aic_patch10_func(struct ahc_softc *ahc); static int -ahc_patch10_func(struct ahc_softc *ahc) +aic_patch10_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_MULTI_TID) != 0); } -static int ahc_patch9_func(struct ahc_softc *ahc); +static int aic_patch9_func(struct ahc_softc *ahc); static int -ahc_patch9_func(struct ahc_softc *ahc) +aic_patch9_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_CMD_CHAN) != 0); } -static int ahc_patch8_func(struct ahc_softc *ahc); +static int aic_patch8_func(struct ahc_softc *ahc); static int -ahc_patch8_func(struct ahc_softc *ahc) +aic_patch8_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_INITIATORROLE) != 0); } -static int ahc_patch7_func(struct ahc_softc *ahc); +static int aic_patch7_func(struct ahc_softc *ahc); static int -ahc_patch7_func(struct ahc_softc *ahc) +aic_patch7_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_TARGETROLE) != 0); } -static int ahc_patch6_func(struct ahc_softc *ahc); +static int aic_patch6_func(struct ahc_softc *ahc); static int -ahc_patch6_func(struct ahc_softc *ahc) +aic_patch6_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_DT) == 0); } -static int ahc_patch5_func(struct ahc_softc *ahc); +static int aic_patch5_func(struct ahc_softc *ahc); static int -ahc_patch5_func(struct ahc_softc *ahc) +aic_patch5_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_SEQUENCER_DEBUG) != 0); } -static int ahc_patch4_func(struct ahc_softc *ahc); +static int aic_patch4_func(struct ahc_softc *ahc); static int -ahc_patch4_func(struct ahc_softc *ahc) +aic_patch4_func(struct ahc_softc *ahc) { return ((ahc->flags & AHC_PAGESCBS) != 0); } -static int ahc_patch3_func(struct ahc_softc *ahc); +static int aic_patch3_func(struct ahc_softc *ahc); static int -ahc_patch3_func(struct ahc_softc *ahc) +aic_patch3_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_QUEUE_REGS) != 0); } -static int ahc_patch2_func(struct ahc_softc *ahc); +static int aic_patch2_func(struct ahc_softc *ahc); static int -ahc_patch2_func(struct ahc_softc *ahc) +aic_patch2_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_TWIN) != 0); } -static int ahc_patch1_func(struct ahc_softc *ahc); +static int aic_patch1_func(struct ahc_softc *ahc); static int -ahc_patch1_func(struct ahc_softc *ahc) +aic_patch1_func(struct ahc_softc *ahc) { return ((ahc->features & AHC_ULTRA2) != 0); } -static int ahc_patch0_func(struct ahc_softc *ahc); +static int aic_patch0_func(struct ahc_softc *ahc); static int -ahc_patch0_func(struct ahc_softc *ahc) +aic_patch0_func(struct ahc_softc *ahc) { return (0); } -typedef int patch_func_t(struct ahc_softc *); -struct patch { +typedef int patch_func_t (struct ahc_softc *ahc); +static struct patch { patch_func_t *patch_func; - u_int32_t begin :10, + uint32_t begin :10, skip_instr :10, skip_patch :12; } patches[] = { - { ahc_patch1_func, 4, 1, 1 }, - { ahc_patch2_func, 6, 2, 1 }, - { ahc_patch2_func, 9, 1, 1 }, - { ahc_patch3_func, 11, 1, 2 }, - { ahc_patch0_func, 12, 2, 1 }, - { ahc_patch4_func, 15, 1, 2 }, - { ahc_patch0_func, 16, 1, 1 }, - { ahc_patch5_func, 22, 2, 1 }, - { ahc_patch3_func, 27, 1, 2 }, - { ahc_patch0_func, 28, 1, 1 }, - { ahc_patch6_func, 34, 1, 1 }, - { ahc_patch7_func, 37, 62, 21 }, - { ahc_patch8_func, 37, 1, 1 }, - { ahc_patch9_func, 42, 3, 2 }, - { ahc_patch0_func, 45, 3, 1 }, - { ahc_patch10_func, 49, 1, 2 }, - { ahc_patch0_func, 50, 2, 3 }, - { ahc_patch1_func, 50, 1, 2 }, - { ahc_patch0_func, 51, 1, 1 }, - { ahc_patch2_func, 53, 2, 1 }, - { ahc_patch9_func, 55, 1, 2 }, - { ahc_patch0_func, 56, 1, 1 }, - { ahc_patch9_func, 60, 1, 2 }, - { ahc_patch0_func, 61, 1, 1 }, - { ahc_patch9_func, 70, 1, 2 }, - { ahc_patch0_func, 71, 1, 1 }, - { ahc_patch9_func, 74, 1, 2 }, - { ahc_patch0_func, 75, 1, 1 }, - { ahc_patch11_func, 85, 1, 2 }, - { ahc_patch0_func, 86, 1, 1 }, - { ahc_patch9_func, 94, 1, 2 }, - { ahc_patch0_func, 95, 1, 1 }, - { ahc_patch8_func, 99, 9, 4 }, - { ahc_patch1_func, 101, 1, 2 }, - { ahc_patch0_func, 102, 1, 1 }, - { ahc_patch2_func, 104, 2, 1 }, - { ahc_patch2_func, 113, 4, 1 }, - { ahc_patch1_func, 117, 1, 2 }, - { ahc_patch0_func, 118, 2, 3 }, - { ahc_patch2_func, 118, 1, 2 }, - { ahc_patch0_func, 119, 1, 1 }, - { ahc_patch7_func, 120, 4, 2 }, - { ahc_patch0_func, 124, 1, 1 }, - { ahc_patch12_func, 126, 2, 1 }, - { ahc_patch1_func, 128, 1, 2 }, - { ahc_patch0_func, 129, 1, 1 }, - { ahc_patch7_func, 130, 4, 1 }, - { ahc_patch7_func, 141, 80, 9 }, - { ahc_patch4_func, 159, 1, 1 }, - { ahc_patch1_func, 172, 1, 1 }, - { ahc_patch9_func, 180, 1, 2 }, - { ahc_patch0_func, 181, 1, 1 }, - { ahc_patch9_func, 190, 1, 2 }, - { ahc_patch0_func, 191, 1, 1 }, - { ahc_patch9_func, 207, 6, 2 }, - { ahc_patch0_func, 213, 6, 1 }, - { ahc_patch8_func, 221, 18, 2 }, - { ahc_patch1_func, 234, 1, 1 }, - { ahc_patch1_func, 241, 1, 2 }, - { ahc_patch0_func, 242, 2, 2 }, - { ahc_patch12_func, 243, 1, 1 }, - { ahc_patch9_func, 251, 31, 3 }, - { ahc_patch1_func, 267, 14, 2 }, - { ahc_patch13_func, 272, 1, 1 }, - { ahc_patch14_func, 282, 14, 1 }, - { ahc_patch1_func, 298, 1, 2 }, - { ahc_patch0_func, 299, 1, 1 }, - { ahc_patch9_func, 302, 1, 1 }, - { ahc_patch13_func, 307, 1, 1 }, - { ahc_patch9_func, 308, 2, 2 }, - { ahc_patch0_func, 310, 4, 1 }, - { ahc_patch14_func, 314, 1, 1 }, - { ahc_patch15_func, 317, 2, 3 }, - { ahc_patch9_func, 317, 1, 2 }, - { ahc_patch0_func, 318, 1, 1 }, - { ahc_patch6_func, 323, 1, 2 }, - { ahc_patch0_func, 324, 1, 1 }, - { ahc_patch1_func, 328, 50, 11 }, - { ahc_patch6_func, 337, 2, 4 }, - { ahc_patch7_func, 337, 1, 1 }, - { ahc_patch8_func, 338, 1, 1 }, - { ahc_patch0_func, 339, 1, 1 }, - { ahc_patch16_func, 340, 1, 1 }, - { ahc_patch6_func, 359, 6, 3 }, - { ahc_patch16_func, 359, 5, 1 }, - { ahc_patch0_func, 365, 5, 1 }, - { ahc_patch13_func, 373, 5, 1 }, - { ahc_patch0_func, 378, 54, 17 }, - { ahc_patch14_func, 378, 1, 1 }, - { ahc_patch7_func, 380, 2, 2 }, - { ahc_patch17_func, 381, 1, 1 }, - { ahc_patch9_func, 384, 1, 1 }, - { ahc_patch18_func, 391, 1, 1 }, - { ahc_patch14_func, 396, 9, 3 }, - { ahc_patch9_func, 397, 3, 2 }, - { ahc_patch0_func, 400, 3, 1 }, - { ahc_patch9_func, 408, 6, 2 }, - { ahc_patch0_func, 414, 9, 2 }, - { ahc_patch13_func, 414, 1, 1 }, - { ahc_patch13_func, 423, 2, 1 }, - { ahc_patch14_func, 425, 1, 1 }, - { ahc_patch9_func, 427, 1, 2 }, - { ahc_patch0_func, 428, 1, 1 }, - { ahc_patch7_func, 431, 1, 1 }, - { ahc_patch7_func, 432, 1, 1 }, - { ahc_patch8_func, 433, 3, 3 }, - { ahc_patch6_func, 434, 1, 2 }, - { ahc_patch0_func, 435, 1, 1 }, - { ahc_patch9_func, 436, 1, 1 }, - { ahc_patch15_func, 437, 1, 2 }, - { ahc_patch13_func, 437, 1, 1 }, - { ahc_patch14_func, 439, 9, 4 }, - { ahc_patch9_func, 439, 1, 1 }, - { ahc_patch9_func, 446, 2, 1 }, - { ahc_patch0_func, 448, 4, 3 }, - { ahc_patch9_func, 448, 1, 2 }, - { ahc_patch0_func, 449, 3, 1 }, - { ahc_patch1_func, 453, 2, 1 }, - { ahc_patch7_func, 455, 5, 2 }, - { ahc_patch0_func, 460, 1, 1 }, - { ahc_patch8_func, 461, 109, 23 }, - { ahc_patch1_func, 463, 3, 2 }, - { ahc_patch0_func, 466, 5, 3 }, - { ahc_patch9_func, 466, 2, 2 }, - { ahc_patch0_func, 468, 3, 1 }, - { ahc_patch1_func, 473, 2, 2 }, - { ahc_patch0_func, 475, 6, 3 }, - { ahc_patch9_func, 475, 2, 2 }, - { ahc_patch0_func, 477, 3, 1 }, - { ahc_patch1_func, 483, 2, 2 }, - { ahc_patch0_func, 485, 9, 7 }, - { ahc_patch9_func, 485, 5, 6 }, - { ahc_patch19_func, 485, 1, 2 }, - { ahc_patch0_func, 486, 1, 1 }, - { ahc_patch19_func, 488, 1, 2 }, - { ahc_patch0_func, 489, 1, 1 }, - { ahc_patch0_func, 490, 4, 1 }, - { ahc_patch6_func, 494, 3, 2 }, - { ahc_patch0_func, 497, 1, 1 }, - { ahc_patch1_func, 500, 1, 1 }, - { ahc_patch6_func, 506, 1, 2 }, - { ahc_patch0_func, 507, 1, 1 }, - { ahc_patch20_func, 544, 7, 1 }, - { ahc_patch3_func, 572, 1, 2 }, - { ahc_patch0_func, 573, 1, 1 }, - { ahc_patch21_func, 576, 1, 1 }, - { ahc_patch8_func, 578, 104, 33 }, - { ahc_patch4_func, 579, 1, 1 }, - { ahc_patch1_func, 585, 2, 2 }, - { ahc_patch0_func, 587, 1, 1 }, - { ahc_patch1_func, 590, 1, 2 }, - { ahc_patch0_func, 591, 1, 1 }, - { ahc_patch9_func, 592, 3, 3 }, - { ahc_patch15_func, 593, 1, 1 }, - { ahc_patch0_func, 595, 4, 1 }, - { ahc_patch19_func, 603, 2, 2 }, - { ahc_patch0_func, 605, 1, 1 }, - { ahc_patch19_func, 609, 10, 3 }, - { ahc_patch5_func, 611, 8, 1 }, - { ahc_patch0_func, 619, 9, 2 }, - { ahc_patch5_func, 620, 8, 1 }, - { ahc_patch4_func, 630, 1, 2 }, - { ahc_patch0_func, 631, 1, 1 }, - { ahc_patch19_func, 632, 1, 2 }, - { ahc_patch0_func, 633, 3, 2 }, - { ahc_patch4_func, 635, 1, 1 }, - { ahc_patch5_func, 636, 1, 1 }, - { ahc_patch5_func, 639, 1, 1 }, - { ahc_patch5_func, 641, 1, 1 }, - { ahc_patch4_func, 643, 2, 2 }, - { ahc_patch0_func, 645, 2, 1 }, - { ahc_patch5_func, 647, 1, 1 }, - { ahc_patch5_func, 650, 1, 1 }, - { ahc_patch5_func, 653, 1, 1 }, - { ahc_patch19_func, 657, 1, 1 }, - { ahc_patch19_func, 660, 1, 1 }, - { ahc_patch4_func, 666, 1, 1 }, - { ahc_patch6_func, 669, 1, 2 }, - { ahc_patch0_func, 670, 1, 1 }, - { ahc_patch7_func, 682, 16, 1 }, - { ahc_patch4_func, 698, 20, 1 }, - { ahc_patch9_func, 719, 4, 2 }, - { ahc_patch0_func, 723, 4, 1 }, - { ahc_patch9_func, 727, 4, 2 }, - { ahc_patch0_func, 731, 3, 1 }, - { ahc_patch6_func, 737, 1, 1 }, - { ahc_patch22_func, 739, 14, 1 }, - { ahc_patch7_func, 753, 3, 1 }, - { ahc_patch9_func, 765, 24, 8 }, - { ahc_patch19_func, 769, 1, 2 }, - { ahc_patch0_func, 770, 1, 1 }, - { ahc_patch15_func, 775, 4, 2 }, - { ahc_patch0_func, 779, 7, 3 }, - { ahc_patch23_func, 779, 5, 2 }, - { ahc_patch0_func, 784, 2, 1 }, - { ahc_patch0_func, 789, 42, 3 }, - { ahc_patch18_func, 801, 18, 2 }, - { ahc_patch0_func, 819, 1, 1 }, - { ahc_patch4_func, 843, 1, 1 }, - { ahc_patch4_func, 844, 3, 2 }, - { ahc_patch0_func, 847, 1, 1 }, - { ahc_patch13_func, 848, 3, 1 }, - { ahc_patch4_func, 851, 12, 1 } + { aic_patch1_func, 4, 1, 1 }, + { aic_patch2_func, 6, 2, 1 }, + { aic_patch2_func, 9, 1, 1 }, + { aic_patch3_func, 11, 1, 2 }, + { aic_patch0_func, 12, 2, 1 }, + { aic_patch4_func, 15, 1, 2 }, + { aic_patch0_func, 16, 1, 1 }, + { aic_patch5_func, 22, 2, 1 }, + { aic_patch3_func, 27, 1, 2 }, + { aic_patch0_func, 28, 1, 1 }, + { aic_patch6_func, 34, 1, 1 }, + { aic_patch7_func, 37, 62, 21 }, + { aic_patch8_func, 37, 1, 1 }, + { aic_patch9_func, 42, 3, 2 }, + { aic_patch0_func, 45, 3, 1 }, + { aic_patch10_func, 49, 1, 2 }, + { aic_patch0_func, 50, 2, 3 }, + { aic_patch1_func, 50, 1, 2 }, + { aic_patch0_func, 51, 1, 1 }, + { aic_patch2_func, 53, 2, 1 }, + { aic_patch9_func, 55, 1, 2 }, + { aic_patch0_func, 56, 1, 1 }, + { aic_patch9_func, 60, 1, 2 }, + { aic_patch0_func, 61, 1, 1 }, + { aic_patch9_func, 70, 1, 2 }, + { aic_patch0_func, 71, 1, 1 }, + { aic_patch9_func, 74, 1, 2 }, + { aic_patch0_func, 75, 1, 1 }, + { aic_patch11_func, 85, 1, 2 }, + { aic_patch0_func, 86, 1, 1 }, + { aic_patch9_func, 94, 1, 2 }, + { aic_patch0_func, 95, 1, 1 }, + { aic_patch8_func, 99, 9, 4 }, + { aic_patch1_func, 101, 1, 2 }, + { aic_patch0_func, 102, 1, 1 }, + { aic_patch2_func, 104, 2, 1 }, + { aic_patch2_func, 113, 4, 1 }, + { aic_patch1_func, 117, 1, 2 }, + { aic_patch0_func, 118, 2, 3 }, + { aic_patch2_func, 118, 1, 2 }, + { aic_patch0_func, 119, 1, 1 }, + { aic_patch7_func, 120, 4, 2 }, + { aic_patch0_func, 124, 1, 1 }, + { aic_patch12_func, 126, 2, 1 }, + { aic_patch1_func, 128, 1, 2 }, + { aic_patch0_func, 129, 1, 1 }, + { aic_patch7_func, 130, 4, 1 }, + { aic_patch7_func, 141, 80, 9 }, + { aic_patch4_func, 159, 1, 1 }, + { aic_patch1_func, 172, 1, 1 }, + { aic_patch9_func, 180, 1, 2 }, + { aic_patch0_func, 181, 1, 1 }, + { aic_patch9_func, 190, 1, 2 }, + { aic_patch0_func, 191, 1, 1 }, + { aic_patch9_func, 207, 6, 2 }, + { aic_patch0_func, 213, 6, 1 }, + { aic_patch8_func, 221, 18, 2 }, + { aic_patch1_func, 234, 1, 1 }, + { aic_patch1_func, 241, 1, 2 }, + { aic_patch0_func, 242, 2, 2 }, + { aic_patch12_func, 243, 1, 1 }, + { aic_patch9_func, 251, 31, 3 }, + { aic_patch1_func, 267, 14, 2 }, + { aic_patch13_func, 272, 1, 1 }, + { aic_patch14_func, 282, 14, 1 }, + { aic_patch1_func, 298, 1, 2 }, + { aic_patch0_func, 299, 1, 1 }, + { aic_patch9_func, 302, 1, 1 }, + { aic_patch13_func, 307, 1, 1 }, + { aic_patch9_func, 308, 2, 2 }, + { aic_patch0_func, 310, 4, 1 }, + { aic_patch14_func, 314, 1, 1 }, + { aic_patch15_func, 317, 2, 3 }, + { aic_patch9_func, 317, 1, 2 }, + { aic_patch0_func, 318, 1, 1 }, + { aic_patch6_func, 323, 1, 2 }, + { aic_patch0_func, 324, 1, 1 }, + { aic_patch1_func, 328, 50, 11 }, + { aic_patch6_func, 337, 2, 4 }, + { aic_patch7_func, 337, 1, 1 }, + { aic_patch8_func, 338, 1, 1 }, + { aic_patch0_func, 339, 1, 1 }, + { aic_patch16_func, 340, 1, 1 }, + { aic_patch6_func, 359, 6, 3 }, + { aic_patch16_func, 359, 5, 1 }, + { aic_patch0_func, 365, 5, 1 }, + { aic_patch13_func, 373, 5, 1 }, + { aic_patch0_func, 378, 54, 17 }, + { aic_patch14_func, 378, 1, 1 }, + { aic_patch7_func, 380, 2, 2 }, + { aic_patch17_func, 381, 1, 1 }, + { aic_patch9_func, 384, 1, 1 }, + { aic_patch18_func, 391, 1, 1 }, + { aic_patch14_func, 396, 9, 3 }, + { aic_patch9_func, 397, 3, 2 }, + { aic_patch0_func, 400, 3, 1 }, + { aic_patch9_func, 408, 6, 2 }, + { aic_patch0_func, 414, 9, 2 }, + { aic_patch13_func, 414, 1, 1 }, + { aic_patch13_func, 423, 2, 1 }, + { aic_patch14_func, 425, 1, 1 }, + { aic_patch9_func, 427, 1, 2 }, + { aic_patch0_func, 428, 1, 1 }, + { aic_patch7_func, 431, 1, 1 }, + { aic_patch7_func, 432, 1, 1 }, + { aic_patch8_func, 433, 3, 3 }, + { aic_patch6_func, 434, 1, 2 }, + { aic_patch0_func, 435, 1, 1 }, + { aic_patch9_func, 436, 1, 1 }, + { aic_patch15_func, 437, 1, 2 }, + { aic_patch13_func, 437, 1, 1 }, + { aic_patch14_func, 439, 9, 4 }, + { aic_patch9_func, 439, 1, 1 }, + { aic_patch9_func, 446, 2, 1 }, + { aic_patch0_func, 448, 4, 3 }, + { aic_patch9_func, 448, 1, 2 }, + { aic_patch0_func, 449, 3, 1 }, + { aic_patch1_func, 453, 2, 1 }, + { aic_patch7_func, 455, 5, 2 }, + { aic_patch0_func, 460, 1, 1 }, + { aic_patch8_func, 461, 109, 23 }, + { aic_patch1_func, 463, 3, 2 }, + { aic_patch0_func, 466, 5, 3 }, + { aic_patch9_func, 466, 2, 2 }, + { aic_patch0_func, 468, 3, 1 }, + { aic_patch1_func, 473, 2, 2 }, + { aic_patch0_func, 475, 6, 3 }, + { aic_patch9_func, 475, 2, 2 }, + { aic_patch0_func, 477, 3, 1 }, + { aic_patch1_func, 483, 2, 2 }, + { aic_patch0_func, 485, 9, 7 }, + { aic_patch9_func, 485, 5, 6 }, + { aic_patch19_func, 485, 1, 2 }, + { aic_patch0_func, 486, 1, 1 }, + { aic_patch19_func, 488, 1, 2 }, + { aic_patch0_func, 489, 1, 1 }, + { aic_patch0_func, 490, 4, 1 }, + { aic_patch6_func, 494, 3, 2 }, + { aic_patch0_func, 497, 1, 1 }, + { aic_patch1_func, 500, 1, 1 }, + { aic_patch6_func, 506, 1, 2 }, + { aic_patch0_func, 507, 1, 1 }, + { aic_patch20_func, 544, 7, 1 }, + { aic_patch3_func, 572, 1, 2 }, + { aic_patch0_func, 573, 1, 1 }, + { aic_patch21_func, 576, 1, 1 }, + { aic_patch8_func, 578, 104, 33 }, + { aic_patch4_func, 579, 1, 1 }, + { aic_patch1_func, 585, 2, 2 }, + { aic_patch0_func, 587, 1, 1 }, + { aic_patch1_func, 590, 1, 2 }, + { aic_patch0_func, 591, 1, 1 }, + { aic_patch9_func, 592, 3, 3 }, + { aic_patch15_func, 593, 1, 1 }, + { aic_patch0_func, 595, 4, 1 }, + { aic_patch19_func, 603, 2, 2 }, + { aic_patch0_func, 605, 1, 1 }, + { aic_patch19_func, 609, 10, 3 }, + { aic_patch5_func, 611, 8, 1 }, + { aic_patch0_func, 619, 9, 2 }, + { aic_patch5_func, 620, 8, 1 }, + { aic_patch4_func, 630, 1, 2 }, + { aic_patch0_func, 631, 1, 1 }, + { aic_patch19_func, 632, 1, 2 }, + { aic_patch0_func, 633, 3, 2 }, + { aic_patch4_func, 635, 1, 1 }, + { aic_patch5_func, 636, 1, 1 }, + { aic_patch5_func, 639, 1, 1 }, + { aic_patch5_func, 641, 1, 1 }, + { aic_patch4_func, 643, 2, 2 }, + { aic_patch0_func, 645, 2, 1 }, + { aic_patch5_func, 647, 1, 1 }, + { aic_patch5_func, 650, 1, 1 }, + { aic_patch5_func, 653, 1, 1 }, + { aic_patch19_func, 657, 1, 1 }, + { aic_patch19_func, 660, 1, 1 }, + { aic_patch4_func, 666, 1, 1 }, + { aic_patch6_func, 669, 1, 2 }, + { aic_patch0_func, 670, 1, 1 }, + { aic_patch7_func, 682, 16, 1 }, + { aic_patch4_func, 698, 20, 1 }, + { aic_patch9_func, 719, 4, 2 }, + { aic_patch0_func, 723, 4, 1 }, + { aic_patch9_func, 727, 4, 2 }, + { aic_patch0_func, 731, 3, 1 }, + { aic_patch6_func, 737, 1, 1 }, + { aic_patch22_func, 739, 14, 1 }, + { aic_patch7_func, 753, 3, 1 }, + { aic_patch9_func, 765, 24, 8 }, + { aic_patch19_func, 769, 1, 2 }, + { aic_patch0_func, 770, 1, 1 }, + { aic_patch15_func, 775, 4, 2 }, + { aic_patch0_func, 779, 7, 3 }, + { aic_patch23_func, 779, 5, 2 }, + { aic_patch0_func, 784, 2, 1 }, + { aic_patch0_func, 789, 42, 3 }, + { aic_patch18_func, 801, 18, 2 }, + { aic_patch0_func, 819, 1, 1 }, + { aic_patch4_func, 843, 1, 1 }, + { aic_patch4_func, 844, 3, 2 }, + { aic_patch0_func, 847, 1, 1 }, + { aic_patch13_func, 848, 3, 1 }, + { aic_patch4_func, 851, 12, 1 } }; -struct cs { - u_int16_t begin; - u_int16_t end; + +static struct cs { + u_int16_t begin; + u_int16_t end; } critical_sections[] = { { 11, 18 }, { 21, 30 }, @@ -1290,5 +1291,6 @@ struct cs { { 859, 861 }, { 861, 863 } }; -const int num_critical_sections = sizeof(critical_sections) - / sizeof(*critical_sections); + +static const int num_critical_sections = sizeof(critical_sections) + / sizeof(*critical_sections); diff --git a/sys/dev/microcode/aic7xxx/aicasm.c b/sys/dev/microcode/aic7xxx/aicasm.c index d50c96d3046..c7a9e5718d8 100644 --- a/sys/dev/microcode/aic7xxx/aicasm.c +++ b/sys/dev/microcode/aic7xxx/aicasm.c @@ -1,8 +1,9 @@ -/* $OpenBSD: aicasm.c,v 1.7 2002/06/28 00:34:55 smurph Exp $ */ +/* $OpenBSD: aicasm.c,v 1.8 2002/06/30 18:25:58 smurph Exp $ */ /* * Aic7xxx SCSI host adapter firmware asssembler * - * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs. + * Copyright (c) 1997, 1998, 2000, 2001 Justin T. Gibbs. + * Copyright (c) 2001 Adaptec Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,33 +11,43 @@ * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, - * without modification, immediately at the beginning of the file. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the - * GNU Public License ("GPL"). + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. * - * $Id: aicasm.c,v 1.7 2002/06/28 00:34:55 smurph Exp $ + * $Id: aicasm.c,v 1.8 2002/06/30 18:25:58 smurph Exp $ * - * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.c,v 1.32 2001/07/18 21:03:32 gibbs Exp $ + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.c,v 1.34 2002/06/05 22:51:54 gibbs Exp $ */ #include <sys/types.h> #include <sys/mman.h> #include <ctype.h> +#include <inttypes.h> +#include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -59,8 +70,8 @@ TAILQ_HEAD(patch_list, patch) patches; static void usage(void); static void back_patch(void); -static void output_code(FILE *ofile); -static void output_listing(FILE *listfile, char *ifilename); +static void output_code(void); +static void output_listing(char *ifilename); static void dump_scope(scope_t *scope); static void emit_patch(scope_t *scope, int patch); static int check_patch(patch_t **start_patch, int start_instr, @@ -75,6 +86,8 @@ char *regfilename; FILE *regfile; char *listfilename; FILE *listfile; +int src_mode; +int dst_mode; static TAILQ_HEAD(,instruction) seq_program; struct cs_tailq cs_tailq; @@ -83,7 +96,9 @@ symlist_t patch_functions; #if DEBUG extern int yy_flex_debug; +extern int mm_flex_debug; extern int yydebug; +extern int mmdebug; #endif extern FILE *yyin; extern int yyparse(void); @@ -116,7 +131,9 @@ main(argc, argv) listfile = NULL; #if DEBUG yy_flex_debug = 0; + mm_flex_debug = 0; yydebug = 0; + mmdebug = 0; #endif while ((ch = getopt(argc, argv, "d:l:n:o:r:I:O:")) != -1) { switch(ch) { @@ -124,8 +141,10 @@ main(argc, argv) #if DEBUG if (strcmp(optarg, "s") == 0) { yy_flex_debug = 1; + mm_flex_debug = 1; } else if (strcmp(optarg, "p") == 0) { yydebug = 1; + mmdebug = 1; } else { fprintf(stderr, "%s: -d Requires either an " "'s' or 'p' argument\n", appname); @@ -246,12 +265,12 @@ main(argc, argv) back_patch(); if (ofile != NULL) - output_code(ofile); + output_code(); if (regfile != NULL) { symtable_dump(regfile); } if (listfile != NULL) - output_listing(listfile, inputfilename); + output_listing(inputfilename); } stop(NULL, 0); @@ -264,9 +283,9 @@ usage() { (void)fprintf(stderr, -"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file] - [-r register_output_file] [-l program_list_file] - input_file\n", +"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]\n" +" [-r register_output_file] [-l program_list_file]\n" +" input_file\n", appname); exit(EX_USAGE); } @@ -301,8 +320,7 @@ back_patch() } static void -output_code(ofile) - FILE *ofile; +output_code() { struct instruction *cur_instr; patch_t *cur_patch; @@ -312,11 +330,11 @@ output_code(ofile) instrcount = 0; fprintf(ofile, -"/* - * DO NOT EDIT - This file is automatically generated - * from the following source files: - * -%s */\n", versions); +"/*\n" +" * DO NOT EDIT - This file is automatically generated\n" +" * from the following source files:\n" +" *\n" +"%s */\n", versions); fprintf(ofile, "static u_int8_t seqprog[] = {\n"); for(cur_instr = seq_program.tqh_first; @@ -340,6 +358,10 @@ output_code(ofile) } fprintf(ofile, "\n};\n\n"); + if (patch_arg_list == NULL) + stop("Patch argument list not defined", + EX_DATAERR); + /* * Output patch information. Patch functions first. */ @@ -347,43 +369,45 @@ output_code(ofile) cur_node != NULL; cur_node = SLIST_NEXT(cur_node,links)) { fprintf(ofile, -"static int ahc_patch%d_func(struct ahc_softc *ahc); - -static int -ahc_patch%d_func(struct ahc_softc *ahc) -{ - return (%s); -}\n\n", +"static int aic_patch%d_func(%s);\n" +"\n" +"static int\n" +"aic_patch%d_func(%s)\n" +"{\n" +" return (%s);\n" +"}\n\n", cur_node->symbol->info.condinfo->func_num, + patch_arg_list, cur_node->symbol->info.condinfo->func_num, + patch_arg_list, cur_node->symbol->name); } fprintf(ofile, -"typedef int patch_func_t(struct ahc_softc *); -struct patch { - patch_func_t *patch_func; - u_int32_t begin :10, - skip_instr :10, - skip_patch :12; -} patches[] = {\n"); +"typedef int patch_func_t (%s);\n" +"static struct patch {\n" +" patch_func_t *patch_func;\n" +" uint32_t begin :10,\n" +" skip_instr :10,\n" +" skip_patch :12;\n" +"} patches[] = {\n", patch_arg_list); for(cur_patch = TAILQ_FIRST(&patches); cur_patch != NULL; cur_patch = TAILQ_NEXT(cur_patch,links)) { - fprintf(ofile, "%s\t{ ahc_patch%d_func, %d, %d, %d }", + fprintf(ofile, "%s\t{ aic_patch%d_func, %d, %d, %d }", cur_patch == TAILQ_FIRST(&patches) ? "" : ",\n", cur_patch->patch_func, cur_patch->begin, cur_patch->skip_instr, cur_patch->skip_patch); } - fprintf(ofile, "\n};\n"); + fprintf(ofile, "\n};\n\n"); fprintf(ofile, -"struct cs { - u_int16_t begin; - u_int16_t end; -} critical_sections[] = {\n"); +"static struct cs {\n" +" u_int16_t begin;\n" +" u_int16_t end;\n" +"} critical_sections[] = {\n"); for(cs = TAILQ_FIRST(&cs_tailq); cs != NULL; @@ -393,11 +417,11 @@ struct patch { cs->begin_addr, cs->end_addr); } - fprintf(ofile, "\n};\n"); + fprintf(ofile, "\n};\n\n"); fprintf(ofile, -"const int num_critical_sections = sizeof(critical_sections) - / sizeof(*critical_sections);\n"); +"static const int num_critical_sections = sizeof(critical_sections)\n" +" / sizeof(*critical_sections);\n"); fprintf(stderr, "%s: %d instructions used\n", appname, instrcount); } @@ -462,7 +486,7 @@ emit_patch(scope_t *scope, int patch) } void -output_listing(FILE *listfile, char *ifilename) +output_listing(char *ifilename) { char buf[1024]; FILE *ifile; diff --git a/sys/dev/microcode/aic7xxx/aicasm.h b/sys/dev/microcode/aic7xxx/aicasm.h index 8156d25c316..f20cae736c1 100644 --- a/sys/dev/microcode/aic7xxx/aicasm.h +++ b/sys/dev/microcode/aic7xxx/aicasm.h @@ -1,8 +1,9 @@ -/* $OpenBSD: aicasm.h,v 1.4 2002/06/28 00:34:55 smurph Exp $ */ +/* $OpenBSD: aicasm.h,v 1.5 2002/06/30 18:25:58 smurph Exp $ */ /* * Assembler for the sequencer program downloaded to Aic7xxx SCSI host adapters * * Copyright (c) 1997 Justin T. Gibbs. + * Copyright (c) 2001 Adaptec Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,25 +12,33 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the - * GNU Public License ("GPL"). + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.h,v 1.13 2001/07/18 21:03:32 gibbs Exp $ + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.h,v 1.15 2002/06/05 22:51:54 gibbs Exp $ */ #include <sys/queue.h> @@ -64,10 +73,15 @@ extern int includes_search_curdir; /* False if we've seen -I- */ extern char *appname; extern int yylineno; extern char *yyfilename; +extern char *patch_arg_list; extern char *versions; +extern int src_mode; +extern int dst_mode; +struct symbol; void stop(const char *errstring, int err_code); void include_file(char *file_name, include_type type); +void expand_macro(struct symbol *macro_symbol); struct instruction *seq_alloc(void); struct critical_section *cs_alloc(void); struct scope *scope_alloc(void); diff --git a/sys/dev/microcode/aic7xxx/aicasm_gram.y b/sys/dev/microcode/aic7xxx/aicasm_gram.y index 8e7c7a3bd91..ae40ec76d04 100644 --- a/sys/dev/microcode/aic7xxx/aicasm_gram.y +++ b/sys/dev/microcode/aic7xxx/aicasm_gram.y @@ -3,6 +3,7 @@ * Parser for the Aic7xxx SCSI Host adapter sequencer assembler. * * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs. + * Copyright (c) 2001 Adaptec Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,33 +12,44 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the - * GNU Public License ("GPL"). + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_gram.y,v 1.15 2001/07/18 21:03:32 gibbs Exp $ + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_gram.y,v 1.17 2002/06/05 22:51:54 gibbs Exp $ */ +#include <sys/types.h> + +#include <inttypes.h> +#include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sysexits.h> -#include <sys/types.h> #include <sys/queue.h> #include "aicasm.h" @@ -46,43 +58,50 @@ int yylineno; char *yyfilename; +char *patch_arg_list; char *versions; +static char errbuf[255]; +static char regex_pattern[255]; static symbol_t *cur_symbol; +static symbol_t *scb_or_sram_symbol; static symtype cur_symtype; -static symbol_t *accumulator; +static symbol_ref_t accumulator; +static symbol_ref_t mode_ptr; static symbol_ref_t allones; static symbol_ref_t allzeros; static symbol_ref_t none; static symbol_ref_t sindex; static int instruction_ptr; +static int num_srams; static int sram_or_scb_offset; static int download_constant_count; static int in_critical_section; static void process_bitmask(int mask_type, symbol_t *sym, int mask); static void initialize_symbol(symbol_t *symbol); +static void add_macro_arg(const char *argtext, int position); +static void add_macro_body(const char *bodytext); 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 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 void add_version(const char *); +static void add_version(const char *verstring); static int is_download_const(expression_t *immed); -#define YYDEBUG 1 #define SRAM_SYMNAME "SRAM_BASE" #define SCB_SYMNAME "SCB_BASE" %} %union { - int value; + u_int value; char *str; symbol_t *sym; symbol_ref_t sym_ref; @@ -93,6 +112,8 @@ static int is_download_const(expression_t *immed); %token <value> T_CONST +%token T_EXPORT + %token T_DOWNLOAD %token T_SCB @@ -103,10 +124,22 @@ static int is_download_const(expression_t *immed); %token T_SIZE +%token T_EXPR_LSHIFT + +%token T_EXPR_RSHIFT + %token <value> T_ADDRESS %token T_ACCESS_MODE +%token T_MODES + +%token T_DEFINE + +%token T_SET_SRC_MODE + +%token T_SET_DST_MODE + %token <value> T_MODE %token T_BEGIN_CS @@ -119,11 +152,11 @@ static int is_download_const(expression_t *immed); %token <value> T_NUMBER -%token <str> T_PATH T_STRING +%token <str> T_PATH T_STRING T_ARG T_MACROBODY %token <sym> T_CEXPR -%token T_EOF T_INCLUDE T_VERSION +%token T_EOF T_INCLUDE T_VERSION T_PATCH_ARG_LIST %token <value> T_SHR T_SHL T_ROR T_ROL @@ -147,7 +180,7 @@ static int is_download_const(expression_t *immed); %token T_NOP -%token T_ACCUM T_ALLONES T_ALLZEROS T_NONE T_SINDEX +%token T_ACCUM T_ALLONES T_ALLZEROS T_NONE T_SINDEX T_MODE_PTR %token T_A @@ -161,13 +194,15 @@ static int is_download_const(expression_t *immed); %type <expression> expression immediate immediate_or_a -%type <value> ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne +%type <value> export ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne -%type <value> numerical_value +%type <value> numerical_value mode_value mode_list macro_arglist %left '|' %left '&' +%left T_EXPR_LSHIFT T_EXPR_RSHIFT %left '+' '-' +%left '*' '/' %right '~' %nonassoc UMINUS %% @@ -175,18 +210,26 @@ static int is_download_const(expression_t *immed); program: include | program include +| patch_arg_list +| program patch_arg_list | version | program version | register | program register | constant | program constant +| macrodefn +| program macrodefn | scratch_ram | program scratch_ram | scb | program scb | label | program label +| set_src_mode +| program set_src_mode +| set_dst_mode +| program set_dst_mode | critical_section_start | program critical_section_start | critical_section_end @@ -208,6 +251,18 @@ include: } ; +patch_arg_list: + T_PATCH_ARG_LIST '=' T_STRING + { + if (patch_arg_list != NULL) + stop("Patch argument list multiply defined", + EX_DATAERR); + patch_arg_list = strdup($3); + if (patch_arg_list == NULL) + stop("Unable to record patch arg list", EX_SOFTWARE); + } +; + version: T_VERSION '=' T_STRING { add_version($3); } @@ -264,10 +319,12 @@ reg_attribute: reg_address | size | access_mode +| modes | bit_defn | mask_defn | alias | accumulator +| mode_pointer | allones | allzeros | none @@ -285,6 +342,18 @@ size: T_SIZE T_NUMBER { cur_symbol->info.rinfo->size = $2; + if (scb_or_sram_symbol != NULL) { + u_int max_addr; + u_int sym_max_addr; + + max_addr = scb_or_sram_symbol->info.rinfo->address + + scb_or_sram_symbol->info.rinfo->size; + sym_max_addr = cur_symbol->info.rinfo->address + + cur_symbol->info.rinfo->size; + + if (sym_max_addr > max_addr) + stop("SCB or SRAM space exhausted", EX_DATAERR); + } } ; @@ -295,6 +364,54 @@ access_mode: } ; +modes: + T_MODES mode_list + { + cur_symbol->info.rinfo->modes = $2; + } +; + +mode_list: + mode_value + { + $$ = $1; + } +| mode_list ',' mode_value + { + $$ = $1 | $3; + } +; + +mode_value: + T_NUMBER + { + if ($1 > 4) { + stop("Valid register modes range between 0 and 4.", + EX_DATAERR); + /* NOTREACHED */ + } + + $$ = (0x1 << $1); + } +| T_SYMBOL + { + symbol_t *symbol; + + symbol = $1; + if (symbol->type != CONST) { + stop("Only \"const\" symbols allowed in " + "mode definitions.", EX_DATAERR); + /* NOTREACHED */ + } + if (symbol->info.cinfo->value > 4) { + stop("Valid register modes range between 0 and 4.", + EX_DATAERR); + /* NOTREACHED */ + } + $$ = (0x1 << symbol->info.cinfo->value); + } +; + bit_defn: T_BIT T_SYMBOL T_NUMBER { @@ -326,12 +443,24 @@ alias: accumulator: T_ACCUM { - if (accumulator != NULL) { + if (accumulator.symbol != NULL) { stop("Only one accumulator definition allowed", EX_DATAERR); /* NOTREACHED */ } - accumulator = cur_symbol; + accumulator.symbol = cur_symbol; + } +; + +mode_pointer: + T_MODE_PTR + { + if (mode_ptr.symbol != NULL) { + stop("Only one mode pointer definition allowed", + EX_DATAERR); + /* NOTREACHED */ + } + mode_ptr.symbol = cur_symbol; } ; @@ -412,6 +541,34 @@ expression: &($1.referenced_syms), &($3.referenced_syms)); } +| expression '*' expression + { + $$.value = $1.value * $3.value; + symlist_merge(&($$.referenced_syms), + &($1.referenced_syms), + &($3.referenced_syms)); + } +| expression '/' expression + { + $$.value = $1.value / $3.value; + symlist_merge(&($$.referenced_syms), + &($1.referenced_syms), + &($3.referenced_syms)); + } +| expression T_EXPR_LSHIFT expression + { + $$.value = $1.value << $3.value; + symlist_merge(&$$.referenced_syms, + &$1.referenced_syms, + &$3.referenced_syms); + } +| expression T_EXPR_RSHIFT expression + { + $$.value = $1.value >> $3.value; + symlist_merge(&$$.referenced_syms, + &$1.referenced_syms, + &$3.referenced_syms); + } | '(' expression ')' { $$ = $2; @@ -455,12 +612,10 @@ expression: case UNINITIALIZED: default: { - char buf[255]; - - snprintf(buf, sizeof(buf), + snprintf(errbuf, sizeof(errbuf), "Undefined symbol %s referenced", symbol->name); - stop(buf, EX_DATAERR); + stop(errbuf, EX_DATAERR); /* NOTREACHED */ break; } @@ -481,7 +636,6 @@ constant: $2->type = CONST; initialize_symbol($2); $2->info.cinfo->value = $3; - $2->info.cinfo->define = $1; } | T_CONST T_SYMBOL T_DOWNLOAD { @@ -498,7 +652,54 @@ constant: $2->type = DOWNLOAD_CONST; initialize_symbol($2); $2->info.cinfo->value = download_constant_count++; - $2->info.cinfo->define = FALSE; + } +; + +macrodefn_prologue: + T_DEFINE T_SYMBOL + { + if ($2->type != UNINITIALIZED) { + stop("Re-definition of symbol as a macro", + EX_DATAERR); + /* NOTREACHED */ + } + cur_symbol = $2; + cur_symbol->type = MACRO; + initialize_symbol(cur_symbol); + } +; + +macrodefn: + macrodefn_prologue T_MACROBODY + { + add_macro_body($2); + } +| macrodefn_prologue '(' macro_arglist ')' T_MACROBODY + { + add_macro_body($5); + cur_symbol->info.macroinfo->narg = $3; + } +; + +macro_arglist: + { + /* Macros can take no arguments */ + $$ = 0; + } +| T_ARG + { + $$ = 1; + add_macro_arg($1, 0); + } +| macro_arglist ',' T_ARG + { + if ($1 == 0) { + stop("Comma without preceeding argument in arg list", + EX_DATAERR); + /* NOTREACHED */ + } + $$ = $1 + 1; + add_macro_arg($3, $1); } ; @@ -516,13 +717,10 @@ numerical_value: scratch_ram: T_SRAM '{' { + snprintf(errbuf, sizeof(errbuf), "%s%d", SRAM_SYMNAME, + num_srams); cur_symbol = symtable_get(SRAM_SYMNAME); cur_symtype = SRAMLOC; - if (cur_symbol->type != UNINITIALIZED) { - stop("Only one SRAM definition allowed", - EX_DATAERR); - /* NOTREACHED */ - } cur_symbol->type = SRAMLOC; initialize_symbol(cur_symbol); } @@ -530,10 +728,15 @@ scratch_ram: { sram_or_scb_offset = cur_symbol->info.rinfo->address; } - scb_or_sram_reg_list + size + { + scb_or_sram_symbol = cur_symbol; + } + scb_or_sram_attributes '}' { cur_symbol = NULL; + scb_or_sram_symbol = NULL; } ; @@ -556,13 +759,25 @@ scb: { sram_or_scb_offset = cur_symbol->info.rinfo->address; } - scb_or_sram_reg_list + size + { + scb_or_sram_symbol = cur_symbol; + } + scb_or_sram_attributes '}' { cur_symbol = NULL; + scb_or_sram_symbol = NULL; } ; +scb_or_sram_attributes: + /* NULL definition is okay */ +| modes +| scb_or_sram_reg_list +| modes scb_or_sram_reg_list +; + scb_or_sram_reg_list: reg_definition | scb_or_sram_reg_list reg_definition @@ -603,11 +818,11 @@ reg_symbol: } | T_A { - if (accumulator == NULL) { + if (accumulator.symbol == NULL) { stop("No accumulator has been defined", EX_DATAERR); /* NOTREACHED */ } - $$.symbol = accumulator; + $$.symbol = accumulator.symbol; $$.offset = 0; } ; @@ -628,6 +843,14 @@ immediate: immediate_or_a: expression { + if ($1.value == 0 && is_download_const(&$1) == 0) { + snprintf(errbuf, sizeof(errbuf), + "\nExpression evaluates to 0 and thus " + "references the accumulator.\n " + "If this is the desired effect, use 'A' " + "instead.\n"); + stop(errbuf, EX_DATAERR); + } $$ = $1; } | T_A @@ -660,9 +883,23 @@ ret: { $$ = 1; } ; +set_src_mode: + T_SET_SRC_MODE T_NUMBER ';' + { + src_mode = $2; + } +; + +set_dst_mode: + T_SET_DST_MODE T_NUMBER ';' + { + dst_mode = $2; + } +; + critical_section_start: - T_BEGIN_CS - { + T_BEGIN_CS ';' + { critical_section_t *cs; if (in_critical_section != FALSE) { @@ -676,8 +913,8 @@ critical_section_start: } critical_section_end: - T_END_CS - { + T_END_CS ';' + { critical_section_t *cs; if (in_critical_section == FALSE) { @@ -689,16 +926,23 @@ critical_section_end: in_critical_section = FALSE; } +export: + { $$ = 0; } +| T_EXPORT + { $$ = 1; } +; + label: - T_SYMBOL ':' + export T_SYMBOL ':' { - if ($1->type != UNINITIALIZED) { + if ($2->type != UNINITIALIZED) { stop("Program label multiply defined", EX_DATAERR); /* NOTREACHED */ } - $1->type = LABEL; - initialize_symbol($1); - $1->info.linfo->address = instruction_ptr; + $2->type = LABEL; + initialize_symbol($2); + $2->info.linfo->address = instruction_ptr; + $2->info.linfo->exported = $1; } ; @@ -1048,10 +1292,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 @@ -1096,8 +1337,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: @@ -1116,6 +1356,16 @@ initialize_symbol(symbol) } memset(symbol->info.rinfo, 0, sizeof(struct reg_info)); + /* + * Default to allowing access in all register modes + * or to the mode specified by the SCB or SRAM space + * we are in. + */ + if (scb_or_sram_symbol != NULL) + symbol->info.rinfo->modes = + scb_or_sram_symbol->info.rinfo->modes; + else + symbol->info.rinfo->modes = ~0; break; case ALIAS: symbol->info.ainfo = @@ -1169,6 +1419,17 @@ initialize_symbol(symbol) memset(symbol->info.condinfo, 0, sizeof(struct cond_info)); break; + case MACRO: + symbol->info.macroinfo = + (struct macro_info *)malloc(sizeof(struct macro_info)); + if (symbol->info.macroinfo == NULL) { + stop("Can't create macro info", EX_SOFTWARE); + /* NOTREACHED */ + } + memset(symbol->info.macroinfo, 0, + sizeof(struct macro_info)); + TAILQ_INIT(&symbol->info.macroinfo->args); + break; default: stop("Call to initialize_symbol with invalid symbol type", EX_SOFTWARE); @@ -1178,36 +1439,81 @@ initialize_symbol(symbol) } static void -process_register(p_symbol) - symbol_t **p_symbol; +add_macro_arg(const char *argtext, int argnum) +{ + struct macro_arg *marg; + int i; + int retval; + + + if (cur_symbol == NULL || cur_symbol->type != MACRO) { + stop("Invalid current symbol for adding macro arg", + EX_SOFTWARE); + /* NOTREACHED */ + } + + marg = (struct macro_arg *)malloc(sizeof(*marg)); + if (marg == NULL) { + stop("Can't create macro_arg structure", EX_SOFTWARE); + /* NOTREACHED */ + } + marg->replacement_text = NULL; + retval = snprintf(regex_pattern, sizeof(regex_pattern), + "[^-/A-Za-z0-9_](%s)([^-/A-Za-z0-9_]|$)", + argtext); + if (retval >= sizeof(regex_pattern)) { + stop("Regex text buffer too small for arg", + EX_SOFTWARE); + /* NOTREACHED */ + } + retval = regcomp(&marg->arg_regex, regex_pattern, REG_EXTENDED); + if (retval != 0) { + stop("Regex compilation failed", EX_SOFTWARE); + /* NOTREACHED */ + } + TAILQ_INSERT_TAIL(&cur_symbol->info.macroinfo->args, marg, links); +} + +static void +add_macro_body(const char *bodytext) +{ + if (cur_symbol == NULL || cur_symbol->type != MACRO) { + stop("Invalid current symbol for adding macro arg", + EX_SOFTWARE); + /* NOTREACHED */ + } + cur_symbol->info.macroinfo->body = strdup(bodytext); + if (cur_symbol->info.macroinfo->body == NULL) { + stop("Can't duplicate macro body text", EX_SOFTWARE); + /* NOTREACHED */ + } +} + +static void +process_register(symbol_t **p_symbol) { - char buf[255]; symbol_t *symbol = *p_symbol; if (symbol->type == UNINITIALIZED) { - snprintf(buf, sizeof(buf), "Undefined register %s", + snprintf(errbuf, sizeof(errbuf), "Undefined register %s", symbol->name); - stop(buf, EX_DATAERR); + stop(errbuf, EX_DATAERR); /* NOTREACHED */ } else if (symbol->type == ALIAS) { *p_symbol = symbol->info.ainfo->parent; } else if ((symbol->type != REGISTER) && (symbol->type != SCBLOC) && (symbol->type != SRAMLOC)) { - snprintf(buf, sizeof(buf), + snprintf(errbuf, sizeof(errbuf), "Specified symbol %s is not a register", symbol->name); - stop(buf, EX_DATAERR); + stop(errbuf, EX_DATAERR); } } 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; @@ -1235,22 +1541,59 @@ format_1_instr(opcode, dest, immed, src, ret) if (is_download_const(immed)) f1_instr->parity = 1; + else if (dest->symbol == mode_ptr.symbol) { + u_int src_value; + u_int dst_value; + + /* + * Attempt to update mode information if + * we are operating on the mode register. + */ + if (src->symbol == allones.symbol) + src_value = 0xFF; + else if (src->symbol == allzeros.symbol) + src_value = 0; + else if (src->symbol == mode_ptr.symbol) + src_value = (dst_mode << 4) | src_mode; + else + goto cant_update; + + switch (opcode) { + case AIC_OP_AND: + dst_value = src_value & immed->value; + break; + case AIC_OP_XOR: + dst_value = src_value ^ immed->value; + break; + case AIC_OP_ADD: + dst_value = (src_value + immed->value) & 0xFF; + break; + case AIC_OP_OR: + dst_value = src_value | immed->value; + break; + break; + case AIC_OP_BMOV: + dst_value = src_value; + break; + default: + goto cant_update; + } + src_mode = dst_value & 0xF; + dst_mode = (dst_value >> 4) & 0xF; +cant_update: + } symlist_free(&immed->referenced_syms); instruction_ptr++; } 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; - u_int8_t shift_control; + uint8_t shift_control; if (src->symbol == NULL) src = dest; @@ -1306,11 +1649,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; @@ -1348,9 +1688,16 @@ 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->modes & (0x1 << src_mode)) == 0) { + snprintf(errbuf, sizeof(errbuf), + "Register %s unavailable in source reg mode %d", + symbol->name, src_mode); + stop(errbuf, EX_DATAERR); + } + if (symbol->info.rinfo->mode == WO) { stop("Write Only register specified as source", EX_DATAERR); @@ -1359,9 +1706,16 @@ test_readable_symbol(symbol) } static void -test_writable_symbol(symbol) - symbol_t *symbol; +test_writable_symbol(symbol_t *symbol) { + + if ((symbol->info.rinfo->modes & (0x1 << dst_mode)) == 0) { + snprintf(errbuf, sizeof(errbuf), + "Register %s unavailable in destination reg mode %d", + symbol->name, dst_mode); + stop(errbuf, EX_DATAERR); + } + if (symbol->info.rinfo->mode == RO) { stop("Read Only register specified as destination", EX_DATAERR); @@ -1370,14 +1724,10 @@ 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; - char buf[255]; and_op = FALSE; if (opcode == AIC_OP_AND || opcode == AIC_OP_JNZ || AIC_OP_JZ) @@ -1390,11 +1740,11 @@ type_check(symbol, expression, opcode) */ if (and_op == FALSE && (expression->value & ~symbol->info.rinfo->valid_bitmask) != 0) { - snprintf(buf, sizeof(buf), + snprintf(errbuf, sizeof(errbuf), "Invalid bit(s) 0x%x in immediate written to %s", expression->value & ~symbol->info.rinfo->valid_bitmask, symbol->name); - stop(buf, EX_DATAERR); + stop(errbuf, EX_DATAERR); /* NOTREACHED */ } @@ -1410,11 +1760,11 @@ type_check(symbol, expression, opcode) || node->symbol->type == BIT) && symlist_search(&node->symbol->info.minfo->symrefs, symbol->name) == NULL) { - snprintf(buf, sizeof(buf), + snprintf(errbuf, sizeof(errbuf), "Invalid bit or mask %s " "for register %s", node->symbol->name, symbol->name); - stop(buf, EX_DATAERR); + stop(errbuf, EX_DATAERR); /* NOTREACHED */ } } @@ -1422,17 +1772,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; @@ -1469,8 +1816,7 @@ add_conditional(symbol) } static void -add_version(verstring) -const char *verstring; +add_version(const char *verstring) { const char prefix[] = " * "; int newlen; @@ -1490,15 +1836,13 @@ const char *verstring; } 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/microcode/aic7xxx/aicasm_macro_gram.y b/sys/dev/microcode/aic7xxx/aicasm_macro_gram.y new file mode 100644 index 00000000000..be2e87c7983 --- /dev/null +++ b/sys/dev/microcode/aic7xxx/aicasm_macro_gram.y @@ -0,0 +1,160 @@ +%{ +/* + * Sub-parser for macro invocation in the Aic7xxx SCSI + * Host adapter sequencer assembler. + * + * Copyright (c) 2001 Adaptec Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * $Id: aicasm_macro_gram.y,v 1.1 2002/06/30 18:25:58 smurph Exp $ + * + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y,v 1.1 2002/04/24 16:24:43 gibbs Exp $ + */ + +#include <sys/types.h> + +#include <inttypes.h> +#include <regex.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sysexits.h> + +#include <sys/queue.h> + +#include "aicasm.h" +#include "aicasm_symbol.h" +#include "sequencer.h" + +static symbol_t *macro_symbol; + +static void add_macro_arg(const char *argtext, int position); + +%} + +%union { + int value; + char *str; + symbol_t *sym; +} + + +%token <str> T_ARG + +%token <sym> T_SYMBOL + +%type <value> macro_arglist + +%% + +macrocall: + T_SYMBOL '(' + { + macro_symbol = $1; + } + macro_arglist ')' + { + if (macro_symbol->info.macroinfo->narg != $4) { + printf("Narg == %d", macro_symbol->info.macroinfo->narg); + stop("Too few arguments for macro invocation", + EX_DATAERR); + /* NOTREACHED */ + } + macro_symbol = NULL; + YYACCEPT; + } +; + +macro_arglist: + { + /* Macros can take 0 arguments */ + $$ = 0; + } +| T_ARG + { + $$ = 1; + add_macro_arg($1, 1); + } +| macro_arglist ',' T_ARG + { + if ($1 == 0) { + stop("Comma without preceeding argument in arg list", + EX_DATAERR); + /* NOTREACHED */ + } + $$ = $1 + 1; + add_macro_arg($3, $$); + } +; + +%% + +static void +add_macro_arg(const char *argtext, int argnum) +{ + struct macro_arg *marg; + int i; + + if (macro_symbol == NULL || macro_symbol->type != MACRO) { + stop("Invalid current symbol for adding macro arg", + EX_SOFTWARE); + /* NOTREACHED */ + } + /* + * Macro Invocation. Find the appropriate argument and fill + * in the replace ment text for this call. + */ + i = 0; + TAILQ_FOREACH(marg, ¯o_symbol->info.macroinfo->args, links) { + i++; + if (i == argnum) + break; + } + if (marg == NULL) { + stop("Too many arguments for macro invocation", EX_DATAERR); + /* NOTREACHED */ + } + marg->replacement_text = strdup(argtext); + if (marg->replacement_text == NULL) { + stop("Unable to replicate replacement text", EX_SOFTWARE); + /* NOTREACHED */ + } +} + +void +mmerror(const char *string) +{ + stop(string, EX_DATAERR); +} diff --git a/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l b/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l new file mode 100644 index 00000000000..6495fa73f48 --- /dev/null +++ b/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l @@ -0,0 +1,150 @@ +%{ +/* + * Sub-Lexical Analyzer for macro invokation in + * the Aic7xxx SCSI Host adapter sequencer assembler. + * + * Copyright (c) 2001 Adaptec Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * $Id: aicasm_macro_scan.l,v 1.1 2002/06/30 18:25:58 smurph Exp $ + * + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l,v 1.1 2002/04/24 16:24:43 gibbs Exp $ + */ + +#include <sys/types.h> + +#include <limits.h> +#include <regex.h> +#include <stdio.h> +#include <string.h> +#include <sysexits.h> +#include <sys/queue.h> + +#include "aicasm.h" +#include "aicasm_symbol.h" +#include "y.tab.h" + +#define MAX_STR_CONST 4096 +static char string_buf[MAX_STR_CONST]; +static char *string_buf_ptr; +static int parren_count; +static char buf[255]; +%} + +WORD [A-Za-z_][-A-Za-z_0-9]* +SPACE [ \t]+ +MCARG [^(), \t]+ + +%x ARGLIST + +%% +\n { + ++yylineno; + } +<ARGLIST>{SPACE} ; +<ARGLIST>\( { + parren_count++; + if (parren_count == 1) { + string_buf_ptr = string_buf; + return ('('); + } + *string_buf_ptr++ = '('; + } +<ARGLIST>\) { + if (parren_count == 1) { + if (string_buf_ptr != string_buf) { + /* + * Return an argument and + * rescan this parren so we + * can return it as well. + */ + *string_buf_ptr = '\0'; + mmlval.str = string_buf; + string_buf_ptr = string_buf; + unput(')'); + return T_ARG; + } + BEGIN INITIAL; + return (')'); + } + parren_count--; + *string_buf_ptr++ = ')'; + } +<ARGLIST>{MCARG} { + char *yptr; + + yptr = mmtext; + while (*yptr) + *string_buf_ptr++ = *yptr++; + } +<ARGLIST>\, { + if (string_buf_ptr != string_buf) { + /* + * Return an argument and + * rescan this comma so we + * can return it as well. + */ + *string_buf_ptr = '\0'; + mmlval.str = string_buf; + string_buf_ptr = string_buf; + unput(','); + return T_ARG; + } + return ','; + } +{WORD}[(] { + /* May be a symbol or a macro invocation. */ + mmlval.sym = symtable_get(mmtext); + if (mmlval.sym->type != MACRO) { + stop("Expecting Macro Name", + EX_DATAERR); + } + unput('('); + parren_count = 0; + BEGIN ARGLIST; + return T_SYMBOL; + } +. { + snprintf(buf, sizeof(buf), "Invalid character " + "'%c'", mmtext[0]); + stop(buf, EX_DATAERR); + } +%% + +int +mmwrap() +{ + stop("EOF encountered in macro call", EX_DATAERR); +} diff --git a/sys/dev/microcode/aic7xxx/aicasm_scan.l b/sys/dev/microcode/aic7xxx/aicasm_scan.l index c3098c3aae3..d4d7177e26f 100644 --- a/sys/dev/microcode/aic7xxx/aicasm_scan.l +++ b/sys/dev/microcode/aic7xxx/aicasm_scan.l @@ -2,7 +2,8 @@ /* * Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler. * - * Copyright (c) 1997, 1998 Justin T. Gibbs. + * Copyright (c) 1997, 1998, 2000 Justin T. Gibbs. + * Copyright (c) 2001 Adaptec Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,30 +12,39 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the - * GNU Public License ("GPL"). + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD: src/sys/dev/aic7xxx/aicasm_scan.l,v 1.15 1999/12/06 18:23:30 gibbs Exp $ + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_scan.l,v 1.18 2002/06/05 22:51:54 gibbs Exp $ */ #include <sys/types.h> #include <limits.h> +#include <regex.h> #include <stdio.h> #include <string.h> #include <sysexits.h> @@ -44,23 +54,29 @@ #include "aicasm_symbol.h" #include "y.tab.h" -#define MAX_STR_CONST 256 -char string_buf[MAX_STR_CONST]; -char *string_buf_ptr; -int parren_count; -int quote_count; +/* This is used for macro body capture too, so err on the large size. */ +#define MAX_STR_CONST 4096 +static char string_buf[MAX_STR_CONST]; +static char *string_buf_ptr; +static int parren_count; +static int quote_count; +static char buf[255]; %} -%option nounput - -PATH [-/A-Za-z0-9_.]*[./][-/A-Za-z0-9_.]* +PATH ([/]*[-A-Za-z0-9_.])+ WORD [A-Za-z_][-A-Za-z_0-9]* SPACE [ \t]+ +MCARG [^(), \t]+ +MBODY ((\\[^\n])*[^\n\\]*)+ %x COMMENT %x CEXPR %x INCLUDE %x STRING +%x MACRODEF +%x MACROARGLIST +%x MACROCALLARGS +%x MACROBODY %% \n { ++yylineno; } @@ -109,6 +125,7 @@ if[ \t]*\( { } VERSION { return T_VERSION; } +PATCH_ARG_LIST { return T_PATCH_ARG_LIST; } \" { string_buf_ptr = string_buf; BEGIN STRING; @@ -130,11 +147,13 @@ VERSION { return T_VERSION; } {SPACE} ; /* Register/SCB/SRAM definition keywords */ +export { return T_EXPORT; } register { return T_REGISTER; } const { yylval.value = FALSE; return T_CONST; } download { return T_DOWNLOAD; } address { return T_ADDRESS; } access_mode { return T_ACCESS_MODE; } +modes { return T_MODES; } RW|RO|WO { if (strcmp(yytext, "RW") == 0) yylval.value = RW; @@ -146,6 +165,8 @@ RW|RO|WO { } BEGIN_CRITICAL { return T_BEGIN_CS; } END_CRITICAL { return T_END_CS; } +SET_SRC_MODE { return T_SET_SRC_MODE; } +SET_DST_MODE { return T_SET_DST_MODE; } bit { return T_BIT; } mask { return T_MASK; } alias { return T_ALIAS; } @@ -153,6 +174,7 @@ size { return T_SIZE; } scb { return T_SCB; } scratch_ram { return T_SRAM; } accumulator { return T_ACCUM; } +mode_pointer { return T_MODE_PTR; } allones { return T_ALLONES; } allzeros { return T_ALLZEROS; } none { return T_NONE; } @@ -193,7 +215,9 @@ nop { return T_NOP; } else { return T_ELSE; } /* Allowed Symbols */ -[-+,:()~|&."{};<>[\]!=] { return yytext[0]; } +\<\< { return T_EXPR_LSHIFT; } +\>\> { return T_EXPR_RSHIFT; } +[-+,:()~|&."{};<>[\]/*!=] { return yytext[0]; } /* Number processing */ 0[0-7]* { @@ -210,7 +234,6 @@ else { return T_ELSE; } yylval.value = strtol(yytext, NULL, 10); return T_NUMBER; } - /* Include Files */ #include{SPACE} { BEGIN INCLUDE; @@ -225,13 +248,7 @@ else { return T_ELSE; } quote_count++; return yytext[0]; } -<INCLUDE>. { stop("Invalid include line", EX_DATAERR); } - - /* For parsing C include files with #define foo */ -#define { yylval.value = TRUE; return T_CONST; } - /* Throw away macros */ -#define[^\n]*[()]+[^\n]* ; -<INITIAL,INCLUDE>{PATH} { +<INCLUDE>{PATH} { char *yptr; yptr = yytext; @@ -242,12 +259,158 @@ else { return T_ELSE; } *string_buf_ptr = '\0'; return T_PATH; } +<INCLUDE>. { stop("Invalid include line", EX_DATAERR); } +#define{SPACE} { + BEGIN MACRODEF; + return T_DEFINE; + } +<MACRODEF>{WORD}{SPACE} { + char *yptr; + + /* Strip space and return as a normal symbol */ + yptr = yytext; + while (*yptr != ' ' && *yptr != '\t') + yptr++; + *yptr = '\0'; + yylval.sym = symtable_get(yytext); + string_buf_ptr = string_buf; + BEGIN MACROBODY; + return T_SYMBOL; + } +<MACRODEF>{WORD}\( { + /* + * We store the symbol with its opening + * parren so we can differentiate macros + * that take args from macros with the + * same name that do not take args as + * is allowed in C. + */ + BEGIN MACROARGLIST; + yylval.sym = symtable_get(yytext); + unput('('); + return T_SYMBOL; + } +<MACROARGLIST>{WORD} { + yylval.str = yytext; + return T_ARG; + } +<MACROARGLIST>{SPACE} ; +<MACROARGLIST>[(,] { + return yytext[0]; + } +<MACROARGLIST>[)] { + string_buf_ptr = string_buf; + BEGIN MACROBODY; + return ')'; + } +<MACROARGLIST>. { + snprintf(buf, sizeof(buf), "Invalid character " + "'%c' in macro argument list", + yytext[0]); + stop(buf, EX_DATAERR); + } +<MACROCALLARGS>{SPACE} ; +<MACROCALLARGS>\( { + parren_count++; + if (parren_count == 1) + return ('('); + *string_buf_ptr++ = '('; + } +<MACROCALLARGS>\) { + parren_count--; + if (parren_count == 0) { + BEGIN INITIAL; + return (')'); + } + *string_buf_ptr++ = ')'; + } +<MACROCALLARGS>{MCARG} { + char *yptr; -{WORD} { yylval.sym = symtable_get(yytext); return T_SYMBOL; } + yptr = yytext; + while (*yptr) + *string_buf_ptr++ = *yptr++; + } +<MACROCALLARGS>\, { + if (string_buf_ptr != string_buf) { + /* + * Return an argument and + * rescan this comma so we + * can return it as well. + */ + *string_buf_ptr = '\0'; + yylval.str = string_buf; + string_buf_ptr = string_buf; + unput(','); + return T_ARG; + } + return ','; + } +<MACROBODY>\\\n { + /* Eat escaped newlines. */ + ++yylineno; + } +<MACROBODY>\n { + /* Macros end on the first unescaped newline. */ + BEGIN INITIAL; + *string_buf_ptr = '\0'; + yylval.str = string_buf; + ++yylineno; + return T_MACROBODY; + } +<MACROBODY>{MBODY} { + char *yptr; + yptr = yytext; + while (*yptr) + *string_buf_ptr++ = *yptr++; + } +{WORD}\( { + char *yptr; + char *ycopy; + + /* May be a symbol or a macro invocation. */ + yylval.sym = symtable_get(yytext); + if (yylval.sym->type == MACRO) { + YY_BUFFER_STATE old_state; + YY_BUFFER_STATE temp_state; + + ycopy = strdup(yytext); + yptr = ycopy + yyleng; + while (yptr > ycopy) + unput(*--yptr); + old_state = YY_CURRENT_BUFFER; + temp_state = + yy_create_buffer(stdin, + YY_BUF_SIZE); + yy_switch_to_buffer(temp_state); + mm_switch_to_buffer(old_state); + mmparse(); + mm_switch_to_buffer(temp_state); + yy_switch_to_buffer(old_state); + mm_delete_buffer(temp_state); + expand_macro(yylval.sym); + } else { + if (yylval.sym->type == UNINITIALIZED) { + /* Try without the '(' */ + symbol_delete(yylval.sym); + yytext[yyleng-1] = '\0'; + yylval.sym = + symtable_get(yytext); + } + unput('('); + return T_SYMBOL; + } + } +{WORD} { + yylval.sym = symtable_get(yytext); + if (yylval.sym->type == MACRO) { + expand_macro(yylval.sym); + } else { + return T_SYMBOL; + } + } . { - char buf[255]; - snprintf(buf, sizeof(buf), "Invalid character " "'%c'", yytext[0]); stop(buf, EX_DATAERR); @@ -264,9 +427,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; @@ -318,6 +479,92 @@ include_file(file_name, type) yyfilename = strdup(file_name); } +static void next_substitution(struct symbol *mac_symbol, const char *body_pos, + const char **next_match, + struct macro_arg **match_marg, regmatch_t *match); + +void +expand_macro(struct symbol *macro_symbol) +{ + struct macro_arg *marg; + struct macro_arg *match_marg; + const char *body_head; + const char *body_pos; + const char *next_match; + + /* + * Due to the nature of unput, we must work + * backwards through the macro body performing + * any expansions. + */ + body_head = macro_symbol->info.macroinfo->body; + body_pos = body_head + strlen(body_head); + while (body_pos > body_head) { + regmatch_t match; + + next_match = body_head; + match_marg = NULL; + next_substitution(macro_symbol, body_pos, &next_match, + &match_marg, &match); + + /* Put back everything up until the replacement. */ + while (body_pos > next_match) + unput(*--body_pos); + + /* Perform the replacement. */ + if (match_marg != NULL) { + const char *strp; + + next_match = match_marg->replacement_text; + strp = next_match + strlen(next_match); + while (strp > next_match) + unput(*--strp); + + /* Skip past the unexpanded macro arg. */ + body_pos -= match.rm_eo - match.rm_so; + } + } + + /* Cleanup replacement text. */ + TAILQ_FOREACH(marg, ¯o_symbol->info.macroinfo->args, links) { + free(marg->replacement_text); + } +} + +/* + * Find the next substitution in the macro working backwards from + * body_pos until the beginning of the macro buffer. next_match + * should be initialized to the beginning of the macro buffer prior + * to calling this routine. + */ +static void +next_substitution(struct symbol *mac_symbol, const char *body_pos, + const char **next_match, struct macro_arg **match_marg, + regmatch_t *match) +{ + regmatch_t matches[2]; + struct macro_arg *marg; + const char *search_pos; + int retval; + + do { + search_pos = *next_match; + + TAILQ_FOREACH(marg, &mac_symbol->info.macroinfo->args, links) { + + retval = regexec(&marg->arg_regex, search_pos, 2, + matches, 0); + if (retval == 0 + && (matches[1].rm_eo + search_pos) <= body_pos + && (matches[1].rm_eo + search_pos) > *next_match) { + *match = matches[1]; + *next_match = match->rm_eo + search_pos; + *match_marg = marg; + } + } + } while (search_pos != *next_match); +} + int yywrap() { diff --git a/sys/dev/microcode/aic7xxx/aicasm_symbol.c b/sys/dev/microcode/aic7xxx/aicasm_symbol.c index 2ebd01b4bd1..7b4ba330f65 100644 --- a/sys/dev/microcode/aic7xxx/aicasm_symbol.c +++ b/sys/dev/microcode/aic7xxx/aicasm_symbol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aicasm_symbol.c,v 1.4 2002/06/28 00:34:55 smurph Exp $ */ +/* $OpenBSD: aicasm_symbol.c,v 1.5 2002/06/30 18:25:58 smurph Exp $ */ /* * Aic7xxx SCSI host adapter firmware asssembler symbol table implementation * @@ -11,31 +11,40 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the - * GNU Public License ("GPL"). + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.c,v 1.14 2001/07/18 21:03:32 gibbs Exp $ + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.c,v 1.17 2002/06/06 16:07:18 gibbs Exp $ */ #include <sys/types.h> #include <db.h> #include <fcntl.h> +#include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -317,12 +326,15 @@ symtable_dump(ofile) symlist_t constants; symlist_t download_constants; symlist_t aliases; + symlist_t exported_labels; + u_int i; SLIST_INIT(®isters); SLIST_INIT(&masks); SLIST_INIT(&constants); SLIST_INIT(&download_constants); SLIST_INIT(&aliases); + SLIST_INIT(&exported_labels); if (symtable != NULL) { DBT key; @@ -344,10 +356,8 @@ symtable_dump(ofile) symlist_add(&masks, cursym, SYMLIST_SORT); break; case CONST: - if (cursym->info.cinfo->define == FALSE) { - symlist_add(&constants, cursym, + symlist_add(&constants, cursym, SYMLIST_INSERT_HEAD); - } break; case DOWNLOAD_CONST: symlist_add(&download_constants, cursym, @@ -357,6 +367,12 @@ symtable_dump(ofile) symlist_add(&aliases, cursym, SYMLIST_INSERT_HEAD); break; + case LABEL: + if (cursym->info.linfo->exported == 0) + break; + symlist_add(&exported_labels, cursym, + SYMLIST_INSERT_HEAD); + break; default: break; } @@ -395,14 +411,14 @@ symtable_dump(ofile) /* Output what we have */ fprintf(ofile, -"/* - * DO NOT EDIT - This file is automatically generated - * from the following source files: - * -%s */\n", versions); +"/*\n" +" * DO NOT EDIT - This file is automatically generated\n" +" * from the following source files:\n" +" *\n" +"%s */\n", versions); while (registers.slh_first != NULL) { symbol_node_t *curnode; - u_int8_t value; + u_int value; char *tab_str; char *tab_str2; @@ -472,5 +488,20 @@ symtable_dump(ofile) curnode->symbol->info.cinfo->value); free(curnode); } + fprintf(ofile, "#define\tDOWNLOAD_CONST_COUNT\t0x%02x\n", i); + + fprintf(ofile, "\n\n/* Exported Labels */\n"); + + while (exported_labels.slh_first != NULL) { + symbol_node_t *curnode; + + curnode = exported_labels.slh_first; + SLIST_REMOVE_HEAD(&exported_labels, links); + fprintf(ofile, "#define\tLABEL_%-8s\t0x%02x\n", + curnode->symbol->name, + curnode->symbol->info.linfo->address); + free(curnode); + } } } + diff --git a/sys/dev/microcode/aic7xxx/aicasm_symbol.h b/sys/dev/microcode/aic7xxx/aicasm_symbol.h index 028f072a46b..08f2acb2102 100644 --- a/sys/dev/microcode/aic7xxx/aicasm_symbol.h +++ b/sys/dev/microcode/aic7xxx/aicasm_symbol.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aicasm_symbol.h,v 1.6 2002/06/28 00:34:55 smurph Exp $ */ +/* $OpenBSD: aicasm_symbol.h,v 1.7 2002/06/30 18:25:58 smurph Exp $ */ /* * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions * @@ -11,25 +11,33 @@ * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * substantially similar to the "NO WARRANTY" disclaimer below + * ("Disclaimer") and any redistribution must be conditioned upon + * including a substantially similar Disclaimer requirement for further + * binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the - * GNU Public License ("GPL"). + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. * - * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.h,v 1.12 2000/11/10 19:54:17 gibbs Exp $ + * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.h,v 1.15 2002/06/05 22:51:54 gibbs Exp $ */ #include <sys/queue.h> @@ -45,7 +53,8 @@ typedef enum { CONST, DOWNLOAD_CONST, LABEL, - CONDITIONAL + CONDITIONAL, + MACRO }symtype; typedef enum { @@ -55,10 +64,11 @@ typedef enum { }amode_t; struct reg_info { - u_int8_t address; + u_int address; int size; amode_t mode; u_int8_t valid_bitmask; + u_int8_t modes; int typecheck_masks; }; @@ -70,7 +80,7 @@ struct mask_info { }; struct const_info { - u_int8_t value; + u_int value; int define; }; @@ -80,12 +90,26 @@ struct alias_info { struct label_info { int address; + int exported; }; struct cond_info { int func_num; }; +struct macro_arg { + TAILQ_ENTRY(macro_arg) links; + regex_t arg_regex; + char *replacement_text; +}; +TAILQ_HEAD(macro_arg_list, macro_arg) args; + +struct macro_info { + struct macro_arg_list args; + int narg; + const char* body; +}; + typedef struct expression_info { symlist_t referenced_syms; int value; @@ -101,6 +125,7 @@ typedef struct symbol { struct alias_info *ainfo; struct label_info *linfo; struct cond_info *condinfo; + struct macro_info *macroinfo; }info; } symbol_t; @@ -170,4 +195,3 @@ void symlist_free(symlist_t *symlist); void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1, symlist_t *symlist_src2); void symtable_dump(FILE *ofile); - |