-all: pic hostprogs
+recurse = set -e; for f in $($(1)_DIRS); do $(MAKE) -C $$f $(2); done
-PICPROGS_DIRS= iwjpictest cebpic detpic
-HOSTPROGS_DIRS= layout hostside
+PIC_DIRS= iwjpictest cebpic detpic
+HOST_DIRS= layout hostside
+
+all:
+ $(call recurse,HOST,recurse)
+ $(call recurse,PIC,)
+
+host: host_recurse
+
+host_%:
+ $(call recurse,HOST,$*)
pic:
- set -e; for f in $(PICPROGS_DIRS); do $(MAKE) -C $$f; done
+ $(MAKE) -C layout for-pic
+ $(call recurse,PIC,)
pic_%:
- set -e; for f in $(PICPROGS_DIRS); do $(MAKE) -C $$f $*; done
+ $(MAKE) -C layout for-pic
+ $(call recurse,PIC,$*)
+
+pic_clean:
+ $(call recurse,PIC,clean)
-hostprogs:
- set -e; for f in $(HOSTPROGS_DIRS); do $(MAKE) -C $$f; done
+clean: host_clean pic_clean
-*.hex
+*+morse.asm
*.cod
+*.hex
*.lst
*.map
-idlocs*.asm
+.submakefile
+blank[0246].asm
gpsim.log
-routines.lib
-morse-auto.asm
-morse-auto.inc
+idlocs*.asm
+morse+auto.inc
ours-pindata.asm
+routines.lib
-PROGRAMS= led-flash send-serial panic reply-serial \
- nmra-stream nmra-stream,slow tblrd_test \
- i2c-test i2c-test,slow
-# booster-output-low -disabled because you forgot to cvs add it
-INCLUDES= common.inc morse-auto.inc ../iwjpictest/insn-aliases.inc
-LIBS= routines.lib
+CEBPIC= ./
PICNOS= 0 1 3
-include manypics.make
+PROGRAMS= led-flash send-serial panic reply-serial \
+ nmra-stream nmra-stream,slow tblrd_test \
+ i2c-test i2c-test,slow
ROUTINES= routines-led
+LIBS= routines.lib
-clean: manypic-clean
- rm -f routines.lib
+INCLUDES= common.inc pindata.inc
+
+include manypics.make
routines.lib: $(addsuffix .o, $(ROUTINES))
rm -f $@.new
%,slow.o: %.asm
$(ASSEMBLE) -D SLOW_VERSION -c -o $@ $<
+
+clean: manypic-clean
+ rm -f routines.lib
+default: all
+
+#---------- bizarre macro arrangements for $(PROGRAMS) ----------
+
+define define_prog
+
+TARGETS += $(1)+code.hex $(1)+program.hex $(1)+program.map
+TARGETS += $$(foreach i, $$(PICNOS), $(1)+entire$$i.hex)
+
+$(1)_CODEHEX= $$(foreach panel, $$(XCODEN_$(1)), $(1)+$$(panel).hex) \
+ $$(foreach panel, $$(XCODE1_$(1)), $$(panel).hex)
+
+$(1)+code.hex: $(1)+program.hex $($(1)_CODEHEX)
+ $$(MERGEHEX)
+
+$(1)+entire%.hex: $(1)+program.hex $($(1)_CODEHEX) idlocs%.hex config.hex
+ $$(MERGEHEX)
+
+$(1)+program.hex: $(1).o $(OBJS_$(prog)) $(LIBS)
+ $$(LINK)
+
+endef
+
+define define_directasm
+
+$(1).hex: $(1).asm
+ $$(ASSEMBLE) $$<
+endef
+
+define makesubmakefile
+set -e; d=.submakefile.new; rm -f $$d; for f in "$$@";do echo "$$f" >>$$d; done
+--
+$(foreach prog, $(PROGRAMS), $(call define_prog,$(prog)))
+$(foreach da, idlocs% config %+morse blank%, $(call define_directasm,$(da)))
+endef
+
+.submakefile: $(CEBPIC)manypics.make Makefile
+ : $(shell $(makesubmakefile)) ... generate .submakefile
+ @mv -f $@.new $@
+
+ifneq ($(MAKECMDGOALS),clean)
+include .submakefile
+endif
+
+blank0.asm blank2.asm blank4.asm blank6.asm: blank%.asm: $(CEBPIC)manypics.make
+ echo >$@.new " org 0x$*000"
+ echo >>$@.new " nop"
+ echo >>$@.new " end"
+ mv -f $@.new $@
+
+#---------- general definitions etc. ----------
+
+TARGETS += $(foreach i, $(PICNOS), idlocs$i.hex noncode$i.hex)
+MORSE_INCLUDE ?= common.inc
+INCLUDES += ../iwjpictest/insn-aliases.inc morse+auto.inc
+MERGEHEX= $(CEBPIC)merge-hex $^ $o
+
include ../common.make
include ../pic.make
-perpic%.hex: config.o idlocs%.o
- $(LINK)
+#---------- targets ----------
-morse-auto.inc: $(CEBPIC)morse-auto.asm-gen morse-auto.messages
- ./$^ inc $o
+all: $(TARGETS)
-%-automorse.asm: $(CEBPIC)morse-auto.asm-gen morse-auto.messages %-bare.map
- ./$^ asm $o
+noncode%.hex: idlocs%.hex config.hex
+ $(MERGEHEX)
+
+morse+auto.inc: $(CEBPIC)morse-generator morse.messages
+ ./$^ inc $o
-%-bare.map: %.o $(LIBS)
- gplink -m -o $*-bare.hex $^
+%+morse.asm: $(CEBPIC)morse-generator morse.messages %+program.map
+ ./$^ asm -I$(MORSE_INCLUDE) $o
-%-entire0.hex: %.o config.o idlocs0.o $(LIBS) $(DEFLIBS)
- $(LINK)
+%.map: %.hex
+ @:
idlocs%.asm: $(CEBPIC)make-idlocs
./$< $* >$@.new && mv -f $@.new $@
cp $< $@
manypic-clean: pic-clean
- rm -f idlocs*.asm *.map *-automorse.*
+ rm -f idlocs*.asm *+morse.* morse+auto.inc blank[0246].*
-.PRECIOUS: idlocs%.asm %-bare.map %-automorse.asm
+.PRECIOUS: idlocs%.asm morse+auto.inc %+morse.asm %+morse.hex %.map
--- /dev/null
+#!/usr/bin/perl
+$end= ':00000001FF';
+while (<>) {
+ chomp;
+ next if uc $_ eq $end;
+ print or die $!;
+ print "\n" or die $!;
+}
+print $end or die $!;
+print "\n" or die $!;
+++ /dev/null
-; stub file
+++ /dev/null
- include common.inc
#!/usr/bin/perl
-# Converts morse-auto.messages to morse-auto.asm or morse-auto.inc.
-# morse.asm specifies some flash contents, as follows:
+# Converts morse.messages to *+morse.asm or morse+auto.inc.
+# morse-auto.asm specifies some flash contents, as follows:
#
# Each message XY produces a symbol
# morse_XY
# should also arrange to define any symbolic addresse referred to
# in morse-auto.messages, eg by including the pXXXX.inc.
#
-# morse-auto.asm contains the actual source and morse-auto.inc
-# contains `extern' references for the labels morse_XY.
+# *+morse.asm contains the actual source and morse+auto.inc
+# contains `equ' definitions for the addresses morse_XY.
use IO::File;
use IO::Handle;
sub badusage () {
die ("usages:\n".
- " morse-auto.asm-gen <input>... asm\n".
- " morse-auto.asm-gen <input>... [<file>.map] inc\n");
+ " morse-generator <input>... asm\n".
+ " morse-generator <input>... [<file>.map] inc\n");
}
@ARGV or badusage();
+
+$includefile= 'morse-defs.inc';
+if ($ARGV[$#ARGV] =~ s/^\-I//) {
+ $includefile= pop @ARGV;
+}
+
$which= pop @ARGV;
$which eq 'asm' or $which eq 'inc' or badusage();
$morse{$let}= $morse;
}
-sub oops ($) { die "morse-auto.asm-gen: $ARGV:$.: $_[0]\n"; }
+sub oops ($) { die "morse-generator: $ARGV:$.: $_[0]\n"; }
$mapfile= $ARGV[$#ARGV];
($sym,$val,$progdata,$staticext,$filename) = ($1,$2,$3,$4,$5);
next if $progdata ne 'data';
$filename =~ s/\.asm$//;
- $sym= "$filename:$sym" if $staticext eq 'static';
+ $sym= $staticext eq 'static' ? "$filename:$sym" : "::$sym";
$symval{$sym}= $val;
}
die "$0: $mapfile: $!\n" if $maph->error;
END
;
-print <<'END' or die $!
-
- include morse-defs.inc
- include morse-auto.inc
+print <<END or die $!
+ include $includefile
radix dec
+xxx_unknown_xxx equ 0
morse_section org morse_messages_start
+
END
if $which eq 'asm';
unshift @data, sprintf "0x%x%x", scalar(@addrs), $morse_bytes;
push @data, map {
s/^\:/ $filename.':' /e;
- $filename= $1 if m/^(.+)\:/;
- (exists $symval{$_} ? $symval{$_} :
- "$_ - (0xf00 * !(($_ & 0xf00)^0xf00))");
-
+ $filename= $1 if m/^([^:]+)\:/;
+ $_ = $symval{$_} if exists $symval{$_};
+ m/\:/ ? ' xxx_unknown_xxx' : "$_ - (0xf00 * !(($_ & 0xf00)^0xf00))"
} @addrs;
push @data, ('0') x (3 - (scalar(@data) + 3) % 4);
-*.hex
+*+morse.asm
*.cod
+*.hex
*.lst
*.map
-*-automorse.asm
-idlocs*.asm
+.submakefile
+blank[0246].asm
gpsim.log
-morse-auto.asm
-morse-auto.inc
+idlocs*.asm
+morse+auto.inc
ours-pindata.asm
-PROGRAMS= test-sofar
-INCLUDES= common.inc final.inc morse-auto.inc \
- ../iwjpictest/insn-aliases.inc
-LIBS= vectors.o panic.o routines-led.o variables.o i2clib.o
-DEFLIBS= test-sofar-automorse.o
-PICNOS= 0 1 2
+
CEBPIC= ../cebpic/
-TARGETS= $(addsuffix -bare.map, $(PROGRAMS)) \
- $(foreach i, $(PICNOS), perpic$i.hex)
+PICNOS= 0 1 2
+
+PROGRAMS= test-sofar
+OBJS_test-sofar= vectors.o panic.o routines-led.o i2clib.o
+XCODEN_test-sofar= morse
+XCODE1_test-sofar= blank2 blank6
+
+INCLUDES= common.inc \
+ final.inc \
+ i2clib.inc \
+ panic.fin \
+ panic.inc \
+ routines-led.fin \
+ vectors.fin
include $(CEBPIC)manypics.make
; common macros & equs etc.
;**********************************************************************
-; boilerplate.inc
-; Include this at the top of each file.
-; Does the following things:
-; includes the PIC18F458 definitions file (register and bit names)
-; switches to decimal by default
+; common.inc
+; Generally include this at the top of each file.
include /usr/share/gputils/header/p18f458.inc
radix dec
include panic.inc
+ include morse+auto.inc
include ../iwjpictest/insn-aliases.inc
;****************************************************************************
radix dec
include ../iwjpictest/insn-aliases.inc
include panic.inc
+ include morse+auto.inc
;======================================================================
; NOTATION
+++ /dev/null
- include final.inc
+++ /dev/null
- include common.inc
TI5 ; for iwj
X test-sofar:ch ; bad character received from host
+Z ::nonexistent_variable ; test message
+
# Messages for i2clib, S*
SM i2clib:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state
SS i2clib:st,:sspstat,:sspcon1 ; slave, intr, controller bad state
; Area filled in by morse-auto.asm (see morse-auto.asm-gen for details)
morse_messages_start equ 0x4000
morse_messages_end equ 0x4400
-
- include morse-auto.inc
+++ /dev/null
-;######################################################################
-; seriallib.inc - SERIAL LIBRARY - DECLARATIONS AND DOCUMENTATION
-;
-;============================================================
-; GENERAL INFORMATION
-
-; Purpose:
-; --------
-;
-; This library allows the PIC to communicate with the host via the
-; PIC's UART, configured for RS232 at 9600 8N1. It implements
-; unidirectional flow control: the host may ask the PIC not to
-; transmit, but not vice versa.
-
-; Naming scheme:
-; --------------
-;
-; serial_... are for use by the rest of the program and
-; are the entrypoints which enable use of the serial port
-; serialu_... must be defined in the rest of the program
-; with the functionality and behaviour described.
-
-; At all times following serial_init, the serial hardware in the PIC is
-; completely reserved to the routines defined in seriallib.asm. Nothing
-; else is allowed to read or modify the PIC UART state.
-
-; Use of PORTB, RBIF etc.:
-; ------------------------
-;
-; The seriallib makes use of the PORTB `interrupt on change' feature,
-; and expects at all times after serial_init to have exclusive use of
-; that feature, including the RBIF flag. Only seriallib is allowed to
-; make reads of PORTB directly; the main program must call
-; serial_portb_read instead. The main program may freely write to
-; LATB.
-;
-; If any of RB5, RB6 or RB7 is an output which would be electrically
-; floating if left in tristate (Z state) by the PIC then before
-; calling serial_init the main program must have configured the
-; appropriate TRISB bit(s) as outputs - presumably, after having
-; configured the corresponding LATB bit(s). This will avoid excessive
-; interrupts resulting from floating values.
-;
-; Registers and calling conventions:
-; ----------------------------------
-;
-; Unless otherwise stated, all routines accept any value in, and may
-; trash, W and the flags. All other registers and locations not
-; specifically mentioned here will be preserved by the
-; serial_... routines (and are therefore reserved for the rest of the
-; program). In all cases, routines are called with CALL or RCALL or
-; the equivalent, and routines are allowed to have subroutines (ie, to
-; use the call/return address stack).
-
-; serial_... routines except serial_interrupt will never _directly_ call
-; any serialu_... routine; when we say `causes' this means that the
-; relevant serialu_... routine will be called at some later point from
-; serial_interrupt. serialu_... routines are allowed to call appropriate
-; serial_... routines (except serial_interrupt) directly if the context
-; and Tx State allows.
-
-; All routines except serial_init and serial_write_please
-; must be called only:
-; * During a low-priority interrupt;
-; * From the main loop with low-priority interrupts disabled; or
-; * From within an serialu_... routine (which are always called
-; from within serial_interrupt).
-; This is to avoid having one serial_... routine running in an interrupt
-; which interrupted the middle of another serial_... routine.
-
-; Some time between calling serial_init and waiting for the first event,
-; the main program should of course enable interrupts.
-
-;============================================================
-; COMMON ROUTINES and RECEPTION
-
-;--------------------
- extern serial_init
-;
-; Initialises the serial port and library state appropriately. Must
-; be called exactly once, which must be before any other
-; serial_... function.
-;
-; At call On return
-; serial controller any for use by seriallib
-; PORTB any for use by seriallib
-; serial interrupt config any enabled, low priority
-; Port B interrupt-on-change any enabled, low priority
-; TRISB<5:7> any outputs configured unchanged
-; TRISB<4> any configured for input
-; TRISB<0:2> any unchanged
-; LATB any outputs configured unchanged, use freely
-; global interrupt enable disabled unchanged
-; Tx State Not-in-use Must-Notify
-;
-; Note that as soon as the interrupts are enabled, the serial port
-; will generate an interrupt, so that we go from Tx State Must-Notify
-; to Idle via call to serialu_writeable. (See the Transmission
-; section below.)
-
-;--------------------
- extern serial_portb_read
-; At call On return
-; W any value from PORTB
-;
-; Provided to allow the main program to read any bits in PORTB which
-; it is using as inputs. See the notes above about PORTB.
-
-;--------------------
- extern serial_interrupt
-;
-; Must be called by the main program's low priority interrupt handler.
-; The main program's interrupt handler is responsible for saving W and
-; the flags register and other interrupt-related administrivia. If
-; there is a serial interrupt, this routine will service it, taking any
-; necessary action including calling appropriate serialu_... routines,
-; and clear the interrupt flag[*].
-;
-; At call On return
-; Tx State any except Not-in-use may change
-; serial interrupt state any cleared[*]
-;
-; [*] The interrupt event on entry, if any, will be dealt with. If
-; interrupt processing takes a long time, another interrupt will occur
-; and this may result in the serial interrupt flag being set on return
-; from serial_inerrupt.
-
-;--------------------
- extern serialu_receive
-;
-; Called to notify the main program that a byte has been recieved from
-; the host. The byte value is supplied. There is no way for the PIC
-; to signal flow control to the host, to stop the host from sending
-; data. It is up to the main program to do _something_ with the
-; received data (or to panic or to discard it).
-;
-; Beforehand At call
-; W data byte from host
-
-;======================================================================
-; TRANSMISSION
-;
-; States:
-; [Not-in-use]
-; |
-; |init
-; V
-; ,------------->+<-------------.
-; | | |
-; | [Must-Notify] |
-; | | |
-; | write_ready| |
-; | | |
-; | V |
-; | [Idle] |
-; | | `-----------'
-; | write_byte| write_please
-; | |
-; | V
-; | [Busy]<----------.
-; | | `-----------'
-; `--------------' write_please
-
-; The seriallib will handle the host's requests for flow control.
-
-;--------------------
- extern serialu_write_ready
-;
-; Called to notify the main program that the serial port is now ready
-; to transmit a byte. The main program should call serial_write_byte,
-; or serial_write_please, either immediately or at some later point.
-;
-; Beforehand At call
-; Tx State Must-Notify Idle
-
-;--------------------
- extern serial_write_byte
-;
-; Provides a byte to be written to the serial port.
-;
-; At call On return
-; Tx State Idle Busy
-; W byte for host any
-
-;--------------------
- extern serial_write_please
-;
-; Asks to be re-notified if the serial port is ready for transmission.
-; This will regenerate the call to serialu_write_ready if applicable.
-;
-; At call On return
-; Tx State Idle Must-Notify
-; Tx State Busy Busy
-;
-; serialu_write_ready will *not* be called directly from
-; serial_write_please, but only from serial_interrupt (as discussed
-; above).
-;
-; Exceptionally, serial_write_please is fully reentrant. It need not
-; be called from interrupt context and need not be called with
-; interrupts disabled. It is permissible for serial_write_please to
-; be interrupted by an invocation of serial_interrupt or vice versa.
-;
-; Use example: if the main program has a buffer of characters for
-; transmission, serialu_write_ready would call serial_write_byte if
-; the buffer had something in it. If it didn't then it would simply
-; return. When something is put in the buffer, the main program would
-; call serial_write_please unconditionally, which would ensure that
-; serialu_write_ready will be called soon.
-
-;======================================================================
include common.inc
-garbage2 code 0x2000
- db 1
-garbage6 code 0x6000
- db 1
-
udata_acs
t res 1
+++ /dev/null
-; reservations for variables
-
-; boilerplate:
-
- include /usr/share/gputils/header/p18f458.inc
- radix dec
-
-
- end
TARGETS= hostside hostside-old gui-plan-bot
+default: all
+recurse: all
all: $(TARGETS)
hostside-old: serialio.o nmra.o main.o encode.o utils.o
INCLUDES= insn-aliases.inc onecopybit.inc test.inc
include ../common.make
+
+PROGRAM_HEXES= $(addsuffix .hex, $(PROGRAMS)) \
+ $(addsuffix -withcfg.hex, $(PROGRAMS))
+
+all: $(TARGETS) $(PROGRAM_HEXES)
+
include ../pic.make
+%-withcfg.hex: %.o config.o $(LIBS) $(DEFLIBS)
+ $(LINK)
+
+%.hex: %.o $(LIBS) $(DEFLIBS)
+ $(LINK)
+
clean: pic-clean
rm -f $(INSN_TARGETS)
CPROGS= subseg2display compose-segenco
default: $(CPROGS) for-test-ui
+for-pic: ours-pindata.asm
+recurse: $(CPROGS) for-pic
all: default lpages layers extras
for-test-ui: ours.graph.c ours.redactgraph ours.raw.neato.ps \
ours.redacted.neato.ps ours.layout-data.o \
include ours.dgram.m
include segencolayers.m
-NETPBM= -lnetpbm
-# -lppm
+NETPBM = -lnetpbm
+ifeq (,$(shell test -f /usr/lib/libppm.so || echo no))
+NETPBM += -lppm
+endif
REDACT= consistency movfeatsplitedges \
consistency movfeatrmstubs \
# FOO-entire0.hex FOO.o idlocs0.o config.o
# perpicNUMBER.hex idlocsNUMBER.o config.o
-PROGRAM_HEXES= $(addsuffix .hex, $(PROGRAMS)) \
- $(addsuffix -withcfg.hex, $(PROGRAMS))
-
-all: $(TARGETS) $(PROGRAM_HEXES)
LINK= gplink -m -o $@ $^
ASSEMBLE= gpasm -p 18f458
-%-withcfg.hex: %.o config.o $(LIBS) $(DEFLIBS)
- $(LINK)
-
-%.hex: %.o $(LIBS) $(DEFLIBS)
- $(LINK)
-
%.o: %.asm $(INCLUDES)
$(ASSEMBLE) -c $<
mv $*.lst $*-asm.lst
pic-clean:
-rm -f -- *~ *.new *.tmp
- -rm -f *.hex *.cod *.lst *.o
+ -rm -f *.hex *.cod *.lst *.o *.map