Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first cut of ported code

  • Loading branch information...
commit 586aedca5fdbe3f207392c5a3d7e50ee5cd5ae9c 0 parents
authored July 09, 2009

Showing 66 changed files with 45,516 additions and 0 deletions. Show diff stats Hide diff stats

  1. 113  Makefile
  2. 238  README
  3. BIN  cadr_1.bin
  4. BIN  cadr_2.bin
  5. BIN  cadr_3.bin
  6. BIN  cadr_4.bin
  7. BIN  cadr_5.bin
  8. BIN  cadr_6.bin
  9. 19  cadrmem.c
  10. 806  chaos.c
  11. 12  chaos.h
  12. 51  config.c
  13. 10  config.h
  14. 724  decode.c
  15. 735  disk.c
  16. 848  diskmaker.c
  17. 469  diskmaker_old.c
  18. 158  div.c
  19. 38  endian.h
  20. 4,724  fadd.txt
  21. 549  iob.c
  22. 622  kbd_new.c
  23. 334  kbd_old.c
  24. 46  keyboard.cfg
  25. 341  keyboard.h
  26. 831  lmfs.c
  27. 661  lod.c
  28. 124  logo.h
  29. 507  macro.c
  30. 268  main.c
  31. 312  poo.html
  32. 559  prom.dis.txt
  33. 754  promh.9
  34. 34  promh.sym.9
  35. 241  readmcr.c
  36. 374  sdl.c
  37. 274  syms.c
  38. 27  template.disk1
  39. 20  template.disk2
  40. 8  template.disk3
  41. 26  template.disk4
  42. 26  template.disk5
  43. 20,265  ucadr.lisp.841
  44. BIN  ucadr.mcr.841
  45. BIN  ucadr.mcr.896
  46. BIN  ucadr.mcr.979
  47. 2,508  ucadr.sym.841
  48. 2,638  ucadr.sym.979
  49. 3,065  ucode.c
  50. 77  ucode.h
  51. 23  usim.h
  52. 2  win32/.svn/README.txt
  53. 5  win32/.svn/dir-wcprops
  54. 0  win32/.svn/empty-file
  55. 36  win32/.svn/entries
  56. 1  win32/.svn/format
  57. 226  win32/.svn/text-base/getopt.c.svn-base
  58. 24  win32/.svn/text-base/getopt.h.svn-base
  59. 61  win32/.svn/text-base/win32.c.svn-base
  60. 5  win32/.svn/wcprops/getopt.c.svn-work
  61. 5  win32/.svn/wcprops/getopt.h.svn-work
  62. 5  win32/.svn/wcprops/win32.c.svn-work
  63. 226  win32/getopt.c
  64. 24  win32/getopt.h
  65. 61  win32/win32.c
  66. 376  x11.c
113  Makefile
... ...
@@ -0,0 +1,113 @@
  1
+#
  2
+# usim CADR simulator
  3
+# $Id: Makefile 77 2006-07-18 18:13:25Z brad $
  4
+#
  5
+
  6
+#---------- figure out what we are runnign on ---------
  7
+
  8
+OS_NAME = $(shell uname)
  9
+MACH_NAME = $(shell uname -m)
  10
+
  11
+ifeq ($(OS_NAME), Darwin)
  12
+OS = OSX
  13
+endif
  14
+
  15
+ifeq ($(OS_NAME), Linux)
  16
+OS = LINUX
  17
+endif
  18
+
  19
+#--------- options ---------
  20
+
  21
+DISPLAY = SDL
  22
+#DISPLAY = X11
  23
+
  24
+#KEYBOARD = OLD
  25
+KEYBOARD = NEW
  26
+
  27
+#----------- code ------------
  28
+
  29
+USIM_SRC = main.c decode.c ucode.c disk.c iob.c chaos.c syms.c config.c
  30
+USIM_HDR = ucode.h config.h
  31
+
  32
+ifeq ($(DISPLAY), SDL)
  33
+DISPLAY_SRC = sdl.c
  34
+USIM_LIBS = -L/opt/local/lib -lSDL -lpthread
  35
+DEFINES = -DDISPLAY_SDL
  36
+endif
  37
+
  38
+ifeq ($(DISPLAY), X11)
  39
+DISPLAY_SRC = x11.c
  40
+USIM_LIBS = -L/usr/X11R6/lib -lX11
  41
+DEFINES = -DDISPLAY_X11
  42
+endif
  43
+
  44
+ifeq ($(KEYBOARD), OLD)
  45
+KEYBOARD_SRC = kbd_old.c
  46
+endif
  47
+
  48
+ifeq ($(KEYBOARD), NEW)
  49
+KEYBOARD_SRC = kbd_new.c
  50
+endif
  51
+
  52
+# Mac OSX
  53
+ifeq ($(OS), OSX)
  54
+LFLAGS = -framework Cocoa
  55
+USIM_LIBS = -L/opt/local/lib -lSDLmain -lSDL -lpthread -lobjc
  56
+CFLAGS = -O $(DEFINES)
  57
+# good for G5
  58
+#CFLAGS = -fast $(DEFINES)
  59
+endif
  60
+
  61
+ifeq ($(DISPLAY), X11)
  62
+LFLAGS =
  63
+USIM_LIBS = -L/usr/X11R6/lib -lX11
  64
+endif
  65
+
  66
+# Linux
  67
+ifeq ($(OS), LINUX)
  68
+#CFLAGS = -g
  69
+#CFLAGS = -O -pg -g -fprofile-arcs
  70
+#CFLAGS= -O3 -march=pentium3 -mfpmath=sse -mmmx -msse $(DEFINES) -Walle
  71
+#CFLAGS = -O3 -fomit-frame-pointer -mcpu=i686 -g $(DEFINES)
  72
+#CFLAGS= -O3 -mfpmath=sse -mmmx -msse $(DEFINES) -Walle
  73
+CFLAGS = -O3 -mfpmath=sse -mmmx -msse $(DEFINES) -Walle $(M32) -g
  74
+LFLAGS = $(M32) -L/usr/lib
  75
+endif
  76
+
  77
+# override above if 64 bit
  78
+ifeq ($(MACH_NAME), x86_64)
  79
+M32 = -m32
  80
+USIM_LIBS = /usr/lib/libSDL-1.2.so.0.7.0 -lpthread
  81
+endif
  82
+
  83
+#DEFINES=-DLASHUP
  84
+
  85
+USIM_OBJ = $(USIM_SRC:.c=.o) $(DISPLAY_SRC:.c=.o) $(KEYBOARD_SRC:.c=.o)
  86
