Made the cgg and the cg code generator work; use this to beat the PDP/11
authorDavid Given <dg@cowlark.com>
Fri, 23 Feb 2018 21:31:46 +0000 (22:31 +0100)
committerDavid Given <dg@cowlark.com>
Fri, 23 Feb 2018 21:31:46 +0000 (22:31 +0100)
backend into shape. It now generates binaries --- no idea whether they work or
not.

134 files changed:
build.lua
lib/pdp/descr [deleted file]
mach/pdp/Action [deleted file]
mach/pdp/cg/mach.h
mach/pdp/cv/build.lua [new file with mode: 0644]
mach/pdp/cv/proto.make
mach/pdp/libem/LIST [deleted file]
mach/pdp/libem/build.lua [new file with mode: 0644]
mach/pdp/libend/LIST [deleted file]
mach/pdp/libend/build.lua [new file with mode: 0644]
mach/pdp/libsys/LIST [deleted file]
mach/pdp/mach_params [deleted file]
mach/pdp/ncg/mach.c
mach/pdp/ncg/mach.h
mach/pdp/ncg/table
mach/proto/cg/build.lua [new file with mode: 0644]
mach/proto/cg/proto.make [deleted file]
plat/build.lua
plat/pdpv7/boot.s [moved from mach/pdp/libsys/head_em.s with 100% similarity]
plat/pdpv7/build-pkg.lua [new file with mode: 0644]
plat/pdpv7/build-tools.lua [new file with mode: 0644]
plat/pdpv7/descr [new file with mode: 0644]
plat/pdpv7/include/ack/config.h [new file with mode: 0644]
plat/pdpv7/include/build.lua [new file with mode: 0644]
plat/pdpv7/include/sys/select.h [new file with mode: 0644]
plat/pdpv7/include/termios.h [new file with mode: 0644]
plat/pdpv7/include/unistd.h [new file with mode: 0644]
plat/pdpv7/libsys/_alarm.s [moved from mach/pdp/libsys/_alarm.s with 100% similarity]
plat/pdpv7/libsys/_close.s [moved from mach/pdp/libsys/_close.s with 100% similarity]
plat/pdpv7/libsys/_creat.s [moved from mach/pdp/libsys/_creat.s with 100% similarity]
plat/pdpv7/libsys/_dup.s [moved from mach/pdp/libsys/_dup.s with 100% similarity]
plat/pdpv7/libsys/_execl.s [moved from mach/pdp/libsys/_execl.s with 100% similarity]
plat/pdpv7/libsys/_exit.s [moved from mach/pdp/libsys/_exit.s with 100% similarity]
plat/pdpv7/libsys/_fork.s [moved from mach/pdp/libsys/_fork.s with 100% similarity]
plat/pdpv7/libsys/_fstat.s [moved from mach/pdp/libsys/_fstat.s with 100% similarity]
plat/pdpv7/libsys/_ftime.s [moved from mach/pdp/libsys/_ftime.s with 100% similarity]
plat/pdpv7/libsys/_getpid.s [moved from mach/pdp/libsys/_getpid.s with 100% similarity]
plat/pdpv7/libsys/_gtty.c [moved from mach/pdp/libsys/_gtty.c with 100% similarity]
plat/pdpv7/libsys/_ioctl.s [moved from mach/pdp/libsys/_ioctl.s with 100% similarity]
plat/pdpv7/libsys/_kill.s [moved from mach/pdp/libsys/_kill.s with 100% similarity]
plat/pdpv7/libsys/_link.s [moved from mach/pdp/libsys/_link.s with 100% similarity]
plat/pdpv7/libsys/_lseek.s [moved from mach/pdp/libsys/_lseek.s with 100% similarity]
plat/pdpv7/libsys/_open.s [moved from mach/pdp/libsys/_open.s with 100% similarity]
plat/pdpv7/libsys/_pause.s [moved from mach/pdp/libsys/_pause.s with 100% similarity]
plat/pdpv7/libsys/_pipe.s [moved from mach/pdp/libsys/_pipe.s with 100% similarity]
plat/pdpv7/libsys/_read.s [moved from mach/pdp/libsys/_read.s with 100% similarity]
plat/pdpv7/libsys/_sbrk.s [moved from mach/pdp/libsys/_sbrk.s with 100% similarity]
plat/pdpv7/libsys/_unlink.s [moved from mach/pdp/libsys/_unlink.s with 100% similarity]
plat/pdpv7/libsys/_wait.s [moved from mach/pdp/libsys/_wait.s with 100% similarity]
plat/pdpv7/libsys/_write.s [moved from mach/pdp/libsys/_write.s with 100% similarity]
plat/pdpv7/libsys/access.s [moved from mach/pdp/libsys/access.s with 100% similarity]
plat/pdpv7/libsys/acct.s [moved from mach/pdp/libsys/acct.s with 100% similarity]
plat/pdpv7/libsys/alarm.s [moved from mach/pdp/libsys/alarm.s with 100% similarity]
plat/pdpv7/libsys/build.lua [new file with mode: 0644]
plat/pdpv7/libsys/chdir.s [moved from mach/pdp/libsys/chdir.s with 100% similarity]
plat/pdpv7/libsys/chmod.s [moved from mach/pdp/libsys/chmod.s with 100% similarity]
plat/pdpv7/libsys/chown.s [moved from mach/pdp/libsys/chown.s with 100% similarity]
plat/pdpv7/libsys/chroot.s [moved from mach/pdp/libsys/chroot.s with 100% similarity]
plat/pdpv7/libsys/cleanup.c [moved from mach/pdp/libsys/cleanup.c with 100% similarity]
plat/pdpv7/libsys/close.s [moved from mach/pdp/libsys/close.s with 100% similarity]
plat/pdpv7/libsys/creat.s [moved from mach/pdp/libsys/creat.s with 100% similarity]
plat/pdpv7/libsys/dup.s [moved from mach/pdp/libsys/dup.s with 100% similarity]
plat/pdpv7/libsys/errno.s [moved from mach/pdp/libsys/errno.s with 100% similarity]
plat/pdpv7/libsys/execl.s [moved from mach/pdp/libsys/execl.s with 100% similarity]
plat/pdpv7/libsys/execle.s [moved from mach/pdp/libsys/execle.s with 100% similarity]
plat/pdpv7/libsys/execv.s [moved from mach/pdp/libsys/execv.s with 100% similarity]
plat/pdpv7/libsys/execve.s [moved from mach/pdp/libsys/execve.s with 100% similarity]
plat/pdpv7/libsys/exit.c [moved from mach/pdp/libsys/exit.c with 100% similarity]
plat/pdpv7/libsys/fetchi.s [moved from mach/pdp/libsys/fetchi.s with 100% similarity]
plat/pdpv7/libsys/fork.s [moved from mach/pdp/libsys/fork.s with 100% similarity]
plat/pdpv7/libsys/fperr.s [moved from mach/pdp/libsys/fperr.s with 100% similarity]
plat/pdpv7/libsys/fstat.s [moved from mach/pdp/libsys/fstat.s with 100% similarity]
plat/pdpv7/libsys/ftime.s [moved from mach/pdp/libsys/ftime.s with 100% similarity]
plat/pdpv7/libsys/getgid.s [moved from mach/pdp/libsys/getgid.s with 100% similarity]
plat/pdpv7/libsys/getgrp.s [moved from mach/pdp/libsys/getgrp.s with 100% similarity]
plat/pdpv7/libsys/getpid.s [moved from mach/pdp/libsys/getpid.s with 100% similarity]
plat/pdpv7/libsys/getppid.s [moved from mach/pdp/libsys/getppid.s with 100% similarity]
plat/pdpv7/libsys/getuid.s [moved from mach/pdp/libsys/getuid.s with 100% similarity]
plat/pdpv7/libsys/gldav.s [moved from mach/pdp/libsys/gldav.s with 100% similarity]
plat/pdpv7/libsys/gtty.c [moved from mach/pdp/libsys/gtty.c with 100% similarity]
plat/pdpv7/libsys/ioctl.s [moved from mach/pdp/libsys/ioctl.s with 100% similarity]
plat/pdpv7/libsys/isatty.c [new file with mode: 0644]
plat/pdpv7/libsys/kill.s [moved from mach/pdp/libsys/kill.s with 100% similarity]
plat/pdpv7/libsys/killbkg.s [moved from mach/pdp/libsys/killbkg.s with 100% similarity]
plat/pdpv7/libsys/killpg.s [moved from mach/pdp/libsys/killpg.s with 100% similarity]
plat/pdpv7/libsys/link.s [moved from mach/pdp/libsys/link.s with 100% similarity]
plat/pdpv7/libsys/lock.s [moved from mach/pdp/libsys/lock.s with 100% similarity]
plat/pdpv7/libsys/login.s [moved from mach/pdp/libsys/login.s with 100% similarity]
plat/pdpv7/libsys/lseek.s [moved from mach/pdp/libsys/lseek.s with 100% similarity]
plat/pdpv7/libsys/lstat.s [moved from mach/pdp/libsys/lstat.s with 100% similarity]
plat/pdpv7/libsys/mknod.s [moved from mach/pdp/libsys/mknod.s with 100% similarity]
plat/pdpv7/libsys/mount.s [moved from mach/pdp/libsys/mount.s with 100% similarity]
plat/pdpv7/libsys/mpxcall.s [moved from mach/pdp/libsys/mpxcall.s with 100% similarity]
plat/pdpv7/libsys/nice.s [moved from mach/pdp/libsys/nice.s with 100% similarity]
plat/pdpv7/libsys/nostk.s [moved from mach/pdp/libsys/nostk.s with 100% similarity]
plat/pdpv7/libsys/open.s [moved from mach/pdp/libsys/open.s with 100% similarity]
plat/pdpv7/libsys/pause.s [moved from mach/pdp/libsys/pause.s with 100% similarity]
plat/pdpv7/libsys/phys.s [moved from mach/pdp/libsys/phys.s with 100% similarity]
plat/pdpv7/libsys/pipe.s [moved from mach/pdp/libsys/pipe.s with 100% similarity]
plat/pdpv7/libsys/profil.s [moved from mach/pdp/libsys/profil.s with 100% similarity]
plat/pdpv7/libsys/ptrace.s [moved from mach/pdp/libsys/ptrace.s with 100% similarity]
plat/pdpv7/libsys/qfstat.s [moved from mach/pdp/libsys/qfstat.s with 100% similarity]
plat/pdpv7/libsys/qstat.s [moved from mach/pdp/libsys/qstat.s with 100% similarity]
plat/pdpv7/libsys/quota.s [moved from mach/pdp/libsys/quota.s with 100% similarity]
plat/pdpv7/libsys/read.s [moved from mach/pdp/libsys/read.s with 100% similarity]
plat/pdpv7/libsys/readlink.s [moved from mach/pdp/libsys/readlink.s with 100% similarity]
plat/pdpv7/libsys/reboot.s [moved from mach/pdp/libsys/reboot.s with 100% similarity]
plat/pdpv7/libsys/renice.s [moved from mach/pdp/libsys/renice.s with 100% similarity]
plat/pdpv7/libsys/rtp.s [moved from mach/pdp/libsys/rtp.s with 100% similarity]
plat/pdpv7/libsys/sbrk.s [moved from mach/pdp/libsys/sbrk.s with 100% similarity]
plat/pdpv7/libsys/setgid.s [moved from mach/pdp/libsys/setgid.s with 100% similarity]
plat/pdpv7/libsys/setgrp.s [moved from mach/pdp/libsys/setgrp.s with 100% similarity]
plat/pdpv7/libsys/setuid.s [moved from mach/pdp/libsys/setuid.s with 100% similarity]
plat/pdpv7/libsys/signal.s [moved from mach/pdp/libsys/signal.s with 100% similarity]
plat/pdpv7/libsys/stat.s [moved from mach/pdp/libsys/stat.s with 100% similarity]
plat/pdpv7/libsys/stime.s [moved from mach/pdp/libsys/stime.s with 100% similarity]
plat/pdpv7/libsys/stty.c [moved from mach/pdp/libsys/stty.c with 100% similarity]
plat/pdpv7/libsys/submit.s [moved from mach/pdp/libsys/submit.s with 100% similarity]
plat/pdpv7/libsys/symlink.s [moved from mach/pdp/libsys/symlink.s with 100% similarity]
plat/pdpv7/libsys/sync.s [moved from mach/pdp/libsys/sync.s with 100% similarity]
plat/pdpv7/libsys/sys.h [moved from mach/pdp/libsys/sys.h with 100% similarity]
plat/pdpv7/libsys/time.s [moved from mach/pdp/libsys/time.s with 100% similarity]
plat/pdpv7/libsys/times.s [moved from mach/pdp/libsys/times.s with 100% similarity]
plat/pdpv7/libsys/ucall.s [moved from mach/pdp/libsys/ucall.s with 100% similarity]
plat/pdpv7/libsys/umask.s [moved from mach/pdp/libsys/umask.s with 100% similarity]
plat/pdpv7/libsys/umount.s [moved from mach/pdp/libsys/umount.s with 100% similarity]
plat/pdpv7/libsys/unlink.s [moved from mach/pdp/libsys/unlink.s with 100% similarity]
plat/pdpv7/libsys/utime.s [moved from mach/pdp/libsys/utime.s with 100% similarity]
plat/pdpv7/libsys/vfork.s [moved from mach/pdp/libsys/vfork.s with 100% similarity]
plat/pdpv7/libsys/vhangup.s [moved from mach/pdp/libsys/vhangup.s with 100% similarity]
plat/pdpv7/libsys/wait.s [moved from mach/pdp/libsys/wait.s with 100% similarity]
plat/pdpv7/libsys/write.s [moved from mach/pdp/libsys/write.s with 100% similarity]
util/cgg/build.lua [new file with mode: 0644]
util/led/led.6

