From 05cbfd57959b54c46375105c1b653a5803c591ed Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 23 Dec 2005 02:56:24 +0000 Subject: [PATCH] mangle i2clib into two copies, one for panic starting pan_... --- detpic/.cvsignore | 3 +++ detpic/Makefile | 10 ++++++-- detpic/detect.asm | 4 --- detpic/final.inc | 2 +- detpic/i2clib.asm | 7 ------ detpic/i2clib.incm | 7 ++++++ detpic/make-panicworthy | 55 +++++++++++++++++++++++++++++++++++++++++ detpic/morse.messages | 1 + detpic/panic.asm | 18 +++++++++++--- detpic/program.asm | 3 --- detpic/variables.asm | 1 - 11 files changed, 89 insertions(+), 22 deletions(-) create mode 100755 detpic/make-panicworthy diff --git a/detpic/.cvsignore b/detpic/.cvsignore index 3e990c1..d3c835c 100644 --- a/detpic/.cvsignore +++ b/detpic/.cvsignore @@ -18,3 +18,6 @@ t *.new *.tmp *+program.disasm +i2clib+panic.asm +i2clib+panic.inc +i2clib+panic.mangles diff --git a/detpic/Makefile b/detpic/Makefile index b42be34..7da6979 100644 --- a/detpic/Makefile +++ b/detpic/Makefile @@ -3,7 +3,7 @@ CEBPIC= ../cebpic/ PICNOS= 0 1 2 PROGRAMS= program -OBJS_program= vectors.o panic.o routines-led.o i2clib.o \ +OBJS_program= vectors.o panic.o routines-led.o i2clib+panic.o \ misc.o detect.o variables.o points.o serout.o \ syncwrite.o mascan.o energy.o \ reverse.o nmra-stream.o @@ -16,7 +16,7 @@ INCLUDES= \ detect.inc \ energy.fin \ final.inc \ - i2clib.inc \ + i2clib+panic.inc \ i2clib.incm \ misc.fin \ mascan.fin \ @@ -39,6 +39,12 @@ include $(CEBPIC)manypics.make syncwrite.asm: ../iwjpictest/syncwrite.asm cp $< $@ +i2clib+panic.%: make-panicworthy i2clib+panic.mangles i2clib.% + ./$+ -Ii2clib.inc,i2clib+panic.inc $o + +i2clib+panic.mangles: make-panicworthy i2clib.inc i2clib.asm Makefile + ./$(filter-out Makefile, $+) -M $o + %+clocks.inc: make-clocks %.clocks ./$+ $(CLOCKS) $o diff --git a/detpic/detect.asm b/detpic/detect.asm index f5b43b6..f26a45b 100644 --- a/detpic/detect.asm +++ b/detpic/detect.asm @@ -176,8 +176,6 @@ near_i2csu code ;---------- i2csu_read_begin ; called from High ISR, see i2clib.inc - bt_f_if1 picno,picno_panicd - bra i2csu_read_begin_panicd bt_f_if1 idloc1,idloc1_boarddet bra i2csu_read_begin_detectors bra i2csu_read_begin_reversers @@ -185,8 +183,6 @@ i2csu_read_begin ;---------- i2csu_read_another ; called from High ISR, see i2clib.inc - bt_f_if1 picno,picno_panicd - bra i2csu_read_another_panicd mov_fw POSTINC2 i2cs_read_data_macro mov_fw outmsg_end diff --git a/detpic/final.inc b/detpic/final.inc index 6e5ede9..5b31b79 100644 --- a/detpic/final.inc +++ b/detpic/final.inc @@ -1,7 +1,7 @@ include ../iwjpictest/syncwrite.inc include detect.inc include energy.fin - include i2clib.inc + include i2clib+panic.inc include mascan.fin include misc.fin include nmra-stream.fin diff --git a/detpic/i2clib.asm b/detpic/i2clib.asm index b6b8b94..e594532 100644 --- a/detpic/i2clib.asm +++ b/detpic/i2clib.asm @@ -80,13 +80,6 @@ st_stopping equ 0 ; Stopping code -;---------- -i2cpanic macro morse_addr -; Like panic but turns off the I2C controller - bc_f SSPCON1, SSPEN - panic morse_addr - endm - ;---------- slave2addr ; computes slave address in form suitable for use in i2c controller diff --git a/detpic/i2clib.incm b/detpic/i2clib.incm index 344e217..732cef4 100644 --- a/detpic/i2clib.incm +++ b/detpic/i2clib.incm @@ -2,6 +2,13 @@ ; MACROS FOR I2CLIB USERS ; see i2clib.inc +;---------- +i2cpanic macro morse_addr +; Like panic but turns off the I2C controller + bc_f SSPCON1, SSPEN + panic morse_addr + endm + ;-------------------- i2cs_read_data_macro macro mov_wf SSPBUF diff --git a/detpic/make-panicworthy b/detpic/make-panicworthy new file mode 100755 index 0000000..9f127cf --- /dev/null +++ b/detpic/make-panicworthy @@ -0,0 +1,55 @@ +#!/usr/bin/perl -n +BEGIN { + while (@ARGV && $ARGV[$#ARGV] =~ m/^\-/) { + $_= pop; + if (m/^-M$/) { $manglout= 1; } + elsif (m/^-I(\S+),(\S+)$/) { $mapinclude{$1}= $2; } + else { die "$_ ?"; } + } +} +$l= $_; +$pfx= 'pan_'; +$pcode= ''; +sub endsection () { + return unless defined $codesection; + print(";{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\n", + $codesection, + ";}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n") + or die $! + unless $manglout; + undef $codesection; +} +sub mangle ($) { + print ";#MANGLE# $1\n" + or die $! + if $manglout; +} +if (m/^(\w*)\s+code\b/) { + endsection(); + $codesection= "$pfx$_"; +} elsif (m/^\s+(?:include|end|udata(?:_acs)?)\b/) { + endsection(); +} elsif (m/^(\w+)\s+macro\b/) { + $inmacro++; +} elsif (m/^\w*\s+endm\b/) { + $inmacro--; +} elsif (m/^(\w*)\s+(?:equ)\b/) { +} elsif (m/^\s+extern\s+(\w+)\b/) { + mangle($1); + print " extern $pfx$1;##\n" or die $! + unless $manglout; +} elsif (!$inmacro && defined $codesection) { + if (!s/^\;/;\#\#/) { + mangle($1) if m/^(\w+)\b/; + s/\b(\w+)\b/ $mangle{$1} ? "$pfx$1" : $1 /ge; + } + $codesection .= $_; +} elsif (m/^\;\#MANGLE\# (\w+)$/) { + $mangle{$1}= 1; + $l= ''; +} +if (m/^\s+include\s+(\S+)\s+$/ && exists $mapinclude{$1}) { + $l= " include $mapinclude{$1}\n"; +} +print $l or die $! + unless $manglout; diff --git a/detpic/morse.messages b/detpic/morse.messages index 277d053..96592f6 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -63,6 +63,7 @@ UEC URM UCI UCP +USP # Messages for i2clib, S* SM i2clib:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state diff --git a/detpic/panic.asm b/detpic/panic.asm index 151d0bc..6b08ea0 100644 --- a/detpic/panic.asm +++ b/detpic/panic.asm @@ -96,7 +96,6 @@ stacksave_loop clr_f STKPTR ; avoids stack overruns clr_f panicst - bs_f picno, picno_panicd call panic_kill_hook @@ -342,7 +341,7 @@ waiting_done_if_master ; MEMORY READOUT ;---------- -i2csu_write_panicd +pan_i2csu_write_data panicd_process_input_byte ; W instruction from host or master tst_w_ifnz @@ -392,8 +391,13 @@ panic_crashread_commanded bs_f panicst, panicst_acked ; since we were asked to panic morse_E + +;---------- +pan_i2csu_write_begin + return + ;---------- -i2csu_read_begin_panicd +pan_i2csu_read_begin mov_lw 0x80 ; M0000000 bt_f_if0 panicst, panicst_acked goto i2cs_read_data @@ -403,13 +407,19 @@ i2csu_read_panicd_ok goto i2cs_read_data ;---------- -i2csu_read_another_panicd +pan_i2csu_read_another bt_f_if1 panicst, panicst_acked bra i2csu_read_panicd_ok ; not ok mov_lw 0x0b ; AARGH goto i2cs_read_data +;---------- +pan_i2cmu_read_got_byte +pan_i2cmu_write_next_byte +pan_i2cmu_done + i2cpanic morse_USP + near_gots code ;---------- got_aargh diff --git a/detpic/program.asm b/detpic/program.asm index 1638d76..ce3bb59 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -197,9 +197,6 @@ near_local_do code i2csu_write_data call led_green - bt_f_if1 picno,picno_panicd - goto i2csu_write_panicd - bt_w_if0 7 bra i2csu_write_if_special bt_w_if1 6 diff --git a/detpic/variables.asm b/detpic/variables.asm index e70fae2..e0380c8 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -4,7 +4,6 @@ udata_acs picno res 1 ; from first idlocs byte -picno_panicd equ 7 ; this bit set if we panic idloc1 res 1 ; from 2nd idlocs byte; bit 7 is master: idloc1_master equ 7 -- 2.30.2