+
  87
+SRC = $(USIM_SRC) $(DISPLAY_SRC) $(KEYBOARD_SRC)
  88
+
  89
+all: usim readmcr diskmaker lod lmfs
  90
+
  91
+usim: $(USIM_OBJ)
  92
+	$(CC) -o usim $(LFLAGS) $(USIM_OBJ) $(USIM_LIBS)
  93
+
  94
+run:
  95
+	./usim >xx
  96
+
  97
+readmcr: readmcr.c
  98
+	$(CC) $(CFLAGS) -o $@ $<
  99
+
  100
+diskmaker: diskmaker.c
  101
+	$(CC) $(CFLAGS) -o $@ $<
  102
+
  103
+lmfs: lmfs.c
  104
+	$(CC) $(CFLAGS) -o $@ $<
  105
+
  106
+lod: lod.c macro.c
  107
+	$(CC) $(CFLAGS) -o $@ $<
  108
+
  109
+clean:
  110
+	rm -f *.o usim lod readmcr diskmaker lmfs xx
  111
+	rm -f *~
  112
+
  113
+
238  README
... ...
@@ -0,0 +1,238 @@
  1
+CADR simulator
  2
+08/07/06
  3
+Brad Parker
  4
+brad@heeltoe.com
  5
+
  6
+What is this?
  7
+-------------
  8
+
  9
+This is a program designed to emulate the MIT CADR microprocessor
  10
+hardware.  A CADR is a second generation MIT lisp machine.  A good
  11
+description can be found in "A.I. Memo 528" from the MIT AI Labs
  12
+entitled, "CADR".
  13
+
  14
+The CADR was a 32 bit microcoded microprocessor designed to run the
  15
+lisp language.
  16
+
  17
+This program interprets the microcode found in the machine starting
  18
+with the "prom" microcode which runs when the machine is first powered
  19
+on.  The prom microcode loads additional microcode from the simulated
  20
+disk and then boots the load band.
  21
+
  22
+There is sufficient hardware support for the disk and network to
  23
+provide a reasonaly functional lisp machine experience.
  24
+
  25
+Quickstart
  26
+----------
  27
+
  28
+Grab the pre-made disk image with a warm start file (disk-with-state.tgz) and
  29
+run as "./usim -w". Enter the data and time and press "F1" and "F7" to
  30
+clean up the display. You're up!
  31
+
  32
+If you want to use the network download and run chaosd.  Read the
  33
+"README" in the disks subdirectory on the http server.
  34
+
  35
+Recent Changes
  36
+--------------
  37
+
  38
+v0.9 - minor speedups.
  39
+       Mac OSX (little endian) fixes.
  40
+       Warm start support (usim.state)
  41
+       Mouse/microcode synchronization (thanks to Devon for the idea)
  42
+
  43
+v0.8 - speedups and bug fixes;  chaosd/FILE server supports rebuilding
  44
+       sources from server.  can now resize screen.
  45
+
  46
+v0.7 - added raw X11 support.  Bjorn's new keyboard configuration code.
  47
+       diskmaker now takes a template file and will show info on existing
  48
+       disk images.
  49
+
  50
+v0.6 - better network support
  51
+
  52
+
  53
+Building
  54
+--------
  55
+
  56
+Unix, Linus, OS X:
  57
+
  58
+There are three defines at the top of the Makefile you should check.
  59
+They are OS, DISPLAY and KEYBOARD.  OS should be set automagically.
  60
+
  61
+The X11 display works but the keyboard mapping is not correct yet.  Both
  62
+the OLD and NEW keyboard code works, I would recomment using NEW.
  63
+
  64
+Once the Makefile is changed just type "make".
  65
+
  66
+Win32:
  67
+
  68
+I used a VC 6.0 project to make under win32.
  69
+
  70
+
  71
+Making a disk
  72
+-------------
  73
+
  74
+I would recommend using the distributed disk.img unless you understand
  75
+the structure of a CADR disk.  The program "diskmaker" will interpret
  76
+a disk image partition table and make a new disk using a template file.
  77
+
  78
+The distributed disk was made using "template.disk1".  The template file
  79
+basically feeds all the parameters to diskmaker to build a valid disk
  80
+image an populate it with microcode and a load band.
  81
+
  82
+
  83
+Running
  84
+-------
  85
+
  86
+Everything basically works.  The simulator will boot a load band and talk
  87
+on the (simulated) network.
  88
+
  89
+The emulation is reasonably complete (modulo bugs).  It gets through the
  90
+prom code, loads the microcode band, copies the band to swap and
  91
+executes the load band cleanly.  The system boots and runs.
  92
+
  93
+The code was originally written to run on x86 linux using SDL and X
  94
+Windows.  It's since been ported to run on OS X and Win32, both with
  95
+SDL libraries.  A native X11 interface has also been added.  It should
  96
+compile and run on X86 linux, Win32 and and OS X.
  97
+
  98
+The console display is drawn into an X window (using SDL) which tracks
  99
+the mouse and keyboard.  The simplest way to run it is
  100
+
  101
+	./usim
  102
+
  103
+You can turn off the mouse synchronization with the "-m" option.
  104
+
  105
+If you want to see a trace of macrocode function names try:
  106
+
  107
+	./usim -n -Tl >output
  108
+
  109
+If you want to see a voluminous trace of every microcode instruction
  110
+try:
  111
+
  112
+	./usim -n -t >output
  113
+
  114
+You can make a warm start state file with
  115
+
  116
+	./usim -S
  117
+
  118
+Run the emulator, enter the date and time.  The ^C twice.  The memory state
  119
+will be saved in "usim.state".  You can then warm start to come up
  120
+quickly
  121
+
  122
+	./usim -w
  123
+
  124
+Note that the warm start state file is intimately connected to the
  125
+disk image.  If the two are mismatched bad things will happen.  The two
  126
+files should be portable across X86, Win32 and Macintosh.
  127
+
  128
+The disk emulation reads from a 'disk image' file which is constructed
  129
+with 'diskmaker'.  The disk image looks like a Trident T-300 disk
  130
+to the microcode, complete with a parition table.
  131
+
  132
+The display board and iob are emulated.  An X window displays in
  133
+monochrome at 768x1024.  The mouse and keyboard are tracked.  The
  134
+keyboard is "mapped" to the old Knight keyboard or new style depending
  135
+on compilation options.
  136
+
  137
+The internal microsecond clock and the 60hz tv interrupt currently try
  138
+and use wall clock time for a more realistic simulation.
  139
+
  140