index 9ac5cc7..0e167a0 100644 (file)
--- a/build.lua
+++ b/build.lua
@@ -14,6 +14,7 @@ vars.plats = {
        --"qemuppc",
        "pc86",
        "rpi",
+       "pdpv7",
 }
 vars.plats_with_tests = {
        "linux386",
diff --git a/lib/pdp/descr b/lib/pdp/descr
deleted file mode 100644 (file)
index 7b4bf0f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# $Revision$
-var w=2
-var p=2
-var s=2
-var l=4
-var f=4
-var d=8
-var M=pdp
-var NAME=pdp
-var LIB=lib/{M}/tail_
-var RT=lib/{M}/head_
-var CPP_F=-D__unix
-var C_LIB={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g
-var OLD_C_LIB={C_LIB}
-var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1
-name be
-       from .m.g
-       to .s
-       program {EM}/lib.bin/{M}/cg
-       args <
-       stdout
-       need .e
-end
-name asopt
-       from .s
-       to .so
-       program {EM}/lib.bin/{M}/top
-       args
-       optimizer
-       stdin
-       stdout
-end
-name as
-       from .s.so
-       to .o
-       program {EM}/lib.bin/{M}/as
-       args - -o > <
-       prep cond
-end
-name led
-       from .o.a
-       to .out
-       program {EM}/lib.bin/em_led
-       mapflag -l* LNAME={EM}/{LIB}*
-       mapflag -i SEPID=-b1:0
-       mapflag -n ALIGN=-a0:1 -a1:0x2000 -a2:1 -a3:1
-       mapflag -nr ALIGN=-a0:1 -a1:1 -a2:0x2000 -a3:1
-       mapflag -ansi C_LIB={EM}/{LIB}ac
-       args {ALIGN} {SEPID?} (.e:{HEAD}={EM}/{RT}em) \
-               ({RTS}:.ocm.bas={EM}/{RT}cc) \
-               ({RTS}{ANSI?}:.c={EM}/{RT}cc) \
-               ({RTS}{ANSI?}:.cansi={EM}/{RT}ac) \
-               ({RTS}:.mod={EM}/{RT}m2) \
-               ({RTS}:.p={EM}/{RT}pc) \
-               -o > < \
-               (.p:{TAIL}={EM}/{LIB}pc) \
-               (.bas:{TAIL}={EM}/{LIB}bc) \
-               (.ocm:{TAIL}={EM}/{LIB}ocm) \
-               (.mod:{TAIL}={EM}/{LIB}m2) \
-               (.ocm.bas:{TAIL}={OLD_C_LIB}) \
-               (.c:{TAIL}={C_LIB}) \
-               (.e:{TAIL}={EM}/{LIB}em {EM}/{LIB}mon {EM}/lib/{M}/end_em)
-       linker
-end
-name cv
-       from .out
-       to .cv
-       program {EM}/lib.bin/{M}/cv
-       args < >
-       outfile a.out
-end
diff --git a/mach/pdp/Action b/mach/pdp/Action
deleted file mode 100644 (file)
index 0ef9e1d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-name "PDP 11 assembler"
-dir as
-end
-name "PDP 11 backend"
-dir cg
-end
-name "PDP 11 target optimizer"
-dir top
-end
-name "PDP 11 conversion program"
-dir cv
-end
-name "PDP 11 interpreter"
-system pdp*
-dir int
-end
-name "PDP 11 EM library"
-dir libem
-end
-name "PDP 11 etext,edata,end library"
-dir libend
-end
-name "PDP 11 systemcall library"
-dir libsys
-end
index 7200eb4..4deb9c4 100644 (file)
 #ifdef ACK_ASS
 #define newlbss(l,x)   fprintf(codefile,".comm %s,%u\n",l,x);
 #else
-#define newlbss(l,x)   fprintf(codefile,"%s:.=.+0%o\n",l,x);
+#define newlbss(l,x)   fprintf(codefile,"%s:.=.+%d\n",l,x);
 #endif
 
-#define cst_fmt                "$0%o"
-#define off_fmt                "0%o"
+#define cst_fmt                "$%d"
+#define off_fmt                "%d"
 #define ilb_fmt                "I%x_%x"
 #define dlb_fmt                "_%d"
 #define        hol_fmt         "hol%d"
 
-#define hol_off                "0%lo+hol%d"
+#define hol_off                "%d+hol%d"
 
 #ifdef ACK_ASS
-#define con_cst(x)     fprintf(codefile,".data2 0%lo\n",x)
+#define con_cst(x)     fprintf(codefile,".data2 %d\n",x)
 #define con_ilb(x)     fprintf(codefile,".data2 %s\n",x)
 #define con_dlb(x)     fprintf(codefile,".data2 %s\n",x)
 #else
-#define con_cst(x)     fprintf(codefile,"0%lo\n",x)
+#define con_cst(x)     fprintf(codefile,"%d\n",x)
 #define con_ilb(x)     fprintf(codefile,"%s\n",x)
 #define con_dlb(x)     fprintf(codefile,"%s\n",x)
 #endif
diff --git a/mach/pdp/cv/build.lua b/mach/pdp/cv/build.lua
new file mode 100644 (file)
index 0000000..5ba9e5e
--- /dev/null
@@ -0,0 +1,8 @@
+cprogram {
+    name = "cv",
+    srcs = { "./*.c" },
+    deps = {
+        "h+emheaders",
+        "modules/src/object+lib",
+    }
+}
index 45f357d..a4d3f2b 100644 (file)
@@ -25,7 +25,8 @@ clean:
        rm -f *.$(SUF) Out cv
 
 lint:
-       $(LINT) $(LINTOPTIONS) -I$(TARGET_HOME)/h $(SRC_DIR)/cv.c $(UTIL_HOME)/modules/lib/$(LINTPREF)object.$(LINTSUF)
+       $(LINT) $(LINTOPTIONS) -I$(TARGET_HOME)/h $(SRC_DIR)/cv.c
+$(UTIL_HOME)/modules/lib/$(LINTPREF)object.$(LINTSUF)
 
 pr:
        @pr $(SRC_DIR)/proto.make $(SRC_DIR)/cv.c
diff --git a/mach/pdp/libem/LIST b/mach/pdp/libem/LIST
deleted file mode 100644 (file)
index ec28624..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-libem_s.a
-RT.s
-adf.s
-adi.s
-and.s
-cff.s
-cfi.s
-cif.s
-cii.s
-ciu.s
-cmf.s
-cmi.s
-cmi4.s
-cms.s
-cmu.s
-cmu4.s
-csa.s
-csb.s
-dup.s
-dvf.s
-dvi.s
-dvi4.s
-dvu.s
-dvu2.s
-dvu4.s
-eret.s
-exg.s
-fef.s
-fif.s
-gto.s
-iaar.s
-aar.s
-ilar.s
-inn.s
-isar.s
-lar.s
-los2.s
-mlf.s
-mli.s
-mli4.s
-mlu.s
-mlu4.s
-mon.s
-ngf.s
-ngi.s
-nop.s
-prf.s
-printf.s
-rck.s
-ret.s
-rmi.s
-rmi4.s
-rmu.s
-rmu2.s
-rmu4.s
-rol.s
-ror.s
-sar.s
-sbf.s
-sbi.s
-set.s
-setfl.s
-sim.s
-sli.s
-sri.s
-sru.s
-sto2.s
-strhp.s
-unknown.s
-trp.s
-xor.s
-save.s
diff --git a/mach/pdp/libem/build.lua b/mach/pdp/libem/build.lua
new file mode 100644 (file)
index 0000000..ca5a13c
--- /dev/null
@@ -0,0 +1,8 @@
+for _, plat in ipairs(vars.plats) do
+       acklibrary {
+               name = "lib_"..plat,
+               srcs = { "./*.s" },
+               vars = { plat = plat },
+       }
+end
+
diff --git a/mach/pdp/libend/LIST b/mach/pdp/libend/LIST
deleted file mode 100644 (file)
index 2efbd3e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-end_s.a
-edata.s
-em_end.s
-end.s
-etext.s
diff --git a/mach/pdp/libend/build.lua b/mach/pdp/libend/build.lua
new file mode 100644 (file)
index 0000000..ca5a13c
--- /dev/null
@@ -0,0 +1,8 @@
+for _, plat in ipairs(vars.plats) do
+       acklibrary {
+               name = "lib_"..plat,
+               srcs = { "./*.s" },
+               vars = { plat = plat },
+       }
+end
+
diff --git a/mach/pdp/libsys/LIST b/mach/pdp/libsys/LIST
deleted file mode 100644 (file)
index 8770661..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-libmon_s.a
-exit.c
-cleanup.c
-stty.c
-gtty.c
-access.s
-acct.s
-alarm.s
-chdir.s
-chmod.s
-chown.s
-chroot.s
-close.s
-creat.s
-dup.s
-execl.s
-execle.s
-execv.s
-execve.s
-fetchi.s
-fork.s
-fperr.s
-fstat.s
-ftime.s
-getgid.s
-getgrp.s
-getpid.s
-getppid.s
-getuid.s
-gldav.s
-ioctl.s
-kill.s
-killbkg.s
-killpg.s
-link.s
-lock.s
-login.s
-lseek.s
-lstat.s
-mknod.s
-mount.s
-mpxcall.s
-nice.s
-nostk.s
-open.s
-pause.s
-phys.s
-pipe.s
-profil.s
-ptrace.s
-qfstat.s
-qstat.s
-quota.s
-read.s
-readlink.s
-reboot.s
-renice.s
-rtp.s
-sbrk.s
-setgid.s
-setgrp.s
-setuid.s
-signal.s
-stat.s
-stime.s
-submit.s
-symlink.s
-sync.s
-time.s
-times.s
-ucall.s
-umask.s
-umount.s
-unlink.s
-utime.s
-vfork.s
-vhangup.s
-wait.s
-write.s
-errno.s
-_alarm.s
-_close.s
-_creat.s
-_dup.s
-_execl.s
-_exit.s
-_fork.s
-_fstat.s
-_ftime.s
-_getpid.s
-_gtty.c
-_ioctl.s
-_kill.s
-_link.s
-_lseek.s
-_open.s
-_pause.s
-_pipe.s
-_read.s
-_sbrk.s
-_unlink.s
-_wait.s
-_write.s
diff --git a/mach/pdp/mach_params b/mach/pdp/mach_params
deleted file mode 100644 (file)
index 554a833..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-MACH=pdp
-SUF=o
-ASAR=aal
-RANLIB=:
-MACHFL=-O -DUFS
index 66150f0..54eb607 100644 (file)
@@ -40,9 +40,9 @@ con_mult(sz) word sz; {
                fatal("bad icon/ucon size");
        l = atol(str);
 #ifdef ACK_ASS
-       fprintf(codefile,".data2 0%o, 0%o !%s\n",(int)(l>>16),(int)l, str);
+       fprintf(codefile,".data2 %d, %d !%s\n",(int)(l>>16),(int)l, str);
 #else
-       fprintf(codefile,"\t%o;%o\n",(int)(l>>16),(int)l);
+       fprintf(codefile,"\t%d;%d\n",(int)(l>>16),(int)l);
 #endif
 }
 
@@ -96,12 +96,12 @@ f_regsave() {
                if (lbytes == 2)
                        fprintf(codefile,"tst -(sp)\n");
                else if (lbytes!=0)
-                       fprintf(codefile,"sub $0%o,sp\n",lbytes);
+                       fprintf(codefile,"sub $%d,sp\n",lbytes);
                for (i=0;i<n_regvars;i++)
                        fprintf(codefile,"mov %s,-(sp)\n",regadm[i].ra_str);
        } else {
                if (lbytes>6) {
-                       fprintf(codefile,"mov $0%o,r0\n",lbytes);
+                       fprintf(codefile,"mov $%d,r0\n",lbytes);
                        fprintf(codefile,"jsr r5,PR%s\n",Rstring);
                } else {
                        fprintf(codefile,"jsr r5,PR%d%s\n",lbytes,Rstring);
@@ -109,7 +109,7 @@ f_regsave() {
        }
        for (i=0;i<n_regvars;i++)
                if (regadm[i].ra_off>=0)
-                       fprintf(codefile,"mov 0%lo(r5),%s\n",regadm[i].ra_off,
+                       fprintf(codefile,"mov %d(r5),%s\n",regadm[i].ra_off,
                                                regadm[i].ra_str);
 }
 
@@ -122,7 +122,7 @@ regsave(regstr,off,size) char *regstr; long off; {
 #endif
        strcat(Rstring,regstr);
        if (off>=0)
-               fprintf(codefile,"mov 0%lo(r5),%s\n",off,regstr);
+               fprintf(codefile,"mov %d(r5),%s\n",off,regstr);
 end of commented away */
 
        strcat(Rstring,regstr);
@@ -154,7 +154,7 @@ prolog(nlocals) full nlocals; {
        if (nlocals == 2)
                fprintf(codefile,"tst -(sp)\n");
        else
-               fprintf(codefile,"sub $0%o,sp\n",nlocals);
+               fprintf(codefile,"sub $%d,sp\n",nlocals);
 #else
        lbytes = nlocals;
 #endif
index dbbdf8f..33e6c97 100644 (file)
 #ifdef ACK_ASS
 #define newlbss(l,x)   fprintf(codefile,".comm %s,%u\n",l,x);
 #else
-#define newlbss(l,x)   fprintf(codefile,"%s:.=.+0%o\n",l,x);
+#define newlbss(l,x)   fprintf(codefile,"%s:.=.+%d\n",l,x);
 #endif
 
-#define cst_fmt                "$0%o"
-#define off_fmt                "0%o"
+#define cst_fmt                "$%d"
+#define off_fmt                "%d"
 #define ilb_fmt                "I%x_%x"
 #define dlb_fmt                "_%d"
 #define        hol_fmt         "hol%d"
 
-#define hol_off                "0%lo+hol%d"
+#define hol_off                "%d+hol%d"
 
 #ifdef ACK_ASS
-#define con_cst(x)     fprintf(codefile,".data2 0%lo\n",x)
+#define con_cst(x)     fprintf(codefile,".data2 %d\n",x)
 #define con_ilb(x)     fprintf(codefile,".data2 %s\n",x)
 #define con_dlb(x)     fprintf(codefile,".data2 %s\n",x)
 #else
-#define con_cst(x)     fprintf(codefile,"0%lo\n",x)
+#define con_cst(x)     fprintf(codefile,"%d\n",x)
 #define con_ilb(x)     fprintf(codefile,"%s\n",x)
 #define con_dlb(x)     fprintf(codefile,"%s\n",x)
 #endif
index dea4500..74f59e3 100644 (file)
@@ -8,7 +8,7 @@ EM_BSIZE=4
 
 SL=4
 
-FORMAT = "0%lo"
+FORMAT = "%d"
 TIMEFACTOR = 1/300
 
 illins = "Illegal"
diff --git a/mach/proto/cg/build.lua b/mach/proto/cg/build.lua
new file mode 100644 (file)
index 0000000..a754ebb
--- /dev/null
@@ -0,0 +1,42 @@
+include("util/cgg/build.lua")
+
+definerule("build_cg",
+       {
+               arch = { type="string" }
+       },
+       function(e)
+               -- Remember this is executed from the caller's directory; local
+               -- target names will resolve there
+               local headers = clibrary {
+                       name = e.name.."/headers",
+                       srcs = {},
+                       hdrs = {
+                               "mach/proto/cg/*.h",
+                               "mach/"..e.arch.."/cg/mach.c",
+                               "mach/"..e.arch.."/cg/*.h",
+                       }
+               }
+
+               local tables = cgg {
+                       name = e.name.."/tables",
+                       srcs = { "mach/"..e.arch.."/cg/table" }
+               }
+
+               return cprogram {
+                       name = e.name,
+                       srcs = {
+                               "mach/proto/cg/*.c",
+                               matching(filenamesof(tables), "%.c$")
+                       },
+                       deps = {
+                               "h+emheaders",
+                               "modules+headers",
+                               "modules/src/em_data+lib",
+                               "modules/src/flt_arith+lib",
+                               headers,
+                               tables, -- for .h file
+                       }
+               }
+       end
+)
+
diff --git a/mach/proto/cg/proto.make b/mach/proto/cg/proto.make
deleted file mode 100644 (file)
index 5b4c459..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-# $Id$
-
-#PARAMS         do not remove this line!
-
-#MACH_DEFINE   do not remove this or the next line!
-MACH = 
-
-SRC_DIR = $(SRC_HOME)/mach/$(MACH)/cg
-CDIR=$(SRC_HOME)/mach/proto/cg
-LIBEM = $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF)
-LIBFLT = $(TARGET_HOME)/modules/lib/libflt.$(LIBSUF)
-CPP = $(UTIL_HOME)/lib.bin/cpp
-CGG = $(UTIL_HOME)/lib.bin/cgg
-
-PREFLAGS=-I$(TARGET_HOME)/h -I$(SRC_HOME)/mach -I$(TARGET_HOME)/modules/h -I$(SRC_DIR) -I. -I$(CDIR) -DNDEBUG
-PFLAGS=
-CFLAGS=$(PREFLAGS) $(PFLAGS) $(COPTIONS)
-LDFLAGS=$(PFLAGS) $(LDOPTIONS)
-LINTFLAGS=$(PREFLAGS) $(LINTOPTIONS)
-LIBS=$(LIBEM) $(LIBFLT)
-CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
-       $(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
-       $(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
-       $(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
-OFILES=        codegen.$(SUF) compute.$(SUF) equiv.$(SUF) fillem.$(SUF) \
-       gencode.$(SUF) glosym.$(SUF) main.$(SUF) move.$(SUF) nextem.$(SUF) \
-       reg.$(SUF) regvar.$(SUF) salloc.$(SUF) state.$(SUF) subr.$(SUF) \
-       var.$(SUF)
-
-all:   tables.c
-       make cg
-
-cg: tables.o $(OFILES)
-       $(CC) $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
-
-tables.$(SUF): tables.c
-       $(CC) -c $(PREFLAGS) tables.c
-
-codegen.$(SUF): $(CDIR)/codegen.c
-       $(CC) -c $(CFLAGS) $(CDIR)/codegen.c
-compute.$(SUF): $(CDIR)/compute.c
-       $(CC) -c $(CFLAGS) $(CDIR)/compute.c
-equiv.$(SUF): $(CDIR)/equiv.c
-       $(CC) -c $(CFLAGS) $(CDIR)/equiv.c
-fillem.$(SUF): $(CDIR)/fillem.c
-       $(CC) -c $(CFLAGS) $(CDIR)/fillem.c
-gencode.$(SUF): $(CDIR)/gencode.c
-       $(CC) -c $(CFLAGS) $(CDIR)/gencode.c
-glosym.$(SUF): $(CDIR)/glosym.c
-       $(CC) -c $(CFLAGS) $(CDIR)/glosym.c
-main.$(SUF): $(CDIR)/main.c
-       $(CC) -c $(CFLAGS) $(CDIR)/main.c
-move.$(SUF): $(CDIR)/move.c
-       $(CC) -c $(CFLAGS) $(CDIR)/move.c
-nextem.$(SUF): $(CDIR)/nextem.c
-       $(CC) -c $(CFLAGS) $(CDIR)/nextem.c
-reg.$(SUF): $(CDIR)/reg.c
-       $(CC) -c $(CFLAGS) $(CDIR)/reg.c
-regvar.$(SUF): $(CDIR)/regvar.c
-       $(CC) -c $(CFLAGS) $(CDIR)/regvar.c
-salloc.$(SUF): $(CDIR)/salloc.c
-       $(CC) -c $(CFLAGS) $(CDIR)/salloc.c
-state.$(SUF): $(CDIR)/state.c
-       $(CC) -c $(CFLAGS) $(CDIR)/state.c
-subr.$(SUF): $(CDIR)/subr.c
-       $(CC) -c $(CFLAGS) $(CDIR)/subr.c
-var.$(SUF): $(CDIR)/var.c
-       $(CC) -c $(CFLAGS) $(CDIR)/var.c
-
-install: all
-       -mkdir $(TARGET_HOME)/lib.bin/$(MACH)
-       cp cg $(TARGET_HOME)/lib.bin/$(MACH)/cg
-
-cmp:    all
-       -cmp cg $(TARGET_HOME)/lib.bin/$(MACH)/cg
-
-tables.c: $(SRC_DIR)/table $(CGG)
-       -mv tables.h tables.h.save
-       $(CPP) -P -I$(SRC_DIR) $(SRC_DIR)/table | $(CGG) > debug.out
-       -if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-       -if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
-
-lint:  tables.c
-       $(LINT) $(LINTFLAGS) $(CFILES) tables.c
-clean:
-       rm -f *.$(SUF) tables.c tables.h debug.out cg tables.h.save
-
-codegen.$(SUF):        $(CDIR)/assert.h
-codegen.$(SUF):        $(CDIR)/data.h
-codegen.$(SUF):        $(CDIR)/equiv.h
-codegen.$(SUF):        $(CDIR)/extern.h
-codegen.$(SUF):        $(CDIR)/param.h
-codegen.$(SUF):        $(CDIR)/result.h
-codegen.$(SUF):        $(CDIR)/state.h
-codegen.$(SUF):        tables.h
-codegen.$(SUF):        $(CDIR)/types.h
-compute.$(SUF):        $(CDIR)/assert.h
-compute.$(SUF):        $(CDIR)/data.h
-compute.$(SUF):        $(CDIR)/extern.h
-compute.$(SUF):        $(CDIR)/glosym.h
-compute.$(SUF):        $(CDIR)/param.h
-compute.$(SUF):        $(CDIR)/result.h
-compute.$(SUF):        tables.h
-compute.$(SUF):        $(CDIR)/types.h
-equiv.$(SUF):  $(CDIR)/assert.h
-equiv.$(SUF):  $(CDIR)/data.h
-equiv.$(SUF):  $(CDIR)/equiv.h
-equiv.$(SUF):  $(CDIR)/extern.h
-equiv.$(SUF):  $(CDIR)/param.h
-equiv.$(SUF):  $(CDIR)/result.h
-equiv.$(SUF):  tables.h
-equiv.$(SUF):  $(CDIR)/types.h
-fillem.$(SUF): $(CDIR)/assert.h
-fillem.$(SUF): $(CDIR)/data.h
-fillem.$(SUF): $(CDIR)/extern.h
-fillem.$(SUF): $(SRC_DIR)/mach.c
-fillem.$(SUF): $(SRC_DIR)/mach.h
-fillem.$(SUF): $(CDIR)/param.h
-fillem.$(SUF): $(CDIR)/regvar.h
-fillem.$(SUF): $(CDIR)/result.h
-fillem.$(SUF): tables.h
-fillem.$(SUF): $(CDIR)/types.h
-gencode.$(SUF):        $(CDIR)/assert.h
-gencode.$(SUF):        $(CDIR)/data.h
-gencode.$(SUF):        $(CDIR)/extern.h
-gencode.$(SUF):        $(CDIR)/param.h
-gencode.$(SUF):        $(CDIR)/result.h
-gencode.$(SUF):        tables.h
-gencode.$(SUF):        $(CDIR)/types.h
-glosym.$(SUF): $(CDIR)/glosym.h
-glosym.$(SUF): $(CDIR)/param.h
-glosym.$(SUF): tables.h
-glosym.$(SUF): $(CDIR)/types.h
-main.$(SUF):           $(CDIR)/param.h
-move.$(SUF):           $(CDIR)/assert.h
-move.$(SUF):           $(CDIR)/data.h
-move.$(SUF):           $(CDIR)/extern.h
-move.$(SUF):           $(CDIR)/param.h
-move.$(SUF):           $(CDIR)/result.h
-move.$(SUF):           tables.h
-move.$(SUF):           $(CDIR)/types.h
-nextem.$(SUF): $(CDIR)/assert.h
-nextem.$(SUF): $(CDIR)/data.h
-nextem.$(SUF): $(CDIR)/extern.h
-nextem.$(SUF): $(CDIR)/param.h
-nextem.$(SUF): $(CDIR)/result.h
-nextem.$(SUF): tables.h
-nextem.$(SUF): $(CDIR)/types.h
-reg.$(SUF):            $(CDIR)/assert.h
-reg.$(SUF):            $(CDIR)/data.h
-reg.$(SUF):            $(CDIR)/extern.h
-reg.$(SUF):            $(CDIR)/param.h
-reg.$(SUF):            $(CDIR)/result.h
-reg.$(SUF):            tables.h
-reg.$(SUF):            $(CDIR)/types.h
-regvar.$(SUF): $(CDIR)/assert.h
-regvar.$(SUF): $(CDIR)/data.h
-regvar.$(SUF): $(CDIR)/extern.h
-regvar.$(SUF): $(CDIR)/param.h
-regvar.$(SUF): $(CDIR)/regvar.h
-regvar.$(SUF): $(CDIR)/result.h
-regvar.$(SUF): tables.h
-regvar.$(SUF): $(CDIR)/types.h
-salloc.$(SUF): $(CDIR)/assert.h
-salloc.$(SUF): $(CDIR)/data.h
-salloc.$(SUF): $(CDIR)/extern.h
-salloc.$(SUF): $(CDIR)/param.h
-salloc.$(SUF): $(CDIR)/result.h
-salloc.$(SUF): tables.h
-salloc.$(SUF): $(CDIR)/types.h
-state.$(SUF):  $(CDIR)/assert.h
-state.$(SUF):  $(CDIR)/data.h
-state.$(SUF):  $(CDIR)/extern.h
-state.$(SUF):  $(CDIR)/param.h
-state.$(SUF):  $(CDIR)/result.h
-state.$(SUF):  $(CDIR)/state.h
-state.$(SUF):  tables.h
-state.$(SUF):  $(CDIR)/types.h
-subr.$(SUF):           $(CDIR)/assert.h
-subr.$(SUF):           $(CDIR)/data.h
-subr.$(SUF):           $(CDIR)/extern.h
-subr.$(SUF):           $(CDIR)/param.h
-subr.$(SUF):           $(CDIR)/result.h
-subr.$(SUF):           tables.h
-subr.$(SUF):           $(CDIR)/types.h
-var.$(SUF):            $(CDIR)/data.h
-var.$(SUF):            $(CDIR)/param.h
-var.$(SUF):            $(CDIR)/result.h
-var.$(SUF):            tables.h
-var.$(SUF):            $(CDIR)/types.h
index dc0821f..6fc96f8 100644 (file)
@@ -1,4 +1,5 @@
 include("mach/proto/as/build.lua")
+include("mach/proto/cg/build.lua")
 include("mach/proto/ncg/build.lua")
 include("mach/proto/mcg/build.lua")
 include("mach/proto/top/build.lua")
similarity index 100%
rename from mach/pdp/libsys/head_em.s
rename to plat/pdpv7/boot.s
diff --git a/plat/pdpv7/build-pkg.lua b/plat/pdpv7/build-pkg.lua
new file mode 100644 (file)
index 0000000..4afe82d
--- /dev/null
@@ -0,0 +1,25 @@
+include("plat/build.lua")
+
+ackfile {
+       name = "boot",
+       srcs = { "./boot.s" },
+       vars = { plat = "pdpv7" }
+}
+
+build_plat_libs {
+       name = "libs",
+       arch = "pdp",
+       plat = "pdpv7",
+}
+
+installable {
+       name = "pkg",
+       map = {
+               "+tools",
+               "+libs",
+        "./include+pkg",
+               ["$(PLATIND)/pdpv7/boot.o"] = "+boot",
+        ["$(PLATIND)/pdpv7/libsys.a"] = "./libsys+lib",
+       }
+}
+
diff --git a/plat/pdpv7/build-tools.lua b/plat/pdpv7/build-tools.lua
new file mode 100644 (file)
index 0000000..353ae49
--- /dev/null
@@ -0,0 +1,28 @@
+include("plat/build.lua")
+
+build_as {
+       name = "as",
+       arch = "pdp",
+}
+
+build_cg {
+       name = "cg",
+       arch = "pdp",
+}
+
+build_top {
+       name = "top",
+       arch = "pdp"
+}
+
+return installable {
+       name = "tools",
+       map = {
+               ["$(PLATDEP)/pdpv7/as"] = "+as",
+               ["$(PLATDEP)/pdpv7/cg"] = "+cg",
+               ["$(PLATDEP)/pdpv7/cv"] = "mach/pdp/cv+cv",
+               ["$(PLATDEP)/pdpv7/top"] = "+top",
+               ["$(PLATIND)/descr/pdpv7"] = "./descr",
+               "util/opt+pkg",
+       }
+}
diff --git a/plat/pdpv7/descr b/plat/pdpv7/descr
new file mode 100644 (file)
index 0000000..88c77ce
--- /dev/null
@@ -0,0 +1,87 @@
+# $Revision$
+var w=2
+var wa=1
+var p=2
+var pa=1
+var s=2
+var sa=1
+var l=4
+var la=1
+var f=4
+var fa=1
+var d=8
+var da=1
+var x=8
+var xa=1
+
+var ARCH=pdp
+var PLATFORM=pdpv7
+var PLATFORMDIR={EM}/share/ack/{PLATFORM}
+var CPP_F=-D__unix
+var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1
+
+var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi
+
+name be
+       from .m.g
+       to .s
+       program {EM}/lib/ack/{PLATFORM}/cg
+       args <
+       stdout
+       need .e
+end
+
+# There's an ack driver bug where if the .s file needs preprocessing, the path
+# isn't set correctly in stages other than the first; this affects the PDP/11
+# libsys assembler files. Work around this for now by disabling asopt.
+#name asopt
+#      from .s
+#      to .so
+#      program {EM}/lib/ack/{PLATFORM}/top
+#      args
+#      optimizer
+#      stdin
+#      stdout
+#end
+
+name as
+       from .s.so
+       to .o
+       program {EM}/lib/ack/{PLATFORM}/as
+       args - -o > <
+       prep cond
+end
+name led
+       from .o.a
+       to .out
+       program {EM}/lib/ack/em_led
+       mapflag -l* LNAME={PLATFORMDIR}/lib*
+       mapflag -i SEPID=-b1:0
+       mapflag -n ALIGN=-a0:1 -a1:0x2000 -a2:1 -a3:1
+       mapflag -nr ALIGN=-a0:1 -a1:1 -a2:0x2000 -a3:1
+       args {ALIGN} {SEPID?} \
+               ({RTS}:.b=-u _i_main) \
+               (.e:{HEAD}={PLATFORMDIR}/boot.o) \
+               ({RTS}:.ocm.bas.b={PLATFORMDIR}/c-ansi.o) \
+               ({RTS}:.c={PLATFORMDIR}/c-ansi.o) \
+               ({RTS}:.mod={PLATFORMDIR}/modula2.o) \
+               ({RTS}:.p={PLATFORMDIR}/pascal.o) \
+               -o > < \
+               (.p:{TAIL}={PLATFORMDIR}/libpascal.a) \
+               (.b:{TAIL}={PLATFORMDIR}/libb.a) \
+               (.bas:{TAIL}={PLATFORMDIR}/libbasic.a) \
+               (.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \
+               (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \
+               (.ocm.bas.mod.b.c.p:{TAIL}={PLATFORMDIR}/libc.a) \
+               (.e:{TAIL}={PLATFORMDIR}/libem.a \
+                       {PLATFORMDIR}/libsys.a \
+                       {PLATFORMDIR}/libend.a)
+       linker
+end
+name cv
+       from .out
+       to .cv
+       program {EM}/lib/ack/{PLATFORM}/cv
+       args < >
+       outfile a.out
+end
diff --git a/plat/pdpv7/include/ack/config.h b/plat/pdpv7/include/ack/config.h
new file mode 100644 (file)
index 0000000..73dbbc3
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Raspberry Pi support library for the PDP/11
+ * © 2013 David Given
+ * This file is redistributable under the terms of the 3-clause BSD license.
+ * See the file 'Copying' in the root of the distribution for the full text.
+ */
+
+#ifndef _ACK_CONFIG_H
+#define _ACK_CONFIG_H
+
+/* We're providing a time() system call rather than wanting a wrapper around
+ * gettimeofday() in the libc. */
+#define ACKCONF_TIME_IS_A_SYSCALL
+
+#endif
diff --git a/plat/pdpv7/include/build.lua b/plat/pdpv7/include/build.lua
new file mode 100644 (file)
index 0000000..c0334a3
--- /dev/null
@@ -0,0 +1,26 @@
+include("plat/build.lua")
+
+headermap = {}
+packagemap = {}
+
+local function addheader(h)
+       headermap[h] = "./"..h
+       packagemap["$(PLATIND)/pdpv7/include/"..h] = "./"..h
+end
+
+addheader("ack/config.h")
+addheader("sys/select.h")
+addheader("termios.h")
+addheader("unistd.h")
+
+acklibrary {
+       name = "headers",
+       hdrs = headermap
+}
+
+installable {
+       name = "pkg",
+       map = packagemap
+}
+
+
diff --git a/plat/pdpv7/include/sys/select.h b/plat/pdpv7/include/sys/select.h
new file mode 100644 (file)
index 0000000..3352558
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Raspberry Pi support library for the PDP/11
+ * © 2013 David Given
+ * This file is redistributable under the terms of the 3-clause BSD license.
+ * See the file 'Copying' in the root of the distribution for the full text.
+ */
+
+#ifndef _SYS_SELECT_H
+#define _SYS_SELECT_H
+
+#include <unistd.h>
+
+#endif
diff --git a/plat/pdpv7/include/termios.h b/plat/pdpv7/include/termios.h
new file mode 100644 (file)
index 0000000..e3769f2
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Raspberry Pi support library for the PDP/11
+ * © 2013 David Given
+ * This file is redistributable under the terms of the 3-clause BSD license.
+ * See the file 'Copying' in the root of the distribution for the full text.
+ */
+
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
+
+typedef unsigned char tcflag_t;
+
+struct termios
+{
+    tcflag_t c_iflag;
+    tcflag_t c_oflag;
+    tcflag_t c_lflag;
+    tcflag_t c_cflag;
+};
+
+#define ONLCR 1
+#define ECHO 2
+#define INLCR 4
+
+/* Dummied parameters for compatibility --- only the ones above are
+ * honoured. */
+
+#define BRKINT 0
+#define ICRNL 0
+#define INPCK 0
+#define ISTRIP 0
+#define IXON 0
+#define CS8 0
+#define ICANON 0
+#define IEXTEN 0
+#define ISIG 0
+
+#define OPOST ONLCR
+
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+extern int tcgetattr(int fd, struct termios* t);
+extern int tcsetattr(int fd, int actions, struct termios* t);
+
+#endif
diff --git a/plat/pdpv7/include/unistd.h b/plat/pdpv7/include/unistd.h
new file mode 100644 (file)
index 0000000..2b48dd6
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Raspberry Pi support library for the PDP/11
+ * © 2013 David Given
+ * This file is redistributable under the terms of the 3-clause BSD license.
+ * See the file 'Copying' in the root of the distribution for the full text.
+ */
+
+#ifndef _UNISTD_H
+#define _UNISTD_H
+
+#include <stddef.h>
+#include <time.h>
+
+/* Types */
+
+typedef int pid_t;
+typedef int mode_t;
+
+typedef long suseconds_t;
+
+/* Time handling. */
+
+struct timeval
+{
+       time_t tv_sec;
+       suseconds_t tv_usec;
+};
+
+struct timezone
+{
+       int tz_minuteswest;
+       int tz_dsttime;
+}; /* obsolete, unused */
+
+extern int gettimeofday(struct timeval* tv, struct timezone* tz);
+extern int settimeofday(const struct timeval* tv, const struct timezone* tz);
+
+/* Constants for file access (open and friends) */
+
+enum
+{
+       O_ACCMODE = 0x3,
+       
+       O_RDONLY = 0,
+       O_WRONLY = 1,
+       O_RDWR = 2,
+       
+       O_CREAT = 0100,
+       O_TRUNC = 01000,
+       O_APPEND = 02000,
+       O_NONBLOCK = 04000
+};
+
+/* Special variables */
+
+extern char** environ;
+
+/* Implemented system calls */
+
+extern void _exit(int);
+extern pid_t getpid(void);
+extern void* sbrk(int increment);
+extern int isatty(int d);
+extern off_t lseek(int fildes, off_t offset, int whence);
+extern int close(int d);
+extern int open(const char* path, int access, ...);
+extern int creat(const char* path, mode_t mode);
+extern int read(int fd, void* buffer, size_t count);
+extern int write(int fd, void* buffer, size_t count);
+
+/* Unimplemented system calls (these are just prototypes to let the library
+ * compile). */
+
+extern int fcntl(int fd, int op, ...);
+
+/* Signal handling */
+
+typedef int sig_atomic_t;
+
+#define SIG_ERR ((sighandler_t) -1)           /* Error return.  */
+#define SIG_DFL ((sighandler_t) 0)            /* Default action.  */
+#define SIG_IGN ((sighandler_t) 1)            /* Ignore signal.  */
+
+#define SIGABRT         6       /* Abort (ANSI) */
+#define SIGILL          11      /* Illegal instruction */
+
+#define _NSIG           32      /* Biggest signal number + 1
+                                   (not including real-time signals).  */
+typedef void (*sighandler_t)(int);
+extern sighandler_t signal(int signum, sighandler_t handler);
+extern int raise(int signum);
+
+/* Select */
+
+typedef uint32_t fd_set;
+
+extern int select(int nfds, fd_set *readfds, fd_set *writefds,
+                  fd_set *exceptfds, struct timeval *timeout);
+
+#define FD_ZERO(set) do { *set = 0; } while (0)
+#define FD_SET(fd, set) do { *set |= (1<<fd); } while (0);
+#define FD_CLR(fd, set) do { *set &= ~(1<<fd); } while (0);
+#define FD_ISSET(fd, set) (*set | (1<<fd))
+
+#endif
diff --git a/plat/pdpv7/libsys/build.lua b/plat/pdpv7/libsys/build.lua
new file mode 100644 (file)
index 0000000..27c90a8
--- /dev/null
@@ -0,0 +1,16 @@
+acklibrary {
+    name = "lib",
+    srcs = {
+        "./*.c",
+        "./*.s",
+    },
+       deps = {
+               "lang/cem/libcc.ansi/headers+headers",
+               "plat/pdpv7/include+headers",
+       },
+    vars = {
+        plat = "pdpv7"
+    }
+}
+
+-- /tmp/ack-build/staging/lib/ack/cpp.ansi -D__unix -I/tmp/ack-build/obj/lang/cem/libcc.ansi/headers/headers -I/tmp/ack-build/obj/plat/rpi/include/headers -D__vc4 -D__rpi -D__ACK -I/tmp/ack-build/staging/share/ack/rpi/include -I/tmp/ack-build/staging/share/ack/include/ansi -Dvc4 -DEM_WSIZE=4 -DEM_PSIZE=4 -DEM_SSIZE=2 -DEM_LSIZE=4 -DEM_FSIZE=4 -DEM_DSIZE=4 -D_EM_WSIZE=4 -D_EM_PSIZE=4 -D_EM_SSIZE=2 -D_EM_LSIZE=4 -D_EM_FSIZE=4 -D_EM_DSIZE=4 plat/rpi/libsys/pi_user_to_phys.s
diff --git a/plat/pdpv7/libsys/isatty.c b/plat/pdpv7/libsys/isatty.c
new file mode 100644 (file)
index 0000000..9ff30e7
--- /dev/null
@@ -0,0 +1,8 @@
+int isatty(int fd)
+{
+    char* p;
+
+    if (gtty(fd, &p) < 0)
+        return 0;
+    return 1;
+}
diff --git a/util/cgg/build.lua b/util/cgg/build.lua
new file mode 100644 (file)
index 0000000..00ae597
--- /dev/null
@@ -0,0 +1,62 @@
+include("first/yacc.lua")
+
+local cggparser = yacc {
+       name = "cggparser",
+       srcs = { "./bootgram.y" }
+}
+
+local cgglexer = flex {
+       name = "cgglexer",
+       srcs = { "./bootlex.l" }
+}
+
+cprogram {
+       name = "cgg",
+       srcs = concat(
+               "./*.c",
+               matching(filenamesof(cggparser), "%.c$"),
+               matching(filenamesof(cgglexer), "%.c$")
+       ),
+       deps = {
+               "./booth.h",
+               "+cggparser", -- for .h file
+               "+cgglexer", -- for .h file
+               "h+emheaders",
+               "modules/src/em_data+lib",
+       }
+}
+       
+definerule("cgg",
+       {
+               srcs = { type="targets" }
+       },
+       function(e)
+               -- Remember this is executed from the caller's directory; local
+               -- target names will resolve there
+               if (#e.srcs ~= 1) then
+                       error("you must supply exactly one input file")
+               end
+
+               local cpptable = cppfile {
+                       name = e.name.."/cpptable",
+                       outleaf = "cpptable",
+                       srcs = e.srcs
+               }
+
+               return normalrule {
+                       name = e.name,
+                       cwd = e.cwd,
+                       outleaves = {
+                               "tables.c",
+                               "tables.h",
+                       },
+                       ins = {
+                               "util/cgg+cgg",
+                               cpptable
+                       },
+                       commands = {
+                               "cd %{dir} && %{ins}",
+                       }
+               }
+       end
+)
index 8e4b98e..cabcac1 100644 (file)
@@ -69,7 +69,7 @@ else if it starts with `0', it is octal,
 else it is decimal.
 .TP
 .BI \-b dd:nnnn
-The base addres in the machine of section
+The base address in the machine of section
 .IR dd ,
 is set to
 .IR nnnn .