From 8b8e17eda2c981a6f9ba4ecab5a44cc419353b69 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Thu, 19 Sep 2013 21:03:28 -0700 Subject: [PATCH] Clean up build --- src/Makefile | 44 +++++++++++++------------------------------- src/a2pi-setup.sh | 4 ++-- src/a2pid.c | 25 +++++++++++++++++++++++++ src/gpclk.c | 6 +++--- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/Makefile b/src/Makefile index e9d7c8b..3ce9b89 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,42 +1,24 @@ -PACKAGE=a2pi -VERSION=0.9.0 -PREFIX=/usr/local -BIN= a2serclk a2pid a2joy a2joymou a2joypad a2mon a2term dskread dskwrite bintomon bload brun text2merlin merlin2text -BINDIR=$(PREFIX)/bin -DIST=$(PACKAGE)-$(VERSION) -DISTDIR=./$(DIST) +DESTDIR=/usr/local/bin +SHAREDIR=/usr/share/a2pi +BIN=a2pid a2joy a2joymou a2joypad a2mon a2term fusea2pi dskread dskwrite bload brun +A2PIDEFS=-DSETSERCLK -all: $(BIN) fusea2pi +all: $(BIN) + +a2pid: a2pid.c gpclk.c + $(CC) $(A2PIDEFS) a2pid.c -o a2pid fusea2pi: fusea2pi.c a2lib.c $(CC) -I/usr/include/fuse -D_FILE_OFFSET_BITS=64 fusea2pi.c -lfuse -o fusea2pi clean: - -rm $(BIN) *~ fusea2pi + -rm $(BIN) *~ *.tar.gz install: - cp $(BIN) fusea2pi a2mount $(BINDIR) + cp $(BIN) a2mount $(DESTDIR) + -mkdir $(SHAREDIR) + cp ../share/* $(SHAREDIR) $(BASH) ./a2pi-setup.sh uninstall: - cd $(BINDIR); rm $(BIN) fusea2pi a2mount - -dist: - -rm -rf $(DISTDIR) - mkdir $(DISTDIR) - -chmod 777 $(DISTDIR) - cp ../LICENSE.txt $(DISTDIR) - cp ../README.md $(DISTDIR) - mkdir $(DISTDIR)/docs - cp ../docs/* $(DISTDIR)/docs - mkdir $(DISTDIR)/src - cp *.c $(DISTDIR)/src - cp *.sh $(DISTDIR)/src - cp *.conf $(DISTDIR)/src - cp *.bin $(DISTDIR)/src - cp *.mon $(DISTDIR)/src - cp *.PO $(DISTDIR)/src - cp a2mount execfile Makefile $(DISTDIR)/src - -chmod -R a+r $(DISTDIR) - tar czf $(DIST).tar.gz $(DISTDIR) - rm -rf $(DISTDIR) \ No newline at end of file + cd $(DESTDIR); rm $(BIN) a2mount diff --git a/src/a2pi-setup.sh b/src/a2pi-setup.sh index fe8cbe2..aa8f6f9 100755 --- a/src/a2pi-setup.sh +++ b/src/a2pi-setup.sh @@ -15,12 +15,12 @@ if [ -n "$gettyline" -a ${gettyline:0:1} = T ] ; then sed 's/^T0*/#T0*/' /etc/inittab.bak > /etc/inittab fi # -# Add a2serclk and a2pid to rc.local +# Add a2joy and a2pid to rc.local # if [ -f /etc/rc.local ] ; then if ! grep a2pid /etc/rc.local > /dev/null ; then mv /etc/rc.local /etc/rc.local.bak - sed -e '/^exit/i\# Start Apple II Pi' -e '/^exit/i\/usr/local/bin/a2serclk' -e '/^exit/i\/usr/local/bin/a2pid --daemon' -e '/^exit/i\wait 1' -e '/^exit/i\/usr/local/bin/a2joy' /etc/rc.local.bak > /etc/rc.local + sed -e '/^exit/i\# Start Apple II Pi' -e '/^exit/i\/usr/local/bin/a2pid --daemon' -e '/^exit/i\wait 1' -e '/^exit/i\/usr/local/bin/a2joy' /etc/rc.local.bak > /etc/rc.local chmod +x /etc/rc.local fi fi diff --git a/src/a2pid.c b/src/a2pid.c index cccef0b..526dd63 100755 --- a/src/a2pid.c +++ b/src/a2pid.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,10 @@ #include #include +#ifdef SETSERCLK +#include "gpclk.c" +#endif + #define BAUDRATE B115200 #define _POSIX_SOURCE 1 /* POSIX compliant source */ #define FALSE 0 @@ -586,6 +591,13 @@ void flushreqs(int a2fd, int clidx, int status, int result) } } } +static void sig_bye(int signo) +{ + /* + * Exit gracefully + */ + state = STOP; +} void main(int argc, char **argv) { struct uinput_user_dev uidev; @@ -622,6 +634,13 @@ void main(int argc, char **argv) */ devtty = argv[1]; } + /* + * Add signal handlers. + */ + if (signal(SIGINT, sig_bye) == SIG_ERR) + die("signal"); + if (signal(SIGHUP, sig_bye) == SIG_ERR) + die("signal"); /* * Create keyboard input device */ @@ -709,6 +728,12 @@ void main(int argc, char **argv) evrely.type = EV_REL; evrely.code = REL_Y; evsync.type = EV_SYN; +#ifdef SETSERCLK + /* + * Initialize ACIA clock for Apple II Pi card + */ + gpclk(271); /* divisor for ~1.8 MHz => (500/271) MHz */ +#endif /* * Open serial port. */ diff --git a/src/gpclk.c b/src/gpclk.c index 28e94b7..c34af6e 100755 --- a/src/gpclk.c +++ b/src/gpclk.c @@ -67,7 +67,7 @@ void release_io(volatile unsigned int *io_map) munmap((void *)io_map, IOMAP_LEN); } -void setserclk(void) +void gpclk(int idiv) { // I/O access volatile unsigned *gpio, *cmgp; @@ -77,7 +77,7 @@ void setserclk(void) cmgp = setup_io(ARM_PERI_BASE + CMGP_OFFSET); gpio = setup_io(ARM_PERI_BASE + GPIO_OFFSET); - // Set Clock Manager to provivede ~1.8432 MHz from 500 MHz source (PLLD) + // Set Clock Manager to 500 MHz source (PLLD) CMGP_REG(CM_GP0CTL) = (0x5A << 24) // Password // Disable | (1); // Src = oscillator @@ -86,7 +86,7 @@ void setserclk(void) // Disable | (6); // Src = PLLD CMGP_REG(CM_GP0DIV) = (0x5A << 24) // Password - | (271 << 12); // IDIV + | ((idiv) << 12); // IDIV usleep(1000); CMGP_REG(CM_GP0CTL) = (0x5A << 24) // Password | (1 << 4) // Enable