+There is also emulation of the chaosnet board.  Packets are sent via a
  141
+unix socket to a "chaosd" daemon which distributes them to various
  142
+client programs (see the chaos directory).
  143
+
  144
+There are some hacks for noticing unibus access but no xbus/unibus
  145
+mapping support.  The two machine lash-up/debug interface is not (yet)
  146
+supported.  I want to add this, however.
  147
+
  148
+There's still a long delay when booting the distributed world.  The
  149
+system is available right away, however, try "F2-p".  If you are
  150
+impatient try the warm start state file, but be sure to use it with
  151
+it's matching disk.img.
  152
+
  153
+
  154
+What needs to be done?
  155
+----------------------
  156
+
  157
+- cleanup mouse emulation
  158
+- speed up the network emulation
  159
+- speed up the microcode simulation
  160
+
  161
+The keyboard mapping has been cleaned up by Bjorn Victor (thanks!).  The
  162
+latest (v0.7+) code uses the "keyboard.cfg" file to map the PC keyboard
  163
+onto the lispm keyboard.
  164
+
  165
+Some default keys:
  166
+
  167
+f1	terminal
  168
+f2	system
  169
+f3	network
  170
+f4	abort
  171
+f5	clear_input
  172
+esc	Alt Mode
  173
+f1	Terminal
  174
+f2	System
  175
+f3	Network
  176
+f4	Abort
  177
+f5	Clear Input
  178
+f6	Help
  179
+f7	Page
  180
+f8	
  181
+f9	
  182
+f10	
  183
+f11	
  184
+f12
  185
+pgup	Break
  186
+pgdn	{appears to crash usim}
  187
+home	Call
  188
+end	End
  189
+backspace rubout
  190
+backspace Rub Out
  191
+
  192
+Terminal-M	Toggle **MORE** processing.
  193
+Terminal-0-M	Disable **MORE** processing.
  194
+
  195
+	http://world.std.com/~jdostale/kbd/Knight1.jpeg
  196
+	http://world.std.com/~jdostale/kbd/SpaceCadet1.jpeg
  197
+	http://world.std.com/~jdostale/kbd/SpaceCadet2.jpeg
  198
+
  199
+The mouse emulation works but doesn't track exactly.
  200
+
  201
+What programs are here?
  202
+-----------------------
  203
+
  204
+usim		- the CADR emulator
  205
+diskmaker	- program to make CADR disk images from .mcr files and
  206
+		  .lod files
  207
+lod		- utiltity to pick apart load bands and show their insides
  208
+lmfs		- raw hack to read files from LMFS paritition
  209
+
  210
+Standing on the Shoulders of Giants
  211
+-----------------------------------
  212
+
  213
+I would like to thanks the following people for helping me on this, er,
  214
+project:
  215
+
  216
+Tom Knight
  217
+Howard Shrobe
  218
+Richard Greenblatt
  219
+Danial Weinreb
  220
+Al Kossow
  221
+George Carrette
  222
+Steve Krueger
  223
+Alastair Bridgewater
  224
+John Wroclawski
  225
+Bjorn Victor
  226
+Devon Sean McCullough
  227
+
  228
+Without their support or encouragement I would probably not have done
  229
+this.  Certainly if Al had not sent me the prom images I would never
  230
+have started.  And without Dan's box-of-tapes I could never have
  231
+succeeded.  RG offered some good explainations when I was confused.
  232
+TK and Howie were extremely supportive at the just right moment (and
  233
+answered a lot of email).  George offered many good suggestions and
  234
+answered lots of questions. Steve helped me locate missing pages from
  235
+"memo 528".  Alastair did some amazing work on several explorer
  236
+emulators.  Bjorn has used the code, offered many suggestions, fixes
  237
+and improvements.  And John's office is where I first saw a 3600
  238
+console and said, "what's that?".
BIN  cadr_1.bin
Binary file not shown
BIN  cadr_2.bin
Binary file not shown
BIN  cadr_3.bin
Binary file not shown
BIN  cadr_4.bin
Binary file not shown
BIN  cadr_5.bin
Binary file not shown
BIN  cadr_6.bin
Binary file not shown
19  cadrmem.c
... ...
@@ -0,0 +1,19 @@
  1
+main()
  2
+{
  3
+	int xbusl, xbush, unibusl, unibush, xbusiol, xbusioh;
  4
+
  5
+	printf("CADR memory map:\n");
  6
+	xbusl = 0;
  7
+	xbush = 016777777;
  8
+	unibusl = 017400000;
  9
+	unibush = 017777777;
  10
+	xbusiol = 017000000;
  11
+	xbusioh = 017377777;
  12
+	printf("22-bit      %011o\n", (1 << 22)-1);
  13
+	printf("xbus memory %011o-%011o, pn %05o-%05o\n",
  14
+	       xbusl, xbush, xbusl >> 8, xbush>> 8);
  15
+	printf("xbus io     %011o-%011o, pn %05o-%05o\n",
  16
+	       xbusiol, xbusioh, xbusiol >> 8, xbusioh >> 8);
  17
+	printf("unibus io   %011o-%011o, pn %05o-%05o\n",
  18
+	       unibusl, unibush, unibusl >> 8, unibush >> 8);
  19
+}
806  chaos.c
... ...
@@ -0,0 +1,806 @@
  1
+/*
  2
+ * chaosnet adapter emulation
  3
+ * $Id: chaos.c 83 2006-08-07 16:08:20Z brad $
  4
+ */
  5
+
  6
+/* TODO:
  7
+   - desynchronize network process from CPU
  8
+ */
  9
+
  10
+#include "usim.h"
  11
+
  12
+ /* until I split out the unix socket code */
  13
+#if defined(LINUX) || defined(OSX)
  14
+
  15
+#include <stdio.h>
  16
+#include <unistd.h>
  17
+#include <string.h>
  18
+#include <stdlib.h>
  19
+#include <time.h>
  20
+
  21
+#include <sys/types.h>
  22
+#include <sys/socket.h>
  23
+#include <sys/stat.h>
  24
+#include <sys/un.h>
  25
+#include <netinet/in.h>
  26
+#include <sys/poll.h>
  27
+#include <sys/uio.h>
  28
+
  29
+#include "ucode.h"
  30
+#include "endian.h"
  31
+
  32
+#ifndef CHAOS_MY_ADDRESS
  33
+# define CHAOS_MY_ADDRESS 0401
  34
+#endif
  35
+
  36
+#ifndef CHAOS_DEBUG
  37
+# define CHAOS_DEBUG 0
  38
+#endif
  39
