diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f72f18f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +r2plugin/*.so +examples/build/*.o +examples/build/*.elf diff --git a/README.md b/README.md index 52f7d1d..132aa1d 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,23 @@ engineering ADSP-2191 firmware. ## Plugin Status -Currently decodes: NOP, IDLE, Type 1 (multifunction), Type 3 -(direct memory), Type 4 (compute + memory), Type 6/7 (immediate -loads), Type 10/10a (jump/call), Type 17 (reg move), Type 20 -(RTS/RTI). +The decoder now covers most ADSP-219x instruction types and has +assembler verification for 34 of 37 documented opcode families. -Work in progress: Type 9/9a (standalone compute), Type 11 -(DO UNTIL), Type 15 (shift), Type 18 (mode control), Type 25 -(saturate). +Assembler-verified coverage includes: + +- Types 1, 3, 4, 6, 7, 8, 9, 9a, 10, 10a, 11, 12, 14, 15, 16, + 17, 18, 19, 20, 21, 21a, 23, 24, 25, 26, 29, 30, 32, 33, 34, + 35, 36, 37 + +Structural-only coverage remains for: + +- Type 22 / 22a (2-word immediate data write) +- Type 31 (IDLE) +- Type 32a (DAG register store with transfer) + +For the current verification matrix and test inputs, see +`r2plugin/TESTING.md`. ## Assembler diff --git a/r2plugin/Makefile b/r2plugin/Makefile index 1449d1c..7b80baf 100644 --- a/r2plugin/Makefile +++ b/r2plugin/Makefile @@ -1,15 +1,24 @@ -NAME=asm_adsp219x -R2_PLUGINS=$(shell r2 -H R2_USER_PLUGINS) -R2_INCDIR=$(shell r2 -H R2_INCDIR) -R2_LIBDIR=$(shell r2 -H R2_LIBDIR) +NAME ?= asm_adsp219x +CC ?= gcc +CFLAGS ?= -Wall -Wextra -O2 -fPIC +LDFLAGS ?= +LDLIBS ?= -lr_arch -lr_util + +R2_PLUGINS := $(shell r2 -H R2_USER_PLUGINS) +R2_INCDIR := $(shell r2 -H R2_INCDIR) +R2_LIBDIR := $(shell r2 -H R2_LIBDIR) + +CPPFLAGS += -I$(R2_INCDIR) -I$(R2_INCDIR)/sdb all: $(NAME).so $(NAME).so: $(NAME).c - gcc -shared -Wall -O2 -fPIC \ - -I$(R2_INCDIR) -I$(R2_INCDIR)/sdb \ + $(CC) $(CPPFLAGS) $(CFLAGS) -shared $(LDFLAGS) \ -L$(R2_LIBDIR) \ - $(NAME).c -o $@ -lr_arch -lr_util + $< -o $@ $(LDLIBS) + +test: $(NAME).so + r2 -q -a adsp219x -L ./$(NAME).so -b 24 -c "pd 48" ../examples/isa_test.bin >/dev/null install: $(NAME).so mkdir -p $(R2_PLUGINS) @@ -21,4 +30,4 @@ uninstall: clean: rm -f $(NAME).so -.PHONY: all install uninstall clean +.PHONY: all test install uninstall clean diff --git a/r2plugin/README.md b/r2plugin/README.md index 5a6579e..c01b30e 100644 --- a/r2plugin/README.md +++ b/r2plugin/README.md @@ -10,6 +10,9 @@ ADSP-2191) 24-bit instructions in radare2 and iaito. Requires: GCC, radare2 >= 5.8.0 (RArchPlugin API). +The `Makefile` also provides `make test`, which builds the plugin and +runs a smoke test against `../examples/isa_test.bin`. + ## Usage r2 -a adsp219x -b 24 firmware.bin @@ -20,9 +23,16 @@ Compare against the assembler-verified test ROM: r2 -a adsp219x -b 24 -q -c "pd 48" ../examples/isa_test.bin +Or run the local plugin without installing it: + + make test + The test ROM (`isa_test.dsp`) was assembled with open21xx and contains known opcodes for all major instruction types. +For the current verification matrix and remaining structural-only +types, see `TESTING.md`. + ## Coding Standards This plugin follows the GNU Coding Standards for C source code. diff --git a/r2plugin/asm_adsp219x.c b/r2plugin/asm_adsp219x.c index d67d4b0..6f8a89e 100644 --- a/r2plugin/asm_adsp219x.c +++ b/r2plugin/asm_adsp219x.c @@ -64,6 +64,7 @@ get_reg (int gp, int idx) static bool decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) { + (void) as; ut32 ins, ins2 = 0; const ut8 *b = op->bytes; int avail = op->size; @@ -814,6 +815,7 @@ decode (RArchSession *as, RAnalOp *op, RAnalOpMask mask) static int archinfo (RArchSession *s, ut32 q) { + (void) s; switch (q) { case R_ARCH_INFO_CODE_ALIGN: return 3; case R_ARCH_INFO_MINOP_SIZE: case R_ARCH_INFO_MAXOP_SIZE: return 3; diff --git a/r2plugin/asm_adsp219x.so b/r2plugin/asm_adsp219x.so deleted file mode 100755 index 8632862..0000000 Binary files a/r2plugin/asm_adsp219x.so and /dev/null differ