pdp11: introduce base PDP11 code
authorAlan Cox <alan@linux.intel.com>
Tue, 25 Oct 2016 20:42:13 +0000 (21:42 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 25 Oct 2016 20:42:13 +0000 (21:42 +0100)
Far from complete

Kernel/cpu-pdp11/cpu.h [new file with mode: 0644]
Kernel/cpu-pdp11/image.mk [new file with mode: 0644]
Kernel/cpu-pdp11/rules.mk [new file with mode: 0644]
Kernel/kernel-pdp11.def [new file with mode: 0644]
Kernel/usermem_std-pdp11.S [new file with mode: 0644]

diff --git a/Kernel/cpu-pdp11/cpu.h b/Kernel/cpu-pdp11/cpu.h
new file mode 100644 (file)
index 0000000..e4bb3b8
--- /dev/null
@@ -0,0 +1,82 @@
+typedef unsigned long uint32_t;
+typedef signed long int32_t;
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+typedef unsigned char uint8_t;
+typedef signed char int8_t;
+typedef unsigned int size_t;
+typedef signed int ssize_t;
+
+typedef uint8_t irqflags_t;
+
+typedef int16_t arg_t;
+typedef uint16_t uarg_t;               /* Holds arguments */
+typedef uint16_t usize_t;              /* Largest value passed by userspace */
+typedef int16_t susize_t;
+typedef uint16_t uaddr_t;              /* A user address must fit this */
+typedef uint16_t uptr_t;               /* User pointer equivalent */
+
+#define uputp  uputw                   /* Copy user pointer type */
+#define ugetp  ugetw                   /* between user and kernel */
+#define uputi  uputw                   /* Copy user int type */
+#define ugeti  ugetw                   /* between user and kernel */
+
+extern void ei(void);
+extern irqflags_t di(void);
+extern void irqrestore(irqflags_t f);
+
+/* FIXME: we actually want to use an a.out loader */
+
+#define EMAGIC    0x7E    /* Header of executable  (JMP) */
+#define EMAGIC_2  0x20    /* BRA */
+
+/* Allow a minimum of 512 bytes gap between stack and top of allocations */
+#define brk_limit() (udata.u_syscall_sp - 512)
+
+extern void *memcpy(void *, const void *, size_t);
+extern void *memset(void *, int, size_t);
+extern size_t strlen(const char *);
+extern uint16_t swab(uint16_t);
+extern uint32_t swab32(uint16_t);
+extern uint32_t shuffle32(uint16_t);
+
+/* PDP 11 32bit values are an odd order indeed hence the shuffle32 helper
+   we also need below */
+#define        ntohs(x)        swab(x)
+#define ntohl(x)       swab32(x)
+
+/* PDP-11 doesn't benefit much from making a few key variables in
+   non-reentrant functions static */
+#define staticfast     auto
+
+/* User's structure for times() system call */
+typedef unsigned long clock_t;
+
+typedef struct {
+   uint32_t low;
+   uint32_t high;
+} time_t;
+
+typedef union {            /* this structure is endian dependent */
+    clock_t  full;         /* 32-bit count of ticks since boot */
+    struct {
+      /* PDP11 endian: be careful here */
+      uint16_t high;
+      uint16_t low;         /* 16-bit count of ticks since boot */
+    } h;
+} ticks_t;
+
+
+#define cpu_to_le16(x) (x)
+#define le16_to_cpu(x) (x)
+/* FIXME: make shuffle32 a define */
+#define cpu_to_le32(x)  shuffle32(x)
+#define le32_to_cpu(x) cpu_to_le32(x)
+
+/* Sane behaviour for unused parameters */
+#define used(x)
+
+#define gcc_miscompile_workaround()
+
+#define BIG_ENDIAN
+#define PDP_ENDIAN
diff --git a/Kernel/cpu-pdp11/image.mk b/Kernel/cpu-pdp11/image.mk
new file mode 100644 (file)
index 0000000..b8821ed
--- /dev/null
@@ -0,0 +1,2 @@
+fuzix.bin: target $(OBJS)
+       +make -C platform-$(TARGET) image
diff --git a/Kernel/cpu-pdp11/rules.mk b/Kernel/cpu-pdp11/rules.mk
new file mode 100644 (file)
index 0000000..dbb503f
--- /dev/null
@@ -0,0 +1,15 @@
+export CROSS_LD=pdp11-aout-ld
+export CROSS_CC = pdp11-aout-gcc
+# Do not use the Fedora gcc 5.3.1. It miscompiles stuff badly.
+export CROSS_CCOPTS=-c -Os -fno-strict-aliasing -fomit-frame-pointer -fno-builtin -Wall -I$(ROOT_DIR)/cpu-pdp11 -I$(ROOT_DIR)/platform-$(TARGET) -I$(ROOT_DIR)/include
+export CROSS_AS=$(CROSS_CC) $(CROSS_CCOPTS)
+export CROSS_CC_SEG1=
+export CROSS_CC_SEG2=
+export CROSS_CC_SEG3=
+# Fixme: we should split discard off
+export CROSS_CC_SEGDISC=
+export CROSS_CC_VIDEO=
+export ASOPTS=
+export ASMEXT = .S
+export BINEXT = .o
+export BITS=16
diff --git a/Kernel/kernel-pdp11.def b/Kernel/kernel-pdp11.def
new file mode 100644 (file)
index 0000000..3fcdaca
--- /dev/null
@@ -0,0 +1,69 @@
+/* Keep these in sync with struct u_data!! */
+
+#define U_DATA__U_PTAB         0
+#define U_DATA__U_PAGE         2
+#define U_DATA__U_PAGE2                4
+#define U_DATA__U_INSYS                6
+#define U_DATA__U_CALLNO       7
+#define U_DATA__U_SYSCALL_SP   8
+#define U_DATA__U_RETVAL       10
+#define U_DATA__U_ERROR                12
+#define U_DATA__U_SP           14
+#define U_DATA__U_ININTERRUPT  16
+#define U_DATA__U_CURSIG       17
+#define U_DATA__U_ARGN         18
+#define U_DATA__U_ARGN1                20
+#define U_DATA__U_ARGN2                22
+#define U_DATA__U_ARGN3                24
+#define U_DATA__U_ISP          26
+#define U_DATA__U_TOP          28
+#define U_DATA__U_BREAK                30
+#define U_DATA__U_SIGVEC       32
+
+#define P_TAB__P_STATUS_OFFSET 0
+#define P_TAB__P_TTY_OFFSET    1
+#define P_TAB__P_PID_OFFSET    2
+#define P_TAB__P_PAGE_OFFSET   14
+
+#define P_RUNNING              1
+#define P_READY                        2
+#define P_DEFER                        3
+
+#define OS_BANK                        0
+
+#define EAGAIN                 11
+
+#define SIGHUP          1
+#define SIGINT          2
+#define SIGQUIT                 3
+#define SIGILL          4
+#define SIGTRAP                 5
+#define SIGABRT                 6
+#define SIGIOT          6
+#define SIGBUS          7
+#define SIGFPE          8
+#define SIGKILL                 9
+#define SIGUSR1                10
+#define SIGSEGV                11
+#define SIGUSR2                12
+#define SIGPIPE                13
+#define SIGALRM                14
+#define SIGTERM                15
+#define SIGSTKFLT      16
+#define SIGCHLD                17
+#define SIGCONT                18
+#define SIGSTOP                19
+#define SIGTSTP                20
+#define SIGTTIN                21
+#define SIGTTOU                22
+#define SIGURG         23
+#define SIGXCPU                24
+#define SIGXFSZ                25
+#define SIGVTALRM      26
+#define SIGPROF                27
+#define SIGWINCH       28
+#define SIGIO          29
+#define SIGPOLL                SIGIO
+#define SIGPWR         30
+#define SIGSYS         31
+#define        SIGUNUSED       31
diff --git a/Kernel/usermem_std-pdp11.S b/Kernel/usermem_std-pdp11.S
new file mode 100644 (file)
index 0000000..e69de29