+
  40
+#define CHAOS_DEBUG_PKT 0
  41
+//#define CHAOS_TOSS_IF_RXBUFF_FULL
  42
+
  43
+#define CHAOS_BUF_SIZE_BYTES 4096
  44
+
  45
+int chaos_csr;
  46
+int chaos_addr = CHAOS_MY_ADDRESS;
  47
+int chaos_bit_count;
  48
+int chaos_lost_count = 0;
  49
+unsigned short chaos_xmit_buffer[CHAOS_BUF_SIZE_BYTES/2];
  50
+int chaos_xmit_buffer_size;
  51
+int chaos_xmit_buffer_ptr;
  52
+
  53
+unsigned short chaos_rcv_buffer[CHAOS_BUF_SIZE_BYTES/2];
  54
+unsigned short chaos_rcv_buffer_toss[CHAOS_BUF_SIZE_BYTES/2];
  55
+int chaos_rcv_buffer_ptr;
  56
+int chaos_rcv_buffer_size;
  57
+int chaos_rcv_buffer_empty;
  58
+
  59
+int chaos_fd;
  60
+int chaos_need_reconnect;
  61
+static int reconnect_delay;
  62
+static int reconnect_time;
  63
+void chaos_force_reconect(void);
  64
+int chaos_send_to_chaosd(char *buffer, int size);
  65
+int chaos_reconnect(void);
  66
+
  67
+
  68
+extern void assert_unibus_interrupt(int v);
  69
+
  70
+
  71
+/*
  72
+chaos csr 
  73
+	TIMER-INTERRUPT-ENABLE 1<<0
  74
+	LOOP-BACK 1<<1
  75
+	RECEIVE-ALL 1<<2
  76
+	RECEIVER-CLEAR 1<<3
  77
+	RECEIVE-ENABLE 1<<4
  78
+	TRANSMIT-ENABLE 1<<5
  79
+	INTERRUPT-ENABLES 3<<4
  80
+	TRANSMIT-ABORT 1<<6
  81
+	TRANSMIT-DONE 1<<7
  82
+	TRANSMITTER-CLEAR 1<<8
  83
+	LOST-COUNT 017<<9
  84
+	RESET 1<<13
  85
+	CRC-ERROR 1<<14
  86
+	RECEIVE-DONE 1<<15
  87
+
  88
+;;; Offsets of other registers from CSR
  89
+;;; These are in words, not bytes
  90
+
  91
+	MY-NUMBER-OFFSET 1
  92
+	WRITE-BUFFER-OFFSET 1
  93
+	READ-BUFFER-OFFSET 2
  94
+	BIT-COUNT-OFFSET 3
  95
+	START-TRANSMIT-OFFSET 5
  96
+*/
  97
+#define CHAOS_CSR_TIMER_INTERRUPT_ENABLE (1<<0)
  98
+#define	CHAOS_CSR_LOOP_BACK		(1<<1)
  99
+#define	CHAOS_CSR_RECEIVE_ALL		(1<<2)
  100
+#define	CHAOS_CSR_RECEIVER_CLEAR	(1<<3)
  101
+#define	CHAOS_CSR_RECEIVE_ENABLE	(1<<4)
  102
+#define	CHAOS_CSR_TRANSMIT_ENABLE	(1<<5)
  103
+#define	CHAOS_CSR_INTERRUPT_ENABLES	(3<<4)
  104
+#define	CHAOS_CSR_TRANSMIT_ABORT	(1<<6)
  105
+#define	CHAOS_CSR_TRANSMIT_DONE		(1<<7)
  106
+#define	CHAOS_CSR_TRANSMITTER_CLEAR	(1<<8)
  107
+#define	CHAOS_CSR_LOST_COUNT		(017<<9)
  108
+#define	CHAOS_CSR_RESET			(1<<13)
  109
+#define	CHAOS_CSR_CRC_ERROR		(1<<14)
  110
+#define	CHAOS_CSR_RECEIVE_DONE		(1<<15)
  111
+
  112
+static unsigned int
  113
+ch_checksum(const unsigned char *addr, int count)
  114
+{
  115
+	/*
  116
+	 * RFC1071
  117
+	 * Compute Internet Checksum for "count" bytes
  118
+	 *         beginning at location "addr".
  119
+	 */
  120
+	register long sum = 0;
  121
+
  122
+	while( count > 1 )  {
  123
+		/*  This is the inner loop */
  124
+		sum += *(addr)<<8 | *(addr+1);
  125
+		addr += 2;
  126
+		count -= 2;
  127
+	}
  128
+
  129
+	/*  Add left-over byte, if any */
  130
+	if( count > 0 )
  131
+		sum += * (unsigned char *) addr;
  132
+
  133
+	/*  Fold 32-bit sum to 16 bits */
  134
+	while (sum>>16)
  135
+		sum = (sum & 0xffff) + (sum >> 16);
  136
+
  137
+	return (~sum) & 0xffff;
  138
+}
  139
+
  140
+void
  141
+chaos_rx_pkt(void)
  142
+{
  143
+	chaos_rcv_buffer_ptr = 0;
  144
+	chaos_bit_count = (chaos_rcv_buffer_size * 2 * 8) - 1;
  145
+	if (chaos_rcv_buffer_size > 0) {
  146
+#if CHAOS_DEBUG
  147
+	  printf("chaos: set RDN, generate interrupt\n");
  148
+#endif
  149
+	  chaos_csr |= CHAOS_CSR_RECEIVE_DONE;
  150
+	  if (chaos_csr & CHAOS_CSR_RECEIVE_ENABLE)
  151
+	    assert_unibus_interrupt(0404);
  152
+	}
  153
+}
  154
+
  155
+void
  156
+char_xmit_done_intr(void)
  157
+{
  158
+	chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
  159
+	if (chaos_csr & CHAOS_CSR_TRANSMIT_ENABLE)
  160
+	  assert_unibus_interrupt(0400);
  161
+}
  162
+
  163
+void
  164
+chaos_xmit_pkt(void)
  165
+{
  166
+#if CHAOS_DEBUG_PKT
  167
+	int i, n;
  168
+#endif
  169
+
  170
+#if CHAOS_DEBUG
  171
+	printf("chaos_xmit_pkt() %d bytes, data len %d\n",
  172
+	       chaos_xmit_buffer_ptr * 2,
  173
+	       (chaos_xmit_buffer_ptr > 0 ? chaos_xmit_buffer[1]&0x3f : -1));
  174
+#endif
  175
+
  176
+#if CHAOS_DEBUG_PKT
  177
+	n = 0;
  178
+	for (i = 0; i < chaos_xmit_buffer_ptr; i++) {
  179
+		printf("%02x %02x ",
  180
+		       chaos_xmit_buffer[i] & 0xff,
  181
+		       (chaos_xmit_buffer[i] >> 8) & 0xff);
  182
+		n += 2;
  183
+		if (n > 16) {
  184
+			n = 0;
  185
+			printf("\n");
  186
+		}
  187
+	}
  188
+	if (n)
  189
+		printf("\n");
  190
+#endif
  191
+
  192
+	chaos_xmit_buffer_size = chaos_xmit_buffer_ptr;
  193
+
  194
+	/* Dest is already in the buffer */
  195
+//	chaos_xmit_buffer[chaos_xmit_buffer_size++] = 0;/* dest */
  196
+
  197
+	chaos_xmit_buffer[chaos_xmit_buffer_size++] =	/* source */
  198
+		chaos_addr;
  199
+
  200
+	chaos_xmit_buffer[chaos_xmit_buffer_size] =	/* checksum */
  201
+		ch_checksum((u_char *)chaos_xmit_buffer,
  202
+			    chaos_xmit_buffer_size*2);
  203
+	chaos_xmit_buffer_size++;
  204
+
  205
+	chaos_send_to_chaosd((char *)chaos_xmit_buffer,
  206
+			     chaos_xmit_buffer_size*2);
  207
+
  208
+	chaos_xmit_buffer_ptr = 0;
  209
+	char_xmit_done_intr();
  210
+
  211
+#if 0
  212
+	/* set back to ourselves - only for testing */
  213
+	chaos_rcv_buffer_size = chaos_xmit_buffer_size + 2;
  214
+	memcpy(chaos_rcv_buffer, chaos_xmit_buffer, chaos_xmit_buffer_size*2);
  215
+
  216
+	chaos_rcv_buffer[chaos_xmit_buffer_size+0] = 0; /* source */
  217
+	chaos_rcv_buffer[chaos_xmit_buffer_size+1] = 0; /* checksum */
  218
+
  219
+	chaos_rx_pkt();
  220
+#endif
  221
+}
  222
+
  223
+int
  224
+chaos_get_bit_count(void)
  225
+{
  226
+	if (chaos_rcv_buffer_size > 0)
  227
+		return chaos_bit_count;
  228
+	else
  229
+		return 07777;
  230
+}
  231
+
  232
+int
  233
+chaos_get_rcv_buffer(void)
  234
+{
  235
+	int v = 0;
  236
+	if (chaos_rcv_buffer_ptr < chaos_rcv_buffer_size) {
  237
+		v = chaos_rcv_buffer[chaos_rcv_buffer_ptr++];
  238
+
  239
+		if (chaos_rcv_buffer_ptr == chaos_rcv_buffer_size)
  240
+			chaos_rcv_buffer_empty = 1;
  241
+
  242
+	} else {
  243
+		/* read last word, clear receive done */
  244
+		chaos_csr &= ~CHAOS_CSR_RECEIVE_DONE;
  245
+		chaos_rcv_buffer_size = 0;
  246
+	}
  247
+	return v;
  248
+}
  249
+
  250
+void
  251
+chaos_put_xmit_buffer(int v)
  252
+{
  253
+	if (chaos_xmit_buffer_ptr < sizeof(chaos_xmit_buffer)/2)
  254
+		chaos_xmit_buffer[chaos_xmit_buffer_ptr++] = v;
  255
+	chaos_csr &= ~CHAOS_CSR_TRANSMIT_DONE;
  256
+}
  257
+
  258
+int
  259
+chaos_get_csr(void)
  260
+{
  261
+	{
  262
+		static int old_chaos_csr = 0;
  263
+		if (chaos_csr != old_chaos_csr) {
  264
+			old_chaos_csr = chaos_csr;
  265
+#if CHAOS_DEBUG
  266
+			printf("unibus: chaos read csr %o\n",
  267
+			       chaos_csr);
  268
+#endif
  269
+		}
  270
+	}
  271
+
  272
+	return chaos_csr | ((chaos_lost_count << 9) & 017);
  273
+}
  274
+
  275
+int
  276
+chaos_get_addr(void)
  277
+{
  278
+	return chaos_addr;
  279
+}
  280
+
  281
+void
  282
+print_csr_bits(int csr)
  283
+{
  284
+	if (csr & CHAOS_CSR_LOOP_BACK)
  285
+		printf(" LUP");
  286
+	if (csr & CHAOS_CSR_RECEIVE_ALL)
  287
+		printf(" SPY");
  288
+	if (csr & CHAOS_CSR_RECEIVER_CLEAR)
  289
+		printf(" RCL");
  290
+	if (csr & CHAOS_CSR_RECEIVE_ENABLE)
  291
+		printf(" REN");
  292
+	if (csr & CHAOS_CSR_TRANSMIT_ENABLE)
  293
+		printf(" TEN");
  294
+	if (csr & CHAOS_CSR_TRANSMIT_ABORT)
  295
+		printf(" TAB");
  296
+	if (csr & CHAOS_CSR_TRANSMIT_DONE)
  297
+		printf(" TDN");
  298
+	if (csr & CHAOS_CSR_TRANSMITTER_CLEAR)
  299
+		printf(" TCL");
  300
+	if (csr & CHAOS_CSR_RESET)
  301
+		printf(" RST");
  302
+	if (csr & CHAOS_CSR_RECEIVE_DONE)
  303
+		printf(" RDN");
  304
+	if (csr & CHAOS_CSR_CRC_ERROR)
  305
+		printf(" ERR");
  306
+	if (csr & CHAOS_CSR_LOST_COUNT)
  307
+		printf(" Lost %d.",(csr & CHAOS_CSR_LOST_COUNT)>>9);
  308
+
  309
+	csr &= ~(CHAOS_CSR_LOST_COUNT|CHAOS_CSR_RESET|
  310
+		 CHAOS_CSR_TRANSMITTER_CLEAR|CHAOS_CSR_TRANSMIT_ABORT|
  311
+		 CHAOS_CSR_RECEIVE_DONE|CHAOS_CSR_RECEIVE_ENABLE|
  312
+		 CHAOS_CSR_TRANSMIT_DONE|CHAOS_CSR_TRANSMIT_ENABLE|
  313
+		 CHAOS_CSR_CRC_ERROR|CHAOS_CSR_LOOP_BACK|
  314
+		 CHAOS_CSR_RECEIVE_ALL|CHAOS_CSR_RECEIVER_CLEAR);
  315
+
  316
+	if (csr)
  317
+		printf(" unk bits 0%o",csr);
  318
+}
  319
+
  320
+int
  321
+chaos_set_csr(int v)
  322
+{
  323
+	int mask;
  324
+
  325
+	v &= 0xffff;
  326
+
  327
+ 	/* Writing these don't stick */
  328
+	mask = CHAOS_CSR_TRANSMIT_DONE |
  329
+		CHAOS_CSR_LOST_COUNT |
  330
+		CHAOS_CSR_CRC_ERROR |
  331
+		CHAOS_CSR_RECEIVE_DONE |
  332
+	  	CHAOS_CSR_RECEIVER_CLEAR;
  333
+
  334
+#if CHAOS_DEBUG
  335
+	printf("chaos: set csr bits 0%o (",v);
  336
+	print_csr_bits(v);
  337
+	printf ("), old 0%o ", chaos_csr);
  338
+#endif
  339
+
  340
+	chaos_csr = (chaos_csr & mask) | (v & ~mask);
  341
+
  342
+	if (chaos_csr & CHAOS_CSR_RESET) {
  343
+#if CHAOS_DEBUG
  344
+		printf("reset ");
  345
+#endif
  346
+		chaos_rcv_buffer_size = 0;
  347
+		chaos_xmit_buffer_ptr = 0;
  348
+		chaos_lost_count = 0;
  349
+		chaos_bit_count = 0;
  350
+		chaos_rcv_buffer_ptr = 0;
  351
+		chaos_csr &= ~(CHAOS_CSR_RESET | CHAOS_CSR_RECEIVE_DONE);
  352
+		chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
  353
+
  354
+		reconnect_delay = 200; /* Do it right away */
  355
+		chaos_force_reconect();
  356
+	}
  357
+
  358
+	if (v & CHAOS_CSR_RECEIVER_CLEAR) {
  359
+		chaos_csr &= ~CHAOS_CSR_RECEIVE_DONE;
  360
+		chaos_lost_count = 0;
  361
+		chaos_bit_count = 0;
  362
+		chaos_rcv_buffer_ptr = 0;
  363
+		chaos_rcv_buffer_size = 0;
  364
+	}
  365
+
  366
+	if (v & (CHAOS_CSR_TRANSMITTER_CLEAR | CHAOS_CSR_TRANSMIT_DONE)) {
  367
+		chaos_csr &= ~CHAOS_CSR_TRANSMIT_ABORT;
  368
+		chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
  369
+		chaos_xmit_buffer_ptr = 0;
  370
+	}
  371
+
  372
+	if (chaos_csr & CHAOS_CSR_RECEIVE_ENABLE) {
  373
+#if CHAOS_DEBUG
  374
+		printf("rx-enable ");
  375
+#endif
  376
+		if (chaos_rcv_buffer_empty) {
  377
+			chaos_rcv_buffer_ptr = 0;
  378
+			chaos_rcv_buffer_size = 0;
  379
+#if 0
  380
+			chaos_poll();
  381
+#endif
  382
+		}
  383
+
  384
+		/* if buffer is full, generate status & interrupt again */
  385
+		if (chaos_rcv_buffer_size > 0)
  386
+			chaos_rx_pkt();
  387
+	}
  388
+
  389
+	if (chaos_csr & CHAOS_CSR_TRANSMIT_ENABLE) {
  390
+#if CHAOS_DEBUG
  391
+		printf("tx-enable ");
  392
+#endif
  393
+		chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
  394
+#if 0
  395
+		char_xmit_done_intr();
  396
+	} else {
  397
+		chaos_csr &= ~CHAOS_CSR_TRANSMIT_DONE;
  398
+#endif
  399
+	}
  400
+
  401
+#if CHAOS_DEBUG
  402
+	printf(" New csr 0%o", chaos_csr);
  403
+	print_csr_bits(chaos_csr);
  404
+	printf("\n");
  405
+#endif
  406
+	return 0;
  407
+}
  408
+
  409
+#define UNIX_SOCKET_PATH	"/var/tmp/"
  410
+#define UNIX_SOCKET_CLIENT_NAME	"chaosd_"
  411
+#define UNIX_SOCKET_SERVER_NAME	"chaosd_server"
  412
+#define UNIX_SOCKET_PERM	S_IRWXU
  413
+
  414
+static struct sockaddr_un unix_addr;
  415
+
  416
+void
  417
+chaos_force_reconect(void)
  418
+{
  419
+#if CHAOS_DEBUG || 1
  420
+	printf("chaos: forcing reconnect to chaosd\n");
  421
+#endif
  422
+	close(chaos_fd);
  423
+	chaos_fd = 0;
  424
+	chaos_need_reconnect = 1;
  425
+}
  426
+
  427
+int
  428
+chaos_poll(void)
  429
+{
  430
+	int ret;
  431
+	struct pollfd pfd[1];
  432
+	int nfds, timeout;
  433
+
  434
+	if (chaos_need_reconnect) {
  435
+		chaos_reconnect();
  436
+	}
  437
+
  438
+	if (chaos_fd == 0) {
  439
+		return 0;
  440
+	}
  441
+
  442
+	timeout = 0;
  443
+	nfds = 1;
  444
+	pfd[0].fd = chaos_fd;
  445
+	pfd[0].events = POLLIN;
  446
+	pfd[0].revents = 0;
  447
+
  448
+	ret = poll(pfd, nfds, timeout);
  449
+	if (ret < 0) {
  450
+#if CHAOS_DEBUG
  451
+		printf("chaos: Polling, nothing there (RDN=%o)\n",
  452
+		       chaos_csr & CHAOS_CSR_RECEIVE_DONE);
  453
+#endif
  454
+		chaos_need_reconnect = 1;
  455
+		return -1;
  456
+	}
  457
+
  458
+	if (ret > 0) {
  459
+		u_char lenbytes[4];
  460
+		int len;
  461
+
  462
+		/* is rx buffer full? */
  463
+		if (!chaos_rcv_buffer_empty &&
  464
+		    (chaos_csr & CHAOS_CSR_RECEIVE_DONE))
  465
+		{
  466
+#ifndef CHAOS_TOSS_IF_RXBUFF_FULL
  467
+			printf("chaos: polling, but unread data exists\n");
  468
+			return 0;
  469
+#else
  470
+			/*
  471
+			 * Toss packets arriving when buffer is already in use
  472
+			 * they will be resent
  473
+			 */
  474
+#if CHAOS_DEBUG
  475
+			printf("chaos: polling, unread data, drop "
  476
+			       "(RDN=%o, lost %d)\n",
  477
+			       chaos_csr & CHAOS_CSR_RECEIVE_DONE,
  478
+			       chaos_lost_count);
  479
+#endif
  480
+			chaos_lost_count++;
  481
+			read(chaos_fd, lenbytes, 4);
  482
+			len = (lenbytes[0] << 8) | lenbytes[1];
  483
+#if CHAOS_DEBUG
  484
+			printf("chaos: tossing packet of %d bytes\n", len);
  485
+#endif
  486
+			if (len > sizeof(chaos_rcv_buffer_toss)) {
  487
+				printf("chaos packet won't fit");
  488
+				chaos_force_reconect();
  489
+				return -1;
  490
+			}
  491
+
  492
+			/* toss it */
  493
+			read(chaos_fd, (char *)chaos_rcv_buffer_toss, len);
  494
+			return -1;
  495
+#endif
  496
+		}
  497
+
  498
+		/* read header from chaosd */
  499
+		ret = read(chaos_fd, lenbytes, 4);
  500
+		if (ret <= 0) {
  501
+			perror("chaos: header read error");
  502
+			chaos_force_reconect();
  503
+			return -1;
  504
+		}
  505
+
  506
+		len = (lenbytes[0] << 8) | lenbytes[1];
  507
+
  508
+		if (len > sizeof(chaos_rcv_buffer)) {
  509
+			printf("chaos: packet too big: "
  510
+			       "pkt size %d, buffer size %d\n",
  511
+			       len, sizeof(chaos_rcv_buffer));
  512
+
  513
+			/* When we get out of synch break socket conn */
  514
+			chaos_force_reconect();
  515
+			return -1;
  516
+		}
  517
+
  518
+		ret = read(chaos_fd, (char *)chaos_rcv_buffer, len);
  519
+		if (ret < 0) {
  520
+			perror("chaos: read");
  521
+			chaos_force_reconect();
  522
+			return -1;
  523
+		}
  524
+
  525
+#if CHAOS_DEBUG
  526
+		printf("chaos: polling; got chaosd packet %d\n", ret);
  527
+#endif
  528
+
  529
+		if (ret > 0) {
  530
+		  int dest_addr;
  531
+
  532
+		  chaos_rcv_buffer_size = (ret+1)/2;
  533
+		  chaos_rcv_buffer_empty = 0;
  534
+
  535
+#if __BIG_ENDIAN__
  536
+		  /* flip shorts to host order */
  537
+		  int w;
  538
+		  for (w = 0; w < chaos_rcv_buffer_size; w++) {
  539
+		    chaos_rcv_buffer[w] = SWAP_SHORT(chaos_rcv_buffer[w]);
  540
+		  }
  541
+#endif		  
  542
+
  543
+		  dest_addr = chaos_rcv_buffer[chaos_rcv_buffer_size-3];
  544
+
  545
+#if CHAOS_DEBUG
  546
+		  printf("chaos rx: to %o, my %o\n", dest_addr, chaos_addr);
  547
+#endif
  548
+
  549
+#if CHAOS_DEBUG_PKT
  550
+		  {
  551
+			  int i, c = 0, o = 0;
  552
+			  unsigned char cc, cb[9];
  553
+			  cb[8] = 0;
  554
+			  for (i = 0; i < ret; i++) {
  555
+				  if (c == 8) { printf("%s\n", cb); c = 0; }
  556
+				  if (c++ == 0) printf("%04d ", o);
  557
+				  cc = ((unsigned char *)chaos_rcv_buffer)[i];
  558
+				  printf("%02x ", cc);
  559
+				  cb[c-1] = (cc >= ' ' && cc <= '~') ?
  560
+					  cc : '.';
  561
+				  if (i == ret-1 && c > 0) {
  562
+					  for (; c < 8; c++) {
  563
+						  printf("xx "); cb[c]=' ';
  564
+					  }
  565
+					  printf("%s\n", cb);
  566
+					  break;
  567
+				  }
  568
+			  }
  569
+		  }
  570
+#endif
  571
+
  572
+		  /* if not to us, ignore */
  573
+		  if (dest_addr != chaos_addr) {
  574
+		    chaos_rcv_buffer_size = 0;
  575
+		    chaos_rcv_buffer_empty = 1;
  576
+		    return 0;
  577
+		  }
  578
+
  579
+		  chaos_rx_pkt();
  580
+		}
  581
+	}
  582
+
  583
+	return 0;
  584
+}
  585
+
  586
+int
  587
+chaos_send_to_chaosd(char *buffer, int size)
  588
+{
  589
+	int ret, wcount, dest_addr;
  590
+
  591
+	/* local loopback */
  592
+	if (chaos_csr & CHAOS_CSR_LOOP_BACK) {
  593
+
  594
+		printf("chaos: loopback %d bytes\n", size);
  595
+		memcpy(chaos_rcv_buffer, buffer, size);
  596
+
  597
+		chaos_rcv_buffer_size = (size+1)/2;
  598
+		chaos_rcv_buffer_empty = 0;
  599
+
  600
+		chaos_rx_pkt();
  601
+
  602
+		return 0;
  603
+	}
  604
+
  605
+	wcount = (size+1)/2;
  606
+	dest_addr = ((u_short *)buffer)[wcount-3];
  607
+
  608
+	//printf("chaos_send_to_chaosd() dest_addr %o\n", dest_addr);
  609
+
  610
+#if __BIG_ENDIAN__
  611
+	/* flip host order to network order */
  612
+	int w;
  613
+	for (w = 0; w < wcount; w++) {
  614
+		u_short *ps = &((u_short *)buffer)[w];
  615
+		*ps = SWAP_SHORT(*ps);
  616
+	}
  617
+#endif
  618
+
  619
+#if CHAOS_DEBUG
  620
+	printf("chaos tx: dest_addr = %o, chaos_addr=%o, size %d, wcount %d\n", 
  621
+	       dest_addr, chaos_addr, size, wcount);
  622
+#endif
  623
+
  624
+	/* recieve packets address to ourselves */
  625
+	if (dest_addr == chaos_addr) {
  626
+		memcpy(chaos_rcv_buffer, buffer, size);
  627
+
  628
+		chaos_rcv_buffer_size = (size+1)/2;
  629
+		chaos_rcv_buffer_empty = 0;
  630
+
  631
+		chaos_rx_pkt();
  632
+	}
  633
+
  634
+	/* chaosd server */
  635
+	if (chaos_fd) {
  636
+		struct iovec iov[2];
  637
+		unsigned char lenbytes[4];
  638
+
  639
+		lenbytes[0] = size >> 8;
  640
+		lenbytes[1] = size;
  641
+		lenbytes[2] = 1;
  642
+		lenbytes[3] = 0;
  643
+
  644
+		iov[0].iov_base = lenbytes;
  645
+		iov[0].iov_len = 4;
  646
+
  647
+		iov[1].iov_base = buffer;
  648
+		iov[1].iov_len = size;
  649
+
  650
+		ret = writev(chaos_fd, iov, 2);
  651
+		if (ret < 0) {
  652
+			perror("chaos write");
  653
+			return -1;
  654
+		}
  655
+	}
  656
+
  657
+	return 0;
  658
+}
  659
+
  660
+
  661
+/*
  662
+ * connect to server using specificed socket type
  663
+ */
  664
+static int
  665
+chaos_connect_to_server(void)
  666
+{
  667
+	int len;
  668
+
  669
+	if (0) printf("connect_to_server()\n");
  670
+
  671
+	if ((chaos_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
  672
+		perror("socket(AF_UNIX)");
  673
+		chaos_fd = 0;
  674
+		return -1;
  675
+	}
  676
+
  677
+	memset(&unix_addr, 0, sizeof(unix_addr));
  678
+
  679
+	sprintf(unix_addr.sun_path, "%s%s%05u",
  680
+		UNIX_SOCKET_PATH, UNIX_SOCKET_CLIENT_NAME, getpid());
  681
+
  682
+	unix_addr.sun_family = AF_UNIX;
  683
+	len = SUN_LEN(&unix_addr);
  684
+
  685
+	unlink(unix_addr.sun_path);
  686
+
  687
+	if ((bind(chaos_fd, (struct sockaddr *)&unix_addr, len) < 0)) {
  688
+		perror("bind(AF_UNIX)");
  689
+		return -1;
  690
+	}
  691
+
  692
+	if (chmod(unix_addr.sun_path, UNIX_SOCKET_PERM) < 0) {
  693
+		perror("chmod(AF_UNIX)");
  694
+		return -1;
  695
+	}
  696
+
  697
+	memset(&unix_addr, 0, sizeof(unix_addr));
  698
+	sprintf(unix_addr.sun_path, "%s%s",
  699
+		UNIX_SOCKET_PATH, UNIX_SOCKET_SERVER_NAME);
  700
+	unix_addr.sun_family = AF_UNIX;
  701
+	len = SUN_LEN(&unix_addr);
  702
+
  703
+	if (connect(chaos_fd, (struct sockaddr *)&unix_addr, len) < 0) {
  704
+		printf("chaos: no chaosd server\n");
  705
+		return -1;
  706
+	}
  707
+
  708
+	if (0) printf("chaos_fd %d\n", chaos_fd);
  709
+        
  710
+	return 0;
  711
+}
  712
+
  713
+int
  714
+chaos_init(void)
  715
+{
  716
+	if (chaos_connect_to_server()) {
  717
+		close(chaos_fd);
  718
+		chaos_fd = 0;
  719
+		return -1;
  720
+	}
  721
+
  722
+	chaos_rcv_buffer_empty = 1;
  723
+
  724
+	return 0;
  725
+}
  726
+
  727
+int
  728
+chaos_reconnect(void)
  729
+{
  730
+	/* */
  731
+	if (++reconnect_delay < 200) {
  732
+		return 0;
  733
+	}
  734
+	reconnect_delay = 0;
  735
+
  736
+	/* try every 5 seconds */
  737
+	if (reconnect_time &&
  738
+	    time(NULL) < (reconnect_time + 5))
  739
+	{
  740
+		return 0;
  741
+	}
  742
+	reconnect_time = time(NULL);
  743
+
  744
+# if CHAOS_DEBUG || 1
  745
+	printf("chaos: reconnecting to chaosd\n");
  746
+#endif
  747
+	if (chaos_init() == 0) {
  748
+		printf("chaos: reconnected\n");
  749
+		chaos_need_reconnect = 0;
  750
+		reconnect_delay = 0;
  751
+	}
  752
+
  753
+	return 0;
  754
+}
  755
+
  756
+#endif /* linux || osx */
  757
+
  758
+/* these are stubs; eventually I'll fix the code work with win32 sockets */
  759
+#ifdef WIN32
  760
+int
  761
+chaos_init(void)
  762
+{
  763
+	return 0;
  764
+}
  765
+
  766
+void
  767
+chaos_xmit_pkt(void)
  768
+{
  769
+}
  770
+ 
  771
+int
  772
+chaos_get_bit_count(void)
  773
+{
  774
+	return 0;
  775
+}
  776
+ 
  777
+int
  778
+chaos_get_rcv_buffer(void)
  779
+{
  780
+	return 0;
  781
+}
  782
+ 
  783
+int
  784
+chaos_get_csr(void)
  785
+{
  786
+	return 0;
  787
+}
  788
+ 
  789
+int
  790
+chaos_put_xmit_buffer(int v)
  791
+{
  792
+	return 0;
  793
+}
  794
+ 
  795
+int
  796
+chaos_get_addr(void)
  797
+{
  798
+	return 0;
  799
+}
  800
+
  801
+int
  802
+chaos_set_csr(int v)
  803
+{
  804
+	return 0;
  805
+}
  806
+#endif
12  chaos.h
... ...
@@ -0,0 +1,12 @@
  1
+/*
  2
+ * chaos.h
  3
+ */
  4
+
  5
+int chaos_get_csr(void);
  6
+int chaos_get_addr(void);
  7
+int chaos_get_rcv_buffer(void);
  8
+int chaos_get_bit_count(void);
  9
+
  10
+int chaos_set_csr(int v);
  11
+int chaos_put_xmit_buffer(int v);
  12
+
51  config.c
... ...
@@ -0,0 +1,51 @@
  1
+/*
  2
+ * config.c
  3
+ * $Id: config.c 61 2006-04-01 01:25:14Z brad $
  4
+ */
  5
+
  6
+#include "usim.h"
  7
+
  8
+#include <string.h>
  9
+
  10
+#include "config.h"
  11
+
  12
+static char *mcrsym_filename;
  13
+static char *disk_filename;
  14
+
  15
+const char *
  16
+config_get_promsym_filename(void)
  17
+{
  18
+	return "promh.sym.9";
  19
+}
  20
+
  21
+const char *
  22
+config_get_mcrsym_filename(void)
  23
+{
  24
+	if (mcrsym_filename)