From de170a64d978143debdd3ebe4e865913905cb6e4 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Mon, 20 Apr 2015 18:53:52 -0700 Subject: [PATCH] Maiko sources matching state as of 020102 prior to initial patching for Mac OSX --- bin/ChangeLog | 69 + bin/README | 8 + bin/checksum | 78 + bin/checksum-readme | 88 + bin/checksum-readme-internal | 67 + bin/compile-flags | 182 + bin/config.guess | 1313 +++++++ bin/config.sub | 1434 ++++++++ bin/copyright | 14 + bin/dbxinit.txt | 62 + bin/dir.o | Bin 0 -> 18408 bytes bin/dosmkfil | 631 ++++ bin/endiffix | Bin 0 -> 24576 bytes bin/endiffix.lex | 4 + bin/environment-variables | 14 + bin/find-writes | 4 + bin/fixid | 68 + bin/fixid~ | 38 + bin/install-medley | 758 ++++ bin/launch.asm | 362 ++ bin/ldechecksum | 170 + bin/machinetype | 24 + bin/machinetype~ | 19 + bin/makedecright | 120 + bin/makefile-ISC.i386-x | 64 + bin/makefile-aix.ps2-x | 64 + bin/makefile-aix.rs6000-x | 66 + bin/makefile-domain.mc68020-x | 74 + bin/makefile-dos | 631 ++++ bin/makefile-header | 35 + bin/makefile-hpux.hp9000-x | 93 + bin/makefile-init.sgi | 100 + bin/makefile-init.sparc | 120 + bin/makefile-init.sparc-multi | 104 + bin/makefile-init.sparc~ | 90 + bin/makefile-irix.sgi-x | 112 + bin/makefile-linux.386-x | 103 + bin/makefile-osf1.dec-x | 69 + bin/makefile-riscos.mips-x | 81 + bin/makefile-sunos3.mc68020 | 30 + bin/makefile-sunos3.mc68020-multi | 38 + bin/makefile-sunos3.mc68020-x | 58 + bin/makefile-sunos3.sparc | 67 + bin/makefile-sunos4.1.i386 | 44 + bin/makefile-sunos4.1.i386-multi | 46 + bin/makefile-sunos4.1.mc68020 | 36 + bin/makefile-sunos4.1.mc68020-multi | 38 + bin/makefile-sunos4.1.mc68020-x | 64 + bin/makefile-sunos4.1.sparc | 73 + bin/makefile-sunos4.1.sparc-color | 71 + bin/makefile-sunos4.1.sparc-multi | 79 + bin/makefile-sunos4.1.sparc-x | 121 + bin/makefile-sunos4.i386 | 44 + bin/makefile-sunos4.i386-multi | 48 + bin/makefile-sunos4.mc68020 | 36 + bin/makefile-sunos4.mc68020-multi | 38 + bin/makefile-sunos4.mc68020-x | 65 + bin/makefile-sunos4.sparc | 129 + bin/makefile-sunos4.sparc% | 100 + bin/makefile-sunos4.sparc-3 | 79 + bin/makefile-sunos4.sparc-color | 69 + bin/makefile-sunos4.sparc-multi | 134 + bin/makefile-sunos4.sparc-multi% | 98 + bin/makefile-sunos4.sparc-multi-3 | 94 + bin/makefile-sunos4.sparc-x | 127 + bin/makefile-sunos4.sparc-x% | 104 + bin/makefile-sunos4.sparc-x-3 | 96 + bin/makefile-sunos5.i386-x | 139 + bin/makefile-sunos5.sparc-x | 143 + bin/makefile-tail | 1134 ++++++ bin/makefile-ultrix.dec3100-x | 67 + bin/makefile.dos | 631 ++++ bin/makeinitlde | 17 + bin/makeisc | 1092 ++++++ bin/makeright | 133 + bin/makeright.sh | 131 + bin/makersright | 120 + bin/makewrong | 6 + bin/medley-solaris | 203 ++ bin/mkdos | 212 ++ bin/mkfile | 201 ++ bin/mkfile.c | 201 ++ bin/mkfile.i | 86 + bin/mkr2 | 133 + bin/optck | Bin 0 -> 24576 bytes bin/optck- | Bin 0 -> 24576 bytes bin/optck.sh | 17 + bin/osversion | 20 + bin/runlisp | 50 + bin/runlispether | 54 + bin/u2dnames.sed | 81 + bin/unix2dos.sed | 81 + bin/usermakefile | 30 + bin/usermakefile-domain.mc68020 | 0 bin/usermakefile-domain.mc68020-x | 0 bin/usermakefile-irix.sgi | 0 bin/usermakefile-irix.sgi-x | 0 bin/usermakefile-sunos3.mc68020 | 39 + bin/usermakefile-sunos3.mc68020-multi | 37 + bin/usermakefile-sunos3.mc68020-x | 39 + bin/usermakefile-sunos4.1.mc68020 | 39 + bin/usermakefile-sunos4.1.sparc | 39 + bin/usermakefile-sunos4.1.sparc-multi | 39 + bin/usermakefile-sunos4.1.sparc-x | 39 + bin/usermakefile-sunos4.mc68020 | 39 + bin/usermakefile-sunos4.mc68020-multi | 37 + bin/usermakefile-sunos4.mc68020-x | 39 + bin/usermakefile-sunos4.sparc | 39 + bin/usermakefile-sunos4.sparc-multi | 39 + bin/usermakefile-sunos4.sparc-x | 39 + inc/Check.h | 64 + inc/MyWindow.h | 115 + inc/Stipple.h | 46 + inc/XCursors.h | 260 ++ inc/XKeymap.h | 264 ++ inc/XVersion.h | 60 + inc/XWaitCur.h | 38 + inc/Xbitblt.h | 71 + inc/Xcursdef.h | 38 + inc/Xdefcur.h | 39 + inc/Xdeflt.h | 35 + inc/Xdisplay.h | 50 + inc/Xicon.h | 81 + inc/address.h | 59 + inc/adr68k.h | 69 + inc/arith.h | 275 ++ inc/arith2.h | 142 + inc/array.h | 234 ++ inc/bb.h | 837 +++++ inc/bbt386i.h | 1 + inc/bitblt.h | 95 + inc/cdrom.h | 144 + inc/cell.h | 493 +++ inc/cell.h% | 467 +++ inc/copyright | 13 + inc/cr | 13 + inc/dbprint.h | 94 + inc/debug.h | 443 +++ inc/devconf.h | 51 + inc/devif.h | 309 ++ inc/display.h | 81 + inc/dld.h | 64 + inc/dspdata.h | 131 + inc/emlglob.h | 36 + inc/ether.h | 126 + inc/externs.h | 187 + inc/fast_dsp.h | 258 ++ inc/fp.h | 119 + inc/gc.h | 270 ++ inc/gc.h.save | 270 ++ inc/gcscan.h | 52 + inc/hdw_conf.h | 41 + inc/ifpage.h | 362 ++ inc/initatms.h | 44 + inc/inlineC.h | 1075 ++++++ inc/inln386i.h | 261 ++ inc/inln68k+.h | 200 ++ inc/inln68k.h | 162 + inc/inlnMIPS.h | 95 + inc/inlnPS2.h | 1112 ++++++ inc/inlnSPARC.h | 177 + inc/inlndos.h | 1125 ++++++ inc/inlsparc.h | 175 + inc/iopage.h | 156 + inc/kbdif.h | 46 + inc/keyboard.h | 196 + inc/keyboard.h% | 195 + inc/keysym.h | 133 + inc/ldeXdefs.h | 43 + inc/lispemul.h | 640 ++++ inc/lispemul.h.save | 640 ++++ inc/lispmap.h | 388 ++ inc/lispver1.h | 44 + inc/lispver2.h | 71 + inc/lldsp.h | 219 ++ inc/lnk-Xdeflt.h | 35 + inc/lnk-debug.h | 443 +++ inc/lnk-fast_dsp.h | 166 + inc/lnk-inlineC.h | 1074 ++++++ inc/lnk-lispmap.h | 247 ++ inc/lnk-tosfns.h | 794 ++++ inc/lnk-tosret.h | 90 + inc/lnk-version.h | 99 + inc/locfile.h | 707 ++++ inc/lpdefs.h | 195 + inc/lpglob.h | 79 + inc/lpglobl.h | 82 + inc/lpkit.h | 537 +++ inc/lppatch.h | 2 + inc/lpproto.h | 36 + inc/lspglob.h | 192 + inc/lsptypes.h | 718 ++++ inc/medleyfp.h | 126 + inc/miscstat.h | 53 + inc/mnxdefs.h | 529 +++ inc/my.h | 236 ++ inc/native.h | 829 +++++ inc/nfsfh.h | 43 + inc/nfswatch.h | 430 +++ inc/ocr.h | 259 ++ inc/opcodes.h | 44 + inc/os.h | 126 + inc/osmsg.h | 27 + inc/picture.h | 24 + inc/pilotbbt.h | 145 + inc/print.h | 44 + inc/profile.h | 290 ++ inc/rawrs232c.h | 41 + inc/return.h | 118 + inc/rs232c.h | 172 + inc/sccsid.c | 2 + inc/sccsid.c% | 2 + inc/sccsid.h | 1 + inc/sccsid.h% | 1 + inc/sccsid.s | 1 + inc/stack.h | 454 +++ inc/stream.h | 183 + inc/stream.h% | 158 + inc/stream.h2 | 183 + inc/subrs.h | 193 + inc/sunerrno.h | 121 + inc/sunfilio.h | 27 + inc/sunioccom.h | 33 + inc/suntermios.h | 119 + inc/sunttold.h | 170 + inc/sunttycom.h | 69 + inc/sunttydev.h | 29 + inc/sysatms.h | 35 + inc/sysatms.h- | 36 + inc/timeout.h | 82 + inc/tos1defs.h | 129 + inc/tosfns.h | 806 +++++ inc/tosret.h | 93 + inc/tty.h | 81 + inc/version.h | 473 +++ inc/vmemsave.h | 27 + inc/xbitmaps.h | 405 +++ inc/xdefs.h | 89 + include/README | 7 + include/ansidecl.h | 141 + include/dld.h | 157 + src/#ldeboot.c# | 290 ++ src/Cldeetr.c | 187 + src/allocmds.c | 212 ++ src/arith2.c | 312 ++ src/arith3.c | 119 + src/arith4.c | 210 ++ src/array.c | 75 + src/array2.c | 71 + src/array3.c | 79 + src/array4.c | 84 + src/array5.c | 89 + src/array6.c | 68 + src/asmbbt.c | 59 + src/asmbitblt.c | 66 + src/atom.c | 91 + src/bbt68k.s | 1683 +++++++++ src/bbtSPARC.s | 1941 ++++++++++ src/bbtsub.c | 2428 +++++++++++++ src/bin.c | 71 + src/binds.c | 167 + src/bitblt.c | 275 ++ src/blt.c | 75 + src/box | 6 + src/byteswap.c | 236 ++ src/call-c.c | 39 + src/car-cdr.c | 738 ++++ src/cdaudio.c | 381 ++ src/cdrom.c | 250 ++ src/chardev.c | 454 +++ src/chatter.c | 249 ++ src/codeconv.c | 210 ++ src/codetbl.c | 582 +++ src/colorbltfns.c | 787 ++++ src/common.c | 203 ++ src/conspage.c | 496 +++ src/cr | 13 + src/dbgtool.c | 865 +++++ src/dir.c | 2420 +++++++++++++ src/dlpi.c | 720 ++++ src/doscomm.c | 26 + src/doskbd.c | 345 ++ src/dosmouse.c | 701 ++++ src/draw.c | 391 ++ src/dsk.c | 4767 +++++++++++++++++++++++++ src/dsp386.il | 1791 ++++++++++ src/dspSPARC.il | 723 ++++ src/dsphack.lex | 62 + src/dspif.c | 165 + src/dspsubrs.c | 328 ++ src/ejlisp.c | 974 +++++ src/eqf.c | 315 ++ src/ether.c | 1190 ++++++ src/find-dsp.lex | 17 + src/findkey.c | 84 + src/foreign.c | 997 ++++++ src/fp.c | 192 + src/fvar.c | 610 ++++ src/gc.c | 52 + src/gc2.c | 96 + src/gcarray.c | 371 ++ src/gccode.c | 390 ++ src/gcfinal.c | 628 ++++ src/gchtfind.c | 584 +++ src/gcmain3.c | 629 ++++ src/gcoflow.c | 118 + src/gcr.c | 186 + src/gcrcell.c | 390 ++ src/gcscan.c | 105 + src/gvar2.c | 101 + src/hacks.c | 44 + src/hardrtn.c | 334 ++ src/hasbcopy | 8 + src/id | 2 + src/imagefile.c | 375 ++ src/imagefile2.c | 180 + src/inet.c | 480 +++ src/initdsp.c | 931 +++++ src/initkbd.c | 810 +++++ src/initsout.c | 544 +++ src/intcall.c | 132 + src/kbdif.c | 54 + src/kbdsubrs.c | 222 ++ src/keyevent.c | 880 +++++ src/keylib.c | 251 ++ src/keymaker.c | 251 ++ src/keytst.c | 201 ++ src/keytstno.c | 26 + src/kprint.c | 253 ++ src/launch.asm | 363 ++ src/ldeboot.c | 288 ++ src/ldeether.c | 291 ++ src/ldsout.c | 408 +++ src/lineblt8.c | 232 ++ src/lisp2c.c | 139 + src/llcolor.c | 359 ++ src/llstk.c | 1261 +++++++ src/loader.c | 221 ++ src/loopsops.c | 475 +++ src/lowlev1.c | 163 + src/lowlev2.c | 137 + src/lpdual.c | 191 + src/lpkit.c | 1856 ++++++++++ src/lplexyy.c | 878 +++++ src/lplexyy.c.X | 0 src/lpmain.c | 331 ++ src/lpread.c | 137 + src/lpsolve.c | 1564 ++++++++ src/lptran.c | 98 + src/lpwrite.c | 134 + src/lpytab.c | 740 ++++ src/lpytab.c.X | 0 src/lsthandl.c | 145 + src/main.c | 888 +++++ src/misc7.c | 133 + src/miscn.c | 217 ++ src/mkatom.c | 453 +++ src/mkcell.c | 245 ++ src/mkkey.c | 19 + src/mkkey.c.X | 0 src/mkvdate.c | 80 + src/mnwevent.c | 688 ++++ src/mnxmeth.c | 3727 +++++++++++++++++++ src/mouseif.c | 137 + src/mvs.c | 353 ++ src/ocr.c | 1613 +++++++++ src/ocr.c.X | 0 src/ocrproc.c | 1142 ++++++ src/ocrproc.c.X | 0 src/oether.c | 1015 ++++++ src/oldeether.c | 195 + src/optck.c | 57 + src/osmsg.c | 455 +++ src/perrno.c | 79 + src/picture.c | 706 ++++ src/rawcolor.c | 788 ++++ src/rawrs232c.c | 352 ++ src/return.c | 200 ++ src/rpc.c | 229 ++ src/rplcons.c | 90 + src/rs232c.c | 913 +++++ src/setsout.c | 121 + src/shift.c | 111 + src/socdvr.c | 322 ++ src/socket.c | 135 + src/storage.c | 452 +++ src/subr.c | 786 ++++ src/subr0374.c | 48 + src/sxhash.c | 383 ++ src/sysatms.c | 2 + src/sysatms.c.X | 0 src/testdsp.c | 403 +++ src/testtool.c | 1342 +++++++ src/timeoday.c | 31 + src/timeofday.c | 31 + src/timer.c | 1310 +++++++ src/truecolor.c | 503 +++ src/tstsout.c | 93 + src/tty.c | 263 ++ src/typeof.c | 96 + src/ubf1.c | 94 + src/ubf2.c | 81 + src/ubf3.c | 60 + src/ufn.c | 227 ++ src/ufs.c | 1425 ++++++++ src/unixcomm.c | 1228 +++++++ src/unixfork.c | 729 ++++ src/unwind.c | 234 ++ src/uraid.c | 1537 ++++++++ src/usrsubr.c | 49 + src/uutils.c | 501 +++ src/vars3.c | 194 + src/vesafns.asm | 831 +++++ src/vesainit.c | 503 +++ src/vgainit.c | 183 + src/vmemsave.c | 667 ++++ src/xbbt.c | 111 + src/xc.c | 1857 ++++++++++ src/xc.c.orig | 1854 ++++++++++ src/xcursor.c | 299 ++ src/xinit.c | 393 ++ src/xlspwin.c | 545 +++ src/xmkicon.c | 106 + src/xrdopt.c | 442 +++ src/xscroll.c | 89 + src/xwinman.c | 420 +++ src/z2.c | 182 + 427 files changed, 129342 insertions(+) create mode 100644 bin/ChangeLog create mode 100644 bin/README create mode 100755 bin/checksum create mode 100755 bin/checksum-readme create mode 100755 bin/checksum-readme-internal create mode 100755 bin/compile-flags create mode 100755 bin/config.guess create mode 100644 bin/config.sub create mode 100755 bin/copyright create mode 100755 bin/dbxinit.txt create mode 100644 bin/dir.o create mode 100755 bin/dosmkfil create mode 100755 bin/endiffix create mode 100755 bin/endiffix.lex create mode 100755 bin/environment-variables create mode 100755 bin/find-writes create mode 100755 bin/fixid create mode 100755 bin/fixid~ create mode 100755 bin/install-medley create mode 100755 bin/launch.asm create mode 100755 bin/ldechecksum create mode 100755 bin/machinetype create mode 100644 bin/machinetype~ create mode 100755 bin/makedecright create mode 100755 bin/makefile-ISC.i386-x create mode 100755 bin/makefile-aix.ps2-x create mode 100755 bin/makefile-aix.rs6000-x create mode 100755 bin/makefile-domain.mc68020-x create mode 100755 bin/makefile-dos create mode 100755 bin/makefile-header create mode 100755 bin/makefile-hpux.hp9000-x create mode 100755 bin/makefile-init.sgi create mode 100755 bin/makefile-init.sparc create mode 100755 bin/makefile-init.sparc-multi create mode 100755 bin/makefile-init.sparc~ create mode 100755 bin/makefile-irix.sgi-x create mode 100755 bin/makefile-linux.386-x create mode 100755 bin/makefile-osf1.dec-x create mode 100755 bin/makefile-riscos.mips-x create mode 100755 bin/makefile-sunos3.mc68020 create mode 100755 bin/makefile-sunos3.mc68020-multi create mode 100755 bin/makefile-sunos3.mc68020-x create mode 100755 bin/makefile-sunos3.sparc create mode 100755 bin/makefile-sunos4.1.i386 create mode 100755 bin/makefile-sunos4.1.i386-multi create mode 100755 bin/makefile-sunos4.1.mc68020 create mode 100755 bin/makefile-sunos4.1.mc68020-multi create mode 100755 bin/makefile-sunos4.1.mc68020-x create mode 100755 bin/makefile-sunos4.1.sparc create mode 100755 bin/makefile-sunos4.1.sparc-color create mode 100755 bin/makefile-sunos4.1.sparc-multi create mode 100755 bin/makefile-sunos4.1.sparc-x create mode 100755 bin/makefile-sunos4.i386 create mode 100755 bin/makefile-sunos4.i386-multi create mode 100755 bin/makefile-sunos4.mc68020 create mode 100755 bin/makefile-sunos4.mc68020-multi create mode 100755 bin/makefile-sunos4.mc68020-x create mode 100755 bin/makefile-sunos4.sparc create mode 100755 bin/makefile-sunos4.sparc% create mode 100755 bin/makefile-sunos4.sparc-3 create mode 100755 bin/makefile-sunos4.sparc-color create mode 100755 bin/makefile-sunos4.sparc-multi create mode 100755 bin/makefile-sunos4.sparc-multi% create mode 100755 bin/makefile-sunos4.sparc-multi-3 create mode 100755 bin/makefile-sunos4.sparc-x create mode 100755 bin/makefile-sunos4.sparc-x% create mode 100755 bin/makefile-sunos4.sparc-x-3 create mode 100755 bin/makefile-sunos5.i386-x create mode 100755 bin/makefile-sunos5.sparc-x create mode 100755 bin/makefile-tail create mode 100755 bin/makefile-ultrix.dec3100-x create mode 100755 bin/makefile.dos create mode 100755 bin/makeinitlde create mode 100755 bin/makeisc create mode 100755 bin/makeright create mode 100755 bin/makeright.sh create mode 100755 bin/makersright create mode 100755 bin/makewrong create mode 100755 bin/medley-solaris create mode 100755 bin/mkdos create mode 100755 bin/mkfile create mode 100755 bin/mkfile.c create mode 100755 bin/mkfile.i create mode 100755 bin/mkr2 create mode 100755 bin/optck create mode 100755 bin/optck- create mode 100755 bin/optck.sh create mode 100755 bin/osversion create mode 100755 bin/runlisp create mode 100755 bin/runlispether create mode 100755 bin/u2dnames.sed create mode 100755 bin/unix2dos.sed create mode 100755 bin/usermakefile create mode 100755 bin/usermakefile-domain.mc68020 create mode 100755 bin/usermakefile-domain.mc68020-x create mode 100755 bin/usermakefile-irix.sgi create mode 100755 bin/usermakefile-irix.sgi-x create mode 100755 bin/usermakefile-sunos3.mc68020 create mode 100755 bin/usermakefile-sunos3.mc68020-multi create mode 100755 bin/usermakefile-sunos3.mc68020-x create mode 100755 bin/usermakefile-sunos4.1.mc68020 create mode 100755 bin/usermakefile-sunos4.1.sparc create mode 100755 bin/usermakefile-sunos4.1.sparc-multi create mode 100755 bin/usermakefile-sunos4.1.sparc-x create mode 100755 bin/usermakefile-sunos4.mc68020 create mode 100755 bin/usermakefile-sunos4.mc68020-multi create mode 100755 bin/usermakefile-sunos4.mc68020-x create mode 100755 bin/usermakefile-sunos4.sparc create mode 100755 bin/usermakefile-sunos4.sparc-multi create mode 100755 bin/usermakefile-sunos4.sparc-x create mode 100755 inc/Check.h create mode 100755 inc/MyWindow.h create mode 100755 inc/Stipple.h create mode 100755 inc/XCursors.h create mode 100755 inc/XKeymap.h create mode 100755 inc/XVersion.h create mode 100755 inc/XWaitCur.h create mode 100755 inc/Xbitblt.h create mode 100755 inc/Xcursdef.h create mode 100755 inc/Xdefcur.h create mode 100755 inc/Xdeflt.h create mode 100755 inc/Xdisplay.h create mode 100755 inc/Xicon.h create mode 100755 inc/address.h create mode 100755 inc/adr68k.h create mode 100755 inc/arith.h create mode 100755 inc/arith2.h create mode 100755 inc/array.h create mode 100755 inc/bb.h create mode 100755 inc/bbt386i.h create mode 100755 inc/bitblt.h create mode 100755 inc/cdrom.h create mode 100755 inc/cell.h create mode 100755 inc/cell.h% create mode 100755 inc/copyright create mode 100755 inc/cr create mode 100755 inc/dbprint.h create mode 100755 inc/debug.h create mode 100755 inc/devconf.h create mode 100755 inc/devif.h create mode 100755 inc/display.h create mode 100755 inc/dld.h create mode 100755 inc/dspdata.h create mode 100755 inc/emlglob.h create mode 100755 inc/ether.h create mode 100755 inc/externs.h create mode 100755 inc/fast_dsp.h create mode 100755 inc/fp.h create mode 100755 inc/gc.h create mode 100755 inc/gc.h.save create mode 100755 inc/gcscan.h create mode 100755 inc/hdw_conf.h create mode 100755 inc/ifpage.h create mode 100755 inc/initatms.h create mode 100755 inc/inlineC.h create mode 100755 inc/inln386i.h create mode 100755 inc/inln68k+.h create mode 100755 inc/inln68k.h create mode 100755 inc/inlnMIPS.h create mode 100755 inc/inlnPS2.h create mode 100755 inc/inlnSPARC.h create mode 100755 inc/inlndos.h create mode 100755 inc/inlsparc.h create mode 100755 inc/iopage.h create mode 100755 inc/kbdif.h create mode 100755 inc/keyboard.h create mode 100755 inc/keyboard.h% create mode 100755 inc/keysym.h create mode 100755 inc/ldeXdefs.h create mode 100755 inc/lispemul.h create mode 100755 inc/lispemul.h.save create mode 100755 inc/lispmap.h create mode 100755 inc/lispver1.h create mode 100755 inc/lispver2.h create mode 100755 inc/lldsp.h create mode 100755 inc/lnk-Xdeflt.h create mode 100755 inc/lnk-debug.h create mode 100755 inc/lnk-fast_dsp.h create mode 100755 inc/lnk-inlineC.h create mode 100755 inc/lnk-lispmap.h create mode 100755 inc/lnk-tosfns.h create mode 100755 inc/lnk-tosret.h create mode 100755 inc/lnk-version.h create mode 100755 inc/locfile.h create mode 100755 inc/lpdefs.h create mode 100755 inc/lpglob.h create mode 100755 inc/lpglobl.h create mode 100755 inc/lpkit.h create mode 100755 inc/lppatch.h create mode 100755 inc/lpproto.h create mode 100755 inc/lspglob.h create mode 100755 inc/lsptypes.h create mode 100755 inc/medleyfp.h create mode 100755 inc/miscstat.h create mode 100755 inc/mnxdefs.h create mode 100755 inc/my.h create mode 100755 inc/native.h create mode 100755 inc/nfsfh.h create mode 100755 inc/nfswatch.h create mode 100755 inc/ocr.h create mode 100755 inc/opcodes.h create mode 100755 inc/os.h create mode 100755 inc/osmsg.h create mode 100755 inc/picture.h create mode 100755 inc/pilotbbt.h create mode 100755 inc/print.h create mode 100755 inc/profile.h create mode 100755 inc/rawrs232c.h create mode 100755 inc/return.h create mode 100755 inc/rs232c.h create mode 100755 inc/sccsid.c create mode 100755 inc/sccsid.c% create mode 100755 inc/sccsid.h create mode 100755 inc/sccsid.h% create mode 100755 inc/sccsid.s create mode 100755 inc/stack.h create mode 100755 inc/stream.h create mode 100755 inc/stream.h% create mode 100755 inc/stream.h2 create mode 100755 inc/subrs.h create mode 100755 inc/sunerrno.h create mode 100755 inc/sunfilio.h create mode 100755 inc/sunioccom.h create mode 100755 inc/suntermios.h create mode 100755 inc/sunttold.h create mode 100755 inc/sunttycom.h create mode 100755 inc/sunttydev.h create mode 100755 inc/sysatms.h create mode 100755 inc/sysatms.h- create mode 100755 inc/timeout.h create mode 100755 inc/tos1defs.h create mode 100755 inc/tosfns.h create mode 100755 inc/tosret.h create mode 100755 inc/tty.h create mode 100755 inc/version.h create mode 100755 inc/vmemsave.h create mode 100755 inc/xbitmaps.h create mode 100755 inc/xdefs.h create mode 100644 include/README create mode 100644 include/ansidecl.h create mode 100644 include/dld.h create mode 100755 src/#ldeboot.c# create mode 100755 src/Cldeetr.c create mode 100755 src/allocmds.c create mode 100755 src/arith2.c create mode 100755 src/arith3.c create mode 100755 src/arith4.c create mode 100755 src/array.c create mode 100755 src/array2.c create mode 100755 src/array3.c create mode 100755 src/array4.c create mode 100755 src/array5.c create mode 100755 src/array6.c create mode 100755 src/asmbbt.c create mode 100755 src/asmbitblt.c create mode 100755 src/atom.c create mode 100755 src/bbt68k.s create mode 100755 src/bbtSPARC.s create mode 100755 src/bbtsub.c create mode 100755 src/bin.c create mode 100755 src/binds.c create mode 100755 src/bitblt.c create mode 100755 src/blt.c create mode 100755 src/box create mode 100755 src/byteswap.c create mode 100755 src/call-c.c create mode 100755 src/car-cdr.c create mode 100755 src/cdaudio.c create mode 100755 src/cdrom.c create mode 100755 src/chardev.c create mode 100755 src/chatter.c create mode 100755 src/codeconv.c create mode 100755 src/codetbl.c create mode 100755 src/colorbltfns.c create mode 100755 src/common.c create mode 100755 src/conspage.c create mode 100755 src/cr create mode 100755 src/dbgtool.c create mode 100755 src/dir.c create mode 100755 src/dlpi.c create mode 100755 src/doscomm.c create mode 100755 src/doskbd.c create mode 100755 src/dosmouse.c create mode 100755 src/draw.c create mode 100755 src/dsk.c create mode 100755 src/dsp386.il create mode 100755 src/dspSPARC.il create mode 100755 src/dsphack.lex create mode 100755 src/dspif.c create mode 100755 src/dspsubrs.c create mode 100755 src/ejlisp.c create mode 100755 src/eqf.c create mode 100755 src/ether.c create mode 100755 src/find-dsp.lex create mode 100755 src/findkey.c create mode 100755 src/foreign.c create mode 100755 src/fp.c create mode 100755 src/fvar.c create mode 100755 src/gc.c create mode 100755 src/gc2.c create mode 100755 src/gcarray.c create mode 100755 src/gccode.c create mode 100755 src/gcfinal.c create mode 100755 src/gchtfind.c create mode 100755 src/gcmain3.c create mode 100755 src/gcoflow.c create mode 100755 src/gcr.c create mode 100755 src/gcrcell.c create mode 100755 src/gcscan.c create mode 100755 src/gvar2.c create mode 100755 src/hacks.c create mode 100755 src/hardrtn.c create mode 100755 src/hasbcopy create mode 100755 src/id create mode 100755 src/imagefile.c create mode 100755 src/imagefile2.c create mode 100755 src/inet.c create mode 100755 src/initdsp.c create mode 100755 src/initkbd.c create mode 100755 src/initsout.c create mode 100755 src/intcall.c create mode 100755 src/kbdif.c create mode 100755 src/kbdsubrs.c create mode 100755 src/keyevent.c create mode 100755 src/keylib.c create mode 100755 src/keymaker.c create mode 100755 src/keytst.c create mode 100755 src/keytstno.c create mode 100755 src/kprint.c create mode 100755 src/launch.asm create mode 100755 src/ldeboot.c create mode 100755 src/ldeether.c create mode 100755 src/ldsout.c create mode 100755 src/lineblt8.c create mode 100755 src/lisp2c.c create mode 100755 src/llcolor.c create mode 100755 src/llstk.c create mode 100755 src/loader.c create mode 100755 src/loopsops.c create mode 100755 src/lowlev1.c create mode 100755 src/lowlev2.c create mode 100755 src/lpdual.c create mode 100755 src/lpkit.c create mode 100755 src/lplexyy.c create mode 100644 src/lplexyy.c.X create mode 100755 src/lpmain.c create mode 100755 src/lpread.c create mode 100755 src/lpsolve.c create mode 100755 src/lptran.c create mode 100755 src/lpwrite.c create mode 100755 src/lpytab.c create mode 100644 src/lpytab.c.X create mode 100755 src/lsthandl.c create mode 100755 src/main.c create mode 100755 src/misc7.c create mode 100755 src/miscn.c create mode 100755 src/mkatom.c create mode 100755 src/mkcell.c create mode 100755 src/mkkey.c create mode 100644 src/mkkey.c.X create mode 100755 src/mkvdate.c create mode 100755 src/mnwevent.c create mode 100755 src/mnxmeth.c create mode 100755 src/mouseif.c create mode 100755 src/mvs.c create mode 100755 src/ocr.c create mode 100644 src/ocr.c.X create mode 100755 src/ocrproc.c create mode 100644 src/ocrproc.c.X create mode 100755 src/oether.c create mode 100755 src/oldeether.c create mode 100755 src/optck.c create mode 100755 src/osmsg.c create mode 100755 src/perrno.c create mode 100755 src/picture.c create mode 100755 src/rawcolor.c create mode 100755 src/rawrs232c.c create mode 100755 src/return.c create mode 100755 src/rpc.c create mode 100755 src/rplcons.c create mode 100755 src/rs232c.c create mode 100755 src/setsout.c create mode 100755 src/shift.c create mode 100755 src/socdvr.c create mode 100755 src/socket.c create mode 100755 src/storage.c create mode 100755 src/subr.c create mode 100755 src/subr0374.c create mode 100755 src/sxhash.c create mode 100755 src/sysatms.c create mode 100644 src/sysatms.c.X create mode 100755 src/testdsp.c create mode 100755 src/testtool.c create mode 100755 src/timeoday.c create mode 100755 src/timeofday.c create mode 100755 src/timer.c create mode 100755 src/truecolor.c create mode 100755 src/tstsout.c create mode 100755 src/tty.c create mode 100755 src/typeof.c create mode 100755 src/ubf1.c create mode 100755 src/ubf2.c create mode 100755 src/ubf3.c create mode 100755 src/ufn.c create mode 100755 src/ufs.c create mode 100755 src/unixcomm.c create mode 100755 src/unixfork.c create mode 100755 src/unwind.c create mode 100755 src/uraid.c create mode 100755 src/usrsubr.c create mode 100755 src/uutils.c create mode 100755 src/vars3.c create mode 100755 src/vesafns.asm create mode 100755 src/vesainit.c create mode 100755 src/vgainit.c create mode 100755 src/vmemsave.c create mode 100755 src/xbbt.c create mode 100755 src/xc.c create mode 100755 src/xc.c.orig create mode 100755 src/xcursor.c create mode 100755 src/xinit.c create mode 100755 src/xlspwin.c create mode 100755 src/xmkicon.c create mode 100755 src/xrdopt.c create mode 100755 src/xscroll.c create mode 100755 src/xwinman.c create mode 100755 src/z2.c diff --git a/bin/ChangeLog b/bin/ChangeLog new file mode 100644 index 0000000..e95d735 --- /dev/null +++ b/bin/ChangeLog @@ -0,0 +1,69 @@ +1 Jan 02 JDS + + FILES CHANGED: src/byteswap.c bin/makefile-tail + + Fix MAKE rules for tstsout, setsout so they use the byteswapper if + necessary. Changed byteswap.c to only define byte_swap_code_page + if we're using reswapped code streams (which we aren't, as of + now), so we don't have to drag that all in or move the function to + someplace unrelated. + + +1 Jan 2002 JDS + + FILES CHANGED: bin/config.guess bin/config.sub bin/osversion, + bin/machinetype (new), bin/makeright, bin/README + + Update config.guess to GNU latest, and make osversion use it. Add + a new script, machinetype, also based on config.guess to determine + underlying hardware architecture for us. Changed makeright to use + machinetype. + + Added a README file, describing where to get new versions of the + config utilities. + +22 Nov 01 JDS + + FILES CHANGED: bin/makeright, bin/makefile-linux.386-x, osversion, + mach + + Revamped Linux make to use "makeright" script, as other systems + do. Need to revamp it all to use autoconf somehow. + +13 Dec 01 JDS + + FILES CHANGED: llstk.c, xlspwin.c, dspsubrs.c, xcursor.c + + The function Set_XCursor is called two ways: From the DSPCURSOR subr, + and within the C code directly. I had to fix the direct C calls + because Set_XCursor sets Current_Hot_X to 15-y (its second arg)-- + but the function was being called with Current_Hot_Y as the 2nd + arg. As a result (HARDRESET) followed by ^B would bollix the + cursor position and menu selection would be off. + + Fixed files llstk.c, xlspwin.c, dspsubrs.c to make it work. + + Added a warning comment to the function itself. + +20 Dec 01 JDS + + FILES CHANGED: xrdopt.c, main.c, lspwin.c, storage.c + + The X-emulator parser for command line options would NOT accept + the -m flag to set max memory size (it required -memory); changed + the -maxpages to -xpages (controlling # of pages written at once + in sysout writing), and changed the default sysout size from 8Mb + to 32Mb. + +22 Dec 01 JDS + + FILES CHANGED: main.c, mkvdate.c, version.h + + Changed Linux to using gettimeofday() from time(), so we get finer + grained timings. Changed mkvdate.c to include sys/time.h unless + USETIMEFN rather than unless SYSVONLY. + + Need to think about using autoconf to drive make process and get + away from the script-based maker. + + \ No newline at end of file diff --git a/bin/README b/bin/README new file mode 100644 index 0000000..57fd0e0 --- /dev/null +++ b/bin/README @@ -0,0 +1,8 @@ + +FILES USED IN THIS DIRECTORY + + config.guess + config.sub taken from GNU project's "config" directory, on + prep.ai.mit.edu/pub/gnu/config. Update 'em as + needed. + diff --git a/bin/checksum b/bin/checksum new file mode 100755 index 0000000..d37e42e --- /dev/null +++ b/bin/checksum @@ -0,0 +1,78 @@ +#! /bin/sh +# First line invokes Bourne shell +# ============================================================================ +# ABSTRACT: +# Bourne script for checking/generating checksums for files contained +# in a specific Medley release directory. Should normally be invoked +# by ldechecksum and expects the calling script to be connected to +# the medley installation directory. Also, expects the directory +# checksumdir to exist. "< W > ..." warning and "< E > ..." +# error messages will be issued. +# +# SYNOPSIS: +# checksum -cg dir +# +# -c generates a FOO.check file and compares it to FOO.sum. +# -g generates a FOO.sum file. +# NOTE: One of -c or -g is required. +# dir the name of the Medley release directory containing files +# for which checksum checking/generating will be performed. +# +# CHANGES: +# 05-05-89 Carl Gadener : added "trap" to delete created file if +# interrupted. Also "FOO.check" files are now +# deleted after being used. +# 12-14-88 Carl Gadener : Had to rewrite it for Bourne shell because +# the "foreach" loop in csh doesn't accept +# enough args. +# ============================================================================ +# +if test $# -lt 2 +then + echo "Usage: checksum -cg dir" + exit 2 + +else + case $1 in + -c) suffix="check" + operation="Verifying" + ;; + -g) suffix="sum" + operation="Generating checksum for" + ;; + *) echo "Usage: checksum -cg dir" + exit 2 ;; + esac +fi + +if test -d $2 +then + resultdir=`pwd`/checksumdir + resultfile=`echo "$2" | sed s/\\\//-/g` + + # If interrupted be sure to delete created file + trap "/bin/rm -f $resultdir/$resultfile.$suffix ; exit" 1 2 3 15 + + cd $2 + echo "$operation: $2" + echo "Checksum for directory: $2" > $resultdir/$resultfile.$suffix + echo "" >> $resultdir/$resultfile.$suffix + for file in `/bin/ls -FL | /bin/grep -v "/" ` + do + echo "E > `sum $file` $file" >> $resultdir/$resultfile.$suffix + done + + if test "$1" = "-c" # Verifying + then + /bin/diff $resultdir/$resultfile.sum \ + $resultdir/$resultfile.check | grep "<" + + # Remove check-file after check has been done + /bin/rm -f $resultdir/$resultfile.check + fi + +else + echo "< W > `pwd`/$2 : Directory not installed" +fi + + diff --git a/bin/checksum-readme b/bin/checksum-readme new file mode 100755 index 0000000..30d98d9 --- /dev/null +++ b/bin/checksum-readme @@ -0,0 +1,88 @@ +January 19, 1989 + +=========================================================================== +CHECKSUM CONTROL FOR FILES UNDER MEDLEY +=========================================================================== + +If you encounter inexplicable problems shortly after you install Medley, +they may be due to files being corrupted. We recommend that you verify the +checksums of your installed files. + +=========================================================================== +DESCRIPTION +=========================================================================== + +The script generates checksum files named FOO.check and compares them to +the released FOO.sum residing in the /checksumdir subdirectory. The +checksum script reports inconsistent files, the correct checksum values for +the files, and an error message. The checksum of individual files can be +verified with the UNIX command "sum filename". + +=========================================================================== +COMMANDS +=========================================================================== + +ldechecksum [-cg] medleydir [ dir | dirgroup ] + + -c Generates checksums for your installed files and compares + them with correct values. This is the default action. + + -g Generates checksums for the files specified. + + medleydir Name of the Medley installation directory. Usually its + /usr/local/lde. + + dir Any specific directory residing under medleydir. Only + relative pathnames with respect to medleydir are accepted. + + dirgroup The directory group, either all (the default) or lisp, + which includes the X/install.sunos3, X/install.sunos4, + X/lisplibrary and X/lispsysouts directories. + +=========================================================================== +OUTPUT +=========================================================================== + + As it begins checking each directory, the script prints a message + in the form: + + Checking directory: /usr/local/lde/subdir + + + Error and warning messages may be one of two forms: + + < E > 32711 49 4045XLPSTREAM.DFASL + + indicates that file 4045XLPSTREAM.DFASL is erroneous or does not + reside in the directory. The correct checksum of 32711, together + with the size (49kbytes) of the file, are shown. + + < W > /usr/local/lde/fonts/display/chinese : Directory not installed + + indicates that Chinese fonts were not installed or were removed + after Medley was installed. + +=========================================================================== +EXAMPLES: +=========================================================================== + + prompt% ldechecksum /usr/local/lde + + All files in the installed Medley directories in /usr/local/lde are + checked. + + prompt% ldechecksum /usr/local/somedir/lde lisp + + This example checks all files in: + /usr/local/somedir/lde/install.sunos3 + /usr/local/somedir/lde/install.sunos4 + /usr/local/somedir/lde/lisplibrary + /usr/local/somedir/lde/lispsysouts + + + prompt% cd /usr/local/lde + prompt% ldechecksum -c . fonts/display + + This example checks only the display font directories. The period + (.) is used because you are positioned under the current Medley + installation directory. diff --git a/bin/checksum-readme-internal b/bin/checksum-readme-internal new file mode 100755 index 0000000..671250b --- /dev/null +++ b/bin/checksum-readme-internal @@ -0,0 +1,67 @@ +January 19, 1989 + +====================================================================== +HOW TO GENERATE CHECKSUMFILES FOR MEDLEY +====================================================================== + +=========================================================================== +COMMANDS +=========================================================================== + +ldechecksum [-cg] medleydir [ dir | dirgroup ] + + -c Generates checksums for your installed files and compares + them with correct values. This is the default action. + + -g Generates checksums for the files specified. + + medleydir Name of the Medley installation directory. Usually its + /usr/local/lde. + + dir Any specific directory residing under medleydir. Only + relative pathnames with respect to medleydir are accepted. + + dirgroup The directory group, either all (the default) or lisp, + which includes the X/install.sunos3, X/install.sunos4, + X/lisplibrary and X/lispsysouts directories. + +=========================================================================== +REQUIREMENTS +=========================================================================== + +Before generating checksumfiles, make sure that the subdirectory +"checksumdir" resides under the local Medley directory (normally +/usr/local/lde/checksumdir). + +Make also sure that a copy of the scripts "ldechecksum" and "checksum" +reside under the subdirectory "checksumdir". + +NOTE: Don't forget to give the "-g" parameter to generate the + checksumfiles. + +====================================================================== +EXAMPLES +====================================================================== + prompt% ldechecksum -g /usr/local/lde + + All checksumfiles for the Medley directories residing in + /usr/local/lde will be generated + + + prompt% ldechecksum /usr/local/somedir/lde lisp + + This example generates checksumfiles for all files in: + /usr/local/somedir/lde/install.sunos3 + /usr/local/somedir/lde/install.sunos4 + /usr/local/somedir/lde/lisplibrary + /usr/local/somedir/lde/lispsysouts + + + prompt% cd /usr/local/lde + prompt% ldechecksum -c . fonts/display + + This example only generates checksumfiles for the display font + directories. The period (.) is used because you are positioned + under the current Medley installation directory. + + diff --git a/bin/compile-flags b/bin/compile-flags new file mode 100755 index 0000000..eb8fb71 --- /dev/null +++ b/bin/compile-flags @@ -0,0 +1,182 @@ + + Medley compile flags & their meanings + + Created: 28-Sep-89 JDS + Updated: + +** Flags that control compilation for various machine +** architectures, manufacturers, and OS versions + +Flag Name Meaning/Usage +_________ ________________________________________________________ +BYTESWAP Used when compiling for a hardware architecture that has + byte-swapped words and word-swapped 32-bit cells, e.g. 80386. +SYSVSIGNALS True when compiling on a system that requires the use of + SYSV (rather than BSD) signal-handling code (just MIPS & ISC + for 486, now). +SYSVONLY True when compiling on a system that has little or no + BSD support (the ISC unix for 486, or MIPS). E.g. gettimofday + is missing. +I386 True if compiling for the Sun386i (not just any 80386); + used because the 386i's display controller is odd. +OS4 True if compiling for SunOS 4.x +AIX +NOPIXRECT Used to suppress pixrect/pixwin options when they're not + needed or not available. True if XWINDOW is. + +AIX True if compiling for AIX +_I386 True if compiling for PS/2 under AIX (not our flag) +AIXPS2 True if compiling for PS/2 under AIX (our flag) +APOLLO True if compiling for the Apollo +sparc True if we're compiling on a SPARC machine. +mc68020 True if we're compiling on a Motorola 680x0 machine. +sun3 We're compiling for a Sun-3. +HP9000 We're compiling on an HP9000 RISC machine. +HPUX We're compiling for HP-UX +RS6000 We're compiling for the RS/6000 processor. +DEC3100 We're compiling for the DECStation 3100. +RISCOS We're compiling for the MIPS RISCstation under RISCOS. + +UNSAFE If true, enables the "fast" version of 68020 opcodes. +NOASM If true, suppress any attempt to include assembler + versions of things in the emulator. In 'lispemul.c', + if this is true, disables: + SUN3_OS3_IL + SUN3_OS4_IL + SUN4_OS4_IL + OPDISP + NATIVETRAN + UNSAFE + PROFILE + and enables NOASMFNCALL +C_ONLY +SUN4_OS4_IL Try assembler peephole optimizations for SPARC & SunOS4.x +SUN3_OS3_IL Try assembler peephole optimizations for 68K & SunOS 3.x +SUN3_OS4_IL Try assembler peephole optimizations for 68K & SunOS 4.x +SUN3_OS3_OR_OS4_IL Try asm optimizations for 68K & either sunOS. This is + turned on whenever either of SUN3_OS3_IL or SUN3_OS4_IL is on. + +OPDISP Use "fast-opcode-dispatch" macros +SPARCDISP Use fast-opcode-dispatch macros on SPARC +HPTIMERBUG True if we must compile in the patch around the HPUX + timer-resetting bug for Series 700. + + + + +--Debugging/Tracing/Check-enabling flags-- + +DEBUG Used when debugging, to enclose trace and dump code. + Best usage is with DBPRINT((controlString, args*));, which + calls printf, and compiles only if DEBUG is true. See + dbprint.h for the definition. +TRACE +TRACE2 +TRASE +OPTRACE If true, the dispatch loop prints the PC & opcode each time thru +FNTRACE If true, you see the name of each function called. +STACKCHECK If true, you see unusual cases of stack manipulation + traced. E.g., the hard cases of RETURN, like non-contiguous + stack frames, get mentioned. +LISPTRACE True if you want to see LISP calls & returns traced to + stdout; Generally, for traces of lisp-level events. +PROFILE If true, the profiling control code is enabled. You must + also change the optflags to contain -p or -pg, to use prof + or gprof, respectively. +CHECK +FSBCHECK If true, you see a trace of large free stack blocks when + the stack is manipulated; was used for debugging stack code. +FSMESSAGE If true, prints a message telling you about the hard links + it makes (in support of version numbering), as it makes them. + +WINDOW +INIT Used when compiling an emulator to build a loadup. Use it + to dike out code that deals with network initialization, e.g. + +MYOPTRACE Used to check the stack's validity on each opcode execution. + Requires NOASM, and the absence of SUN..._IL and SPARCDISP &c. + +PCTRACE When true, compiles in a 100-long ring buffer that holds the + last 100 PCs, Function-blocks, and Opcodes executed. "pccounter" + is the offset where the next one will go. Also requires NOASM. + The 3 tables are called pc_table, fn_table, and op_table. + + + + +--Flags that control new features, features under test, etc.-- + +DISPLAYBUFFER 10/3/89 JDS -- enables the experimental code for copying + changed portions of the display bank to the frame buffer. + Meant for supporting mono mode on a CG6 with no single-bit + bitplane. 1/22/91 JDS: This is now the standard flag for + compiling for color displays. +FSERROR Enables the emulator's returning Unix error codes for + {DSK} & {UNIX} operations, so Lisp can decode them and + give better indication of problems. FEATURE STANDARD IN 1.1 +WINDOW +FLIPCURSOR If true, the "sandbar" line in the cursor will get flipped + by the C stack-frame-moving code, just as it does on a D + machine. Otherwise, you don't see it. +ORG_FILPCORSORBAR If true, you get the pixwin version of cursor changing; + otherwise, it gets done by direct writes into the display + region. +OLD_CURSOR If true, uses the pixwin cursor code (e.g., win_setcursor); + otherwise, uses the direct-write technique. +NATIVETRAN If true, code to support the native-code translator is + included in the emulator. This feature was never released, + and most such code is probably obsolete. +OS4_TYPE4BUG If true, includes the patches around SunOS 4.0.x's failure + to tell you you've got a Type-4 keyboard. +ALLDIRSEARCH CURRENTLY HARD DISABLED IN directory.c; looks like it + controlled recursive directory searches?? +KBINT If true (it looks like??), the emulator does most of the KBD + transition processing in C, rather than interrupting LISP for + it, and the transition interrupts happen when the OS signals + a transition, rather than by polling? +RS232INT If true, the RS232 device (NOT USED, a translation of Lisp's + code), uses the interrupt signalling support of timer.c to + know when to read characters. NOT USED, probably obsolete. +TTYINT Analogous to RS232INT, for the translated TTY device. +ETHERINT +COLOR If TRUE, supports 8bits-per-pixel color on CG4 and CG6 frame + buffer of Sun work station. IF COLOR is TRUE, don't use OLD_CURSOR + flag. +CATCH If true, includes some CATCH C code, for finding the blip, + finding variable names and PVAR names in frames. As of 10/2/89 + this code is unused, and is called nowhere else in the system. +RECLAIMINC If true, then the RECLAIMCELL opcode calls gcreclaimcell in + C; otherwise it punts. As of 10/3/89, this was never debugged + and is not in any system. Probably fairly easy to debug?? +KB_SUN4 The kbd type for the Type-4 keyboard. Defined only because + older OS versions of the compiler don't define it automatically. +FUJI If true, and you don't set the LDEKBDTYPE environment variable, + you'll get a nasty message asking you to set it before + running lisp. Otherwise, you'll default to a type-3 kbd. +FLTINT If true, use the floating-point exception interrupts to detect + errors and overflows on FP operations. The interrupt sets a + global error flag. Otherwise, calls library routines to see + the condition code from each operation. For SPARCs, it's not + clear that the interrupt trick works, because of code re- + arrangement by the C compiler. +BUFFER Used (apparently) only in testdisplay.c to decide if it should + read the sysout directly, or buffer each page. + +IFPAGE_DEFINED Used in .h files to prevent redefinition of Interface page. +IOPAGE_DEFINED " for IO page definition. +NOWAY Used to dike out C definitions of RPLACA and RPLACD in the + file car-cdrmacro.h +XWINDOW True if compiling for an X-windows emulator. + +BIGATOMS True if this emulator will support 3-byte symbols, instead of + the old, 2-byte atom numbers. + +NEWBITBLT True if we want to use assembler BITBLT code, rather than + have code created inline by macro calls. + +bitbltsub.c:#ifdef GETBASE +testdisplay.c:#ifdef NOTUSED +uraid.c:#ifdef ETHERINT +bitblt.c:#ifndef COLOR +bitbltsub.c:#ifndef prropstyle +lispmap.h:#ifdef MEDLEY diff --git a/bin/config.guess b/bin/config.guess new file mode 100755 index 0000000..83e7b84 --- /dev/null +++ b/bin/config.guess @@ -0,0 +1,1313 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-12-13' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c ; + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $dummy.c $dummy.o $dummy.rel ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + UNAME_MACHINE_ARCH=`(uname -p) 2>/dev/null` || \ + UNAME_MACHINE_ARCH=unknown + case "${UNAME_MACHINE_ARCH}" in + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:3*) + echo i386-pc-interix3 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + rm -f $dummy.c + test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_targets=`cd /; ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + LIBC=gnuaout + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + rm -f $dummy.c + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/bin/config.sub b/bin/config.sub new file mode 100644 index 0000000..59148c7 --- /dev/null +++ b/bin/config.sub @@ -0,0 +1,1434 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-12-10' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dsp16xx \ + | fr30 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el | mips64vr4300 \ + | mips64vr4300el | mips64vr5000 | mips64vr5000el \ + | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ + | mipsisa32 \ + | mn10200 | mn10300 \ + | ns16k | ns32k \ + | openrisc \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[34] | sh[34]eb | shbe | shle \ + | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alphapca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c54x-* \ + | clipper-* | cray2-* | cydra-* \ + | d10v-* | d30v-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | m32r-* \ + | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ + | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ + | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ + | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [cjt]90) + basic_machine=${basic_machine}-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + windows32) + basic_machine=i386-pc + os=-windows32-msvcrt + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh3eb | sh4eb) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/bin/copyright b/bin/copyright new file mode 100755 index 0000000..1b61738 --- /dev/null +++ b/bin/copyright @@ -0,0 +1,14 @@ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ diff --git a/bin/dbxinit.txt b/bin/dbxinit.txt new file mode 100755 index 0000000..5fb5a16 --- /dev/null +++ b/bin/dbxinit.txt @@ -0,0 +1,62 @@ +alias a alias +a t trace +a d delete +a r run +a c cont +a q quit +a h help +a p print +a l list +a s step +a go "run /python/local/sysouts/LISP.SYSOUT -NF" +a dbx "stop in OP_dbx" +a gc "set *(LispPTR *)(Valspace + 2*1772) = 0114" +a engc "set *(LispPTR *)(Valspace + 2*1772) = 0" +a st status +a csf "call sf(MachineState.pvar-10)" +a bt "call bt()" +a btvv "call btvv()" +a n next +a tos "call print(MachineState.tosvalue)" +a Ctos "call print(tscache)" +a csp "call print(*((LispPTR *)(MachineState.csp)))" +a Csp "call print(*((LispPTR *)(cspcache)))" +a do "call doko()" +a ppc "print ((int)(MachineState.currentpc) - (int)(MachineState.currentfunc))" +a sf "call sf(fx)" +a fn "stop in OP_fn" +a ret "stop in OP_return" +a err "stop in error" +a warn "stop in warn" +a ifp "print *InterfacePage" +a iop "print *IOPage" +a pro "print *(PROCESS *)(\!:1)" +a oct "call printf(\"%o\n\" , (\!:1)" +a eve "print *(EVENT *)(\!:1)" +a dev "print *(FDEV *)(\!:1)" +a pac "print *(PACKAGE *)(\!:1)" +a str "print *(Stream *)(\!:1)" +a pque "print *(PROCESSQUEUE *)(\!:1)" +a name "call print_atomname((\!:1))" +a stk "call all_stack_dump((\!:1) , (\!:2) ,(\!:3))" +a astk "call all_stack_dump(0 , 0 , 0)" +a sastk "call all_stack_dump(0 , 0 , 1)" +a type "call type_num(\!:1)" +a dtd "call dtd_chain(\!:1)" +a btvv "call btvv()" +a satom "call S_MAKEATOM(\!:1)" +a a68k "call a68k(\!:1)" +a la "call laddr(\!:1)" +a sval "call S_TOPVAL(\!:1)" +a atom "print MAKEATOM(\!:1)" +a val "call GETTOPVAL(\!:1)" +a sff "call sff((\!:1))" +a stopop "stop in \!:1 if ((struct fnhead *)(MachineState.currentfunc))->framename == \!:2" +a stopfunc "stop if ((struct fnhead *)(MachineState.currentfunc))->framename == \!:1" +a stoppc "stop in \!:1 if (((struct fnhead *)(MachineState.currentfunc))->framename == \!:2 && ((int)(MachineState.currentpc) - (int )(MachineState.currentfunc) > \!:3)) " +a sop "stop in \!:1" +a sc "call stack_check(0)" + +use . /python0/users/maiko/working/src /python0/users/maiko/working/inc +ignore VTALRM +ignore IO diff --git a/bin/dir.o b/bin/dir.o new file mode 100644 index 0000000000000000000000000000000000000000..12adb077d84179a5fba3488645eb7f4a4e99280f GIT binary patch literal 18408 zcmeHO4|r6?wV&N=$P$($2m&hVVu=OBkbqPIRDrOdEsH2dtbQ>K$%X{UACp~yY9#5h z!sT|`*kYfxrIl*!YwNS%(>9{CDNuqfkJ3t&7PP5SyX%d8RCzINBl~{8xpOzWOOhhI z_S5fmzi;<<&zv)7&YU@OX70VS>phDX+H5vqeQY94^ie|0oNjWik}y%Y#86SJ{UO-p zTz<H)Kh9X8bvGA^>@DpDM>p-!N_urqZ}i`wAbhuI zZJssRZ#NwCjc#0uKt>x|Gw#)1+H9L?_d8K9kYU(bjUih1Ji};}bV0juJL;mLA4}X1c>qg&hSym++LR96a2@&aqKya^9Yu9#b=hFwFUj@c&bnm!7Y{#E`iF^-~+#qS8RjGtBRRnC5!9hK6o zF$VQJ(pkriujxqkJ?!hb{SI~q*K({Jw=63-S}2WMV>jGk$1AL4b|5&%E&@ZfBhe>O zq;(e=FSp8eg6%m=Qw%BYMdwE+S?$2jaenb^;kuC-1f5SFG-C@5`>YtcQ< z_%#O9b0XMuLIj2fKTc7H-)Y#jZpMxAlGeS-8hVEm8hd)Lqq#$bXiYIx_nhc!Vo#rv zg6@J?ho_efg^mWYtR~Z=?dVzPX!eHnz^d!O4i{xw8W44%cK`UQPxM!u8JrE;Pm4NhL zAf4QZYgJxyfl~`@dN&r+l$CTpKfnB2M4MU_^>Q&*Bjr|W8k zf`N3A7uTgUS;l$(rlvBSItM(8TCGn?;JI~A4*ep{%1K~k7$aovV4Oq`Vmia;=12d2B|T(ic^1;&FY%gq4mHU=>;((x3y}lEs4kcG6vIY*m5i83u2*IV5xQ@ z*d{YWAl(>-_Vi{_#+xepw35=ysg)3V{Y2{;(_Za|tied(Y^d@wv_jj_Ny}?F$#W*` z*$!Wr0;{h;UX!`db28X;GS(NzeL2@Sm^^nNb*t$kyZ;8Q$Lfs3$V4odeKC^yV!Cng zzI=~eu;M+@c&F}Z%N28lsKgk5y0T+q4kT?UJ#?u4gcmuiPCKnGn(5x5d3v;-G*3@> zsbio08g-ez&n~#sRBB&vVDOBal>Sr?TKcVlgtC5G?9(rFPfw+`kvh#8oYbS!En8(n z)N;gw68(SJ_YPDS&PYZ1o@(Hd;(75Am5x9Ufio4Vy*~(>t0x`wit+8tjR51 z{(tIPbt6`Yb6%^uu&?1-^*!#6&UUS;MdkS1{Xnc$eGz!tT1A#zt9WrHYgMYQgth84 zU4yMvUpYDOT7}GOZb^~jlGdt<1V++Y^;b+<`20h&Ry}IkdoF8L`-Bh3TJ-b#{5(fmQKL@_O^>dA;iW=k?gx--En>Yhqo!2Ag{!;B= z67NCG+l)sNZ!>r&A-Db5mL!PEJBh>s+(|qH7whsD*?H)`&~|wz;nu@s$lS~e=4Nu@ z3%$H2No+Dj6Yoh-Pu)kHri;9|F4#&w4@^jD46E6LL;9|PTn>q<;Y;y1ip*$ICZDyjp&{T9yIRj z@EqsEkq*x>6FLdHH&PjVme0h5|1uDo_c(raO+G|4tL}?=j>SBk(R>Jj7krjHk-gz_ ztnP`V%g0Bo)Ix?yS`SzFxH?dos<8v=`ZW0`pOF@ad=5Vvd+-GNpvZUz_fkeW%9|p= zAIWD{*`b>ec7=gR_J#~xsHg1OJLX#!J;)I$yq~{;OfVrLjNz??C6Pdyk=|+?(YpD} zCa^-654q+pty%_&u&2w~{<(M^UYPK#uZaj+lzI-@mGm6ce5UKA%3#xR;m^{&$2B<`h7&%(aBDLMYHOa>UA5dCuwZ+i z;SjG3w$NJp05viAy7!po?KGyN4fxbQEZ#9=Xq-Dh?NE0>KG%(Ic`p`|Hg>A_G=~!3 zul+;f^$mt2k2jMp`|ILmm=4n58RKBt(4zszZ@$-o5JA!judi@rzogS>Z; z&+6k*p#_jljwff6=og`@uqood!hAClZ%H*QUza2`Yz%9C|MMhngPbbE`lbq=#A2Rk zO~>^wBqllI+H;*B>(u;Mu79112X*BU>#c{~aH_ffR?=L*m>!S!!Eix$oT67hpJ+Q~ z8T3Ru@v365IW{F_P4FB}SQL)1LA5p@lU4?QY%U5HupddwL9_vzS+;|G`(v5D-q%{t z6wzfZ4HsCLJcnh!tZC|>)VCNwKn6oUONz|Xr>zCYj32-*!ztGSt?6*9_D+YVlO01R z3co^I@y?9z{q-Ohib9Vokgk<t}*wcEryL$Z*erse03KO-8tUuZFDvs?O|NWd^oYy*uPObDVZ0ju!R;NAQXVD^PSb z9M~FPaPOcyx!^wacM{l8Yr%EJ*W2Hi>uq*uH0tV2hgAy0=wyc;g}eB)=i8StGteKUi-S!roBs~|N9+P7rfemfor>=;uqQzbVJG8!|G8KX zM2xwu{pMF@8u^~n+JB(U{sRt4&Wzb;3AV-biRYNwOYBeHOE{S40#3ce6?SYz=i)Cn z@e-E@kFX^jxsBy2gCd@q?`|uXSv|RCYN54vs@ptG_viKc~6elr5>6=n=6*BaxBLS@EcWck#~ADZ*MSW zTd(r0w^z66__@)c$%6?&Pp{(!<5d>fI^@fKIS}3+-KGsm(Bw!wyOeYmtEKDKEFpLz z3m?@kHr?>Cc@C*VRDc18WQ*uqJdeZf7rEF~+adEfmTiwF*H?1VQW#tJ{uxh09^~)l z`9tOu;r!YHzuTCPu?tDoQm6LdF>pIVo%p2@#qT%gD158X?SmphNXuJ zUZ~VR;RuhjX5`K_%_BnFQCGvf>KZ<8oM0lKC+u8d#HJa~^o1hP9q zhgIK=;qakJQtK)k4~g`=bDF_9@*X|YjH%}lEqoIbffBsk=uv>@3#3?CSv^YDa+$U6 zM=h-3W=LmmSj6}V^{|rVDy-yA3{qFvh zo2JQ8$?P*TxJx?OUl0!Mhf266VnU+7BKN+`gbDYWbJ>^*I|r@s?kmX^K7%;ur^8n3 zQwLS{+1HbmUD-OQ_@j{|ag~QKWG#-#(@7qtHK-q%?e2D%6p4jtthx6D6^ut?=oFR zN4$+Oh)?q{noOR?1vqD;nvZlPX^Zq6Mp}UCLm0QNw zeVkUZUk~gLj|xbu4yhF>Wuf}H)ym0&_V99t?mb!1U8(<&&$_fgq|g&tZ#TwiKM%f> zrj;DueBq{&*Eg5Et_O~9x`gY}i@Yc45rJBsPLmr{ZFkFSa_D~LpLbee%U|UPjw(1> zseeN@QF5%=`)amFNJ$vSXMkaf_$w(zRcToO7%KOJcH9_-Ig2U7e*Ir!;- z+OM`H?s5AKa&wPw207NrXW*FDg!slE6>OY~*_eD;JU@tn!j?aB?ir&<*utYcbmlhx z=yP&Hv3t#vi`NzQG~oXV-2a9h?~!YTv_4(#+=q7*VNn(W64*C(V7bGi6|<=C)^FhR zu5z-qEk>om_Vc$ai=QKwo7?1lJe$PFX@dO!Mt(tFegWtS*H_GPS5!CTl~1|bU641; zT~Jt9I5oduYW{S0{<<6ESluL z#aA2fi9C^)CvqF7<~EAixfNn|fmmGKSij8QP+hxnv9ETeziO6yNuA$a<}R-)YbY!C z`x@M34Gm@M@-h=7Z>}pcs|+l>VA&@{@sjIr6_W+^EvqS8y}I6AQRXibVo_1iEce7k zONuACeJjfwubh@wn4dST&|Nq)e@4L!_e5EUj^|BxH~3cj${Kx>gve`LSK}{R0rWSR zSY=)LeQW(952AVIm25@Q=GBVEMv+%r=STM&>dd0@x|$katzUWi@54n9!L$+BzRM5) zNAmy&Mtx-H;Cej1L#;w!{cL<)LS*8a^(n{k#Sv^t%P_$=;SZ}zwB=gzVu0=zOjYSXBi8gr4N@$ zpTu&9__Ms>umqC-F-84}Es#!6@?B~xY2c1l%4jG5gN0YRq6)r40K=Dwty7;BO=hJu zjNm2arT8uIJjhQ0^3~seDf()l^`RfG!Iy3EJ3_o2V*;{1AOHb z0W<#qWc&94tqbQ2_Mpb%TnZT13hP)5GxRRUe z&=2KeRa5j1&<8+2tmx-b>i-0E)#XA=L6Ts5zewS~ltTY5g?=-IK9NG7N}-3r57vkN zz9@yx1-<1;^dCrjrl;_)1$}S65O1O``AbvyLav!&WqJ9uQsn&l>earAJW*XC8vSK{ zQB&qGuPUuC^JAH-71g!X{?f|o+R8dnj@7EJTr6zx`4+MOi=LhT1w|{z}$7 zu8zVx@79IaFIjklSm{$bO3_Fq>I>WjgNI#`)XBDr7SA**HzQH`ZWPqW*KE(1S%U%>r5T8LMaO4T!9Tjjq(l6 zgYWuEN~^HR@WDX|MV7Jk4K&|Z+E~}%FI^F+gv+I8>5obb20I$4tzH`^SSY2%U92OD zZt#|_^wmm!qgYi_PbHuAGbwF77$Bg8J^SRsC?_{!Nu< zAuqAsC?M;(iO6SD6up3a=>HTEYXtL{{X+C#(d!ib7!jMQ!wUI8%#OTwA@O1%iizM? zDteouvyeyW*D(q&QhHxXga9ST>H5B+tdp+7)Gy)7(9f1V|}k%JX|lsF#aiF|9n zOo)j@(AN;ze}w^6-b#d@_Nej*@gqV^#io+>&H&QB1;h!ki{)s)QI$VTg#M?A(El67 ze~pOx5tgI=Ng_8dSnEiiPei|#0I6>|5%ML9Urj{(G%5ayg}9FHs@<7b?ra}~Xm2>Y8AK0}0G_7M?3Hf$EjKaU97tLU9Tj@KTA z2NfP8AMw+paF`1;;%6F=^4BO_#B%uI2GZzPF%kBzA;R7u`G_B#H2V1fY51>=G~|Av z=vNheiU|FgXqz|^Nc|U)hW_zH)SJt4^v6d;{H#^y0Nu zZVnNCs#E1#h=`vZK(@1!$njx0>^?x`_$c}T(&MZc%$iI8FcW-DAqME@#?827EJ z{7FSe6@3eGCjDKiaFxQfK*qrqh2JJ34h|~*Zxz1Ia`?d@4O{+9gzk~ZwY2wAAmiYp zq|whSNu!@PlZM=#ivEnEA11<{#}$5`eCYonY3ScYM7?7yM}KW2frx`qM9?20VtmVp zA4R@Z^! zI`T2zYe+*!6KQ-OBMrId6#X+rze$AtZiO-Op+5t@r2gSV)SCjN{WlUZ-W7^&Bx1aG z5Ha5EihfD)PbnM@A5$(DNPT%k*mo7n(dJwtzKa!IMuZ(B;CuRixx(K8+0O`R^s|RJ z8TXE`jrwl`vOkpyzeR-n4)P)Q6O0k{WnhemUjmZ@ z{5YOJ5uxv0B64az#)5j+6H)$Ug%`sH>c0#~{a+#t{&y96U>o_L0FoahjrKQ@M*CkT ooeg<~PZH7oD@5pt648EI0TAuaCuU)vrEo3Kel7AOK5XZI0lE`Q9smFU literal 0 HcmV?d00001 diff --git a/bin/dosmkfil b/bin/dosmkfil new file mode 100755 index 0000000..9d28e7d --- /dev/null +++ b/bin/dosmkfil @@ -0,0 +1,631 @@ +AFLAGS = /T +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj + + +ADMINFILES = makefile mkvdate.c optck.c + +LPFILES = lpmain.obj lpread.obj lpsolve.obj lpwrite.obj lpdual.obj lptran.obj + +KEY = keytstno.obj + +CFLAGS = -DBIGATOMS -DNEW_STORAGE -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT \ + -DNOFORN -DNOETHER -DNOVERSION -DLPSOLVE -g + +LDFLAGS = -g graphics.lib binmode.lib mouse.lib + +RM = del + +SRCFILES = conspage.c gcoflow.c shift.c dbgtool.c gcr.c gcrcell.c llstk.c gcscan.c loopsops.c storage.c allocmds.c dir.c gvar2.c lowlev1.c subr.c arith2.c hacks.c lowlev2.c subr0374.c arith3.c doscomm.c hardrtn.c lsthandl.c sxhash.c arith4.c draw.c main.c testtool.c array.c dsk.c inet.c misc7.c timer.c array2.c dspif.c initdsp.c miscn.c typeof.c array3.c initkbd.c ubf1.c array4.c dspsubrs.c initsout.c mkatom.c ubf2.c array5.c eqf.c intcall.c mkcell.c ubf3.c array6.c ether.c mkvdate.c ufn.c atom.c findkey.c kbdsubrs.c mouseif.c ufs.c bbtsub.c foreign.c keyevent.c unixcomm.c bin.c fp.c keylib.c binds.c asmbbt.c fvar.c mvs.c unwind.c bitblt.c gc.c uraid.c blt.c gc2.c kprint.c keytstno.c keytst.c osmsg.c usrsubr.c byteswap.c gcarray.c perrno.c ldeboot.c ldeether.c uutils.c carcdr.c gccode.c rawcolor.c vars3.c gcfinal.c ldsout.c return.c vmemsave.c chardev.c gchtfind.c lineblt8.c rpc.c xc.c common.c gcmain3.c lisp2c.c rplcons.c z2.c find-dsp.l dsphack.l xmkicon.c xbbt.c xinit.c xscroll.c xcursor.c xlspwin.c xrdopt.c xwinman.c dosmouse.c vesafns.asm vesainit.c vgainit.c kbdif.c dspsparc.il copyright launch.asm lpread.c lpsolve.c lpmain.c lpwrite.c lpdual.c lptran.c + +OFILES = conspage.obj gcoflow.obj shift.obj dbgtool.obj gcr.obj gcrcell.obj llstk.obj gcscan.obj loopsops.obj storage.obj allocmds.obj dir.obj gvar2.obj lowlev1.obj subr.obj arith2.obj hacks.obj lowlev2.obj subr0374.obj arith3.obj doscomm.obj hardrtn.obj lsthandl.obj sxhash.obj arith4.obj draw.obj main.obj testtool.obj array.obj dsk.obj inet.obj misc7.obj timer.obj array2.obj dspif.obj initdsp.obj miscn.obj typeof.obj array3.obj initkbd.obj ubf1.obj array4.obj dspsubrs.obj initsout.obj mkatom.obj ubf2.obj array5.obj eqf.obj intcall.obj mkcell.obj ubf3.obj array6.obj ether.obj ufn.obj atom.obj findkey.obj kbdsubrs.obj mouseif.obj ufs.obj bbtsub.obj foreign.obj keyevent.obj unixcomm.obj bin.obj fp.obj keylib.obj binds.obj fvar.obj mvs.obj unwind.obj bitblt.obj gc.obj uraid.obj blt.obj gc2.obj kprint.obj osmsg.obj usrsubr.obj byteswap.obj gcarray.obj perrno.obj uutils.obj carcdr.obj asmbbt.obj gccode.obj vars3.obj gcfinal.obj ldsout.obj return.obj vmemsave.obj chardev.obj gchtfind.obj lineblt8.obj rpc.obj xc.obj common.obj gcmain3.obj lisp2c.obj rplcons.obj z2.obj vdate.obj $(KEY) $(COLORFILES) $(ARCHFILES) $(LPFILES) + + +HFILES = address.h adr68k.h arith.h cell.h dbprint.h display.h dspif.h ifpage.h iopage.h lispemul.h lispmap.h lsptypes.h miscstat.h lspglob.h array.h bb.h bitblt.h debug.h devconf.h dspdata.h ether.h fast_dsp.h fp.h gc.h hdw_conf.h initatms.h inlinec.h keyboard.h lispver1.h lispver2.h lldsp.h locfile.h mouseif.h my.h opcodes.h osmsg.h pilotbbt.h print.h profile.h return.h stack.h stream.h subrs.h sysatms.h timeout.h tos1defs.h tosfns.h tosret.h vmemsave.h xdefs.h xbitmaps.h xkeymap.h + + + +bigvm: + CFLAGS = $(CFLAGS) -DBIGVM -DNEWCDRCODRING + make -f foot emul.exe + +emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(RM) vdate.c + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +main.o : lispemul.h address.h lsptypes.h adr68k.h stack.h lspglob.h lispmap.h ifpage.h iopage.h return.h debug.h profile.h + + + + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +medley.exe: launch.obj + TLINK launch,medley + +launch.obj: launch.asm + + # xc.obj: xc.s + # tasm /ml xc.s + # + #xc.s: xc.c + # rsh sparky (cd /users/nilsson/curr ; gcc-make $* ) + +vdate.obj : mkvdate.exe + mkvdate > vdate.c + $(CC) vdate.c -c $@ + +mkvdate.exe : ../src/mkvdate.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mkvdate.c + del copts + +xc.obj : ../src/xc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/xc.c -I ../inc -c $@ + del copts + +lpmain.obj : ../src/lpmain.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpmain.c -I ../inc -c $@ + del copts + +lpsolve.obj : ../src/lpsolve.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpsolve.c -I ../inc -c $@ + del copts + +lpread.obj : ../src/lpread.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpread.c -I ../inc -c $@ + del copts + +lptran.obj : ../src/lptran.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lptran.c -I ../inc -c $@ + del copts + +lpdual.obj : ../src/lpdual.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpdual.c -I ../inc -c $@ + del copts + +lpwrite.obj : ../src/lpwrite.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpwrite.c -I ../inc -c $@ + del copts + + + +conspage.obj : ../src/conspage.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/conspage.c -I ../inc -c $@ + del copts + +keytstno.obj : ../src/keytstno.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/keytstno.c -I ../inc -c $@ + del copts + +dosmouse.obj : ../src/dosmouse.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dosmouse.c -I ../inc -c $@ + del copts + +doskbd.obj : ../src/doskbd.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/doskbd.c -I ../inc -c $@ + del copts + +vesafns.obj : ../src/vesafns.asm + tasm /ml ..\src\vesafns.asm + +vesainit.obj : ../src/vesainit.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vesainit.c -I ../inc -c $@ + del copts + +vgainit.obj : ../src/vgainit.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vgainit.c -I ../inc -c $@ + del copts + +kbdif.obj : ../src/kbdif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/kbdif.c -I ../inc -c $@ + del copts + +gcoflow.obj : ../src/gcoflow.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcoflow.c -I ../inc -c $@ + del copts + +shift.obj : ../src/shift.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/shift.c -I ../inc -c $@ + del copts + +dbgtool.obj : ../src/dbgtool.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dbgtool.c -I ../inc -c $@ + del copts + +gcr.obj : ../src/gcr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcr.c -I ../inc -c $@ + del copts + +gcrcell.obj : ../src/gcrcell.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcrcell.c -I ../inc -c $@ + del copts + +llstk.obj : ../src/llstk.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/llstk.c -I ../inc -c $@ + del copts + +gcscan.obj : ../src/gcscan.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcscan.c -I ../inc -c $@ + del copts + +loopsops.obj : ../src/loopsops.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/loopsops.c -I ../inc -c $@ + del copts + +storage.obj : ../src/storage.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/storage.c -I ../inc -c $@ + del copts + +allocmds.obj : ../src/allocmds.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/allocmds.c -I ../inc -c $@ + del copts + +dir.obj : ../src/dir.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dir.c -I ../inc -c $@ + del copts + +gvar2.obj : ../src/gvar2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gvar2.c -I ../inc -c $@ + del copts + +lowlev1.obj : ../src/lowlev1.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lowlev1.c -I ../inc -c $@ + del copts + +subr.obj : ../src/subr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/subr.c -I ../inc -c $@ + del copts + +arith2.obj : ../src/arith2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/arith2.c -I ../inc -c $@ + del copts + +hacks.obj : ../src/hacks.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/hacks.c -I ../inc -c $@ + del copts + +lowlev2.obj : ../src/lowlev2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lowlev2.c -I ../inc -c $@ + del copts + +subr0374.obj : ../src/subr0374.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/subr0374.c -I ../inc -c $@ + del copts + +arith3.obj : ../src/arith3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/arith3.c -I ../inc -c $@ + del copts + +doscomm.obj : ../src/doscomm.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/doscomm.c -I ../inc -c $@ + del copts + +hardrtn.obj : ../src/hardrtn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/hardrtn.c -I ../inc -c $@ + del copts + +lsthandl.obj : ../src/lsthandl.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lsthandl.c -I ../inc -c $@ -Le + del copts + +sxhash.obj : ../src/sxhash.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/sxhash.c -I ../inc -c $@ + del copts + +arith4.obj : ../src/arith4.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/arith4.c -I ../inc -c $@ + del copts + +draw.obj : ../src/draw.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/draw.c -I ../inc -c $@ + del copts + +main.obj : ../src/main.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/main.c -I ../inc -c $@ + del copts + +testtool.obj : ../src/testtool.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/testtool.c -I ../inc -c $@ + del copts + +array.obj : ../src/array.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array.c -I ../inc -c $@ + del copts + +dsk.obj : ../src/dsk.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dsk.c -I ../inc -c $@ + del copts + +inet.obj : ../src/inet.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/inet.c -I ../inc -c $@ + del copts + +misc7.obj : ../src/misc7.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/misc7.c -I ../inc -c $@ + del copts + +timer.obj : ../src/timer.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/timer.c -I ../inc -c $@ + del copts + +array2.obj : ../src/array2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array2.c -I ../inc -c $@ + del copts + +dspif.obj : ../src/dspif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dspif.c -I ../inc -c $@ + del copts + +initdsp.obj : ../src/initdsp.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/initdsp.c -I ../inc -c $@ + del copts + +miscn.obj : ../src/miscn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/miscn.c -I ../inc -c $@ + del copts + +typeof.obj : ../src/typeof.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/typeof.c -I ../inc -c $@ + del copts + +array3.obj : ../src/array3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array3.c -I ../inc -c $@ + del copts + +initkbd.obj : ../src/initkbd.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/initkbd.c -I ../inc -c $@ + del copts + +ubf1.obj : ../src/ubf1.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ubf1.c -I ../inc -c $@ + del copts + +array4.obj : ../src/array4.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array4.c -I ../inc -c $@ + del copts + +dspsubrs.obj : ../src/dspsubrs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dspsubrs.c -I ../inc -c $@ + del copts + +initsout.obj : ../src/initsout.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/initsout.c -I ../inc -c $@ + del copts + +mkatom.obj : ../src/mkatom.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mkatom.c -I ../inc -c $@ + del copts + +ubf2.obj : ../src/ubf2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ubf2.c -I ../inc -c $@ + del copts + +array5.obj : ../src/array5.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array5.c -I ../inc -c $@ + del copts + +eqf.obj : ../src/eqf.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/eqf.c -I ../inc -c $@ + del copts + +intcall.obj : ../src/intcall.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/intcall.c -I ../inc -c $@ + del copts + +mkcell.obj : ../src/mkcell.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mkcell.c -I ../inc -c $@ + del copts + +ubf3.obj : ../src/ubf3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ubf3.c -I ../inc -c $@ + del copts + +array6.obj : ../src/array6.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array6.c -I ../inc -c $@ + del copts + +ether.obj : ../src/ether.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ether.c -I ../inc -c $@ + del copts + +ufn.obj : ../src/ufn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ufn.c -I ../inc -c $@ + del copts + +atom.obj : ../src/atom.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/atom.c -I ../inc -c $@ + del copts + +findkey.obj : ../src/findkey.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/findkey.c -I ../inc -c $@ + del copts + +kbdsubrs.obj : ../src/kbdsubrs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/kbdsubrs.c -I ../inc -c $@ + del copts + +mouseif.obj : ../src/mouseif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mouseif.c -I ../inc -c $@ + del copts + +ufs.obj : ../src/ufs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ufs.c -I ../inc -c $@ + del copts + +bbtsub.obj : ../src/bbtsub.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/bbtsub.c -I ../inc -c $@ + del copts + +foreign.obj : ../src/foreign.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/foreign.c -I ../inc -c $@ + del copts + +keyevent.obj : ../src/keyevent.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/keyevent.c -I ../inc -c $@ + del copts + +unixcomm.obj : ../src/unixcomm.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/unixcomm.c -I ../inc -c $@ + del copts + +bin.obj : ../src/bin.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/bin.c -I ../inc -c $@ + del copts + +fp.obj : ../src/fp.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/fp.c -I ../inc -c $@ + del copts + +keylib.obj : ../src/keylib.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/keylib.c -I ../inc -c $@ + del copts + +binds.obj : ../src/binds.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/binds.c -I ../inc -c $@ + del copts + +fvar.obj : ../src/fvar.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/fvar.c -I ../inc -c $@ + del copts + +mvs.obj : ../src/mvs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mvs.c -I ../inc -c $@ + del copts + +unwind.obj : ../src/unwind.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/unwind.c -I ../inc -c $@ + del copts + +bitblt.obj : ../src/bitblt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/bitblt.c -I ../inc -c $@ + del copts + +gc.obj : ../src/gc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gc.c -I ../inc -c $@ + del copts + +uraid.obj : ../src/uraid.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/uraid.c -I ../inc -c $@ + del copts + +blt.obj : ../src/blt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/blt.c -I ../inc -c $@ + del copts + +gc2.obj : ../src/gc2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gc2.c -I ../inc -c $@ + del copts + +kprint.obj : ../src/kprint.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/kprint.c -I ../inc -c $@ + del copts + +osmsg.obj : ../src/osmsg.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/osmsg.c -I ../inc -c $@ + del copts + +usrsubr.obj : ../src/usrsubr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/usrsubr.c -I ../inc -c $@ + del copts + +byteswap.obj : ../src/byteswap.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/byteswap.c -I ../inc -c $@ + del copts + +gcarray.obj : ../src/gcarray.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcarray.c -I ../inc -c $@ + del copts + +perrno.obj : ../src/perrno.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/perrno.c -I ../inc -c $@ + del copts + +uutils.obj : ../src/uutils.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/uutils.c -I ../inc -c $@ + del copts + +carcdr.obj : ../src/carcdr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/carcdr.c -I ../inc -c $@ + del copts + +asmbbt.obj : ../src/asmbbt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/asmbbt.c -I ../inc -c $@ + del copts + +gccode.obj : ../src/gccode.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gccode.c -I ../inc -c $@ + del copts + +vars3.obj : ../src/vars3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vars3.c -I ../inc -c $@ + del copts + +gcfinal.obj : ../src/gcfinal.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcfinal.c -I ../inc -c $@ + del copts + +ldsout.obj : ../src/ldsout.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ldsout.c -I ../inc -c $@ + del copts + +return.obj : ../src/return.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/return.c -I ../inc -c $@ + del copts + +vmemsave.obj : ../src/vmemsave.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vmemsave.c -I ../inc -c $@ + del copts + +chardev.obj : ../src/chardev.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/chardev.c -I ../inc -c $@ + del copts + +gchtfind.obj : ../src/gchtfind.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gchtfind.c -I ../inc -c $@ + del copts + +lineblt8.obj : ../src/lineblt8.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lineblt8.c -I ../inc -c $@ + del copts + +rpc.obj : ../src/rpc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/rpc.c -I ../inc -c $@ + del copts + +common.obj : ../src/common.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/common.c -I ../inc -c $@ + del copts + +gcmain3.obj : ../src/gcmain3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcmain3.c -I ../inc -c $@ + del copts + +lisp2c.obj : ../src/lisp2c.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lisp2c.c -I ../inc -c $@ + del copts + +rplcons.obj : ../src/rplcons.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/rplcons.c -I ../inc -c $@ + del copts + +z2.obj : ../src/z2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/z2.c -I ../inc -c $@ + del copts + diff --git a/bin/endiffix b/bin/endiffix new file mode 100755 index 0000000000000000000000000000000000000000..336b84ce676ab30924649d30b90bb0e15eb2dcc8 GIT binary patch literal 24576 zcmeHO4Qw38b$+|I_e1hXF7J*K{THw9_+wK)wBj_8oxnOHN@UrQ96)Xgr$%_xk+g|Y zBtcTL*ckE3HBh5*Q<|1lRf&}~NvoIbFVzNS#Sq#{)!>6SRZ$VUlE>6bYr$;MuYA+K*C(mZpeory~K5 zUp+hdR10K|)t=F65D&+a3d%e(g0_yT6hT{0aC)DrY5J(9#dLa<%bkcD-_eb>3Zx(5 z^!b31IT0}0&jgI8#)Bk{D0+=kZ+aMYp?q+qMzlX>$p=(gfjYl%5d6bvV_2rdG|ECI z?8w9%nbikXN;vg&JNm^@HpTkAfwE}xDaYQ5rS=pvHlk9^vifRKZY8&gGJS?(N((9D znfFtMzL+wecdGF||!o}kQe&@VFoIW_YH=wa9){WwR2wx8L1(u(Xo4?&$m&%rjt z3gXR(WyFD(@*0&peX#demgobNmq&t@G7~fjG78Ip_bh0MY3{9-T?73s-Ca9cy4%+c z^ioTE$L^Lt@96JECO@}i`v>p2U+d}BN(Ia9Y-+UgOEa~dZGC-RJx^+#ZC%~F`a2xq zM6oWn6+0)eu~2x9vIky0t4nF3P29ivrpYV7ITF(8K2F2VCXUmj#5v|X_*{@_?r-GZ z>&UI>Q`z}O&90xp+OcVb%3o&pAC7!P5tqZW4Vi;bO{X_{OF7Uj$X z1_?8n5*R?2G}yyWO3`X?XGDBOqOb3d}4Vt!C{>3NoC98aSIZ$VuL z;;3uXjCy3g%QCk?hq*w;yc6-E_*qjQOIJs9s^Gj;;8}`h8ugl#V!A$Kp8E#z_>RH; zI+nQ`b)OGv=0XtsdP`bp5PlPfPl-BKBmezi##{_$l%qjIT5QND#~KW2q0(f361cLh z=zlX!p?A4XovS6Ne%X?^zfAP~M@^F#Fjw6MY}AACHqytaQqgHU z>jpo({BpA*|X+Fr@to-rZN)u`CQ7H zScRDT8M-CTDA}nqYlzT|v2%)Hjw^=L#B{x70>clu&GXO|^K{}TYcn#|liD}e8qyoV z^a{+?HOFetM&AmiSH7cC-31gp9@Z3;o9A+ff5!3Kz!v@F__rQeq0^hpcX=a8y6u(w zGt%Dz1J`#C%4T#9{Q|rz=g|kRt+u4mkf|bFe!l$JPy2HUt>t4N;-z_tvQ@H8$F_=j2N$n3L4ESG>k^_O0NH`AD7o&3`lYm^c1E$En+P54U|JjB(hcDVU2BZ`5Y< z=&M@H@qgv&Wj2eoWpN~#kuWbV&OjcvmBR+Ho}Wf~R<mBxr`(_{3E1Wvk+d2RrS>yFl$WB9c zM5D4aNtK+hk7~U4ZDbm2X98<*UjKV4hYhQk$F?!P%jZA%_2Pk)Ce6Yo=$@DhWHA?J zmgYjo*C!68ENK<{eZ4lp>)aV7V>UqkoH90bZcUot=dlIFG7l@3g!L}A(4d*vSNuD- z{XW`Q+?u9i*#E9a-Up3Z?q1k&xiLG7@y6?a9P9t7kw%O+IU@msIOb*(^I9BpvkAT8 znA1<0tHsz8SmuEx^r^Fy)Qq8M3UsQo>a#PLKmUo_yq2xM^SOSqFu-lW-uU^gsZ%_M zqR(ovj+8Oqo<~w9`Ye`DW=v;)b%^uON3j{%Fzx=vo?=w5KwpV99D4FvX>z~7_SkGH zW6nQ9#A_t%6MG8St8yP$N}71@Vb!OFZ@GI4^o`1E(}H3s+$Rh5hH|9dlB`N(T(zfA zPO?s@Kf?ZRHNXeP#d;|8!Fmu|3>p(hgNB6lE4J8RO`snW7ed87g`3t77xxrDRkfu( z1^PR2F_fM9`MONq&mS=AfKB{TGx}VmTN#V#q>*DR#9nWhDioczu};831s1uv0MS9L z$8#_o7+1p1YR-p$s+fy&R=|R#z#(NRqre09^V*y{95o6H@K0XnV7J)A!$#h3`*U+wA{sz7Uj9>Qpm{V(HO>BL?2Dxf^}G9Iq0mS|8l2s7G;0O z{w{Zar9qcLsi(kERL!qE5@1 z9L^Z++!l0?K-S$$$M_sDT&@*7a^H64V0U~xF?Q-4#@z4=Tg>5E!^)XJ69bxgv&d0A~JSDCV329G@}s@ENi1 zvweooZ~||PDV6v0^MQHrHTsS&T z00-f3`T9?{*LE-v>ksO1_vSang!{_TD>p6UJkD!TQjCW(*jB}Qdi_%D*OP{FAZbZ+ z=)*%5nZi7r-W&?P#1$n?t`FCZ)vnr zKTNe43u1qbv903Fk-HSiC>Gi=qFTXPrxVX1?l|}oWIhU6xyvC-!G2e|+-NE9G-13} zrCb7gMk?_3sRCy`HPr+`;tMjk`I8cS=Q zGY?Jd2W~tUpH68LJP$i(zy#Lvsrl9E;@J=L4*Wx${g$^4wfS3<@oeGO@3DSq3S?Mj z?@252(s>OWBK}S?ET)xoH&JANp-`BB9;{YPjna4KLR~W)XelZK_i_6{mB!c zkKi;4`olg{3C|~ZGnFB%Ku{52vT$XXEFS*o!7`l3bOHgU(;Wyfo9Yp;tD$NHcpFt9 zC;RTvrHWVm$?;zb^08F+qSD4>&!Z^?Cl6F z3r`nyArd?dG3&|?*MX%#1Ws!R=o0QCc4JW%k>Fv96t*=YX8JA!rm=+)0g>Qw%w@6j z6M@q(Jp3ZjhD{*DVG8{hJ`tLrtI8-iMU=Hb$Ac7v-I@j(^JnM`Vt%wB1-?i0c?)!7 zn1cQ2v*Vy!!W6y_G)P{b0tOR!Hik)hoMJapL(Tp}zi(-Ce!A2ABuc`k~d((9YiePEqU5w!!RE%*pn*^@w_R z4-EE-ijdJJYTDJ)w+osN4RsX>PIkkx!49T6mZqoDsK9Q>ZVv?nvttjn_Vsu548r`@uHGHg+UX=2V5+-a=LiFVqb&dNA0Gi90UrS$ z0UrS$fj>k9u-2!sS54R7*tk00&*Dixfsnyg8+*Ap_HKzIf-TN5D~@9GfIN*^*wf;~ z1!Aw6!Ir{3ixsYT=>G*R*=MxEN1$bg{t$G)p)Y_|9GbsXW6S7$c#pURZ4u#ICibCj z43_Nh3*Hzss=5AC#-}akiSh~ThL0`HyKo%oZYq8KszQ-~5-uwT$`L*hk^(!GkSiYy zSMZtd22W}Eippa7iYkDHO*cPG+i^wJ^4HFB|1Qt{H0felZt1swxl|<%uqAJ0rCO3M z&0Ut_Ed6TD)MYek#^cF9=?ltpN8VDwY8|ivAyK2 zs!~hRrMb&eeCT)IYth%z#g(_?Qi*E*W^mKTt)aTcaW0go=C2ISf!t6vu3Qg$6z z=ii*;G$LBOx%AZ%tZNNEj+DGLHSv;kY3{NVe_C03J$1Q!S3_^SBri(ZIW;kUnJ)gd zsUpvo6lteTZsoH)T*}rWhEGBzZ!8usNtfm>OYsLK_q`Tuws~SvEQA zGUvKFr{5*|$`wcc9MPAtE^eNM{GvzZlAZ7V-3(%L9ZAkp<`Shb*eOYB6ioixxb!%3 zNN@Vu*BcwRG&X*taU17u=RbH@ppgq)FP|lZHcrHJ`mWU7J=xCQ{+-(TbzjsrY-qXX z^DXym(6(>g!r71)-vG-~_!`vJskJm~4Fg(pOF5-Fx(7Nu=^btD+Q8FY`0%3P>k7W} zXbtU7{ruTzUG|#wi}vmBKi89BH9U`PfrkN7z6LYoaj8;iKjkCfBj6+8Bj6+8Bj6+8 zBj6+8Bj6+8Bj6+8Bj6+8Bj6+8Bj6+8Bj6+OyFkGCkvYwERoOp8Xd38Ro94Tj^f~*7 z=!Xo@Yi+)`OZx?zFTTZp#pa9qtzUEa8sxV+eB2kH?VdZl-}c<$ZS&mW?eyH??e^T; z?f2Z<{jTSJ?q7KB=YAh|PTl*tFMICi{?KzjcMLy;-p`fpEZ)zR z8jAOGrIzCTThN$3V9`_i+Cd`n&gVcYxl5Uszy^)aAK{+vmA^ zySsRamj82qT`zTa>{&N71ftdcS*CR$n;qzCC-EZ+xK7gf&7{b{Wm7J6-7CDy?(Y8K z-PIi$y6MeaaU&O=".$file.".new"; + +## Copy the first two lines of the file (ID comment & static) + +$line = ; +printf OUT "%s", $line; +$line = ; +printf OUT "%s", $line; + + +## Now copy the rest of the file, omitting any line with a (#) +## in it (the likeliest ID Comment/static contents for SCCS. + +$line = ; + +while ( $line ) + { + if ( $line =~ /\(#\)/ ) + { + printf "Omitting line: %s", $line; + } + else + { + printf OUT "%s", $line; + } + $line = ; + + } + +close IN; +close OUT; + +## Save the original file, and put the "fixed" on in its place. + +`mv $file $file.orig`; +`mv $file.new $file`; + + + diff --git a/bin/fixid~ b/bin/fixid~ new file mode 100755 index 0000000..42eb8fd --- /dev/null +++ b/bin/fixid~ @@ -0,0 +1,38 @@ +#!/usr/local/bin/perl + +$file = shift; +chomp $file; + +printf "File is %s.\n", $file; + +open IN, "<" . $file; +open OUT, ">".$file.".new"; + +$line = ; +printf OUT "%s", $line; +$line = ; +printf OUT "%s", $line; + +$line = ; + +while ( $line ) + { + if ( $line =~ /\(#\)/ ) + { + printf "Omitting line: %s", $line; + } + else + { + printf OUT "%s", $line; + } + $line = ; + + } + +close IN; +close OUT; + +`mv $file $file.orig`; +`mv $file.new $file`; + + diff --git a/bin/install-medley b/bin/install-medley new file mode 100755 index 0000000..8c6f3fc --- /dev/null +++ b/bin/install-medley @@ -0,0 +1,758 @@ +#! /bin/sh +# ============================================================================ +# Changes: +# ============================================================================ +# SYNOPSYS: +# install-medley +# +# Utility used for installation and upgrading of the medley system. +# The utility will infer as much as possible about the host and network, +# but will prompt for answers when needed. +# +# ============================================================================ + +# What is the application to be installed +APPLICATION="Medley 2.0" + +SHAREDIR=/usr/share/lde +LOCALDIR=/usr/local/lde +INSTALLDIR=$LOCALDIR + +TAPEDEV=/dev/rst0 + +#************************************************************ +#********* Changes below this point should normally ********* +#********* not be required ********* +#************************************************************ + +# What we normally recommend to install (marked with 'x') +# COLORP and X11P versions are deduced if possible +SYSOUTP=x +MONOP=x +DISPLAYFONTP=x +LIBRARYP=x + +# All sizes in MB +SYSOUTSIZE=5.1 +MONOSIZE=0.5 +COLORSIZE=0.5 +X11SIZE=0.6 +XNSSIZE=0.1 +LIBRARYSIZE=3 +DISPLAYFONTSIZE=5.5 +INTERPRESSFONTSIZE=1.5 +CHECKSUMSIZE=0.1 +OBJECTSIZE=0.6 + +# All the files for each group +SYSOUTFILES="./lispsysouts" +CHECKSUMFILES="./checksumdir" +LIBRARYFILES="./lisplibrary ./clos" +DISPLAYFONTFILES="./fonts/display" +INTERPRESSFONTFILES="./fonts/interpress ./fonts/press" + +LOCALHOST=`/bin/hostname` +scriptName=`/bin/basename $0` + +# Send out a message when interrupted +trap 'echo " +Aborted..."; exit' 2 + +#----------------------------------------------------------- +#----------------------- PROCEDURES ------------------------ + +exitScript () { + echo "$scriptName: $1" + exit +} # exitScript + + +ask(){ +# Ask a question=$1 and use default=$2 if no answer is given. If arg $3 +# is specified, it will be considered the opposite of $2. Return 0 if +# default is used, 1 otherwise. 'answer' can be used as a global variable + + echo -n "$1 ${2:+[$2]}: " + answer=`/bin/line` + if [ $# -gt 2 ] + then until [ "$answer" = "" -o "$answer" = "$2" -o "$answer" = "$3" ]; + do echo "Please type '$2' or '$3'." + echo -n "$1 $2: " + answer=`/bin/line` + done + fi + +# Note the "-" in the argument below. test will not behave well with some +# of the shell escape characters otherwise. + [ "-${answer:=$2}" = "-$2" ] +} # ask + + +menuInstructions () { + echo "<--------------------> Menu Instructions <--------------------> + - Only options marked with an 'x' will be installed. They are + initally based on inferred information, recommendations and answers + to questions. + - To select additional options, at the prompt enter at least as + many characters as needed to make the selection unique, e.g., + 'XN' for XNS. To select all options, enter 'All'. + - To deselect an option already marked with an 'x', at the prompt + enter at least as many characters as needed to make the + selection unique. To deselect all options, enter 'None'. +" + ask "Continue?" "y" + +} # menuInstructions + + +welcome() { + + /usr/ucb/clear + echo " +<----------> Welcome to the $APPLICATION Installation Utility <----------> + +Utility is used to install or upgrade a $APPLICATION system. It will try to infer +as much information as possible about your system, but you will be prompted +for specific information when it is not able to infer it automatically. + +Recommended options are initially filled in, but you can change them at +any time using the Installation Options Menu. +" + menuInstructions + +} # welcome + + +scriptMessage () { + MESSAGE="************************** $1 *************************** +$2 +************************************************************" +} # scriptMessage + + +setOSType () { +# Pass it OS versions and it will set the OSVERSION variable + + while [ $# != 0 ] + do case "$1" in + 3|3.[245]) OS3P=x ;; + 4|4.0|4.0.*) OS4P=x ;; + 4.1|4.1.*) OS41P=x ;; + *) echo " Should not happen: OStype $1 invalid" ;; + esac + shift + done + OSVERSION="${OS3P:+3} ${OS4P:+4} ${OS41P:+4.1}" +} # setOSType + + +askOSVersion(){ +# Prompt user for the correct OS-version + + MESSAGE="$1" + + unset menuloop1 + while [ ${menuloop1:-notdone} = notdone ] + do /usr/ucb/clear + echo " +<---------------> OS Options Menu <---------------> + + ${OS3P:--} 3.X - SunOS 3.2 3.4 3.5 + ${OS4P:--} 4.0 - SunOS 4.0 4.0.X + ${OS41P:--} 4.1 - SunOS 4.1 4.1.X + + All - Mark all options + None - Unmark all options + Continue installation +${MESSAGE:+ +$MESSAGE}" + unset MESSAGE + ask "Select" "Continue" + case "$answer" in + 3|3.[X245]) + if [ "$OS3P" != "x" ] + then OS3P=x + else unset OS3P + fi ;; + 4.0|4.0.*) + if [ "$OS4P" != "x" ] + then OS4P=x + else unset OS4P + fi ;; + 4.1|4.1.*) + if [ "$OS41P" != "x" ] + then OS41P=x + else unset OS41P + fi ;; + [aA]*) OS3P=x ; OS4P=x ; OS41P=x ;; + [nN]*) unset OS3P OS4P OS41P ;; + [cC]*|"") menuloop1=done ;; + *) MESSAGE="Invalid reply: $answer" ;; + esac + done + OSVERSION="${OS3P:+3} ${OS4P:+4} ${OS41P:+4.1}" +} # askOSVersion + + +checkInstallPoint () { +# Uses INSTALLDIR to determine if it is possible to make an +# installation. INSTDIRERRP is just used to return result of operation and +# to signal an error message. EXISTSP is used to avoid repetitive messages. + + unset INSTDIRERRP + if [ -f "$INSTALLDIR" ] + then scriptMessage "ERROR" "A file with the same name already exists: $INSTALLDIR +Select the 'Directory' command and make a change." + INSTDIRERRP=x + elif [ -d "$INSTALLDIR" -a ! -w "$INSTALLDIR" ] + then scriptMessage "ERROR" "Write permission denied for directory: $INSTALLDIR +Select the 'Directory' command and make a change." + INSTDIRERRP=x + elif [ ! -d "$INSTALLDIR" ] + then /bin/mkdir -p $INSTALLDIR 1>/dev/null 2>/dev/null + if [ $? = 0 ] + then EXISTSP=x + else scriptMessage "ERROR" "Could not create: $INSTALLDIR - Permission denied +Select the 'Directory' command and make a change." + INSTDIRERRP=x + fi + elif [ -d "$INSTALLDIR" -a ${EXISTSP:--} = - ] + then scriptMessage "WARNING" "Directory already exists: $INSTALLDIR +If this is the location of a previous $APPLICATION installation, +\"$scriptName\" may overwrite some of the old files." + EXISTSP=x + fi + + [ ${INSTDIRERRP:--} = - ] +} # checkInstallPoint + + +mountTape () { + unset TAPEMOUNTEDP + while [ ${TAPEMOUNTEDP:--} = - ] + do if [ "$1" = "$LOCALHOST" ] + then mt -f $TAPEDEV status 2>&1 | /bin/egrep -s "no sense" + else /usr/ucb/rsh "$1" mt -f $TAPEDEV status 2>&1 | /bin/egrep -s "no sense" + fi + + if [ $? != 0 ] + then echo "ERROR. Tape not mounted or mounted improperly." + ask "Please insert installation tape in the tape drive. Done?" "y" + else TAPEMOUNTEDP=x + fi + done +} # mountTape + + +checkTape () { + + if [ "$1" = "$LOCALHOST" ] + then echo -n "Looking for a local tape drive on $1 ..." + mt -f $TAPEDEV status 2>&1 | /bin/egrep -s "no sense|not ready|no tape loaded" + if [ $? = 0 ] + then echo " Found" + TAPEHOST="$LOCALHOST" + else echo " Not found" + echo "'$LOCALHOST' does not seem to have a tape drive." + fi + else /usr/etc/ping "$1" 10 1>/dev/null 2>/dev/null + if [ $? = 0 ] + then echo -n "Looking for a remote tape drive on $1 ..." + /usr/ucb/rsh "$1" mt -f $TAPEDEV status 2>&1 | /bin/egrep -s "no sense|not ready|no tape loaded" + if [ $? = 0 ] + then echo " Found" + TAPEHOST="$1" + else echo " Not Found" + echo "'$1' does not seem to have a tape drive." + fi + else echo "Could not connect to '$1' or host unknown." + fi + fi + +} # checkTape + + +inferConfiguration () { +# Infers as much as possible the type of configuration on the host +# or network. Will ask when not able to determine something. + + # Try to infer Os type + if [ -f /etc/motd ] + then OSVERSION=`sed -e '1s/.*Release \(...\).*/\1/' -e '1q' < /etc/motd` + setOSType $OSVERSION + else askOSVersion "Please specify the SunOS version you are running." + fi + + # Is it necessary to install 'ldemulti' + /bin/egrep -s "cgthree0|cgsix0" /var/adm/messages + if [ $? = 0 ] + then COLORP=x + fi + + # Is X-windows installed on this host + if [ -d /usr/bin/X11 -o -d /usr/local/X11 ] + then X11P=x + fi + + + checkTape $LOCALHOST + + while [ ${TAPEHOSTP:--} = - ] + do + if [ ${TAPEHOST:--} = - ] + then + # Host is networked + ask "Name of a host with a tape drive" + checkTape "$answer" + fi + + if [ "${TAPEHOST:+-}" = - ] + then if ask "Insert installation tape in tape drive of $TAPEHOST. Ready?" "y" + then TAPEHOSTP=x + mountTape "$TAPEHOST" + else unset TAPEHOST + fi + fi + done + +} # inferConfiguration + + +emulatorSpace () { +# Figure out according to selections what the real space requirements +# are for the emulator. Sets the variables RMONOSIZE, RCOLORSIZE, RX11SIZE +# for later usage + + RMONOSIZE=0 + RCOLORSIZE=0 + RX11SIZE=0 + + if [ ${MONOP:--} != - ] + then for x in $OSVERSION + do RMONOSIZE=`echo $MONOSIZE ${OBJECTP:+"+ $OBJECTSIZE"} + $RMONOSIZE | /bin/bc` + done + fi + + if [ ${COLORP:--} != - ] + then for x in $OSVERSION + do RCOLORSIZE=`echo $COLORSIZE ${OBJECTP:+"+ $OBJECTSIZE"} + $RCOLORSIZE | /bin/bc` + done + fi + + if [ ${X11P:--} != - ] + then for x in $OSVERSION + do RX11SIZE=`echo $X11SIZE ${OBJECTP:+"+ $OBJECTSIZE"} + $RX11SIZE | /bin/bc` + done + fi +} # emulatorSpace + + +showInstallMenu () { +# Will do different calculations depending on $1. If no argument is +# given, it will only redisplay the Installation Options Menu. + + if [ $# -ge 1 ] + then if [ "$1" = available -o $# -gt 1 ] + then if checkInstallPoint + then calculateSpace available + fi + fi + + if [ "$1" = required -o $# -gt 1 ] + then calculateSpace required + fi + + if [ "${EXISTSP:+-}" = - ] + then sufficientSpaceP + fi + fi + + /usr/ucb/clear + + echo " +<---------------> Installation Options Menu <--------------> +------------------------ Emulators ------------------------- +For one or several OS versions (At least one of monochrome, +color, or X11-version is required for new installations). + + ${MONOP:--} Monochrome ${MONOP:+- $RMONOSIZE MByte} + ${COLORP:--} Color ${COLORP:+- $RCOLORSIZE MByte} + ${X11P:--} X11-version ${X11P:+- $RX11SIZE MByte} + ${XNSP:--} XNS ${XNSP:+- $XNSSIZE MByte }- allows handling of the XNS protocol. + ${OBJECTP:--} Object files - allows linking of Medley to other software. + OS version - Change versions. Selected: $OSVERSION +-------------------------- Fonts --------------------------- + ${DISPLAYFONTP:--} Display ${DISPLAYFONTP:+- $DISPLAYFONTSIZE MByte }(recommended) + ${INTERPRESSFONTP:--} Interpress ${INTERPRESSFONTP:+- $INTERPRESSFONTSIZE MByte} +------------ Sysout, Library & Checksum files ------------- + ${SYSOUTP:--} Sysout ${SYSOUTP:+- $SYSOUTSIZE MByte} (required for new installations). + ${LIBRARYP:--} Library modules ${LIBRARYP:+- $LIBRARYSIZE MByte }(recommended) + ${CHECKSUMP:--} Checksum files ${CHECKSUMP:+- $CHECKSUMSIZE MByte} +------------------------- Commands ------------------------- + Directory - Change the installation directory. + -- Current: $INSTALLDIR + -- Disk-space(KByte) Available:${AVAILABLESPACE:----} Needed:$DISKSPACE + ! - Execute a Unix command. + ? or Help - Show menu instructions. + Redraw - Redisplay this menu. + All - Mark all options. + None - Unmark all options. + Continue installation. + Quit installation. +${MESSAGE}" +} # showInstallMenu + + +getInstallOptions() { +# General menu for selecting what to install + + showInstallMenu required available + + menuloop3=notdone + while [ "$menuloop3" = notdone ] + do if [ "${INSTDIRERRP:+-}" = - ] + then ask "Select" "Directory" + unset INSTDIRERRP + else ask "Select" "Continue" + fi + unset MESSAGE + + case "$answer" in + [sS]*) if [ "$SYSOUTP" != "x" ] + then SYSOUTP=x + else unset SYSOUTP + fi + showInstallMenu required ;; + [mM]*) if [ "$MONOP" != "x" ] + then MONOP=x + else unset MONOP + fi + showInstallMenu required ;; + [cC][oO][lL]*) + if [ "$COLORP" != "x" ] + then COLORP=x + else unset COLORP + fi + showInstallMenu required ;; + [xX][1]*) + if [ "$X11P" != "x" ] + then X11P=x + else unset X11P + fi + showInstallMenu required ;; + [xX][nN]*) + if [ "$XNSP" != "x" ] + then XNSP=x + else unset XNSP + fi + showInstallMenu required ;; + [oO][bB]*) + if [ "$OBJECTP" != "x" ] + then OBJECTP=x + else unset OBJECTP + fi + showInstallMenu required ;; + [oO][sS]*) + askOSVersion "Please specify changes you wish to make." + showInstallMenu required ;; + [dD][iI][sS]*) + if [ "$DISPLAYFONTP" != "x" ] + then DISPLAYFONTP=x + else unset DISPLAYFONTP + fi + showInstallMenu required ;; + [iI]*) if [ "$INTERPRESSFONTP" != "x" ] + then INTERPRESSFONTP=x + else unset INTERPRESSFONTP + fi + showInstallMenu required ;; + [lL]*) if [ "$LIBRARYP" != "x" ] + then LIBRARYP=x + else unset LIBRARYP + fi + showInstallMenu required ;; + [cC][hH]*) + if [ "$CHECKSUMP" != "x" ] + then CHECKSUMP=x + else unset CHECKSUMP + fi + showInstallMenu required ;; + [dD][iI][rR]*) + ask "Where do you want to install $APPLICATION?" "$INSTALLDIR" + INSTALLDIR="$answer" + unset EXISTSP + showInstallMenu available ;; + !?*) eval `echo "$answer" | /bin/sed -e s/\\!//` ;; + \?|[hH]*) menuInstructions ; showInstallMenu ;; + [rR]*) showInstallMenu ;; + [aa]*) SYSOUTP=x ; MONOP=x ; COLORP=x ; X11P=x ; XNSP=x + OBJECTP=x ; DISPLAYFONTP=x ; INTERPRESSFONTP=x + LIBRARYP=x ; CHECKSUMP=x ; showInstallMenu required ;; + [nN]*) unset SYSOUTP MONOP COLORP X11P XNSP OBJECTP DISPLAYFONTP INTERPRESSFONTP LIBRARYP CHECKSUMP + showInstallMenu required ;; + [cC][oO][nN]*|"") + if [ ${SYSOUTP:--} = - -a ${MONOP:--} = - -a \ + ${COLORP:--} = - -a ${X11P:--} = - -a \ + ${DISPLAYFONTP:--} = - -a ${INTERPRESSFONTP:--} -a \ + ${LIBRARYP:--} = - -a ${CHECKSUMP:--} = - -a \ + ${OBJECTP:--} = - -a ${XNSP:--} = - ] + then scriptMessage "ERROR" "It doesn't make sense not installing anything. +Please select an option to install" + elif [ \( ${MONOP:--} != - -o ${COLORP:--} != - -o \ + ${X11P:--} != - \) -a ${OS3P:--} = - -a \ + ${OS4P:--} = - -a ${OS41P:--} = - ] + then scriptMessage "ERROR" "You have to select a SunOS version in order to install an emulator." + elif checkInstallPoint + then if sufficientSpaceP + then menuloop3=done + fi + fi + echo "$MESSAGE" ;; + [qQ]*) exitScript "Aborted ..." ;; + *) echo "Invalid reply: $answer" ;; + esac + done + +} # getInstallOptions + + +calculateSpace(){ +# Calculate either available space for chosen installation point or required +# space for selected options. $1 is used to determine what to calculate. + + if [ "$1" = required ] + then emulatorSpace + + REQUIREDSPACE=`echo ${SYSOUTP:+"$SYSOUTSIZE +"} \ + ${LIBRARYP:+"$LIBRARYSIZE +"} \ + ${DISPLAYFONTP:+"$DISPLAYFONTSIZE +"} \ + ${INTERPRESSFONTP:+"$INTERPRESSFONTSIZE +"} \ + ${CHECKSUMP:+"$CHECKSUMSIZE +"} \ + ${XNSP:+"$XNSSIZE +"} \ + "$RMONOSIZE + $RCOLORSIZE + $RX11SIZE" | /bin/bc` + + DISKSPACE=`echo $REQUIREDSPACE "*" 1024 | /bin/bc` + else DF=`/bin/df $INSTALLDIR 2>/dev/null| egrep -v Filesystem` + + if [ "$DF" != "" ] + then FILESYSTEM=`echo $DF | /bin/awk '{print $6}'` + AVAILABLESPACE=`echo $DF | /bin/awk '{print $4}'` + else unset AVAILABLESPACE + fi + fi +} + + +sufficientSpaceP () { +# Check if there is enough space in FILESYSTEM to make install + + unset MISSINGSPACE + if [ "$DISKSPACE" -ge "$AVAILABLESPACE" ] + then MISSINGSPACE=`echo $DISKSPACE - $AVAILABLESPACE | /bin/bc` + scriptMessage "ERROR" "There is not enough disk-space in file system: $FILESYSTEM +Additional space needed: ($MISSINGSPACE Kbytes) +To complete installation, select the 'Directory' command and +make a change, or deselect some of the selected options." + + INSTDIRERRP=x + fi + + [ "$DISKSPACE" -lt "$AVAILABLESPACE" ] +} + + +tapeCommand() { +# Tape commands are $1 = 'rewind' and 'fsf 1' and +# $2 is the message to print out if given. + + if [ $# -gt 1 ] + then echo -n "$2" + fi + + if [ "$TAPEHOST" = `/bin/hostname` ] + then /bin/mt -f /dev/nrst0 $1 # local tape drive + else /usr/ucb/rsh -n "$TAPEHOST" /bin/mt -f /dev/nrst0 $1 # remote host + fi + + if [ $? = 0 -a $# -gt 1 ] + then echo " Done" + fi + +} + +collectEmulatorFiles () { + EMULATORFILES="$EMULATORFILES $*" +} + + +extract() { +# Extract from tape + + # Print message + echo -n "Extracting: $1 ..." + shift + + if [ "$TAPEHOST" = `/bin/hostname` ] + then /bin/dd if=/dev/nrst0 bs=256b 2>/dev/null | /bin/tar xBipfb - 256 $* + else /usr/ucb/rsh -n "$TAPEHOST" /bin/dd if=/dev/nrst0 bs=256b 2>/dev/null | /bin/tar xBipfb - 256 $* + fi + + if [ $? != 0 ] + then echo " Not extracted !" + else echo " Done" + fi +} + + +extractFilesP () { +# Returns true if either of the file arguments passed are to be +# extracted. It is used to avoid unnecessary skips and searches on the tape. + + unset EXTRACTP + while [ ${EXTRACTP:--} = - -a $# != 0 ] + do case "$1" in + File3) EXTRACTP=${MONOP:-${COLORP:-${X11P:-${XNSP:-${OBJECTP:--}}}}} ;; + File4) EXTRACTP=${LIBRARYP:--} ;; + File5) EXTRACTP=${SYSOUTP:-${CHECKSUMP:--}} ;; + File6) EXTRACTP=${DISPLAYFONTP:-${INTERPRESSFONTP:--}} ;; + *) + exitScript "Help! Should not happen: extractFilesP $1 " ;; + esac + shift + done + [ ${EXTRACTP:--} != - ] +} + + +performInstall () { +# The actual tar of the tape. There are 5 files on the tape. +# File 1 Contains this script 'install-medley' (Skip past it) +# File 2 Contains the 'medley' script (always extracted) +# File 3 Contains the emulator files for the supported OS-versions +# (executables, objectfiles and makefile) +# File 4 Contains Lisp Library files +# File 5 Contains Lisp Sysouts and checksumfiles +# File 6 Contains Font files (Display and Interpress) + + cd $INSTALLDIR + + tapeCommand rewind "Positioning media ..." + tapeCommand 'fsf 1' + + extract "medley startup script" ./medley + + if extractFilesP File3 + then EMULATORFILES="" + + for OS in $OSVERSION + do collectEmulatorFiles ${MONOP:+"./install.sunos$OS/ldesingle ${OBJECTP:+./install.sunos$OS/ldesingle.o}"} ${COLORP:+"./install.sunos$OS/ldemulti ${OBJECTP:+./install.sunos$OS/ldemulti.o}"} ${X11P:+"./install.sunos$OS/ldex ${OBJECTP:+./install.sunos$OS/ldex.o}"} ${XNSP:+"./install.sunos$OS/ldeether ${OBJECTP:+./install.sunos$OS/ldeether.c}"} ${OBJECTP:+"./install.sunos$OS/makefile ./install.sunos$OS/usersubrs.c"} + + if [ "${MONOP:+-}" = - -o "${COLORP:+-}" = - -o "${MULTI:+-}" = - ] + then EMULATORFILES="./install.sunos$OS/lde $EMULATORFILES" + fi + done + + extract "emulator files for OS versions: $OSVERSION" $EMULATORFILES + + elif extractFilesP File4 File5 File6 + then tapeCommand 'fsf 1' "Skipping: emulator files ..." + fi + + if extractFilesP File4 + then extract "library files" ${LIBRARYP:+$LIBRARYFILES} + elif extractFilesP File5 File6 + then tapeCommand 'fsf 1' "Skipping: library files ..." + fi + + if extractFilesP File5 + then extract "${SYSOUTP:+sysout }${CHECKSUMP:+checksum }files" ${SYSOUTP:+$SYSOUTFILES} ${CHECKSUMP:+$CHECKSUMFILES} + elif extractFilesP File6 + then tapeCommand 'fsf 1' "Skipping: ${SYSOUTP:+sysout }${CHECKSUMP:+checksum }files ..." + fi + + if extractFilesP File6 + then extract "${DISPLAYFONTP:+display }${INTERPRESSFONTP:+interpress }font-files" ${DISPLAYFONTP:+$DISPLAYFONTFILES} ${INTERPRESSFONTP:+$INTERPRESSFONTFILES} + fi + + tapeCommand rewind "Done extracting files. Rewinding media ..." + +} + + +updateFile() { +# Will create a copy of file $1 into $1.orig +# Will then replace $* with $2 from file $1.orig into file $1 + FILE=$1 + CHANGES="$*" + TO=$2 + + if [ ! -f "$FILEDIR/$FILE.orig" ] + then /bin/cp $FILE $FILE.orig + fi + echo -n "Updating: $FILE ... " + for CHANGE in CHANGES + do + /bin/sed -e 1,'$'s/$CHANGE/$TO/ <$FILE.orig >$FILE + done + if [ $? = 0 ] + then echo -n "Done - " + else echo "An error occured while trying to update: $FILE" + fi + echo "Original in: $FILE.orig ..." +} + + +updateFiles(){ +# Will update 'site-init' and 'medley' by replacing all ocassions of +# $SHAREDIR or $LOCALDIR to $INSTALLDIR + + if ask "Do you wish to update the files 'site-init' and 'medley' +with respect to the installation directory: $INSTALLDIR" "y" "n" + then CHANGEDIR1=`echo $SHAREDIR | /bin/sed -e 's/\//\\\\\//g'` + CHANGEDIR2=`echo $LOCALDIR | /bin/sed -e 's/\//\\\\\//g'` + NEWDIR=`echo $INSTALLDIR | /bin/sed -e 's/\//\\\\\//g'` + + + FILEDIR="$INSTALLDIR/`/bin/basename $LIBRARYFILES`" + if [ ${LIBRARYP:--} != - -a -d "$FILEDIR" ] + then cd "$FILEDIR" + if [ -f "$FILEDIR/site-init" ] + then + updateFile site-init "$NEWDIR" "$CHANGEDIR1" "$CHANGEDIR2" + elif [ -f "$FILEDIR/site-init.lisp" ] + then + cp site-init.lisp site-init + updateFile site-init "$NEWDIR" "$CHANGEDIR1" "$CHANGEDIR2" + else echo "Could not find: $FILEDIR/site-init" + fi + else echo "$FILEDIR/site-init not installed." + fi + if [ -f "$INSTALLDIR/medley" ] + then cd "$INSTALLDIR" + + updateFile medley "$NEWDIR" "$CHANGEDIR1" "$CHANGEDIR2" + else echo "Could not find: $INSTALLDIR/medley" + fi + fi +} + + +#------------------------------------------------------------ +# ********** Main procedure starts here. ********** +#------------------------------------------------------------ + +welcome + +inferConfiguration + +unset answer +while [ ${answer:--} != y ] +do getInstallOptions + ask "Ready to make installation in: $INSTALLDIR" "y" "n" +done + +performInstall + +updateFiles + +exitScript "Installation of $APPLICATION completed." diff --git a/bin/launch.asm b/bin/launch.asm new file mode 100755 index 0000000..ced4548 --- /dev/null +++ b/bin/launch.asm @@ -0,0 +1,362 @@ +;************************************************************************ +;* * +;* l a u n c h . a s m * +;* * +;* This is the launcher for Medley on DOS. It: * +;* * +;* * Looks for and validates any -m memsize argument on the * +;* command line. Only values in the range 8 - 32 are allowed. * +;* * +;* * Loads the real Medley emulator, emul.exe, from the same * +;* directory that the launcher came from. * +;* * +;* * Sets the Intel DOS Extender's profile to the requested * +;* memory size + 3Mb (to allow for the emulator, internal * +;* data areas, etc.) * +;* * +;* * Set the termination address in the child process's PSP, * +;* so control returns to the launcher when Medley terminates. * +;* * +;* * Jumps to the emulator's start address. * +;* * +;* * Upon return, just terminates cleanly. * +;* * +;* [We could perhaps do some diagnosis here of error returns?] * +;* * +;* * +;* * +;************************************************************************ + +;************************************************************************/ +;* */ +;* (C) Copyright 1993, 1994 Venue. All Rights Reserved. */ +;* Manufactured in the United States of America. */ +;* */ +;* The contents of this file are proprietary information */ +;* belonging to Venue, and are provided to you under license. */ +;* They may not be further distributed or disclosed to third */ +;* parties without the specific permission of Venue. */ +;* */ +;************************************************************************/ + +.model small +.386p +.stack 100h +.data + align 8 + ;******************************************************** + ;* Parameter block for INT 214B, that loads medley.exe * + ;******************************************************** +envseg DW 0 ; environment (0 = copy mine) +cmdip DW ? ; command-line-tail pointer +cmdcs DW ? +fcb1 DD ? ; dummy first FCB to fill in +fcb2 DD ? ; " 2nd FCB, not here in DOS 4.01??? +stk DD ? ; SS:SP for emul.exe, filled in by loader +csip DD ? ; start addr for emul.exe, filled in by loader + + + +retad DD FAR PTR myret ; cs:ip return address, to put in + ; child PSP, so we get control back. + + + ;* Error messages, misc strings, and work areas* + align 8 +memval dd 0 +errstg DB 'ERROR: Couldn''t free excess storage.',13,10,'$' +noload db 'ERROR: Loading emulator failed: $' +loaded db 'LOAD SUCCESSFUL.',13,10,'$' +nominfo db 'ERROR: -m must be followed by a number 8 - 64.',13,10,'$' +badexe db 'ERROR: emul.exe is corrupted.',13,10,'$' +emulpath DB 'emul.exe',0 ; name of the real emulator. +mflag db '-m' ; to search for -m/-M in cmd line +mmflag db '-M' +profile db 'PRO' ; to find the DOS extender profile +cmdline db 128 dup (?) ; hold the cmd line tail for real emulator + + ;* Error-message table for failures loading emul.exe + align 2 +errtbl dw OFFSET ng0msg ; 0 = unknown failure + dw OFFSET ng1msg ; 1 = "invalid function" + dw OFFSET ng2msg ; 2 = file not found + dw OFFSET ng3msg ; 3 = path not found + dw OFFSET ng4msg ; 4 = too many open files + dw OFFSET ng5msg ; 5 = access denied + dw OFFSET ng0msg ; 6 = not possible error + dw OFFSET ng0msg ; 7 = not possible error + dw OFFSET ng8msg ; 8 = insufficient storage + dw OFFSET ng0msg ; 9 = not possible + dw OFFSET ngamsg ; A = bad environment + dw OFFSET ngbmsg ; B = bad format (corrupt .exe?)a + +ng0msg db 'Unknown problem',13,10,'$' +ng1msg db 'Invalid Function',13,10 + db 'Make sure you are running DOS 4.0 or later.',13,10,'$' +ng2msg db 'File not found.',13,10 + db 'CD to proper directory, or set PATH.',13,10,'$' +ng3msg db 'Path not found.',13,10 + db 'CD to proper directory, or set PATH.',13,10,'$' +ng4msg db 'Too many files open.',13,10 + db 'Shut down some TSRs that have file open?',13,10,'$' +ng5msg db 'Access denied.',13,10 + db 'Make sure of your access rights to emul.exe?',13,10,'$' +ng8msg db 'Not enough memory.',13,10 + db 'Shut down some TSR applications?',13,10,'$' +ngamsg db 'Environment corrupt.',13,10 + db 'Check using SET; You may need to re-boot.',13,10,'$' +ngbmsg db 'EXE file corrupted.',13,10,'$' + db 'You may need to restore from backup or re-install.',13,10,'$' +.code + + + +;************************************************************************ +;* * +;* M A C R O S * +;* * +;* prints Given a string ptr in DX, print it to the display. * +;* * +;* kill Exit cleanly, using INT 21/4C * +;* * +;************************************************************************ + +prints macro text + mov dx, OFFSET text + mov ah,9 + int 21h + endm + +kill macro + mov ah,4ch + int 21h + endm + + + +;************************************************************************ +;* * +;* M A I N E N T R Y * +;* * +;* * +;* * +;* * +;* * +;************************************************************************ + +PUBLIC main +main PROC NEAR + + mov ax,ds ; Save memory-block start for freeing + mov es,ax ; excess memory in a bit. + + mov ax,@data ; DS points to start of data segment + mov ds,ax + + mov cmdcs, ax ; Copy the command line for the emulator + mov cmdip, OFFSET cmdline + + mov di, OFFSET cmdline + mov cx,128 + mov bx,es + mov dx,ds + mov es,dx + mov ds,bx + mov si,80h + + rep + movsb + + mov es,bx ; Free the excess memory that DOS gives + mov ds,dx ; us (we need it for the emulator) + + mov ax,4a00h + mov bx,090h ; We only need 900h bytes for this program + int 21h + jnc freeok + + prints errstg ; Couldn't free spare space; punt. + kill + + ;************************************************ + ;* Search the command line for -m or -M * + ;************************************************ +freeok: + mov di,81h ; start of command line tail + mov si, OFFSET mflag + mov cx, 2 + + mov bx,81h + add bl,es:[80h] + +m1lp: call strcmp + je fndm + + add di, 1 + cmp di, bx + jl m1lp + + mov di,81h ; start of command line tail + mov si, OFFSET mmflag + +m2lp: call strcmp + je fndm + + add di, 1 + cmp di, bx + jl m2lp + + mov memval,02400000h ; memory value not set--use 35MB total. + jmp doload + +fndm: add di,2 ; Found "-m". Now look for a number + cmp di,bx ; (Make sure it's not end of line) + jnl nogoodm + +ok1: + mov edx, 0 ; Holds the memory-requirement value + mov ax,0 ; holds characters as we read + + ;************************************************ + ;* Skip over spaces/tabs before any number * + ;************************************************ +skiplp: + mov al, es:[di] + inc di + cmp al, 20h ; spaces + je skiplp + cmp al, 09h ; tabs + je skiplp + cmp di,bx ; make sure we're still in the string + jle cnvst ; Yup, we've got the first char, so enter + ; the conversion loop part-way down. + +nogoodm: + prints nominfo ; no arg to -m, or it's bad; Punt. + kill + + ;******************************************************** + ; Convert the numeric argument to -m; result in edx. * + ;******************************************************** +cnvlp: mov al,es:[di] + add di, 1 +cnvst: cmp al, 30h + jl endcnv + cmp al, 39h + jg endcnv + sub al, 30h + imul dx, 10 + add dx, ax + jmp cnvlp + +endcnv: + cmp edx,0 ; if still 0, no valid chars! + je nogoodm + cmp edx, 8 ; must be in the range [8, 32] + jl nogoodm + cmp edx,64 + jg nogoodm + + add edx, 3 ; add 3mb for data areas, etc, and + sal edx, 20 ; convert to megabytes + mov memval, edx ; save memory requested + + ;************************************************ + ;* Load the real emulator .EXE file, emul.exe * + ;************************************************ +doload: mov dx, OFFSET emulpath + mov ax, seg envseg + mov es, ax + mov bx, OFFSET envseg + mov ax,4b01h ; load-don't-start + int 21h + jnc loadok + + add ax,ax + mov si,ax + prints noload + mov bx,OFFSET errtbl + mov dx,ds:[bx+si] + mov ah,9 + int 21h + kill + +loadok: ; Load succeeded. + mov ah,51h ; get PSP address for child + int 21h + mov es, bx ; get segment for DI addressing + +; mov cx,128 ; copy the command line tail +; mov di,80h ; (which appears to be flaky in DOS 4) +; mov si, offset cmdline +; rep +; movsb + + mov eax,retad + mov dword ptr es:[+0ah], eax ; set up return address. + + cmp memval, 0 ; If no -m value given, just + je dorun ; go start the emulator. + + mov di,0 ; Search for the Intel Extender's PROFILE + mov si, OFFSET profile ; (see extender.h) + mov cx, 3 ; (length is 3 bytes) + +srchlp: call strcmp + je gotprof ; found the profile; fix it. + add di, 1 + cmp di, 2048 + jle srchlp + + prints badexe ; No extender profile, so the emulator + kill ; EXE must be corrupt. Punt. + +gotprof: + mov eax,memval ; Fill in the memory requirement. + mov es:[di+1bch], eax + +;******************************************************** +;* * +;* Set up the stack seg/pointer & start medley. * +;* * +;******************************************************** +dorun: lss sp,stk ; load stack SS & SP regs + mov ax, es ; copy PSP ptr to ax & ds, since some + mov bx, ds ; code expects it in both places. + mov fs,bx ; Also, copy DS to FS, so we still have + mov ds,ax ; a base for the indirect jump . . . + jmp fs:[csip] ; to start-of-medley. + +myret: kill ; we get back here, so quit gracefully. + +main endp + + + +;************************************************************************/ +;* */ +;* s t r c m p */ +;* */ +;* Compare [ds]di and es:[si] for (CX) characters. If the */ +;* strings are equal, the Zero flag is set when this returns. */ +;* */ +;* All registers are preserved. */ +;* */ +;************************************************************************/ + +strcmp proc near + cld + push di + push si + push cx + + repe + cmpsb + + pop cx + pop si + pop di + ret +strcmp endp + +END diff --git a/bin/ldechecksum b/bin/ldechecksum new file mode 100755 index 0000000..d57cc33 --- /dev/null +++ b/bin/ldechecksum @@ -0,0 +1,170 @@ +#! /bin/sh +# First line invokes Bourne shell +# ============================================================================ +# ABSTRACT: +# Bourne script for checking/generating checksums files for the +# Medley release. The script will generate a checksum-file for each +# release directory, containing the corresponding checksums for all +# files residing in the directory. The files having incorrect +# checksums will be reported with a message. The checksum-files will +# be put under: +# /checksumdir (Normally /usr/local/lde/checksumdir). +# +# +# SYNOPSIS: +# ldechecksum [-cg] medleydir [ dir | dirgroup ] +# +# -c compare checksumfiles "FOO.check" with "FOO.sum" (default). +# -g generate checksumfiles "FOO.sum". +# medleydir is the name of the Medley installation directory (normally +# is "/usr/local/lde"). +# dir can be any specific directory residing under medleydir. Only +# relative pathnames with respect to medleydir are accepted. +# dirgroup can be either "all" (default), "fonts" or "lisp" which +# means the "install.sunosX", "lisplibrary" and "lispsysouts" +# directories. +# +# CHANGES: +# 08-23-90 Carl Gadener : Added install.sunos4.1 +# 05-05-89 Carl Gadener : Added lispusers as an option +# 03-30-89 Carl Gadener : Added fonts and fonts/press +# 01-19-89 Carl Gadener : Parameter "medleydir" is now mandatory. Also +# check that "checksum" files were installed. +# 12-22-88 Carl Gadener : Compressed the big "case $dirspec" statement +# 12-15-88 Carl Gadener : Rewrote it for Bourne shell due to limitation +# factors in CSH +# 12-12-88 Carl Gadener & Larry Harada : Creation of script +# ============================================================================ +# +# First case statement checks arguments to ldechecksum +case $# in + 0) echo "Usage: ldechecksum [ -cg ] medleydir [ dir | dirgroup ] " + exit 1 ;; + 1) case $1 in + -*) echo "Usage: ldechecksum [ -cg ] medleydir [ dir | dirgroup ] " + exit 1 ;; + *) arg="-c" + medleydir=$1 + dirspec=all + break ;; + esac ;; + [23]) + case $1 in + -[cg]) arg=$1 + medleydir=$2 + if test $# = 3 + then + dirspec=$3 + else + dirspec=all + fi + break ;; + -*) echo "Usage: ldechecksum [ -cg ] medleydir [ dir | dirgroup ] " + exit 1 ;; + *) arg="-c" + medleydir=$1 + if test $# = 2 + then + dirspec=$2 + else + echo "Unexpected arg: $3" + exit 1 + fi + break ;; + esac ;; + *) echo "Usage: ldechecksum [ -cg ] medleydir [ dir | dirgroup ] " + exit 1 ;; +esac + +# Checking if the Medley directory exists +if test -d $medleydir +then + cd $medleydir + +# Checking that script is correctly installed + if test -d checksumdir \ + -a -f checksumdir/ldechecksum \ + -a -f checksumdir/checksum + then + + lispdirs="install.sunos3 install.sunos4 install.sunos4.1 lisplibrary lispsysouts" + fonts="JIS1 JIS2 chinese miscellaneous presentation printwheel \ + publishing" + + if test $arg = "-g" + then + operation="Generating" + else #$arg = "-c" + operation="Verifying" + fi + + case $dirspec in + all) + checksumdir/ldechecksum $arg `pwd` lisp + checksumdir/ldechecksum $arg `pwd` fonts/display + checksumdir/ldechecksum $arg `pwd` fonts/interpress + checksumdir/ldechecksum $arg `pwd` fonts/press + ;; + lisp) + echo "----------------------------------------------------" + echo "$operation checksums for Lisp directories" + echo "----------------------------------------------------" + for file in $lispdirs + do + checksumdir/checksum $arg $file + done + ;; + fonts) + checksumdir/ldechecksum $arg `pwd` fonts/display + checksumdir/ldechecksum $arg `pwd` fonts/interpress + checksumdir/ldechecksum $arg `pwd` fonts/press + ;; + fonts/display | \ + fonts/interpress) + fonttype=`basename $dirspec` + echo "----------------------------------------------------" + echo "$operation checksums for $fonttype font directories" + echo "----------------------------------------------------" + for file in $fonts + do + checksumdir/checksum $arg $dirspec/$file + done + ;; +# All Medley directories at the "lowest" level + install.sunos3 | \ + install.sunos4 | \ + install.sunos4.1 | \ + lisplibrary | \ + lispsysouts | \ + lispusers | \ + fonts/display/JIS1 | \ + fonts/display/JIS2 | \ + fonts/display/chinese | \ + fonts/display/miscellaneous | \ + fonts/display/presentation | \ + fonts/display/printwheel | \ + fonts/display/publishing | \ + fonts/interpress/JIS1 | \ + fonts/interpress/JIS2 | \ + fonts/interpress/chinese | \ + fonts/interpress/miscellaneous | \ + fonts/interpress/presentation | \ + fonts/interpress/printwheel | \ + fonts/interpress/publishing | \ + fonts/press) + checksumdir/checksum $arg $dirspec + ;; + *) echo "$dirspec : No such directory/grouping under `pwd`" + exit 1 ;; + esac + + else + echo "`pwd`/checksumdir : No such directory or script incorrectly installed" + exit 1 + fi + +else + echo "$medleydir : No such directory" + exit 1 +fi + diff --git a/bin/machinetype b/bin/machinetype new file mode 100755 index 0000000..2caa90d --- /dev/null +++ b/bin/machinetype @@ -0,0 +1,24 @@ +#!/bin/sh +######################################################################### +# # +# M A C H I N E T Y P E # +# # +# Compute the hardware architecture we're running on. # +# # +# (C) Copyright 2001 Venue. All Rights Reserved # +# # +######################################################################### + +os=`./config.guess` + +# o/s switch block +case "$os" in + sparc-*) echo sparc ;; + alpha-*) echo alpha ;; + i*86-*-*) echo 386 ;; + powerpc-*) echo ppc ;; +esac + + +### Don't leave the variables set. +unset os diff --git a/bin/machinetype~ b/bin/machinetype~ new file mode 100644 index 0000000..48601a6 --- /dev/null +++ b/bin/machinetype~ @@ -0,0 +1,19 @@ +#!/bin/sh + + +os=`./config.guess` + +# o/s switch block +case "$os" in + sparc-sun-sunos*) echo sunos4 ;; + sparc-sun-solaris1*) echo sunos4 ;; + sparc-sun-solaris2*) echo sunos5 ;; + alpha-dec-osf1) echo osf1 ;; + i386-*-solaris*) echo sunos5 ;; + *-*-linux*) echo linux ;; + *-*-openbsd*) echo openbsd ;; +esac + + +### Don't leave the variables set. +unset os diff --git a/bin/makedecright b/bin/makedecright new file mode 100755 index 0000000..dbea6eb --- /dev/null +++ b/bin/makedecright @@ -0,0 +1,120 @@ +# makeright +# @(#) makeright Version 1.12 (7/18/90). +##***********************************************************************/ +## */ +## Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +## */ +## This file is work-product resulting from the Xerox/Venue */ +## Agreement dated 18-August-1989 for support of Medley. */ +## */ +##***********************************************************************/ +# +# Feb. 6 1990 osamu: Add display option +# release option does not support yet. +# Apr.23 1990 osamu: add release option. +# +# Jul 18 1990 JDS: Add 'init' option for making init-loading emulators +# +# usage: makeright [display-option] [other-option] +# +# example: makeright single ; make lde for mmaped displayFB +# makeright multi ; make lde for cg3,cg6 +# makeright x ; make lde for X-windows +# makeright color ; make lde with color support in it. +# makeright multi release ; make release version of lde for cg3,cg6 +# makeright init ; make lde for loading INIT.DLINIT b/w only +# +# makeright multi requires directory "maiko/${osversion}.${architecture}-multi" +# (ex. maiko/sunos4.sparc-multi) +# object files are stored there. +# +# makeright init requires directory "maiko/init.${architecture} +# +# Note: X11R4 environment link shared libraries. +# lde need X library. If lde links shared libraries, +# X shared libraries are needed at run time. +# +# Hide X shared libraries from link libraries search path. +setenv LD_LIBRARY_PATH /usr/local/lib +set RELDIR = ../RELEASE/ + +if($1 == "") then + set display=single +else + if($1 == "release") then + switch($2) + case single: + set display = single + breaksw + case multi: + set display = multi + breaksw + case x: + set display = x + breaksw + default: + makeright single release + makeright multi release + makeright x release + exit + breaksw + endsw + else + set display=$1 + endif +endif + +if( $#argv > 0 ) then + shift +endif + +set architecture = dec3100 +set osversion = ultrix +switch($display) + case init: + set display = single + set releasename = init.${architecture} + set ldename = ldeinit + breaksw + case single: + set releasename = ${osversion}.${architecture} + set ldename = ldesingle + breaksw + case multi: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldemulti + breaksw + case x: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldex + breaksw + default: + echo "display-option: $display is not supported." + exit + breaksw +endsw +set releaseflg = 0 +if( "$1" == "release" ) then + set releaseflg = 1 + if($display != single) then + if( !(-e usermakefile-${releasename})) then + ln usermakefile-${osversion}.${architecture} usermakefile-${releasename} + endif + endif +else + set releaseflg = 0 +endif +set installdir = ${RELDIR}install.${osversion}.${architecture}/ + +#if($display == single ) then +# set releasename = ${osversion}.${architecture} +#else +# set releasename = ${osversion}.${architecture}-${display} +#endif +echo start making lde for ${releasename}. +# then finally do the make, including the right stuff +# With makefile-tail merged, this should only take ONE make command.... +make RELEASENAME=${releasename} INSDIR=${installdir} LDENAME=${ldename} \ + OSARCHNAME=${osversion}.${architecture} \ + -f makefile-header -f makefile-${releasename} \ + -f makefile-tail $* diff --git a/bin/makefile-ISC.i386-x b/bin/makefile-ISC.i386-x new file mode 100755 index 0000000..aa0e7dd --- /dev/null +++ b/bin/makefile-ISC.i386-x @@ -0,0 +1,64 @@ +# Options for SunOS4, SPARC and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +FPFLAGS = +DFLAGS = -DFSERROR -DAIX -DSYSVONLY -DSYSVSIGNALS -DNOASM -DLOGINT -DNOPIXRECT $(XFLAGS) -DBYTESWAP -DAIXPS2 -DFLTINT -D_I386 -DNOETHER -DFORKCOMM +LDFLAGS = -lX11 -lc -lm -lbsd + +INLINE = +BITBLTFILE = +# for the files that need to be included in byte-swapped implementations: +BYTESWAPFILES = $(OBJECTDIR)byteswapfns$(OEXT) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O -fstrength-reduce -fcombine-regs +DISPOPTFLAGS = -O -fstrength-reduce -fcombine-regs -finline-functions +CC = /gcc/gcc + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)profile.h + $(CC) $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-aix.ps2-x b/bin/makefile-aix.ps2-x new file mode 100755 index 0000000..85b59a3 --- /dev/null +++ b/bin/makefile-aix.ps2-x @@ -0,0 +1,64 @@ +# Options for SunOS4, SPARC and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +FPFLAGS = +DFLAGS = -DFSERROR -DAIX -D_BSD -DNOASM -DLOGINT -DNOPIXRECT $(XFLAGS) -DBYTESWAP -DAIXPS2 -DFLTINT -D_I386 -DNOETHER -DFORKCOMM +LDFLAGS = -lX11 -lc -lm -lbsd + +INLINE = +BITBLTFILE = +# for the files that need to be included in byte-swapped implementations: +BYTESWAPFILES = $(OBJECTDIR)byteswapfns$(OEXT) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O -fstrength-reduce -fcombine-regs +DISPOPTFLAGS = -O -fstrength-reduce -fcombine-regs -finline-functions +CC = gcc + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)profile.h + $(CC) $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-aix.rs6000-x b/bin/makefile-aix.rs6000-x new file mode 100755 index 0000000..47b090d --- /dev/null +++ b/bin/makefile-aix.rs6000-x @@ -0,0 +1,66 @@ +# Options for AIX 3.1, IBM RISC System/6000, and X-Windows +DEMO = +EURO = +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O. +#OPTFLAGS = -g +OPTFLAGS = -O +DISPOPTFLAGS = -O +FPFLAGS = + +DFLAGS = -DFSERROR -DNEW_STORAGE -DAIX -D_BSD -DNOASM -DNOPIXRECT -DNOETHER \ + -DRS6000 -DFORKCOMM -DLOGINT -DBIGATOMS -DNOFORN $(DEMO) $(EURO) $(XFLAGS) +LDFLAGS = -lX11 -lc -lm -lbsd +LDELDFLAGS = -lX11 -lc -lm -lbsd + + +INLINE = +BITBLTFILE = +BYTESWAPFILES = $(OBJECTDIR)byteswap$(OEXT) + +OBJECTDIR = ../$(RELEASENAME)/ + +# don't need ldeether on this machine, so omit it from here: + +default : ../$(OSARCHNAME)/lde + +# Special rules to create xc.o on IBM RISC-system/6000's: + +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-domain.mc68020-x b/bin/makefile-domain.mc68020-x new file mode 100755 index 0000000..4661808 --- /dev/null +++ b/bin/makefile-domain.mc68020-x @@ -0,0 +1,74 @@ +# Options for Domain/OS, APOLLO Workstation 680x0, and X-Window + +CLXFLAGS = -DCLX -DTCP_NODELAY + +CLXFILES = $(OBJECTDIR)socket.o \ + $(OBJECTDIR)socdvr.o + + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o \ + $(CLXFILES) + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g -O -W0,-natural +DISPOPTFLAGS = -g -O -W0,-natural +FPFLAGS = +DFLAGS = -DAPOLLO -DFSERROR -DNEW_STORAGE -DNOFORN \ + -DFORKCOMM -DLOGINT -DBIGATOMS $(XFLAGS) \ + -DNOETHER -DNOASM -DNOEUROKBD + +LDFLAGS = -lX11 -lc -lm +LDELDFLAGS = -lX11 -lc -lm +MAIN = main + +INLINE = # $(SRCDIR)dsp68K.il +BITBLTFILE = # $(OBJECTDIR)bbt68k.o +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde # ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Apollo + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.i $(INCDIR)lispemul.h +# $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-dos b/bin/makefile-dos new file mode 100755 index 0000000..9d28e7d --- /dev/null +++ b/bin/makefile-dos @@ -0,0 +1,631 @@ +AFLAGS = /T +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj + + +ADMINFILES = makefile mkvdate.c optck.c + +LPFILES = lpmain.obj lpread.obj lpsolve.obj lpwrite.obj lpdual.obj lptran.obj + +KEY = keytstno.obj + +CFLAGS = -DBIGATOMS -DNEW_STORAGE -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT \ + -DNOFORN -DNOETHER -DNOVERSION -DLPSOLVE -g + +LDFLAGS = -g graphics.lib binmode.lib mouse.lib + +RM = del + +SRCFILES = conspage.c gcoflow.c shift.c dbgtool.c gcr.c gcrcell.c llstk.c gcscan.c loopsops.c storage.c allocmds.c dir.c gvar2.c lowlev1.c subr.c arith2.c hacks.c lowlev2.c subr0374.c arith3.c doscomm.c hardrtn.c lsthandl.c sxhash.c arith4.c draw.c main.c testtool.c array.c dsk.c inet.c misc7.c timer.c array2.c dspif.c initdsp.c miscn.c typeof.c array3.c initkbd.c ubf1.c array4.c dspsubrs.c initsout.c mkatom.c ubf2.c array5.c eqf.c intcall.c mkcell.c ubf3.c array6.c ether.c mkvdate.c ufn.c atom.c findkey.c kbdsubrs.c mouseif.c ufs.c bbtsub.c foreign.c keyevent.c unixcomm.c bin.c fp.c keylib.c binds.c asmbbt.c fvar.c mvs.c unwind.c bitblt.c gc.c uraid.c blt.c gc2.c kprint.c keytstno.c keytst.c osmsg.c usrsubr.c byteswap.c gcarray.c perrno.c ldeboot.c ldeether.c uutils.c carcdr.c gccode.c rawcolor.c vars3.c gcfinal.c ldsout.c return.c vmemsave.c chardev.c gchtfind.c lineblt8.c rpc.c xc.c common.c gcmain3.c lisp2c.c rplcons.c z2.c find-dsp.l dsphack.l xmkicon.c xbbt.c xinit.c xscroll.c xcursor.c xlspwin.c xrdopt.c xwinman.c dosmouse.c vesafns.asm vesainit.c vgainit.c kbdif.c dspsparc.il copyright launch.asm lpread.c lpsolve.c lpmain.c lpwrite.c lpdual.c lptran.c + +OFILES = conspage.obj gcoflow.obj shift.obj dbgtool.obj gcr.obj gcrcell.obj llstk.obj gcscan.obj loopsops.obj storage.obj allocmds.obj dir.obj gvar2.obj lowlev1.obj subr.obj arith2.obj hacks.obj lowlev2.obj subr0374.obj arith3.obj doscomm.obj hardrtn.obj lsthandl.obj sxhash.obj arith4.obj draw.obj main.obj testtool.obj array.obj dsk.obj inet.obj misc7.obj timer.obj array2.obj dspif.obj initdsp.obj miscn.obj typeof.obj array3.obj initkbd.obj ubf1.obj array4.obj dspsubrs.obj initsout.obj mkatom.obj ubf2.obj array5.obj eqf.obj intcall.obj mkcell.obj ubf3.obj array6.obj ether.obj ufn.obj atom.obj findkey.obj kbdsubrs.obj mouseif.obj ufs.obj bbtsub.obj foreign.obj keyevent.obj unixcomm.obj bin.obj fp.obj keylib.obj binds.obj fvar.obj mvs.obj unwind.obj bitblt.obj gc.obj uraid.obj blt.obj gc2.obj kprint.obj osmsg.obj usrsubr.obj byteswap.obj gcarray.obj perrno.obj uutils.obj carcdr.obj asmbbt.obj gccode.obj vars3.obj gcfinal.obj ldsout.obj return.obj vmemsave.obj chardev.obj gchtfind.obj lineblt8.obj rpc.obj xc.obj common.obj gcmain3.obj lisp2c.obj rplcons.obj z2.obj vdate.obj $(KEY) $(COLORFILES) $(ARCHFILES) $(LPFILES) + + +HFILES = address.h adr68k.h arith.h cell.h dbprint.h display.h dspif.h ifpage.h iopage.h lispemul.h lispmap.h lsptypes.h miscstat.h lspglob.h array.h bb.h bitblt.h debug.h devconf.h dspdata.h ether.h fast_dsp.h fp.h gc.h hdw_conf.h initatms.h inlinec.h keyboard.h lispver1.h lispver2.h lldsp.h locfile.h mouseif.h my.h opcodes.h osmsg.h pilotbbt.h print.h profile.h return.h stack.h stream.h subrs.h sysatms.h timeout.h tos1defs.h tosfns.h tosret.h vmemsave.h xdefs.h xbitmaps.h xkeymap.h + + + +bigvm: + CFLAGS = $(CFLAGS) -DBIGVM -DNEWCDRCODRING + make -f foot emul.exe + +emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(RM) vdate.c + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +main.o : lispemul.h address.h lsptypes.h adr68k.h stack.h lspglob.h lispmap.h ifpage.h iopage.h return.h debug.h profile.h + + + + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +medley.exe: launch.obj + TLINK launch,medley + +launch.obj: launch.asm + + # xc.obj: xc.s + # tasm /ml xc.s + # + #xc.s: xc.c + # rsh sparky (cd /users/nilsson/curr ; gcc-make $* ) + +vdate.obj : mkvdate.exe + mkvdate > vdate.c + $(CC) vdate.c -c $@ + +mkvdate.exe : ../src/mkvdate.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mkvdate.c + del copts + +xc.obj : ../src/xc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/xc.c -I ../inc -c $@ + del copts + +lpmain.obj : ../src/lpmain.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpmain.c -I ../inc -c $@ + del copts + +lpsolve.obj : ../src/lpsolve.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpsolve.c -I ../inc -c $@ + del copts + +lpread.obj : ../src/lpread.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpread.c -I ../inc -c $@ + del copts + +lptran.obj : ../src/lptran.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lptran.c -I ../inc -c $@ + del copts + +lpdual.obj : ../src/lpdual.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpdual.c -I ../inc -c $@ + del copts + +lpwrite.obj : ../src/lpwrite.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lpwrite.c -I ../inc -c $@ + del copts + + + +conspage.obj : ../src/conspage.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/conspage.c -I ../inc -c $@ + del copts + +keytstno.obj : ../src/keytstno.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/keytstno.c -I ../inc -c $@ + del copts + +dosmouse.obj : ../src/dosmouse.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dosmouse.c -I ../inc -c $@ + del copts + +doskbd.obj : ../src/doskbd.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/doskbd.c -I ../inc -c $@ + del copts + +vesafns.obj : ../src/vesafns.asm + tasm /ml ..\src\vesafns.asm + +vesainit.obj : ../src/vesainit.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vesainit.c -I ../inc -c $@ + del copts + +vgainit.obj : ../src/vgainit.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vgainit.c -I ../inc -c $@ + del copts + +kbdif.obj : ../src/kbdif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/kbdif.c -I ../inc -c $@ + del copts + +gcoflow.obj : ../src/gcoflow.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcoflow.c -I ../inc -c $@ + del copts + +shift.obj : ../src/shift.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/shift.c -I ../inc -c $@ + del copts + +dbgtool.obj : ../src/dbgtool.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dbgtool.c -I ../inc -c $@ + del copts + +gcr.obj : ../src/gcr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcr.c -I ../inc -c $@ + del copts + +gcrcell.obj : ../src/gcrcell.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcrcell.c -I ../inc -c $@ + del copts + +llstk.obj : ../src/llstk.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/llstk.c -I ../inc -c $@ + del copts + +gcscan.obj : ../src/gcscan.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcscan.c -I ../inc -c $@ + del copts + +loopsops.obj : ../src/loopsops.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/loopsops.c -I ../inc -c $@ + del copts + +storage.obj : ../src/storage.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/storage.c -I ../inc -c $@ + del copts + +allocmds.obj : ../src/allocmds.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/allocmds.c -I ../inc -c $@ + del copts + +dir.obj : ../src/dir.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dir.c -I ../inc -c $@ + del copts + +gvar2.obj : ../src/gvar2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gvar2.c -I ../inc -c $@ + del copts + +lowlev1.obj : ../src/lowlev1.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lowlev1.c -I ../inc -c $@ + del copts + +subr.obj : ../src/subr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/subr.c -I ../inc -c $@ + del copts + +arith2.obj : ../src/arith2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/arith2.c -I ../inc -c $@ + del copts + +hacks.obj : ../src/hacks.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/hacks.c -I ../inc -c $@ + del copts + +lowlev2.obj : ../src/lowlev2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lowlev2.c -I ../inc -c $@ + del copts + +subr0374.obj : ../src/subr0374.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/subr0374.c -I ../inc -c $@ + del copts + +arith3.obj : ../src/arith3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/arith3.c -I ../inc -c $@ + del copts + +doscomm.obj : ../src/doscomm.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/doscomm.c -I ../inc -c $@ + del copts + +hardrtn.obj : ../src/hardrtn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/hardrtn.c -I ../inc -c $@ + del copts + +lsthandl.obj : ../src/lsthandl.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lsthandl.c -I ../inc -c $@ -Le + del copts + +sxhash.obj : ../src/sxhash.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/sxhash.c -I ../inc -c $@ + del copts + +arith4.obj : ../src/arith4.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/arith4.c -I ../inc -c $@ + del copts + +draw.obj : ../src/draw.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/draw.c -I ../inc -c $@ + del copts + +main.obj : ../src/main.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/main.c -I ../inc -c $@ + del copts + +testtool.obj : ../src/testtool.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/testtool.c -I ../inc -c $@ + del copts + +array.obj : ../src/array.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array.c -I ../inc -c $@ + del copts + +dsk.obj : ../src/dsk.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dsk.c -I ../inc -c $@ + del copts + +inet.obj : ../src/inet.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/inet.c -I ../inc -c $@ + del copts + +misc7.obj : ../src/misc7.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/misc7.c -I ../inc -c $@ + del copts + +timer.obj : ../src/timer.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/timer.c -I ../inc -c $@ + del copts + +array2.obj : ../src/array2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array2.c -I ../inc -c $@ + del copts + +dspif.obj : ../src/dspif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dspif.c -I ../inc -c $@ + del copts + +initdsp.obj : ../src/initdsp.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/initdsp.c -I ../inc -c $@ + del copts + +miscn.obj : ../src/miscn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/miscn.c -I ../inc -c $@ + del copts + +typeof.obj : ../src/typeof.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/typeof.c -I ../inc -c $@ + del copts + +array3.obj : ../src/array3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array3.c -I ../inc -c $@ + del copts + +initkbd.obj : ../src/initkbd.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/initkbd.c -I ../inc -c $@ + del copts + +ubf1.obj : ../src/ubf1.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ubf1.c -I ../inc -c $@ + del copts + +array4.obj : ../src/array4.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array4.c -I ../inc -c $@ + del copts + +dspsubrs.obj : ../src/dspsubrs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/dspsubrs.c -I ../inc -c $@ + del copts + +initsout.obj : ../src/initsout.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/initsout.c -I ../inc -c $@ + del copts + +mkatom.obj : ../src/mkatom.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mkatom.c -I ../inc -c $@ + del copts + +ubf2.obj : ../src/ubf2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ubf2.c -I ../inc -c $@ + del copts + +array5.obj : ../src/array5.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array5.c -I ../inc -c $@ + del copts + +eqf.obj : ../src/eqf.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/eqf.c -I ../inc -c $@ + del copts + +intcall.obj : ../src/intcall.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/intcall.c -I ../inc -c $@ + del copts + +mkcell.obj : ../src/mkcell.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mkcell.c -I ../inc -c $@ + del copts + +ubf3.obj : ../src/ubf3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ubf3.c -I ../inc -c $@ + del copts + +array6.obj : ../src/array6.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/array6.c -I ../inc -c $@ + del copts + +ether.obj : ../src/ether.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ether.c -I ../inc -c $@ + del copts + +ufn.obj : ../src/ufn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ufn.c -I ../inc -c $@ + del copts + +atom.obj : ../src/atom.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/atom.c -I ../inc -c $@ + del copts + +findkey.obj : ../src/findkey.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/findkey.c -I ../inc -c $@ + del copts + +kbdsubrs.obj : ../src/kbdsubrs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/kbdsubrs.c -I ../inc -c $@ + del copts + +mouseif.obj : ../src/mouseif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mouseif.c -I ../inc -c $@ + del copts + +ufs.obj : ../src/ufs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ufs.c -I ../inc -c $@ + del copts + +bbtsub.obj : ../src/bbtsub.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/bbtsub.c -I ../inc -c $@ + del copts + +foreign.obj : ../src/foreign.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/foreign.c -I ../inc -c $@ + del copts + +keyevent.obj : ../src/keyevent.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/keyevent.c -I ../inc -c $@ + del copts + +unixcomm.obj : ../src/unixcomm.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/unixcomm.c -I ../inc -c $@ + del copts + +bin.obj : ../src/bin.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/bin.c -I ../inc -c $@ + del copts + +fp.obj : ../src/fp.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/fp.c -I ../inc -c $@ + del copts + +keylib.obj : ../src/keylib.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/keylib.c -I ../inc -c $@ + del copts + +binds.obj : ../src/binds.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/binds.c -I ../inc -c $@ + del copts + +fvar.obj : ../src/fvar.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/fvar.c -I ../inc -c $@ + del copts + +mvs.obj : ../src/mvs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/mvs.c -I ../inc -c $@ + del copts + +unwind.obj : ../src/unwind.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/unwind.c -I ../inc -c $@ + del copts + +bitblt.obj : ../src/bitblt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/bitblt.c -I ../inc -c $@ + del copts + +gc.obj : ../src/gc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gc.c -I ../inc -c $@ + del copts + +uraid.obj : ../src/uraid.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/uraid.c -I ../inc -c $@ + del copts + +blt.obj : ../src/blt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/blt.c -I ../inc -c $@ + del copts + +gc2.obj : ../src/gc2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gc2.c -I ../inc -c $@ + del copts + +kprint.obj : ../src/kprint.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/kprint.c -I ../inc -c $@ + del copts + +osmsg.obj : ../src/osmsg.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/osmsg.c -I ../inc -c $@ + del copts + +usrsubr.obj : ../src/usrsubr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/usrsubr.c -I ../inc -c $@ + del copts + +byteswap.obj : ../src/byteswap.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/byteswap.c -I ../inc -c $@ + del copts + +gcarray.obj : ../src/gcarray.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcarray.c -I ../inc -c $@ + del copts + +perrno.obj : ../src/perrno.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/perrno.c -I ../inc -c $@ + del copts + +uutils.obj : ../src/uutils.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/uutils.c -I ../inc -c $@ + del copts + +carcdr.obj : ../src/carcdr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/carcdr.c -I ../inc -c $@ + del copts + +asmbbt.obj : ../src/asmbbt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/asmbbt.c -I ../inc -c $@ + del copts + +gccode.obj : ../src/gccode.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gccode.c -I ../inc -c $@ + del copts + +vars3.obj : ../src/vars3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vars3.c -I ../inc -c $@ + del copts + +gcfinal.obj : ../src/gcfinal.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcfinal.c -I ../inc -c $@ + del copts + +ldsout.obj : ../src/ldsout.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/ldsout.c -I ../inc -c $@ + del copts + +return.obj : ../src/return.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/return.c -I ../inc -c $@ + del copts + +vmemsave.obj : ../src/vmemsave.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/vmemsave.c -I ../inc -c $@ + del copts + +chardev.obj : ../src/chardev.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/chardev.c -I ../inc -c $@ + del copts + +gchtfind.obj : ../src/gchtfind.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gchtfind.c -I ../inc -c $@ + del copts + +lineblt8.obj : ../src/lineblt8.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lineblt8.c -I ../inc -c $@ + del copts + +rpc.obj : ../src/rpc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/rpc.c -I ../inc -c $@ + del copts + +common.obj : ../src/common.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/common.c -I ../inc -c $@ + del copts + +gcmain3.obj : ../src/gcmain3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/gcmain3.c -I ../inc -c $@ + del copts + +lisp2c.obj : ../src/lisp2c.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/lisp2c.c -I ../inc -c $@ + del copts + +rplcons.obj : ../src/rplcons.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/rplcons.c -I ../inc -c $@ + del copts + +z2.obj : ../src/z2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../src/z2.c -I ../inc -c $@ + del copts + diff --git a/bin/makefile-header b/bin/makefile-header new file mode 100755 index 0000000..2180d62 --- /dev/null +++ b/bin/makefile-header @@ -0,0 +1,35 @@ +# Default values for Maiko makefile variables +# These get overridden by OS and hardware-specific stuff +# in sub-makefiles + +SRCDIR = ../src/ +INCDIR = ../inc/ +INCLUDEDIR = ../include/ +LIBDIR = ../lib +BINDIR = ./ +RELDIR = ../RELEASE/ +MAIN = _main +RANLIB = ranlib +AR = ar rcv +ANSICC = $(CC) + +# for the files that need to be included in byte-swapped implementations: +BYTESWAPFILES = +SXHASHFILE = +BITBLTFILE = +DLPIFILES = + +# for files needed by X windows version +XFILES = + +# for files needed by color (actually files NOT needed by X) +COLORFILES = + +# Flags to include inthe linking of various S/W +# LDFLAGS - in emulator itself (e.g., ldesingle) +# LDELDFLAGS - in "lde" unix-comm forker. +# LDEETHERLDFLAGS - in "ldeether" ethernet kick-start +LDFLAGS = +LDELDFLAGS = +LDEETHERLDFLAGS = + diff --git a/bin/makefile-hpux.hp9000-x b/bin/makefile-hpux.hp9000-x new file mode 100755 index 0000000..f26ccf3 --- /dev/null +++ b/bin/makefile-hpux.hp9000-x @@ -0,0 +1,93 @@ +#************************************************************************/ +#* */ +#* (C) Copyright 1991 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# Options for HP Series 700 and 800, under HPUX and X-windows + +CC = gcc + +#XFILES = $(OBJECTDIR)XClose.o \ +# $(OBJECTDIR)Cursor.o \ +# $(OBJECTDIR)XWindow.o \ +# $(OBJECTDIR)DoRing.o \ +# $(OBJECTDIR)DoScroll.o \ +# $(OBJECTDIR)XEvent.o \ +# $(OBJECTDIR)XGravity.o \ +# $(OBJECTDIR)XInit.o \ +# $(OBJECTDIR)Xevinit.o \ +# $(OBJECTDIR)Xkbdmus.o \ +# $(OBJECTDIR)Xlspwin.o \ +# $(OBJECTDIR)Xbbt.o \ +# $(OBJECTDIR)Xkbd.o \ +# $(OBJECTDIR)Xmkicon.o \ +# $(OBJECTDIR)Xopendsp.o \ +# $(OBJECTDIR)Xrdopt.o \ +# $(OBJECTDIR)Xreconf.o \ +# $(OBJECTDIR)XScroll.o \ +# $(OBJECTDIR)Xscrolb.o \ +# $(OBJECTDIR)XCursor.o \ +# $(OBJECTDIR)XMouse.o \ +# $(OBJECTDIR)Xsubwin.o \ +# $(OBJECTDIR)Xcolor.o \ +# $(OBJECTDIR)Xwinman.o + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O +Obb990 -- latter enables large-file (xc) opt. +OPTFLAGS = -O # +Onolimit +DISPOPTFLAGS = -O # +Onolimit +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DAIX -DFORKCOMM -DLOGINT $(XFLAGS) \ + -DHPUX -DNOETHER -DNOPIXRECT -DHP9000 -DHPTIMERBUG \ + -DSYSVONLY \ + -DNOFORN \ + -DRELEASE=201 + +LDFLAGS = -L/usr/lib/X11R4 -lX11 -lm -lBSD +LDELDFLAGS = $(LDFLAGS) +MAIN = main + +# -Dsparc? + +INLINE = +BITBLTFILE = +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on HP/Apollo Series 700 or 800 + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -c $(OPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-init.sgi b/bin/makefile-init.sgi new file mode 100755 index 0000000..b1ddbaf --- /dev/null +++ b/bin/makefile-init.sgi @@ -0,0 +1,100 @@ +# +# +#************************************************************************/ +#* */ +#* (C) Copyright 1991 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# Options for SGI Indigo under IRIX operating system, X windows. + + +XFILES = $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xwinman.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)kbdif.o \ + $(OBJECTDIR)xinit.o + +### XFILES used to include: + +#XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xcolor.o \ + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O +OPTFLAGS = -g +DISPOPTFLAGS = -g +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DAIX -DFORKCOMM -DLOGINT $(XFLAGS) \ + -D_IEEE -DINDIGO -DSYSVONLY -DNOETHER -DNOPIXRECT -DSYSVSIGNALS -DNOFORN \ + -DNOASM -DBIGATOMS -DINIT -DNOVERSION -DBIGVM -DNEWCDRCODING +LDFLAGS = -L/usr/lib/X11R4 -L/d/scsistr2/guest/gcc2 -lsun -lX11 -lm +LDELDFLAGS = $(LDFLAGS) +# -Dsparc? + +CC = cc +RANLIB = touch +MAIN = main + +INLINE = +BITBLTFILE = +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on HP/Apollo Series 700 or 800 + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.i $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ +# $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ +# $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ +# $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ +# $(INCDIR)inln68k.h +# $(CC) -c $(DISPOPTFLAGS) $(SRCDIR)xc.i -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-init.sparc b/bin/makefile-init.sparc new file mode 100755 index 0000000..93cc964 --- /dev/null +++ b/bin/makefile-init.sparc @@ -0,0 +1,120 @@ +#************************************************************************/ +#* */ +#* Makefile for MAKEINIT processing. */ +#* */ +#* $Id: makefile-init.sparc,v 1.4 2001/12/26 22:17:08 sybalsky Exp $ */ +#* */ +#************************************************************************/ + + + + +#************************************************************************/ +#* */ +#* (C) Copyright 1991,8 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# Options for SPARC under Solaris-2 operating system, X windows. + +CC = gcc + +XFILES = $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xwinman.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)kbdif.o \ + $(OBJECTDIR)xinit.o + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -DXV11R4 -I/usr/openwin/include + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -g for MAKEINIT, as it needs debugging often. +OPTFLAGS = -g3 -O +DISPOPTFLAGS = -g3 -O + +MAIN = main + +# Set any debugging options in DEBUGFLAGS. E.g., to enable stack +# checking, use -DSTACKCHECK; to enable the fn-call-time stack +# check, use -DFNSTKCHECK. + +DEBUGFLAGS = # -DSTACKCHECK -DFNSTKCHECK + +MACHINEFLAGS = -DOS5 -DAIX -DUSE_DLPI -DNOPIXRECT \ + -I$(OPENWINHOME)/include -DSYSVSIGNALS -DSYSVONLY \ + -DOLD_CURSOR -DLOGINT -DFORKCOMM -DLOCK_X_UPDATES + +INLINEFLAGS = + +FPFLAGS = + +# The LDEINIT wants to have NOVERSION set, so we don't hang up on +# any change-over in versions. + +DFLAGS = -DINIT \ + $(XFLAGS) \ + $(DEBUGFLAGS) \ + $(MACHINEFLAGS) \ + $(INLINEFLAGS) \ + -DNOVERSION -DRELEASE=351 + + +LDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDELDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDEETHERLDFLAGS = -lc -lm -lsocket -lnsl + +# SPARC Assemble optimize check +# DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = + +DLPIFILES = $(OBJECTDIR)dlpi.o + +OBJECTDIR = ../$(RELEASENAME)/ +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +#RANLIB = touch + + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c with GCC + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.i $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ +# $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ +# $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ +# $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ +# $(INCDIR)inln68k.h +# $(CC) -c $(DISPOPTFLAGS) $(SRCDIR)xc.i -o $(OBJECTDIR)xc.o + + + diff --git a/bin/makefile-init.sparc-multi b/bin/makefile-init.sparc-multi new file mode 100755 index 0000000..90a687b --- /dev/null +++ b/bin/makefile-init.sparc-multi @@ -0,0 +1,104 @@ +# Options for SunOS4 and SPARC +# @(#) makefile-init.sparc Version 1.0 (7/18/90). +# +# MAKE AN INIT-LOADING emulator for sparc. +# +#************************************************************************/ +#* */ +#* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -g for init building. +OPTFLAGS = -g +DISPOPTFLAGS = -g +FPFLAGS = +# Now share the same ldesingle with COLOR(CG4)/MONO Suns +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +# for bigatom work, removed -DSPARCDISP -DSUN4_OS4_IL +DFLAGS = -DINIT -DKBINT -DFSERROR -DOS4 -DOS4_TYPE4BUG -DCOLOR \ + -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DDISPLAYBUFFER -DFORKCOMM \ + -DBIGATOMS -DNOASM -DNOFORN -DRELEASE=210 # -DNOVERSION -DRELEASE=201 + +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +#-Dsparc? +INLINE = # $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o +BYTESWAPFILES= $(OBJECTDIR)/byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o + +default: ../$(OSARCHNAME)/$(LDENAME) +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -P $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dspatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dspatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dspatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dspatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dspatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dspatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +############ +# +# SPECIAL xc.o for debugging +# +############ +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-init.sparc~ b/bin/makefile-init.sparc~ new file mode 100755 index 0000000..8a7462c --- /dev/null +++ b/bin/makefile-init.sparc~ @@ -0,0 +1,90 @@ +# +# +#************************************************************************/ +#* */ +#* (C) Copyright 1991,8 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# Options for SPARC under Solaris-2 operating system, X windows. + + +XFILES = $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xwinman.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)kbdif.o \ + $(OBJECTDIR)xinit.o + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -DXV11R4 -I/usr/openwin/include + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g +DISPOPTFLAGS = -g + +MAIN = main + +FPFLAGS = +DFLAGS = -DINIT -DFSERROR -DNEW_STORAGE -DOS5 -DAIX -DUSE_DLPI \ + -DOLD_CURSOR -DLOGINT $(XFLAGS) \ + -DNOPIXRECT -DFORKCOMM -DLOCK_X_UPDATES \ + -I$(OPENWINHOME)/include -DSYSVSIGNALS -DSYSVONLY \ + -DNOVERSION -DRELEASE=350 +LDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDELDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDEETHERLDFLAGS = -lc -lm -lsocket -lnsl + +# SPARC Assemble optimize check +# DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = + +DLPIFILES = $(OBJECTDIR)dlpi.o + +OBJECTDIR = ../$(RELEASENAME)/ +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +CC = gcc +#RANLIB = touch + + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c with GCC + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.i $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ +# $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ +# $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ +# $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ +# $(INCDIR)inln68k.h +# $(CC) -c $(DISPOPTFLAGS) $(SRCDIR)xc.i -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-irix.sgi-x b/bin/makefile-irix.sgi-x new file mode 100755 index 0000000..c108b9f --- /dev/null +++ b/bin/makefile-irix.sgi-x @@ -0,0 +1,112 @@ +# +#************************************************************************/ +#* */ +#* (C) Copyright 1991 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# Options for SGI Indigo under IRIX operating system, X windows. + +ANSICC = gcc + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + +OLDXFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o + +LPFILES = $(OBJECTDIR)lpmain.o \ + $(OBJECTDIR)lpread.o \ + $(OBJECTDIR)lpsolve.o \ + $(OBJECTDIR)lpkit.o +# $(OBJECTDIR)lptran.o \ +# $(OBJECTDIR)lpdual.o \ +# $(OBJECTDIR)lpwrite.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2 -Olimit 1600 +OPTFLAGS = -O2 -Olimit 1600 +ANSIOPTFLAGS = -O4 +DISPOPTFLAGS = -O2 -Olimit 1600 +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DAIX -DFORKCOMM -DLOGINT $(XFLAGS)\ + -D_IEEE -DINDIGO -DSYSVONLY -DNOETHER -DNOPIXRECT -DSYSVSIGNALS -DNOFORN \ + -DNOASM -DBIGATOMS -DLPSOLVE -DNOVERSION -DBIGVM -DNEWCDRCODING +LDFLAGS = -L/usr/lib/X11R4 -L/d/scsistr2/guest/gcc2 -lX11 -ll -lm -ly -lsun +LDELDFLAGS = $(LDFLAGS) +# -Dsparc? + +CC = cc +RANLIB = touch +MAIN = main + +INLINE = +BITBLTFILE = +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on HP/Apollo Series 700 or 800 + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.i $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ +# $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ +# $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ +# $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ +# $(INCDIR)inln68k.h +# $(CC) -c $(DISPOPTFLAGS) $(SRCDIR)xc.i -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x new file mode 100755 index 0000000..19192e1 --- /dev/null +++ b/bin/makefile-linux.386-x @@ -0,0 +1,103 @@ +# Options for Linux, Intel 386/486 and X-Window + +CC = gcc + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) # $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -g3 +DISPOPTFLAGS = -O2 -g3 +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DLINUX -DAIX -DOLD_CURSOR -DUSETERMIOS \ + -DBYTESWAP -DFORKCOMM -DNOFORN -DLOGINT $(XFLAGS) \ + -DRELEASE=351 -D__USE_BSD + +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lcrypt +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lcrypt + +INLINE = # $(SRCDIR)dspSPARC.il +BITBLTFILE = # $(OBJECTDIR)bbtSPARC.o +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +#$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ +# $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ +# $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ +# $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ +# $(INCDIR)inln68k.h +# cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + +############ +# +# SPECIAL xc.o for debugging +# +############ +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h \ + $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) $(DISPRFLAGS) -UOPDISP $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-osf1.dec-x b/bin/makefile-osf1.dec-x new file mode 100755 index 0000000..2fdd462 --- /dev/null +++ b/bin/makefile-osf1.dec-x @@ -0,0 +1,69 @@ +# Options for Ultrix, DECStation 3100, and X-Window + + +CC = cc + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o + +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -Olimit 999 +DISPOPTFLAGS = -O2 -Olimit 999 + +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DAIX -DOLD_CURSOR -DNOPIXRECT -DBYTESWAP \ +-DFORKCOMM -DLOGINT -DSYS5 -DDEC3100 -DNOFORN -DNOETHER -DBIGATOMS \ + -DDECSTN -D_BSD -DOSF1 $(XFLAGS) +LDFLAGS = -lX11 -lc -lm +LDELDFLAGS = -lX11 -lc -lm +# -Dsparc? +INLINE = + + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -c $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-riscos.mips-x b/bin/makefile-riscos.mips-x new file mode 100755 index 0000000..2ac6e03 --- /dev/null +++ b/bin/makefile-riscos.mips-x @@ -0,0 +1,81 @@ +# Options for Ultrix, RISCStation, and X-Window + + +# CC = gcc + +# CLXFLAGS = -DCLX -DTCP_NODELAY + +# CLXFILES = $(OBJECTDIR)socket.o \ +# $(OBJECTDIR)socketdvr.o + + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o \ + $(CLXFILES) + +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O; the Olimit lets us optimize the BIG files +# (i.e., bitblt* and xc). +OPTFLAGS = -O -Olimit 1000 +DISPOPTFLAGS = -O -Olimit 1000 +FPFLAGS = +DFLAGS = -DFSERROR \ + -DNEW_STORAGE -DAIX -DOLD_CURSOR -DNOPIXRECT -DRISCOS \ + -DSYSVSIGNALS -DSYSVONLY \ + -DBIGATOMS -DFORKCOMM -DLOGINT -DSYS5 -DNOETHER -DNOFORN \ + $(XFLAGS) -I/usr/include -I/usr/include/bsd +LDFLAGS = -lX11 -lc -lm -lbsd +LDELDFLAGS = $(LDFLAGS) + +MAIN = main + +# -Dsparc? +INLINE = + + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on MIPS RISCstation. + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + $(CC) -c $(DISPOPTFLAGS) $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-sunos3.mc68020 b/bin/makefile-sunos3.mc68020 new file mode 100755 index 0000000..f939111 --- /dev/null +++ b/bin/makefile-sunos3.mc68020 @@ -0,0 +1,30 @@ +# Options for sun3 and mc68020 + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +DFLAGS = -DKBINT -DNEW_STORAGE -DFSERROR -DOPDISP -DUNSAFE -DSUN3_OS3_IL -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +OBJECTDIR = ../sunos3.mc68020/ + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos3.mc68020-multi b/bin/makefile-sunos3.mc68020-multi new file mode 100755 index 0000000..b3bca72 --- /dev/null +++ b/bin/makefile-sunos3.mc68020-multi @@ -0,0 +1,38 @@ +# makefile-sunos4.mc68020-multi +# Options for SunOS4 and mc68020 for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos3.mc68020-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -g +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DKBINT -DFSERROR -DOPDISP -DUNSAFE -DSUN3_OS3_IL -DDISPLAYBUFFER -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncallmacro.h $(INCDIR)inlinedefsC.h \ + $(INCDIR)inlinedefs68K.h \ + $(INCDIR)inlinedefsSPARC.h $(INCDIR)fastdispatch.h \ + $(INCDIR)fastinlinedefs68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-sunos3.mc68020-x b/bin/makefile-sunos3.mc68020-x new file mode 100755 index 0000000..831f223 --- /dev/null +++ b/bin/makefile-sunos3.mc68020-x @@ -0,0 +1,58 @@ +# Options for sun3, mc68020 and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +DFLAGS = -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DSUN3_OS3_IL -DNEWBITBLT -DLOGINT $(XFLAGS) -DFORKCOMM -DBIGATOMS +LDFLAGS = -lX11 -lpixrect -lc -lm +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o + +OBJECTDIR = ../sunos3.mc68020-x/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos3.sparc b/bin/makefile-sunos3.sparc new file mode 100755 index 0000000..d086a18 --- /dev/null +++ b/bin/makefile-sunos3.sparc @@ -0,0 +1,67 @@ +# Options for SunOS3 and SPARC + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +FPFLAGS = +# JRB - I'm not 100% sure about these flags; someone should check... +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DFLTINT -DSPARCDISP -DOS4_TYPE4BUG -DOLD_CURSOR -DSUNDISPLAY -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +#-Dsparc? +INLINE = $(SRCDIR)dispSPARC.il + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)disphack.c: $(SRCDIR)disphack.lex + rm -f $(OBJECTDIR)disphack.c + lex -t $(SRCDIR)disphack.lex > $(OBJECTDIR)disphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-disp.c: $(SRCDIR)find-disp.lex + rm -f $(OBJECTDIR)find-disp.c + lex -t $(SRCDIR)find-disp.lex > $(OBJECTDIR)find-disp.c + +$(OBJECTDIR)find-disp: $(OBJECTDIR)find-disp.c + cc -o $(OBJECTDIR)find-disp $(OBJECTDIR)find-disp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-disp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-disp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)disphack: $(OBJECTDIR)disphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)disphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)disphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)disphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)disphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)disphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.1.i386 b/bin/makefile-sunos4.1.i386 new file mode 100755 index 0000000..9ce7cd6 --- /dev/null +++ b/bin/makefile-sunos4.1.i386 @@ -0,0 +1,44 @@ +# Options for i386SUN +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +#For debugging +OPTFLAGS = -g +FPFLAGS = +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DFLTINT -DNOASM -DOS4 -DI386 -DBYTESWAP -DCHECK -DLOGINT -DSUNDISPLAY -DFORKCOMM +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +INLINE = $(SRCDIR)disp386i.il + +OBJECTDIR = ../sunos4.i386/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on 386i + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncallmacro.h $(INCDIR)inlineC.h \ + $(INCDIR)n_op_inlineC.h $(SRCDIR)disp386i.il \ + $(INCDIR)dummy_entries.h \ + $(INCDIR)inline386i.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc -c -O -Qproduce .s $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.s + +#run c compiler to produce first pass assembly +#$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i +# rm -f $(OBJECTDIR)xc.s1 +# /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s $(INLINE) + rm -f $(OBJECTDIR)xc.s2 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s > $(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s2 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s2 diff --git a/bin/makefile-sunos4.1.i386-multi b/bin/makefile-sunos4.1.i386-multi new file mode 100755 index 0000000..c967efc --- /dev/null +++ b/bin/makefile-sunos4.1.i386-multi @@ -0,0 +1,46 @@ +# Options for sun4 and mc68020 + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O +DISPOPTFLAGS = -O +FPFLAGS = +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DI386 -DBYTESWAP -DCHECK -DLOGINT -DDISPLAYBUFFER -DSUNDISPLAY -DNEWBITBLT -DOPDISP -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +INLINE = $(SRCDIR)disp386i.il +BITBLTFILE=$(OBJECTDIR)bitblt386i.o + +OBJECTDIR = ../sunos4.i386-multi/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on 386i + +#run cpp to expand macros +$(OBJECTDIR)xc.s: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(SRCDIR)disp386i.il \ + $(INCDIR)inline386i.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc -c -O -Qproduce .s $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.s + +#run c compiler to produce first pass assembly +#$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i +# rm -f $(OBJECTDIR)xc.s1 +# /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s $(INLINE) + rm -f $(OBJECTDIR)xc.s2 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s > $(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s2 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s2 + diff --git a/bin/makefile-sunos4.1.mc68020 b/bin/makefile-sunos4.1.mc68020 new file mode 100755 index 0000000..dcedf56 --- /dev/null +++ b/bin/makefile-sunos4.1.mc68020 @@ -0,0 +1,36 @@ +# Options for sun4 and mc68020 + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# [I remove DISPLAYBUFFER option . +# You may run 'makeright multi'. -osamu '90/02/07] +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DOS4 -DSUN3_OS4_IL -DOS4_TYPE4BUG -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +OBJECTDIR = ../sunos4.mc68020/ + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-sunos4.1.mc68020-multi b/bin/makefile-sunos4.1.mc68020-multi new file mode 100755 index 0000000..49af8e2 --- /dev/null +++ b/bin/makefile-sunos4.1.mc68020-multi @@ -0,0 +1,38 @@ +# makefile-sunos4.mc68020-multi +# Options for SunOS4 and mc68020 for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos4.mc68020-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DOS4 -DSUN3_OS4_IL -DOS4_TYPE4BUG -DDISPLAYBUFFER -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DDISPLAYBUFFER -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-sunos4.1.mc68020-x b/bin/makefile-sunos4.1.mc68020-x new file mode 100755 index 0000000..7597cb8 --- /dev/null +++ b/bin/makefile-sunos4.1.mc68020-x @@ -0,0 +1,64 @@ +# Options for sun4, mc68020 and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# [I remove DISPLAYBUFFER option . +# You may run 'makeright x'. -osamu '90/02/27] +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DOS4 -DSUN3_OS4_IL -DOS4_TYPE4BUG -DNEWBITBLT -DLOGINT $(XFLAGS) -DFORKCOMM -DBIGATOMS +LDFLAGS = -lX11 -lpixrect -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o + +OBJECTDIR = ../sunos4.mc68020-x/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-sunos4.1.sparc b/bin/makefile-sunos4.1.sparc new file mode 100755 index 0000000..293d088 --- /dev/null +++ b/bin/makefile-sunos4.1.sparc @@ -0,0 +1,73 @@ +# Options for SunOS4 and SPARC +# @(#) makefile-sunos4.sparc Version 1.19 (5/9/90). +# +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g -O2 +DISPOPTFLAGS = -g +FPFLAGS = +# Now share the same ldesingle with COLOR(CG4)/MONO Suns +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DCOLOR -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DFORKCOMM -DBIGATOMS -DNOEUROKBD +LDFLAGS = -lsuntool -lsunwindow -lpixrect -ldld -lc -lm +# SPARC Assemble optimize check +DFLAGS:sh += optck.sh ; true +#-Dsparc? +INLINE = $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.1.sparc-color b/bin/makefile-sunos4.1.sparc-color new file mode 100755 index 0000000..2898905 --- /dev/null +++ b/bin/makefile-sunos4.1.sparc-color @@ -0,0 +1,71 @@ +# Options for SunOS4 and SPARC + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g +FPFLAGS = +# For COLOR, Add COLOR, remove OLD_CURSOR +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DFLTINT -DCOLOR -DNEWBITBLT -DSUNDISPLAY -DLOGINT -DFORKCOMM +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +# SPARC Assemble optimize check +DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = $(SRCDIR)dispSPARC.il +BITBLTFILE = $(OBJECTDIR)bitbltSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)Cldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)disphack.c: $(SRCDIR)disphack.lex + rm -f $(OBJECTDIR)disphack.c + lex -t $(SRCDIR)disphack.lex > $(OBJECTDIR)disphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-disp.c: $(SRCDIR)find-disp.lex + rm -f $(OBJECTDIR)find-disp.c + lex -t $(SRCDIR)find-disp.lex > $(OBJECTDIR)find-disp.c + +$(OBJECTDIR)find-disp: $(OBJECTDIR)find-disp.c + cc -o $(OBJECTDIR)find-disp $(OBJECTDIR)find-disp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-disp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-disp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)disphack: $(OBJECTDIR)disphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)disphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)disphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)disphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)disphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)disphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.1.sparc-multi b/bin/makefile-sunos4.1.sparc-multi new file mode 100755 index 0000000..b4c400c --- /dev/null +++ b/bin/makefile-sunos4.1.sparc-multi @@ -0,0 +1,79 @@ +# makefile-sunos4.sparc-multi +# @(#) makefile-sunos4.sparc-multi Version 1.6 (5/9/90). +# +# Options for SunOS4 and SPARC for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos4.sparc-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g -O2 +DISPOPTFLAGS = -g -O2 +FPFLAGS = +# Now share the same ldemulti for Mono-Medley & Color-Medley +# If you load MAIKOCOLOR.LCOM etc., you can use color functions + +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DCOLOR -DDISPLAYBUFFER -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DDISPLAYBUFFER -DFORKCOMM -DBIGATOMS -DNOEUROKBD +LDFLAGS = -lsuntool -lsunwindow -lpixrect -ldld -lc -lm +# SPARC Assemble optimize check +DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.1.sparc-x b/bin/makefile-sunos4.1.sparc-x new file mode 100755 index 0000000..d221ea7 --- /dev/null +++ b/bin/makefile-sunos4.1.sparc-x @@ -0,0 +1,121 @@ +# Options for SunOS4, SPARC and X-Window + +CLXFLAGS = -DCLX -DTCP_NODELAY + +CLXFILES = $(OBJECTDIR)socket.o \ + $(OBJECTDIR)socdvr.o + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o \ + $(CLXFILES) + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g +DISPOPTFLAGS = -g + +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DOLD_CURSOR -DNEWBITBLT -DLOGINT $(XFLAGS) -DFORKCOMM -DBIGATOMS -DNOEUROKBD +LDFLAGS = -lX11 -lpixrect -lc -lm -ldld +LDELDFLAGS = -Bstatic -lX11 -lpixrect -Bdynamic -lc -lm +# SPARC Assemble optimize check +DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + + +default: ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +########### debugging version of xc maker + + +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h #$(INCDIR)address.h \ +# $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ +# $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ +# $(INCDIR)tosfns.h $(INCDIR)inlineC.h +# cc $(DISPRFLAGS) -USPARCDISP -UOPDISP -DNOASM $(INLINE) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.i386 b/bin/makefile-sunos4.i386 new file mode 100755 index 0000000..9ce7cd6 --- /dev/null +++ b/bin/makefile-sunos4.i386 @@ -0,0 +1,44 @@ +# Options for i386SUN +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +#For debugging +OPTFLAGS = -g +FPFLAGS = +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DFLTINT -DNOASM -DOS4 -DI386 -DBYTESWAP -DCHECK -DLOGINT -DSUNDISPLAY -DFORKCOMM +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +INLINE = $(SRCDIR)disp386i.il + +OBJECTDIR = ../sunos4.i386/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on 386i + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncallmacro.h $(INCDIR)inlineC.h \ + $(INCDIR)n_op_inlineC.h $(SRCDIR)disp386i.il \ + $(INCDIR)dummy_entries.h \ + $(INCDIR)inline386i.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc -c -O -Qproduce .s $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.s + +#run c compiler to produce first pass assembly +#$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i +# rm -f $(OBJECTDIR)xc.s1 +# /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s $(INLINE) + rm -f $(OBJECTDIR)xc.s2 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s > $(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s2 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s2 diff --git a/bin/makefile-sunos4.i386-multi b/bin/makefile-sunos4.i386-multi new file mode 100755 index 0000000..0b2a8cc --- /dev/null +++ b/bin/makefile-sunos4.i386-multi @@ -0,0 +1,48 @@ +# Options for sun4 and mc68020 + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O -traditional +DISPOPTFLAGS = -O -traditional +FPFLAGS = +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DI386 -DBYTESWAP -DCHECK -DLOGINT -DDISPLAYBUFFER -DSUNDISPLAY -DNEWBITBLT -DOPDISP -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +INLINE = $(SRCDIR)disp386i.il +BITBLTFILE=$(OBJECTDIR)bitblt386i.o +CC=gcc +AS=/users/sybalsky/gcc/gas/gas-1.35/a386 + +OBJECTDIR = ../sunos4.i386-multi/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on 386i + +#run cpp to expand macros +$(OBJECTDIR)xc.s: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(SRCDIR)disp386i.il \ + $(INCDIR)inline386i.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc -c -O -Qproduce .s $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.s + +#run c compiler to produce first pass assembly +#$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i +# rm -f $(OBJECTDIR)xc.s1 +# /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s $(INLINE) + rm -f $(OBJECTDIR)xc.s2 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s > $(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s2 + $(AS) -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s2 + diff --git a/bin/makefile-sunos4.mc68020 b/bin/makefile-sunos4.mc68020 new file mode 100755 index 0000000..dcedf56 --- /dev/null +++ b/bin/makefile-sunos4.mc68020 @@ -0,0 +1,36 @@ +# Options for sun4 and mc68020 + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# [I remove DISPLAYBUFFER option . +# You may run 'makeright multi'. -osamu '90/02/07] +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DOS4 -DSUN3_OS4_IL -DOS4_TYPE4BUG -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +OBJECTDIR = ../sunos4.mc68020/ + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-sunos4.mc68020-multi b/bin/makefile-sunos4.mc68020-multi new file mode 100755 index 0000000..49af8e2 --- /dev/null +++ b/bin/makefile-sunos4.mc68020-multi @@ -0,0 +1,38 @@ +# makefile-sunos4.mc68020-multi +# Options for SunOS4 and mc68020 for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos4.mc68020-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DOS4 -DSUN3_OS4_IL -DOS4_TYPE4BUG -DDISPLAYBUFFER -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DDISPLAYBUFFER -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o +COLORFILES = $(OBJECTDIR)colorbltfns.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile-sunos4.mc68020-x b/bin/makefile-sunos4.mc68020-x new file mode 100755 index 0000000..fb5183a --- /dev/null +++ b/bin/makefile-sunos4.mc68020-x @@ -0,0 +1,65 @@ +# Options for sun4, mc68020 and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O2 +DISPOPTFLAGS = -O +FPFLAGS = -f68881 +# DISPLAYBUFFER for Color Sparcstation code testing +# [I remove DISPLAYBUFFER option . +# You may run 'makeright x'. -osamu '90/02/27] +# NEWBITBLT for assembler version of bitblt. +DFLAGS = -DFSERROR -DNEW_STORAGE -DOPDISP -DUNSAFE -DOS4 -DSUN3_OS4_IL -DOS4_TYPE4BUG -DNEWBITBLT -DLOGINT $(XFLAGS) -DFORKCOMM -DBIGATOMS +LDFLAGS = -lX11 -lpixrect -lc -lm +LDELDFLAGS = -Bstatic -lX11 -lpixrect -Bdynamic -lc -lm + +INLINE = $(SRCDIR)disp68K.il +BITBLTFILE = $(OBJECTDIR)bitblt68K.o + +OBJECTDIR = ../sunos4.mc68020-x/ +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h \ + $(INCDIR)inlineSPARC.h $(INCDIR)fast_disp.h \ + $(INCDIR)fastinline68K.h $(INCDIR)profile.h + cc $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + diff --git a/bin/makefile-sunos4.sparc b/bin/makefile-sunos4.sparc new file mode 100755 index 0000000..bb84936 --- /dev/null +++ b/bin/makefile-sunos4.sparc @@ -0,0 +1,129 @@ +# Options for SunOS4 and SPARC +# @(#) makefile-sunos4.sparc Version 1.19 (5/9/90). + +#************************************************************************/ +#* */ +#* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ +# + + +CC = gcc +ANSICC = gcc + +#LPFILES = $(OBJECTDIR)lpmain.o \ +# $(OBJECTDIR)lpread.o \ +# $(OBJECTDIR)lpsolve.o \ +# $(OBJECTDIR)lpkit.o +# $(OBJECTDIR)lptran.o \ +# $(OBJECTDIR)lpdual.o \ +# $(OBJECTDIR)lpwrite.o + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 +DISPOPTFLAGS = -O2 +FPFLAGS = +# Now share the same ldesingle with COLOR(CG4)/MONO Suns +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +# +# Removed for debug: -DSPARCDISP -DSUN4_OS4_IL +# Added for debug: -DFNSTKCHECK -DMYOPTRACE -DOPTRACE -DNOASM +# +DEBUGFLAGS = # -DNOASM -DSTACKCHECK -DFNSTKCHECK +MACHINEFLAGS = -DOS4 -DOS4_TYPE4BUG -DCOLOR -DSUNDISPLAY \ + -DNEWBITBLT -DLOGINT -DFORKCOMM +FEATUREFLAGS = # -DLPSOLVE -DXMAS + +INLINEFLAGS = # -DSPARCDISP -DSUN4_OS4_IL + +DFLAGS = $(DEBUGFLAGS) \ + $(MACHINEFLAGS) \ + $(INLINEFLAGS) \ + -DKBINT -DFSERROR -DNEW_STORAGE \ + -DRELEASE=350 + +LDFLAGS = -L$(LIBDIR) -lsuntool -lsunwindow -lpixrect -ldld -lc -lm +#-Dsparc? +INLINE = # $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + +############ +# +# SPECIAL xc.o for debugging +# +############ +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h \ + $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) $(DISPRFLAGS) -UOPDISP -USPARCDISP $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.sparc% b/bin/makefile-sunos4.sparc% new file mode 100755 index 0000000..dea61b0 --- /dev/null +++ b/bin/makefile-sunos4.sparc% @@ -0,0 +1,100 @@ +# Options for SunOS4 and SPARC +# @(#) makefile-sunos4.sparc Version 1.19 (5/9/90). + +#************************************************************************/ +#* */ +#* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ +# +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 +FPFLAGS = +# Now share the same ldesingle with COLOR(CG4)/MONO Suns +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL \ + -DOS4_TYPE4BUG -DCOLOR -DNEWBITBLT -DLOGINT -DSUNDISPLAY \ + -DFORKCOMM -DBIGATOMS + +LDFLAGS = -lsuntool -lsunwindow -lpixrect -ldld -lc -lm +#-Dsparc? +INLINE = $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + +############ +# +# SPECIAL xc.o for debugging +# +############ +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h \ + $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h +# cc $(DISPRFLAGS) -UOPDISP -USPARCDISP $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.sparc-3 b/bin/makefile-sunos4.sparc-3 new file mode 100755 index 0000000..dbf9c38 --- /dev/null +++ b/bin/makefile-sunos4.sparc-3 @@ -0,0 +1,79 @@ +# Options for SunOS4 and SPARC +# @(#) makefile-sunos4.sparc Version 1.19 (5/9/90). +# +##***********************************************************************/ +## */ +## Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +## */ +## This file is work-product resulting from the Xerox/Venue */ +## Agreement dated 18-August-1989 for support of Medley. */ +## */ +##***********************************************************************/ +# +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 +FPFLAGS = +# Now share the same ldesingle with COLOR(CG4)/MONO Suns +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DCOLOR -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DFORKCOMM -DBIGATOMS +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +#-Dsparc? +INLINE = $(SRCDIR)dispSPARC.il +BITBLTFILE = $(OBJECTDIR)bitbltSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)disphack.c: $(SRCDIR)disphack.lex + rm -f $(OBJECTDIR)disphack.c + lex -t $(SRCDIR)disphack.lex > $(OBJECTDIR)disphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-disp.c: $(SRCDIR)find-disp.lex + rm -f $(OBJECTDIR)find-disp.c + lex -t $(SRCDIR)find-disp.lex > $(OBJECTDIR)find-disp.c + +$(OBJECTDIR)find-disp: $(OBJECTDIR)find-disp.c + cc -o $(OBJECTDIR)find-disp $(OBJECTDIR)find-disp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-disp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-disp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)disphack: $(OBJECTDIR)disphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)disphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)disphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)disphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)disphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)disphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.sparc-color b/bin/makefile-sunos4.sparc-color new file mode 100755 index 0000000..c35c37c --- /dev/null +++ b/bin/makefile-sunos4.sparc-color @@ -0,0 +1,69 @@ +# Options for SunOS4 and SPARC + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g +FPFLAGS = +# For COLOR, Add COLOR, remove OLD_CURSOR +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DFLTINT -DCOLOR -DNEWBITBLT -DSUNDISPLAY -DLOGINT -DFORKCOMM +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm + +#-Dsparc? +INLINE = $(SRCDIR)dispSPARC.il +BITBLTFILE = $(OBJECTDIR)bitbltSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : $(OBJECTDIR)lde $(OBJECTDIR)Cldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)disphack.c: $(SRCDIR)disphack.lex + rm -f $(OBJECTDIR)disphack.c + lex -t $(SRCDIR)disphack.lex > $(OBJECTDIR)disphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-disp.c: $(SRCDIR)find-disp.lex + rm -f $(OBJECTDIR)find-disp.c + lex -t $(SRCDIR)find-disp.lex > $(OBJECTDIR)find-disp.c + +$(OBJECTDIR)find-disp: $(OBJECTDIR)find-disp.c + cc -o $(OBJECTDIR)find-disp $(OBJECTDIR)find-disp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-disp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-disp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)disphack: $(OBJECTDIR)disphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)disphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)disphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)disphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)disphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)disphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.sparc-multi b/bin/makefile-sunos4.sparc-multi new file mode 100755 index 0000000..d113b65 --- /dev/null +++ b/bin/makefile-sunos4.sparc-multi @@ -0,0 +1,134 @@ +# makefile-sunos4.sparc-multi +# @(#) makefile-sunos4.sparc-multi Version 1.6 (5/9/90). +# + + +#************************************************************************/ +#* */ +#* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +CC = gcc +ANSICC = gcc + +#LPFILES = $(OBJECTDIR)lpmain.o \ +# $(OBJECTDIR)lpdual.o \ +# $(OBJECTDIR)lpread.o \ +# $(OBJECTDIR)lpsolve.o \ +## $(OBJECTDIR)lptran.o \ +# $(OBJECTDIR)lpwrite.o \ +# $(OBJECTDIR)lpy.tab.o + +LPFILES = + +# Options for SunOS4 and SPARC for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos4.sparc-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g # -O2 +DISPOPTFLAGS = -g # -O2 +FPFLAGS = +# Now share the same ldemulti for Mono-Medley & Color-Medley +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +# +# Removed for debug: -DSPARCDISP -DSUN4_OS4_IL +# Added for debug: -DFNSTKCHECK -DMYOPTRACE -DOPTRACE -DNOASM +# +#DEBUGFLAGS = -DNOASM -DSTACKCHECK -DFNSTKCHECK +MACHINEFLAGS = -DOS4 -DOS4_TYPE4BUG -DCOLOR -DDISPLAYBUFFER -DSUNDISPLAY \ + -DNEWBITBLT -DLOGINT -DFORKCOMM + +INLINEFLAGS = # -DSPARCDISP -DSUN4_OS4_IL + +DFLAGS = $(DEBUGFLAGS) \ + $(MACHINEFLAGS) \ + $(INLINEFLAGS) \ + -DKBINT -DFSERROR -DNEW_STORAGE \ + -DNOVERSION -DRELEASE=350 + +LDFLAGS = -L$(LIBDIR) -lsuntool -lsunwindow -lpixrect -ldld -lc -lm +#-Dsparc? +INLINE = # $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +############ +# +# SPECIAL xc.o for debugging +# +############ +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h \ + $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) $(DISPRFLAGS) -UOPDISP -USPARCDISP $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.sparc-multi% b/bin/makefile-sunos4.sparc-multi% new file mode 100755 index 0000000..099deb2 --- /dev/null +++ b/bin/makefile-sunos4.sparc-multi% @@ -0,0 +1,98 @@ +# makefile-sunos4.sparc-multi +# @(#) makefile-sunos4.sparc-multi Version 1.6 (5/9/90). +# +# Options for SunOS4 and SPARC for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos4.sparc-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g +DISPOPTFLAGS = -g +FPFLAGS = +# Now share the same ldemulti for Mono-Medley & Color-Medley +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +# +# Removed for debug: -DSPARCDISP -DSUN4_OS4_IL +# Added for debug: -DFNSTKCHECK -DMYOPTRACE -DOPTRACE -DNOASM +# +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DOS4_TYPE4BUG -DCOLOR \ + -DDISPLAYBUFFER -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DSPARCDISP \ + -DSUN4_OS4_IL -DBIGATOMS -DFORKCOMM -DBIGVM -DNEWCDRCODING + +LDFLAGS = -lsuntool -lsunwindow -lpixrect -ldld -lc -lm +#-Dsparc? +INLINE = $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)rawcolor.o + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +############ +# +# SPECIAL xc.o for debugging +# +############ +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h \ + $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + cc $(DISPRFLAGS) -UOPDISP -USPARCDISP $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.sparc-multi-3 b/bin/makefile-sunos4.sparc-multi-3 new file mode 100755 index 0000000..99389e2 --- /dev/null +++ b/bin/makefile-sunos4.sparc-multi-3 @@ -0,0 +1,94 @@ +# makefile-sunos4.sparc-multi +# @(#) makefile-sunos4.sparc-multi Version 1.6 (5/9/90). +# +# Options for SunOS4 and SPARC for CG3 or CG6 +# Add -DDISPLAYBUFFER in DFLAGS +# ${RELEASENAME} is "sunos4.sparc-multi" + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g +DISPOPTFLAGS = -g +FPFLAGS = +# Now share the same ldemulti for Mono-Medley & Color-Medley +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +# +# Removed for debug: -DSPARCDISP -DSUN4_OS4_IL +# Added for debug: -DFNSTKCHECK -DMYOPTRACE -DOPTRACE -DNOASM +# +DFLAGS = -DKBINT -DFSERROR -DNEW_STORAGE -DOS4 -DOS4_TYPE4BUG -DCOLOR -DDISPLAYBUFFER -DNEWBITBLT -DLOGINT -DSUNDISPLAY -DSPARCDISP -DSUN4_OS4_IL -DBIGATOMS -DFORKCOMM +LDFLAGS = -lsuntool -lsunwindow -lpixrect -lc -lm +#-Dsparc? +INLINE = $(SRCDIR)dispSPARC.il +BITBLTFILE = $(OBJECTDIR)bitbltSPARC.o + +OBJECTDIR = ../$(RELEASENAME)/ +COLORFILES = $(OBJECTDIR)colorbltfns.o + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)disphack.c: $(SRCDIR)disphack.lex + rm -f $(OBJECTDIR)disphack.c + lex -t $(SRCDIR)disphack.lex > $(OBJECTDIR)disphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-disp.c: $(SRCDIR)find-disp.lex + rm -f $(OBJECTDIR)find-disp.c + lex -t $(SRCDIR)find-disp.lex > $(OBJECTDIR)find-disp.c + +$(OBJECTDIR)find-disp: $(OBJECTDIR)find-disp.c + cc -o $(OBJECTDIR)find-disp $(OBJECTDIR)find-disp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-disp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-disp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)disphack: $(OBJECTDIR)disphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)disphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)disphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)disphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)disphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)disphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +############ +# +# SPECIAL xc.o for debugging +# +############ +#$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h# $(INCDIR)address.h \ +# $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ +# $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ +# $(INCDIR)initatoms.h $(INCDIR)gc.h \ +# $(INCDIR)arith.h $(INCDIR)stream.h \ +# $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ +# $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h +# cc $(DISPRFLAGS) $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.sparc-x b/bin/makefile-sunos4.sparc-x new file mode 100755 index 0000000..6067281 --- /dev/null +++ b/bin/makefile-sunos4.sparc-x @@ -0,0 +1,127 @@ +# Options for SunOS4, SPARC and X-Window + +# CLXFLAGS = -DTCP_NODELAY + +#CLXFILES = $(OBJECTDIR)socket.o \ +# $(OBJECTDIR)socdvr.o + + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + +CC = gcc + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) # $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -g -O2 +DISPOPTFLAGS = -g -O2 +FPFLAGS = +# Now share the same ldemulti for Mono-Medley & Color-Medley +# If you load MAIKOCOLOR.LCOM etc., you can use color functions +# +# Removed for debug: -DSPARCDISP -DSUN4_OS4_IL +# Added for debug: -DFNSTKCHECK -DMYOPTRACE -DOPTRACE -DNOASM +# +#DEBUGFLAGS = -DNOASM -DSTACKCHECK -DFNSTKCHECK +MACHINEFLAGS = -DOS4 -DOS4_TYPE4BUG -DOLD_CURSOR -DNOPIXRECT \ + -I$(OPENWINHOME)/include \ + -DNEWBITBLT -DLOGINT -DFORKCOMM -DLOCK_X_UPDATES + +INLINEFLAGS = # -DSPARCDISP -DSUN4_OS4_IL + +DFLAGS = $(DEBUGFLAGS) \ + $(MACHINEFLAGS) \ + $(INLINEFLAGS) \ + $(XFLAGS) \ + -DKBINT -DFSERROR -DNEW_STORAGE \ + -DNOVERSION -DRELEASE=200 + + + + +LDFLAGS = -L$(LIBDIR) -L$(OPENWINHOME)/lib -lX11 -lpixrect -ldld -lc -lm +LDELDFLAGS = -L$(LIBDIR) -L$(OPENWINHOME)/lib -Bstatic -lX11 -lpixrect -Bdynamic -lc -lm + +INLINE = # $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + +############ +# +# SPECIAL xc.o for debugging +# +############ +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h \ + $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) -g $(DISPRFLAGS) -UOPDISP -USPARCDISP $(SRCDIR)xc.c -I$(INCDIR) -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos4.sparc-x% b/bin/makefile-sunos4.sparc-x% new file mode 100755 index 0000000..d057f49 --- /dev/null +++ b/bin/makefile-sunos4.sparc-x% @@ -0,0 +1,104 @@ +# Options for SunOS4, SPARC and X-Window + +CLXFLAGS = -DCLX -DTCP_NODELAY + +CLXFILES = $(OBJECTDIR)socket.o \ + $(OBJECTDIR)socdvr.o + + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o \ + $(CLXFILES) + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -DNOPIXRECT -D$(XVERSION) $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DOLD_CURSOR \ + -DFORKCOMM -DNEWBITBLT -DLOGINT -DBIGATOMS $(XFLAGS) -DBIGVM -DNEWCDRCODING +LDFLAGS = -lX11 -lpixrect -ldld -lc -lm +LDELDFLAGS = -Bstatic -lX11 -lpixrect -Bdynamic -lc -lm + +INLINE = $(SRCDIR)dspSPARC.il +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + cc -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos4.sparc-x-3 b/bin/makefile-sunos4.sparc-x-3 new file mode 100755 index 0000000..7309857 --- /dev/null +++ b/bin/makefile-sunos4.sparc-x-3 @@ -0,0 +1,96 @@ +# Options for SunOS4, SPARC and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DOS4 -DSPARCDISP -DSUN4_OS4_IL -DOS4_TYPE4BUG -DOLD_CURSOR \ + -DFORKCOMM -DNEWBITBLT -DLOGINT -DBIGATOMS $(XFLAGS) +LDFLAGS = -lX11 -lpixrect -lc -lm +# -Dsparc? +INLINE = $(SRCDIR)dispSPARC.il +BITBLTFILE = $(OBJECTDIR)bitbltSPARC.o +BYTESWAPFILES = $(OBJECTDIR)byteswapfns.o + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)inline68K.h + cc -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)disphack.c: $(SRCDIR)disphack.lex + rm -f $(OBJECTDIR)disphack.c + lex -t $(SRCDIR)disphack.lex > $(OBJECTDIR)disphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-disp.c: $(SRCDIR)find-disp.lex + rm -f $(OBJECTDIR)find-disp.c + lex -t $(SRCDIR)find-disp.lex > $(OBJECTDIR)find-disp.c + +$(OBJECTDIR)find-disp: $(OBJECTDIR)find-disp.c + cc -o $(OBJECTDIR)find-disp $(OBJECTDIR)find-disp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-disp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-disp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)disphack: $(OBJECTDIR)disphack.c $(OBJECTDIR)dispatch-label.c + cc -o $(OBJECTDIR)disphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)disphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)disphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)disphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)disphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 + /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 diff --git a/bin/makefile-sunos5.i386-x b/bin/makefile-sunos5.i386-x new file mode 100755 index 0000000..9458fc1 --- /dev/null +++ b/bin/makefile-sunos5.i386-x @@ -0,0 +1,139 @@ +# Options for SOlaris 2.x, INTEL x86 and X-Window + + + +#************************************************************************/ +#* */ +#* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1996 Venue. */ +#* All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +CC = gcc + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -g3 +DISPOPTFLAGS = -O2 -g3 + +MAIN = main + +# Set any debugging options in DEBUGFLAGS. E.g., to enable stack +# checking, use -DSTACKCHECK; to enable the fn-call-time stack +# check, use -DFNSTKCHECK. + +DEBUGFLAGS = # -DSTACKCHECK -DFNSTKCHECK + +FPFLAGS = + +DFLAGS = $(XFLAGS) \ + $(DEBUGFLAGS) \ + -DFSERROR -DNEW_STORAGE -DOS5 -DAIX -DUSE_DLPI \ + -DBYTESWAP \ + -DOLD_CURSOR -DLOGINT \ + -DNOPIXRECT -DFORKCOMM -DLOCK_X_UPDATES \ + -I$(OPENWINHOME)/include -DSYSVSIGNALS -DSYSVONLY \ + -DRELEASE=210 + +LDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDELDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDEETHERLDFLAGS = -lc -lm -lsocket -lnsl + +# SPARC Assemble optimize check +# DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = +BITBLTFILE = # $(OBJECTDIR)bbtSPARC.o + +DLPIFILES = $(OBJECTDIR)dlpi.o + +OBJECTDIR = ../$(RELEASENAME)/ + +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + + +default: ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + $(CC) -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + $(CC) -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +########### debugging version of xc maker + + +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) $(DISPRFLAGS) -USPARCDISP -UOPDISP -DNOASM $(INLINE) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-sunos5.sparc-x b/bin/makefile-sunos5.sparc-x new file mode 100755 index 0000000..c7ce364 --- /dev/null +++ b/bin/makefile-sunos5.sparc-x @@ -0,0 +1,143 @@ +# Options for SOlaris 2.x, SPARC and X-Window + +# $Id: makefile-sunos5.sparc-x,v 1.7 2001/12/26 22:17:10 sybalsky Exp $ # + +#************************************************************************/ +#* */ +#* (C) Copyright 1989, 1990, 1990, 1991, */ +#* 1992, 1993, 1994, 1996, */ +#* 1999 */ +#* Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +CC = gcc + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) $(CLXFLAGS) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -g3 +DISPOPTFLAGS = -O2 -g3 + +MAIN = main + +# Set any debugging options in DEBUGFLAGS. E.g., to enable stack +# checking, use -DSTACKCHECK; to enable the fn-call-time stack +# check, use -DFNSTKCHECK. + +DEBUGFLAGS = # -DSTACKCHECK -DFNSTKCHECK + +MACHINEFLAGS = -DOS5 -DAIX -DUSE_DLPI -DNOPIXRECT \ + -I$(OPENWINHOME)/include -DSYSVSIGNALS -DSYSVONLY \ + -DOLD_CURSOR -DLOGINT -DFORKCOMM -DLOCK_X_UPDATES + +INLINEFLAGS = + +FPFLAGS = + +DFLAGS = $(XFLAGS) \ + $(DEBUGFLAGS) \ + $(MACHINEFLAGS) \ + $(INLINEFLAGS) \ + -DRELEASE=351 + +LDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDELDFLAGS = -R$(OPENWINHOME)/lib -L$(OPENWINHOME)/lib -lX11 -lc -lm -lsocket -lnsl +LDEETHERLDFLAGS = -lc -lm -lsocket -lnsl + +# SPARC Assemble optimize check +# DFLAGS:sh += optck.sh ; true + +#-Dsparc? +INLINE = +BITBLTFILE = $(OBJECTDIR)bbtSPARC.o + +DLPIFILES = $(OBJECTDIR)dlpi.o + +OBJECTDIR = ../$(RELEASENAME)/ +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + + +default: ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.i: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -Qproduce .i $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.i + +#run c compiler to produce first pass assembly +$(OBJECTDIR)xc.s1: $(OBJECTDIR)xc.i + rm -f $(OBJECTDIR)xc.s1 + /lib/ccom - $(FPFLAGS) <$(OBJECTDIR)xc.i >$(OBJECTDIR)xc.s1 + +#generate C program to remove dispatch loop, optimize +$(OBJECTDIR)dsphack.c: $(SRCDIR)dsphack.lex + rm -f $(OBJECTDIR)dsphack.c + lex -t $(SRCDIR)dsphack.lex > $(OBJECTDIR)dsphack.c + +#uses this program to find dispatch +$(OBJECTDIR)find-dsp.c: $(SRCDIR)find-dsp.lex + rm -f $(OBJECTDIR)find-dsp.c + lex -t $(SRCDIR)find-dsp.lex > $(OBJECTDIR)find-dsp.c + +$(OBJECTDIR)find-dsp: $(OBJECTDIR)find-dsp.c + $(CC) -o $(OBJECTDIR)find-dsp $(OBJECTDIR)find-dsp.c -ll + +$(OBJECTDIR)dispatch-label.c: $(OBJECTDIR)find-dsp $(OBJECTDIR)xc.s1 + rm -f $(OBJECTDIR)dispatch-label.c + $(OBJECTDIR)find-dsp < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)dispatch-label.c + +$(OBJECTDIR)dsphack: $(OBJECTDIR)dsphack.c $(OBJECTDIR)dispatch-label.c + $(CC) -o $(OBJECTDIR)dsphack $(OBJECTDIR)dispatch-label.c $(OBJECTDIR)dsphack.c -ll + rm -f $(OBJECTDIR)dispatch-label.o $(OBJECTDIR)dsphack.o + +$(OBJECTDIR)xc.s2: $(OBJECTDIR)xc.s1 $(OBJECTDIR)dsphack + rm -f $(OBJECTDIR)xc.s2 + $(OBJECTDIR)dsphack < $(OBJECTDIR)xc.s1 >$(OBJECTDIR)xc.s2 + +$(OBJECTDIR)xc.s3: $(OBJECTDIR)xc.s2 $(INLINE) + rm -f $(OBJECTDIR)xc.s3 + /usr/lib/inline -i $(INLINE) < $(OBJECTDIR)xc.s2 > $(OBJECTDIR)xc.s3 + +#$(OBJECTDIR)xc.o: $(OBJECTDIR)xc.s3 +# /bin/as -o $(OBJECTDIR)xc.o -O1 $(OBJECTDIR)xc.s3 + + +########### debugging version of xc maker + + +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h + $(CC) $(DISPRFLAGS) -USPARCDISP -UOPDISP -DNOASM $(INLINE) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o diff --git a/bin/makefile-tail b/bin/makefile-tail new file mode 100755 index 0000000..c149c95 --- /dev/null +++ b/bin/makefile-tail @@ -0,0 +1,1134 @@ +# remainder of makefile +# +# +# +# +##***********************************************************************/ +## */ +## (C) Copyright 1989, 1990, 1991, 1995, 2002 Venue. */ +## All Rights Reserved. */ +## Manufactured in the United States of America. */ +## */ +## The contents of this file are proprietary information */ +## belonging to Venue, and are provided to you under license. */ +## They may not be further distributed or disclosed to third */ +## parties without the specific permission of Venue. */ +## */ +##***********************************************************************/ +# +# +# +# +# NOTE: to add a NEW object file you must +# 1. Add the file.o to one of the object file lists, +# (i.e. OFILES, GCFILES, DEVICES, etc). +# 2. Add the "how to make" & dependency info such as: +# (Remember that version.h is REQUIRED in all .c files) +# +# $(OBJECTDIR)<>.o : $(SRCDIR)<>.c $(REQUIRED-INCS) \ +# $(INCDIR)lispemul.h $(INCDIR)version.h \ +# $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ +# $(INCDIR)stack.h $(INCDIR)emlglob.h $(INCDIR)lispmap.h \ +# $(INCDIR)gc.h +# $(CC) $(RFLAGS) $(SRCDIR)<>.c $(INLINE) -o $(OBJECTDIR)<>.o + +# to build sysouts on the sun, you must do the following: +# 1. setenv OPTFLAGS '-DINIT -g' +# 2. rm objectdir/bitblt.c objectdir/dspsubrs.c objectdir/keyevent.c +# 3. makeright -e init +# 4. follow the instructions on {eris}sunloadup>howto-loadup-sunlisp.txt + + +# '90/04/23 osamu: $INSDIR is defined in makeright +# +#INSDIR = $(RELDIR)install.$(RELEASENAME)/ +CHKDIR = $(RELDIR)checksumdir/ +SCRPTDIR = $(RELDIR)scripts/ +NATDIR = $(RELDIR)usernative/ + +# OSARCHDIR is the os/architecture dir, where executables all go. +OSARCHDIR = ../$(OSARCHNAME)/ + +# +# The DISPxxx flags are for compiling files which rely on 'as' much +# more than the other files do. For mc68020, it'll use optimization +# -O rather than -O2 which is good for the other files in the system +# [JDS 10-26-89] Files affected: xc, arith2, arith4, fvar. +# + +REQUIRED-INCS = $(INCDIR)version.h + +CFLAGS = $(OPTFLAGS) $(DFLAGS) $(FPFLAGS) +DISPCFLAGS = $(DISPOPTFLAGS) $(DFLAGS) $(FPGLAGS) +RFLAGS = -c $(CFLAGS) -I$(INCDIR) -I$(INCLUDEDIR) -L$(LIBDIR) +ANSIRFLAGS = -c $(ANSIOPTFLAGS) $(DFLAGS) $(FPFLAGS) -I$(INCDIR) -I$(INCLUDEDIR) +DISPRFLAGS = -c $(DISPCFLAGS) -I$(INCDIR) -I$(INCLUDEDIR) + +KEYON = $(OBJECTDIR)keytst.o +KEYOFF = $(OBJECTDIR)keytstno.o + +OFILES = $(OBJECTDIR)arith2.o \ + $(OBJECTDIR)arith3.o \ + $(OBJECTDIR)arith4.o \ + $(OBJECTDIR)array.o \ + $(OBJECTDIR)array2.o \ + $(OBJECTDIR)array3.o \ + $(OBJECTDIR)array4.o \ + $(OBJECTDIR)array5.o \ + $(OBJECTDIR)array6.o \ + $(OBJECTDIR)bin.o \ + $(OBJECTDIR)binds.o \ + $(OBJECTDIR)bitblt.o \ + $(OBJECTDIR)bbtsub.o \ + $(OBJECTDIR)blt.o \ + $(OBJECTDIR)car-cdr.o \ + $(OBJECTDIR)chardev.o \ + $(OBJECTDIR)common.o \ + $(OBJECTDIR)conspage.o \ + $(OBJECTDIR)mkcell.o \ + $(OBJECTDIR)draw.o \ + $(OBJECTDIR)findkey.o \ + $(OBJECTDIR)fvar.o \ + $(OBJECTDIR)xc.o \ + $(OBJECTDIR)gc.o \ + $(OBJECTDIR)gc2.o \ + $(OBJECTDIR)gvar2.o \ + $(OBJECTDIR)hardrtn.o \ + $(OBJECTDIR)inet.o \ + $(OBJECTDIR)intcall.o \ + $(OBJECTDIR)keylib.o \ + $(OBJECTDIR)lineblt8.o \ + $(OBJECTDIR)lsthandl.o \ + $(OBJECTDIR)llcolor.o \ + $(OBJECTDIR)llstk.o \ + $(OBJECTDIR)loopsops.o \ + $(OBJECTDIR)lowlev1.o \ + $(OBJECTDIR)lowlev2.o \ + $(OBJECTDIR)misc7.o \ + $(OBJECTDIR)mvs.o \ + $(OBJECTDIR)return.o \ + $(OBJECTDIR)rplcons.o \ + $(OBJECTDIR)shift.o \ + $(OBJECTDIR)subr.o \ + $(OBJECTDIR)miscn.o \ + $(OBJECTDIR)subr0374.o \ + $(OBJECTDIR)timer.o \ + $(OBJECTDIR)typeof.o \ + $(OBJECTDIR)unwind.o \ + $(OBJECTDIR)vars3.o \ + $(OBJECTDIR)unixcomm.o \ + $(OBJECTDIR)uraid.o \ + $(OBJECTDIR)rpc.o \ + $(OBJECTDIR)ufn.o \ + $(OBJECTDIR)z2.o \ + $(OBJECTDIR)eqf.o \ + $(OBJECTDIR)fp.o \ + $(OBJECTDIR)ubf1.o \ + $(OBJECTDIR)ubf2.o \ + $(OBJECTDIR)ubf3.o \ + $(OBJECTDIR)uutils.o \ + $(OBJECTDIR)perrno.o \ + $(OBJECTDIR)foreign.o \ + $(OBJECTDIR)lisp2c.o \ + $(OBJECTDIR)hacks.o \ + $(OBJECTDIR)osmsg.o +# $(OBJECTDIR)mnxmeth.o \ +# $(OBJECTDIR)mnwevent.o + +GCFILES = $(OBJECTDIR)gcscan.o \ + $(OBJECTDIR)gcarray.o \ + $(OBJECTDIR)gccode.o \ + $(OBJECTDIR)gcfinal.o \ + $(OBJECTDIR)gcrcell.o \ + $(OBJECTDIR)gchtfind.o \ + $(OBJECTDIR)gcmain3.o \ + $(OBJECTDIR)gcr.o \ + $(OBJECTDIR)gcoflow.o + +DEVICES = $(OBJECTDIR)dspsubrs.o \ + $(OBJECTDIR)initdsp.o \ + $(OBJECTDIR)dsk.o \ + $(OBJECTDIR)ufs.o \ + $(OBJECTDIR)dir.o \ + $(OBJECTDIR)keyevent.o \ + $(OBJECTDIR)kbdsubrs.o \ + $(OBJECTDIR)ether.o \ + $(OBJECTDIR)initkbd.o + +TESTFILES = $(OBJECTDIR)dbgtool.o \ + $(OBJECTDIR)testtool.o \ + $(OBJECTDIR)kprint.o + +MAINFILES = $(OBJECTDIR)main.o \ + $(OBJECTDIR)initsout.o \ + $(OBJECTDIR)storage.o \ + $(OBJECTDIR)allocmds.o \ + $(OBJECTDIR)vmemsave.o \ + $(OBJECTDIR)mkatom.o \ + $(OBJECTDIR)ldsout.o + +SXHASHFILE = $(OBJECTDIR)sxhash.o + +VFILE = $(OBJECTDIR)vdate + +DEVFILES = $(OFILES) $(KEYOFF) $(TESTFILES) $(BYTESWAPFILES) $(MAINFILES) \ + $(DEVICES) $(GCFILES) $(SXHASHFILE) $(BITBLTFILE) $(XFILES) \ + $(COLORFILES) $(LPFILES) $(DLPIFILES) +LIBFILES = $(OFILES) $(KEYON) $(TESTFILES) $(BYTESWAPFILES) $(MAINFILES) \ + $(DEVICES) $(GCFILES) $(SXHASHFILE) $(BITBLTFILE) $(XFILES) \ + $(COLORFILES) $(LPFILES) $(DLPIFILES) +EXTFILES = $(OBJECTDIR)usrsubr.o + +# execute to make /tmp/vdate.c + +################################################################################ +# Development targets - copyprotect is OFF here +################################################################################ + +default : $(OSARCHDIR)lde $(OSARCHDIR)$(LDENAME) $(OSARCHDIR)ldeether \ + $(OSARCHDIR)tstsout $(OSARCHDIR)setsout $(OSARCHDIR)keymaker + +$(OSARCHDIR)lde: $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c + $(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c \ + $(LDELDFLAGS) -o $(OSARCHDIR)lde + +$(OSARCHDIR)$(LDENAME) : $(DEVFILES) $(EXTFILES) $(OSARCHDIR)mkvdate + /bin/rm -f $(VFILE).c + $(OSARCHDIR)mkvdate > $(VFILE).c + $(CC) $(CFLAGS) $(DEVFILES) $(EXTFILES) $(VFILE).c \ + $(LDFLAGS) -o $(OSARCHDIR)$(LDENAME) + @ echo "" + @ echo "Executable is now named '$(OSARCHDIR)$(LDENAME)'" + +$(OSARCHDIR)ldeether : $(SRCDIR)ldeether.c $(DLPIFILES) + $(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)ldeether.c $(DLPIFILES) $(LDEETHERLDFLAGS) -o $(OSARCHDIR)ldeether + ls -l $(OSARCHDIR)ldeether + +$(OSARCHDIR)mkvdate : $(SRCDIR)mkvdate.c $(REQUIRED-INCS) + $(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)mkvdate.c -o $(OSARCHDIR)mkvdate + +$(OSARCHDIR)tstsout : $(OBJECTDIR)tstsout.o $(BYTESWAPFILES) $(REQUIRED-INCS) + $(CC) $(CFLAGS) $(OBJECTDIR)tstsout.o $(BYTESWAPFILES) -lc -lm -o $(OSARCHDIR)tstsout + +$(OSARCHDIR)setsout : $(OBJECTDIR)setsout.o $(REQUIRED-INCS) + $(CC) $(CFLAGS) $(OBJECTDIR)setsout.o $(BYTESWAPFILES) -lc -lm -o $(OSARCHDIR)setsout + + +$(OSARCHDIR)testdsp : $(SRCDIR)testdsp.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)display.h $(INCDIR)dbprint.h + $(CC) $(CFLAGS) -DDEBUG -I$(INCDIR) $(SRCDIR)testdsp.c -lsuntool -lsunwindow -lpixrect -lc -lm -o $(OSARCHDIR)testdsp + +$(OSARCHDIR)keymaker : ../src/keymaker.c $(REQUIRED-INCS) $(OBJECTDIR)keylib.o + $(CC) $(CFLAGS) -I$(INCDIR) ../src/keymaker.c $(OBJECTDIR)keylib.o -o $(OSARCHDIR)keymaker + +#### Component files ###################################################### + +$(OBJECTDIR)tstsout.o: $(SRCDIR)tstsout.c $(REQUIRED-INCS) + $(CC) -c $(CFLAGS) $(SRCDIR)tstsout.c -I$(INCDIR) -o $(OBJECTDIR)tstsout$(OEXT) + +$(OBJECTDIR)setsout.o: $(SRCDIR)setsout.c $(REQUIRED-INCS) + $(CC) -c $(CFLAGS) $(SRCDIR)setsout.c -I$(INCDIR) -o $(OBJECTDIR)setsout$(OEXT) + +$(OBJECTDIR)main.o : $(SRCDIR)main.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)address.h $(INCDIR)lsptypes.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lispmap.h $(INCDIR)ifpage.h $(INCDIR)iopage.h \ + $(INCDIR)return.h $(INCDIR)debug.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)main.c $(INLINE) -o $(OBJECTDIR)main$(OEXT) + +$(OBJECTDIR)dbgtool.o : $(SRCDIR)dbgtool.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)cell.h $(INCDIR)stack.h + $(CC) $(RFLAGS) $(SRCDIR)dbgtool.c $(INLINE) -o $(OBJECTDIR)dbgtool$(OEXT) + +$(OBJECTDIR)dlpi.o : $(SRCDIR)dlpi.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)os.h $(INCDIR)nfswatch.h $(INCDIR)externs.h + $(CC) $(RFLAGS) $(SRCDIR)dlpi.c $(INLINE) -o $(OBJECTDIR)dlpi$(OEXT) + +$(OBJECTDIR)kprint.o : $(SRCDIR)kprint.c $(REQUIRED-INCS) $(INCDIR)print.h \ + $(INCDIR)address.h $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)lspglob.h $(INCDIR)initatms.h \ + $(INCDIR)cell.h $(INCDIR)emlglob.h $(INCDIR)lispmap.h \ + $(INCDIR)adr68k.h + $(CC) $(RFLAGS) $(SRCDIR)kprint.c $(INLINE) -o $(OBJECTDIR)kprint$(OEXT) + +$(OBJECTDIR)testtool.o : $(SRCDIR)testtool.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)cell.h $(INCDIR)stack.h $(INCDIR)ifpage.h + $(CC) $(RFLAGS) $(SRCDIR)testtool.c $(INLINE) -o $(OBJECTDIR)testtool$(OEXT) + +$(OBJECTDIR)allocmds.o : $(SRCDIR)allocmds.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)cell.h $(INCDIR)lispmap.h \ + $(INCDIR)initatms.h $(INCDIR)sysatms.h $(INCDIR)lspglob.h + $(CC) $(RFLAGS) $(SRCDIR)allocmds.c $(INLINE) -o $(OBJECTDIR)allocmds$(OEXT) + +$(OBJECTDIR)arith2.o : $(SRCDIR)arith2.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)adr68k.h $(INCDIR)lispmap.h $(INCDIR)lsptypes.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INLINE) + $(CC) $(DISPRFLAGS) $(SRCDIR)arith2.c $(INLINE) -o $(OBJECTDIR)arith2$(OEXT) + +$(OBJECTDIR)arith3.o : $(SRCDIR)arith3.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h $(INLINE) \ + $(INCDIR)lspglob.h $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)cell.h $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)arith3.c $(INLINE) -o $(OBJECTDIR)arith3$(OEXT) + +$(OBJECTDIR)arith4.o : $(SRCDIR)arith4.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h $(INLINE) \ + $(INCDIR)lspglob.h $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)cell.h $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(DISPRFLAGS) $(SRCDIR)arith4.c $(INLINE) -o $(OBJECTDIR)arith4$(OEXT) + +$(OBJECTDIR)array.o : $(SRCDIR)array.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array.c $(INLINE) -o $(OBJECTDIR)array$(OEXT) + +$(OBJECTDIR)array3.o : $(SRCDIR)array3.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array3.c $(INLINE) -o $(OBJECTDIR)array3$(OEXT) + +$(OBJECTDIR)array5.o : $(SRCDIR)array5.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array5.c $(INLINE) -o $(OBJECTDIR)array5$(OEXT) + +$(OBJECTDIR)bin.o : $(SRCDIR)bin.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)cell.h $(INCDIR)stream.h + $(CC) $(RFLAGS) $(SRCDIR)bin.c $(INLINE) -o $(OBJECTDIR)bin$(OEXT) + +$(OBJECTDIR)binds.o : $(SRCDIR)binds.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)emlglob.h + $(CC) $(RFLAGS) $(SRCDIR)binds.c $(INLINE) -o $(OBJECTDIR)binds$(OEXT) + +$(OBJECTDIR)bitblt.o : $(SRCDIR)bitblt.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)lispmap.h \ + $(INCDIR)emlglob.h $(INCDIR)adr68k.h $(INCDIR)address.h \ + $(INCDIR)pilotbbt.h $(INCDIR)display.h $(INCDIR)bitblt.h \ + $(INCDIR)bb.h + $(CC) $(RFLAGS) $(SRCDIR)bitblt.c $(INLINE) -o $(OBJECTDIR)bitblt$(OEXT) + +$(OBJECTDIR)bbt68k.o : $(OBJECTDIR)bbt68k.i $(SRCDIR)bbt68k.s + as -O $(OBJECTDIR)bbt68k.i -o $(OBJECTDIR)bbt68k$(OEXT) + +$(OBJECTDIR)bbt68k.i : $(SRCDIR)bbt68k.s + /lib/cpp $(SRCDIR)bbt68k.s $(OBJECTDIR)bbt68k.i + +$(OBJECTDIR)bbtSPARC.o : $(SRCDIR)bbtSPARC.s + as -P $(SRCDIR)bbtSPARC.s -o $(OBJECTDIR)bbtSPARC$(OEXT) + +$(OBJECTDIR)bbt386i.o : $(SRCDIR)bbt386i.s $(OBJECTDIR)bbt386i.i + as $(OBJECTDIR)bbt386i.i -o $(OBJECTDIR)bbt386i$(OEXT) + +$(OBJECTDIR)bbt386i.i : $(SRCDIR)bbt386i.s + /lib/cpp $(SRCDIR)bbt386i.s $(OBJECTDIR)bbt386i.i + +$(OBJECTDIR)bbtsub.o : $(SRCDIR)bbtsub.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)lispmap.h $(INCDIR)lsptypes.h \ + $(INCDIR)emlglob.h $(INCDIR)adr68k.h $(INCDIR)address.h \ + $(INCDIR)pilotbbt.h $(INCDIR)display.h $(INCDIR)dspdata.h \ + $(INCDIR)bitblt.h $(INCDIR)bb.h $(INCDIR)dbprint.h \ + $(INCDIR)stack.h $(INCDIR)cell.h $(INCDIR)gc.h $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)bbtsub.c $(INLINE) -o $(OBJECTDIR)bbtsub$(OEXT) + +$(OBJECTDIR)blt.o : $(SRCDIR)blt.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)blt.c $(INLINE) -o $(OBJECTDIR)blt$(OEXT) + +$(OBJECTDIR)byteswap.o: $(SRCDIR)byteswap.c $(REQUIRED-INCS) $(INLINE) + $(CC) $(RFLAGS) $(SRCDIR)byteswap.c $(INLINE) -o $(OBJECTDIR)byteswap$(OEXT) + +$(OBJECTDIR)car-cdr.o : $(SRCDIR)car-cdr.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)gc.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)car-cdr.c $(INLINE) -o $(OBJECTDIR)car-cdr$(OEXT) + +$(OBJECTDIR)chardev.o : $(SRCDIR)chardev.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)lspglob.h $(INCDIR)stream.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)arith.h $(INCDIR)locfile.h \ + $(INCDIR)sunerrno.h $(INCDIR)suntermios.h $(INCDIR)sunfilio.h \ + $(INCDIR)sunioccom.h $(INCDIR)sunttycom.h $(INCDIR)sunttold.h \ + $(INCDIR)sunttydev.h + $(CC) $(RFLAGS) $(SRCDIR)chardev.c $(INLINE) -o $(OBJECTDIR)chardev$(OEXT) + +$(OBJECTDIR)rawcolor.o : $(SRCDIR)rawcolor.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)lispmap.h $(INCDIR)lsptypes.h \ + $(INCDIR)emlglob.h $(INCDIR)adr68k.h $(INCDIR)address.h \ + $(INCDIR)pilotbbt.h $(INCDIR)display.h $(INCDIR)bitblt.h \ + $(INCDIR)arith.h $(INCDIR)cell.h $(INCDIR)dspdata.h $(INCDIR)debug.h \ + $(INCDIR)stream.h + $(CC) $(RFLAGS) $(SRCDIR)rawcolor.c $(INLINE) -o $(OBJECTDIR)rawcolor$(OEXT) + +$(OBJECTDIR)llcolor.o : $(SRCDIR)llcolor.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lspglob.h $(INCDIR)emlglob.h $(INCDIR)display.h \ + $(INCDIR)devconf.h $(INCDIR)bb.h $(INCDIR)bitblt.h $(INCDIR)pilotbbt.h \ + $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)llcolor.c $(INLINE) -o $(OBJECTDIR)llcolor$(OEXT) + +$(OBJECTDIR)lineblt8.o : $(SRCDIR)lineblt8.c $(REQUIRED-INCS) $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)lineblt8.c $(INLINE) -o $(OBJECTDIR)lineblt8$(OEXT) + +$(OBJECTDIR)common.o : $(SRCDIR)common.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)adr68k.h $(INCDIR)lspglob.h \ + $(INCDIR)emlglob.h + $(CC) $(RFLAGS) $(SRCDIR)common.c $(INLINE) -o $(OBJECTDIR)common$(OEXT) + +$(OBJECTDIR)conspage.o : $(SRCDIR)conspage.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)cell.h $(INCDIR)lispmap.h \ + $(INCDIR)gc.h $(INCDIR)lspglob.h + $(CC) $(RFLAGS) $(SRCDIR)conspage.c $(INLINE) -o $(OBJECTDIR)conspage$(OEXT) + +$(OBJECTDIR)mkcell.o : $(SRCDIR)mkcell.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)cell.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)mkcell.c $(INLINE) -o $(OBJECTDIR)mkcell$(OEXT) + +$(OBJECTDIR)draw.o : $(SRCDIR)draw.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)draw.c $(INLINE) -o $(OBJECTDIR)draw$(OEXT) + +$(OBJECTDIR)z2.o : $(SRCDIR)z2.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)lspglob.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)gc.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)z2.c $(INLINE) -o $(OBJECTDIR)z2$(OEXT) + +$(OBJECTDIR)eqf.o : $(SRCDIR)eqf.c $(REQUIRED-INCS) $(INCDIR)fp.h \ + $(INCDIR)lispemul.h $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)eqf.c $(INLINE) -o $(OBJECTDIR)eqf$(OEXT) + +$(OBJECTDIR)fp.o : $(SRCDIR)fp.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)my.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)fp.c $(INLINE) -o $(OBJECTDIR)fp$(OEXT) + +$(OBJECTDIR)intcall.o : $(SRCDIR)intcall.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)lsptypes.h \ + $(INCDIR)lispmap.h $(INCDIR)stack.h $(INCDIR)return.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h $(INCDIR)initatms.h \ + $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)intcall.c $(INLINE) -o $(OBJECTDIR)intcall$(OEXT) + +$(OBJECTDIR)ubf1.o : $(SRCDIR)ubf1.c $(REQUIRED-INCS) $(INCDIR)fp.h \ + $(INCDIR)lispemul.h $(INCDIR)adr68k.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)ubf1.c $(INLINE) -o $(OBJECTDIR)ubf1$(OEXT) + +$(OBJECTDIR)ubf2.o : $(SRCDIR)ubf2.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)ubf2.c $(INLINE) -o $(OBJECTDIR)ubf2$(OEXT) + +$(OBJECTDIR)ubf3.o : $(SRCDIR)ubf3.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)ubf3.c $(INLINE) -o $(OBJECTDIR)ubf3$(OEXT) + +$(OBJECTDIR)uutils.o : $(SRCDIR)uutils.c $(REQUIRED-INCS) \ + $(INCDIR)lsptypes.h $(INCDIR)keyboard.h + $(CC) $(RFLAGS) $(SRCDIR)uutils.c $(INLINE) -o $(OBJECTDIR)uutils$(OEXT) + +$(OBJECTDIR)dspsubrs.o : $(SRCDIR)dspsubrs.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)display.h $(INCDIR)lsptypes.h \ + $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)dspsubrs.c $(INLINE) -o $(OBJECTDIR)dspsubrs$(OEXT) + +$(OBJECTDIR)dspif.o : $(SRCDIR)dspif.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)dbprint.h $(INCDIR)devif.h + $(CC) $(RFLAGS) $(SRCDIR)dspif.c $(INLINE) -o $(OBJECTDIR)dspif$(OEXT) + +$(OBJECTDIR)kbdif.o : $(SRCDIR)kbdif.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)dbprint.h $(INCDIR)devif.h + $(CC) $(RFLAGS) $(SRCDIR)kbdif.c $(INLINE) -o $(OBJECTDIR)kbdif$(OEXT) + +$(OBJECTDIR)mouseif.o : $(SRCDIR)mouseif.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)dbprint.h $(INCDIR)devif.h + $(CC) $(RFLAGS) $(SRCDIR)mouseif.c $(INLINE) -o $(OBJECTDIR)mouseif$(OEXT) + +$(OBJECTDIR)ether.o : $(SRCDIR)ether.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)ether.h + $(CC) $(RFLAGS) $(SRCDIR)ether.c $(INLINE) -o $(OBJECTDIR)ether$(OEXT) + +$(OBJECTDIR)findkey.o : $(SRCDIR)findkey.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)stack.h $(INCDIR)lspglob.h $(INCDIR)adr68k.h + $(CC) $(RFLAGS) $(SRCDIR)findkey.c $(INLINE) -o $(OBJECTDIR)findkey$(OEXT) + +$(OBJECTDIR)dsk.o : $(SRCDIR)dsk.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)adr68k.h $(INCDIR)lsptypes.h $(INCDIR)lspglob.h \ + $(INCDIR)fp.h $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)timeout.h \ + $(INCDIR)locfile.h $(INCDIR)osmsg.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)dsk.c $(INLINE) -o $(OBJECTDIR)dsk$(OEXT) + +$(OBJECTDIR)ufs.o : $(SRCDIR)ufs.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)adr68k.h $(INCDIR)dbprint.h $(INLINE)\ + $(INCDIR)lsptypes.h $(INCDIR)lspglob.h $(INCDIR)arith.h \ + $(INCDIR)stream.h $(INCDIR)timeout.h $(INCDIR)locfile.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)ufs.c $(INLINE) -o $(OBJECTDIR)ufs$(OEXT) + +$(OBJECTDIR)dir.o : $(SRCDIR)dir.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)adr68k.h $(INCDIR)lsptypes.h \ + $(INCDIR)arith.h $(INCDIR)lspglob.h $(INCDIR)timeout.h $(INCDIR)locfile.h + $(CC) $(RFLAGS) $(SRCDIR)dir.c $(INLINE) -o $(OBJECTDIR)dir$(OEXT) + +$(OBJECTDIR)fvar.o : $(SRCDIR)fvar.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)stack.h $(INCDIR)emlglob.h $(INCDIR)lispmap.h \ + $(INCDIR)gc.h $(INCDIR)lsptypes.h + $(CC) $(DISPRFLAGS) $(SRCDIR)fvar.c $(INLINE) -o $(OBJECTDIR)fvar$(OEXT) + +$(OBJECTDIR)gc.o : $(SRCDIR)gc.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)gc.h \ + $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)emlglob.h + $(CC) $(RFLAGS) $(SRCDIR)gc.c $(INLINE) -o $(OBJECTDIR)gc$(OEXT) + +$(OBJECTDIR)gc2.o : $(SRCDIR)gc2.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)lsptypes.h \ + $(INCDIR)lspglob.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h + $(CC) $(RFLAGS) $(SRCDIR)gc2.c $(INLINE) -o $(OBJECTDIR)gc2$(OEXT) + +$(OBJECTDIR)gcarray.o : $(SRCDIR)gcarray.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)stack.h \ + $(INCDIR)cell.h $(INCDIR)ifpage.h $(INCDIR)gc.h \ + $(INCDIR)array.h + $(CC) $(RFLAGS) $(SRCDIR)gcarray.c $(INLINE) -o $(OBJECTDIR)gcarray$(OEXT) + +$(OBJECTDIR)gcfinal.o : $(SRCDIR)gcfinal.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)stack.h \ + $(INCDIR)cell.h $(INCDIR)ifpage.h $(INCDIR)gc.h \ + $(INCDIR)array.h + $(CC) $(RFLAGS) $(SRCDIR)gcfinal.c $(INLINE) -o $(OBJECTDIR)gcfinal$(OEXT) + +$(OBJECTDIR)gcoflow.o : $(SRCDIR)gcoflow.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcoflow.c $(INLINE) -o $(OBJECTDIR)gcoflow$(OEXT) + +$(OBJECTDIR)gchtfind.o : $(SRCDIR)gchtfind.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)gc.h \ + $(INCDIR)lispmap.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)gchtfind.c $(INLINE) -o $(OBJECTDIR)gchtfind$(OEXT) + +$(OBJECTDIR)gcmain3.o : $(SRCDIR)gcmain3.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)stack.h $(INCDIR)cell.h $(INCDIR)ifpage.h \ + $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcmain3.c $(INLINE) -o $(OBJECTDIR)gcmain3$(OEXT) + +$(OBJECTDIR)gcr.o : $(SRCDIR)gcr.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)lsptypes.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)lspglob.h \ + $(INCDIR)stack.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcr.c $(INLINE) -o $(OBJECTDIR)gcr$(OEXT) + +$(OBJECTDIR)gcrcell.o : $(SRCDIR)gcrcell.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)dbprint.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)stack.h \ + $(INCDIR)cell.h $(INCDIR)ifpage.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcrcell.c $(INLINE) -o $(OBJECTDIR)gcrcell$(OEXT) + +$(OBJECTDIR)gccode.o : $(SRCDIR)gccode.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)lsptypes.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)lispmap.h \ + $(INCDIR)stack.h $(INCDIR)cell.h $(INCDIR)ifpage.h \ + $(INCDIR)gc.h $(INCDIR)array.h + $(CC) $(RFLAGS) $(SRCDIR)gccode.c $(INLINE) -o $(OBJECTDIR)gccode$(OEXT) + +$(OBJECTDIR)gcscan.o : $(SRCDIR)gcscan.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)gc.h $(INCDIR)lsptypes.h + $(CC) $(RFLAGS) $(SRCDIR)gcscan.c $(INLINE) -o $(OBJECTDIR)gcscan$(OEXT) + +$(OBJECTDIR)gvar2.o : $(SRCDIR)gvar2.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)gc.h $(INCDIR)emlglob.h $(INCDIR)cell.h $(INCDIR)lsptypes.h + $(CC) $(RFLAGS) $(SRCDIR)gvar2.c $(INLINE) -o $(OBJECTDIR)gvar2$(OEXT) + +$(OBJECTDIR)hardrtn.o : $(SRCDIR)hardrtn.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)cell.h $(INCDIR)stack.h $(INCDIR)return.h \ + $(INCDIR)emlglob.h + $(CC) $(RFLAGS) $(SRCDIR)hardrtn.c $(INLINE) -o $(OBJECTDIR)hardrtn$(OEXT) + +$(OBJECTDIR)inet.o : $(SRCDIR)inet.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)arith.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h $(INCDIR)ether.h \ + $(INCDIR)dbprint.h $(INCDIR)locfile.h + $(CC) $(RFLAGS) $(SRCDIR)inet.c $(INLINE) -o $(OBJECTDIR)inet$(OEXT) + +$(OBJECTDIR)initdsp.o : $(SRCDIR)initdsp.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address.h $(INCDIR)lsptypes.h \ + $(INCDIR)adr68k.h $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)display.h $(INCDIR)dbprint.h $(INLINE) + $(CC) $(RFLAGS) $(SRCDIR)initdsp.c $(INLINE) -o $(OBJECTDIR)initdsp$(OEXT) + +$(OBJECTDIR)initkbd.o : $(SRCDIR)initkbd.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)lspglob.h \ + $(INCDIR)adr68k.h $(INCDIR)address.h $(INCDIR)iopage.h \ + $(INCDIR)ifpage.h + $(CC) $(RFLAGS) $(SRCDIR)initkbd.c $(INLINE) -o $(OBJECTDIR)initkbd$(OEXT) + +$(OBJECTDIR)initsout.o : $(SRCDIR)initsout.c $(REQUIRED-INCS) $(INCDIR)hdw_conf.h \ + $(INCDIR)lispemul.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)adr68k.h \ + $(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)cell.h \ + $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)initsout.c $(INLINE) -o $(OBJECTDIR)initsout$(OEXT) + +$(OBJECTDIR)kbdsubrs.o : $(SRCDIR)kbdsubrs.c $(REQUIRED-INCS) $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)kbdsubrs.c $(INLINE) -o $(OBJECTDIR)kbdsubrs$(OEXT) + +$(OBJECTDIR)keyevent.o : $(SRCDIR)keyevent.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)address.h $(INCDIR)stack.h $(INCDIR)iopage.h \ + $(INCDIR)ifpage.h $(INCDIR)keyboard.h $(INCDIR)display.h \ + $(INCDIR)pilotbbt.h + $(CC) $(RFLAGS) $(SRCDIR)keyevent.c $(INLINE) -o $(OBJECTDIR)keyevent$(OEXT) + +$(OBJECTDIR)keylib.o : $(SRCDIR)keylib.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)keylib.c $(INLINE) -o $(OBJECTDIR)keylib$(OEXT) + +$(OBJECTDIR)keytst.o : $(SRCDIR)keytst.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)keytst.c $(INLINE) -o $(OBJECTDIR)keytst$(OEXT) + +$(OBJECTDIR)keytstno.o : $(SRCDIR)keytstno.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)keytstno.c $(INLINE) -o $(OBJECTDIR)keytstno$(OEXT) + +$(OBJECTDIR)lsthandl.o : $(SRCDIR)lsthandl.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)lsthandl.c $(INLINE) -o $(OBJECTDIR)lsthandl$(OEXT) + +$(OBJECTDIR)llstk.o : $(SRCDIR)llstk.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)adr68k.h \ + $(INCDIR)address.h $(INCDIR)lsptypes.h $(INCDIR)initatms.h \ + $(INCDIR)lspglob.h $(INCDIR)emlglob.h $(INCDIR)cell.h \ + $(INCDIR)stack.h + $(CC) $(RFLAGS) $(SRCDIR)llstk.c $(INLINE) -o $(OBJECTDIR)llstk$(OEXT) + +#$(OBJECTDIR)loader.o : $(SRCDIR)loader.c $(REQUIRED-INCS) +# $(CC) $(RFLAGS) $(SRCDIR)loader.c $(INLINE) -o $(OBJECTDIR)loader$(OEXT) + +$(OBJECTDIR)ldsout.o : $(SRCDIR)ldsout.c $(REQUIRED-INCS) $(INCDIR)adr68k.h \ + $(INCDIR)lispemul.h $(INCDIR)lispmap.h $(INCDIR)lspglob.h \ + $(INCDIR)ifpage.h $(INCDIR)dbprint.h $(INCDIR)lsptypes.h $(INLINE) + $(CC) $(RFLAGS) $(SRCDIR)ldsout.c $(INLINE) -o $(OBJECTDIR)ldsout$(OEXT) + +$(OBJECTDIR)loopsops.o : $(SRCDIR)loopsops.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)address.h $(INCDIR)lsptypes.h \ + $(INCDIR)adr68k.h $(INCDIR)cell.h $(INCDIR)lspglob.h \ + $(INCDIR)lispmap.h $(INCDIR)ifpage.h $(INCDIR)iopage.h \ + $(INCDIR)debug.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)loopsops.c $(INLINE) -o $(OBJECTDIR)loopsops$(OEXT) + +$(OBJECTDIR)lowlev1.o : $(SRCDIR)lowlev1.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)emlglob.h $(INCDIR)lsptypes.h + $(CC) $(RFLAGS) $(SRCDIR)lowlev1.c $(INLINE) -o $(OBJECTDIR)lowlev1$(OEXT) + +$(OBJECTDIR)lowlev2.o : $(SRCDIR)lowlev2.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h + $(CC) $(RFLAGS) $(SRCDIR)lowlev2.c $(INLINE) -o $(OBJECTDIR)lowlev2$(OEXT) + +$(OBJECTDIR)misc7.o : $(SRCDIR)misc7.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)stack.h $(INCDIR)opcodes.h $(INCDIR)display.h + $(CC) $(RFLAGS) $(SRCDIR)misc7.c $(INLINE) -o $(OBJECTDIR)misc7$(OEXT) + +$(OBJECTDIR)mvs.o : $(SRCDIR)mvs.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)stack.h $(INCDIR)opcodes.h + $(CC) $(RFLAGS) $(SRCDIR)mvs.c $(INLINE) -o $(OBJECTDIR)mvs$(OEXT) + +$(OBJECTDIR)mkatom.o : $(SRCDIR)mkatom.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)adr68k.h $(INCDIR)lsptypes.h \ + $(INCDIR)lispmap.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)mkatom.c $(INLINE) -o $(OBJECTDIR)mkatom$(OEXT) + +$(OBJECTDIR)osmsg.o : $(SRCDIR)osmsg.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)adr68k.h $(INCDIR)stream.h $(INCDIR)arith.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h + $(CC) $(RFLAGS) $(SRCDIR)osmsg.c $(INLINE) -o $(OBJECTDIR)osmsg$(OEXT) + +$(OBJECTDIR)return.o : $(SRCDIR)return.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h $(INCDIR)initatms.h \ + $(INCDIR)return.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)return.c $(INLINE) -o $(OBJECTDIR)return$(OEXT) + +$(OBJECTDIR)rplcons.o : $(SRCDIR)rplcons.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)gc.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)rplcons.c $(INLINE) -o $(OBJECTDIR)rplcons$(OEXT) + +$(OBJECTDIR)rs232c.o : $(SRCDIR)rs232c.c $(REQUIRED-INCS) $(INCDIR)rs232c.h + $(CC) $(RFLAGS) $(SRCDIR)rs232c.c $(INLINE) -o $(OBJECTDIR)rs232c$(OEXT) + +$(OBJECTDIR)shift.o : $(SRCDIR)shift.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)emlglob.h \ + $(INCDIR)adr68k.h $(INCDIR)lispmap.h $(INCDIR)lsptypes.h \ + $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)shift.c $(INLINE) -o $(OBJECTDIR)shift$(OEXT) + +$(OBJECTDIR)storage.o : $(SRCDIR)storage.c $(REQUIRED-INCS) $(INCDIR)hdw_conf.h \ + $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)lspglob.h $(INCDIR)cell.h $(INCDIR)lsptypes.h \ + $(INCDIR)ifpage.h + $(CC) $(RFLAGS) $(SRCDIR)storage.c $(INLINE) -o $(OBJECTDIR)storage$(OEXT) + +$(OBJECTDIR)subr.o : $(SRCDIR)subr.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)subrs.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)arith.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)subr.c $(INLINE) -o $(OBJECTDIR)subr$(OEXT) + +$(OBJECTDIR)miscn.o : $(SRCDIR)miscn.c $(REQUIRED-INCS) \ + $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)subrs.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h \ + $(INCDIR)arith.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)miscn.c $(INLINE) -o $(OBJECTDIR)miscn$(OEXT) + + +$(OBJECTDIR)subr0374.o : $(SRCDIR)subr0374.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)adr68k.h $(INCDIR)lspglob.h + $(CC) $(RFLAGS) $(SRCDIR)subr0374.c $(INLINE) -o $(OBJECTDIR)subr0374$(OEXT) + +$(OBJECTDIR)perrno.o : $(SRCDIR)perrno.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)perrno.c $(INLINE) -o $(OBJECTDIR)perrno$(OEXT) + +$(OBJECTDIR)timer.o : $(SRCDIR)timer.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h \ + $(INCDIR)adr68k.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)timer.c $(INLINE) -o $(OBJECTDIR)timer$(OEXT) + +$(OBJECTDIR)tty.o : $(SRCDIR)tty.c $(REQUIRED-INCS) $(INCDIR)tty.h + $(CC) $(RFLAGS) $(SRCDIR)tty.c $(INLINE) -o $(OBJECTDIR)tty$(OEXT) + +$(OBJECTDIR)typeof.o : $(SRCDIR)typeof.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lsptypes.h $(INCDIR)cell.h \ + $(INCDIR)lispmap.h + $(CC) $(RFLAGS) $(SRCDIR)typeof.c $(INLINE) -o $(OBJECTDIR)typeof$(OEXT) + +$(OBJECTDIR)ufn.o : $(SRCDIR)ufn.c $(REQUIRED-INCS) $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h $(INCDIR)initatms.h \ + $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)ufn.c $(INLINE) -o $(OBJECTDIR)ufn$(OEXT) + +$(OBJECTDIR)unixcomm.o : $(SRCDIR)unixcomm.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)arith.h + $(CC) $(RFLAGS) $(SRCDIR)unixcomm.c $(INLINE) -o $(OBJECTDIR)unixcomm$(OEXT) + +$(OBJECTDIR)uraid.o : $(SRCDIR)uraid.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)debug.h + $(CC) $(RFLAGS) $(SRCDIR)uraid.c $(INLINE) -o $(OBJECTDIR)uraid$(OEXT) + +$(OBJECTDIR)rpc.o : $(SRCDIR)rpc.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)emlglob.h \ + $(INCDIR)lspglob.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)arith.h $(INCDIR)locfile.h + $(CC) $(RFLAGS) $(SRCDIR)rpc.c $(INLINE) -o $(OBJECTDIR)rpc$(OEXT) + +$(OBJECTDIR)unwind.o : $(SRCDIR)unwind.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emlglob.h $(INCDIR)lspglob.h + $(CC) $(RFLAGS) $(SRCDIR)unwind.c $(INLINE) -o $(OBJECTDIR)unwind$(OEXT) + +$(OBJECTDIR)vars3.o : $(SRCDIR)vars3.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)lispmap.h \ + $(INCDIR)adr68k.h $(INCDIR)emlglob.h $(INCDIR)cell.h \ + $(INCDIR)lsptypes.h $(INCDIR)stack.h + $(CC) $(RFLAGS) $(SRCDIR)vars3.c $(INLINE) -o $(OBJECTDIR)vars3$(OEXT) + +$(OBJECTDIR)vmemsave.o : $(SRCDIR)vmemsave.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)lspglob.h \ + $(INCDIR)ifpage.h $(INCDIR)vmemsave.h + $(CC) $(RFLAGS) $(SRCDIR)vmemsave.c $(INLINE) -o $(OBJECTDIR)vmemsave$(OEXT) + +$(OBJECTDIR)array2.o : $(SRCDIR)array2.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array2.c $(INLINE) -o $(OBJECTDIR)array2$(OEXT) + +$(OBJECTDIR)array4.o : $(SRCDIR)array4.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array4.c $(INLINE) -o $(OBJECTDIR)array4$(OEXT) + +$(OBJECTDIR)array6.o : $(SRCDIR)array6.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array6.c $(INLINE) -o $(OBJECTDIR)array6$(OEXT) + +$(OBJECTDIR)socket.o : $(SRCDIR)socket.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)socket.c -o $(OBJECTDIR)socket$(OEXT) + +$(OBJECTDIR)socdvr.o : $(SRCDIR)socdvr.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)adr68k.h $(INCDIR)lsptypes.h $(INCDIR)lispmap.h \ + $(INCDIR)arith.h + $(CC) $(RFLAGS) $(SRCDIR)socdvr.c -o $(OBJECTDIR)socdvr$(OEXT) + +$(OBJECTDIR)sxhash.o : $(SRCDIR)sxhash.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)lspglob.h $(INCDIR)adr68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lsptypes.h $(INCDIR)emlglob.h \ + $(INCDIR)arith.h + $(CC) $(RFLAGS) $(SRCDIR)sxhash.c $(INLINE) -o $(OBJECTDIR)sxhash$(OEXT) + +$(OBJECTDIR)usrsubr.o : $(SRCDIR)usrsubr.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)usrsubr.c $(INLINE) -o $(OBJECTDIR)usrsubr$(OEXT) + +######## +# X-windows-specific files +####### + +$(OBJECTDIR)xinit.o : $(SRCDIR)xinit.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)dbprint.h $(INCDIR)xdefs.h $(INCDIR)devif.h \ + $(INCDIR)adr68k.h + $(CC) $(RFLAGS) $(SRCDIR)xinit.c -o $(OBJECTDIR)xinit$(OEXT) + +$(OBJECTDIR)XClose.o : $(SRCDIR)XClose.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XClose.c -o $(OBJECTDIR)XClose$(OEXT) + +$(OBJECTDIR)Cursor.o : $(SRCDIR)Cursor.c $(REQUIRED-INCS) $(INCDIR)XVersion.h $(INCDIR)MyWindow.h \ + $(INCDIR)lispemul.h $(INCDIR)display.h + $(CC) $(RFLAGS) $(SRCDIR)Cursor.c -o $(OBJECTDIR)Cursor$(OEXT) + +$(OBJECTDIR)XWindow.o : $(SRCDIR)XWindow.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h + $(CC) $(RFLAGS) $(SRCDIR)XWindow.c -o $(OBJECTDIR)XWindow$(OEXT) + +$(OBJECTDIR)DoRing.o : $(SRCDIR)DoRing.c $(REQUIRED-INCS) $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)DoRing.c -o $(OBJECTDIR)DoRing$(OEXT) + +$(OBJECTDIR)DoScroll.o : $(SRCDIR)DoScroll.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xbitblt.h + $(CC) $(RFLAGS) $(SRCDIR)DoScroll.c -o $(OBJECTDIR)DoScroll$(OEXT) + +$(OBJECTDIR)XEvent.o : $(SRCDIR)XEvent.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xbitblt.h + $(CC) $(RFLAGS) $(SRCDIR)XEvent.c -o $(OBJECTDIR)XEvent$(OEXT) + +$(OBJECTDIR)XGravity.o : $(SRCDIR)XGravity.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XGravity.c -o $(OBJECTDIR)XGravity$(OEXT) + +$(OBJECTDIR)XInit.o : $(SRCDIR)XInit.c $(REQUIRED-INCS) + $(CC) $(RFLAGS) $(SRCDIR)XInit.c -o $(OBJECTDIR)XInit$(OEXT) + +$(OBJECTDIR)Xevinit.o : $(SRCDIR)Xevinit.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xevinit.c -o $(OBJECTDIR)Xevinit$(OEXT) + +$(OBJECTDIR)Xkbdmus.o : $(SRCDIR)Xkbdmus.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)Xkbdmus.c -o $(OBJECTDIR)Xkbdmus$(OEXT) + +$(OBJECTDIR)Xlspwin.o : $(SRCDIR)Xlspwin.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xdeflt.h + $(CC) $(RFLAGS) $(SRCDIR)Xlspwin.c -o $(OBJECTDIR)Xlspwin$(OEXT) + +$(OBJECTDIR)xlspwin.o : $(SRCDIR)xlspwin.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)xdefs.h + $(CC) $(RFLAGS) $(SRCDIR)xlspwin.c -o $(OBJECTDIR)xlspwin$(OEXT) + +$(OBJECTDIR)Xbbt.o : $(SRCDIR)Xbbt.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xbbt.c -o $(OBJECTDIR)Xbbt$(OEXT) + +$(OBJECTDIR)xbbt.o : $(SRCDIR)xbbt.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)xbbt.c -o $(OBJECTDIR)xbbt$(OEXT) + +$(OBJECTDIR)LispXdisplay.o : $(SRCDIR)LispXdisplay.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)pilotbbt.h \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h $(INCDIR)Xbitblt.h + $(CC) $(RFLAGS) $(SRCDIR)LispXdisplay.c -o $(OBJECTDIR)LispXdisplay$(OEXT) + +$(OBJECTDIR)Xkbd.o : $(SRCDIR)Xkbd.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xkbd.c -o $(OBJECTDIR)Xkbd$(OEXT) + +$(OBJECTDIR)Xmkicon.o : $(SRCDIR)Xmkicon.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xicon.h + $(CC) $(RFLAGS) $(SRCDIR)Xmkicon.c -o $(OBJECTDIR)Xmkicon$(OEXT) + +$(OBJECTDIR)xmkicon.o : $(SRCDIR)xmkicon.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xicon.h + $(CC) $(RFLAGS) $(SRCDIR)xmkicon.c -o $(OBJECTDIR)xmkicon$(OEXT) + +$(OBJECTDIR)Xopendsp.o : $(SRCDIR)Xopendsp.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xopendsp.c -o $(OBJECTDIR)Xopendsp$(OEXT) + +$(OBJECTDIR)Xrdopt.o : $(SRCDIR)Xrdopt.c $(REQUIRED-INCS) $(INCDIR)Xdeflt.h + $(CC) $(RFLAGS) $(SRCDIR)Xrdopt.c -o $(OBJECTDIR)Xrdopt$(OEXT) + +$(OBJECTDIR)xrdopt.o : $(SRCDIR)xrdopt.c $(REQUIRED-INCS) $(INCDIR)xdefs.h + $(CC) $(RFLAGS) $(SRCDIR)xrdopt.c -o $(OBJECTDIR)xrdopt$(OEXT) + +$(OBJECTDIR)Xreconf.o : $(SRCDIR)Xreconf.c $(REQUIRED-INCS) \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xreconf.c -o $(OBJECTDIR)Xreconf$(OEXT) + +$(OBJECTDIR)XScroll.o : $(SRCDIR)XScroll.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Stipple.h $(INCDIR)Xcursdef.h \ + $(INCDIR)XCursors.h + $(CC) $(RFLAGS) $(SRCDIR)XScroll.c -o $(OBJECTDIR)XScroll$(OEXT) + +$(OBJECTDIR)xscroll.o : $(SRCDIR)xscroll.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Stipple.h $(INCDIR)Xcursdef.h \ + $(INCDIR)XCursors.h + $(CC) $(RFLAGS) $(SRCDIR)xscroll.c -o $(OBJECTDIR)xscroll$(OEXT) + +$(OBJECTDIR)Xscrolb.o : $(SRCDIR)Xscrolb.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xscrolb.c -o $(OBJECTDIR)Xscrolb$(OEXT) + +$(OBJECTDIR)XCursor.o : $(SRCDIR)XCursor.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)iopage.h $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XCursor.c -o $(OBJECTDIR)XCursor$(OEXT) + +$(OBJECTDIR)xcursor.o : $(SRCDIR)xcursor.c $(REQUIRED-INCS) $(INCDIR)lispemul.h \ + $(INCDIR)iopage.h $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)xcursor.c -o $(OBJECTDIR)xcursor$(OEXT) + +$(OBJECTDIR)XMouse.o : $(SRCDIR)XMouse.c $(REQUIRED-INCS) \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XMouse.c -o $(OBJECTDIR)XMouse$(OEXT) + +$(OBJECTDIR)Xsubwin.o : $(SRCDIR)Xsubwin.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xsubwin.c -o $(OBJECTDIR)Xsubwin$(OEXT) + +$(OBJECTDIR)Xcolor.o : $(SRCDIR)Xcolor.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Xcolor.c -o $(OBJECTDIR)Xcolor$(OEXT) + +$(OBJECTDIR)Xwinman.o : $(SRCDIR)Xwinman.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)Xwinman.c -o $(OBJECTDIR)Xwinman$(OEXT) + +$(OBJECTDIR)xwinman.o : $(SRCDIR)xwinman.c $(REQUIRED-INCS) $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)xwinman.c -o $(OBJECTDIR)xwinman$(OEXT) + +$(OBJECTDIR)hacks.o : $(SRCDIR)hacks.c $(REQUIRED-INCS) $(INCLUDEDIR)dld.h + $(CC) $(RFLAGS) $(SRCDIR)hacks.c -o $(OBJECTDIR)hacks$(OEXT) + +$(OBJECTDIR)foreign.o : $(SRCDIR)foreign.c $(REQUIRED-INCS) $(INCLUDEDIR)dld.h + $(CC) $(RFLAGS) $(SRCDIR)foreign.c $(INLINE) -o $(OBJECTDIR)foreign$(OEXT) + +$(OBJECTDIR)lisp2c.o : $(SRCDIR)lisp2c.c $(REQUIRED-INCS) $(INCLUDEDIR)dld.h + $(CC) $(RFLAGS) $(SRCDIR)lisp2c.c -o $(OBJECTDIR)lisp2c$(OEXT) + +$(OBJECTDIR)mnxmeth.o : $(SRCDIR)mnxmeth.c $(REQUIRED-INCS) $(INCDIR)mnxdefs.h $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)mnxmeth.c -o $(OBJECTDIR)mnxmeth$(OEXT) + +$(OBJECTDIR)mnwevent.o : $(SRCDIR)mnwevent.c $(REQUIRED-INCS) $(INCDIR)mnxdefs.h $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)mnwevent.c -o $(OBJECTDIR)mnwevent$(OEXT) + +$(OBJECTDIR)lpdual.o : $(SRCDIR)lpdual.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpdual.c -o $(OBJECTDIR)lpdual$(OEXT) + +$(OBJECTDIR)lpkit.o : $(SRCDIR)lpkit.c $(REQUIRED-INCS) $(INCDIR)lpkit.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpkit.c -o $(OBJECTDIR)lpkit$(OEXT) + +$(OBJECTDIR)lplex.yy.o : $(SRCDIR)lplex.yy.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lplex.yy.c -o $(OBJECTDIR)lpdual$(OEXT) + +$(OBJECTDIR)lpmain.o : $(SRCDIR)lpmain.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpmain.c -o $(OBJECTDIR)lpmain$(OEXT) + +$(OBJECTDIR)lpread.o : $(SRCDIR)lpread.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpread.c -o $(OBJECTDIR)lpread$(OEXT) + +$(OBJECTDIR)lpsolve.o : $(SRCDIR)lpsolve.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpsolve.c -o $(OBJECTDIR)lpsolve$(OEXT) + +$(OBJECTDIR)lptran.o : $(SRCDIR)lptran.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lptran.c -o $(OBJECTDIR)lptran$(OEXT) + +$(OBJECTDIR)lpwrite.o : $(SRCDIR)lpwrite.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpwrite.c -o $(OBJECTDIR)lpwrite$(OEXT) + +$(OBJECTDIR)lpy.tab.o : $(SRCDIR)lpy.tab.c $(REQUIRED-INCS) $(INCDIR)lpdefs.h $(INCDIR)lispemul.h \ + $(INCDIR)lpdefs.h $(INCDIR)lpglobl.h $(INCDIR)lpproto.h + $(ANSICC) $(ANSIRFLAGS) $(SRCDIR)lpy.tab.c -o $(OBJECTDIR)lpy.tab$(OEXT) + +################################################################################ +# Installation targets - copyprotect is ON here +# library, sysouts, fonts on release directories not handled here. +# userfiles are separate target explicitly (can make w/o building lde) +# $(NATDIR)native.h $(NATDIR)disp68K.il +################################################################################ + +prerelease : + mkdir $(RELDIR) + mkdir $(INSDIR) + mkdir $(CHKDIR) + mkdir $(SCRPTDIR) + + +release : $(INSDIR)$(LDENAME).o userfiles $(INSDIR)$(LDENAME) \ + $(INSDIR)ldeether $(INSDIR)lde csumfiles scriptfiles + +userfiles : $(INSDIR)usrsubr.c $(INSDIR)makefile $(INSDIR)ldeether.c + +$(INSDIR)lde: $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c + $(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c \ + $(LDELDFLAGS) -o $(INSDIR)lde + +$(OBJECTDIR)$(LDENAME).a : $(LIBFILES) $(OSARCHDIR)mkvdate + /bin/rm -f $(VFILE).c + $(OSARCHDIR)mkvdate > $(VFILE).c + $(CC) -c $(VFILE).c -o $(VFILE).o + rm -f $(LDENAME).a + $(AR) $(OBJECTDIR)$(LDENAME).a $(LIBFILES) $(VFILE).o + $(RANLIB) $(OBJECTDIR)$(LDENAME).a + rm -f $(VFILE).o + +$(INSDIR)$(LDENAME).o : $(OBJECTDIR)$(LDENAME).a + ld -o $(INSDIR)$(LDENAME).o -r -u $(MAIN) $(OBJECTDIR)$(LDENAME).a + +$(INSDIR)$(LDENAME) : $(INSDIR)$(LDENAME).o $(INSDIR)usrsubr.o + $(CC) $(INSDIR)$(LDENAME).o $(INSDIR)usrsubr.o $(FPFLAGS) $(LDFLAGS)\ + -o $(INSDIR)$(LDENAME) + rm -f $(INSDIR)usrsubr.o + +## ldeether from release - can't tar off with root permission. + +$(INSDIR)ldeether : $(INSDIR)ldeether.c $(DLPIFILES) $(REQUIRED-INCS) + $(CC) $(CFLAGS) $(INSDIR)ldeether.c $(DLPIFILES) $(LDEETHERLDFLAGS) -o $(INSDIR)ldeether + - suid $(INSDIR)ldeether" + +$(INSDIR)makefile : $(BINDIR)usermakefile-$(OSARCHNAME) + rm -f $(INSDIR)makefile + ln -s $(BINDIR)usermakefile-$(OSARCHNAME) $(INSDIR)makefile + +$(INSDIR)usrsubr.c : $(SRCDIR)usrsubr.c + rm -f $(INSDIR)usrsubr.c + ln -s $(SRCDIR)usrsubr.c $(INSDIR)usrsubr.c + +$(INSDIR)ldeether.c : $(SRCDIR)ldeether.c + rm -f $(INSDIR)ldeether.c + ln -s $(SRCDIR)ldeether.c $(INSDIR)ldeether.c + +csumfiles : $(CHKDIR)checksum $(CHKDIR)ldechecksum $(CHKDIR)README + +$(CHKDIR)README : $(BINDIR)checksum-readme + rm -f $(CHKDIR)README + ln -s $(BINDIR)checksum-readme $(CHKDIR)README + +$(CHKDIR)checksum : $(BINDIR)checksum + rm -f $(CHKDIR)checksum + cp -p $(BINDIR)checksum $(CHKDIR)checksum + chmod 755 $(CHKDIR)checksum + +$(CHKDIR)ldechecksum : $(BINDIR)ldechecksum + rm -f $(CHKDIR)ldechecksum + cp -p $(BINDIR)ldechecksum $(CHKDIR)ldechecksum + chmod 755 $(CHKDIR)ldechecksum + +scriptfiles : $(SCRPTDIR)install-medley $(SCRPTDIR)medley + +$(SCRPTDIR)install-medley : $(BINDIR)install-medley + rm -f $(SCRPTDIR)install-medley + cp -p $(BINDIR)install-medley $(SCRPTDIR)install-medley + chmod 755 $(SCRPTDIR)install-medley + +$(SCRPTDIR)medley : $(BINDIR)medley + rm -f $(SCRPTDIR)medley + cp -p $(BINDIR)medley $(SCRPTDIR)medley + chmod 755 $(SCRPTDIR)medley + +################################################################################ +# Obsolete +################################################################################ + +$(NATDIR)native.h : $(INCDIR)native.h + rm -f $(NATDIR)native.h + ln -s $(INCDIR)native.h $(NATDIR)native.h + +$(NATDIR)disp68K.il : $(SRCDIR)disp68K.il + rm -f $(NATDIR)disp68K.il + ln -s $(SRCDIR)disp68K.il $(NATDIR)disp68K.il + +################################################################################ +# Miscellaneous targets +# .c.s. should always have -O +################################################################################ + +cleanup : + rm $(LIBFILES) $(EXTFILES) $(KEYOFF) + +.c.o: + $(CC) $(RFLAGS) $*.c -o $@ $(INLINE) + +.c.s: + $(CC) -S $(CFLAGS) -I$(INCDIR) $(SRCDIR)$*.c -o $(SRCDIR)$@ $(INLINE) + +$(OBJECTDIR)keymaker : ../src/keymaker.c $(REQUIRED-INCS) $(OBJECTDIR)keylib.o + $(CC) $(CFLAGS) -I$(INCDIR) ../src/keymaker.c $(OBJECTDIR)keylib.o -o $(OBJECTDIR)keymaker + +cxref : + cxref -c $(DFLAGS) -I$(INCDIR) $(SRCDIR)*.c -o ../all.cxref diff --git a/bin/makefile-ultrix.dec3100-x b/bin/makefile-ultrix.dec3100-x new file mode 100755 index 0000000..7ea0d4d --- /dev/null +++ b/bin/makefile-ultrix.dec3100-x @@ -0,0 +1,67 @@ +# Options for Ultrix, DECStation 3100, and X-Window + + +CC = cc + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)Xevinit.o \ + $(OBJECTDIR)Xkbdmus.o \ + $(OBJECTDIR)Xlspwin.o \ + $(OBJECTDIR)Xbbt.o \ + $(OBJECTDIR)Xkbd.o \ + $(OBJECTDIR)Xmkicon.o \ + $(OBJECTDIR)Xopendsp.o \ + $(OBJECTDIR)Xrdopt.o \ + $(OBJECTDIR)Xreconf.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Xscrolb.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Xsubwin.o \ + $(OBJECTDIR)Xcolor.o \ + $(OBJECTDIR)Xwinman.o + +BYTESWAPFILES = $(OBJECTDIR)byteswap.o + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -Olimit 999 +DISPOPTFLAGS = -O2 -Olimit 999 +FPFLAGS = +DFLAGS = -DFSERROR -DNEW_STORAGE -DAIX -DOLD_CURSOR -DNOPIXRECT -DBYTESWAP \ +-DFORKCOMM -DLOGINT -DSYS5 -DDEC3100 -DNOFORN -DNOETHER -DBIGATOMS $(XFLAGS) +LDFLAGS = -lX11 -lc -lm +LDELDFLAGS = -lX11 -lc -lm +# -Dsparc? +INLINE = + + +OBJECTDIR = ../$(RELEASENAME)/ + +default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldeether + +# Special rules to create xc.c on Sun4 + +#run cpp to expand macros +$(OBJECTDIR)xc.o: $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emlglob.h $(INCDIR)address.h \ + $(INCDIR)adr68k.h $(INCDIR)stack.h $(INCDIR)lspglob.h \ + $(INCDIR)lsptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosret.h \ + $(INCDIR)tosfns.h $(INCDIR)inlineC.h \ + $(INCDIR)inln68k.h + $(CC) -c $(DFLAGS) -I$(INCDIR) $(SRCDIR)xc.c -o $(OBJECTDIR)xc.o + + diff --git a/bin/makefile.dos b/bin/makefile.dos new file mode 100755 index 0000000..cb91fdd --- /dev/null +++ b/bin/makefile.dos @@ -0,0 +1,631 @@ +AFLAGS = /T +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj + + +ADMINFILES = makefile mkvdate.c optck.c + +LPFILES = lpmain.obj lpread.obj lpsolve.obj lpwrite.obj lpdual.obj lptran.obj + +KEY = keytstno.obj + +CFLAGS = -DBIGATOMS -DNEW_STORAGE -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT \ + -DNOFORN -DNOETHER -DNOVERSION -DBIGVM -DNEWCDRCODING + +LDFLAGS = -g graphics.lib binmode.lib mouse.lib + +RM = del + +SRCFILES = conspage.c gcoflow.c shift.c dbgtool.c gcr.c gcrcell.c llstk.c gcscan.c loopsops.c storage.c allocmds.c dir.c gvar2.c lowlev1.c subr.c arith2.c hacks.c lowlev2.c subr0374.c arith3.c doscomm.c hardrtn.c lsthandl.c sxhash.c arith4.c draw.c main.c testtool.c array.c dsk.c inet.c misc7.c timer.c array2.c dspif.c initdsp.c miscn.c typeof.c array3.c initkbd.c ubf1.c array4.c dspsubrs.c initsout.c mkatom.c ubf2.c array5.c eqf.c intcall.c mkcell.c ubf3.c array6.c ether.c mkvdate.c ufn.c atom.c findkey.c kbdsubrs.c mouseif.c ufs.c bbtsub.c foreign.c keyevent.c unixcomm.c bin.c fp.c keylib.c binds.c asmbbt.c fvar.c mvs.c unwind.c bitblt.c gc.c uraid.c blt.c gc2.c kprint.c keytstno.c keytst.c osmsg.c usrsubr.c byteswap.c gcarray.c perrno.c ldeboot.c ldeether.c uutils.c carcdr.c gccode.c rawcolor.c vars3.c gcfinal.c ldsout.c return.c vmemsave.c chardev.c gchtfind.c lineblt8.c rpc.c xc.c common.c gcmain3.c lisp2c.c rplcons.c z2.c find-dsp.l dsphack.l xmkicon.c xbbt.c xinit.c xscroll.c xcursor.c xlspwin.c xrdopt.c xwinman.c dosmouse.c vesafns.asm vesainit.c vgainit.c kbdif.c dspsparc.il copyright launch.asm lpread.c lpsolve.c lpmain.c lpwrite.c lpdual.c lptran.c + +OFILES = conspage.obj gcoflow.obj shift.obj dbgtool.obj gcr.obj gcrcell.obj llstk.obj gcscan.obj loopsops.obj storage.obj allocmds.obj dir.obj gvar2.obj lowlev1.obj subr.obj arith2.obj hacks.obj lowlev2.obj subr0374.obj arith3.obj doscomm.obj hardrtn.obj lsthandl.obj sxhash.obj arith4.obj draw.obj main.obj testtool.obj array.obj dsk.obj inet.obj misc7.obj timer.obj array2.obj dspif.obj initdsp.obj miscn.obj typeof.obj array3.obj initkbd.obj ubf1.obj array4.obj dspsubrs.obj initsout.obj mkatom.obj ubf2.obj array5.obj eqf.obj intcall.obj mkcell.obj ubf3.obj array6.obj ether.obj ufn.obj atom.obj findkey.obj kbdsubrs.obj mouseif.obj ufs.obj bbtsub.obj foreign.obj keyevent.obj unixcomm.obj bin.obj fp.obj keylib.obj binds.obj fvar.obj mvs.obj unwind.obj bitblt.obj gc.obj uraid.obj blt.obj gc2.obj kprint.obj osmsg.obj usrsubr.obj byteswap.obj gcarray.obj perrno.obj uutils.obj carcdr.obj asmbbt.obj gccode.obj vars3.obj gcfinal.obj ldsout.obj return.obj vmemsave.obj chardev.obj gchtfind.obj lineblt8.obj rpc.obj xc.obj common.obj gcmain3.obj lisp2c.obj rplcons.obj z2.obj vdate.obj $(KEY) $(COLORFILES) $(ARCHFILES) $(LPFILES) + + +HFILES = address.h adr68k.h arith.h cell.h dbprint.h display.h dspif.h ifpage.h iopage.h lispemul.h lispmap.h lsptypes.h miscstat.h lspglob.h array.h bb.h bitblt.h debug.h devconf.h dspdata.h ether.h fast_dsp.h fp.h gc.h hdw_conf.h initatms.h inlinec.h keyboard.h lispver1.h lispver2.h lldsp.h locfile.h mouseif.h my.h opcodes.h osmsg.h pilotbbt.h print.h profile.h return.h stack.h stream.h subrs.h sysatms.h timeout.h tos1defs.h tosfns.h tosret.h vmemsave.h xdefs.h xbitmaps.h xkeymap.h + + + +bigvm: + CFLAGS = $(CFLAGS) -DBIGVM -DNEWCDRCODRING + make -f foot emul.exe + +emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(RM) vdate.c + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +main.o : lispemul.h address.h lsptypes.h adr68k.h stack.h lspglob.h lispmap.h ifpage.h iopage.h return.h debug.h profile.h + + + + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +medley.exe: launch.obj + TLINK launch,medley + +launch.obj: launch.asm + + # xc.obj: xc.s + # tasm /ml xc.s + # + #xc.s: xc.c + # rsh sparky (cd /users/nilsson/curr ; gcc-make $* ) + +vdate.obj : mkvdate.exe + mkvdate > vdate.c + $(CC) vdate.c -c $@ + +mkvdate.exe : ../dossrc/mkvdate.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/mkvdate.c + del copts + +xc.obj : ../dossrc/xc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/xc.c -I ../dosinc -c $@ + del copts + +lpmain.obj : ../dossrc/lpmain.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lpmain.c -I ../dosinc -c $@ + del copts + +lpsolve.obj : ../dossrc/lpsolve.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lpsolve.c -I ../dosinc -c $@ + del copts + +lpread.obj : ../dossrc/lpread.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lpread.c -I ../dosinc -c $@ + del copts + +lptran.obj : ../dossrc/lptran.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lptran.c -I ../dosinc -c $@ + del copts + +lpdual.obj : ../dossrc/lpdual.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lpdual.c -I ../dosinc -c $@ + del copts + +lpwrite.obj : ../dossrc/lpwrite.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lpwrite.c -I ../dosinc -c $@ + del copts + + + +conspage.obj : ../dossrc/conspage.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/conspage.c -I ../dosinc -c $@ + del copts + +keytstno.obj : ../dossrc/keytstno.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/keytstno.c -I ../dosinc -c $@ + del copts + +dosmouse.obj : ../dossrc/dosmouse.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/dosmouse.c -I ../dosinc -c $@ + del copts + +doskbd.obj : ../dossrc/doskbd.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/doskbd.c -I ../dosinc -c $@ + del copts + +vesafns.obj : ../dossrc/vesafns.asm + tasm /ml ..\dossrc\vesafns.asm + +vesainit.obj : ../dossrc/vesainit.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/vesainit.c -I ../dosinc -c $@ + del copts + +vgainit.obj : ../dossrc/vgainit.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/vgainit.c -I ../dosinc -c $@ + del copts + +kbdif.obj : ../dossrc/kbdif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/kbdif.c -I ../dosinc -c $@ + del copts + +gcoflow.obj : ../dossrc/gcoflow.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcoflow.c -I ../dosinc -c $@ + del copts + +shift.obj : ../dossrc/shift.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/shift.c -I ../dosinc -c $@ + del copts + +dbgtool.obj : ../dossrc/dbgtool.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/dbgtool.c -I ../dosinc -c $@ + del copts + +gcr.obj : ../dossrc/gcr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcr.c -I ../dosinc -c $@ + del copts + +gcrcell.obj : ../dossrc/gcrcell.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcrcell.c -I ../dosinc -c $@ + del copts + +llstk.obj : ../dossrc/llstk.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/llstk.c -I ../dosinc -c $@ + del copts + +gcscan.obj : ../dossrc/gcscan.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcscan.c -I ../dosinc -c $@ + del copts + +loopsops.obj : ../dossrc/loopsops.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/loopsops.c -I ../dosinc -c $@ + del copts + +storage.obj : ../dossrc/storage.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/storage.c -I ../dosinc -c $@ + del copts + +allocmds.obj : ../dossrc/allocmds.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/allocmds.c -I ../dosinc -c $@ + del copts + +dir.obj : ../dossrc/dir.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/dir.c -I ../dosinc -c $@ + del copts + +gvar2.obj : ../dossrc/gvar2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gvar2.c -I ../dosinc -c $@ + del copts + +lowlev1.obj : ../dossrc/lowlev1.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lowlev1.c -I ../dosinc -c $@ + del copts + +subr.obj : ../dossrc/subr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/subr.c -I ../dosinc -c $@ + del copts + +arith2.obj : ../dossrc/arith2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/arith2.c -I ../dosinc -c $@ + del copts + +hacks.obj : ../dossrc/hacks.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/hacks.c -I ../dosinc -c $@ + del copts + +lowlev2.obj : ../dossrc/lowlev2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lowlev2.c -I ../dosinc -c $@ + del copts + +subr0374.obj : ../dossrc/subr0374.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/subr0374.c -I ../dosinc -c $@ + del copts + +arith3.obj : ../dossrc/arith3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/arith3.c -I ../dosinc -c $@ + del copts + +doscomm.obj : ../dossrc/doscomm.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/doscomm.c -I ../dosinc -c $@ + del copts + +hardrtn.obj : ../dossrc/hardrtn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/hardrtn.c -I ../dosinc -c $@ + del copts + +lsthandl.obj : ../dossrc/lsthandl.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lsthandl.c -I ../dosinc -c $@ -Le + del copts + +sxhash.obj : ../dossrc/sxhash.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/sxhash.c -I ../dosinc -c $@ + del copts + +arith4.obj : ../dossrc/arith4.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/arith4.c -I ../dosinc -c $@ + del copts + +draw.obj : ../dossrc/draw.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/draw.c -I ../dosinc -c $@ + del copts + +main.obj : ../dossrc/main.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/main.c -I ../dosinc -c $@ + del copts + +testtool.obj : ../dossrc/testtool.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/testtool.c -I ../dosinc -c $@ + del copts + +array.obj : ../dossrc/array.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/array.c -I ../dosinc -c $@ + del copts + +dsk.obj : ../dossrc/dsk.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/dsk.c -I ../dosinc -c $@ + del copts + +inet.obj : ../dossrc/inet.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/inet.c -I ../dosinc -c $@ + del copts + +misc7.obj : ../dossrc/misc7.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/misc7.c -I ../dosinc -c $@ + del copts + +timer.obj : ../dossrc/timer.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/timer.c -I ../dosinc -c $@ + del copts + +array2.obj : ../dossrc/array2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/array2.c -I ../dosinc -c $@ + del copts + +dspif.obj : ../dossrc/dspif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/dspif.c -I ../dosinc -c $@ + del copts + +initdsp.obj : ../dossrc/initdsp.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/initdsp.c -I ../dosinc -c $@ + del copts + +miscn.obj : ../dossrc/miscn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/miscn.c -I ../dosinc -c $@ + del copts + +typeof.obj : ../dossrc/typeof.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/typeof.c -I ../dosinc -c $@ + del copts + +array3.obj : ../dossrc/array3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/array3.c -I ../dosinc -c $@ + del copts + +initkbd.obj : ../dossrc/initkbd.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/initkbd.c -I ../dosinc -c $@ + del copts + +ubf1.obj : ../dossrc/ubf1.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ubf1.c -I ../dosinc -c $@ + del copts + +array4.obj : ../dossrc/array4.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/array4.c -I ../dosinc -c $@ + del copts + +dspsubrs.obj : ../dossrc/dspsubrs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/dspsubrs.c -I ../dosinc -c $@ + del copts + +initsout.obj : ../dossrc/initsout.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/initsout.c -I ../dosinc -c $@ + del copts + +mkatom.obj : ../dossrc/mkatom.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/mkatom.c -I ../dosinc -c $@ + del copts + +ubf2.obj : ../dossrc/ubf2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ubf2.c -I ../dosinc -c $@ + del copts + +array5.obj : ../dossrc/array5.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/array5.c -I ../dosinc -c $@ + del copts + +eqf.obj : ../dossrc/eqf.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/eqf.c -I ../dosinc -c $@ + del copts + +intcall.obj : ../dossrc/intcall.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/intcall.c -I ../dosinc -c $@ + del copts + +mkcell.obj : ../dossrc/mkcell.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/mkcell.c -I ../dosinc -c $@ + del copts + +ubf3.obj : ../dossrc/ubf3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ubf3.c -I ../dosinc -c $@ + del copts + +array6.obj : ../dossrc/array6.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/array6.c -I ../dosinc -c $@ + del copts + +ether.obj : ../dossrc/ether.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ether.c -I ../dosinc -c $@ + del copts + +ufn.obj : ../dossrc/ufn.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ufn.c -I ../dosinc -c $@ + del copts + +atom.obj : ../dossrc/atom.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/atom.c -I ../dosinc -c $@ + del copts + +findkey.obj : ../dossrc/findkey.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/findkey.c -I ../dosinc -c $@ + del copts + +kbdsubrs.obj : ../dossrc/kbdsubrs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/kbdsubrs.c -I ../dosinc -c $@ + del copts + +mouseif.obj : ../dossrc/mouseif.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/mouseif.c -I ../dosinc -c $@ + del copts + +ufs.obj : ../dossrc/ufs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ufs.c -I ../dosinc -c $@ + del copts + +bbtsub.obj : ../dossrc/bbtsub.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/bbtsub.c -I ../dosinc -c $@ + del copts + +foreign.obj : ../dossrc/foreign.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/foreign.c -I ../dosinc -c $@ + del copts + +keyevent.obj : ../dossrc/keyevent.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/keyevent.c -I ../dosinc -c $@ + del copts + +unixcomm.obj : ../dossrc/unixcomm.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/unixcomm.c -I ../dosinc -c $@ + del copts + +bin.obj : ../dossrc/bin.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/bin.c -I ../dosinc -c $@ + del copts + +fp.obj : ../dossrc/fp.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/fp.c -I ../dosinc -c $@ + del copts + +keylib.obj : ../dossrc/keylib.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/keylib.c -I ../dosinc -c $@ + del copts + +binds.obj : ../dossrc/binds.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/binds.c -I ../dosinc -c $@ + del copts + +fvar.obj : ../dossrc/fvar.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/fvar.c -I ../dosinc -c $@ + del copts + +mvs.obj : ../dossrc/mvs.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/mvs.c -I ../dosinc -c $@ + del copts + +unwind.obj : ../dossrc/unwind.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/unwind.c -I ../dosinc -c $@ + del copts + +bitblt.obj : ../dossrc/bitblt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/bitblt.c -I ../dosinc -c $@ + del copts + +gc.obj : ../dossrc/gc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gc.c -I ../dosinc -c $@ + del copts + +uraid.obj : ../dossrc/uraid.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/uraid.c -I ../dosinc -c $@ + del copts + +blt.obj : ../dossrc/blt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/blt.c -I ../dosinc -c $@ + del copts + +gc2.obj : ../dossrc/gc2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gc2.c -I ../dosinc -c $@ + del copts + +kprint.obj : ../dossrc/kprint.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/kprint.c -I ../dosinc -c $@ + del copts + +osmsg.obj : ../dossrc/osmsg.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/osmsg.c -I ../dosinc -c $@ + del copts + +usrsubr.obj : ../dossrc/usrsubr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/usrsubr.c -I ../dosinc -c $@ + del copts + +byteswap.obj : ../dossrc/byteswap.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/byteswap.c -I ../dosinc -c $@ + del copts + +gcarray.obj : ../dossrc/gcarray.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcarray.c -I ../dosinc -c $@ + del copts + +perrno.obj : ../dossrc/perrno.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/perrno.c -I ../dosinc -c $@ + del copts + +uutils.obj : ../dossrc/uutils.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/uutils.c -I ../dosinc -c $@ + del copts + +carcdr.obj : ../dossrc/carcdr.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/carcdr.c -I ../dosinc -c $@ + del copts + +asmbbt.obj : ../dossrc/asmbbt.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/asmbbt.c -I ../dosinc -c $@ + del copts + +gccode.obj : ../dossrc/gccode.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gccode.c -I ../dosinc -c $@ + del copts + +vars3.obj : ../dossrc/vars3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/vars3.c -I ../dosinc -c $@ + del copts + +gcfinal.obj : ../dossrc/gcfinal.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcfinal.c -I ../dosinc -c $@ + del copts + +ldsout.obj : ../dossrc/ldsout.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/ldsout.c -I ../dosinc -c $@ + del copts + +return.obj : ../dossrc/return.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/return.c -I ../dosinc -c $@ + del copts + +vmemsave.obj : ../dossrc/vmemsave.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/vmemsave.c -I ../dosinc -c $@ + del copts + +chardev.obj : ../dossrc/chardev.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/chardev.c -I ../dosinc -c $@ + del copts + +gchtfind.obj : ../dossrc/gchtfind.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gchtfind.c -I ../dosinc -c $@ + del copts + +lineblt8.obj : ../dossrc/lineblt8.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lineblt8.c -I ../dosinc -c $@ + del copts + +rpc.obj : ../dossrc/rpc.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/rpc.c -I ../dosinc -c $@ + del copts + +common.obj : ../dossrc/common.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/common.c -I ../dosinc -c $@ + del copts + +gcmain3.obj : ../dossrc/gcmain3.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/gcmain3.c -I ../dosinc -c $@ + del copts + +lisp2c.obj : ../dossrc/lisp2c.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/lisp2c.c -I ../dosinc -c $@ + del copts + +rplcons.obj : ../dossrc/rplcons.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/rplcons.c -I ../dosinc -c $@ + del copts + +z2.obj : ../dossrc/z2.c + @ echo $(CFLAGS) > copts + $(CC) @copts ../dossrc/z2.c -I ../dosinc -c $@ + del copts + diff --git a/bin/makeinitlde b/bin/makeinitlde new file mode 100755 index 0000000..fff98eb --- /dev/null +++ b/bin/makeinitlde @@ -0,0 +1,17 @@ +# Start a csh +# Building an init needs several flags turned on and it is +# best to build an entire new LDE. + +# to run this script, enter 'makeinitlde -e' from the shell + +set architecture = `mach` +set osversion = `osversion` +set releasename = ${osversion}.${architecture} + +set initname = init.${architecture} +setenv OPTFLAGS '-DINIT -g' + +# now do the make, including the right stuff, but putting +# it all into init.mach + +(echo RELEASENAME = ${initname}; cat makefile-header makefile-${releasename} makefile-tail) | make -f - $* diff --git a/bin/makeisc b/bin/makeisc new file mode 100755 index 0000000..e2a385d --- /dev/null +++ b/bin/makeisc @@ -0,0 +1,1092 @@ +#************************************************************************/ +#* */ +#* Makefile for Medley on Interactive Unix/386 2.2.1 under X. */ +#* */ +#* (this way because ISC's csh won't work right for us) */ +#* */ +#************************************************************************/ + + + + +#************************************************************************/ +#* */ +#* (C) Copyright 1989, 1990, 1991 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + + +# values for Maiko makefile variables +# These get overridden by OS and hardware-specific stuff +# in sub-makefiles + +SRCDIR = ../src/ +INCDIR = ../inc/ +BINDIR = ./ +RELDIR = ../RELEASE/ +OBJECTDIR = /ISC.i386-x/ +INSDIR = ../ISC.i386/ +LDENAME = ldex +OSARCHNAME = ISC.i386 +# for the files that need to be included in byte-swapped implementations: +BYTESWAPFILES = +SXHASHFILE = +BITBLTFILE = + + +# for files needed by color (actually files NOT needed by X) +COLORFILES = +# Options for SunOS4, SPARC and X-Window + +XFILES = $(OBJECTDIR)XClose.o \ + $(OBJECTDIR)Cursor.o \ + $(OBJECTDIR)XWindow.o \ + $(OBJECTDIR)DoRing.o \ + $(OBJECTDIR)DoScroll.o \ + $(OBJECTDIR)XEvent.o \ + $(OBJECTDIR)XGravity.o \ + $(OBJECTDIR)XInit.o \ + $(OBJECTDIR)InitXevent.o \ + $(OBJECTDIR)XKbdMouse.o \ + $(OBJECTDIR)LispWindow.o \ + $(OBJECTDIR)LispXbitblt.o \ + $(OBJECTDIR)XKeyboard.o \ + $(OBJECTDIR)MakeXicon.o \ + $(OBJECTDIR)OpenDisplay.o \ + $(OBJECTDIR)ReadXoption.o \ + $(OBJECTDIR)XReconfig.o \ + $(OBJECTDIR)XScroll.o \ + $(OBJECTDIR)Scrollbar.o \ + $(OBJECTDIR)XCursor.o \ + $(OBJECTDIR)XMouse.o \ + $(OBJECTDIR)Subwindows.o \ + $(OBJECTDIR)VideoColor.o \ + $(OBJECTDIR)XWindowMgr.o + + +XVERSION = XV11R4 +XFLAGS = -DXWINDOW -D$(XVERSION) + +FPFLAGS = +DFLAGS = -U__STDC__ -DNO_ASM -DBIGATOMS -DFSERROR -DAIX -DSYSVONLY -DSYSVSIGNALS -DNOASM -DLOGINT -DNOPIXRECT $(XFLAGS) -DBYTESWAP -DFLTINT -D_I386 -DNOETHER -DFORKCOMM -DISC +LDFLAGS = -lX11 -lc -lm -linet + +INLINE = +BITBLTFILE = +# for the files that need to be included in byte-swapped implementations: +BYTESWAPFILES = $(OBJECTDIR)byteswapfns$(OEXT) + +# This is to make the %$#@! Apollo cc happy +OEXT = .o + +OPTFLAGS = -O -fpcc-struct-return -fstrength-reduce +DISPOPTFLAGS = -O -fpcc-struct-return -fstrength-reduce -finline-functions +CC = gcc + +default: /$(OSARCHNAME)/$(LDENAME) + +$(OBJECTDIR)xc.o : $(SRCDIR)xc.c $(INCDIR)lispemul.h $(INCDIR)emulglobal.h \ + $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)cell.h \ + $(INCDIR)initatoms.h $(INCDIR)gc.h \ + $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)dbprint.h\ + $(INCDIR)tos1defs.h $(INCDIR)tosretmacro.h \ + $(INCDIR)tosfuncall.h $(INCDIR)inlineC.h \ + $(INCDIR)profile.h $(INCDIR)inlinePS2.h + $(CC) $(DISPRFLAGS) $(SRCDIR)xc.c $(INLINE) -o $(OBJECTDIR)xc.o + + +# remainder of makefile +# +# +# +# +# +# +# NOTE: to add a NEW object file you must +# 1. Add the file.o to one of the object file lists, +# (i.e. OFILES, GCFILES, DEVICES, etc). +# 2. Add the "how to make" & dependency info such as: +# +# $(OBJECTDIR)<>.o : $(SRCDIR)<>.c \ +# $(INCDIR)lispemul.h \ +# $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ +# $(INCDIR)stack.h $(INCDIR)emulglobal.h $(INCDIR)lispmap.h \ +# $(INCDIR)gc.h +# $(CC) $(RFLAGS) $(SRCDIR)<>.c $(INLINE) -o $(OBJECTDIR)<>.o + +# to build sysouts on the sun, you must do the following: +# 1. setenv OPTFLAGS '-DINIT -g' +# 2. rm objectdir/bitblt.c objectdir/dspsubrs.c objectdir/keyevent.c +# 3. makeright -e init +# 4. follow the instructions on {eris}sunloadup>howto-loadup-sunlisp.txt + + +# '90/04/23 osamu: $INSDIR is defined in makeright +# +#INSDIR = $(RELDIR)install.$(RELEASENAME)/ +CHKDIR = $(RELDIR)checksumdir/ +NATDIR = $(RELDIR)usernative/ + +# OSARCHDIR is the os/architecture directory, where executables all go. +OSARCHDIR = /$(OSARCHNAME)/ + +# +# The DISPxxx flags are for compiling files which rely on 'as' much +# more than the other files do. For mc68020, it'll use optimization +# -O rather than -O2 which is good for the other files in the system +# [JDS 10-26-89] Files affected: xc, arith2, arith4, fvar. +# + +CFLAGS = $(OPTFLAGS) $(DFLAGS) $(FPFLAGS) +DISPCFLAGS = $(DISPOPTFLAGS) $(DFLAGS) $(FPGLAGS) +RFLAGS = -c $(CFLAGS) -I$(INCDIR) +DISPRFLAGS = -c $(DISPCFLAGS) -I$(INCDIR) + +KEYON = $(OBJECTDIR)keytester.o +KEYOFF = $(OBJECTDIR)keytestno.o + +OFILES = $(OBJECTDIR)arith2.o \ + $(OBJECTDIR)arith3.o \ + $(OBJECTDIR)arith4.o \ + $(OBJECTDIR)array.o \ + $(OBJECTDIR)array2.o \ + $(OBJECTDIR)array3.o \ + $(OBJECTDIR)array4.o \ + $(OBJECTDIR)array5.o \ + $(OBJECTDIR)array6.o \ + $(OBJECTDIR)atom.o \ + $(OBJECTDIR)bin.o \ + $(OBJECTDIR)binds.o \ + $(OBJECTDIR)bitblt.o \ + $(OBJECTDIR)bitbltsub.o \ + $(OBJECTDIR)blt.o \ + $(OBJECTDIR)car-cdr.o \ + $(OBJECTDIR)chardevice.o \ + $(OBJECTDIR)common.o \ + $(OBJECTDIR)conspage.o \ + $(OBJECTDIR)createcell.o \ + $(OBJECTDIR)draw.o \ + $(OBJECTDIR)findkey.o \ + $(OBJECTDIR)fvar.o \ + $(OBJECTDIR)xc.o \ + $(OBJECTDIR)gc.o \ + $(OBJECTDIR)gc2.o \ + $(OBJECTDIR)gvar2.o \ + $(OBJECTDIR)hardreturn.o \ + $(OBJECTDIR)inet.o \ + $(OBJECTDIR)intcall.o \ + $(OBJECTDIR)keylib.o \ + $(OBJECTDIR)lineblt8.o \ + $(OBJECTDIR)listhandle.o \ + $(OBJECTDIR)llcolor.o \ + $(OBJECTDIR)llstk.o \ + $(OBJECTDIR)loopsops.o \ + $(OBJECTDIR)lowlevel1.o \ + $(OBJECTDIR)lowlevel2.o \ + $(OBJECTDIR)misc7.o \ + $(OBJECTDIR)mvs.o \ + $(OBJECTDIR)return.o \ + $(OBJECTDIR)rplcons.o \ + $(OBJECTDIR)shift.o \ + $(OBJECTDIR)subr.o \ + $(OBJECTDIR)miscn.o \ + $(OBJECTDIR)subr0374.o \ + $(OBJECTDIR)timer.o \ + $(OBJECTDIR)typeof.o \ + $(OBJECTDIR)unwind.o \ + $(OBJECTDIR)vars3.o \ + $(OBJECTDIR)unixcomm.o \ + $(OBJECTDIR)uraid.o \ + $(OBJECTDIR)rpc.o \ + $(OBJECTDIR)ufn.o \ + $(OBJECTDIR)z2.o \ + $(OBJECTDIR)eqf.o \ + $(OBJECTDIR)fp.o \ + $(OBJECTDIR)ubf1.o \ + $(OBJECTDIR)ubf2.o \ + $(OBJECTDIR)ubf3.o \ + $(OBJECTDIR)unix-utils.o \ + $(OBJECTDIR)syscallmsg.o \ + $(OBJECTDIR)osmessage.o + +GCFILES = $(OBJECTDIR)gcscan.o \ + $(OBJECTDIR)gcarrayops.o \ + $(OBJECTDIR)gccode.o \ + $(OBJECTDIR)gcfinal.o \ + $(OBJECTDIR)gcreccell.o \ + $(OBJECTDIR)gchtfind.o \ + $(OBJECTDIR)gcmain3.o \ + $(OBJECTDIR)gcreclaim.o \ + $(OBJECTDIR)gchoverflow.o + +DEVICES = $(OBJECTDIR)dspsubrs.o \ + $(OBJECTDIR)initdisplay.o \ + $(OBJECTDIR)dsk.o \ + $(OBJECTDIR)ufs.o \ + $(OBJECTDIR)directory.o \ + $(OBJECTDIR)keyevent.o \ + $(OBJECTDIR)kbdsubrs.o \ + $(OBJECTDIR)ether.o \ + $(OBJECTDIR)initkbd.o + +TESTFILES = $(OBJECTDIR)debugtools.o \ + $(OBJECTDIR)testtool.o \ + $(OBJECTDIR)Kprint.o + +MAINFILES = $(OBJECTDIR)main.o \ + $(OBJECTDIR)initsysout.o \ + $(OBJECTDIR)storage.o \ + $(OBJECTDIR)allocmds.o \ + $(OBJECTDIR)vmemsave.o \ + $(OBJECTDIR)newmakeatom.o \ + $(OBJECTDIR)loadsysout.o + +SXHASHFILE = $(OBJECTDIR)sxhash.o + +VFILE = $(OBJECTDIR)vdate + +DEVFILES = $(OFILES) $(KEYOFF) $(TESTFILES) $(BYTESWAPFILES) $(MAINFILES) $(DEVICES) \ + $(GCFILES) $(SXHASHFILE) $(BITBLTFILE) $(XFILES) $(COLORFILES) +LIBFILES = $(OFILES) $(KEYON) $(TESTFILES) $(BYTESWAPFILES) $(MAINFILES) $(DEVICES) \ + $(GCFILES) $(SXHASHFILE) $(BITBLTFILE) $(XFILES) $(COLORFILES) +EXTFILES = $(OBJECTDIR)usersubrs.o + +# execute to make /tmp/vdate.c + +################################################################################ +# Development targets - copyprotect is OFF here +################################################################################ + +default : $(OSARCHDIR)lde $(OSARCHDIR)$(LDENAME) $(OSARCHDIR)ldeether \ + $(OSARCHDIR)testsysout $(OSARCHDIR)setsysout + +$(OSARCHDIR)lde: $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c + $(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c \ + $(LDFLAGS) -o $(OSARCHDIR)lde + +$(OSARCHDIR)$(LDENAME) : $(DEVFILES) $(EXTFILES) $(OSARCHDIR)makevdate + /bin/rm -f $(VFILE).c + $(OSARCHDIR)makevdate > $(VFILE).c + $(CC) -g $(CFLAGS) $(DEVFILES) $(EXTFILES) $(VFILE).c \ + $(LDFLAGS) -o $(OSARCHDIR)$(LDENAME) + @ echo "" + @ echo "Executable is now named '$(OSARCHDIR)$(LDENAME)'" + +$(OSARCHDIR)ldeether : $(SRCDIR)ldeether.c + $(CC) $(CFLAGS) $(SRCDIR)ldeether.c -o $(OSARCHDIR)ldeether + @ echo "" + @ echo "ethernet kickstart is now named 'ldeether'" + @ echo "Now making ldeether setuid root" + - rsh python "(cd `pwd`;/users/maiko/bin/suid $(OSARCHDIR)ldeether)" + ls -l $(OSARCHDIR)ldeether + +$(OSARCHDIR)makevdate : $(SRCDIR)makevdate.c + $(CC) $(CFLAGS) $(SRCDIR)makevdate.c -o $(OSARCHDIR)makevdate + +$(OSARCHDIR)testsysout : $(OBJECTDIR)testsysout.o + $(CC) $(OBJECTDIR)testsysout.o -lc -lm -o $(OSARCHDIR)testsysout + +$(OSARCHDIR)setsysout : $(OBJECTDIR)setsysout.o + $(CC) $(OBJECTDIR)setsysout.o -lc -lm -o $(OSARCHDIR)setsysout + + +$(OSARCHDIR)testdisplay : $(SRCDIR)testdisplay.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)display.h $(INCDIR)dbprint.h + $(CC) $(CFLAGS) -DDEBUG -I$(INCDIR) $(SRCDIR)testdisplay.c -lsuntool -lsunwindow -lpixrect -lc -lm -o $(OSARCHDIR)testdisplay + +#### Component files ###################################################### + +$(OBJECTDIR)testsysout.o: $(SRCDIR)testsysout.c + $(CC) -c $(SRCDIR)testsysout.c -I../inc -o $(OBJECTDIR)testsysout$(OEXT) + +$(OBJECTDIR)setsysout.o: $(SRCDIR)setsysout.c + $(CC) -c $(SRCDIR)setsysout.c -I../inc -o $(OBJECTDIR)setsysout$(OEXT) + +$(OBJECTDIR)main.o : $(SRCDIR)main.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)address.h $(INCDIR)lisptypes.h \ + $(INCDIR)address68k.h $(INCDIR)stack.h $(INCDIR)lispglobal.h \ + $(INCDIR)lispmap.h $(INCDIR)ifpage.h $(INCDIR)iopage.h \ + $(INCDIR)return.h $(INCDIR)debug.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)main.c $(INLINE) -o $(OBJECTDIR)main$(OEXT) + +$(OBJECTDIR)debugtools.o : $(SRCDIR)debugtools.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)cell.h $(INCDIR)stack.h + $(CC) $(RFLAGS) $(SRCDIR)debugtools.c $(INLINE) -o $(OBJECTDIR)debugtools$(OEXT) + +$(OBJECTDIR)Kprint.o : $(SRCDIR)Kprint.c $(INCDIR)print.h \ + $(INCDIR)address.h $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispglobal.h $(INCDIR)initatoms.h \ + $(INCDIR)cell.h $(INCDIR)emulglobal.h $(INCDIR)lispmap.h \ + $(INCDIR)address68k.h + $(CC) $(RFLAGS) $(SRCDIR)Kprint.c $(INLINE) -o $(OBJECTDIR)Kprint$(OEXT) + +$(OBJECTDIR)testtool.o : $(SRCDIR)testtool.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)cell.h $(INCDIR)stack.h $(INCDIR)ifpage.h + $(CC) $(RFLAGS) $(SRCDIR)testtool.c $(INLINE) -o $(OBJECTDIR)testtool$(OEXT) + +$(OBJECTDIR)allocmds.o : $(SRCDIR)allocmds.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)cell.h $(INCDIR)lispmap.h \ + $(INCDIR)initatoms.h $(INCDIR)systematoms.h $(INCDIR)lispglobal.h + $(CC) $(RFLAGS) $(SRCDIR)allocmds.c $(INLINE) -o $(OBJECTDIR)allocmds$(OEXT) + +$(OBJECTDIR)arith2.o : $(SRCDIR)arith2.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)address68k.h $(INCDIR)lispmap.h $(INCDIR)lisptypes.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INLINE) + $(CC) $(DISPRFLAGS) $(SRCDIR)arith2.c $(INLINE) -o $(OBJECTDIR)arith2$(OEXT) + +$(OBJECTDIR)arith3.o : $(SRCDIR)arith3.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h $(INLINE) \ + $(INCDIR)lispglobal.h $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)cell.h $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)arith3.c $(INLINE) -o $(OBJECTDIR)arith3$(OEXT) + +$(OBJECTDIR)arith4.o : $(SRCDIR)arith4.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h $(INLINE) \ + $(INCDIR)lispglobal.h $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)cell.h $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(DISPRFLAGS) $(SRCDIR)arith4.c $(INLINE) -o $(OBJECTDIR)arith4$(OEXT) + +$(OBJECTDIR)array.o : $(SRCDIR)array.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array.c $(INLINE) -o $(OBJECTDIR)array$(OEXT) + +$(OBJECTDIR)array3.o : $(SRCDIR)array3.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array3.c $(INLINE) -o $(OBJECTDIR)array3$(OEXT) + +$(OBJECTDIR)array5.o : $(SRCDIR)array5.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h $(INCDIR)fp.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array5.c $(INLINE) -o $(OBJECTDIR)array5$(OEXT) + +$(OBJECTDIR)atom.o : $(SRCDIR)atom.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h + $(CC) $(RFLAGS) $(SRCDIR)atom.c $(INLINE) -o $(OBJECTDIR)atom$(OEXT) + +$(OBJECTDIR)bin.o : $(SRCDIR)bin.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)cell.h $(INCDIR)stream.h + $(CC) $(RFLAGS) $(SRCDIR)bin.c $(INLINE) -o $(OBJECTDIR)bin$(OEXT) + +$(OBJECTDIR)binds.o : $(SRCDIR)binds.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h + $(CC) $(RFLAGS) $(SRCDIR)binds.c $(INLINE) -o $(OBJECTDIR)binds$(OEXT) + +$(OBJECTDIR)bitblt.o : $(SRCDIR)bitblt.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)lispmap.h \ + $(INCDIR)emulglobal.h $(INCDIR)address68k.h $(INCDIR)address.h \ + $(INCDIR)pilotbbt.h $(INCDIR)display.h $(INCDIR)bitblt.h \ + $(INCDIR)bb.h + $(CC) $(RFLAGS) $(SRCDIR)bitblt.c $(INLINE) -o $(OBJECTDIR)bitblt$(OEXT) + +$(OBJECTDIR)bitblt68K.o : $(OBJECTDIR)bitblt68K.i $(SRCDIR)bitblt68K.s + as -O $(OBJECTDIR)bitblt68K.i -o $(OBJECTDIR)bitblt68K$(OEXT) + +$(OBJECTDIR)bitblt68K.i : $(SRCDIR)bitblt68K.s + /lib/cpp $(SRCDIR)bitblt68K.s $(OBJECTDIR)bitblt68K.i + +$(OBJECTDIR)bitbltSPARC.o : $(SRCDIR)bitbltSPARC.s + as -P $(SRCDIR)bitbltSPARC.s -o $(OBJECTDIR)bitbltSPARC$(OEXT) + +$(OBJECTDIR)bitblt386i.o : $(SRCDIR)bitblt386i.s $(OBJECTDIR)bitblt386i.i + as $(OBJECTDIR)bitblt386i.i -o $(OBJECTDIR)bitblt386i$(OEXT) + +$(OBJECTDIR)bitblt386i.i : $(SRCDIR)bitblt386i.s + /lib/cpp $(SRCDIR)bitblt386i.s $(OBJECTDIR)bitblt386i.i + +$(OBJECTDIR)bitbltsub.o : $(SRCDIR)bitbltsub.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)lispmap.h $(INCDIR)lisptypes.h \ + $(INCDIR)emulglobal.h $(INCDIR)address68k.h $(INCDIR)address.h \ + $(INCDIR)pilotbbt.h $(INCDIR)display.h $(INCDIR)displaydata.h \ + $(INCDIR)bitblt.h $(INCDIR)bb.h $(INCDIR)dbprint.h \ + $(INCDIR)stack.h $(INCDIR)cell.h $(INCDIR)gc.h $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)bitbltsub.c $(INLINE) -o $(OBJECTDIR)bitbltsub$(OEXT) + +$(OBJECTDIR)blt.o : $(SRCDIR)blt.c $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)blt.c $(INLINE) -o $(OBJECTDIR)blt$(OEXT) + +$(OBJECTDIR)byteswapfns.o: $(SRCDIR)byteswapfns.c $(INLINE) + $(CC) $(RFLAGS) $(SRCDIR)byteswapfns.c $(INLINE) -o $(OBJECTDIR)byteswapfns$(OEXT) + +$(OBJECTDIR)car-cdr.o : $(SRCDIR)car-cdr.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)gc.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)car-cdr.c $(INLINE) -o $(OBJECTDIR)car-cdr$(OEXT) + +$(OBJECTDIR)chardevice.o : $(SRCDIR)chardevice.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)lispglobal.h $(INCDIR)stream.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)osmessage.h $(INCDIR)arith.h $(INCDIR)localfile.h + $(CC) $(RFLAGS) $(SRCDIR)chardevice.c $(INLINE) -o $(OBJECTDIR)chardevice$(OEXT) + +$(OBJECTDIR)colorbltfns.o : $(SRCDIR)colorbltfns.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)lispmap.h $(INCDIR)lisptypes.h \ + $(INCDIR)emulglobal.h $(INCDIR)address68k.h $(INCDIR)address.h \ + $(INCDIR)pilotbbt.h $(INCDIR)display.h $(INCDIR)bitblt.h \ + $(INCDIR)arith.h $(INCDIR)displaydata.h $(INCDIR)debug.h \ + $(INCDIR)stream.h + $(CC) $(RFLAGS) $(SRCDIR)colorbltfns.c $(INLINE) -o $(OBJECTDIR)colorbltfns$(OEXT) + +$(OBJECTDIR)llcolor.o : $(SRCDIR)llcolor.c $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h $(INCDIR)display.h \ + $(INCDIR)devconfig.h $(INCDIR)bb.h $(INCDIR)bitblt.h $(INCDIR)pilotbbt.h \ + $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)llcolor.c $(INLINE) -o $(OBJECTDIR)llcolor$(OEXT) + +$(OBJECTDIR)lineblt8.o : $(SRCDIR)lineblt8.c $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)lineblt8.c $(INLINE) -o $(OBJECTDIR)lineblt8$(OEXT) + +$(OBJECTDIR)common.o : $(SRCDIR)common.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address68k.h $(INCDIR)lispglobal.h \ + $(INCDIR)emulglobal.h + $(CC) $(RFLAGS) $(SRCDIR)common.c $(INLINE) -o $(OBJECTDIR)common$(OEXT) + +$(OBJECTDIR)conspage.o : $(SRCDIR)conspage.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)cell.h $(INCDIR)lispmap.h \ + $(INCDIR)gc.h $(INCDIR)lispglobal.h + $(CC) $(RFLAGS) $(SRCDIR)conspage.c $(INLINE) -o $(OBJECTDIR)conspage$(OEXT) + +$(OBJECTDIR)createcell.o : $(SRCDIR)createcell.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)cell.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)createcell.c $(INLINE) -o $(OBJECTDIR)createcell$(OEXT) + +$(OBJECTDIR)draw.o : $(SRCDIR)draw.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)draw.c $(INLINE) -o $(OBJECTDIR)draw$(OEXT) + +$(OBJECTDIR)z2.o : $(SRCDIR)z2.c \ + $(INCDIR)lispemul.h $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)gc.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)z2.c $(INLINE) -o $(OBJECTDIR)z2$(OEXT) + +$(OBJECTDIR)eqf.o : $(SRCDIR)eqf.c $(INCDIR)fp.h \ + $(INCDIR)lispemul.h $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)eqf.c $(INLINE) -o $(OBJECTDIR)eqf$(OEXT) + +$(OBJECTDIR)fp.o : $(SRCDIR)fp.c \ + $(INCDIR)lispemul.h $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)my.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)fp.c $(INLINE) -o $(OBJECTDIR)fp$(OEXT) + +$(OBJECTDIR)intcall.o : $(SRCDIR)intcall.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h $(INCDIR)lisptypes.h \ + $(INCDIR)lispmap.h $(INCDIR)stack.h $(INCDIR)return.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h $(INCDIR)initatoms.h \ + $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)intcall.c $(INLINE) -o $(OBJECTDIR)intcall$(OEXT) + +$(OBJECTDIR)ubf1.o : $(SRCDIR)ubf1.c $(INCDIR)fp.h \ + $(INCDIR)lispemul.h $(INCDIR)address68k.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)ubf1.c $(INLINE) -o $(OBJECTDIR)ubf1$(OEXT) + +$(OBJECTDIR)ubf2.o : $(SRCDIR)ubf2.c \ + $(INCDIR)lispemul.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)ubf2.c $(INLINE) -o $(OBJECTDIR)ubf2$(OEXT) + +$(OBJECTDIR)ubf3.o : $(SRCDIR)ubf3.c \ + $(INCDIR)lispemul.h $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)ubf3.c $(INLINE) -o $(OBJECTDIR)ubf3$(OEXT) + +$(OBJECTDIR)unix-utils.o : $(SRCDIR)unix-utils.c \ + $(INCDIR)lisptypes.h $(INCDIR)keyboard.h + $(CC) $(RFLAGS) $(SRCDIR)unix-utils.c $(INLINE) -o $(OBJECTDIR)unix-utils$(OEXT) + +$(OBJECTDIR)dspsubrs.o : $(SRCDIR)dspsubrs.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)display.h $(INCDIR)lisptypes.h \ + $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)dspsubrs.c $(INLINE) -o $(OBJECTDIR)dspsubrs$(OEXT) + +$(OBJECTDIR)ether.o : $(SRCDIR)ether.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)ether.h + $(CC) $(RFLAGS) $(SRCDIR)ether.c $(INLINE) -o $(OBJECTDIR)ether$(OEXT) + +$(OBJECTDIR)findkey.o : $(SRCDIR)findkey.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)stack.h $(INCDIR)lispglobal.h $(INCDIR)address68k.h + $(CC) $(RFLAGS) $(SRCDIR)findkey.c $(INLINE) -o $(OBJECTDIR)findkey$(OEXT) + +$(OBJECTDIR)dsk.o : $(SRCDIR)dsk.c $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)address68k.h $(INCDIR)lisptypes.h $(INCDIR)lispglobal.h \ + $(INCDIR)fp.h $(INCDIR)arith.h $(INCDIR)stream.h $(INCDIR)timeout.h \ + $(INCDIR)localfile.h $(INCDIR)osmessage.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)dsk.c $(INLINE) -o $(OBJECTDIR)dsk$(OEXT) + +$(OBJECTDIR)ufs.o : $(SRCDIR)ufs.c $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)address68k.h $(INCDIR)dbprint.h $(INLINE)\ + $(INCDIR)lisptypes.h $(INCDIR)lispglobal.h $(INCDIR)arith.h \ + $(INCDIR)stream.h $(INCDIR)timeout.h $(INCDIR)localfile.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)ufs.c $(INLINE) -o $(OBJECTDIR)ufs$(OEXT) + +$(OBJECTDIR)directory.o : $(SRCDIR)directory.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address68k.h $(INCDIR)lisptypes.h \ + $(INCDIR)arith.h $(INCDIR)lispglobal.h $(INCDIR)timeout.h $(INCDIR)localfile.h + $(CC) $(RFLAGS) $(SRCDIR)directory.c $(INLINE) -o $(OBJECTDIR)directory$(OEXT) + +$(OBJECTDIR)fvar.o : $(SRCDIR)fvar.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)stack.h $(INCDIR)emulglobal.h $(INCDIR)lispmap.h \ + $(INCDIR)gc.h $(INCDIR)lisptypes.h + $(CC) $(DISPRFLAGS) $(SRCDIR)fvar.c $(INLINE) -o $(OBJECTDIR)fvar$(OEXT) + +$(OBJECTDIR)gc.o : $(SRCDIR)gc.c $(INCDIR)lispemul.h $(INCDIR)gc.h \ + $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h + $(CC) $(RFLAGS) $(SRCDIR)gc.c $(INLINE) -o $(OBJECTDIR)gc$(OEXT) + +$(OBJECTDIR)gc2.o : $(SRCDIR)gc2.c $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)lisptypes.h \ + $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h $(INCDIR)address.h \ + $(INCDIR)address68k.h + $(CC) $(RFLAGS) $(SRCDIR)gc2.c $(INLINE) -o $(OBJECTDIR)gc2$(OEXT) + +$(OBJECTDIR)gcarrayops.o : $(SRCDIR)gcarrayops.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)stack.h \ + $(INCDIR)cell.h $(INCDIR)ifpage.h $(INCDIR)gc.h \ + $(INCDIR)array.h + $(CC) $(RFLAGS) $(SRCDIR)gcarrayops.c $(INLINE) -o $(OBJECTDIR)gcarrayops$(OEXT) + +$(OBJECTDIR)gcfinal.o : $(SRCDIR)gcfinal.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)stack.h \ + $(INCDIR)cell.h $(INCDIR)ifpage.h $(INCDIR)gc.h \ + $(INCDIR)array.h + $(CC) $(RFLAGS) $(SRCDIR)gcfinal.c $(INLINE) -o $(OBJECTDIR)gcfinal$(OEXT) + +$(OBJECTDIR)gchoverflow.o : $(SRCDIR)gchoverflow.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gchoverflow.c $(INLINE) -o $(OBJECTDIR)gchoverflow$(OEXT) + +$(OBJECTDIR)gchtfind.o : $(SRCDIR)gchtfind.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)gc.h \ + $(INCDIR)lispmap.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)gchtfind.c $(INLINE) -o $(OBJECTDIR)gchtfind$(OEXT) + +$(OBJECTDIR)gcmain3.o : $(SRCDIR)gcmain3.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)stack.h $(INCDIR)cell.h $(INCDIR)ifpage.h \ + $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcmain3.c $(INLINE) -o $(OBJECTDIR)gcmain3$(OEXT) + +$(OBJECTDIR)gcreclaim.o : $(SRCDIR)gcreclaim.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)lisptypes.h \ + $(INCDIR)address.h $(INCDIR)address68k.h $(INCDIR)lispglobal.h \ + $(INCDIR)stack.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcreclaim.c $(INLINE) -o $(OBJECTDIR)gcreclaim$(OEXT) + +$(OBJECTDIR)gcreccell.o : $(SRCDIR)gcreccell.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h $(INCDIR)dbprint.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)stack.h \ + $(INCDIR)cell.h $(INCDIR)ifpage.h $(INCDIR)gc.h + $(CC) $(RFLAGS) $(SRCDIR)gcreccell.c $(INLINE) -o $(OBJECTDIR)gcreccell$(OEXT) + +$(OBJECTDIR)gccode.o : $(SRCDIR)gccode.c \ + $(INCDIR)lispemul.h $(INCDIR)lisptypes.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)lispmap.h \ + $(INCDIR)stack.h $(INCDIR)cell.h $(INCDIR)ifpage.h \ + $(INCDIR)gc.h $(INCDIR)array.h + $(CC) $(RFLAGS) $(SRCDIR)gccode.c $(INLINE) -o $(OBJECTDIR)gccode$(OEXT) + +$(OBJECTDIR)gcscan.o : $(SRCDIR)gcscan.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)gc.h $(INCDIR)lisptypes.h + $(CC) $(RFLAGS) $(SRCDIR)gcscan.c $(INLINE) -o $(OBJECTDIR)gcscan$(OEXT) + +$(OBJECTDIR)gvar2.o : $(SRCDIR)gvar2.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)gc.h $(INCDIR)emulglobal.h $(INCDIR)cell.h $(INCDIR)lisptypes.h + $(CC) $(RFLAGS) $(SRCDIR)gvar2.c $(INLINE) -o $(OBJECTDIR)gvar2$(OEXT) + +$(OBJECTDIR)hardreturn.o : $(SRCDIR)hardreturn.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)cell.h $(INCDIR)stack.h $(INCDIR)return.h \ + $(INCDIR)emulglobal.h + $(CC) $(RFLAGS) $(SRCDIR)hardreturn.c $(INLINE) -o $(OBJECTDIR)hardreturn$(OEXT) + +$(OBJECTDIR)inet.o : $(SRCDIR)inet.c $(INCDIR)lispemul.h $(INCDIR)arith.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h $(INCDIR)ether.h \ + $(INCDIR)dbprint.h $(INCDIR)localfile.h + $(CC) $(RFLAGS) $(SRCDIR)inet.c $(INLINE) -o $(OBJECTDIR)inet$(OEXT) + +$(OBJECTDIR)initdisplay.o : $(SRCDIR)initdisplay.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address.h $(INCDIR)lisptypes.h \ + $(INCDIR)address68k.h $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)display.h $(INCDIR)dbprint.h $(INLINE) + $(CC) $(RFLAGS) $(SRCDIR)initdisplay.c $(INLINE) -o $(OBJECTDIR)initdisplay$(OEXT) + +$(OBJECTDIR)initkbd.o : $(SRCDIR)initkbd.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)lispglobal.h \ + $(INCDIR)address68k.h $(INCDIR)address.h $(INCDIR)iopage.h \ + $(INCDIR)ifpage.h + $(CC) $(RFLAGS) $(SRCDIR)initkbd.c $(INLINE) -o $(OBJECTDIR)initkbd$(OEXT) + +$(OBJECTDIR)initsysout.o : $(SRCDIR)initsysout.c $(INCDIR)hdw_config.h \ + $(INCDIR)lispemul.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)address68k.h \ + $(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)cell.h \ + $(INCDIR)systematoms.h + $(CC) $(RFLAGS) $(SRCDIR)initsysout.c $(INLINE) -o $(OBJECTDIR)initsysout$(OEXT) + +$(OBJECTDIR)kbdsubrs.o : $(SRCDIR)kbdsubrs.c $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)kbdsubrs.c $(INLINE) -o $(OBJECTDIR)kbdsubrs$(OEXT) + +$(OBJECTDIR)keyevent.o : $(SRCDIR)keyevent.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)address.h $(INCDIR)stack.h $(INCDIR)iopage.h \ + $(INCDIR)ifpage.h $(INCDIR)keyboard.h $(INCDIR)display.h \ + $(INCDIR)pilotbbt.h + $(CC) $(RFLAGS) $(SRCDIR)keyevent.c $(INLINE) -o $(OBJECTDIR)keyevent$(OEXT) + +$(OBJECTDIR)keylib.o : $(SRCDIR)keylib.c + $(CC) $(RFLAGS) $(SRCDIR)keylib.c $(INLINE) -o $(OBJECTDIR)keylib$(OEXT) + +$(OBJECTDIR)keytester.o : $(SRCDIR)keytester.c + $(CC) $(RFLAGS) $(SRCDIR)keytester.c $(INLINE) -o $(OBJECTDIR)keytester$(OEXT) + +$(OBJECTDIR)keytestno.o : $(SRCDIR)keytestno.c + $(CC) $(RFLAGS) $(SRCDIR)keytestno.c $(INLINE) -o $(OBJECTDIR)keytestno$(OEXT) + +$(OBJECTDIR)listhandle.o : $(SRCDIR)listhandle.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)listhandle.c $(INLINE) -o $(OBJECTDIR)listhandle$(OEXT) + +$(OBJECTDIR)llstk.o : $(SRCDIR)llstk.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)address68k.h \ + $(INCDIR)address.h $(INCDIR)lisptypes.h $(INCDIR)initatoms.h \ + $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h $(INCDIR)cell.h \ + $(INCDIR)stack.h + $(CC) $(RFLAGS) $(SRCDIR)llstk.c $(INLINE) -o $(OBJECTDIR)llstk$(OEXT) + +#$(OBJECTDIR)loader.o : $(SRCDIR)loader.c +# $(CC) $(RFLAGS) $(SRCDIR)loader.c $(INLINE) -o $(OBJECTDIR)loader$(OEXT) + +$(OBJECTDIR)loadsysout.o : $(SRCDIR)loadsysout.c $(INCDIR)address68k.h \ + $(INCDIR)lispemul.h $(INCDIR)lispmap.h $(INCDIR)lispglobal.h \ + $(INCDIR)ifpage.h $(INCDIR)dbprint.h $(INCDIR)lisptypes.h $(INLINE) + $(CC) $(RFLAGS) $(SRCDIR)loadsysout.c $(INLINE) -o $(OBJECTDIR)loadsysout$(OEXT) + +$(OBJECTDIR)loopsops.o : $(SRCDIR)loopsops.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)address.h $(INCDIR)lisptypes.h \ + $(INCDIR)address68k.h $(INCDIR)cell.h $(INCDIR)lispglobal.h \ + $(INCDIR)lispmap.h $(INCDIR)ifpage.h $(INCDIR)iopage.h \ + $(INCDIR)debug.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)loopsops.c $(INLINE) -o $(OBJECTDIR)loopsops$(OEXT) + +$(OBJECTDIR)lowlevel1.o : $(SRCDIR)lowlevel1.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)emulglobal.h $(INCDIR)lisptypes.h + $(CC) $(RFLAGS) $(SRCDIR)lowlevel1.c $(INLINE) -o $(OBJECTDIR)lowlevel1$(OEXT) + +$(OBJECTDIR)lowlevel2.o : $(SRCDIR)lowlevel2.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h + $(CC) $(RFLAGS) $(SRCDIR)lowlevel2.c $(INLINE) -o $(OBJECTDIR)lowlevel2$(OEXT) + +$(OBJECTDIR)misc7.o : $(SRCDIR)misc7.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)stack.h $(INCDIR)opcodes.h $(INCDIR)display.h + $(CC) $(RFLAGS) $(SRCDIR)misc7.c $(INLINE) -o $(OBJECTDIR)misc7$(OEXT) + +$(OBJECTDIR)mvs.o : $(SRCDIR)mvs.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)stack.h $(INCDIR)opcodes.h + $(CC) $(RFLAGS) $(SRCDIR)mvs.c $(INLINE) -o $(OBJECTDIR)mvs$(OEXT) + +$(OBJECTDIR)newmakeatom.o : $(SRCDIR)newmakeatom.c $(INCDIR)lispemul.h \ + $(INCDIR)address68k.h $(INCDIR)lisptypes.h \ + $(INCDIR)lispmap.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)newmakeatom.c $(INLINE) -o $(OBJECTDIR)newmakeatom$(OEXT) + +$(OBJECTDIR)osmessage.o : $(SRCDIR)osmessage.c $(INCDIR)lispemul.h \ + $(INCDIR)address68k.h $(INCDIR)stream.h $(INCDIR)arith.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h + $(CC) $(RFLAGS) $(SRCDIR)osmessage.c $(INLINE) -o $(OBJECTDIR)osmessage$(OEXT) + +$(OBJECTDIR)return.o : $(SRCDIR)return.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h $(INCDIR)initatoms.h \ + $(INCDIR)return.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)return.c $(INLINE) -o $(OBJECTDIR)return$(OEXT) + +$(OBJECTDIR)rplcons.o : $(SRCDIR)rplcons.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h \ + $(INCDIR)lisptypes.h $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)gc.h $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)rplcons.c $(INLINE) -o $(OBJECTDIR)rplcons$(OEXT) + +$(OBJECTDIR)rs232c.o : $(SRCDIR)rs232c.c $(INCDIR)rs232c.h + $(CC) $(RFLAGS) $(SRCDIR)rs232c.c $(INLINE) -o $(OBJECTDIR)rs232c$(OEXT) + +$(OBJECTDIR)shift.o : $(SRCDIR)shift.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)emulglobal.h \ + $(INCDIR)address68k.h $(INCDIR)lispmap.h $(INCDIR)lisptypes.h \ + $(INCDIR)arith.h $(INCDIR)fp.h + $(CC) $(RFLAGS) $(SRCDIR)shift.c $(INLINE) -o $(OBJECTDIR)shift$(OEXT) + +$(OBJECTDIR)storage.o : $(SRCDIR)storage.c $(INCDIR)hdw_config.h \ + $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)lispglobal.h $(INCDIR)cell.h $(INCDIR)lisptypes.h \ + $(INCDIR)ifpage.h + $(CC) $(RFLAGS) $(SRCDIR)storage.c $(INLINE) -o $(OBJECTDIR)storage$(OEXT) + +$(OBJECTDIR)subr.o : $(SRCDIR)subr.c \ + $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)subrs.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)arith.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)subr.c $(INLINE) -o $(OBJECTDIR)subr$(OEXT) + +$(OBJECTDIR)miscn.o : $(SRCDIR)miscn.c \ + $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)address68k.h $(INCDIR)subrs.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h \ + $(INCDIR)arith.h $(INCDIR)profile.h + $(CC) $(RFLAGS) $(SRCDIR)miscn.c $(INLINE) -o $(OBJECTDIR)miscn$(OEXT) + + +$(OBJECTDIR)subr0374.o : $(SRCDIR)subr0374.c $(INCDIR)lispemul.h $(INCDIR)address68k.h $(INCDIR)lispglobal.h + $(CC) $(RFLAGS) $(SRCDIR)subr0374.c $(INLINE) -o $(OBJECTDIR)subr0374$(OEXT) + +$(OBJECTDIR)syscallmsg.o : $(SRCDIR)syscallmsg.c + $(CC) $(RFLAGS) $(SRCDIR)syscallmsg.c $(INLINE) -o $(OBJECTDIR)syscallmsg$(OEXT) + +$(OBJECTDIR)timer.o : $(SRCDIR)timer.c $(INCDIR)lispemul.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h \ + $(INCDIR)address68k.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)timer.c $(INLINE) -o $(OBJECTDIR)timer$(OEXT) + +$(OBJECTDIR)tty.o : $(SRCDIR)tty.c $(INCDIR)tty.h + $(CC) $(RFLAGS) $(SRCDIR)tty.c $(INLINE) -o $(OBJECTDIR)tty$(OEXT) + +$(OBJECTDIR)typeof.o : $(SRCDIR)typeof.c $(INCDIR)lispemul.h \ + $(INCDIR)lisptypes.h $(INCDIR)cell.h \ + $(INCDIR)lispmap.h + $(CC) $(RFLAGS) $(SRCDIR)typeof.c $(INLINE) -o $(OBJECTDIR)typeof$(OEXT) + +$(OBJECTDIR)ufn.o : $(SRCDIR)ufn.c $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h $(INCDIR)initatoms.h \ + $(INCDIR)cell.h + $(CC) $(RFLAGS) $(SRCDIR)ufn.c $(INLINE) -o $(OBJECTDIR)ufn$(OEXT) + +$(OBJECTDIR)unixcomm.o : $(SRCDIR)unixcomm.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)arith.h + $(CC) $(RFLAGS) $(SRCDIR)unixcomm.c $(INLINE) -o $(OBJECTDIR)unixcomm$(OEXT) + +$(OBJECTDIR)uraid.o : $(SRCDIR)uraid.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)debug.h + $(CC) $(RFLAGS) $(SRCDIR)uraid.c $(INLINE) -o $(OBJECTDIR)uraid$(OEXT) + +$(OBJECTDIR)rpc.o : $(SRCDIR)rpc.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)emulglobal.h \ + $(INCDIR)lispglobal.h $(INCDIR)cell.h $(INCDIR)stack.h \ + $(INCDIR)arith.h $(INCDIR)localfile.h + $(CC) $(RFLAGS) $(SRCDIR)rpc.c $(INLINE) -o $(OBJECTDIR)rpc$(OEXT) + +$(OBJECTDIR)unwind.o : $(SRCDIR)unwind.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h \ + $(INCDIR)lisptypes.h $(INCDIR)lispmap.h $(INCDIR)stack.h \ + $(INCDIR)emulglobal.h $(INCDIR)lispglobal.h + $(CC) $(RFLAGS) $(SRCDIR)unwind.c $(INLINE) -o $(OBJECTDIR)unwind$(OEXT) + +$(OBJECTDIR)vars3.o : $(SRCDIR)vars3.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)lispmap.h \ + $(INCDIR)address68k.h $(INCDIR)emulglobal.h $(INCDIR)cell.h \ + $(INCDIR)lisptypes.h $(INCDIR)stack.h + $(CC) $(RFLAGS) $(SRCDIR)vars3.c $(INLINE) -o $(OBJECTDIR)vars3$(OEXT) + +$(OBJECTDIR)vmemsave.o : $(SRCDIR)vmemsave.c $(INCDIR)lispemul.h \ + $(INCDIR)lispmap.h $(INCDIR)lispglobal.h \ + $(INCDIR)ifpage.h $(INCDIR)vmemsave.h + $(CC) $(RFLAGS) $(SRCDIR)vmemsave.c $(INLINE) -o $(OBJECTDIR)vmemsave$(OEXT) + +$(OBJECTDIR)array2.o : $(SRCDIR)array2.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array2.c $(INLINE) -o $(OBJECTDIR)array2$(OEXT) + +$(OBJECTDIR)array4.o : $(SRCDIR)array4.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array4.c $(INLINE) -o $(OBJECTDIR)array4$(OEXT) + +$(OBJECTDIR)array6.o : $(SRCDIR)array6.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h $(INCDIR)my.h + $(CC) $(RFLAGS) $(SRCDIR)array6.c $(INLINE) -o $(OBJECTDIR)array6$(OEXT) + +$(OBJECTDIR)sxhash.o : $(SRCDIR)sxhash.c $(INCDIR)lispemul.h \ + $(INCDIR)lispglobal.h $(INCDIR)address68k.h \ + $(INCDIR)lispmap.h $(INCDIR)lisptypes.h $(INCDIR)emulglobal.h \ + $(INCDIR)arith.h + $(CC) $(RFLAGS) $(SRCDIR)sxhash.c $(INLINE) -o $(OBJECTDIR)sxhash$(OEXT) + +$(OBJECTDIR)usersubrs.o : $(SRCDIR)usersubrs.c + $(CC) $(RFLAGS) $(SRCDIR)usersubrs.c $(INLINE) -o $(OBJECTDIR)usersubrs$(OEXT) + +$(OBJECTDIR)XClose.o : $(SRCDIR)XClose.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XClose.c -o $(OBJECTDIR)XClose$(OEXT) + +$(OBJECTDIR)Cursor.o : $(SRCDIR)Cursor.c $(INCDIR)XVersion.h $(INCDIR)MyWindow.h \ + $(INCDIR)lispemul.h $(INCDIR)display.h + $(CC) $(RFLAGS) $(SRCDIR)Cursor.c -o $(OBJECTDIR)Cursor$(OEXT) + +$(OBJECTDIR)XWindow.o : $(SRCDIR)XWindow.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)lispemul.h $(INCDIR)address.h \ + $(INCDIR)address68k.h + $(CC) $(RFLAGS) $(SRCDIR)XWindow.c -o $(OBJECTDIR)XWindow$(OEXT) + +$(OBJECTDIR)DoRing.o : $(SRCDIR)DoRing.c $(INCDIR)lispemul.h + $(CC) $(RFLAGS) $(SRCDIR)DoRing.c -o $(OBJECTDIR)DoRing$(OEXT) + +$(OBJECTDIR)DoScroll.o : $(SRCDIR)DoScroll.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xbitblt.h + $(CC) $(RFLAGS) $(SRCDIR)DoScroll.c -o $(OBJECTDIR)DoScroll$(OEXT) + +$(OBJECTDIR)XEvent.o : $(SRCDIR)XEvent.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xbitblt.h + $(CC) $(RFLAGS) $(SRCDIR)XEvent.c -o $(OBJECTDIR)XEvent$(OEXT) + +$(OBJECTDIR)XGravity.o : $(SRCDIR)XGravity.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XGravity.c -o $(OBJECTDIR)XGravity$(OEXT) + +$(OBJECTDIR)XInit.o : $(SRCDIR)XInit.c + $(CC) $(RFLAGS) $(SRCDIR)XInit.c -o $(OBJECTDIR)XInit$(OEXT) + +$(OBJECTDIR)InitXevent.o : $(SRCDIR)InitXevent.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)InitXevent.c -o $(OBJECTDIR)InitXevent$(OEXT) + +$(OBJECTDIR)XKbdMouse.o : $(SRCDIR)XKbdMouse.c $(INCDIR)lispemul.h \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)XKbdMouse.c -o $(OBJECTDIR)XKbdMouse$(OEXT) + +$(OBJECTDIR)LispWindow.o : $(SRCDIR)LispWindow.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xdefaults.h + $(CC) $(RFLAGS) $(SRCDIR)LispWindow.c -o $(OBJECTDIR)LispWindow$(OEXT) + +$(OBJECTDIR)LispXbitblt.o : $(SRCDIR)LispXbitblt.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)LispXbitblt.c -o $(OBJECTDIR)LispXbitblt$(OEXT) + +$(OBJECTDIR)LispXdisplay.o : $(SRCDIR)LispXdisplay.c $(INCDIR)lispemul.h \ + $(INCDIR)address.h $(INCDIR)address68k.h $(INCDIR)pilotbbt.h \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h $(INCDIR)Xbitblt.h + $(CC) $(RFLAGS) $(SRCDIR)LispXdisplay.c -o $(OBJECTDIR)LispXdisplay$(OEXT) + +$(OBJECTDIR)XKeyboard.o : $(SRCDIR)XKeyboard.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XKeyboard.c -o $(OBJECTDIR)XKeyboard$(OEXT) + +$(OBJECTDIR)MakeXicon.o : $(SRCDIR)MakeXicon.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Xicon.h + $(CC) $(RFLAGS) $(SRCDIR)MakeXicon.c -o $(OBJECTDIR)MakeXicon$(OEXT) + +$(OBJECTDIR)OpenDisplay.o : $(SRCDIR)OpenDisplay.c $(INCDIR)lispemul.h \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)OpenDisplay.c -o $(OBJECTDIR)OpenDisplay$(OEXT) + +$(OBJECTDIR)ReadXoption.o : $(SRCDIR)ReadXoption.c $(INCDIR)Xdefaults.h + $(CC) $(RFLAGS) $(SRCDIR)ReadXoption.c -o $(OBJECTDIR)ReadXoption$(OEXT) + +$(OBJECTDIR)XReconfig.o : $(SRCDIR)XReconfig.c \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XReconfig.c -o $(OBJECTDIR)XReconfig$(OEXT) + +$(OBJECTDIR)XScroll.o : $(SRCDIR)XScroll.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)Stipple.h $(INCDIR)XCursorDef.h \ + $(INCDIR)XCursors.h + $(CC) $(RFLAGS) $(SRCDIR)XScroll.c -o $(OBJECTDIR)XScroll$(OEXT) + +$(OBJECTDIR)Scrollbar.o : $(SRCDIR)Scrollbar.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Scrollbar.c -o $(OBJECTDIR)Scrollbar$(OEXT) + +$(OBJECTDIR)XCursor.o : $(SRCDIR)XCursor.c $(INCDIR)lispemul.h \ + $(INCDIR)iopage.h $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XCursor.c -o $(OBJECTDIR)XCursor$(OEXT) + +$(OBJECTDIR)XMouse.o : $(SRCDIR)XMouse.c \ + $(INCDIR)XVersion.h $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)XMouse.c -o $(OBJECTDIR)XMouse$(OEXT) + +$(OBJECTDIR)Subwindows.o : $(SRCDIR)Subwindows.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)Subwindows.c -o $(OBJECTDIR)Subwindows$(OEXT) + +$(OBJECTDIR)VideoColor.o : $(SRCDIR)VideoColor.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h + $(CC) $(RFLAGS) $(SRCDIR)VideoColor.c -o $(OBJECTDIR)VideoColor$(OEXT) + +$(OBJECTDIR)XWindowMgr.o : $(SRCDIR)XWindowMgr.c $(INCDIR)XVersion.h \ + $(INCDIR)MyWindow.h $(INCDIR)dbprint.h + $(CC) $(RFLAGS) $(SRCDIR)XWindowMgr.c -o $(OBJECTDIR)XWindowMgr$(OEXT) + +################################################################################ +# Installation targets - copyprotect is ON here +# library, sysouts, fonts on release directories not handled here. +# userfiles are separate target explicitly (can make w/o building lde) +# $(NATDIR)nativeincludes.h $(NATDIR)disp68K.il +################################################################################ + +prerelease : + mkdir $(RELDIR) + mkdir $(INSDIR) + mkdir $(CHKDIR) + +release : $(INSDIR)$(LDENAME).o userfiles $(INSDIR)$(LDENAME) \ + $(INSDIR)ldeether $(INSDIR)lde csumfiles + +userfiles : $(INSDIR)usersubrs.c $(INSDIR)makefile $(INSDIR)ldeether.c + +$(INSDIR)lde: $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c + $(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)ldeboot.c $(SRCDIR)unixfork.c \ + $(LDFLAGS) -o $(INSDIR)lde + +$(OBJECTDIR)$(LDENAME).a : $(LIBFILES) $(OSARCHDIR)makevdate + /bin/rm -f $(VFILE).c + $(OSARCHDIR)makevdate > $(VFILE).c + $(CC) -c $(VFILE).c -o $(VFILE).o + rm -f $(LDENAME).a + ar rcv $(OBJECTDIR)$(LDENAME).a $(LIBFILES) $(VFILE).o + - ranlib $(OBJECTDIR)$(LDENAME).a + rm -f $(VFILE).o + +$(INSDIR)$(LDENAME).o : $(OBJECTDIR)$(LDENAME).a + ld -o $(INSDIR)$(LDENAME).o -r -u _main $(OBJECTDIR)$(LDENAME).a + +$(INSDIR)$(LDENAME) : $(INSDIR)$(LDENAME).o $(INSDIR)usersubrs.o + $(CC) $(INSDIR)$(LDENAME).o $(INSDIR)usersubrs.o $(FPFLAGS) $(LDFLAGS)\ + -o $(INSDIR)$(LDENAME) + rm -f $(INSDIR)usersubrs.o + +## ldeether from release - can't tar off with root permission. + +$(INSDIR)ldeether : $(INSDIR)ldeether.c + $(CC) $(CFLAGS) $(INSDIR)ldeether.c -o $(INSDIR)ldeether + - rsh python "cd `pwd`; /users/maiko/bin/suid $(INSDIR)ldeether" + +$(INSDIR)makefile : $(BINDIR)usermakefile-$(OSARCHNAME) + rm -f $(INSDIR)makefile + - ln $(BINDIR)usermakefile-$(OSARCHNAME) $(INSDIR)makefile + +$(INSDIR)usersubrs.c : $(SRCDIR)usersubrs.c + rm -f $(INSDIR)usersubrs.c + - ln $(SRCDIR)usersubrs.c $(INSDIR)usersubrs.c + +$(INSDIR)ldeether.c : $(SRCDIR)ldeether.c + rm -f $(INSDIR)ldeether.c + - ln $(SRCDIR)ldeether.c $(INSDIR)ldeether.c + +csumfiles : $(CHKDIR)checksum $(CHKDIR)ldechecksum $(CHKDIR)README + +$(CHKDIR)README : $(BINDIR)checksum-readme + rm -f $(CHKDIR)README + - ln $(BINDIR)checksum-readme $(CHKDIR)README + +$(CHKDIR)checksum : $(BINDIR)checksum + rm -f $(CHKDIR)checksum + cp -p $(BINDIR)checksum $(CHKDIR)checksum + chmod 755 $(CHKDIR)checksum + +$(CHKDIR)ldechecksum : $(BINDIR)ldechecksum + rm -f $(CHKDIR)ldechecksum + cp -p $(BINDIR)ldechecksum $(CHKDIR)ldechecksum + chmod 755 $(CHKDIR)ldechecksum + + + +################################################################################ +# Obsolete +################################################################################ + +$(NATDIR)nativeincludes.h : $(INCDIR)nativeincludes.h + rm -f $(NATDIR)nativeincludes.h + ln $(INCDIR)nativeincludes.h $(NATDIR)nativeincludes.h + +$(NATDIR)disp68K.il : $(SRCDIR)disp68K.il + rm -f $(NATDIR)disp68K.il + ln $(SRCDIR)disp68K.il $(NATDIR)disp68K.il + +################################################################################ +# Miscellaneous targets +# .c.s. should always have -O +################################################################################ + +cleanup : + rm $(LIBFILES) $(EXTFILES) $(KEYOFF) + +.c.o: + $(CC) $(RFLAGS) $*.c -o $@ $(INLINE) + +.c.s: + $(CC) -S $(CFLAGS) -I$(INCDIR) $(SRCDIR)$*.c -o $(SRCDIR)$@ $(INLINE) + +$(OBJECTDIR)keymaker : ../src/keymaker.c $(OBJECTDIR)keylib.o + $(CC) $(CFLAGS) -I$(INCDIR) ../src/keymaker.c $(OBJECTDIR)keylib.o -o $(OBJECTDIR)keymaker + +cxref : + cxref -c $(DFLAGS) -I$(INCDIR) $(SRCDIR)*.c -o ../all.cxref diff --git a/bin/makeright b/bin/makeright new file mode 100755 index 0000000..e069967 --- /dev/null +++ b/bin/makeright @@ -0,0 +1,133 @@ +#!/bin/sh +# $Id: makeright,v 1.5 2002/01/01 23:00:13 sybalsky Exp $ + +#************************************************************************/ +#* */ +#* (C) Copyright 1989-2001 Venue. All Rights Reserved. */ +#* Manufactured in the United States of America. */ +#* */ +#* The contents of this file are proprietary information */ +#* belonging to Venue, and are provided to you under license. */ +#* They may not be further distributed or disclosed to third */ +#* parties without the specific permission of Venue. */ +#* */ +#************************************************************************/ + +# +# Feb. 6 1990 osamu: Add display option +# release option does not support yet. +# Apr.23 1990 osamu: add release option. +# +# Jul 18 1990 JDS: Add 'init' option for making init-loading emulators +# +# Mar 7 1991 JDS: Add '3' option for making 3-byte emulators. +# +# Nov 20 2001 JDS: Convert to use BASH, not CSH, for open-source... +# +# usage: makeright [display-option] [other-option] +# +# example: makeright single ; make lde for mmaped displayFB +# makeright multi ; make lde for cg3,cg6 +# makeright x ; make lde for X-windows +# makeright color ; make lde with color support in it. +# makeright multi release ; make release version of lde for cg3,cg6 +# makeright init ; make lde for loading INIT.DLINIT b/w only +# +# makeright multi requires directory "maiko/${osversion}.${architecture}-multi" +# (ex. maiko/sunos4.sparc-multi) +# object files are stored there. +# +# makeright init requires directory "maiko/init.${architecture} +# +# Note: X11R4 environment link shared libraries. +# lde need X library. If lde links shared libraries, +# X shared libraries are needed at run time. +# +# Hide X shared libraries from link libraries search path. +LD_LIBRARY_PATH=/usr/local/lib +RELDIR="../RELEASE/" + +if test "$1" = "" + then + display="single" +else + if test "$1" = "release" + then + case "$2" in + single) display = single + ;; + multi) display = multi + ;; + x) display=x + ;; + *) makeright single release + makeright multi release + makeright x release + exit + ;; + esac + else + display="$1" + fi +fi + +if test $# > 0 + then + shift +fi + +architecture=`machinetype` +osversion=`osversion` +echo "making so far for ${osversion} on ${architecture}." +case "$display" in + init) set display = single + set releasename = init.${architecture} + set ldename = ldeinit + ;; + single) set releasename = ${osversion}.${architecture} + set ldename = ldesingle + ;; + multi) set releasename = ${osversion}.${architecture}-${display} + set ldename = ldemulti + ;; + x) releasename=${osversion}.${architecture}-${display} + ldename=ldex + ;; + *) echo "display-option: $display is not supported." + exit + ;; +esac + +releaseflg=0 + +if test "$1" = "release" + then + releaseflg=1 + if test "$display" != single + then + if test ! -e usermakefile-${releasename} + then + ln usermakefile-${osversion}.${architecture} usermakefile-${releasename} + fi + fi +else + releaseflg=0 +fi + +installdir=${RELDIR}install.${osversion}.${architecture}/ + +#if($display == single ) then +# set releasename = ${osversion}.${architecture} +#else +# set releasename = ${osversion}.${architecture}-${display} +#endif + +echo start making lde for ${releasename}. + +# then finally do the make, including the right stuff +# With makefile-tail merged, this should only take ONE make command.... + +make RELEASENAME=${releasename} INSDIR=${installdir} LDENAME=${ldename} \ + OSARCHNAME=${osversion}.${architecture} \ + -f makefile-header -f makefile-${releasename} \ + -f makefile-tail $* diff --git a/bin/makeright.sh b/bin/makeright.sh new file mode 100755 index 0000000..a83b361 --- /dev/null +++ b/bin/makeright.sh @@ -0,0 +1,131 @@ +#! /bin/-sh +# +# @(#) makeright Version 1.12 (7/18/90). +##***********************************************************************/ +## */ +## Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +## */ +## This file is work-product resulting from the Xerox/Venue */ +## Agreement dated 18-August-1989 for support of Medley. */ +## */ +##***********************************************************************/ +# +# Feb. 6 1990 osamu: Add display option +# release option does not support yet. +# Apr.23 1990 osamu: add release option. +# +# Jul 18 1990 JDS: Add 'init' option for making init-loading emulators +# +# Mar 7 1991 JDS: Add '3' option for making 3-byte emulators. +# +# usage: makeright [display-option] [other-option] +# +# example: makeright single ; make lde for mmaped displayFB +# makeright multi ; make lde for cg3,cg6 +# makeright x ; make lde for X-windows +# makeright color ; make lde with color support in it. +# makeright multi release ; make release version of lde for cg3,cg6 +# makeright init ; make lde for loading INIT.DLINIT b/w only +# makeright x 3 ; make lde for X-windows, 3-byte-atom version. +# +# makeright multi requires directory "maiko/${osversion}.${architecture}-multi" +# (ex. maiko/sunos4.sparc-multi) +# object files are stored there. +# +# makeright init requires directory "maiko/init.${architecture} +# +# Note: X11R4 environment link shared libraries. +# lde need X library. If lde links shared libraries, +# X shared libraries are needed at run time. +# +# Hide X shared libraries from link libraries search path. +setenv LD_LIBRARY_PATH /usr/local/lib +set RELDIR = ../RELEASE/ + +if($1 == "") then + set display=single +else + if($1 == "release") then + switch($2) + case single: + set display = single + breaksw + case multi: + set display = multi + breaksw + case x: + set display = x + breaksw + default: + makeright single release + makeright multi release + makeright x release + exit + breaksw + endsw + else + set display=$1 + endif +endif + +if( $#argv > 0 ) then + shift +endif + +set architecture = `mach` +set osversion = `osversion` +echo "making so far for ${osversion} on ${architecture}." +switch($display) + case init: + set display = single + set releasename = init.${architecture} + set ldename = ldeinit + breaksw + case single: + set releasename = ${osversion}.${architecture} + set ldename = ldesingle + breaksw + case multi: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldemulti + breaksw + case x: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldex + breaksw + default: + echo "display-option: $display is not supported." + exit + breaksw +endsw + +if ( ("$1" == "3")) then + set releasename = ${releasename}-3 + shift +endif + +set releaseflg = 0 +if( "$1" == "release" ) then + set releaseflg = 1 + if($display != single) then + if( !(-e usermakefile-${releasename})) then + ln usermakefile-${osversion}.${architecture} usermakefile-${releasename} + endif + endif +else + set releaseflg = 0 +endif +set installdir = ${RELDIR}install.${osversion}.${architecture}/ + +#if($display == single ) then +# set releasename = ${osversion}.${architecture} +#else +# set releasename = ${osversion}.${architecture}-${display} +#endif +echo start making lde for ${releasename}. +# then finally do the make, including the right stuff +# With makefile-tail merged, this should only take ONE make command.... +make RELEASENAME=${releasename} INSDIR=${installdir} LDENAME=${ldename} \ + OSARCHNAME=${osversion}.${architecture} \ + -f makefile-header -f makefile-${releasename} \ + -f makefile-tail $* diff --git a/bin/makersright b/bin/makersright new file mode 100755 index 0000000..8364f08 --- /dev/null +++ b/bin/makersright @@ -0,0 +1,120 @@ +# makeright +# @(#) makeright Version 1.12 (7/18/90). +##***********************************************************************/ +## */ +## Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +## */ +## This file is work-product resulting from the Xerox/Venue */ +## Agreement dated 18-August-1989 for support of Medley. */ +## */ +##***********************************************************************/ +# +# Feb. 6 1990 osamu: Add display option +# release option does not support yet. +# Apr.23 1990 osamu: add release option. +# +# Jul 18 1990 JDS: Add 'init' option for making init-loading emulators +# +# usage: makeright [display-option] [other-option] +# +# example: makeright single ; make lde for mmaped displayFB +# makeright multi ; make lde for cg3,cg6 +# makeright x ; make lde for X-windows +# makeright color ; make lde with color support in it. +# makeright multi release ; make release version of lde for cg3,cg6 +# makeright init ; make lde for loading INIT.DLINIT b/w only +# +# makeright multi requires directory "maiko/${osversion}.${architecture}-multi" +# (ex. maiko/sunos4.sparc-multi) +# object files are stored there. +# +# makeright init requires directory "maiko/init.${architecture} +# +# Note: X11R4 environment link shared libraries. +# lde need X library. If lde links shared libraries, +# X shared libraries are needed at run time. +# +# Hide X shared libraries from link libraries search path. +setenv LD_LIBRARY_PATH /usr/local/lib +set RELDIR = ../RELEASE/ + +if($1 == "") then + set display=single +else + if($1 == "release") then + switch($2) + case single: + set display = single + breaksw + case multi: + set display = multi + breaksw + case x: + set display = x + breaksw + default: + makeright single release + makeright multi release + makeright x release + exit + breaksw + endsw + else + set display=$1 + endif +endif + +if( $#argv > 0 ) then + shift +endif + +set architecture = rs6000 +set osversion = aix +switch($display) + case init: + set display = single + set releasename = init.${architecture} + set ldename = ldeinit + breaksw + case single: + set releasename = ${osversion}.${architecture} + set ldename = ldesingle + breaksw + case multi: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldemulti + breaksw + case x: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldex + breaksw + default: + echo "display-option: $display is not supported." + exit + breaksw +endsw +set releaseflg = 0 +if( "$1" == "release" ) then + set releaseflg = 1 + if($display != single) then + if( !(-e usermakefile-${releasename})) then + ln usermakefile-${osversion}.${architecture} usermakefile-${releasename} + endif + endif +else + set releaseflg = 0 +endif +set installdir = ${RELDIR}install.${osversion}.${architecture}/ + +#if($display == single ) then +# set releasename = ${osversion}.${architecture} +#else +# set releasename = ${osversion}.${architecture}-${display} +#endif +echo start making lde for ${releasename}. +# then finally do the make, including the right stuff +# With makefile-tail merged, this should only take ONE make command.... +make RELEASENAME=${releasename} INSDIR=${installdir} LDENAME=${ldename} \ + OSARCHNAME=${osversion}.${architecture} \ + -f makefile-header -f makefile-${releasename} \ + -f makefile-tail $* diff --git a/bin/makewrong b/bin/makewrong new file mode 100755 index 0000000..f81ac3b --- /dev/null +++ b/bin/makewrong @@ -0,0 +1,6 @@ +# Allows user to specify version to make +# Almost useless, except that I needed it to handle the +# SunOS 3.2 sparc version +set relname = $1 +shift +(echo RELEASENAME = ${relname};cat makefile-header makefile-${relname} makefile-tail) | make -f - $* diff --git a/bin/medley-solaris b/bin/medley-solaris new file mode 100755 index 0000000..393a608 --- /dev/null +++ b/bin/medley-solaris @@ -0,0 +1,203 @@ +#! /bin/sh +# ============================================================================ +# Changes: +# ============================================================================ +# SYNOPSYS: +# medley [[emulator] sysout] +# +# If no arguments are passed to the utility, it will try to find +# an emulator and sysout based on DEFAULTDIR. When arguments are +# given, it will try to be "smart" when finding files. +# +# It also will try to find a file containing the Medley software key. +# If it doesn't find one, it will prompt for a valid key. +# +# ============================================================================ + +#---------- Change if necessary ---------- +DEFAULTEMULATOR=lde +DEFAULTSYSOUT=LISP.SYSOUT +DEFAULTDIR=REPLACEME # Normally updated by installation script + +#************************************************************ +#********* Changes below this point should normally ********* +#********* not be required ********* +#************************************************************ + +APPLICATION="Medley 2.0" +SCRIPTNAME=`/bin/basename $0` +HOSTNAME=`/usr/ucb/hostname` + +KEYFILENAME=".medleyKey.$HOSTNAME" + +exitScript(){ + echo "$1" + exit +} + +smartPath() { + FILE=`/bin/basename $1` + if [ -f "$1" ] + then FILEPATH=$1 + elif [ "$FILE" = "$1" ] + then if [ -f "$2/$1" ] + then FILEPATH="$2/$1" + elif [ -f "$HOME/$1" ] + then FILEPATH="$HOME/$1" + elif [ -f "$HOME/medley/$1" ] + then FILEPATH="$HOME/medley/$1" + else exitScript "$3 file not found: $1" + fi + else exitScript "$3 file not found: $1" + fi +} + +parseCommand() { + case $# in + [012]) getOSVersion + # Now set the machine type + EMULATORDIR=install.sunos${OSVERSION} + PATH=$PATH:$DEFAULTDIR/$EMULATORDIR:. + cd $DEFAULTDIR/$EMULATORDIR + export PATH + case $# in + 0) EMULATOR=$DEFAULTEMULATOR ;; + 1) EMULATOR=$DEFAULTEMULATOR + smartPath $1 $DEFAULTDIR/lispsysouts Sysout + SYSOUT=$FILEPATH ;; + 2) EMULATOR=$1 + smartPath $2 $DEFAULTDIR/lispsysouts Sysout + SYSOUT=$FILEPATH ;; + esac ;; + *) echo "Usage: $SCRIPTNAME [[emulator] sysout]" + exit ;; + esac +} + +setOSVersion(){ + unset validOSVersionP + case "$1" in + 3|3.[X245]) OSVERSION=3 ;; + 4.0|4.0.*) OSVERSION=4 ;; + 4.1|4.1.*) OSVERSION=4.1 ;; + 5.*) OSVERSION=5 ;; + *) MESSAGE="Invalid reply: $answer" + validOSVersionP=notTrue ;; + esac + [ ${validOSVersionP:-true} = true ] +} + +askOSVersion(){ + MESSAGE="$1" + while [ ${menuloop:-notdone} = notdone ] + do /usr/ucb/clear + + echo " +<---------------> OS Options Menu <---------------> + 3.X - SunOS 3.2 3.4 3.5 + 4.0 - SunOS 4.0 4.0.X + 4.1 - SunOS 4.1 4.1.X + 5.0 - SunOS 5.0 and up. +${MESSAGE:+ +$MESSAGE}" + unset MESSAGE + echo -n "Select : " + answer=`/usr/bin/line` + if setOSVersion $answer + then menuloop=done + fi + done +} + +getOSVersion() { + if [ -f /etc/motd ] + then if setOSVersion `/usr/ucb/sed -e '1s/.*SunOS \(...\).*/\1/' -e '1q' < /etc/motd` + then echo -n "" + else echo "$MESSAGE" + fi + else askOSVersion "Please specify the SunOS version you are running." + fi +} + +validKeyP() { + unset keyTooLongP + VALID=`echo $* | /bin/awk '/[^0-9a-fA-F ]/'` + for group in $* + do LENGTH=`echo $group | /bin/awk '{print length}'` + if [ "$LENGTH" -gt 8 ] + then keyTooLongP=true + fi + done + [ $# = 3 -a "$VALID" = "" -a ${keyTooLongP:-notTrue} = notTrue ] +} + +saveKey() { + echo "Saving key '$KEY' into file '$KEYFILENAME' ..." + echo -n "Trying $DEFAULTDIR/$KEYFILENAME ..." + if [ -w "$DEFAULTDIR" ] + then echo "$KEY" > "$DEFAULTDIR/$KEYFILENAME" + else echo " Write protected ! " + echo -n "Trying $HOME/$KEYFILENAME instead ..." + echo "$KEY" > "$HOME/$KEYFILENAME" + fi + if [ $? = 0 ] + then echo " Done" + else echo " Some error occured \! " + fi +} + +keyDefinedP() { + if [ -f "$DEFAULTDIR/$KEYFILENAME" ] + then if [ -r "$DEFAULTDIR/$KEYFILENAME" ] + then KEYFILE="$DEFAULTDIR/$KEYFILENAME" + else echo "ERROR! Cannot read file: $DEFAULTDIR/$KEYFILE" + fi + elif [ -f "$HOME/$KEYFILENAME" ] + then KEYFILE="$HOME/$KEYFILENAME" + else echo " + To start $APPLICATION, a host access key is required. + Call Venue at (1-800-228-5325) for one, + + and be prepared to give them your workstations host ID# +" + fi + [ ${KEYFILE:-notSpecified} != notSpecified ] +} + +promptForKey () { + while [ ${VALIDKEYP:-notValid} = notValid ] + do echo "Your workstations host ID# is: `hostid`" + echo -n "Type in the key or [^C] to abort: " + KEY=`/usr/bin/line` + + if validKeyP $KEY + then VALIDKEYP=x + else echo "Sorry, invalid key: $KEY" + fi + done +} + + +#************************************************************ +#********** Main piece of code ********** +#************************************************************ + +trap 'echo " +$SCRIPTNAME: Aborted ..."; exit' 2 + +parseCommand $* + +if keyDefinedP +then KEY=`/usr/bin/cat $KEYFILE` +else promptForKey + saveKey +fi + + +# Well, I think we might be ready to give it a try +echo "Starting up $APPLICATION ..." +/bin/sleep 2 +$EMULATOR $SYSOUT -k "$KEY" + + + diff --git a/bin/mkdos b/bin/mkdos new file mode 100755 index 0000000..ab321ac --- /dev/null +++ b/bin/mkdos @@ -0,0 +1,212 @@ +#define CORRECT WRONG /* don't mind this text */ +#define BELOW in the file makefile in this directory. + + # You are editing the CORRECT file. + # Read more BELOW. + + # /* When you make a compile target this file is run through + # cpp and redirected to a file called mkfile. + # the file mkfile is then used as the make file for the subtargets. + # This may seem convoluted but the win is quite big. /jarl */ + + + # /* The following #ifdef ... #endif selection uses the + # symbols kexitnown to the local icc we use to transmogrify + # this file with. When you port to a new arch you should + # a) find the unique icc macros (sparc, mips, ibm etc.) + # b) add or edit this to the #ifdef selection below + # c) try it out by doing a make. */ + + + # defDEBUG -g -m +#define DEBUG -O2 +#define OEXT o + + # remember -DNOEUROKBD + +#ifdef _INTELC32_ /* The cpp macro for the DOS extender */ +#define EXTRACFLAGS -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT -DNOFORN -DNOETHER -DBIGATOMS -DBIGVM -DNEWCDRCODING +#define EXTRALDFLAGS graphics.lib binmode.lib mouse.lib +AFLAGS = /T +COLORFILES = rawcolor.obj +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj +#define EXTRAFILES +#define EXTRALDFLAGS +#undef OEXT +#define OEXT obj + +#endif /* DOS */ + +#define XFLAGS +#define XLDFLAGS + +ADMINFILES = mkdos mkvdate.c optck.c + +ETHERFILES = ldeether.OEXT + +KEY = keytstno.OEXT + +CFLAGS = -I. -DBIGATOMS -DNEW_STORAGE XFLAGS EXTRACFLAGS DEBUG + +LDFLAGS = DEBUG EXTRALDFLAGS XLDFLAGS + +SRCFILES = $(SRCDIR)conspage.c $(SRCDIR)gcoflow.c $(SRCDIR)shift.c $(SRCDIR)dbgtool.c $(SRCDIR)gcr.c\ + $(SRCDIR)llcolor.c $(SRCDIR)gcrcell.c $(SRCDIR)llstk.c $(SRCDIR)gcscan.c $(SRCDIR)loopsops.c\ + $(SRCDIR)storage.c $(SRCDIR)allocmds.c $(SRCDIR)dir.c $(SRCDIR)gvar2.c $(SRCDIR)lowlev1.c\ + $(SRCDIR)subr.c $(SRCDIR)arith2.c $(SRCDIR)hacks.c $(SRCDIR)lowlev2.c $(SRCDIR)subr0374.c \ + $(SRCDIR)arith3.c $(SRCDIR)doscomm.c $(SRCDIR)hardrtn.c $(SRCDIR)lsthandl.c $(SRCDIR)sxhash.c \ + $(SRCDIR)arith4.c $(SRCDIR)draw.c $(SRCDIR)main.c $(SRCDIR)testtool.c $(SRCDIR)array.c $(SRCDIR)dsk.c \ + $(SRCDIR)inet.c $(SRCDIR)misc7.c $(SRCDIR)timer.c $(SRCDIR)array2.c $(SRCDIR)dspif.c $(SRCDIR)initdsp.c \ + $(SRCDIR)miscn.c $(SRCDIR)typeof.c $(SRCDIR)array3.c $(SRCDIR)initkbd.c $(SRCDIR)ubf1.c \ + $(SRCDIR)array4.c $(SRCDIR)dspsubrs.c $(SRCDIR)initsout.c $(SRCDIR)mkatom.c $(SRCDIR)ubf2.c \ + $(SRCDIR)array5.c $(SRCDIR)eqf.c $(SRCDIR)intcall.c $(SRCDIR)mkcell.c $(SRCDIR)ubf3.c $(SRCDIR)array6.c \ + $(SRCDIR)ether.c $(SRCDIR)mkvdate.c $(SRCDIR)ufn.c $(SRCDIR)atom.c $(SRCDIR)findkey.c \ + $(SRCDIR)kbdsubrs.c $(SRCDIR)mouseif.c $(SRCDIR)ufs.c $(SRCDIR)bbtsub.c $(SRCDIR)foreign.c \ + $(SRCDIR)keyevent.c $(SRCDIR)unixcomm.c $(SRCDIR)bin.c $(SRCDIR)fp.c $(SRCDIR)keylib.c $(SRCDIR)binds.c \ + $(SRCDIR)asmbbt.c $(SRCDIR)fvar.c $(SRCDIR)mvs.c $(SRCDIR)unwind.c $(SRCDIR)bitblt.c $(SRCDIR)gc.c \ + $(SRCDIR)uraid.c $(SRCDIR)blt.c $(SRCDIR)gc2.c $(SRCDIR)kprint.c $(SRCDIR)keytstno.c $(SRCDIR)keytst.c\ + $(SRCDIR)osmsg.c usrsubr.c $(SRCDIR)byteswap.c $(SRCDIR)gcarray.c \ + $(SRCDIR)perrno.c $(SRCDIR)ldeboot.c $(SRCDIR)ldeether.c $(SRCDIR)uutils.c $(SRCDIR)carcdr.c $(SRCDIR)gccode.c \ + $(SRCDIR)rawcolor.c $(SRCDIR)vars3.c $(SRCDIR)gcfinal.c $(SRCDIR)ldsout.c $(SRCDIR)return.c \ + $(SRCDIR)vmemsave.c $(SRCDIR)chardev.c $(SRCDIR)gchtfind.c $(SRCDIR)lineblt8.c $(SRCDIR)rpc.c \ + $(SRCDIR)xc.c $(SRCDIR)common.c $(SRCDIR)gcmain3.c $(SRCDIR)lisp2c.c $(SRCDIR)rplcons.c $(SRCDIR)z2.c \ + $(SRCDIR)find-dsp.l $(SRCDIR)dsphack.l \ + $(SRCDIR)xmkicon.c $(SRCDIR)xbbt.c $(SRCDIR)xinit.c $(SRCDIR)xscroll.c $(SRCDIR)xcursor.c $(SRCDIR)xlspwin.c \ + $(SRCDIR)xrdopt.c $(SRCDIR)xwinman.c \ + $(SRCDIR)dosmouse.c $(SRCDIR)vesafns.asm $(SRCDIR)vesainit.c $(SRCDIR)vgainit.c $(SRCDIR)kbdif.c \ + $(SRCDIR)dspsparc.il $(SRCDIR)copyright $(SRCDIR)launch.asm + +OFILES = $(OBJECTDIR)conspage.OEXT $(OBJECTDIR)gcoflow.OEXT $(OBJECTDIR)shift.OEXT $(OBJECTDIR)dbgtool.OEXT \ + $(OBJECTDIR)gcr.OEXT $(OBJECTDIR)llcolor.OEXT $(OBJECTDIR)gcrcell.OEXT $(OBJECTDIR)llstk.OEXT \ + $(OBJECTDIR)gcscan.OEXT $(OBJECTDIR)loopsops.OEXT $(OBJECTDIR)storage.OEXT \ + $(OBJECTDIR)allocmds.OEXT $(OBJECTDIR)dir.OEXT $(OBJECTDIR)gvar2.OEXT $(OBJECTDIR)lowlev1.OEXT \ + $(OBJECTDIR)subr.OEXT $(OBJECTDIR)arith2.OEXT $(OBJECTDIR)hacks.OEXT $(OBJECTDIR)lowlev2.OEXT \ + $(OBJECTDIR)subr0374.OEXT $(OBJECTDIR)arith3.OEXT $(OBJECTDIR)doscomm.OEXT \ + $(OBJECTDIR)hardrtn.OEXT $(OBJECTDIR)lsthandl.OEXT $(OBJECTDIR)sxhash.OEXT $(OBJECTDIR)arith4.OEXT \ + $(OBJECTDIR)draw.OEXT $(OBJECTDIR)main.OEXT $(OBJECTDIR)testtool.OEXT $(OBJECTDIR)array.OEXT \ + $(OBJECTDIR)dsk.OEXT $(OBJECTDIR)inet.OEXT $(OBJECTDIR)misc7.OEXT $(OBJECTDIR)timer.OEXT \ + $(OBJECTDIR)array2.OEXT $(OBJECTDIR)dspif.OEXT $(OBJECTDIR)initdsp.OEXT $(OBJECTDIR)miscn.OEXT \ + $(OBJECTDIR)typeof.OEXT $(OBJECTDIR)array3.OEXT $(OBJECTDIR)initkbd.OEXT $(OBJECTDIR)ubf1.OEXT \ + $(OBJECTDIR)array4.OEXT $(OBJECTDIR)dspsubrs.OEXT $(OBJECTDIR)initsout.OEXT \ + $(OBJECTDIR)mkatom.OEXT $(OBJECTDIR)ubf2.OEXT $(OBJECTDIR)array5.OEXT $(OBJECTDIR)eqf.OEXT \ + $(OBJECTDIR)intcall.OEXT $(OBJECTDIR)mkcell.OEXT $(OBJECTDIR)ubf3.OEXT $(OBJECTDIR)array6.OEXT \ + $(OBJECTDIR)ether.OEXT $(OBJECTDIR)ufn.OEXT $(OBJECTDIR)atom.OEXT \ + $(OBJECTDIR)findkey.OEXT $(OBJECTDIR)kbdsubrs.OEXT $(OBJECTDIR)mouseif.OEXT $(OBJECTDIR)ufs.OEXT \ + $(OBJECTDIR)bbtsub.OEXT $(OBJECTDIR)foreign.OEXT $(OBJECTDIR)keyevent.OEXT \ + $(OBJECTDIR)unixcomm.OEXT $(OBJECTDIR)bin.OEXT $(OBJECTDIR)fp.OEXT $(OBJECTDIR)keylib.OEXT \ + $(OBJECTDIR)binds.OEXT $(OBJECTDIR)fvar.OEXT $(OBJECTDIR)mvs.OEXT \ + $(OBJECTDIR)unwind.OEXT $(OBJECTDIR)bitblt.OEXT $(OBJECTDIR)gc.OEXT \ + $(OBJECTDIR)uraid.OEXT $(OBJECTDIR)blt.OEXT $(OBJECTDIR)gc2.OEXT \ + $(OBJECTDIR)kprint.OEXT $(OBJECTDIR)osmsg.OEXT $(OBJECTDIR)usrsubr.OEXT $(OBJECTDIR)byteswap.OEXT \ + $(OBJECTDIR)gcarray.OEXT $(OBJECTDIR)perrno.OEXT $(OBJECTDIR)uutils.OEXT \ + $(OBJECTDIR)carcdr.OEXT $(OBJECTDIR)asmbbt.OEXT $(OBJECTDIR)gccode.OEXT \ + $(OBJECTDIR)vars3.OEXT $(OBJECTDIR)gcfinal.OEXT $(OBJECTDIR)ldsout.OEXT \ + $(OBJECTDIR)return.OEXT $(OBJECTDIR)vmemsave.OEXT $(OBJECTDIR)chardev.OEXT \ + $(OBJECTDIR)gchtfind.OEXT $(OBJECTDIR)lineblt8.OEXT $(OBJECTDIR)rpc.OEXT $(OBJECTDIR)xc.OEXT \ + $(OBJECTDIR)common.OEXT $(OBJECTDIR)gcmain3.OEXT $(OBJECTDIR)lisp2c.OEXT $(OBJECTDIR)rplcons.OEXT \ + $(OBJECTDIR)z2.OEXT $(OBJECTDIR) $(OBJECTDIR)vdate.OEXT $(KEY) $(COLORFILES) $(ARCHFILES) EXTRAFILES + + +HFILES = $(INCDIR)address.h $(INCDIR)adr68k.h $(INCDIR)arith.h $(INCDIR)cell.h $(INCDIR)dbprint.h $(INCDIR)display.h \ + $(INCDIR)dspif.h $(INCDIR)ifpage.h $(INCDIR)iopage.h $(INCDIR)lispemul.h $(INCDIR)lispmap.h \ + $(INCDIR)lsptypes.h $(INCDIR)miscstat.h $(INCDIR)lspglob.h $(INCDIR)array.h $(INCDIR)bb.h \ + $(INCDIR)bitblt.h $(INCDIR)debug.h $(INCDIR)devconf.h $(INCDIR)dspdata.h $(INCDIR)ether.h \ + $(INCDIR)fast_dsp.h $(INCDIR)fp.h $(INCDIR)gc.h $(INCDIR)hdw_conf.h $(INCDIR)initatms.h $(INCDIR)inlinec.h $(INCDIR)keyboard.h \ + $(INCDIR)lispver1.h $(INCDIR)lispver2.h $(INCDIR)lldsp.h $(INCDIR)locfile.h $(INCDIR)mouseif.h $(INCDIR)my.h \ + $(INCDIR)opcodes.h $(INCDIR)osmsg.h $(INCDIR)pilotbbt.h $(INCDIR)print.h $(INCDIR)profile.h \ + $(INCDIR)return.h $(INCDIR)stack.h $(INCDIR)stream.h $(INCDIR)subrs.h $(INCDIR)sysatms.h $(INCDIR)timeout.h \ + $(INCDIR)tos1defs.h $(INCDIR)tosfns.h $(INCDIR)tosret.h $(INCDIR)vmemsave.h \ + $(INCDIR)xdefs.h $(INCDIR)xbitmaps.h $(INCDIR)xkeymap.h + + + + ############################## + ### Entry rules ### + ############### ### + ### make only one of these ### + ### four rules on the ### + ### commandline ### + ############################## + +all : x raw color + +x : xmkfile + $(MAKE) -f xmkfile $(MFLAGS) ldex + +raw : mkfile + $(MAKE) -f mkfile $(MFLAGS) lde + +color : mkfile + $(MAKE) -f mkfile $(MFLAGS) lde + +dos4 : + $(MAKE) -f ./mkfile $(MFLAGS) dosmkfil + $(MAKE) -f ./dosmkfile $(MFLAGS) medley.exe + $(MAKE) -f ./dosmkfile $(MFLAGS) emul.exe + + ############################### + ### Compile rules ### + ################# ### + ### Don't touch these. The ### + ### following rules are ### + ### used by the entry rules ### + ############################### + +xmkfile : mkfile + $(CC) -E -DX mkfile > xmkfile + +dosmkfil : mkfile + -copy mkfile mkfile.c + -$(CC) /P /c mkfile.c 2> junk + -copy mkfile.i dosmkfil + +emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +ldex : $(OFILES) mkvdate + $(RM) vdate.c + mkvdate > vdate.c + - cd ARCH;$(MAKE) $(MFLAGS) all #/* Make the speciffic files for this target */ + $(CC) $(OFILES) -o $@ $(LDFLAGS) + +lde : $(OFILES) mkvdate + $(RM) vdate.c + mkvdate > vdate.c + - cd ARCH;$(MAKE) $(MFLAGS) all #/* Make the speciffic files for this target */ + $(CC) $(LDFLAGS) $(OFILES) -o $@ + + ################## + ### File rules ### + ################## + +main.o : lispemul.h address.h lsptypes.h adr68k.h stack.h lspglob.h lispmap.h ifpage.h iopage.h return.h debug.h profile.h + + + ###################################### + ### Architecture speciffic targets ### + ### ### + ### replaces the cruft in the ### + ### makefile-. ### + ###################################### + +#ifdef _INTELC32_ /* The cpp macro for the DOS extender */ + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +medley.exe: launch.obj + TLINK launch,medley + +launch.obj: launch.asm + +xc.obj: xc.s + tasm /ml xc.s + +xc.s: xc.c + rsh sparky (cd /users/nilsson/curr ; gcc-make $* ) + +#endif diff --git a/bin/mkfile b/bin/mkfile new file mode 100755 index 0000000..738bfd9 --- /dev/null +++ b/bin/mkfile @@ -0,0 +1,201 @@ +#define CORRECT WRONG /* don't mind this text */ +#define BELOW in the file makefile in this directory. + + # You are editing the CORRECT file. + # Read more BELOW. + + # /* When you make a compile target this file is run through + # cpp and redirected to a file called mkfile. + # the file mkfile is then used as the make file for the subtargets. + # This may seem convoluted but the win is quite big. /jarl */ + + + # /* The following #ifdef ... #endif selection uses the + # symbols kexitnown to the local icc we use to transmogrify + # this file with. When you port to a new arch you should + # a) find the unique icc macros (sparc, mips, ibm etc.) + # b) add or edit this to the #ifdef selection below + # c) try it out by doing a make. */ + + + # defDEBUG -g -m +#define DEBUG -O2 +#define OEXT o + + # remember -DNOEUROKBD + +#ifdef _INTELC32_ /* The cpp macro for the DOS extender */ +#define SRCDIR . +#define OBJECTDIR . +#define BINDIR ../bin +#define INCDIR ../inc +#define EXTRACFLAGS -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT -DNOFORN -DNOETHER -DBIGATOMS -DBIGVM -DNEWCDRCODING +#define EXTRALDFLAGS graphics.lib binmode.lib mouse.lib +BINARYDIR = BINDIR +AFLAGS = /T +COLORFILES = rawcolor.obj +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj +#define EXTRAFILES +#define EXTRALDFLAGS +#undef OEXT +#define OEXT obj + +#endif /* DOS */ + +#define XFLAGS +#define XLDFLAGS + +ADMINFILES = mkdos mkvdate.c optck.c + +ETHERFILES = ldeether.OEXT + +KEY = keytstno.OEXT + +CFLAGS = -I. -DBIGATOMS -DNEW_STORAGE XFLAGS EXTRACFLAGS DEBUG + +LDFLAGS = DEBUG EXTRALDFLAGS XLDFLAGS + +SRCFILES = SRCDIR/conspage.c SRCDIR/gcoflow.c SRCDIR/shift.c SRCDIR/dbgtool.c SRCDIR/gcr.c\ + SRCDIR/llcolor.c SRCDIR/gcrcell.c SRCDIR/llstk.c SRCDIR/gcscan.c SRCDIR/loopsops.c\ + SRCDIR/storage.c SRCDIR/allocmds.c SRCDIR/dir.c SRCDIR/gvar2.c SRCDIR/lowlev1.c\ + SRCDIR/subr.c SRCDIR/arith2.c SRCDIR/hacks.c SRCDIR/lowlev2.c SRCDIR/subr0374.c \ + SRCDIR/arith3.c SRCDIR/doscomm.c SRCDIR/hardrtn.c SRCDIR/lsthandl.c SRCDIR/sxhash.c \ + SRCDIR/arith4.c SRCDIR/draw.c SRCDIR/main.c SRCDIR/testtool.c SRCDIR/array.c SRCDIR/dsk.c \ + SRCDIR/inet.c SRCDIR/misc7.c SRCDIR/timer.c SRCDIR/array2.c SRCDIR/dspif.c SRCDIR/initdsp.c \ + SRCDIR/miscn.c SRCDIR/typeof.c SRCDIR/array3.c SRCDIR/initkbd.c SRCDIR/ubf1.c \ + SRCDIR/array4.c SRCDIR/dspsubrs.c SRCDIR/initsout.c SRCDIR/mkatom.c SRCDIR/ubf2.c \ + SRCDIR/array5.c SRCDIR/eqf.c SRCDIR/intcall.c SRCDIR/mkcell.c SRCDIR/ubf3.c SRCDIR/array6.c \ + SRCDIR/ether.c SRCDIR/mkvdate.c SRCDIR/ufn.c SRCDIR/atom.c SRCDIR/findkey.c \ + SRCDIR/kbdsubrs.c SRCDIR/mouseif.c SRCDIR/ufs.c SRCDIR/bbtsub.c SRCDIR/foreign.c \ + SRCDIR/keyevent.c SRCDIR/unixcomm.c SRCDIR/bin.c SRCDIR/fp.c SRCDIR/keylib.c SRCDIR/binds.c \ + SRCDIR/asmbbt.c SRCDIR/fvar.c SRCDIR/mvs.c SRCDIR/unwind.c SRCDIR/bitblt.c SRCDIR/gc.c \ + SRCDIR/uraid.c SRCDIR/blt.c SRCDIR/gc2.c SRCDIR/kprint.c SRCDIR/keytstno.c SRCDIR/keytst.c\ + SRCDIR/osmsg.c usrsubr.c SRCDIR/byteswap.c SRCDIR/gcarray.c \ + SRCDIR/perrno.c SRCDIR/ldeboot.c SRCDIR/ldeether.c SRCDIR/uutils.c SRCDIR/carcdr.c SRCDIR/gccode.c \ + SRCDIR/rawcolor.c SRCDIR/vars3.c SRCDIR/gcfinal.c SRCDIR/ldsout.c SRCDIR/return.c \ + SRCDIR/vmemsave.c SRCDIR/chardev.c SRCDIR/gchtfind.c SRCDIR/lineblt8.c SRCDIR/rpc.c \ + SRCDIR/xc.c SRCDIR/common.c SRCDIR/gcmain3.c SRCDIR/lisp2c.c SRCDIR/rplcons.c SRCDIR/z2.c \ + SRCDIR/find-dsp.l SRCDIR/dsphack.l \ + SRCDIR/xmkicon.c SRCDIR/xbbt.c SRCDIR/xinit.c SRCDIR/xscroll.c SRCDIR/xcursor.c SRCDIR/xlspwin.c \ + SRCDIR/xrdopt.c SRCDIR/xwinman.c \ + SRCDIR/dosmouse.c SRCDIR/vesafns.asm SRCDIR/vesainit.c SRCDIR/vgainit.c SRCDIR/kbdif.c \ + SRCDIR/dspsparc.il SRCDIR/copyright SRCDIR/launch.asm + +OFILES = conspage.OEXT gcoflow.OEXT shift.OEXT dbgtool.OEXT \ + gcr.OEXT llcolor.OEXT gcrcell.OEXT llstk.OEXT \ + gcscan.OEXT loopsops.OEXT storage.OEXT \ + allocmds.OEXT dir.OEXT gvar2.OEXT lowlev1.OEXT \ + subr.OEXT arith2.OEXT hacks.OEXT lowlev2.OEXT \ + subr0374.OEXT arith3.OEXT doscomm.OEXT \ + hardrtn.OEXT lsthandl.OEXT sxhash.OEXT arith4.OEXT \ + draw.OEXT main.OEXT testtool.OEXT array.OEXT \ + dsk.OEXT inet.OEXT misc7.OEXT timer.OEXT \ + array2.OEXT dspif.OEXT initdsp.OEXT miscn.OEXT \ + typeof.OEXT array3.OEXT initkbd.OEXT ubf1.OEXT \ + array4.OEXT dspsubrs.OEXT initsout.OEXT \ + mkatom.OEXT ubf2.OEXT array5.OEXT eqf.OEXT \ + intcall.OEXT mkcell.OEXT ubf3.OEXT array6.OEXT \ + ether.OEXT ufn.OEXT atom.OEXT \ + findkey.OEXT kbdsubrs.OEXT mouseif.OEXT ufs.OEXT \ + bbtsub.OEXT foreign.OEXT keyevent.OEXT \ + unixcomm.OEXT bin.OEXT fp.OEXT keylib.OEXT \ + binds.OEXT fvar.OEXT mvs.OEXT \ + unwind.OEXT bitblt.OEXT gc.OEXT \ + uraid.OEXT blt.OEXT gc2.OEXT \ + kprint.OEXT osmsg.OEXT usrsubr.OEXT byteswap.OEXT \ + gcarray.OEXT perrno.OEXT uutils.OEXT \ + carcdr.OEXT asmbbt.OEXT gccode.OEXT \ + vars3.OEXT gcfinal.OEXT ldsout.OEXT \ + return.OEXT vmemsave.OEXT chardev.OEXT \ + gchtfind.OEXT lineblt8.OEXT rpc.OEXT xc.OEXT \ + common.OEXT gcmain3.OEXT lisp2c.OEXT rplcons.OEXT \ + z2.OEXT vdate.OEXT $(KEY) $(COLORFILES) $(ARCHFILES) EXTRAFILES + + +HFILES = INCDIR/address.h INCDIR/adr68k.h INCDIR/arith.h INCDIR/cell.h INCDIR/dbprint.h INCDIR/display.h \ + INCDIR/dspif.h INCDIR/ifpage.h INCDIR/iopage.h INCDIR/lispemul.h INCDIR/lispmap.h \ + INCDIR/lsptypes.h INCDIR/miscstat.h INCDIR/lspglob.h INCDIR/array.h INCDIR/bb.h \ + INCDIR/bitblt.h INCDIR/debug.h INCDIR/devconf.h INCDIR/dspdata.h INCDIR/ether.h \ + INCDIR/fast_dsp.h INCDIR/fp.h INCDIR/gc.h INCDIR/hdw_conf.h INCDIR/initatms.h INCDIR/inlinec.h INCDIR/keyboard.h \ + INCDIR/lispver1.h INCDIR/lispver2.h INCDIR/lldsp.h INCDIR/locfile.h INCDIR/mouseif.h INCDIR/my.h \ + INCDIR/opcodes.h INCDIR/osmsg.h INCDIR/pilotbbt.h INCDIR/print.h INCDIR/profile.h \ + INCDIR/return.h INCDIR/stack.h INCDIR/stream.h INCDIR/subrs.h INCDIR/sysatms.h INCDIR/timeout.h \ + INCDIR/tos1defs.h INCDIR/tosfns.h INCDIR/tosret.h INCDIR/vmemsave.h \ + INCDIR/xdefs.h INCDIR/xbitmaps.h INCDIR/xkeymap.h + + + + ############################## + ### Entry rules ### + ############### ### + ### make only one of these ### + ### four rules on the ### + ### commandline ### + ############################## + +dos4 : + $(MAKE) -f ./mkfile $(MFLAGS) dosmkfil + $(MAKE) -f ./dosmkfil $(MFLAGS) ../bin/medley.exe + $(MAKE) -f ./dosmkfil $(MFLAGS) ../bin/emul.exe + + ############################### + ### Compile rules ### + ################# ### + ### Don't touch these. The ### + ### following rules are ### + ### used by the entry rules ### + ############################### + +dosmkfil : mkfile + -copy mkfile mkfile.c + -$(CC) /P /c mkfile.c 2> junk + -copy mkfile.i dosmkfil + +../bin/emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +lde : $(OFILES) mkvdate + $(RM) vdate.c + mkvdate > vdate.c + - cd ARCH;$(MAKE) $(MFLAGS) all #/* Make the speciffic files for this target */ + $(CC) $(LDFLAGS) $(OFILES) -o $@ + + ################## + ### File rules ### + ################## + +OBJECTDIR/main.o : INCDIR/lispemul.h INCDIR/address.h INCDIR/lsptypes.h INCDIR/adr68k.h\ + INCDIR/stack.h INCDIR/lspglob.h INCDIR/lispmap.h INCDIR/ifpage.h\ + INCDIR/iopage.h INCDIR/return.h INCDIR/debug.h INCDIR/profile.h + + + ###################################### + ### Architecture speciffic targets ### + ### ### + ### replaces the cruft in the ### + ### makefile-. ### + ###################################### + +#ifdef _INTELC32_ /* The cpp macro for the DOS extender */ + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +BINDIR/medley.exe: OBJECTDIR/launch.obj + TLINK launch,medley + +OBJECTDIR/launch.obj: SRCDIR/launch.asm + copy ..\src\launch.asm launch.asm + tasm /ml launch.asm + +OBJECTDIR/xc.obj: SRCDIR/xc.s + tasm /ml xc.s + +SRCDIR/xc.s: SRCDIR/xc.c + rsh sparky (cd /users/sybalsky/maiko/src ; gcc-make $* ) + +#endif diff --git a/bin/mkfile.c b/bin/mkfile.c new file mode 100755 index 0000000..738bfd9 --- /dev/null +++ b/bin/mkfile.c @@ -0,0 +1,201 @@ +#define CORRECT WRONG /* don't mind this text */ +#define BELOW in the file makefile in this directory. + + # You are editing the CORRECT file. + # Read more BELOW. + + # /* When you make a compile target this file is run through + # cpp and redirected to a file called mkfile. + # the file mkfile is then used as the make file for the subtargets. + # This may seem convoluted but the win is quite big. /jarl */ + + + # /* The following #ifdef ... #endif selection uses the + # symbols kexitnown to the local icc we use to transmogrify + # this file with. When you port to a new arch you should + # a) find the unique icc macros (sparc, mips, ibm etc.) + # b) add or edit this to the #ifdef selection below + # c) try it out by doing a make. */ + + + # defDEBUG -g -m +#define DEBUG -O2 +#define OEXT o + + # remember -DNOEUROKBD + +#ifdef _INTELC32_ /* The cpp macro for the DOS extender */ +#define SRCDIR . +#define OBJECTDIR . +#define BINDIR ../bin +#define INCDIR ../inc +#define EXTRACFLAGS -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT -DNOFORN -DNOETHER -DBIGATOMS -DBIGVM -DNEWCDRCODING +#define EXTRALDFLAGS graphics.lib binmode.lib mouse.lib +BINARYDIR = BINDIR +AFLAGS = /T +COLORFILES = rawcolor.obj +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj +#define EXTRAFILES +#define EXTRALDFLAGS +#undef OEXT +#define OEXT obj + +#endif /* DOS */ + +#define XFLAGS +#define XLDFLAGS + +ADMINFILES = mkdos mkvdate.c optck.c + +ETHERFILES = ldeether.OEXT + +KEY = keytstno.OEXT + +CFLAGS = -I. -DBIGATOMS -DNEW_STORAGE XFLAGS EXTRACFLAGS DEBUG + +LDFLAGS = DEBUG EXTRALDFLAGS XLDFLAGS + +SRCFILES = SRCDIR/conspage.c SRCDIR/gcoflow.c SRCDIR/shift.c SRCDIR/dbgtool.c SRCDIR/gcr.c\ + SRCDIR/llcolor.c SRCDIR/gcrcell.c SRCDIR/llstk.c SRCDIR/gcscan.c SRCDIR/loopsops.c\ + SRCDIR/storage.c SRCDIR/allocmds.c SRCDIR/dir.c SRCDIR/gvar2.c SRCDIR/lowlev1.c\ + SRCDIR/subr.c SRCDIR/arith2.c SRCDIR/hacks.c SRCDIR/lowlev2.c SRCDIR/subr0374.c \ + SRCDIR/arith3.c SRCDIR/doscomm.c SRCDIR/hardrtn.c SRCDIR/lsthandl.c SRCDIR/sxhash.c \ + SRCDIR/arith4.c SRCDIR/draw.c SRCDIR/main.c SRCDIR/testtool.c SRCDIR/array.c SRCDIR/dsk.c \ + SRCDIR/inet.c SRCDIR/misc7.c SRCDIR/timer.c SRCDIR/array2.c SRCDIR/dspif.c SRCDIR/initdsp.c \ + SRCDIR/miscn.c SRCDIR/typeof.c SRCDIR/array3.c SRCDIR/initkbd.c SRCDIR/ubf1.c \ + SRCDIR/array4.c SRCDIR/dspsubrs.c SRCDIR/initsout.c SRCDIR/mkatom.c SRCDIR/ubf2.c \ + SRCDIR/array5.c SRCDIR/eqf.c SRCDIR/intcall.c SRCDIR/mkcell.c SRCDIR/ubf3.c SRCDIR/array6.c \ + SRCDIR/ether.c SRCDIR/mkvdate.c SRCDIR/ufn.c SRCDIR/atom.c SRCDIR/findkey.c \ + SRCDIR/kbdsubrs.c SRCDIR/mouseif.c SRCDIR/ufs.c SRCDIR/bbtsub.c SRCDIR/foreign.c \ + SRCDIR/keyevent.c SRCDIR/unixcomm.c SRCDIR/bin.c SRCDIR/fp.c SRCDIR/keylib.c SRCDIR/binds.c \ + SRCDIR/asmbbt.c SRCDIR/fvar.c SRCDIR/mvs.c SRCDIR/unwind.c SRCDIR/bitblt.c SRCDIR/gc.c \ + SRCDIR/uraid.c SRCDIR/blt.c SRCDIR/gc2.c SRCDIR/kprint.c SRCDIR/keytstno.c SRCDIR/keytst.c\ + SRCDIR/osmsg.c usrsubr.c SRCDIR/byteswap.c SRCDIR/gcarray.c \ + SRCDIR/perrno.c SRCDIR/ldeboot.c SRCDIR/ldeether.c SRCDIR/uutils.c SRCDIR/carcdr.c SRCDIR/gccode.c \ + SRCDIR/rawcolor.c SRCDIR/vars3.c SRCDIR/gcfinal.c SRCDIR/ldsout.c SRCDIR/return.c \ + SRCDIR/vmemsave.c SRCDIR/chardev.c SRCDIR/gchtfind.c SRCDIR/lineblt8.c SRCDIR/rpc.c \ + SRCDIR/xc.c SRCDIR/common.c SRCDIR/gcmain3.c SRCDIR/lisp2c.c SRCDIR/rplcons.c SRCDIR/z2.c \ + SRCDIR/find-dsp.l SRCDIR/dsphack.l \ + SRCDIR/xmkicon.c SRCDIR/xbbt.c SRCDIR/xinit.c SRCDIR/xscroll.c SRCDIR/xcursor.c SRCDIR/xlspwin.c \ + SRCDIR/xrdopt.c SRCDIR/xwinman.c \ + SRCDIR/dosmouse.c SRCDIR/vesafns.asm SRCDIR/vesainit.c SRCDIR/vgainit.c SRCDIR/kbdif.c \ + SRCDIR/dspsparc.il SRCDIR/copyright SRCDIR/launch.asm + +OFILES = conspage.OEXT gcoflow.OEXT shift.OEXT dbgtool.OEXT \ + gcr.OEXT llcolor.OEXT gcrcell.OEXT llstk.OEXT \ + gcscan.OEXT loopsops.OEXT storage.OEXT \ + allocmds.OEXT dir.OEXT gvar2.OEXT lowlev1.OEXT \ + subr.OEXT arith2.OEXT hacks.OEXT lowlev2.OEXT \ + subr0374.OEXT arith3.OEXT doscomm.OEXT \ + hardrtn.OEXT lsthandl.OEXT sxhash.OEXT arith4.OEXT \ + draw.OEXT main.OEXT testtool.OEXT array.OEXT \ + dsk.OEXT inet.OEXT misc7.OEXT timer.OEXT \ + array2.OEXT dspif.OEXT initdsp.OEXT miscn.OEXT \ + typeof.OEXT array3.OEXT initkbd.OEXT ubf1.OEXT \ + array4.OEXT dspsubrs.OEXT initsout.OEXT \ + mkatom.OEXT ubf2.OEXT array5.OEXT eqf.OEXT \ + intcall.OEXT mkcell.OEXT ubf3.OEXT array6.OEXT \ + ether.OEXT ufn.OEXT atom.OEXT \ + findkey.OEXT kbdsubrs.OEXT mouseif.OEXT ufs.OEXT \ + bbtsub.OEXT foreign.OEXT keyevent.OEXT \ + unixcomm.OEXT bin.OEXT fp.OEXT keylib.OEXT \ + binds.OEXT fvar.OEXT mvs.OEXT \ + unwind.OEXT bitblt.OEXT gc.OEXT \ + uraid.OEXT blt.OEXT gc2.OEXT \ + kprint.OEXT osmsg.OEXT usrsubr.OEXT byteswap.OEXT \ + gcarray.OEXT perrno.OEXT uutils.OEXT \ + carcdr.OEXT asmbbt.OEXT gccode.OEXT \ + vars3.OEXT gcfinal.OEXT ldsout.OEXT \ + return.OEXT vmemsave.OEXT chardev.OEXT \ + gchtfind.OEXT lineblt8.OEXT rpc.OEXT xc.OEXT \ + common.OEXT gcmain3.OEXT lisp2c.OEXT rplcons.OEXT \ + z2.OEXT vdate.OEXT $(KEY) $(COLORFILES) $(ARCHFILES) EXTRAFILES + + +HFILES = INCDIR/address.h INCDIR/adr68k.h INCDIR/arith.h INCDIR/cell.h INCDIR/dbprint.h INCDIR/display.h \ + INCDIR/dspif.h INCDIR/ifpage.h INCDIR/iopage.h INCDIR/lispemul.h INCDIR/lispmap.h \ + INCDIR/lsptypes.h INCDIR/miscstat.h INCDIR/lspglob.h INCDIR/array.h INCDIR/bb.h \ + INCDIR/bitblt.h INCDIR/debug.h INCDIR/devconf.h INCDIR/dspdata.h INCDIR/ether.h \ + INCDIR/fast_dsp.h INCDIR/fp.h INCDIR/gc.h INCDIR/hdw_conf.h INCDIR/initatms.h INCDIR/inlinec.h INCDIR/keyboard.h \ + INCDIR/lispver1.h INCDIR/lispver2.h INCDIR/lldsp.h INCDIR/locfile.h INCDIR/mouseif.h INCDIR/my.h \ + INCDIR/opcodes.h INCDIR/osmsg.h INCDIR/pilotbbt.h INCDIR/print.h INCDIR/profile.h \ + INCDIR/return.h INCDIR/stack.h INCDIR/stream.h INCDIR/subrs.h INCDIR/sysatms.h INCDIR/timeout.h \ + INCDIR/tos1defs.h INCDIR/tosfns.h INCDIR/tosret.h INCDIR/vmemsave.h \ + INCDIR/xdefs.h INCDIR/xbitmaps.h INCDIR/xkeymap.h + + + + ############################## + ### Entry rules ### + ############### ### + ### make only one of these ### + ### four rules on the ### + ### commandline ### + ############################## + +dos4 : + $(MAKE) -f ./mkfile $(MFLAGS) dosmkfil + $(MAKE) -f ./dosmkfil $(MFLAGS) ../bin/medley.exe + $(MAKE) -f ./dosmkfil $(MFLAGS) ../bin/emul.exe + + ############################### + ### Compile rules ### + ################# ### + ### Don't touch these. The ### + ### following rules are ### + ### used by the entry rules ### + ############################### + +dosmkfil : mkfile + -copy mkfile mkfile.c + -$(CC) /P /c mkfile.c 2> junk + -copy mkfile.i dosmkfil + +../bin/emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +lde : $(OFILES) mkvdate + $(RM) vdate.c + mkvdate > vdate.c + - cd ARCH;$(MAKE) $(MFLAGS) all #/* Make the speciffic files for this target */ + $(CC) $(LDFLAGS) $(OFILES) -o $@ + + ################## + ### File rules ### + ################## + +OBJECTDIR/main.o : INCDIR/lispemul.h INCDIR/address.h INCDIR/lsptypes.h INCDIR/adr68k.h\ + INCDIR/stack.h INCDIR/lspglob.h INCDIR/lispmap.h INCDIR/ifpage.h\ + INCDIR/iopage.h INCDIR/return.h INCDIR/debug.h INCDIR/profile.h + + + ###################################### + ### Architecture speciffic targets ### + ### ### + ### replaces the cruft in the ### + ### makefile-. ### + ###################################### + +#ifdef _INTELC32_ /* The cpp macro for the DOS extender */ + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +BINDIR/medley.exe: OBJECTDIR/launch.obj + TLINK launch,medley + +OBJECTDIR/launch.obj: SRCDIR/launch.asm + copy ..\src\launch.asm launch.asm + tasm /ml launch.asm + +OBJECTDIR/xc.obj: SRCDIR/xc.s + tasm /ml xc.s + +SRCDIR/xc.s: SRCDIR/xc.c + rsh sparky (cd /users/sybalsky/maiko/src ; gcc-make $* ) + +#endif diff --git a/bin/mkfile.i b/bin/mkfile.i new file mode 100755 index 0000000..4666407 --- /dev/null +++ b/bin/mkfile.i @@ -0,0 +1,86 @@ + +#line 1 "d:/windows/TEMP/cbr3" +#pragma si(C:\codebldr\inc\) + +#line 1 "mkfile.c" + + + + + + + + +BINARYDIR = ../bin +AFLAGS = /T +COLORFILES = rawcolor.obj +ARCHFILES = dosmouse.obj doskbd.obj vesafns.obj vesainit.obj vgainit.obj kbdif.obj + + + +ADMINFILES = mkdos mkvdate.c optck.c + +ETHERFILES = ldeether.obj + +KEY = keytstno.obj + +CFLAGS = -I. -DBIGATOMS -DNEW_STORAGE -DDOS -DBYTESWAP -DKBINT -DFSERROR -DNOPIXRECT -DNOFORN -DNOETHER -DBIGATOMS -DBIGVM -DNEWCDRCODING -O2 + +LDFLAGS = -O2 graphics.lib binmode.lib mouse.lib + +SRCFILES = ./conspage.c ./gcoflow.c ./shift.c ./dbgtool.c ./gcr.c ./llcolor.c ./gcrcell.c ./llstk.c ./gcscan.c ./loopsops.c ./storage.c ./allocmds.c ./dir.c ./gvar2.c ./lowlev1.c ./subr.c ./arith2.c ./hacks.c ./lowlev2.c ./subr0374.c ./arith3.c ./doscomm.c ./hardrtn.c ./lsthandl.c ./sxhash.c ./arith4.c ./draw.c ./main.c ./testtool.c ./array.c ./dsk.c ./inet.c ./misc7.c ./timer.c ./array2.c ./dspif.c ./initdsp.c ./miscn.c ./typeof.c ./array3.c ./initkbd.c ./ubf1.c ./array4.c ./dspsubrs.c ./initsout.c ./mkatom.c ./ubf2.c ./array5.c ./eqf.c ./intcall.c ./mkcell.c ./ubf3.c ./array6.c ./ether.c ./mkvdate.c ./ufn.c ./atom.c ./findkey.c ./kbdsubrs.c ./mouseif.c ./ufs.c ./bbtsub.c ./foreign.c ./keyevent.c ./unixcomm.c ./bin.c ./fp.c ./keylib.c ./binds.c ./asmbbt.c ./fvar.c ./mvs.c ./unwind.c ./bitblt.c ./gc.c ./uraid.c ./blt.c ./gc2.c ./kprint.c ./keytstno.c ./keytst.c ./osmsg.c usrsubr.c ./byteswap.c ./gcarray.c ./perrno.c ./ldeboot.c ./ldeether.c ./uutils.c ./carcdr.c ./gccode.c ./rawcolor.c ./vars3.c ./gcfinal.c ./ldsout.c ./return.c ./vmemsave.c ./chardev.c ./gchtfind.c ./lineblt8.c ./rpc.c ./xc.c ./common.c ./gcmain3.c ./lisp2c.c ./rplcons.c ./z2.c ./find-dsp.l ./dsphack.l ./xmkicon.c ./xbbt.c ./xinit.c ./xscroll.c ./xcursor.c ./xlspwin.c ./xrdopt.c ./xwinman.c ./dosmouse.c ./vesafns.asm ./vesainit.c ./vgainit.c ./kbdif.c ./dspsparc.il ./copyright ./launch.asm + +OFILES = conspage.obj gcoflow.obj shift.obj dbgtool.obj gcr.obj llcolor.obj gcrcell.obj llstk.obj gcscan.obj loopsops.obj storage.obj allocmds.obj dir.obj gvar2.obj lowlev1.obj subr.obj arith2.obj hacks.obj lowlev2.obj subr0374.obj arith3.obj doscomm.obj hardrtn.obj lsthandl.obj sxhash.obj arith4.obj draw.obj main.obj testtool.obj array.obj dsk.obj inet.obj misc7.obj timer.obj array2.obj dspif.obj initdsp.obj miscn.obj typeof.obj array3.obj initkbd.obj ubf1.obj array4.obj dspsubrs.obj initsout.obj mkatom.obj ubf2.obj array5.obj eqf.obj intcall.obj mkcell.obj ubf3.obj array6.obj ether.obj ufn.obj atom.obj findkey.obj kbdsubrs.obj mouseif.obj ufs.obj bbtsub.obj foreign.obj keyevent.obj unixcomm.obj bin.obj fp.obj keylib.obj binds.obj fvar.obj mvs.obj unwind.obj bitblt.obj gc.obj uraid.obj blt.obj gc2.obj kprint.obj osmsg.obj usrsubr.obj byteswap.obj gcarray.obj perrno.obj uutils.obj carcdr.obj asmbbt.obj gccode.obj vars3.obj gcfinal.obj ldsout.obj return.obj vmemsave.obj chardev.obj gchtfind.obj lineblt8.obj rpc.obj xc.obj common.obj gcmain3.obj lisp2c.obj rplcons.obj z2.obj vdate.obj $(KEY) $(COLORFILES) $(ARCHFILES) + + +HFILES = ../inc/address.h ../inc/adr68k.h ../inc/arith.h ../inc/cell.h ../inc/dbprint.h ../inc/display.h ../inc/dspif.h ../inc/ifpage.h ../inc/iopage.h ../inc/lispemul.h ../inc/lispmap.h ../inc/lsptypes.h ../inc/miscstat.h ../inc/lspglob.h ../inc/array.h ../inc/bb.h ../inc/bitblt.h ../inc/debug.h ../inc/devconf.h ../inc/dspdata.h ../inc/ether.h ../inc/fast_dsp.h ../inc/fp.h ../inc/gc.h ../inc/hdw_conf.h ../inc/initatms.h ../inc/inlinec.h ../inc/keyboard.h ../inc/lispver1.h ../inc/lispver2.h ../inc/lldsp.h ../inc/locfile.h ../inc/mouseif.h ../inc/my.h ../inc/opcodes.h ../inc/osmsg.h ../inc/pilotbbt.h ../inc/print.h ../inc/profile.h ../inc/return.h ../inc/stack.h ../inc/stream.h ../inc/subrs.h ../inc/sysatms.h ../inc/timeout.h ../inc/tos1defs.h ../inc/tosfns.h ../inc/tosret.h ../inc/vmemsave.h ../inc/xdefs.h ../inc/xbitmaps.h ../inc/xkeymap.h + + + + +dos4 : + $(MAKE) -f ./mkfile $(MFLAGS) dosmkfil + $(MAKE) -f ./dosmkfil $(MFLAGS) ../bin/medley.exe + $(MAKE) -f ./dosmkfil $(MFLAGS) ../bin/emul.exe + + +dosmkfil : mkfile + -copy mkfile mkfile.c + -$(CC) /P /c mkfile.c 2> junk + -copy mkfile.i dosmkfil + +../bin/emul.exe : $(OFILES) + @ echo $** > linkopts + @ echo $(CFLAGS) > copts + $(CC) @copts @linkopts $(LDFLAGS) /e$@ + del linkopts + del copts + @ echo "Executable is now named '$@'" + +lde : $(OFILES) mkvdate + $(RM) vdate.c + mkvdate > vdate.c + - cd ARCH;$(MAKE) $(MFLAGS) all #/* Make the speciffic files for this target */ + $(CC) $(LDFLAGS) $(OFILES) -o $@ + + +./main.o : ../inc/lispemul.h ../inc/address.h ../inc/lsptypes.h ../inc/adr68k.h ../inc/stack.h ../inc/lspglob.h ../inc/lispmap.h ../inc/ifpage.h ../inc/iopage.h ../inc/return.h ../inc/debug.h ../inc/profile.h + + + + +.SUFFIXES .exe .lib .c .obj .c .asm .s .c + +../bin/medley.exe: ./launch.obj + TLINK launch,medley + +./launch.obj: ./launch.asm + copy ..\src\launch.asm launch.asm + tasm /ml launch.asm + +./xc.obj: ./xc.s + tasm /ml xc.s + +./xc.s: ./xc.c + rsh sparky (cd /users/sybalsky/maiko/src ; gcc-make $* ) + diff --git a/bin/mkr2 b/bin/mkr2 new file mode 100755 index 0000000..ec31207 --- /dev/null +++ b/bin/mkr2 @@ -0,0 +1,133 @@ +#!/bin/csh +# @(#) makeright Version 1.12 (7/18/90). +##***********************************************************************/ +## */ +## Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +## */ +## This file is work-product resulting from the Xerox/Venue */ +## Agreement dated 18-August-1989 for support of Medley. */ +## */ +##***********************************************************************/ +# +# Feb. 6 1990 osamu: Add display option +# release option does not support yet. +# Apr.23 1990 osamu: add release option. +# +# Jul 18 1990 JDS: Add 'init' option for making init-loading emulators +# +# Mar 7 1991 JDS: Add '3' option for making 3-byte emulators. +# +# usage: makeright [display-option] [other-option] +# +# example: makeright single ; make lde for mmaped displayFB +# makeright multi ; make lde for cg3,cg6 +# makeright x ; make lde for X-windows +# makeright color ; make lde with color support in it. +# makeright multi release ; make release version of lde for cg3,cg6 +# makeright init ; make lde for loading INIT.DLINIT b/w only +# makeright x 3 ; make lde for X-windows, 3-byte-atom version. +# +# makeright multi requires directory "maiko/${osversion}.${architecture}-multi" +# (ex. maiko/sunos4.sparc-multi) +# object files are stored there. +# +# makeright init requires directory "maiko/init.${architecture} +# +# Note: X11R4 environment link shared libraries. +# lde need X library. If lde links shared libraries, +# X shared libraries are needed at run time. +# +# Hide X shared libraries from link libraries search path. +setenv LD_LIBRARY_PATH /usr/local/lib +set RELDIR = ../RELEASE/ + +# Allows user to specify version to make +# Almost useless, except that I needed it to handle the +# SunOS 3.2 sparc version +set osversion = $1 +shift +set architecture = $1 +shift + +if($1 == "") then + set display=single +else + if($1 == "release") then + switch($2) + case single: + set display = single + breaksw + case multi: + set display = multi + breaksw + case x: + set display = x + breaksw + default: + exit + breaksw + endsw + else + set display=$1 + endif +endif + +if( $#argv > 0 ) then + shift +endif + +echo "making so far for ${osversion} on ${architecture}." +switch($display) + case init: + set display = single + set releasename = init.${architecture} + set ldename = ldeinit + breaksw + case single: + set releasename = ${osversion}.${architecture} + set ldename = ldesingle + breaksw + case multi: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldemulti + breaksw + case x: + set releasename = ${osversion}.${architecture}-${display} + set ldename = ldex + breaksw + default: + echo "display-option: $display is not supported." + exit + breaksw +endsw + +if ( ("$1" == "3")) then + set releasename = ${releasename}-3 + shift +endif + +set releaseflg = 0 +if( "$1" == "release" ) then + set releaseflg = 1 + if($display != single) then + if( !(-e usermakefile-${releasename})) then + ln usermakefile-${osversion}.${architecture} usermakefile-${releasename} + endif + endif +else + set releaseflg = 0 +endif +set installdir = ${RELDIR}install.${osversion}.${architecture}/ + +#if($display == single ) then +# set releasename = ${osversion}.${architecture} +#else +# set releasename = ${osversion}.${architecture}-${display} +#endif +echo start making lde for ${releasename}. +# then finally do the make, including the right stuff +# With makefile-tail merged, this should only take ONE make command.... +make RELEASENAME=${releasename} INSDIR=${installdir} LDENAME=${ldename} \ + OSARCHNAME=${osversion}.${architecture} \ + -f makefile-header -f makefile-${releasename} \ + -f makefile-tail $* diff --git a/bin/optck b/bin/optck new file mode 100755 index 0000000000000000000000000000000000000000..351e41797d95ff74b24f07453d49e5efcbcbbc06 GIT binary patch literal 24576 zcmeI3U1%It6vxkeWi}s#$u=<-5r%BkVoSG(2x`F-iNRc8w_~3((B?`Xy5K8e)h!LcS4~i%Xf%SiOCUz50eD{Ch&iUVS z&$)N+Z)Tq^r(qd`BEBRYM&vxS-&J^g?)kEA#f6p?A9?qF-&`?cd&MjajEi_TCpKbB zB(o;7nW!m-8HsHmryw$r*v$6$?e}uAUyzK|>wo|I)rCCrKOWoMHv-$tP7EP;s)aqT zdy>JP$8@~n`F?c8_p^~ar}=Ap;#Z=$IEe9-j&E7<%$gOKHm!K!sv}0rjz-dTpK4+) zKH>bbvBjjSw zh4kEmfA43vvn@|XcC9ytym8$VIg7E~Hh##(XMW7Z(NDSf{5He2T>K`qw!yD#ddt^uYNX{o*12)t z>ee^z>Q;26)0v3y-k>$EAa2;q`k%m7m67@jB5oV;-fHJJ%}Mnyy2dsSoVO}sU+i=` zpjucK=~w+JG`@dF^>yf`$dKxFoY6tgpxfwu=-Tj#MDeQ6MAsPg^`mQyn|A!iy19Bt zozu3>P3MNvu6``yUJ#l58q#&8?>qdC&!C6<#euJ@_c-DVr~lKvhFG(jhjx!4eVd7t z1CCg)i%j4Q@_;K&9l0^|qpr9QLqp0@{NDU67W=8&O_%PzSm!XaJO!tx$cf0Y~PG?ImOjG?Qw2|uHq0LnP3XS!4G)V$D-ri6~?-iNRc8w_~3((B?`Xy5K8e)h!LcS4~i%Xf%SiOCUz50eD{Ch&iUVS z&$)N+Z)Tq^r(qd`BEBRYM&vxS-&J^g?)kEA#f6p?A9?qF-&`?cd&MjajEi_TCpKbB zB(o;7nW!m-8HsHmryw$r*v$6$?e}uAUyzK|>wo|I)rCCrKOWoMHv-$tP7EP;s)aqT zdy>JP$8@~n`F?c8_p^~ar}=Ap;#Z=$IEe9-j&E7<%$gOKHm!K!sv}0rjz-dTpK4+) zKH>bbvBjjSw zh4kEmfA43vvn@|XcC9ytym8$VIg7E~Hh##(XMW7Z(NDSf{5He2T>K`qw!yD#ddt^uYNX{o*12)t z>ee^z>Q;26)0v3y-k>$EAa2;q`k%m7m67@jB5oV;-fHJJ%}Mnyy2dsSoVO}sU+i=` zpjucK=~w+JG`@dF^>yf`$dKxFoY6tgpxfwu=-Tj#MDeQ6MAsPg^`mQyn|A!iy19Bt zozu3>P3MNvu6``yUJ#l58q#&8?>qdC&!C6<#euJ@_c-DVr~lKvhFG(jhjx!4eVd7t z1CCg)i%j4Q@_;K&9l0^|qpr9QLqp0@{NDU67W=8&O_%PzSm!XaJO!tx$cf0Y~PG?ImOjG?Qw2|uHq0LnP3XS!4G)V$D-ri6~?before_create ) \ + ((child_win)->before_create)(parent_win,child_win); \ + (child_win)->win = XCreateSimpleWindow( display \ + , (parent_win)->win \ + , (child_win)->x \ + , (child_win)->y \ + , (child_win)->width \ + , (child_win)->height \ + , (child_win)->border \ + , Black_Pixel \ + , White_Pixel ); \ + XLOCK; \ + XFlush( display ); \ + XUNLOCK; \ + (child_win)->parent = parent_win; \ + if( (child_win)->after_create ) \ + ((child_win)->after_create)(parent_win,child_win);\ + } \ +} + +#define ResizeWindow(display,window) { \ + if( window ) { \ + if( (window)->before_resize ) \ + ((window)->before_resize)( window ); \ + XLOCK;\ + XMoveResizeWindow( (display) \ + , (window)->win \ + , (window)->x \ + , (window)->y \ + , (window)->width \ + , (window)->height ); \ + XFlush( display ); \ + XUNLOCK; \ + if( (window)->after_resize ) \ + ((window)->after_resize)( window ); \ + } \ +} + +#define DefineCursor(display, window,mycursor) { \ + XLOCK; \ + XDefineCursor( display, (window)->win, *(mycursor) ); \ + XFlush( display ); \ + XUNLOCK; \ + (window)->cursor = mycursor; \ +} + diff --git a/inc/Stipple.h b/inc/Stipple.h new file mode 100755 index 0000000..4df0131 --- /dev/null +++ b/inc/Stipple.h @@ -0,0 +1,46 @@ +/* $Id: Stipple.h,v 1.2 1999/01/03 02:05:47 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* Author: Mitsunori Matsuda +* Date : August 26, 1988 +*/ + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define check_width 16 +#define check_height 16 +static char check_bits[] = { 0x88, 0x88 + , 0x00, 0x00 + , 0x22, 0x22 + , 0x00, 0x00 + , 0x88, 0x88 + , 0x00, 0x00 + , 0x22, 0x22 + , 0x00, 0x00 + , 0x88, 0x88 + , 0x00, 0x00 + , 0x22, 0x22 + , 0x00, 0x00 + , 0x88, 0x88 + , 0x00, 0x00 + , 0x22, 0x22 + , 0x00, 0x00 }; diff --git a/inc/XCursors.h b/inc/XCursors.h new file mode 100755 index 0000000..bbec47d --- /dev/null +++ b/inc/XCursors.h @@ -0,0 +1,260 @@ +/* $Id: XCursors.h,v 1.2 1999/01/03 02:05:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* Author: Mitsunori Matsuda +* Date : August 29, 1988 +*/ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +char horizscrollcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x08, 0x20 + , 0x18, 0x30 + , 0x38, 0x38 + , 0x78, 0x3C + , 0xFF, 0xFE + , 0xFF, 0xFE + , 0x78, 0x3C + , 0x38, 0x38 + , 0x18, 0x30 + , 0x08, 0x20 +}; + +LISP_CURSOR horizscroll_cursor = { + 1 + , horizscrollcursor_bitmap + , horizscrollcursor_bitmap + , 7 + , 5 + , NULL +}; + + + +char horizthumbcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x02, 0x00 + , 0x02, 0x00 + , 0x0A, 0x80 + , 0x0A, 0x80 + , 0x0A, 0x80 + , 0x2A, 0xA0 + , 0x2A, 0xA0 + , 0x2A, 0xA0 + , 0xAA, 0xA8 + , 0xAA, 0xA8 + , 0xAA, 0xA8 + , 0xAA, 0xA8 + , 0xAA, 0xA8 +}; + +LISP_CURSOR horizthumb_cursor = { + 1 + , horizthumbcursor_bitmap + , horizthumbcursor_bitmap + , 6 + , 8 + , NULL +}; + + + +char scrolldowncursor_bitmap[]={ + 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x1F, 0xF0 + , 0x1F, 0xF0 + , 0x0F, 0xE0 + , 0x0F, 0xE0 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x01, 0x00 +}; + +LISP_CURSOR scrolldown_cursor = { + 1 + , scrolldowncursor_bitmap + , scrolldowncursor_bitmap + , 7 + , 15 + , NULL +}; + + + +char scrollleftcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x80 + , 0x03, 0x80 + , 0x0F, 0x80 + , 0x3F, 0x80 + , 0xFF, 0xFF + , 0xFF, 0xFF + , 0x3F, 0x80 + , 0x0F, 0x80 + , 0x03, 0x80 + , 0x00, 0x80 +}; + +LISP_CURSOR scrollleft_cursor = { + 1 + , scrollleftcursor_bitmap + , scrollleftcursor_bitmap + , 8 + , 5 + , NULL +}; + + + +char scrollrightcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x01, 0x00 + , 0x01, 0xC0 + , 0x01, 0xF0 + , 0x01, 0xFC + , 0xFF, 0xFF + , 0xFF, 0xFF + , 0x01, 0xFC + , 0x01, 0xF0 + , 0x01, 0xC0 + , 0x01, 0x00 +}; + +LISP_CURSOR scrollright_cursor = { + 1 + , scrollrightcursor_bitmap + , scrollrightcursor_bitmap + , 7 + , 5 + , NULL +}; + + + +char scrollupcursor_bitmap[]={ + 0x01, 0x00 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x0F, 0xE0 + , 0x0F, 0xE0 + , 0x1F, 0xF0 + , 0x1F, 0xF0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 +}; + +LISP_CURSOR scrollup_cursor = { + 1 + , scrollupcursor_bitmap + , scrollupcursor_bitmap + , 7 + , 15 + , NULL +}; + + + +char vertscrollcursor_bitmap[]={ + 0x01, 0x00 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x0F, 0xE0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x0F, 0xE0 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x01, 0x00 +}; + +LISP_CURSOR vertscroll_cursor = { + 1 + , vertscrollcursor_bitmap + , vertscrollcursor_bitmap + , 7 + , 15 + , NULL +}; + + + +char vertthumbcursor_bitmap[]={ + 0x00,0x00 + ,0x00,0x1f + ,0x00,0x00 + ,0x00,0xff + ,0x00,0x00 + ,0x07,0xff + ,0x00,0x00 + ,0x1f,0xff + ,0x00,0x00 + ,0x07,0xff + ,0x00,0x00 + ,0x00,0xff + ,0x00,0x00 + ,0x00,0x1f + ,0x00,0x00 + ,0x00,0x00 +}; + +LISP_CURSOR vertthumb_cursor = { + 1 + , vertthumbcursor_bitmap + , vertthumbcursor_bitmap + , 8 + , 8 + , NULL +}; + diff --git a/inc/XKeymap.h b/inc/XKeymap.h new file mode 100755 index 0000000..968a5bc --- /dev/null +++ b/inc/XKeymap.h @@ -0,0 +1,264 @@ +/* $Id: XKeymap.h,v 1.2 1999/01/03 02:05:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* Generic X-keyboard map for Medley. This table is used at */ +/* start-up time to create the table that maps X keycodes to */ +/* Medley key numbers. */ +/* */ +/* This is done by asking X for the keycodes that correspond */ +/* to given KEYSYMs (X's machine-independent coding scheme), */ +/* and building the table. This has one problem: The mapping */ +/* for non-ASCII characters isn't standard among keyboards. To */ +/* get as reasonable a map as possible, the table below contains */ +/* possibly several mappings for each Medley key number. Since */ +/* not every keyboard has every key (e.g., Alt vs Meta), there */ +/* may also be several mappings for a single KEYSYM. */ +/* */ +/* Here's how it works: Each entry is tried in turn. If the */ +/* Medley key number we'd be assigning is already assigned a */ +/* mapping, skip this entry. If not, assign this mapping, and */ +/* set the "this-KEYSYM-used" flag. If this is a new KEYSYM, */ +/* reset the flag before trying anything. If the "used" flag */ +/* is set, skip until we find a new KEYSYM. */ +/* */ +/* Constraints: */ +/* Put the better key-number assignment earlier. */ +/* Put the better KEYSYM assignment earlier. */ +/* All entries for a single KEYSYM -must- be adjacent */ +/* Final entry in the map has key number -1. */ +/* */ +/************************************************************************/ +/* */ +/* C H A N G E H I S T O R Y */ +/* */ +/* 23 SEP 91 JDS: Rearrange CUT, BS, and DEL keys to assure that */ +/* we get a BS key first, then a CUT key, then, */ +/* if there's a key left, a DEL (BW) key. */ +/* */ +/* 26 MAY 92 JDS: Rearrange keys for PC kbd layout. */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifdef XWINDOW + +int generic_X_keymap[] = + { + 0, 107, 0x1000ff10, /* Un-named KEYSYM used on Sun kbd for F11 */ + 0, 108, 0x1000ff11, /* Un-named KEYSYM used on Sun kbd for F12 */ + 0, 107, XK_F11, + 0, 61, XK_F11, /* STOP, usual sun type-4 kbd key */ + 0, 61, XK_Pause, /* STOP, Pause/break key on PC */ + 0, 108, XK_F12, + 0, 91, XK_F12, + 0, 61, XK_L1, + 0, 91, XK_L2, + 0, 97, XK_Help, + 0, 99, XK_F2, + 0, 106, XK_F10, + 0, 100, XK_F3, + 0, 67, XK_F4, + 0, 68, XK_F5, + 0, 101, XK_F6, + 0, 66, XK_F7, + 0, 104, XK_F8, + 0, 80, XK_F9, + 0, 31, XK_Meta_L, /* Meta, standard meta key */ + 0, 86, XK_Meta_L, /* (sun left-diamond key) */ + 0, 31, XK_Alt_L, /* Meta, Sun-4 usual key */ + 0, 86, XK_Alt_L, /* (sun left-diamond key) */ + 0, 75, XK_F21, + 0, 110, XK_F22, + 0, 74, XK_F23, + 0, 109, XK_F13, + 0, 14, XK_F15, /* SAME key on Sun type-4 kbd */ +#ifdef XK_Scroll_Lock + 0, 14, XK_Scroll_Lock, /* SAME key on PC kbd */ +#endif /* .. scroll .. */ + 0, 33, XK_Escape, + 0, 32, XK_1, + 0, 32, XK_exclam, + 0, 17, XK_2, + 0, 17, XK_at, + 0, 16, XK_3, + 0, 16, XK_numbersign, + 0, 1, XK_4, + 0, 1, XK_dollar, + 0, 0, XK_5, + 0, 0, XK_percent, + 0, 2, XK_6, + 0, 2, XK_asciicircum, + 0, 4, XK_7, + 0, 4, XK_ampersand, + 0, 53, XK_8, + 0, 53, XK_asterisk, + 0, 22, XK_9, + 0, 22, XK_parenleft, + 0, 8, XK_0, + 0, 8, XK_parenright, + 0, 10, XK_minus, + 0, 10, XK_underscore, + 0, 59, XK_equal, + 0, 59, XK_plus, + 0, 45, XK_quoteleft, + 0, 45, XK_asciitilde, + 0, 89, XK_F16, /* Copy, Sun-4 kbd L6 */ + 0, 34, XK_Tab, + 0, 19, XK_Q, + 0, 18, XK_W, + 0, 3, XK_E, + 0, 48, XK_R, + 0, 49, XK_T, + 0, 51, XK_Y, + 0, 6, XK_U, + 0, 23, XK_I, + 0, 25, XK_O, + 0, 11, XK_P, + 0, 58, XK_bracketleft, + 0, 58, XK_braceleft, + 0, 29, XK_bracketright, + 0, 29, XK_braceright, + 0, 13, XK_Delete, + 0, 111, XK_F17, + 0, 36, XK_Control_L, + 0, 21, XK_A, + 0, 20, XK_S, + 0, 5, XK_D, + 0, 35, XK_F, + 0, 50, XK_G, + 0, 52, XK_H, + 0, 38, XK_J, + 0, 9, XK_K, + 0, 26, XK_L, + 0, 43, XK_semicolon, + 0, 28, XK_quoteright, + 0, 105, XK_backslash, + 0, 105, XK_bar, + 0, 105, XK_brokenbar, + 0, 44, XK_Return, +/* 46, XK_F20, See DELETE, CUT, BS below */ + 0, 41, XK_Shift_L, + 0, 40, XK_Z, + 0, 24, XK_X, + 0, 37, XK_C, + 0, 7, XK_V, + 0, 39, XK_B, + 0, 54, XK_N, + 0, 55, XK_M, + 0, 27, XK_comma, + 0, 42, XK_period, + 0, 12, XK_slash, + 0, 60, XK_Shift_R, + 0, 71, XK_Linefeed, + 0, 92, XK_Help, + 0, 92, XK_Print, /* PC Kbd Print key, works as HELP */ + 0, 56, XK_Caps_Lock, + 0, 86, XK_Meta_L, + 0, 57, XK_space, + 0, 88, XK_Meta_R, + + /* DELETE, CUT, and BACKSPACE keys. It's important that there */ + /* be a BS key, so we'll take over DEL for that purpose */ + /* if nothing better offers. We also need a CUT key, so we'll */ + /* grab it for THAT if there's a BS key. */ + + 0, 15, XK_BackSpace, /* best BS key */ + 0, 46, XK_F20, /* CUT key on Sun kbd */ + 0, 13, XK_KP_Decimal, /* Keypad DEL/. key if all else fails */ + 0, 15, XK_Delete, /* Use DEL for BS if needed */ + 0, 46, XK_Delete, /* or for CUT if needed */ + 1, 13, XK_Delete, /* Or leave it as BackWord */ + + + /* The keypad (right side, numeric entry pad) */ + /* But keypad-decimal is assigned up with DEL & BS */ + 0, 98, XK_KP_0, /* Keypad 0 */ + 0, 89, XK_Insert, /* Copy, generic INS key */ + 0, 98, XK_Insert, /* INS key = Keypad 0 otherwise */ + 0, 94, XK_KP_1, /* Keypad 1 */ + 0, 94, XK_R13, + 0, 69, XK_KP_2, + 0, 70, XK_KP_3, + 0, 70, XK_F35, + 0, 84, XK_KP_4, + 0, 85, XK_KP_5, + 0, 85, XK_F31, + 0, 87, XK_KP_6, + 0, 81, XK_KP_7, + 0, 81, XK_F27, + 0, 82, XK_KP_8, + 0, 83, XK_F29, + 0, 83, XK_KP_9, + 0, 96, XK_KP_Subtract, + 0, 76, XK_KP_Enter, + 0, 102, XK_KP_Add, + 0, 73, XK_Num_Lock, + 0, 64, XK_KP_Equal, + 0, 64, XK_F24, + 0, 65, XK_KP_Divide, + 0, 65, XK_F25, + 0, 95, XK_KP_Multiply, + 0, 95, XK_F26, + + + + /* Arrow keys. If not already assigned by the */ + /* keypad digit assignments above, try assigning */ + /* the new arrow-key key#s assigned for RS/6000 */ + /* Failing that, try assigning the keypad #s. */ + 0, 129, XK_Left, + 0, 84, XK_Left, + + 0, 130, XK_Up, + 0, 82, XK_Up, + + 0, 131, XK_Down, + 0, 69, XK_Down, + + 0, 132, XK_Right, + 0, 87, XK_Right, + + 0, 93, XK_Multi_key, /* Expand, suyn type-4 */ + 0, 93, XK_Alt_R, /* Expand, RH Alt key */ + 0, 93, XK_Mode_switch, /* Expand, RH Alt key on PC kbd */ + /* No key defs may come here! */ + 0, 47, XK_Mode_switch, /* Next, Sun-4 Alt-graph key */ + 1, 47, XK_Control_R, /* Next, PC's right-hand Ctrl key */ + 0, 47, XK_Next, /* Next, Next or PgDn key ? */ + 0, 91, XK_Next, /* Again, Next or PgDn key */ + + 0, 63, XK_F14, /* Undo, Sun-4 kbd L4 */ + 0, 63, XK_Prior, /* Undo, generic Prev or PgUp key */ + + 0, 90, XK_F19, /* Find, Sun-4 L9 key */ + 0, 90, XK_Find, /* Find, generic Find key */ + 0, 90, XK_End, /* End key on PC kbd */ + + 0, 62, XK_F18, /* Move key on Sun4 kbd */ + 0, 62, XK_Home, /* Home key on PC 101-key kbd */ + + -1, -1, -1 }; + + +#endif /* XWINDOW */ + diff --git a/inc/XVersion.h b/inc/XVersion.h new file mode 100755 index 0000000..7fe6c08 --- /dev/null +++ b/inc/XVersion.h @@ -0,0 +1,60 @@ +/* $Id: XVersion.h,v 1.2 1999/01/03 02:05:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +#ifdef XWINDOW +#ifdef XV11R4 +#undef XV11R1 +#undef XV11R2 +#undef XV11R3 +#endif /* XV11R4 */ + + +#ifdef XV11R3 +#undef XV11R1 +#undef XV11R2 +#undef XV11R4 +#endif /* XV11R3 */ + + +#ifdef XV11R2 +#undef XV11R1 +#undef XV11R3 +#undef XV11R4 +#endif /* XV11R2 */ + + +#ifdef XV11R1 +#undef XV11R2 +#undef XV11R3 +#undef XV11R4 +#endif /* XV11R1 */ + + +#if ( !(defined( XV11R1 )) \ + && !(defined( XV11R2 )) \ + && !(defined( XV11R3 )) \ + && !(defined( XV11R4 )) ) +#define XV11R4 /* newest version */ +#endif +#endif /* XWINDOW */ + + + diff --git a/inc/XWaitCur.h b/inc/XWaitCur.h new file mode 100755 index 0000000..7379aa9 --- /dev/null +++ b/inc/XWaitCur.h @@ -0,0 +1,38 @@ +/* $Id: XWaitCur.h,v 1.2 1999/01/03 02:05:49 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* +* Copyright (C) 1988 by Fuji Xerox co.,Ltd. All rights reserved. +* +* Author: Mitsunori Matsuda +* Date : August 30, 1988 +*/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + +char waitcursor_bitmap[]= + { + 0xFF, 0xFE, 0xC0, 0x06, 0x60, 0x1C, 0x3D, 0x78 + , 0x1F, 0xF0, 0x0F, 0xE0, 0x06, 0xC0, 0x03, 0x80 + , 0x02, 0x80, 0x03, 0xC0, 0x0D, 0x60, 0x19, 0x30 + , 0x37, 0xD8, 0x67, 0xEC, 0xFF, 0xFE, 0xFF, 0xFE + }; + +LISP_CURSOR wait_cursor = + { + 1 + , waitcursor_bitmap + , waitcursor_bitmap + , 7 + , 8 + , NULL + }; + diff --git a/inc/Xbitblt.h b/inc/Xbitblt.h new file mode 100755 index 0000000..1996a9e --- /dev/null +++ b/inc/Xbitblt.h @@ -0,0 +1,71 @@ +/* $Id: Xbitblt.h,v 1.2 1999/01/03 02:05:49 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* +* Copyright (C) 1988 by Fuji Xerox co.,Ltd. All rights reserved. +* +* Author: Mitsunori Matsuda +* Date : August 11, 1988 +* +*/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +#define Xbitblt( display, x,y,w,h) { \ + XPutImage( display, Display_Window.win \ + , *(Display_Window.gc) \ + , &XScreenBitmap \ + , x \ + , y \ + , x - ScreenRegion.left_x \ + , y - ScreenRegion.top_y \ + , w \ + , h ); \ + /* XFlush( display ); */ \ +} + +#define clipping_Xbitblt(x,y,w,h) { \ + int temp_x \ + , temp_y; \ + temp_x = x + w - 1; \ + temp_y = y + h - 1; \ + if( ( temp_x < ScreenRegion.left_x ) \ + || ( x > ScreenRegion.right_x ) \ + || ( temp_y < ScreenRegion.top_y ) \ + || ( y > ScreenRegion.bottom_y ) ) { \ + return; \ + } \ + if( ( x >= ScreenRegion.left_x ) \ + && ( temp_x <= ScreenRegion.right_x ) \ + && ( y >= ScreenRegion.top_y ) \ + && ( temp_y <= ScreenRegion.bottom_y ) ) { \ + Xbitblt( x, y, w, h ); \ + return; \ + } \ + if( x < ScreenRegion.left_x ) { \ + w -= ScreenRegion.left_x - x; \ + x = ScreenRegion.left_x; \ + } \ + if( temp_x > ScreenRegion.right_x ) { \ + w -= temp_x - ScreenRegion.right_x; \ + } \ + if( y < ScreenRegion.top_y ) { \ + h -= ScreenRegion.top_y - y; \ + y = ScreenRegion.top_y; \ + } \ + if( temp_y > ScreenRegion.bottom_y ) { \ + h -= temp_y - ScreenRegion.bottom_y; \ + } \ + if( ( w>0 ) && ( h>0 ) ) { \ + Xbitblt( x, y, w, h ); \ + } \ +} diff --git a/inc/Xcursdef.h b/inc/Xcursdef.h new file mode 100755 index 0000000..5877776 --- /dev/null +++ b/inc/Xcursdef.h @@ -0,0 +1,38 @@ +/* $Id: Xcursdef.h,v 1.2 1999/01/03 02:05:49 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* +* Copyright (C) 1988 by Fuji Xerox co.,Ltd. All rights reserved. +* +* Author: Mitsunori Matsuda +* Date : August 29, 1988 +*/ + + +/************************************************************************/ +/* */ +/* Structure used to describe cursors in the X version of Medley. */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +typedef struct { + short cubitsprepixel; /* bits per pixel in the cursor, mostly 1 */ + char *cuimage; /* the image bitmap */ + char *cumask; /* the mask bitmap */ + short cuhotspotx; /* hot-spot X coordinate */ + short cuhotspoty; /* hot-spot Y coordinate */ + short cudata; /* ?? */ +} LISP_CURSOR; diff --git a/inc/Xdefcur.h b/inc/Xdefcur.h new file mode 100755 index 0000000..b942ee9 --- /dev/null +++ b/inc/Xdefcur.h @@ -0,0 +1,39 @@ +/* $Id: Xdefcur.h,v 1.2 1999/01/03 02:05:50 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* +* Copyright (C) 1988 by Fuji Xerox co.,Ltd. All rights reserved. +* +* Author: Mitsunori Matsuda +* Date : August 30, 1988 +*/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +char defaultcursor_bitmap[]= + { + 0x80, 0, 0xc0, 0, 0xe0, 0, 0xf0, 0 + , 0xf8, 0, 0xfc, 0, 0xfe, 0, 0xf0, 0 + , 0xd8, 0, 0x98, 0, 0x0c, 0, 0x0c, 0 + , 0x06, 0, 0x06, 0, 0x03, 0, 0x03, 0 + }; + +LISP_CURSOR default_cursor = + { + 1 + , defaultcursor_bitmap + , defaultcursor_bitmap + , 0 + , 15 + , NULL + }; diff --git a/inc/Xdeflt.h b/inc/Xdeflt.h new file mode 100755 index 0000000..89066d5 --- /dev/null +++ b/inc/Xdeflt.h @@ -0,0 +1,35 @@ +/* $Id: Xdeflt.h,v 1.2 1999/01/03 02:05:50 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/* +* +* Define the X window Medley runs in. +* +*/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define DEF_WIN_X 20 +#define DEF_WIN_Y 20 +#define DEF_WIN_WIDTH 565 +#define DEF_WIN_HEIGHT 430 +#define WIN_MIN_WIDTH 150 +#define WIN_MIN_HEIGHT 100 +#define DEF_BDRWIDE 2 +#define SCROLL_WIDTH 18 +#define WINDOW_NAME "Medley (C) Copyright 1980-94 Venue" +#define ICON_NAME "Medley" + diff --git a/inc/Xdisplay.h b/inc/Xdisplay.h new file mode 100755 index 0000000..5efc1b9 --- /dev/null +++ b/inc/Xdisplay.h @@ -0,0 +1,50 @@ +/* $Id: Xdisplay.h,v 1.2 1999/01/03 02:05:51 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* +* +* +* Copyright (C) 1988 by Fuji Xerox co.,Ltd. All rights reserved. +* +* Author: Mitsunori Matsuda +* Date : July 26,1988 +*/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +typedef struct + { + char *name; /* name of this window */ + Window win; /* window id */ + int x,y; /* x and y cordinates */ + int width,height; /* window size */ + int border; /* border width */ + GC *gc; + unsigned logn event_mask; + Cursor *cursor; /* current cursor */ + int (*func)(); /* Event Function */ + } MyWindow; + + +typedef struct + { + int type; /* Event type */ + int (*func)();/* Event function */ + } MyEvent; + + +typedef struct + { + int left_x; /* x coordinate of upper-left corner */ + int top_y; /* y coordinate of upper-lert corner */ + int right_x; /* x coordinate of lower-right corner */ + int bottom_y;/* y coordinate of lower-right corner */ + } DisplayArea; + diff --git a/inc/Xicon.h b/inc/Xicon.h new file mode 100755 index 0000000..46f1d1b --- /dev/null +++ b/inc/Xicon.h @@ -0,0 +1,81 @@ +/* $Id: Xicon.h,v 1.2 1999/01/03 02:05:51 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1991 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +int Lisp_icon_width = 88; +int Lisp_icon_height = 58; + +char Lisp_icon[] = + { + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, + 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x3f, 0xe2, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x20, + 0xbf, 0xff, 0xff, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x97, 0xa8, + 0x3f, 0xff, 0xff, 0xa0, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x22, + 0x20, 0x00, 0x00, 0x88, 0x20, 0x82, 0x08, 0x20, 0x83, 0xf0, 0x20, + 0xa0, 0x00, 0x00, 0x82, 0x08, 0x20, 0x82, 0x08, 0x21, 0x10, 0x28, + 0x24, 0x01, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0x1f, 0xe2, + 0x29, 0xb2, 0x00, 0x88, 0x24, 0x00, 0x00, 0x60, 0x83, 0x04, 0x20, + 0xa9, 0xb2, 0x50, 0x82, 0x0c, 0x00, 0x00, 0x48, 0x21, 0x06, 0x08, + 0x29, 0xb2, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0xfc, 0x82, + 0x24, 0x01, 0x00, 0xbf, 0xff, 0xff, 0xff, 0xe0, 0x82, 0x08, 0x20, + 0xa0, 0x00, 0x00, 0xbf, 0xff, 0xe0, 0x08, 0x48, 0x21, 0xfe, 0x08, + 0x20, 0x01, 0x20, 0xe0, 0x00, 0x20, 0x0f, 0x42, 0x0a, 0x02, 0x82, + 0x20, 0x00, 0x90, 0xe0, 0x00, 0x3f, 0xf8, 0x60, 0x83, 0xfe, 0x20, + 0xa5, 0x48, 0x90, 0xbf, 0xff, 0xff, 0xff, 0x48, 0x20, 0x82, 0x08, + 0x20, 0x00, 0x90, 0xbf, 0xff, 0xe0, 0x08, 0x42, 0x08, 0x20, 0x82, + 0x20, 0x01, 0x20, 0xa0, 0x00, 0x35, 0x4f, 0x7f, 0xff, 0xff, 0xe0, + 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x20, 0x08, 0x5f, 0xff, 0xff, 0xe8, + 0x20, 0x00, 0x00, 0xa0, 0x00, 0x35, 0x4f, 0x50, 0x00, 0x00, 0x22, + 0x3f, 0xff, 0xff, 0xab, 0x56, 0x20, 0x08, 0x70, 0x07, 0xc0, 0x20, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x0f, 0xd0, 0x0c, 0x47, 0xa8, + 0x22, 0x00, 0x00, 0x2d, 0x5a, 0xa0, 0x08, 0x90, 0x0f, 0xcc, 0xa2, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x34, 0x08, 0x30, 0x10, 0x17, 0xa0, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x20, 0x0a, 0x10, 0x17, 0xd0, 0x28, + 0x22, 0x00, 0x00, 0x20, 0x00, 0x35, 0x08, 0x90, 0x2c, 0x67, 0xa2, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x30, 0x37, 0xdc, 0xa0, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x4a, 0x17, 0xe0, 0x07, 0xa8, + 0x22, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x94, 0x57, 0xc0, 0x22, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x37, 0xec, 0x40, 0x20, + 0x83, 0xff, 0xff, 0xe0, 0x00, 0x20, 0x0a, 0x10, 0x27, 0xc0, 0x28, + 0x20, 0x82, 0x08, 0x20, 0x00, 0x20, 0x08, 0x90, 0x10, 0x00, 0x22, + 0x08, 0x20, 0x82, 0x20, 0x00, 0x3f, 0xf8, 0x30, 0x1f, 0xc0, 0x20, + 0x82, 0x08, 0x20, 0xa0, 0x00, 0x20, 0x82, 0x10, 0x0c, 0x40, 0x28, + 0x20, 0x82, 0x08, 0x3f, 0xff, 0xe8, 0x20, 0x90, 0x07, 0xc0, 0x22, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x00, 0x00, 0x20, + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x00, 0x00, 0x28, + 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x9f, 0xff, 0xff, 0xe2, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, + 0x42, 0x13, 0x18, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x99, 0x34, 0xa5, 0x24, 0x29, 0x26, 0x38, 0xc5, 0x04, 0x00, 0x00, + 0xa1, 0x14, 0x99, 0x27, 0x35, 0x29, 0x40, 0x26, 0x9c, 0x00, 0x00, + 0xa1, 0x13, 0xa4, 0xe4, 0x25, 0x29, 0x30, 0xe4, 0xa4, 0x00, 0x00, + 0xa1, 0x10, 0xa4, 0x24, 0x24, 0xc9, 0x09, 0x24, 0xa4, 0x00, 0x00, + 0x5a, 0x13, 0x18, 0xc7, 0xa4, 0xc6, 0x70, 0xd4, 0x9c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xc0, 0x50, 0x84, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x10, 0x20, + 0x02, 0x12, 0x00, 0x48, 0xcb, 0x32, 0x22, 0x0c, 0x02, 0x38, 0x20, + 0x03, 0x92, 0x50, 0x31, 0x2c, 0x49, 0x42, 0x12, 0x02, 0x10, 0xe0, + 0x02, 0x12, 0x50, 0x31, 0xe8, 0x48, 0x82, 0x12, 0x02, 0x11, 0x20, + 0x02, 0x16, 0x50, 0x49, 0x08, 0x49, 0x42, 0x12, 0x02, 0x15, 0x20, + 0x02, 0x0a, 0x50, 0x84, 0xc8, 0x32, 0x21, 0xcc, 0x93, 0xc8, 0xe0, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; diff --git a/inc/address.h b/inc/address.h new file mode 100755 index 0000000..929910a --- /dev/null +++ b/inc/address.h @@ -0,0 +1,59 @@ +/* $Id: address.h,v 1.2 1999/01/03 02:05:51 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/**********************************************************************/ +/* + File Name : address.h + + Address Manipulate Macros(for LISP pointer) + + Date : December 8, 1986 + Edited by : Takeshi Shimizu + Changed : Dec.22.86 (take) + Changed : Jan.14.87(take) + Changed : Apr.20.87(mitani) + Sep.02.87 take + (add parenthesises) +*/ +/**********************************************************************/ + +/* NOTE: Thease MACRO shuld be used for the pointers in LISP SYSOUT */ +#define LLSH(datum , n) ((datum )<< n) +#define LRSH(datum , n) ((datum) >> n) + +#define HILOC(ptr) (LRSH(((unsigned int)(ptr) & SEGMASK),16)) +#define LOLOC(ptr) ((unsigned int)(ptr) & 0x0ffff) + +#define VAG2(hi,lo) (LLSH((hi),16) | (lo)) + + +/* NOTE: argument off must be WORD offset */ +#define ADDBASE(ptr,off) ((UNSIGNED)(ptr) + (off)) +#define GETBASE(ptr,off) (GETWORD(((DLword *)(ptr)) + (off))) + + + +/* Following MACRO defs. is related with POINTER which is defined as ACCESSFNS in Interlisp(LLNEW) */ +#ifdef BIGVM +#define POINTER_PAGE(datum) (((unsigned int)(datum) & 0x0fffff00) >> 8 ) +#define POINTER_SEGMENT(datum) HILOC(datum) +#define POINTER_PAGEBASE(datum) ((datum) & 0x0fffff00) +#else +#define POINTER_PAGE(datum) (((unsigned int)(datum) & 0x0ffff00) >> 8 ) +#define POINTER_SEGMENT(datum) HILOC(datum) +#define POINTER_PAGEBASE(datum) ((datum) & 0x0ffff00) +#endif /* BIGVM */ diff --git a/inc/adr68k.h b/inc/adr68k.h new file mode 100755 index 0000000..ad31608 --- /dev/null +++ b/inc/adr68k.h @@ -0,0 +1,69 @@ +/* $Id: adr68k.h,v 1.2 1999/01/03 02:05:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* + * Copyright (C) 1987 by Fuji Xerox Co., Ltd. All rights reserved. + * + * Author : Takeshi Shimizu + * Hiroshi Hayata + */ + + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +/**********************************************************************/ +/* + Func name : adr68k.h + Translate 68k address to Lisp or Lisp to 68k + + Date : January 16, 1987 + Create : Takeshi Shimizu +*/ +/**********************************************************************/ + + + +/* translate 68k ptr to Lisp DLword address */ +#define LADDR_from_68k(ptr68k) ((LispPTR)(((UNSIGNED)(ptr68k) - (UNSIGNED)Lisp_world) >>1)) + + +/* translate 68k ptr to Lisp Page number */ +#define LPAGE_from_68k(ptr68k) (LADDR_from_68k(ptr68k) >> 8) + + +/* Translate Lisp_address to 68K address */ +/* Lisp_addr: word offset */ +#ifndef I386 +#define Addr68k_from_LADDR(Lisp_addr) (Lisp_world + (Lisp_addr)) +#else +#define Addr68k_from_LADDR(Lisp_addr) ((Lisp_addr) + Lisp_world) +#endif + + +/* translate LispPage to 68k address */ +#define Addr68k_from_LPAGE(Lisp_page) (Addr68k_from_LADDR((Lisp_page << 8) )) + + + + +/* Stack Offset Macros */ + +#define StkOffset_from_68K(ptr68k)\ + ((LispPTR)(((UNSIGNED)(ptr68k) - (UNSIGNED)Stackspace) >>1)) + +#ifndef I386 +#define Addr68k_from_StkOffset(stkoffset)\ + (Stackspace + (stkoffset)) +#else +#define Addr68k_from_StkOffset(stkoffset)\ + ( (stkoffset) + Stackspace) +#endif diff --git a/inc/arith.h b/inc/arith.h new file mode 100755 index 0000000..7eb25df --- /dev/null +++ b/inc/arith.h @@ -0,0 +1,275 @@ +/* $Id: arith.h,v 1.2 1999/01/03 02:05:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define MAX_SMALL 65535 /* == 0x0000FFFF */ +#define MIN_SMALL -65536 /* == 0xFFFF0000 */ + +#define MAX_FIXP 2147483647 /* == 0x7FFFFFFF */ +#define MIN_FIXP -2147483648 /* == 0x80000000 */ + +#define GetSmalldata(x) (((SEGMASK & x)==S_POSITIVE) ? (0xFFFF & x) : (((SEGMASK & x)==S_NEGATIVE) ? (0xFFFF0000 | x) : error("Not smallp address"))) + +#define GetSmallp(x) ((0xFFFF0000 & x) ? (((0xFFFF0000 & x)==0xFFFF0000) ? (S_NEGATIVE | (0xFFFF & x)) : error("Not Smallp data") ) : (S_POSITIVE | (0xFFFF & x))) + + +/* arg sour is Lisp address, arg dest is a box to store the number */ +#define GetNumber(sour, dest){ \ + switch(SEGMASK & sour){\ + case S_POSITIVE: \ + dest = 0xFFFF & sour; \ + break; \ + case S_NEGATIVE: \ + dest = 0xFFFF0000 | sour; \ + break; \ + default: \ + if(GetTypeNumber( sour ) != TYPE_FIXP){ \ + ufn(0xFF & (*PC)); \ + return; \ + } \ + dest = *((int *)Addr68k_from_LADDR(sour)); \ + } \ + } + + + +#define FIXP_VALUE(dest) *((int *)Addr68k_from_LADDR(dest)) + +#define FLOATP_VALUE(dest) *((float *)Addr68k_from_LADDR(dest)) + +#define N_GETNUMBER(sour, dest, label) \ +{ dest = sour; /* access memory once */ \ + switch(SEGMASK & dest){ \ + case S_POSITIVE: \ + dest = 0xFFFF & (dest); \ + break; \ + case S_NEGATIVE: \ + dest = 0xFFFF0000 | (dest); \ + break; \ + default: \ + if (GetTypeNumber( dest ) != TYPE_FIXP) \ + { goto label; } \ + dest = FIXP_VALUE(dest); \ + } \ +} +#ifdef I386 +#define N_IGETNUMBER(sour, dest, label) \ +{ dest = sour; /* access memory once */ \ + switch(SEGMASK & dest){ \ + case S_POSITIVE: \ + dest = 0xFFFF & dest; \ + break; \ + case S_NEGATIVE: \ + dest = 0xFFFF0000 | dest; \ + break; \ + default: \ + switch (GetTypeNumber( dest )) { \ + case TYPE_FIXP: \ + dest = FIXP_VALUE(dest); \ + break; \ + case TYPE_FLOATP: \ + {register float temp; \ + temp = FLOATP_VALUE(dest) ; \ + if ( (temp > ((float) 0x7fffffff)) || \ + (temp < ((float) 0x80000000)) ) \ + goto label; \ + dest = (int) temp; \ + } \ + break; \ + default: goto label; \ + } \ + break; \ + } \ +} +#else +#define N_IGETNUMBER(sour, dest, label) \ +{ dest = sour; /* access memory once */ \ + switch(SEGMASK & dest){ \ + case S_POSITIVE: \ + dest = 0xFFFF & dest; \ + break; \ + case S_NEGATIVE: \ + dest = 0xFFFF0000 | dest; \ + break; \ + default: \ + switch (GetTypeNumber( dest )) { \ + case TYPE_FIXP: \ + dest = FIXP_VALUE(dest); \ + break; \ + case TYPE_FLOATP: \ + {register float temp; \ + temp = FLOATP_VALUE(dest) ; \ + if ( (temp > ((float) 0x7fffffff)) || \ + (temp < ((float) 0x80000000)) ) \ + goto label; \ + dest = (int) temp; \ + } \ + break; \ + default: goto label; \ + } \ + break; \ + } \ +} + +#endif /* I386 */ + + +#define ARITH_SWITCH(arg, result) \ + switch((int) arg & 0xFFFF0000){ \ + case 0: \ + result = (S_POSITIVE | (int) arg); \ + break; \ + case 0xFFFF0000: \ + result = (S_NEGATIVE | (0xFFFF & (int) arg)); \ + break; \ + default:{register LispPTR *wordp; \ + /* arg is FIXP, call createcell */ \ + wordp = (LispPTR *) createcell68k(TYPE_FIXP); \ + *((int *)wordp) = (int) arg; \ + result = (LADDR_from_68k(wordp)); \ + break; \ + } \ + } + + +/* ******* + NEED to See if this is faster than the N_ARITH_SWITCH macro + + if( (MIN_FIXP <= result) && (result <= MAX_FIXP) ){ + if(0 <= result){ + if(result <= MAX_SMALL) + return(S_POSITIVE | result); + else{ + wordp = createcell68k(TYPE_FIXP); + *((unsigned int *)wordp) = result; + return(LADDR_from_68k(wordp)); + } + }else{ + if(MIN_SMALL <= result) + return(S_NEGATIVE | (0xFFFF & result)); + else{ + wordp = createcell68k(TYPE_FIXP); + *((unsigned int *)wordp) = result; + return(LADDR_from_68k(wordp)); + } + }/ + } +****** */ + + + +#define N_ARITH_SWITCH(arg) \ + switch(arg & 0xFFFF0000){ \ + case 0: \ + return(S_POSITIVE | arg); \ + case 0xFFFF0000: \ + return(S_NEGATIVE | (0xFFFF & arg)); \ + default:{register LispPTR *wordp; \ + /* arg is FIXP, call createcell */ \ + wordp = (LispPTR *) createcell68k(TYPE_FIXP); \ + *((int *)wordp) = arg; \ + return(LADDR_from_68k(wordp)); \ + } \ + } + + + /* Used in ISC asm inlines in arithmetic, to defeat optimizer. + with INLINE_ERROR_EXIT, we use asm jumps to avoid having + one or the other eliminated as dead code. */ +#ifdef ISC +#define INLINE_ARITH_SWITCH(arg,retlbl) \ + switch(arg & 0xFFFF0000){ \ + case 0: \ + result=(S_POSITIVE | arg); \ + break; \ + case 0xFFFF0000: \ + result=(S_NEGATIVE | (0xFFFF & arg)); \ + break; \ + default:{register LispPTR *wordp; \ + /* arg is FIXP, call createcell */ \ + wordp = (LispPTR *) createcell68k(TYPE_FIXP); \ + *((int *)wordp) = arg; \ + result=(LADDR_from_68k(wordp)); \ + } \ + } \ + asm("jmp " retlbl) +#endif /* ISC */ + + +#define N_IARITH_BODY_2(a, tos, op) \ +{ \ +register int arg1,arg2; \ + \ + N_IGETNUMBER( a, arg1, do_ufn); \ + N_IGETNUMBER( tos, arg2, do_ufn); \ + \ + arg1 = arg1 op arg2; \ + \ + N_ARITH_SWITCH(arg1); \ + \ +do_ufn: ERROR_EXIT(tos); \ +} + + +#define N_ARITH_BODY_1(a, n, op) \ +{ \ +register int arg1; \ + \ + N_GETNUMBER( a, arg1, do_ufn); \ + \ + arg1 = arg1 op n; \ + \ +N_ARITH_SWITCH(arg1); \ + \ +do_ufn: ERROR_EXIT(a); \ +} + + +#define N_ARITH_BODY_1_UNSIGNED(a, n, op) \ +{ \ +register unsigned int arg1; \ + \ + N_GETNUMBER( a, arg1, do_ufn); \ + \ + arg1 = arg1 op n; \ + \ +N_ARITH_SWITCH(arg1); \ + \ +do_ufn: ERROR_EXIT(a); \ +} + + + + + +#ifdef I386 + + /*********************************************************/ + /* */ + /* Macros for airthmetic operations, to let inline work */ + /* */ + /*********************************************************/ + +#define iplus32(a,b) Xiplus32() +#define plus32(a,b) Xplus32() +#define iplus32n(a,b) Xiplus32n() +#define sub32(a,b) Xsub32() +#define isub32(a,b) Xisub32() +#define sub32n(a,b) Xisub32n() +#endif + diff --git a/inc/arith2.h b/inc/arith2.h new file mode 100755 index 0000000..b1f4dea --- /dev/null +++ b/inc/arith2.h @@ -0,0 +1,142 @@ +/* $Id: arith2.h,v 1.2 1999/01/03 02:05:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* Take care of results for inlined arithmetic cases. */ +/* xxx_RESULT does overflow checking and boxing. */ +/* */ +/* */ +/************************************************************************/ +#ifdef ARITHINLINE +#ifdef GCC386 +/* Inline defines for arith on GCC386 machines */ + + +extern inline const int plus32 (int arg1, int arg2) +{ + asm(" addl %2,%0 \n\ + jo plus_err": "=r" (arg2): "0" (arg2), "r" (arg1)); + return arg2; +} +#define PLUS_RESULT \ + INLINE_ARITH_SWITCH(result,"plus_ret"); \ + asm("plus_err:"); \ + INLINE_ERROR_EXIT(tos,"plus_ret") + + + +extern inline const int iplus32 (int arg1, int arg2) +{ + asm(" addl %2,%0 \n\ + jo iplus_err": "=r" (arg2): "0" (arg2), "r" (arg1)); + return arg2; +} +#define IPLUS_RESULT \ + INLINE_ARITH_SWITCH(result,"iplus_ret"); \ + asm("iplus_err:"); \ + INLINE_ERROR_EXIT(tos,"iplus_ret") + + + +extern inline const int sub32 (int arg1, int arg2) +{ + asm("subl %2,%0 \n\ + jo diff_err": "=r" (arg1): "0" (arg1), "r" (arg2)); + return arg1; +} +#define DIFF_RESULT \ + INLINE_ARITH_SWITCH(result,"diff_ret"); \ + asm("diff_err:"); \ + INLINE_ERROR_EXIT(tos,"diff_ret") + + + +extern inline const int isub32 (int arg1, int arg2) +{ + asm(" subl %2,%0 \n\ + jo idiff_err": "=r" (arg1): "0" (arg1), "r" (arg2)); + return arg1; +} +#define IDIFF_RESULT \ + INLINE_ARITH_SWITCH(result,"idiff_ret"); \ + asm("idiff_err:"); \ + INLINE_ERROR_EXIT(tos,"idiff_ret") + + + +extern inline const int iplus32n(int arg1, int arg2) +{ + asm("addl %2,%0 \n\ + jo iplusn_err": "=r" (arg2): "0" (arg2), "r" (arg1)); + return arg2; +} +#define IPLUSN_RESULT \ + INLINE_ARITH_SWITCH(result,"iplusn_ret"); \ + asm("iplusn_err:"); \ + INLINE_ERROR_EXIT(tos,"iplusn_ret") + + + +extern inline const int sub32n (int arg1, int arg2) +{ + asm(" subl %2,%0 \n\ + jo idiffn_err": "=r" (arg1): "0" (arg1), "r" (arg2)); + return arg1; +} +#define IDIFFN_RESULT \ + INLINE_ARITH_SWITCH(result,"idiffn_ret"); \ + asm("idiffn_err:"); \ + INLINE_ERROR_EXIT(tos,"idiffn_ret") + + +#else /* Any other ARITHINLINE case */ + +#define PLUS_RESULT \ + N_ARITH_SWITCH(result); \ +doufn2: plus_err_label(); \ + ERROR_EXIT(tos); + + +#define IPLUS_RESULT \ + N_ARITH_SWITCH(result); \ +dummy: iplus_err_label(); + + +#define DIFF_RESULT \ + N_ARITH_SWITCH(result); \ +doufn2: diff_err_label(); \ + ERROR_EXIT(tos); + + +#define IDIFF_RESULT \ + N_ARITH_SWITCH(result); \ +dummy: idiff_err_label(); + + +#define IPLUSN_RESULT \ + N_ARITH_SWITCH(result); \ +dummy: iplusn_err_label(); + + +#define IDIFFN_RESULT \ + N_ARITH_SWITCH(result); \ +dummy: idiffn_err_label(); + +#endif /* GCC386 */ +#endif /* ARITHINLINE */ + diff --git a/inc/array.h b/inc/array.h new file mode 100755 index 0000000..3b32891 --- /dev/null +++ b/inc/array.h @@ -0,0 +1,234 @@ +/* $Id: array.h,v 1.2 1999/01/03 02:05:53 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#ifndef BYTESWAP + /********************************/ + /* Normal byte-order version */ + /********************************/ +#ifdef BIGVM +typedef struct sequencedescriptor { + unsigned orig :1; + unsigned nil :1; + unsigned readonly :1; + unsigned nil2 :1; + unsigned base :28; + unsigned typ :4; + unsigned length: 28; + LispPTR offst; +} Arrayp; + +struct arrayheader { + unsigned nil :4; + unsigned base :28; + unsigned readonlyp :1; + unsigned indirectp :1; + unsigned bitp :1; + unsigned stringp :1; + unsigned adjustablep :1; + unsigned displacedp :1; + unsigned fillpointerp :1; + unsigned extendablep :1; + unsigned typenumber :8; + DLword offset; + LispPTR fillpointer; + LispPTR totalsize; + }; +#else +typedef struct sequencedescriptor { + unsigned orig :1; + unsigned nil :1; + unsigned readonly :1; + unsigned nil2 :1; + unsigned typ :4; + unsigned base :24; + DLword length; + DLword offst; +} Arrayp; + +struct arrayheader { + unsigned nil :8; + unsigned base :24; + unsigned readonlyp :1; + unsigned indirectp :1; + unsigned bitp :1; + unsigned stringp :1; + unsigned adjustablep :1; + unsigned displacedp :1; + unsigned fillpointerp :1; + unsigned extendablep :1; + unsigned typenumber :8; + DLword offset; + DLword fillpointer; + DLword totalsize; + }; +#endif /* BIGVM */ + +struct arrayblock { + unsigned password :13; + unsigned gctype :2; + unsigned inuse :1; + DLword arlen; + LispPTR fwd; + LispPTR bkwd; +}; + +struct abdum { + DLword abflags; +}; + + +#else + /********************************/ + /* Byte-swapped version, for */ + /* e.g., 80386's */ + /********************************/ +#ifdef BIGVM +typedef struct sequencedescriptor { + unsigned base :28; + unsigned nil2 :1; + unsigned readonly :1; + unsigned nil :1; + unsigned orig :1; + unsigned length: 28; + unsigned typ :4; + LispPTR offst; +} Arrayp; + +struct arrayheader { + unsigned base :28; + unsigned nil :4; + DLword offset; + unsigned typenumber :8; + unsigned extendablep :1; + unsigned fillpointerp :1; + unsigned displacedp :1; + unsigned adjustablep :1; + unsigned stringp :1; + unsigned bitp :1; + unsigned indirectp :1; + unsigned readonlyp :1; + LispPTR totalsize; + LispPTR fillpointer; + }; +#else +typedef struct sequencedescriptor { + unsigned base :24; + unsigned typ :4; + unsigned nil2 :1; + unsigned readonly :1; + unsigned nil :1; + unsigned orig :1; + DLword offst; + DLword length; +} Arrayp; + +struct arrayheader { + unsigned base :24; + unsigned nil :8; + DLword offset; + unsigned typenumber :8; + unsigned extendablep :1; + unsigned fillpointerp :1; + unsigned displacedp :1; + unsigned adjustablep :1; + unsigned stringp :1; + unsigned bitp :1; + unsigned indirectp :1; + unsigned readonlyp :1; + DLword totalsize; + DLword fillpointer; + }; +#endif /* BIGVM */ +struct arrayblock { + DLword arlen; + unsigned inuse :1; + unsigned gctype :2; + unsigned password :13; + LispPTR fwd; + LispPTR bkwd; +}; + +struct abdum + { + DLword abflags; +}; + + +#endif /* BYTESWAP */ + + + + +/****************************************************************************/ +/* */ +/* The following data are the constant values for array itself. */ +/* */ +/****************************************************************************/ + +/* #define ST_BYTE 0 in lsptypes.h */ +/* #define ST_POS16 1 in lsptypes.h */ +#define ST_INT32 2 +/*#define ST_CODE 4 in load.h */ +#define ST_PTR 6 +#define ST_FLOAT 7 +#define ST_BIT 8 +#define ST_PTR2 11 + +/****************************************************************************/ +/* */ +/* The following data are the constant values for array reclaimer. */ +/* */ +/****************************************************************************/ + +#define MAXARRAYBLOCKSIZE 65535 +#define MAXARRAYLEN 65535 +#define ARRAYBLOCKHEADERCELLS 1 +#define ARRAYBLOCKTRAILERCELLS 1 +#define ARRAYBLOCKOVERHEADCELLS (ARRAYBLOCKHEADERCELLS+ARRAYBLOCKTRAILERCELLS) +#define MAXARRAYNCELLS (MAXARRAYBLOCKSIZE-ARRAYBLOCKOVERHEADCELLS) +#define ARRAYBLOCKHEADERWORDS 2 +#define ARRAYBLOCKTRAILERWORDS 2 +#define ARRAYBLOCKOVERHEADWORDS (ARRAYBLOCKHEADERWORDS+ARRAYBLOCKTRAILERWORDS) +#define ARRAYBLOCKLINKINGCELLS 2 +#define MINARRAYBLOCKSIZE (ARRAYBLOCKOVERHEADCELLS+ARRAYBLOCKLINKINGCELLS) +#define MAXBUCKETINDEX 30 +#define UNBOXEDBLOCK_GCT 0 +#define PTRBLOCK_GCT 1 +#define CODEBLOCK_GCT 2 +#define ABPASSWORDSHIFT 3 +#define ARRAYBLOCKPASSWORD (43690 >> ABPASSWORDSHIFT) + /* = 1010101010101010 >> 3 = 5461 */ +#define FREEARRAYFLAGWORD ((ARRAYBLOCKPASSWORD << ABPASSWORDSHIFT) | (UNBOXEDBLOCK_GCT << 1)) + /* = 43688 */ +#define USEDARRAYFLAGWORD ((ARRAYBLOCKPASSWORD << ABPASSWORDSHIFT) | 1) +#define CODEARRAYFLAGWORD ((ARRAYBLOCKPASSWORD << ABPASSWORDSHIFT) | ((CODEBLOCK_GCT << 1) | 1)) +#define FIRSTARRAYSEGMENT 19 +#define MAXCELLSPERHUNK 64 + +/****************** The following are for codereclaimer *********************/ + +#define BITSPERBITE 8 + +/********************* End of codereclaimer *********************************/ + + + +/****************************************************************************/ +/* */ +/* End of Definitions */ +/* */ +/****************************************************************************/ diff --git a/inc/bb.h b/inc/bb.h new file mode 100755 index 0000000..5ad1353 --- /dev/null +++ b/inc/bb.h @@ -0,0 +1,837 @@ +/* $Id: bb.h,v 1.2 1999/01/03 02:05:53 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* bb.h + written by don charnley + */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1991 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +/* + COMMENTS: + + This code tries to make very few assumptions about the + underlying hardware, and some are required. The following + assumptions are made: + memory addresses are "byte addresses" + data is effectively 32 bits + the memory is most efficient at 32-bit words + (always 32-bit aligned) + + Left and right shift amounts are always less than 32 bits. + (there is one exception, B_postloop_mask, which may have its + shift count = 32, in which case it is not used) + Right shifted data is masked if necessary to compensate for + possible arithemetic shifts. Arithmetic shifts are assumed as + the default. + + The backwards bit of the control block is followed blindly, + except that gray is always executed forwards. Gray bricks + are always 16 bits wide, and 1 to 16 bits high. These + assumptions are identical to those made in the D-machine + microcode. +*/ + +/* INDEX + + CONSTANTS + op_repl_src + op_fn_and + op_fn_or + op_fn_xor + + CONDITIONS + aligned_loop -- it's all 32-bit-word aligned. + F_single_dst_word -- All the dest bits lie in 1 word + F_postloop_dst_word + F_two_preloop_src + F_src_preloop_normal + F_src_word_in_postloop + B_two_preloop_src + B_src_preloop_normal + B_single_dst_word -- All the dest bits lie in 1 word + B_postloop_dst_word + B_src_word_in_postloop + + VARIABLES + F_num_loop + F_preloop_mask + F_postloop_mask + B_num_loop + B_preloop_mask + B_postloop_mask + + OTHER + + TRANSFER LOOP THINGS + ForInner + DestGetsF + DestGetsB + GetSrcF + GetSrcB + + INIT + some_init + do_gray_init + F_do_init + B_do_init + F_dst_init + gray_src_init + F_src_init + B_dst_init + B_src_init + + SETUPS + do_src_gray_setup + F_do_src_setup + B_do_src_setup + + TRANSFERS + do_gray_transfer + F_do_transfer + B_do_transfer + do_partial_transfer + + POSTLOOP + F_do_postloop_src_prep + B_do_postloop_src_prep + + ADVANCES + do_gray_advance + F_do_advance + B_do_advance + do_src_gray_advance + F_do_dst_advance + F_do_src_advance + B_do_src_advance + B_do_dst_advance + + NAMED VARIABLES + variables +*/ + +/* CONSTANTS */ +#define op_repl_src 0 +#define op_fn_and 1 +#define op_fn_or 2 +#define op_fn_xor 3 + +/* CONDITIONS */ +#define aligned_loop src32lbit == dst32lbit +#define F_single_dst_word (dst32lbit + w) <= 32 +#define F_postloop_dst_word dst32rbit != 31 +#define F_two_preloop_src (src32lbit > dst32lbit) && ((src32lbit + w) > 32) +#define F_src_preloop_normal src32lbit <= dst32lbit +#define F_src_word_in_postloop src32rbit <= dst32rbit +#define B_single_dst_word (dst32lbit + w) <= 32 +#define B_two_preloop_src (src32rbit < dst32rbit) && ((src32lbit + w) > (dst32lbit + 1)) +#define B_src_preloop_normal src32rbit >= dst32rbit +#define B_postloop_dst_word dst32lbit != 0 +#define B_src_word_in_postloop src32lbit >= dst32lbit + +/* VARIABLES */ +#define F_num_loop ((dst32lbit + w) >> 5) - 1 +#define B_num_loop ((w - dst32rbit - 1) > 0) ? ((w - dst32rbit - 1) >> 5) : 0 +#define F_preloop_mask ((dst32lbit) ? (~(0xFFFFFFFF << (32 - dst32lbit))) : 0xFFFFFFFF) +#define F_postloop_mask 0xFFFFFFFF << (31 - dst32rbit) +#define B_preloop_mask 0xFFFFFFFF << (31 - dst32rbit) +#define B_postloop_mask ((dst32lbit) ? (~(0xFFFFFFFF << (32 - dst32lbit))) : 0xFFFFFFFF) + +/* OTHER */ +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/* TRANSFER LOOP THINGS (assume cnt's value is not used!) */ +#define ForInner for (cnt = dstnumL; --cnt >= 0; ) + +#define DestGetsF(FN) *(dst32addr++) FN shS; +#define DestGetsB(FN) *(dst32addr--) FN shS; + + +#define GetSrcF newS = *(src32addr++); \ + shS = savedS | ((newS >> srcRshift)/* & srcRmask*/); \ + savedS = newS << srcLshift; + + +#define GetSrcCF newS = *(src32addr++); \ + shS = ~(savedS | ((newS >> srcRshift) /* & srcRmask */)); \ + savedS = newS << srcLshift; + + +#define GetSrcB newS = *(src32addr--); \ + shS = savedS | (newS << srcLshift); \ + savedS = (newS >> srcRshift) /* & srcRmask*/; + + +#define GetSrcCB newS = *(src32addr--); \ + shS = ~(savedS | (newS << srcLshift)); \ + savedS = (newS >> srcRshift)/* & srcRmask*/; + + + +/************************************************************************/ +/* */ +/* I N I T I A L I Z A T I O N S */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#define some_init \ + num_lines_remaining = h; \ + fwd = !backwardflg; \ + bb_fast = !(31 & (srcbpl | dstbpl)); \ + if (gray) {do_gray_init} \ + else if (fwd) {F_do_init} \ + else {B_do_init} + + +#define do_gray_init \ + F_dst_init \ + gray_src_init + + +#define F_do_init \ + F_dst_init \ + F_src_init + + +#define B_do_init \ + B_dst_init \ + B_src_init + + +#define F_dst_init \ + if (dx < 0) \ + { \ + x32byta = (UNSIGNED)dstbase - ((7 - dx) >> 3); \ + } \ + else \ + { \ + x32byta = (UNSIGNED)dstbase + (dx >> 3); \ + } \ + x32nbyt = x32byta & 3; \ + x32ia = x32byta - x32nbyt; \ + dst32addr = (unsigned int *)x32ia; \ + dst32lbit = (x32nbyt << 3) + (dx & 7); \ + dst32rbit = 31 & (dst32lbit + w - 1); \ + OrigDstAddr = dst32addr; \ + preloop_mask = F_preloop_mask; \ + postloop_mask = F_postloop_mask; \ + sdw_mask = preloop_mask & postloop_mask; \ + dstnumL = F_num_loop; + + +#define gray_src_init \ + bb_fast = !(dstbpl & 31); \ + src32lbit = 15 & sx; + + +#define F_src_init \ + if (sx < 0) \ + { \ + x32byta = (UNSIGNED)srcbase - ((7 - sx) >> 3); \ + } \ + else \ + { \ + x32byta = (UNSIGNED)srcbase + (sx >> 3); \ + } \ + x32nbyt = x32byta & 3; \ + x32ia = x32byta - x32nbyt; \ + src32addr = (unsigned int *)x32ia; \ + src32lbit = (x32nbyt << 3) + (sx & 7); \ + src32rbit = 31 & (src32lbit + w - 1); \ + srcRshift = 31 & (dst32lbit - src32lbit); \ + srcLshift = 31 & (src32lbit - dst32lbit); \ + srcRmask = ((srcLshift) ? ~(0xFFFFFFFF << srcLshift) : 0xFFFFFFFF); \ + OrigSrcAddr = src32addr; + + +#define B_dst_init \ + abc = dx + w - 1; \ + if (abc < 0) \ + { \ + x32byta = (UNSIGNED)dstbase - ((7 - abc) >> 3); \ + } \ + else \ + { \ + x32byta = (UNSIGNED)dstbase + (abc >> 3); \ + } \ + x32nbyt = x32byta & 3; \ + x32ia = x32byta - x32nbyt; \ + dst32addr = (unsigned int *)x32ia; \ + dst32rbit = (x32nbyt << 3) + (abc & 7); \ + dst32lbit = 31 & (dst32rbit - w + 1); \ + OrigDstAddr = dst32addr; \ + preloop_mask = B_preloop_mask; \ + postloop_mask = B_postloop_mask; \ + sdw_mask = preloop_mask & postloop_mask; \ + dstnumL = B_num_loop; + + +#define B_src_init \ + abc = sx + w - 1; \ + if (abc < 0) \ + { \ + x32byta = (UNSIGNED)srcbase - ((7 - abc) >> 3); \ + } \ + else \ + { \ + x32byta = (UNSIGNED)srcbase + (abc >> 3); \ + } \ + x32nbyt = x32byta & 3; \ + x32ia = x32byta - x32nbyt; \ + src32addr = (unsigned int *)x32ia; \ + src32rbit = (x32nbyt << 3) + (abc & 7); \ + src32lbit = 31 & (src32rbit - w + 1); \ + srcRshift = 31 & (dst32lbit - src32lbit); \ + srcLshift = 31 & (src32lbit - dst32lbit); \ + srcRmask = ((srcLshift) ? ~(0xFFFFFFFF << srcLshift) : 0); \ + OrigSrcAddr = src32addr; + + +/************************************************************************/ +/* */ +/* S O U R C E & D E S T I N A T I O N S E T - U P S */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/* SETUPS */ + +#define do_src_gray_setup \ + srcLshift = 15 & (src32lbit - dst32lbit); \ + shS = *srcbase; \ + shS |= (shS << 16); /* replicate the word */ \ + shS <<= srcLshift; /* rotate left */ \ + shS |= (0xFFFF & (shS >> 16)); /* " " */ \ + if (src_comp) shS = ~shS; + + +#define F_do_src_setup \ + if (F_two_preloop_src) \ + { \ + newS = *(src32addr++); \ + savedS = newS << srcLshift; \ + newS = *(src32addr++); \ + shS = savedS | ((newS >> srcRshift) & srcRmask); \ + savedS = (newS << srcLshift) & ~srcRmask; \ + } \ + else if (F_src_preloop_normal) \ + { \ + newS = *(src32addr++); \ + shS = ((newS >> srcRshift) & srcRmask); \ + savedS = (newS << srcLshift) & ~srcRmask; \ + } \ + else \ + { \ + newS = *(src32addr++); \ + shS = newS << srcLshift; \ + } \ + if (src_comp) shS = ~shS; + + +#define B_do_src_setup \ + if (B_two_preloop_src) \ + { \ + newS = *(src32addr--); \ + savedS = (newS >> srcRshift) & srcRmask; \ + newS = *(src32addr--); \ + shS = savedS | (newS << srcLshift); \ + savedS = (newS >> srcRshift) & srcRmask; \ + } \ + else if (B_src_preloop_normal) \ + { \ + newS = *(src32addr--); \ + shS = newS << srcLshift; \ + savedS = (newS >> srcRshift) & srcRmask; \ + } \ + else \ + { \ + newS = *(src32addr--); \ + shS = (newS >> srcRshift) & srcRmask; \ + } \ + if (src_comp) shS = ~shS; + + + +/************************************************************************/ +/* */ +/* T R A N S F E R L O O P S */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#define do_gray_transfer \ + if (F_single_dst_word) \ + { \ + mask = sdw_mask; \ + goto do_fpt; \ + } \ + mask = preloop_mask; \ + do_partial_transfer \ + dst32addr++; \ + switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner { DestGetsF(=) } break; \ + case op_fn_and: ForInner { DestGetsF(&=) } break; \ + case op_fn_or: ForInner { DestGetsF(|=) } break; \ + case op_fn_xor: ForInner { DestGetsF(^=) } break; \ + } \ + if (F_postloop_dst_word) \ + { \ + mask = postloop_mask; \ + goto do_fpt; \ + } \ + goto next_line; + + + +#define F_do_transfer \ + if (F_single_dst_word) \ + { \ + mask = sdw_mask; \ + goto do_fpt; \ + } \ + mask = preloop_mask; \ + do_partial_transfer \ + dst32addr++; \ + if (aligned_loop) \ + { \ + if (src_comp) switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {*dst32addr++ = ~*src32addr++;} break; \ + case op_fn_and: ForInner {*dst32addr++ &= ~*src32addr++;} break; \ + case op_fn_or: ForInner {*dst32addr++ |= ~*src32addr++;} break; \ + case op_fn_xor: ForInner {*dst32addr++ ^= ~*src32addr++;} break; \ + } \ + else switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {*dst32addr++ = *src32addr++;} break; \ + case op_fn_and: ForInner {*dst32addr++ &= *src32addr++;} break; \ + case op_fn_or: ForInner {*dst32addr++ |= *src32addr++;} break; \ + case op_fn_xor: ForInner {*dst32addr++ ^= *src32addr++;} break; \ + } \ + } \ + else \ + { \ + if (src_comp) switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {GetSrcCF DestGetsF(=) } break; \ + case op_fn_and: ForInner {GetSrcCF DestGetsF(&=) } break; \ + case op_fn_or: ForInner {GetSrcCF DestGetsF(|=) } break; \ + case op_fn_xor: ForInner {GetSrcCF DestGetsF(^=) } break; \ + } \ + else switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {GetSrcF DestGetsF(=) } break; \ + case op_fn_and: ForInner {GetSrcF DestGetsF(&=) } break; \ + case op_fn_or: ForInner {GetSrcF DestGetsF(|=) } break; \ + case op_fn_xor: ForInner {GetSrcF DestGetsF(^=) } break; \ + } \ + } \ + if (F_postloop_dst_word) \ + { \ + F_do_postloop_src_prep \ + mask = postloop_mask; \ + goto do_fpt; \ + } \ + goto next_line; + + + + +#define B_do_transfer \ + if (B_single_dst_word) \ + { \ + mask = sdw_mask; \ + goto do_fpt; \ + } \ + mask = preloop_mask; \ + do_partial_transfer \ + dst32addr--; \ + if (aligned_loop) \ + { \ + if (src_comp) switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {*dst32addr-- = ~*src32addr--;} break; \ + case op_fn_and: ForInner {*dst32addr-- &= ~*src32addr--;} break; \ + case op_fn_or: ForInner {*dst32addr-- |= ~*src32addr--;} break; \ + case op_fn_xor: ForInner {*dst32addr-- ^= ~*src32addr--;} break; \ + } \ + else switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {*dst32addr-- = *src32addr--;} break; \ + case op_fn_and: ForInner {*dst32addr-- &= *src32addr--;} break; \ + case op_fn_or: ForInner {*dst32addr-- |= *src32addr--;} break; \ + case op_fn_xor: ForInner {*dst32addr-- ^= *src32addr--;} break; \ + } \ + } \ + else \ + { \ + if (src_comp) switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {GetSrcCB DestGetsB(=) } break; \ + case op_fn_and: ForInner {GetSrcCB DestGetsB(&=) } break; \ + case op_fn_or: ForInner {GetSrcCB DestGetsB(|=) } break; \ + case op_fn_xor: ForInner {GetSrcCB DestGetsB(^=) } break; \ + } \ + else switch (op) \ + { register int cnt; \ + case op_repl_src: ForInner {GetSrcB DestGetsB(=) } break; \ + case op_fn_and: ForInner {GetSrcB DestGetsB(&=) } break; \ + case op_fn_or: ForInner {GetSrcB DestGetsB(|=) } break; \ + case op_fn_xor: ForInner {GetSrcB DestGetsB(^=) } break; \ + } \ + } \ + if (B_postloop_dst_word) \ + { \ + B_do_postloop_src_prep \ + mask = postloop_mask; \ + goto do_fpt; \ + } \ + goto next_line; + + + + +#define do_partial_transfer \ + dstdata = *dst32addr; \ + dstold = dstdata & ~mask; \ + switch (op) \ + { \ + case op_repl_src: dstdata = shS; break; \ + case op_fn_and: dstdata &= shS; break; \ + case op_fn_or: dstdata |= shS; break; \ + case op_fn_xor: dstdata ^= shS; break; \ + } \ + dstdata &= mask; \ + dstdata |= dstold; \ + *dst32addr = dstdata; + + + +/************************************************************************/ +/* */ +/* P O S T - L O O P C O D E */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#define F_do_postloop_src_prep \ + if (F_src_word_in_postloop) \ + { \ + newS = *src32addr; \ + shS = savedS | ((newS >> srcRshift) & srcRmask); \ + } \ + else \ + { \ + shS = savedS; \ + } \ + if (src_comp) shS = ~shS; + + + +#define B_do_postloop_src_prep \ + if (B_src_word_in_postloop) \ + { \ + newS = *src32addr; \ + shS = savedS | (newS << srcLshift); \ + } \ + else \ + { \ + shS = savedS; \ + } \ + if (src_comp) shS = ~shS; + + + + +/************************************************************************/ +/* */ +/* L O O P - C O U N T E R A D V A N C E C O D E */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#define do_gray_advance \ + F_do_dst_advance \ + do_src_gray_advance + +#define F_do_advance \ + F_do_dst_advance \ + F_do_src_advance + +#define B_do_advance \ + B_do_dst_advance \ + B_do_src_advance + +#define F_do_dst_advance \ + if (bb_fast) \ + { \ + OrigDstAddr += dstbpl >> 5; \ + dst32addr = OrigDstAddr; \ + } \ + else \ + { \ + dst32addr = OrigDstAddr; \ + dst32lbit += dstbpl; \ + dst32addr += dst32lbit >> 5; \ + dst32lbit &= 31; \ + dst32rbit = 31 & (dst32lbit + w - 1); \ + OrigDstAddr = dst32addr; \ + preloop_mask = F_preloop_mask; \ + postloop_mask = F_postloop_mask; \ + sdw_mask = preloop_mask & postloop_mask; \ + dstnumL = F_num_loop; \ + } + +#define do_src_gray_advance \ + if (++curr_gray_line >= num_gray) \ + { \ + curr_gray_line = 0; \ + srcbase = srcbase - (num_gray - 1); \ + } \ + else ++srcbase; + +#define F_do_src_advance \ + if (bb_fast) \ + { \ + OrigSrcAddr += srcbpl >> 5; \ + src32addr = OrigSrcAddr; \ + } \ + else \ + { \ + src32addr = OrigSrcAddr; \ + src32lbit += srcbpl; \ + src32addr += src32lbit >> 5; \ + src32lbit &= 31; \ + src32rbit = 31 & (src32lbit + w - 1); \ + OrigSrcAddr = src32addr; \ + srcRshift = 31 & (dst32lbit - src32lbit); \ + srcLshift = 31 & (src32lbit - dst32lbit); \ + srcRmask = ((srcLshift) ? ~(0xFFFFFFFF << srcLshift) : 0xFFFFFFFF); \ + } + +#define B_do_src_advance \ + if (bb_fast) \ + { \ + OrigSrcAddr += srcbpl >> 5; \ + src32addr = OrigSrcAddr; \ + } \ + else \ + { \ + src32addr = OrigSrcAddr; \ + src32rbit += srcbpl; \ + if (src32rbit < 0) \ + { \ + src32addr -= (31 - src32rbit) >> 5; \ + } \ + else \ + { \ + src32addr += src32rbit >> 5; \ + } \ + src32rbit &= 31; \ + src32lbit = 31 & (src32rbit - w + 1); \ + srcRshift = 31 & (dst32lbit - src32lbit); \ + srcLshift = 31 & (src32lbit - dst32lbit); \ + srcRmask = ((srcLshift) ? ~(0xFFFFFFFF << srcLshift) : 0); \ + OrigSrcAddr = src32addr; \ + } + +#define B_do_dst_advance \ + if (bb_fast) \ + { \ + OrigDstAddr += dstbpl >> 5; \ + dst32addr = OrigDstAddr; \ + } \ + else \ + { \ + dst32addr = OrigDstAddr; \ + dst32rbit += dstbpl; \ + if (dst32rbit < 0) \ + { \ + dst32addr -= (31 - dst32rbit) >> 5; \ + } \ + else \ + { \ + dst32addr += dst32lbit >> 5; \ + } \ + dst32rbit &= 31; \ + dst32lbit = 31 & (dst32rbit - w + 1); \ + OrigDstAddr = dst32addr; \ + preloop_mask = B_preloop_mask; \ + postloop_mask = B_postloop_mask; \ + sdw_mask = preloop_mask & postloop_mask; \ + dstnumL = B_num_loop; \ + } + + + +/************************************************************************/ +/* */ +/* V A R I A B L E D E C L A R A T I O N S */ +/* */ +/* This sets up the strictly-internal variables for bitblt. */ +/* */ +/* However, YOU must set up the control variables that are used */ +/* as "arguments" to the bitblt code: */ +/* */ +/* register DLword *srcbase, *dstbase; */ +/* int sx, dx, w, h, srcbpl, dstbpl, backwardflg; */ +/* int src_comp, op, gray, num_gray, curr_gray_line; */ +/* */ +/************************************************************************/ + +#define variables \ +int num_lines_remaining, temp; \ +int dstnumL, src32lbit, srcLshift, dst32lbit; \ +unsigned int srcRmask, dstold, dstdata, mask; \ +UNSIGNED x32byta, x32nbyt, x32ia; \ +int abc, dst32rbit, src32rbit, fwd; \ +unsigned int *OrigSrcAddr, *OrigDstAddr; \ +int bb_fast; \ +unsigned int preloop_mask, postloop_mask, sdw_mask; \ +register unsigned int *dst32addr, *src32addr; \ +register unsigned int shS, savedS, newS; \ +register int srcRshift; + + + +/************************************************************************/ +/* */ +/* n e w _ b i t b l t _ c o d e */ +/* */ +/* Generic bitblt-code macro; generates bitblt code for the */ +/* general cases. Requires a number of symbols be defined */ +/* by the calling code, in lieu of arguments: */ +/* */ +/* srcbase */ +/* dstbase */ +/* srcbpl */ +/* dstbpl */ +/* backwardflg */ +/* sx, dx */ +/* w, h */ +/* */ +/************************************************************************/ + +#define new_bitblt_code \ +{ \ +variables \ +some_init \ +while (num_lines_remaining-- > 0) \ +{ /* begin line loop */ \ + if (gray) \ + { \ + do_src_gray_setup \ + do_gray_transfer \ + } \ + if (fwd) \ + { \ + F_do_src_setup \ + F_do_transfer \ + } \ + { \ + B_do_src_setup \ + B_do_transfer \ + } \ +do_fpt: \ + { \ + do_partial_transfer \ + goto next_line; \ + } \ +next_line: \ + if (gray) \ + { \ + do_gray_advance \ + continue; \ + } \ + if (fwd) \ + { \ + F_do_advance \ + continue; \ + } \ + { \ + B_do_advance \ + continue; \ + } \ +} /* end line loop */ \ +} + + + +/************************************************************************/ +/* */ +/* n e w _ g r a y _ b i t b l t _ c o d e */ +/* */ +/* Handles texture case of bitblt, for BLTSHADE functions. */ +/* */ +/************************************************************************/ + +#define new_gray_bitblt_code \ +{ \ +variables \ +some_init \ +while (num_lines_remaining-- > 0) \ +{ /* begin line loop */ \ + do_src_gray_setup \ + do_gray_transfer \ +do_fpt: \ + do_partial_transfer \ +next_line: \ + do_gray_advance \ +} /* end line loop */ \ +} + + + +/************************************************************************/ +/* */ +/* n e w _ c h a r _ b i t b l t _ c o d e */ +/* */ +/* Optimized slightly for bltchar. */ +/* */ +/************************************************************************/ + +#define new_char_bitblt_code \ +{ \ +variables \ +some_init \ +while (num_lines_remaining-- > 0) \ +{ /* begin line loop */ \ + F_do_src_setup \ + F_do_transfer \ +do_fpt: \ + do_partial_transfer \ +next_line: \ + F_do_advance \ +} /* end line loop */ \ +} + + + diff --git a/inc/bbt386i.h b/inc/bbt386i.h new file mode 100755 index 0000000..98f7b1e --- /dev/null +++ b/inc/bbt386i.h @@ -0,0 +1 @@ +/* $Id: bbt386i.h,v 1.2 1999/01/03 02:05:54 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ diff --git a/inc/bitblt.h b/inc/bitblt.h new file mode 100755 index 0000000..c44ce99 --- /dev/null +++ b/inc/bitblt.h @@ -0,0 +1,95 @@ +/* $Id: bitblt.h,v 1.2 1999/01/03 02:05:54 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* + * Copyright (C) 1988 by Fuji Xerox Co., Ltd. All rights reserved. + * + * File : bitblt.h + * + * Author : Osamu Nakamura + * + */ + + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +#define REPLACE 0 +#define PAINT 2 +#define ERASE 1 +#define INVERT 3 +#define ERROR PIX_SRC + +#define PixOperation( SRCTYPE, OPERATION ) \ + ( SRCTYPE == ERASE ? \ + (OPERATION == REPLACE ? PIX_NOT(PIX_SRC) : \ + (OPERATION == PAINT ? PIX_NOT(PIX_SRC) | PIX_DST : \ + (OPERATION == ERASE ? PIX_NOT(PIX_SRC) & PIX_DST : \ + (OPERATION == INVERT ? PIX_NOT(PIX_SRC) ^ PIX_DST : ERROR)))) : \ + /* SRCTYPE == INPUT */ \ + (OPERATION == REPLACE ? PIX_SRC : \ + (OPERATION == PAINT ? PIX_SRC | PIX_DST : \ + (OPERATION == ERASE ? PIX_SRC & PIX_DST : \ + (OPERATION == INVERT ? PIX_SRC ^ PIX_DST : ERROR))))) + + +extern DLword *EmMouseX68K, *EmMouseY68K; +extern int DisplayRasterWidth; +#define XDELTA 50 +#define YDELTA 50 +#define MOUSEXL ((int)*EmMouseX68K - XDELTA) +#define MOUSEXR ((int)*EmMouseX68K + XDELTA) +#define MOUSEYL ((int)*EmMouseY68K - YDELTA) +#define MOUSEYH ((int)*EmMouseY68K + YDELTA) + + +#ifdef DOS +#define HideCursor { (currentdsp->mouse_invissible)(currentdsp, IOPage68K); } +#define ShowCursor { (currentdsp->mouse_vissible)(IOPage68K->dlmousex, \ + IOPage68K->dlmousey); } + +#elif OLD_CURSOR +extern struct winlock DisplayLockArea; +#define HideCursor \ + ioctl( LispWindowFd, WINLOCKSCREEN, &DisplayLockArea) + +#define ShowCursor \ + ioctl( LispWindowFd, WINUNLOCKSCREEN, &DisplayLockArea) +#else +extern DLword *EmCursorX68K,*EmCursorY68K; +#define HideCursor { taking_mouse_down();} +#define ShowCursor { taking_mouse_up(*EmCursorX68K,*EmCursorY68K);} +#endif + +#define refresh_CG6 \ + HideCursor; \ + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, \ + PIX_SRC,DisplayRegionPixrect, 0, 0); \ + ShowCursor; + +#define clear_CG6 \ + HideCursor; \ + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, \ + PIX_CLR, ColorDisplayPixrect, 0, 0); \ + ShowCursor; + + +/* Macro for locking and unlocking screen to prevent multiple updates */ + +#ifdef DOS +#define LOCKSCREEN currentdsp->device.locked++; +#define UNLOCKSCREEN currentdsp->device.locked--; + +#else + +#define LOCKSCREEN ScreenLocked = T; +#define UNLOCKSCREEN ScreenLocked = NIL; + +#endif /* DOS */ diff --git a/inc/cdrom.h b/inc/cdrom.h new file mode 100755 index 0000000..b8d86c0 --- /dev/null +++ b/inc/cdrom.h @@ -0,0 +1,144 @@ +/* $Id: cdrom.h,v 1.2 1999/01/03 02:05:54 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/*********************************** + + file: cdrom_audio.h + +***********************************/ + +/* function number for CD audio functions */ +#define CD_OPEN 1 +#define CD_CLOSE 2 +#define CD_READ 3 +#define CD_DISK_INFO 4 +#define CD_TRACK_INFO 5 +#define CD_START 6 +#define CD_STOP 7 +#define CD_PLAY 8 +#define CD_Q_READ 9 +#define CD_PAUSE 10 +#define CD_RESUME 11 +#define CD_VOLUME 12 +#define CD_EJECT 13 + +/* function numbers for CD-ROM */ +#define CDROM_INIT_DRV 1 +#define CDROM_KEN_INT 2 +#define CDROM_CHOSAKU 3 +#define CDROM_MIKANA 4 +#define CDROM_MIKANAT 5 +#define CDROM_HYOKI 6 +#define CDROM_HYOKIT 7 +#define CDROM_EIJI 8 +#define CDROM_EIJIT 9 +#define CDROM_SUJI 10 +#define CDROM_SUJIT 11 +#define CDROM_ZENKANA 12 +#define CDROM_ZENKANAT 13 +#define CDROM_ZENKANJ 14 +#define CDROM_ZENKANJT 15 +#define CDROM_ZENEIJI 16 +#define CDROM_ZENEIJIIT 17 +#define CDROM_KOHKANA 18 +#define CDROM_KOHKANAT 19 +#define CDROM_KOHKANJ 20 +#define CDROM_KOHKANJT 21 +#define CDROM_KOHEIJI 22 +#define CDROM_KOHEIJIT 23 +#define CDROM_ZUHAN 24 +#define CDROM_JYOKEN 25 +#define CDROM_JYOKENT 26 +#define CDROM_MENU 27 +#define CDROM_AUDIOST 28 +#define CDROM_AUDIOED 29 +#define CDROM_AUDIOQ_GET 30 +#define CDROM_GAIJI 31 +#define CDROM_ZENGO 32 +#define CDROM_KEIZOKU 33 +#define CDROM_SYURYO 34 + + + +typedef unsigned char BYTE; +typedef unsigned long DWORD; + +/* +extern DWORD CDred_lbn(); +extern void CDlbn_red(); +extern int CDopen(); +extern int CDclose(); +extern int CDread(); +extern int CDdisk_info(); +extern int CDtrack_info(); +extern int CDstart(); +extern int CDstop(); +extern int CDplay(); +extern int CDqread(); +extern int CDpause(); +extern int CDresume(); +extern int CDvolume(); +extern int CDeject(); +*/ + +#define LispStringToCString(Lisp, C, MaxLen) \ + { \ + OneDArray *arrayp; \ + char *base, *dp; \ + short *sbase; \ + int i, length; \ + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); \ + length = min(MaxLen, arrayp->totalsize); \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + strncpy(C, base, length); \ + C[length] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0,dp=C;i<(length);i++) \ + *dp++ = (char)(*sbase++); \ + *dp = '\0'; \ + break; \ + default: \ + error("LispStringToCString can not handle\n"); \ + } \ + } + +#define LispStringToCString2(Lisp, C, MaxLen) \ + { \ + OneDArray *arrayp; \ + char *base, *dp; \ + short *sbase; \ + int i, length; \ + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); \ + length = min(MaxLen, arrayp->totalsize); \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + strncpy(C, base, length); \ + C[length] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0,dp=C;i<(length);i++) { \ + *dp++ = (char)(*sbase / 256 ); \ + *dp++ = (char)(*sbase % 256 ); \ + sbase++; \ + } \ + *dp = '\0'; \ + break; \ + default: \ + error("LispStringToCString can not handle\n"); \ + } \ + } + +#define min(a, b) ((a <= b)?a:b) diff --git a/inc/cell.h b/inc/cell.h new file mode 100755 index 0000000..825fec5 --- /dev/null +++ b/inc/cell.h @@ -0,0 +1,493 @@ +/* $Id: cell.h,v 1.2 1999/01/03 02:05:55 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/**********************************************************************/ +/* + File Name : cell.h + + Cell Manipulate Macros + + Date : December 16, 1986 + Edited by : Takeshi Shimizu + +*/ +/**********************************************************************/ + +/* CONS CELL (LISTP) definitions moved to lispemulater.h */ + + + /* This Macro may produce a pointer that points CAR cell */ + /* On 68010,68000 This Macro does not effect */ + +#ifdef NEWCDRCODING +#define CARFIELD(x) ((int)x & 0x0fffffff) + +/* CDR-Codes defs */ +#define CDR_ONPAGE 8 +#define CDR_NIL 8 +#define CDR_INDIRECT 0 +#define CDR_MAXINDIRECT 7 +#define CONSPAGE_LAST 0xffffffff /* dummy "last cons page" */ + +#else + +#define CARFIELD(x) ((int)x & 0x00ffffff) + +/* CDR-Codes defs */ +#define CDR_ONPAGE 128 +#define CDR_NIL 128 +#define CDR_INDIRECT 0 +#define CDR_MAXINDIRECT 127 +#define CONSPAGE_LAST 0xffff + +#endif /* NEWCDRCODING */ + +/************************************************************************/ +/* */ +/* CONSPAGE describes the free-space management fields at the */ +/* beginning of a cons page -- # of free cells on the page, etc. */ +/* */ +/************************************************************************/ + +#ifndef BYTESWAP +#ifdef NEWCDRCODING +struct + conspage + { +/* used to be ifdef NEWNEW */ + LispPTR cell6; /* cell 6 in shifted world */ + LispPTR cell4; /* cell 4 in shifted world */ +/* used to endif NEWNEW here */ + unsigned count: 8; /* free cells on this page */ + unsigned next_cell: 8; /* next free cell in chain */ + unsigned nil:16; + LispPTR next_page; /* next cons page, or 0 if none */ + }; +#else +struct + conspage + { + unsigned count : 8 ; + unsigned next_cell :8 ; + DLword next_page ; + }; +#endif /* NEWCDRCODING */ +#else +/* byte-swapped version */ +#ifdef NEWCDRCODING +struct + conspage + { + LispPTR cell6; /* cell 6 in shifted world */ + LispPTR cell4; /* cell 4 in shifted world */ + unsigned nil: 16; + unsigned next_cell: 8; + unsigned count: 8; + LispPTR next_page; + }; +#else +struct + conspage + { + DLword next_page ; + unsigned next_cell :8 ; + unsigned count : 8 ; + }; +#endif /* NEWCDRCODING */ +#endif /* BYTESWAP */ + + +/* Following MACROs for Conspage */ + +/* lisp_ptr is LISP pointer, returns 68k ptr points struct conspage obj */ +#define Get_ConsPageBase(lisp_ptr) \ + (struct conspage *)Addr68k_from_LPAGE(POINTER_PAGEBASE(lisp_ptr)) + +#define GetNewCell_68k(conspage68k) \ + (ConsCell *)(((DLword *)(conspage68k)) \ + + (unsigned)((conspage68k)->next_cell) ) + +/* page : LISP page */ +#define GetCONSCount(page) \ + (((struct conspage *)Addr68k_from_LPAGE(page))->count) + + +#ifndef BYTESWAP + /* For chaining together free cons cells on a page */ +typedef struct freec + { + unsigned next_free: 8; /* next free cell on this page */ + unsigned nil: 24; + } freecons; + +#else + +typedef struct freec + { + unsigned nil: 24; + unsigned next_free: 8; + } freecons; + +#endif /* BYTESWAP */ + + +#define FREECONS(page,offset) ((freecons *) ((DLword *)page + offset)) + + +/************************************************************************/ +/* */ +/* S Y M B O L D E F S */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifndef BYTESWAP + /************************************************/ + /* Definitions for normal byte-order machines */ + /************************************************/ + +#ifdef BIGVM +/* Definition of a new-atom, where all the cells are in one object */ +typedef + struct new_atom + { + unsigned dfccodep: 1 ; /* DEFCELL FLAGS */ + unsigned dffastp: 1 ; + unsigned dfargtype: 2 ; + unsigned pncell: 28; /* pointer to the pname itself */ + unsigned nil2: 4; /* top 4 bits of value cell */ + unsigned valcell: 28; /* pointer to the top-level value */ + unsigned nil3: 4; /* top 4 bits of definition cell */ + unsigned defcell: 28; /* pointer to function definition */ + unsigned nil4: 4; /* */ + unsigned plcell: 28; /* pointer to property list */ + unsigned pnpkg: 8; /* package */ + unsigned dfnil1: 4 ; /* DEFCELL FLAGS */ + unsigned dfpseudo: 1 ; + unsigned dfswapped: 1 ; /* T for native-order fn opcodes */ + unsigned dfnil: 2 ; + unsigned plunused: 1; /* PROPLIST FLAGS */ + unsigned plgensymp: 1; + unsigned plfatpnamep: 1; + unsigned plnil: 5; + unsigned nil5: 8; /* Fill out last byte of final cell */ + } NewAtom; + +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned ccodep : 1 ; + unsigned fastp : 1 ; + unsigned argtype : 2 ; + unsigned defpointer : 28; + LispPTR nil_PL; /* skip the proplist cell */ + unsigned nilpkg:8; /* skip pkg byte */ + unsigned nil2 : 4 ; + unsigned pseudocodep : 1 ; + unsigned byteswapped : 1 ; /* T for native-order fn opcodes */ + unsigned nil_last: 18; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned nil : 4 ; + unsigned pnamebase : 28 ; + LispPTR nil_val; + LispPTR nil_def; + LispPTR nil_plist; + unsigned pkg_index : 8 ; + unsigned nil2: 24; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned nil: 4; + unsigned propbase: 28; + unsigned nilpkg: 8; + unsigned nildef: 8; + unsigned unused: 1; + unsigned gensymp: 1; + unsigned fatpnamep: 1; + unsigned nil2: 5; + unsigned nil3: 8; + + } PLCell; + + +struct xpointer{ + unsigned flags:4; + unsigned addr:28; +}; + +#else /* not BIGVM */ + +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned ccodep : 1 ; + unsigned fastp : 1 ; + unsigned argtype : 2 ; + unsigned pseudocodep : 1 ; + unsigned byteswapped : 1 ; /* T for native-order fn opcodes */ + unsigned nil : 2 ; + unsigned defpointer : 24; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned pkg_index : 8 ; + unsigned pnamebase : 24 ; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned unused: 1; + unsigned gensymp: 1; + unsigned fatpnamep: 1; + unsigned nil: 5; + unsigned propbase: 24; + } PLCell; + + +struct xpointer{ + unsigned flags:8; + unsigned addr:24; +}; + +#endif /* BIGVM */ + +#else + /************************************************/ + /* Definitions for byte-swapped machines */ + /************************************************/ +#ifdef BIGVM +/* Definition of a new-atom, where all the cells are in one object */ +typedef + struct new_atom + { + unsigned pncell: 28; /* pointer to the pname itself */ + unsigned dfargtype: 2 ; + unsigned dffastp: 1 ; + unsigned dfccodep: 1 ; /* DEFCELL FLAGS */ + unsigned valcell: 28; /* pointer to the top-level value */ + unsigned nil2: 4; /* top 4 bits of value cell */ + unsigned defcell: 28; /* pointer to function definition */ + unsigned nil3: 4; /* top 4 bits of definition cell */ + unsigned plcell: 28; /* pointer to property list */ + unsigned nil4: 4; /* */ + unsigned nil5: 8; /* Fill out last byte of final cell */ + unsigned plnil: 5; + unsigned plfatpnamep: 1; + unsigned plgensymp: 1; + unsigned plunused: 1; /* PROPLIST FLAGS */ + unsigned dfnil: 2 ; + unsigned dfswapped: 1 ; /* T for native-order fn opcodes */ + unsigned dfpseudo: 1 ; + unsigned dfnil1: 4 ; /* DEFCELL FLAGS */ + unsigned pnpkg: 8; /* package */ + } NewAtom; + +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned defpointer : 28; + unsigned argtype : 2 ; + unsigned fastp : 1 ; + unsigned ccodep : 1 ; + LispPTR nil_PL; /* skip the proplist cell */ + unsigned nil_last: 18; + unsigned byteswapped : 1 ; /* T for native-order fn opcodes */ + unsigned pseudocodep : 1 ; + unsigned nil2 : 4 ; + unsigned nilpkg:8; /* skip pkg byte */ + + } DefCell ; + +typedef + struct pname_cell + { + unsigned pnamebase : 28 ; + unsigned nil : 4 ; + LispPTR nil_val; + LispPTR nil_def; + LispPTR nil_plist; + unsigned nil2: 24; + unsigned pkg_index : 8 ; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned propbase: 28; + unsigned nil: 4; + unsigned nil3: 8; + unsigned nil2: 5; + unsigned fatpnamep: 1; + unsigned gensymp: 1; + unsigned unused: 1; + unsigned nildef: 8; + unsigned nilpkg: 8; + + } PLCell; + + +struct xpointer{ + unsigned addr:28; + unsigned flags:4; +}; +#else /* BIGVM */ +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned defpointer : 24; + unsigned nil : 2 ; + unsigned byteswapped : 1 ; /* T if opcodes are native-order */ + unsigned pseudocodep : 1 ; + unsigned argtype : 2 ; + unsigned fastp : 1 ; + unsigned ccodep : 1 ; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned pnamebase : 24 ; + unsigned pkg_index : 8 ; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned propbase: 24; + unsigned nil: 5; + unsigned fatpnamep: 1; + unsigned gensymp: 1; + unsigned unused: 1; + } PLCell; + +struct xpointer + { + unsigned addr:24; + unsigned flags:8; + }; +#endif /* BIGVM */ + +#endif /* BYTESWAP */ + + + + +struct + cadr_cell + { + LispPTR car_cell; /* Lisp address (word addressing) */ + LispPTR cdr_cell; /* Lisp address (word addressing) */ + }; + + + +/************************************************************************/ +/* */ +/* Access to the parts of a SYMBOL: Pname, Definition, Value, */ +/* and property list. */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifndef BIGATOMS +#define GetDEFCELL68k(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELL68k(index) ((LispPTR *)Valspace + (index)) +#define GetPnameCell(index) ((LispPTR *)Pnamespace + (index)) +#define GetPropCell(index) ((LispPTR *)Plistspace + (index)) + + /* Good only for old-style LITATOMS */ +#define GetDEFCELLlitatom(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELLlitatom(index) ((LispPTR *)Valspace + (index)) +#define GetPnameCelllitatom(index) ((LispPTR *)Pnamespace + (index)) +#define GetPropCelllitatom(index) ((LispPTR *)Plistspace + (index)) + +#else + /* Good for old LITATOMS and new NEW-ATOMs */ +#define GetDEFCELL68k(index) (((index & SEGMASK) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_DEFN_OFFSET) \ + : GetDEFCELLlitatom(index) ) + +#define GetVALCELL68k(index) (((index & SEGMASK) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_VALUE_OFFSET) \ + : GetVALCELLlitatom(index)) + +#define GetPnameCell(index) (((index & SEGMASK) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PNAME_OFFSET) \ + : GetPnameCelllitatom(index)) + +#define GetPropCell(index) (((index & SEGMASK) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PLIST_OFFSET) \ + : GetPropCelllitatom(index)) + + /* Good only for old-style LITATOMS */ +#ifdef BIGVM +#define GetDEFCELLlitatom(index)\ + ((LispPTR *)AtomSpace + (5*(index))+NEWATOM_DEFN_PTROFF) +#define GetVALCELLlitatom(index) \ + ((LispPTR *)AtomSpace + (5*(index))+NEWATOM_VALUE_PTROFF) +#define GetPnameCelllitatom(index) \ + ((LispPTR *)AtomSpace + (5*(index))+NEWATOM_PNAME_PTROFF) +#define GetPropCelllitatom(index) \ + ((LispPTR *)AtomSpace + (5*(index))+NEWATOM_PLIST_PTROFF) +#else /* BIGVM not set, so use old name-space format */ +#define GetDEFCELLlitatom(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELLlitatom(index) ((LispPTR *)Valspace + (index)) +#define GetPnameCelllitatom(index) ((LispPTR *)Pnamespace + (index)) +#define GetPropCelllitatom(index) ((LispPTR *)Plistspace + (index)) +#endif + + /* Good only for new-style NEW-ATOMs */ +#define GetDEFCELLnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_DEFN_OFFSET) +#define GetVALCELLnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_VALUE_OFFSET) +#define GetPnameCellnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PNAME_OFFSET) +#define GetPropCellnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PLIST_OFFSET) + +#endif /* BIGATOMS */ + + + + +/* When cadr() function is called, type check should be done. */ + +#define S_N_CHECKANDCADR(sour, dest, tos) \ + {register LispPTR parm = sour; \ + if(GetTypeNumber(parm) != TYPE_LISTP){ \ + ERROR_EXIT(tos); \ + }else \ + dest = cadr(parm); \ + } + + diff --git a/inc/cell.h% b/inc/cell.h% new file mode 100755 index 0000000..c782062 --- /dev/null +++ b/inc/cell.h% @@ -0,0 +1,467 @@ +/* %Z% %M% Version %I% (%G%). copyright Venue */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/**********************************************************************/ +/* + File Name : cell.h + + Cell Manipulate Macros + + Date : December 16, 1986 + Edited by : Takeshi Shimizu + +*/ +/**********************************************************************/ + +/* CONS CELL (LISTP) definitions moved to lispemulater.h */ + + /* This Macro may produce the CDR code */ +#define CDRCODE(x) LRSH (((int)x & 0x0ff000000) , 24) + + /* This Macro may produce a pointer that points CAR cell */ + /* On 68010,68000 This Macro does not effect * +#define CARFIELD(x) ((int)x & 0x00ffffff) + +/* CDR-Codes defs */ +#define CDR_ONPAGE 128 +#define CDR_NIL 128 +#define CDR_INDIRECT 0 +#define CDR_MAXINDIRECT 127 + +/* short CarCdrError ; */ + + +/************************************************************************/ +/* */ +/* CONSPAGE describes the free-space management fields at the */ +/* beginning of a cons page -- # of free cells on the page, etc. */ +/* */ +/************************************************************************/ + +#ifndef BYTESWAP +#ifdef NEWCDRCODE +struct + conspage + { + unsigned count: 8; /* free cells on this page */ + unsigned next_cell: 8; /* next free cell in chain */ + unsigned nil:16; + LispPTR next_page; /* next cons page, or 0 if none */ + }; +#else +struct + conspage + { + unsigned count : 8 ; + unsigned next_cell :8 ; + DLword next_page ; + }; +#endif /* NEWCDRCODE */ +#else +/* byte-swapped version */ +#ifdef NEWCDRCODE +struct + conspage + { + unsigned nil: 16; + unsigned next_cell: 8; + unsigned count: 8; + LispPTR next_page; + }; +#else +struct + conspage + { + DLword next_page ; + unsigned next_cell :8 ; + unsigned count : 8 ; + }; +#endif /* NEWCDRCODE */ +#endif /* BYTESWAP */ + + +/* Following MACROs for Conspage */ + +/* lisp_ptr is LISP pointer, returns 68k ptr points struct conspage obj */ +#define Get_ConsPageBase(lisp_ptr) \ + (struct conspage *)Addr68k_from_LPAGE(POINTER_PAGEBASE(lisp_ptr)) + +#define GetNewCell_68k(conspage68k) \ + (ConsCell *)(((DLword *)(conspage68k)) \ + + (unsigned)((conspage68k)->next_cell) ) + +/* page : LISP page */ +#define GetCONSCount(page) \ + (((struct conspage *)Addr68k_from_LPAGE(page))->count) + + +#ifndef BYTESWAP + /* For chaining together free cons cells on a page */ +struct freecons + { + unsigned next_free: 8; /* next free cell on this page */ + unsigned nil: 24; + } + +#else + +struct freecons + { + unsigned next_free: 8; + unsigned nil: 24; + } + +#endif /* BYTESWAP */ + + +#ifndef BYTESWAP + /************************************************/ + /* Definitions for normal byte-order machines */ + /************************************************/ + +#ifdef BIGVM2 +/* Definition of a new-atom, where all the cells are in one object */ +typedef + struct new_atom + { + unsigned dfccodep: 1 ; /* DEFCELL FLAGS */ + unsigned dffastp: 1 ; + unsigned dfargtype: 2 ; + unsigned pncell: 28; /* pointer to the pname itself */ + unsigned nil2: 4; /* top 4 bits of value cell */ + unsigned valcell: 28; /* pointer to the top-level value */ + unsigned nil3: 4; /* top 4 bits of definition cell */ + unsigned defcell: 28; /* pointer to function definition */ + unsigned nil4: 4; /* */ + unsigned plcell: 28; /* pointer to property list */ + unsigned pnpkg: 8; /* package */ + unsigned dfnil1: 4 ; /* DEFCELL FLAGS */ + unsigned dfpseudo: 1 ; + unsigned dfswapped: 1 ; /* T for native-order fn opcodes */ + unsigned dfnil: 2 ; + unsigned plunused: 1; /* PROPLIST FLAGS */ + unsigned plgensymp: 1; + unsigned plfatpnamep: 1; + unsigned plnil: 5; + unsigned nil5: 8; /* Fill out last byte of final cell */ + } NewAtom; + +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned ccodep : 1 ; + unsigned fastp : 1 ; + unsigned argtype : 2 ; + unsigned defpointer : 28; + LispPTR nil_PL; /* skip the proplist cell */ + unsigned nilpkg:8; /* skip pkg byte */ + unsigned nil2 : 4 ; + unsigned pseudocodep : 1 ; + unsigned byteswapped : 1 ; /* T for native-order fn opcodes */ + unsigned nil_last: 18; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned nil : 4 ; + unsigned pnamebase : 28 ; + LispPTR nil_val; + LispPTR nil_def; + LispPTR nil_plist; + unsigned pkg_index : 8 ; + unsigned nil2: 24; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned nil: 4; + unsigned propbase: 28; + unsigned nilpkg: 8; + unsigned nildef: 8; + unsigned unused: 1; + unsigned gensymp: 1; + unsigned fatpnamep: 1; + unsigned nil2: 5; + unsigned nil3: 8; + + } PLCell; + + +struct xpointer{ + unsigned flags:4; + unsigned addr:28; +}; + +#elif BIGVM +/* Definition of a new-atom, where all the cells are in one object */ +typedef + struct new_atom + { + unsigned dfccodep: 1 ; /* DEFCELL FLAGS */ + unsigned dffastp: 1 ; + unsigned dfargtype: 2 ; + unsigned nil1:4; + unsigned pncell: 24; /* pointer to the pname itself */ + unsigned nil2: 8; /* top 4 bits of value cell */ + unsigned valcell: 24; /* pointer to the top-level value */ + unsigned nil3: 8; /* top 4 bits of definition cell */ + unsigned defcell: 24; /* pointer to function definition */ + unsigned nil4: 8; /* */ + unsigned plcell: 24; /* pointer to property list */ + unsigned pnpkg: 8; /* package */ + unsigned dfnil1: 4 ; /* DEFCELL FLAGS */ + unsigned dfpseudo: 1 ; + unsigned dfswapped: 1 ; /* T for native-order fn opcodes */ + unsigned dfnil: 2 ; + unsigned plunused: 1; /* PROPLIST FLAGS */ + unsigned plgensymp: 1; + unsigned plfatpnamep: 1; + unsigned plnil: 5; + unsigned nil5: 8; /* Fill out last byte of final cell */ + } NewAtom; + +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned ccodep : 1 ; + unsigned fastp : 1 ; + unsigned argtype : 2 ; + unsigned nil1:4; + unsigned defpointer : 24; + LispPTR nil_PL; /* skip the proplist cell */ + unsigned nilpkg:8; /* skip pkg byte */ + unsigned nil2 : 4 ; + unsigned pseudocodep : 1 ; + unsigned byteswapped : 1 ; /* T for native-order fn opcodes */ + unsigned nil_last: 18; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned nil : 8 ; + unsigned pnamebase : 24 ; + LispPTR nil_val; + LispPTR nil_def; + LispPTR nil_plist; + unsigned pkg_index : 8 ; + unsigned nil2: 24; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned nil: 8; + unsigned propbase: 24; + unsigned nilpkg: 8; + unsigned nildef: 8; + unsigned unused: 1; + unsigned gensymp: 1; + unsigned fatpnamep: 1; + unsigned nil2: 5; + unsigned nil3: 8; + + } PLCell; + + +struct xpointer{ + unsigned flags:8; + unsigned addr:24; +}; + +#else /* not BIGVM */ + +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned ccodep : 1 ; + unsigned fastp : 1 ; + unsigned argtype : 2 ; + unsigned pseudocodep : 1 ; + unsigned byteswapped : 1 ; /* T for native-order fn opcodes */ + unsigned nil : 2 ; + unsigned defpointer : 24; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned pkg_index : 8 ; + unsigned pnamebase : 24 ; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned unused: 1; + unsigned gensymp: 1; + unsigned fatpnamep: 1; + unsigned nil: 5; + unsigned propbase: 24; + } PLCell; + + +struct xpointer{ + unsigned flags:8; + unsigned addr:24; +}; + +#endif /* BIGVM */ + +#else + /************************************************/ + /* Definitions for byte-swapped machines */ + /************************************************/ +/* DEFs for DEFINITIONCELL */ +typedef + struct definition_cell + { + unsigned defpointer : 24; + unsigned nil : 2 ; + unsigned byteswapped : 1 ; /* T if opcodes are native-order */ + unsigned pseudocodep : 1 ; + unsigned argtype : 2 ; + unsigned fastp : 1 ; + unsigned ccodep : 1 ; + + } DefCell ; + +typedef + struct pname_cell + { + unsigned pnamebase : 24 ; + unsigned pkg_index : 8 ; + } PNCell ; + +typedef + struct proplist_cell + { + unsigned propbase: 24; + unsigned nil: 5; + unsigned fatpnamep: 1; + unsigned gensymp: 1; + unsigned unused: 1; + } PLCell; + +struct xpointer + { + unsigned addr:24; + unsigned flags:8; + }; + + +#endif /* BYTESWAP */ + + + + +struct + cadr_cell + { + LispPTR car_cell; /* Lisp address (word addressing) */ + LispPTR cdr_cell; /* Lisp address (word addressing) */ + }; + + + +/************************************************************************/ +/* */ +/* Access to the parts of a SYMBOL: Pname, Definition, Value, */ +/* and property list. */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifndef BIGATOMS +#define GetDEFCELL68k(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELL68k(index) ((LispPTR *)Valspace + (index)) +#define GetPnameCell(index) ((LispPTR *)Pnamespace + (index)) +#define GetPropCell(index) ((LispPTR *)Plistspace + (index)) + + /* Good only for old-style LITATOMS */ +#define GetDEFCELLlitatom(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELLlitatom(index) ((LispPTR *)Valspace + (index)) +#define GetPnameCelllitatom(index) ((LispPTR *)Pnamespace + (index)) +#define GetPropCelllitatom(index) ((LispPTR *)Plistspace + (index)) + +#else + /* Good for old LITATOMS and new NEW-ATOMs */ +#define GetDEFCELL68k(index) (((index & 0xFF0000) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_DEFN_OFFSET) \ + : GetDEFCELLlitatom(index) ) + +#define GetVALCELL68k(index) (((index & 0xFF0000) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_VALUE_OFFSET) \ + : GetVALCELLlitatom(index)) + +#define GetPnameCell(index) (((index & 0xFF0000) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PNAME_OFFSET) \ + : GetPnameCelllitatom(index)) + +#define GetPropCell(index) (((index & 0xFF0000) != 0) ? \ + (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PLIST_OFFSET) \ + : GetPropCelllitatom(index)) + + /* Good only for old-style LITATOMS */ +#ifdef BIGVM +#define GetDEFCELLlitatom(index)\ + ((LispPTR *)Pnamespace + (5*(index))+NEWATOM_DEFN_PTROFF) +#define GetVALCELLlitatom(index) \ + ((LispPTR *)Pnamespace + (5*(index))+NEWATOM_VALUE_PTROFF) +#define GetPnameCelllitatom(index) \ + ((LispPTR *)Pnamespace + (5*(index))+NEWATOM_PNAME_PTROFF) +#define GetPropCelllitatom(index) \ + ((LispPTR *)Pnamespace + (5*(index))+NEWATOM_PLIST_PTROFF) +#else /* BIGVM not set, so use old name-space format */ +#define GetDEFCELLlitatom(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELLlitatom(index) ((LispPTR *)Valspace + (index)) +#define GetPnameCelllitatom(index) ((LispPTR *)Pnamespace + (index)) +#define GetPropCelllitatom(index) ((LispPTR *)Plistspace + (index)) +#endif + + /* Good only for new-style NEW-ATOMs */ +#define GetDEFCELLnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_DEFN_OFFSET) +#define GetVALCELLnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_VALUE_OFFSET) +#define GetPnameCellnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PNAME_OFFSET) +#define GetPropCellnew(index) (LispPTR *)(Addr68k_from_LADDR(index)+NEWATOM_PLIST_OFFSET) + +#endif /* BIGATOMS */ + + + + +/* When cadr() function is called, type check should be done. */ + +#define S_N_CHECKANDCADR(sour, dest, tos) \ + {register LispPTR parm = sour; \ + if(GetTypeNumber(parm) != TYPE_LISTP){ \ + ERROR_EXIT(tos); \ + }else \ + dest = cadr(parm); \ + } + + diff --git a/inc/copyright b/inc/copyright new file mode 100755 index 0000000..919c9f6 --- /dev/null +++ b/inc/copyright @@ -0,0 +1,13 @@ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ diff --git a/inc/cr b/inc/cr new file mode 100755 index 0000000..6b485b6 --- /dev/null +++ b/inc/cr @@ -0,0 +1,13 @@ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1999 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ diff --git a/inc/dbprint.h b/inc/dbprint.h new file mode 100755 index 0000000..dcb2bf7 --- /dev/null +++ b/inc/dbprint.h @@ -0,0 +1,94 @@ +/* $Id: dbprint.h,v 1.2 1999/01/03 02:05:55 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include + +/* ================================================================ */ +/* Debugprint usage: DBPRINT( paren'ed arglist ) + + e.g. DBPRINT ( ("value of foo is %d\n", foo) ); + + the double parens are needed because of cpp's limited macro + capability (can only handle variable number of args if they + are paren'ed. The motivation for this macro is, its easier to + read: + DBPRINT ( ("value of foo is %d\n", foo) ); + than: + #ifdef DEBUG + printf("value of foo is %d\n", foo); + #endif + + e.g. TRACER(expr); + + executes the expression if TRACE is on. +/* ================================================================ */ + + /* For debugging print statements */ + +#ifdef DEBUG +#define DBPRINT(X) printf X; fflush(stdout) +#define DEBUGGER(X) X; +#else +#define DBPRINT(X) +#define DEBUGGER(X) +#endif + + + /* For trace print statements */ + +#ifdef TRACE +#define TPRINT(X) printf X; fflush(stdout); +#define TRACER(X) X; +#else /* TRACE */ + +#define TPRINT(X) +#define TRACER(X) +#endif /* TRACE */ + + + + /* For tracing individual opcode executions */ + +#ifdef OPTRACE +#define OPTPRINT(X) printf X; fflush(stdout); +#define OPTRACER(X) X; +#else +#define OPTPRINT(X) +#define OPTRACER(X) +#endif + + + /* For tracing function calls */ + +#ifdef FNTRACE +#define FNTPRINT(X) printf X; fflush(stdout); +#define FNTRACER(X) X; +#else +#define FNTPRINT(X) +#define FNTRACER(X) +#endif + + + /* For function-call & return stack checking */ + +#ifdef FNSTKCHECK +#define FNCHKPRINT(X) printf X; fflush(stdout); +#define FNCHECKER(X) X; +#else +#define FNCHKPRINT(X) +#define FNCHECKER(X) +#endif + diff --git a/inc/debug.h b/inc/debug.h new file mode 100755 index 0000000..51fe887 --- /dev/null +++ b/inc/debug.h @@ -0,0 +1,443 @@ +/* $Id: debug.h,v 1.2 1999/01/03 02:05:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + /************************************************/ + /* Normal byte-order version of definitions */ + /************************************************/ + +typedef struct{ + DLword W0; + DLword W1; + DLword W2; + DLword W3; + DLword WU; + DLword W4; + DLword W5; + int TIME; + unsigned MOUSESTATE : 3; + unsigned SHIFT1 : 1; + unsigned SHIFT2 : 1; + unsigned keLOCK : 1; + unsigned keCTRL : 1; + unsigned keMETA : 1; + unsigned keFONT : 1; + unsigned USERMODE1 : 1; + unsigned USERMODE2 : 1; + unsigned USERMODE3 : 1; + unsigned NIL1 : 4; + DLword MOUSEX; + DLword MOUSEY; +} KEYBOARDEVENT; + +typedef struct{ + DLword READ; + DLword WRITE; +} RING; + +typedef struct{ + LispPTR FLAGS; + LispPTR CODES; + LispPTR SHIFTCODES; + LispPTR ARMED; + LispPTR INTERRUPTLIST; +} KEYACTION; + +typedef struct{ + unsigned int EVENTWAKEUPPENDING : 1; + unsigned int nil1 : 7; + unsigned int EVENTQUEUETAIL : 24; + LispPTR EVENTNAME; +} EVENT; + +typedef struct{ + unsigned int nil1 : 1; + unsigned int MLOCKPERPROCESS : 1; + unsigned int nil2 : 6; + unsigned int MLOCKQUEUETAIL : 24; + LispPTR MLOCKOWNER; + LispPTR MLOCKNAME; + LispPTR MLOCKLINK; +} MONITORLOCK; + +typedef struct{ + DLword PROCFX0; + DLword PROCFX; + unsigned int PROCSTATUS : 8; + unsigned int PROCNAME : 24; + unsigned int PROCPRIORITY : 8; + unsigned int PROCQUEUE : 24; + unsigned int nil1 : 8; + unsigned int NEXTPROCHANDLE : 24; + unsigned int PROCTIMERSET : 1; + unsigned int PROCBEINGDELETED : 1; + unsigned int PROCDELETED : 1; + unsigned int PROCSYSTEMP : 1; + unsigned int PROCNEVERSTARTED : 1; + unsigned int nil2 : 3; + unsigned int PROCWAKEUPTIMER : 24; + LispPTR PROCTIMERLINK; + LispPTR PROCTIMERBOX; + LispPTR WAKEREASON; + LispPTR PROCEVENTORLOCK; + LispPTR PROCFORM; + LispPTR RESTARTABLE; + LispPTR PROCWINDOW; + LispPTR PROCFINISHED; + LispPTR PROCRESULT; + LispPTR PROCFINISHEVENT; + LispPTR PROCMAILBOX; + LispPTR PROCDRIBBLEOUTPUT; + LispPTR PROCINFOHOOK; + LispPTR PROCTYPEAHEAD; + LispPTR PROCREMOTEINFO; + LispPTR PROCUSERDATA; + LispPTR PROCEVENTLINK; + LispPTR PROCAFTEREXIT; + LispPTR PROCBEFOREEXIT; + LispPTR PROCOWNEDLOCKS; + LispPTR PROCEVAPPLYRESULT; + LispPTR PROCTTYENTRYFN; + LispPTR PROCEXITFN; + LispPTR PROCHARDRESETINFO; + LispPTR PROCRESTARTFORM; + LispPTR PROCOLDTTYPROC; + LispPTR nil3; +} PROCESS; + +typedef struct{ + unsigned int PQPRIORITY : 8; + unsigned int PQHIGHER : 24; + LispPTR PQLOWER; + LispPTR PQNEXT; + LispPTR PQLAST; +} PROCESSQUEUE; + +typedef struct fdev{ + unsigned RESETABLE : 1; + unsigned RANDOMACCESSP : 1; + unsigned NODIRECTORIES : 1; + unsigned PAGEMAPPED : 1; + unsigned FDBINABLE : 1; + unsigned FDBOUTABLE : 1; + unsigned FDEXTENDABLE : 1; + unsigned BUFFERED : 1; + unsigned DEVICENAME : 24; + unsigned REMOTEP : 1; + unsigned SUBDIRECTORIES : 1; + unsigned INPUT_INDIRECTED : 1; + unsigned OUTPUT_INDIRECTED : 1; + unsigned NIL1 : 4; + unsigned DEVICEINFO : 24; + LispPTR OPENFILELST ; + LispPTR HOSTNAMEP ; + LispPTR EVENTFN ; + LispPTR DIRECTORYNAMEP ; + LispPTR OPENFILE ; + LispPTR CLOSEFILE ; + LispPTR REOPENFILE ; + LispPTR GETFILENAME ; + LispPTR DELETEFILE ; + LispPTR GENERATEFILES ; + LispPTR RENAMEFILE ; + LispPTR OPENP ; + LispPTR REGISTERFILE ; + LispPTR UNREGISTERFILE ; + LispPTR FREEPAGECOUNT ; + LispPTR MAKEDIRECTORY ; + LispPTR CHECKFILENAME ; + LispPTR HOSTALIVEP ; + LispPTR BREAKCONNECTION ; + LispPTR BIN ; + LispPTR BOUT ; + LispPTR PEEKBIN ; + LispPTR READCHAR ; + LispPTR WRITECHAR ; + LispPTR PEEKCHAR ; + LispPTR UNREADCHAR ; + LispPTR READP ; + LispPTR EOFP ; + LispPTR BLOCKIN ; + LispPTR BLOCKOUT ; + LispPTR FORCEOUTPUT ; + LispPTR GETFILEINFO ; + LispPTR SETFILEINFO ; + LispPTR CHARSETFN ; + LispPTR INPUTSTREAM ; + LispPTR OUTPUTSTREAM ; + LispPTR GETFILEPTR ; + LispPTR GETEOFPTR ; + LispPTR SETFILEPTR ; + LispPTR BACKFILEPTR ; + LispPTR SETEOFPTR ; + LispPTR LASTC ; + LispPTR GETNEXTBUFFER ; + LispPTR RELEASEBUFFER ; + LispPTR READPAGES ; + LispPTR WRITEPAGES ; + LispPTR TRUNCATEFILE ; + LispPTR WINDOWOPS ; + LispPTR WINDOWDATA ; +}FDEV; +typedef struct package{ + LispPTR INDEX ; + LispPTR TABLES ; + LispPTR NAME ; + LispPTR NAMESYMBOL ; + LispPTR NICKNAMES ; + LispPTR USE_LIST ; + LispPTR USED_BY_LIST ; + LispPTR EXTERNAL_ONLY ; + LispPTR INTERNAL_SYMBOLS ; + LispPTR EXTERNAL_SYMBOLS ; + LispPTR SHADOWING_SYMBOLS ; +} PACKAGE; + +#ifdef NEVER +typedef struct { + unsigned nil1 : 8 ; + unsigned BASE : 24 ; + unsigned READ_ONLY_P : 1 ; + unsigned nil2 : 1 ; + unsigned BIT_P : 1 ; + unsigned STRING_P : 1 ; + unsigned nil3 : 1 ; + unsigned DISPLACED_P : 1 ; + unsigned FILL_POINTER_P : 1 ; + unsigned EXTENDABLE_P : 1 ; + unsigned TYPE_NUMBER : 8 ; + DLword OFFSET; + DLword FILL_POINTER; + DLword TOTAL_SIZE; +} ONED_ARRAY; +#endif /* NEVER */ +#else + + /****************************************************************/ + /* Byte-swapped, word-swapped definitions, for e.g. 80386's */ + /****************************************************************/ + +typedef struct{ + DLword W1; + DLword W0; + DLword W3; + DLword W2; + DLword W4; + DLword WU; + /* only swapped down to here, and MOUSEX & Y -- there */ + /* looks like a missing word in the block at this point. */ + DLword W5; + int TIME; + unsigned MOUSESTATE : 3; + unsigned SHIFT1 : 1; + unsigned SHIFT2 : 1; + unsigned LOCK : 1; + unsigned CTRL : 1; + unsigned META : 1; + unsigned FONT : 1; + unsigned USERMODE1 : 1; + unsigned USERMODE2 : 1; + unsigned USERMODE3 : 1; + unsigned NIL1 : 4; + DLword MOUSEY; + DLword MOUSEX; +} KEYBOARDEVENT; + +typedef struct{ + DLword WRITE; + DLword READ; +} RING; + +typedef struct{ + LispPTR FLAGS; + LispPTR CODES; + LispPTR SHIFTCODES; + LispPTR ARMED; + LispPTR INTERRUPTLIST; +} KEYACTION; + +typedef struct{ + unsigned int EVENTQUEUETAIL : 24; + unsigned int nil1 : 7; + unsigned int EVENTWAKEUPPENDING : 1; + LispPTR EVENTNAME; +} EVENT; + +typedef struct{ + unsigned int MLOCKQUEUETAIL : 24; + unsigned int nil2 : 6; + unsigned int MLOCKPERPROCESS : 1; + unsigned int nil1 : 1; + LispPTR MLOCKOWNER; + LispPTR MLOCKNAME; + LispPTR MLOCKLINK; +} MONITORLOCK; + +typedef struct{ + DLword PROCFX; + DLword PROCFX0; + unsigned int PROCNAME : 24; + unsigned int PROCSTATUS : 8; + unsigned int PROCQUEUE : 24; + unsigned int PROCPRIORITY : 8; + unsigned int NEXTPROCHANDLE : 24; + unsigned int nil1 : 8; + unsigned int PROCWAKEUPTIMER : 24; + unsigned int nil2 : 3; + unsigned int PROCNEVERSTARTED : 1; + unsigned int PROCSYSTEMP : 1; + unsigned int PROCDELETED : 1; + unsigned int PROCBEINGDELETED : 1; + unsigned int PROCTIMERSET : 1; + LispPTR PROCTIMERLINK; + LispPTR PROCTIMERBOX; + LispPTR WAKEREASON; + LispPTR PROCEVENTORLOCK; + LispPTR PROCFORM; + LispPTR RESTARTABLE; + LispPTR PROCWINDOW; + LispPTR PROCFINISHED; + LispPTR PROCRESULT; + LispPTR PROCFINISHEVENT; + LispPTR PROCMAILBOX; + LispPTR PROCDRIBBLEOUTPUT; + LispPTR PROCINFOHOOK; + LispPTR PROCTYPEAHEAD; + LispPTR PROCREMOTEINFO; + LispPTR PROCUSERDATA; + LispPTR PROCEVENTLINK; + LispPTR PROCAFTEREXIT; + LispPTR PROCBEFOREEXIT; + LispPTR PROCOWNEDLOCKS; + LispPTR PROCEVAPPLYRESULT; + LispPTR PROCTTYENTRYFN; + LispPTR PROCEXITFN; + LispPTR PROCHARDRESETINFO; + LispPTR PROCRESTARTFORM; + LispPTR PROCOLDTTYPROC; + LispPTR nil3; +} PROCESS; + +typedef struct{ + unsigned int PQHIGHER : 24; + unsigned int PQPRIORITY : 8; + LispPTR PQLOWER; + LispPTR PQNEXT; + LispPTR PQLAST; +} PROCESSQUEUE; + +typedef struct fdev{ + unsigned DEVICENAME : 24; + unsigned BUFFERED : 1; + unsigned FDEXTENDABLE : 1; + unsigned FDBOUTABLE : 1; + unsigned FDBINABLE : 1; + unsigned PAGEMAPPED : 1; + unsigned NODIRECTORIES : 1; + unsigned RANDOMACCESSP : 1; + unsigned RESETABLE : 1; + unsigned DEVICEINFO : 24; + unsigned NIL1 : 4; + unsigned OUTPUT_INDIRECTED : 1; + unsigned INPUT_INDIRECTED : 1; + unsigned SUBDIRECTORIES : 1; + unsigned REMOTEP : 1; + LispPTR OPENFILELST ; + LispPTR HOSTNAMEP ; + LispPTR EVENTFN ; + LispPTR DIRECTORYNAMEP ; + LispPTR OPENFILE ; + LispPTR CLOSEFILE ; + LispPTR REOPENFILE ; + LispPTR GETFILENAME ; + LispPTR DELETEFILE ; + LispPTR GENERATEFILES ; + LispPTR RENAMEFILE ; + LispPTR OPENP ; + LispPTR REGISTERFILE ; + LispPTR UNREGISTERFILE ; + LispPTR FREEPAGECOUNT ; + LispPTR MAKEDIRECTORY ; + LispPTR CHECKFILENAME ; + LispPTR HOSTALIVEP ; + LispPTR BREAKCONNECTION ; + LispPTR BIN ; + LispPTR BOUT ; + LispPTR PEEKBIN ; + LispPTR READCHAR ; + LispPTR WRITECHAR ; + LispPTR PEEKCHAR ; + LispPTR UNREADCHAR ; + LispPTR READP ; + LispPTR EOFP ; + LispPTR BLOCKIN ; + LispPTR BLOCKOUT ; + LispPTR FORCEOUTPUT ; + LispPTR GETFILEINFO ; + LispPTR SETFILEINFO ; + LispPTR CHARSETFN ; + LispPTR INPUTSTREAM ; + LispPTR OUTPUTSTREAM ; + LispPTR GETFILEPTR ; + LispPTR GETEOFPTR ; + LispPTR SETFILEPTR ; + LispPTR BACKFILEPTR ; + LispPTR SETEOFPTR ; + LispPTR LASTC ; + LispPTR GETNEXTBUFFER ; + LispPTR RELEASEBUFFER ; + LispPTR READPAGES ; + LispPTR WRITEPAGES ; + LispPTR TRUNCATEFILE ; + LispPTR WINDOWOPS ; + LispPTR WINDOWDATA ; +}FDEV; +typedef struct package{ + LispPTR INDEX ; + LispPTR TABLES ; + LispPTR NAME ; + LispPTR NAMESYMBOL ; + LispPTR NICKNAMES ; + LispPTR USE_LIST ; + LispPTR USED_BY_LIST ; + LispPTR EXTERNAL_ONLY ; + LispPTR INTERNAL_SYMBOLS ; + LispPTR EXTERNAL_SYMBOLS ; + LispPTR SHADOWING_SYMBOLS ; +} PACKAGE; +#ifdef NEVER +typedef struct { + unsigned BASE : 24 ; + unsigned nil1 : 8 ; + DLword OFFSET; + unsigned TYPE_NUMBER : 8 ; + unsigned EXTENDABLE_P : 1 ; + unsigned FILL_POINTER_P : 1 ; + unsigned DISPLACED_P : 1 ; + unsigned nil3 : 1 ; + unsigned STRING_P : 1 ; + unsigned BIT_P : 1 ; + unsigned nil2 : 1 ; + unsigned READ_ONLY_P : 1 ; + DLword TOTAL_SIZE; + DLword FILL_POINTER; +} ONED_ARRAY; +#endif /* NEVER */ + +#endif /* BYTESWAP */ + diff --git a/inc/devconf.h b/inc/devconf.h new file mode 100755 index 0000000..917c01a --- /dev/null +++ b/inc/devconf.h @@ -0,0 +1,51 @@ +/* $Id: devconf.h,v 1.2 1999/01/03 02:05:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/**********************************************************/ +/* + devconf.h + + Device Configurations assignments + for IFPAGE->devconfig + + LSB(0)~3 -> KBD + 4~7 -> DISPLAY, + 8~10 -> CPU + + [CPU] [DSP] [KB] + !!!!!! !!! !!!! !!! LSB> + + By Takeshi +*/ +/**********************************************************/ + + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + + +/* MAIKO(sun3,sun4)*/ +/* KBD */ +#define SUN_KEYTYPE_MASK 7 +#define SUN_TYPE3_KBD 0x0 +#define SUN_TYPE4_KBD 0x1 + +/* DISPALY */ +#define SUN_DISPTYPE_MASK 0x78 +#define SUN2BW (2<<3) +#define SUN2COLOR (3<<3) +#define SUN4COLOR (8<<3) +#define SUNMEMCOLOR (7<<3) + +/* CPUTYPE NOT IMPLEMENTED */ + +/* useful macros */ +#define SUN_GETKEYTYPE (InterfacePage->devconfig & SUN_KEYTYPE_MASK) +#define SUN_GETDISPTYPE (InterfacePage->devconfig & SUN_DISPTYPE_MASK) diff --git a/inc/devif.h b/inc/devif.h new file mode 100755 index 0000000..9ab4549 --- /dev/null +++ b/inc/devif.h @@ -0,0 +1,309 @@ +/* $Id: devif.h,v 1.2 1999/01/03 02:05:57 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#ifndef __DEVIF__ +#define __DEVIF__ 1 + + +typedef void (*PFV)(); /* Pointer to Function returning Void */ +typedef int (*PFI)(); /* Pointer to Function returning Int */ +typedef char (*PFC)(); /* Pointer to Function returning Char */ +typedef float (*PFF)(); /* Pointer to Function returning Float */ +typedef int (*PFP)(); /* Pointer to Function returning a Pointer */ +typedef unsigned long (*PFUL)(); /* Pointer to Function returning an unsigned long */ + +#ifdef XWINDOW +#include +#endif /* XWINDOW */ + + +typedef struct + { + short type; /* Type of event */ + short next; /* Index to next event */ + } IRQEvent; + + + +/**************************************************************/ +/* P o s i t i o n */ +/* */ +/* Support structure for the geometry calculations. */ +/**************************************************************/ +typedef struct + { + int x; + int y; + } Mposition; + + + +/**************************************************************/ +/* R e g i o n */ +/* */ +/* Support structure for the geometry calculations. */ +/**************************************************************/ +typedef struct + { + int x; + int y; + int width; + int height; + } MRegion; + + + +/**************************************************************/ +/* D e v R e c */ +/* */ +/* Definition common to all devices. Used for mouse, kbd and */ +/* display. */ +/**************************************************************/ +typedef struct + { + int active; /* ACTIVE, a flag. + TRUE if this device is activated. Use this + to prevent multiple consecutive initializations. */ + int locked; /* LOCK, a semaphore: 0 if dev is free. + Test and increment to use this device. */ + void (* enter)(); /* ENTER, a function + args: self + Called to set up the device. Has to be called before + anything else is done to the device. */ + void (* exit)(); /* EXIT, a function + args: self + Called to deactivate the device and restore the + device to its previous state */ + void (* before_raid)(); /* BEFORE_RAID, a function. + args: self + Prepare this device for uraid. */ + void (* after_raid)(); /* BEFORE_RAID, a function. + args: self + Cleanup and restart device after uraid. */ + void (* sync_device)(); /* SYNC_DEVICE, a function. + args: self + Make reality and emualtor coinside with eachother */ + } DevRec; + + + +/**************************************************************/ +/* M o u s e I n t e r f a c e */ +/* */ +/* Definition of the mouse. Note that the mouse is also */ +/* dependent on the IOPage68K */ +/**************************************************************/ +typedef struct + { + unsigned TwoButtonP: 1; + /* Interface towards Lisp */ + unsigned Left: 1; /* Left button state. */ + unsigned Middle: 1; /* Middle button state. */ + unsigned Right: 1; /* Right button state. */ + /* Mouse chording machinery */ + unsigned StateLeft: 1; + unsigned StateMiddle: 1; /* real middle state */ + unsigned StateRight: 1; + unsigned FakeMiddle: 1; + unsigned nil: 8; + short tick; /* Clock for timeout. */ + long StartTime; /* The maximum timeout */ + long RunTimer; /* Chording timer activate flag. */ + PFV NextHandler; /* Pointer to the next timer (used with 2button) */ + } Button; + + +typedef struct { + MRegion Last; /* Last position the mouse was in. */ + Mposition New; /* The place to move the mouse when we have time */ + Mposition Hotspot; /* The current hotspot for the mousecursor */ + long Moved; /* Did the mouse move? */ + DLword Savebitmap[16]; /* The bitmap under the mouse. Taking down the + mouse involves blitting this bitmap to the screen. + When bringing the mouse back up to the screen you + first have to save the contents of the screen under + the mouse here.*/ + } MCursor; + +typedef struct + { + DevRec device; + void (* Handler)(); /* Event handler for the mouse. */ + MCursor Cursor; + Button Button; + LispPTR *timestamp; + unsigned int keyeventsize; /* The sizeof() one kbd event */ + unsigned int maxkeyevent; /* Offset to the end of the ringbuffer. */ + int eurokbd; /* Keep tabs of the euro-ness of the kbd */ + } MouseInterfaceRec, *MouseInterface; + + + +/**************************************************************/ +/* K b d I n t e r f a c e */ +/* */ +/* Definition of the keyboard. Note that the keyboard is also */ +/* dependent on the IOPage68K */ +/**************************************************************/ +typedef struct + { + DevRec device; + PFV device_event; /* Event handler for the keyboard. */ +#ifdef DOS + u_char KeyMap[0x80]; /* The key translation table. Use the keycode you + get from the keyboard as an index. The value + gives the lispkeycode.*/ + unsigned char lastbyte; /* Last byte that we got from the keyboard. */ + unsigned int keyeventsize; /* The sizeof() one kbd event */ + unsigned int maxkeyevent; /* Offset to the end of the ringbuffer. */ + int eurokbd; /* Keep tabs of the euro-ness of the kbd */ + PFV prev_handler; /* The previous keyboard handler. + Keep this around + to restore when we exit Medley */ + int URaid; /* Put this in a better place later.. /jarl */ +#endif /* DOS */ + } KbdInterfaceRec, *KbdInterface; + + + +/**************************************************************/ +/* D s p I n t e r f a c e */ +/* */ +/* Definition of the display. This structure collects all the */ +/* special knowlege needed to manipulate the screen. */ +/**************************************************************/ +typedef struct + { + DevRec device; + + void (* drawline)(); /* DRAWLINE + args: dont know yet. Not yet implemented.*/ + void (* cleardisplay)(); /* CLEARDISPLAY, a function + args: self + clears the screen.*/ + + unsigned long (* get_color_map_entry)(); + unsigned long (* set_color_map_entry)(); + unsigned long (* available_colors)(); /* How many colors do I have on my palette */ + unsigned long (* possible_colors)(); /* How many colors is it possible to select from */ + +#ifdef NOTYET + unsigned long (* get_color_map)(); /* get a pointer to a colormap */ + unsigned long (* set_color_map)(); /* set the current colormap */ + unsigned long (* make_color_map)(); /* return a brand new colormap */ +#endif /* NOTYET */ + + unsigned long (* medley_to_native_bm)(); /* 1 bit/pix to native bit/pix */ + unsigned long (* native_to_medley_bm)(); /* native bit/pix to 1 bit/pix */ + + unsigned long (* bitblt_to_screen)(); /* BITBLT_TO_SCREEN, a function + args: self, buffer left top width height. + biblt's buffer to the screen. */ + unsigned long (* bitblt_from_screen)(); + unsigned long (* scroll_region)(); /* ie. bbt from screen to screen */ + + void (* mouse_invissible)(); /* MOUSE_INVISSIBLE + args: self (a dsp), iop (an IOPAGE preferably the one and only) + This method makes the mouse invissible on the screen. Note that + the dsp supplys the method and the iop supplys the data. */ + void (* mouse_vissible)(); /* MOUSE_VISSIBLE + args: self (a dsp), iop (an IOPAGE preferably the one and only) + This method makes the mouse vissible on the screen. Note that + the dsp supplys the method and the iop supplys the data. */ + MRegion Display; /* Dimensions of the physical display. */ + unsigned short bitsperpixel; + unsigned long colors; /* cash for the available_colors */ + unsigned long oldstate; /* Keep the old state around */ + unsigned long graphicsmode; /* Magic cookie used to set the state. */ + unsigned long numberofbanks; +#ifdef DOS + unsigned long BytesPerLine; + unsigned long DisplayStartAddr; + unsigned long DisplaySegSize; + unsigned long DisplaySegMagnitude; + unsigned long LinesPerBank; + unsigned short LastLineLen[32]; /* length of last line fragment per bank */ + unsigned short LinesInBank[32]; /* True # of full lines in this bank */ + /* # of lines we can do with the full-line dumpline */ + /* for sure. */ + unsigned short LinesBeforeBank[32]; /* Scan lines before start of this bank. */ + + void (* SwitchBank)(); /* Method to switch the bank (see vesa standard) */ +#elif XWINDOW + char *identifier; + int BitGravity; + Display *display_id; + Window LispWindow; + Window DisplayWindow; + Window HorScrollBar; + Window VerScrollBar; + Window HorScrollButton; + Window VerScrollButton; + Window NEGrav; + Window SEGrav; + Window SWGrav; + Window NWGrav; + GC Copy_GC; + MRegion Vissible; + unsigned int InternalBorderWidth; + unsigned int ScrollBarWidth; + Pixmap ScrollBarPixmap; + Pixmap GravityOnPixmap; + Pixmap GravityOffPixmap; + XImage ScreenBitmap; + Mask DisableEventMask; + Mask EnableEventMask; +#endif /* XWINDOW */ + } DspInterfaceRec, *DspInterface; + + + +#ifdef XWINDOW +#define DefineCursor(display, window, mycursor) { \ + XLOCK;\ + XDefineCursor( display, window, *(mycursor) );\ + XUNLOCK;\ +} +#endif /* XWINDOW */ + +#define OUTER_SB_WIDTH(dsp) (dsp->ScrollBarWidth + 2*(dsp->InternalBorderWidth)) + +#ifndef min +#define min( a, b ) (((a)<(b))?(a):(b)) +#endif /* min */ + +#ifndef max +#define max( a, b ) (((a)>(b))?(a):(b)) +#endif /* max */ + +#ifndef mid +#define mid(a, b, c) max( min( b, max( a, c ), min( a, max( b, c )))) +#endif /* mid */ + +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ + +#ifndef TRUE +#define TRUE !FALSE +#endif /* TRUE */ + +#define MINKEYEVENT 2 /* leave 2 words for read,write offsets */ +#define NUMBEROFKEYEVENTS 383 + +#endif /* __DEVIF__ */ + diff --git a/inc/display.h b/inc/display.h new file mode 100755 index 0000000..aa419ef --- /dev/null +++ b/inc/display.h @@ -0,0 +1,81 @@ +/* $Id: display.h,v 1.2 1999/01/03 02:05:57 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#define BCPLDISPLAY stdout + + +#define CURSORWIDTH 16 +#define CURSORHEIGHT 16 + +/* Max address for HI-RES DISPLAY */ +/* Osamu '90/02/08 + * Change into variable for efficiency +#define DISP_MAX_Address (DisplayRegion68k + 1600*1280/8) + */ +extern DLword *DISP_MAX_Address; + + /* Is the bitmap in the display region? */ + +#define IN_DISPLAY_BANK(hiaddr) (((hiaddr)==DISPLAY_HI)|((hiaddr)==(DISPLAY_HI+1))) + +#define DLWORD_PERLINE (displaywidth/16) +#define HARD_CURSORWIDTH 16 +#define HARD_CURSORHEIGHT 16 +#define COLOR_BITSPER_PIXEL 8 +#define MONO_SCREEN 0 +#define COLOR_SCREEN 1 +#define COLOR_MAX_Address (ColorDisplayRegion68k + 1152 * 900) + +/* Replicate a 4-bit pattern to fill a word */ +#define Expand4Bit(BITS) \ + ((BITS) | ((BITS) << 4) | ((BITS) << 8) | ((BITS) << 12)) + +#ifdef XWINDOW +#define DISPLAYBUFFER +#endif /* XWINDOW */ + +#ifdef DOS +#define DISPLAYBUFFER +#endif /* DOS */ + +#ifdef DISPLAYBUFFER +/************************************************************************/ +/* */ +/* i n _ d i s p l a y _ s e g m e n t */ +/* */ +/* Returns T if the base address for this bitblt is in the */ +/* display segment. */ +/* */ +/************************************************************************/ +/* Osamu '90/02/08 + * This definition is moved from initdsp.c + * Change into macro for efficiency. + * And also DISP_MAX_Address is changed as variable + * to avoid same calicuration every time it uses. + *********************************************************************/ +extern DLword *DisplayRegion68k; + +#define in_display_segment(baseaddr) \ + (((DisplayRegion68k <= baseaddr) && \ + (baseaddr <=DISP_MAX_Address)) ? T :NIL ) +#endif + +#ifdef XWINDOW +#undef DISPLAYBUFFER +#endif /* XWINDOW */ + diff --git a/inc/dld.h b/inc/dld.h new file mode 100755 index 0000000..208f876 --- /dev/null +++ b/inc/dld.h @@ -0,0 +1,64 @@ +/* $Id: dld.h,v 1.2 1999/01/03 02:05:57 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* Error codes */ + +#define DLD_ENOFILE 1 /* cannot open file */ +#define DLD_EBADMAGIC 2 /* bad magic number */ +#define DLD_EBADHEADER 3 /* failure reading header */ +#define DLD_ENOTEXT 4 /* premature eof in text section */ +#define DLD_ENOSYMBOLS 5 /* premature end of file in symbols */ +#define DLD_ENOSTRINGS 6 /* bad string table */ +#define DLD_ENOTXTRELOC 7 /* premature eof in text relocation */ +#define DLD_ENODATA 8 /* premature eof in data section */ +#define DLD_ENODATRELOC 9 /* premature eof in data relocation */ +#define DLD_EMULTDEFS 10 /* multiple definitions of symbol */ +#define DLD_EBADLIBRARY 11 /* malformed library archive */ +#define DLD_EBADCOMMON 12 /* common block not supported */ +#define DLD_EBADOBJECT 13 /* malformed input file (not rel or + archive) */ +#define DLD_EBADRELOC 14 /* bad relocation info */ +#define DLD_ENOMEMORY 15 /* virtual memory exhausted */ +#define DLD_EUNDEFSYM 16 /* undefined symbol */ + +extern int dld_errno; /* error code returned by dld */ +extern int dld_undefined_sym_count; /* # of undefined global symbols */ + +extern int dld_init (); /* initialize the dld routines */ +extern int dld_link (); /* dynamically link and load an object + file */ +extern unsigned long +dld_get_symbol (); /* return the address of the named + identifier */ +extern unsigned long +dld_get_func (); /* return the address of the named + function */ +extern unsigned long +dld_get_bare_symbol (); /* same as dld_get_symbol except that + no underscore (_) is prepended. Use + to locate symbols defined by + assembly routines. */ +extern int dld_unlink_by_file (); /* unlink a file */ +extern int dld_unlink_by_symbol (); /* unlink the module that define the + given symbol */ + +extern int +dld_function_executable_p (); /* return true if the named C function + is executable */ + +extern char ** +dld_list_undefined_sym (); /* return an array of undefined symbols */ + +extern char * +dld_find_executable (); /* return the full path name of the + given executable file. */ + +extern int +dld_create_reference (); /* explicitly create a reference to the + given symbol. */ + +extern int dld_define_sym (); /* explicitly define the value for the + given symbol. */ + +extern void +dld_remove_defined_symbol (); /* remove a explicitly defined symbol */ + +extern void dld_perror (); /* print error messages. */ diff --git a/inc/dspdata.h b/inc/dspdata.h new file mode 100755 index 0000000..c08cb18 --- /dev/null +++ b/inc/dspdata.h @@ -0,0 +1,131 @@ +/* $Id: dspdata.h,v 1.2 1999/01/03 02:05:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + /******************************************************/ + /* Normal-byte-order declarations, for, e.g., 68020's */ + /******************************************************/ +typedef struct displaydata{ + + LispPTR ddxposition ; + LispPTR ddyposition; + LispPTR ddxoffset; + LispPTR ddyoffset; + LispPTR dddestination; + LispPTR ddclippingregion; + LispPTR ddfont; + LispPTR ddslowprintingcase; + LispPTR ddwidthscache; + LispPTR ddoffsetscache; + LispPTR ddcolor; + LispPTR ddlinefeed; + LispPTR ddrightmargin; + LispPTR ddleftmargin; + LispPTR ddscroll; + LispPTR ddoperation; + unsigned ddheldflg : 1; +#ifdef BIGVM + unsigned nil1 : 3; + unsigned ddsourcetype : 28; +#else + unsigned nil1 : 7; + unsigned ddsourcetype : 24; +#endif /* BIGVM */ + DLword ddclippingleft; + DLword ddclippingright; + DLword ddclippingbottom; + DLword ddclippingtop; + DLword nil2; + DLword ddcharsetascent; + LispPTR xwindowhint ; /* xpointer */ + LispPTR ddpilotbbt; + LispPTR ddxscale; + LispPTR ddyscale; + LispPTR ddcharimagewidths;/* Lisp POINTER to DLword array (49,50)*/ + LispPTR ddeolfn; + LispPTR ddpagefullfn; + LispPTR ddtexture; + LispPTR ddmicaxpos; + LispPTR ddmicaypos; + LispPTR ddmicarightmargin; + LispPTR ddcharset; + DLword ddcharsetdescent; + DLword ddspacewidth; /* ??*/ + LispPTR ddcharheightdelta; /* NUM PTR */ +}DISPLAYDATA; + +#else + /*************************************************/ + /* Byte-swapped declarations, for, e.g., 80386's */ + /*************************************************/ +typedef struct displaydata{ + + LispPTR ddxposition ; + LispPTR ddyposition; + LispPTR ddxoffset; + LispPTR ddyoffset; + LispPTR dddestination; + LispPTR ddclippingregion; + LispPTR ddfont; + LispPTR ddslowprintingcase; + LispPTR ddwidthscache; + LispPTR ddoffsetscache; + LispPTR ddcolor; + LispPTR ddlinefeed; + LispPTR ddrightmargin; + LispPTR ddleftmargin; + LispPTR ddscroll; + LispPTR ddoperation; +#ifdef BIGVM + unsigned ddsourcetype : 28; + unsigned nil1 : 3; +#else + unsigned ddsourcetype : 24; + unsigned nil1 : 7; +#endif /* BIGVM */ + unsigned ddheldflg : 1; + + DLword ddclippingright; + DLword ddclippingleft; + DLword ddclippingtop; + DLword ddclippingbottom; + DLword ddcharsetascent; + DLword nil2; + + LispPTR xwindowhint ; /* xpointer */ + LispPTR ddpilotbbt; + LispPTR ddxscale; + LispPTR ddyscale; + LispPTR ddcharimagewidths;/* Lisp POINTER to DLword array (49,50)*/ + LispPTR ddeolfn; + LispPTR ddpagefullfn; + LispPTR ddtexture; + LispPTR ddmicaxpos; + LispPTR ddmicaypos; + LispPTR ddmicarightmargin; + LispPTR ddcharset; + DLword ddspacewidth; /* ??*/ + DLword ddcharsetdescent; + LispPTR ddcharheightdelta; /* NUM PTR */ +}DISPLAYDATA; + +#endif /* BYTESWAP */ + diff --git a/inc/emlglob.h b/inc/emlglob.h new file mode 100755 index 0000000..97d9477 --- /dev/null +++ b/inc/emlglob.h @@ -0,0 +1,36 @@ +/* $Id: emlglob.h,v 1.2 1999/01/03 02:05:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* + * Copyright (C) 1987 by Fuji Xerox Co., Ltd. All rights reserved. + * + * Author : Takeshi Shimizu + * Hiroshi Hayata + + */ +/**********************************************************************/ +/* + File Name : emlglob.h + + Gloval variables for LispEmulator(external declared) + + Date : December 10, 1986 + Edited by : Takeshi Shimizu + Changed by : H. Hayata (11-Feb-87) + Changed : 5-Mar-87(take) + 24-Apr-87 take + 02-Jul-87 take + +*/ +/**********************************************************************/ + + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + diff --git a/inc/ether.h b/inc/ether.h new file mode 100755 index 0000000..647d5fa --- /dev/null +++ b/inc/ether.h @@ -0,0 +1,126 @@ +/* $Id: ether.h,v 1.2 1999/01/03 02:05:59 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + +typedef struct { + DLword DLLOCALHOST0; + DLword DLLOCALHOST1; + DLword DLLOCALHOST2; + DLword DLFIRSTICB; + DLword DLINPUTMASK; + DLword DLFIRSTOCB; + DLword DLOUTPUTMASK; + DLword DLMISSEDPACKETS; + DLword DLLASTICB; + DLword DLLASTOCB; +} DLETHERCSB; + +typedef struct{ + DLword DLIOCBLENGTH; + DLword DLIOCBBUFFERLO; + DLword DLIOCBBUFFERHI; + DLword DLRETRANSMISSIONMASK; + DLword DLIOCBBYTESUSED; + DLword DLIOCBSTATUS; + DLword DLNEXTIOCB; + DLword DLFOROUTPUTUSE; +} DLETHERIOCB; + +typedef struct { + unsigned int NETTYPE : 8; + unsigned int NDBNEXT : 24; + unsigned int NDBPUPNET : 8; + unsigned int NDBNSNET : 24; + unsigned int NDBTASK : 8; + unsigned int NDBBROADCASTP : 24; + unsigned int NDBPUPHOST : 8; + unsigned int NDBTRANSMITTER : 24; + unsigned int nil1: 8; + unsigned int NDBENCAPSULATOR : 24; + unsigned int NDBIQLENGTH : 8; /* DATATYPE */ + unsigned int NDBCSB : 24; /* DATATYPE */ + LispPTR NDBIQ; + LispPTR NDBTQ; + LispPTR NDBTRANSLATIONS; + LispPTR NDBETHERFLUSHER; + LispPTR NDBWATCHER; + LispPTR NDBCANHEARSELF; + LispPTR NDBIPNET; + LispPTR NDBIPHOST; + DLword NDBPUPTYPE; + DLword nil2; + LispPTR nil3; +} NDB; +#else + /***********************************************/ + /* Byte-swapped definitions, for e.g., 80386's */ + /***********************************************/ +typedef struct { + DLword DLLOCALHOST1; + DLword DLLOCALHOST0; + DLword DLFIRSTICB; + DLword DLLOCALHOST2; + DLword DLFIRSTOCB; + DLword DLINPUTMASK; + DLword DLMISSEDPACKETS; + DLword DLOUTPUTMASK; + DLword DLLASTOCB; + DLword DLLASTICB; +} DLETHERCSB; + +typedef struct{ + DLword DLIOCBBUFFERLO; + DLword DLIOCBLENGTH; + DLword DLRETRANSMISSIONMASK; + DLword DLIOCBBUFFERHI; + DLword DLIOCBSTATUS; + DLword DLIOCBBYTESUSED; + DLword DLFOROUTPUTUSE; + DLword DLNEXTIOCB; +} DLETHERIOCB; + +typedef struct { + unsigned int NDBNEXT : 24; + unsigned int NETTYPE : 8; + unsigned int NDBNSNET : 24; + unsigned int NDBPUPNET : 8; + unsigned int NDBBROADCASTP : 24; + unsigned int NDBTASK : 8; + unsigned int NDBTRANSMITTER : 24; + unsigned int NDBPUPHOST : 8; + unsigned int NDBENCAPSULATOR : 24; + unsigned int nil1: 8; + unsigned int NDBCSB : 24; /* DATATYPE */ + unsigned int NDBIQLENGTH : 8; /* DATATYPE */ + LispPTR NDBIQ; + LispPTR NDBTQ; + LispPTR NDBTRANSLATIONS; + LispPTR NDBETHERFLUSHER; + LispPTR NDBWATCHER; + LispPTR NDBCANHEARSELF; + LispPTR NDBIPNET; + LispPTR NDBIPHOST; + DLword nil2; + DLword NDBPUPTYPE; + LispPTR nil3; +} NDB; + +#endif /* BYTESWAP */ + diff --git a/inc/externs.h b/inc/externs.h new file mode 100755 index 0000000..d16186c --- /dev/null +++ b/inc/externs.h @@ -0,0 +1,187 @@ +/* $Id: externs.h,v 1.2 1999/01/03 02:05:59 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* + * + * externs.h - external definitons for nfswatch. + * + * David A. Curry Jeffrey C. Mogul + * Purdue University Digital Equipment Corporation + * Engineering Computer Network Western Research Laboratory + * 1285 Electrical Engineering Building 250 University Avenue + * West Lafayette, IN 47907-1285 Palo Alto, CA 94301 + * davy@ecn.purdue.edu mogul@decwrl.dec.com + * + * $Log: externs.h,v $ + * Revision 1.2 1999/01/03 02:05:59 sybalsky + * Add ID comments / static to files for CVS use + * + * Revision 1.1.1.1 1998/12/17 05:03:16 sybalsky + * Import of Medley 3.5 emulator + * + * Revision 4.2 93/10/04 11:00:24 mogul + * Added fhdebugf flag + * + * Revision 4.1 93/09/28 21:23:40 mogul + * explicit IP address data type. + * + * Revision 4.0 93/03/01 19:59:00 davy + * NFSWATCH Version 4.0. + * + * Revision 3.7 1993/02/24 17:44:45 davy + * Added -auth mode, changes to -proc mode, -map option, -server option. + * + * Revision 3.6 1993/01/20 14:52:30 davy + * Added -T maxtime option. + * + * Revision 3.5 1993/01/16 19:08:59 davy + * Corrected Jeff's address. + * + * Revision 3.4 1993/01/15 19:33:39 davy + * Miscellaneous cleanups. + * + * Revision 3.3 1993/01/13 15:12:05 davy + * Added background mode. + * + * Revision 3.2 1993/01/13 13:00:04 davy + * Fixed a bug in finish() routine, closing too many file descriptors. + * + * Revision 3.1 1992/07/24 18:47:57 mogul + * Added FDDI support + * + * Revision 3.0 1991/01/23 08:23:02 davy + * NFSWATCH Version 3.0. + * + * Revision 1.3 91/01/04 15:52:07 davy + * New features from Jeff Mogul. + * + * Revision 1.2 90/08/17 15:46:43 davy + * NFSWATCH Version 2.0. + * + * Revision 1.1 88/11/29 11:20:27 davy + * NFSWATCH Release 1.0 + * + */ + +extern char *pname; + +extern FILE *logfp; + +extern Counter pkt_total; +extern Counter pkt_drops; +extern Counter int_pkt_total; +extern Counter int_pkt_drops; +extern Counter dst_pkt_total; +extern Counter int_dst_pkt_total; + +extern int errno; +extern int bgflag; +extern int if_fd[]; +extern int allintf; +extern int fhdebugf; +extern int dstflag; +extern int srcflag; +extern int allflag; +extern int logging; +extern int learnfs; +extern int if_dlt[]; +extern int do_update; +extern int cycletime; +extern int totaltime; +extern int showwhich; +extern int serverflag; +extern int truncation; +extern int ninterfaces; +extern int sortbyusage; +extern int nnfscounters; +extern int nfilecounters; +extern int nauthcounters; +extern int screen_inited; +extern int nclientcounters; + +extern ipaddrt thisdst; +extern ipaddrt srcaddrs[]; +extern ipaddrt dstaddrs[]; +extern ipaddrt serveraddrs[]; + +extern struct timeval starttime; + +extern char myhost[]; +extern char srchost[]; +extern char dsthost[]; +extern char serverhost[]; + +extern char *prompt; +extern char *logfile; +extern char *mapfile; +extern char *filelist; +extern char *snapshotfile; + +extern NFSCounter nfs_counters[]; +extern FileCounter fil_counters[]; +extern PacketCounter pkt_counters[]; +extern ProcCounter prc_counters[]; +extern int prc_countmap[]; +extern ClientCounter clnt_counters[]; +extern AuthCounter auth_counters[]; + +extern NFSCall nfs_calls[NFSCALLHASHSIZE]; + +char *dlt_name(); +char *prtime(); +char *savestr(); + +int auth_comp(); +int clnt_comp(); +int dlpi_devtype(); +int fil_comp(); +int is_exported(); +int nfs_comp(); +int nit_devtype(); +int pfilt_devtype(); +int prc_comp(); +int setup_nit_dev(); +int setup_dlpi_dev(); +int setup_pfilt_dev(); +int setup_snoop_dev(); +int snoop_devtype(); +int udprpc_recv(); +int want_packet(); + +void clear_vars(); +void command(); +void error(); +void finish(); +void flush_nit(); +void flush_dlpi(); +void flush_pfilt(); +void flush_snoop(); +void get_net_addrs(); +void icmp_filter(); +void ip_filter(); +void label_screen(); +void nd_filter(); +void nfs_count(); +void nfs_filter(); +void nfs_hash_call(); +void nfs_hash_reply(); +void nfswatch(); +void pkt_filter_ether(); +void pkt_filter_fddi(); +void rpc_callfilter(); +void rpc_filter(); +void rpc_replyfilter(); +void setup_auth_counters(); +void setup_fil_counters(); +void setup_map_file(); +void setup_nfs_counters(); +void setup_pkt_counters(); +void setup_screen(); +void setup_rpcxdr(); +void snapshot(); +void sort_auth_counters(); +void sort_nfs_counters(); +void tcp_filter(); +void udp_filter(); +void update_logfile(); +void update_screen(); +void usage(); +void wakeup(); diff --git a/inc/fast_dsp.h b/inc/fast_dsp.h new file mode 100755 index 0000000..eafdf2a --- /dev/null +++ b/inc/fast_dsp.h @@ -0,0 +1,258 @@ +/* $Id: fast_dsp.h,v 1.2 1999/01/03 02:05:59 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* These are the Macros Used to generate fast dispatch inline code. +*/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1991 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* F A S T O P C O D E D I S P A T C H M A C R O S */ +/* */ +/* These macros generate better opcode-dispatch code than the */ +/* native compiler will. The difference may be only one or */ +/* two instructions, but in the inner loop, that's a LOT. */ +/* */ +/* To add a new architecture, you must define 5 macros: */ +/* */ +/* nextop0 - for single-byte opcodes */ +/* nextop1 - skip a byte and grab an opcode */ +/* nextop2 - skip 2 bytes and grab an opcode */ +/* nextop3 - skip 3 bytes and grab an opcode */ +/* nextop4 - skip 4 bytes and grab an opcode */ +/* */ +/* (These macros are already defined naively, so undef them.) */ +/* */ +/* For existing implementations, these often expand out to */ +/* calls to inline functions. */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifdef OPDISP /* Only do any of this if OPDISP is set. */ + + /* Sun 3 */ +#ifdef mc68020 +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 +/* JRB - fast case is now nextop1 */ +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast1_dispatcher2(); } +#define nextop3 { PCMACL += 2; nextop1; } +#define nextop4 { PCMACL += 3; nextop1; } +#endif + + /* Sun 386i */ +#ifdef I386 +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 +/* JRB - fast case is now nextop1 */ +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast2_dispatcher(); } +#define nextop3 { PCMACL += 2; nextop1; } +#define nextop4 { PCMACL += 3; nextop1; } +#endif + + + /* ISC 386 using gcc */ +#ifdef ISC +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 + +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast2_dispatcher(); goto nextopcode;} +#define nextop3 { fast3_dispatcher(); goto nextopcode;} +#define nextop4 { fast4_dispatcher(); goto nextopcode;} + +#define fast0_dispatcher() \ + asm volatile(" \n\ +// leal -1(%0),%%eax \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + movzbl -1(%0),%%eax \n\ + jmp *optable(,%%eax,4)" : : "r" (pccache): "ax"); + +#define fast1_dispatcher() \ + asm volatile(" \n\ +/ movl %0,%%eax \n\ +/ xorb $3,%%al \n\ + movzbl (%0),%%eax \n\ + incl %0 \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" : "=r" (pccache) : "0" (pccache): "ax"); + +#define fast2_dispatcher() \ + asm volatile(" \n\ +/ leal 1(%0),%%eax \n\ + movzbl 1(%0),%%eax \n\ + addl $2,%0 \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" :"=r" (pccache) : "0" (pccache): "ax"); + +#define fast3_dispatcher() \ + asm volatile(" \n\ +/ leal 2(%0),%%eax \n\ + movzbl 2(%0),%%eax \n\ + addl $3,%0 \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" :"=r" (pccache) : "0" (pccache): "ax"); +#define fast4_dispatcher() \ + asm volatile(" \n\ +/ leal 3(%0),%%eax \n\ + movzbl 3(%0),%%eax \n\ + addl $4,%0 \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" :"=r" (pccache) : "0" (pccache): "ax"); + +#endif + +#endif /* OPDISP */ + + + + + + /* ISC 386 using gcc with turbo assembler (DOS version) */ +#ifdef DOS +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 + +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast2_dispatcher(); goto nextopcode;} +#define nextop3 { fast3_dispatcher(); goto nextopcode;} +#define nextop4 { fast4_dispatcher(); goto nextopcode;} + +#define fast0_dispatcher() \ + asm volatile(" \n\ + lea eax,-1[%0] \n\ + xor al,3 \n\ + movzx eax, BYTE PTR [eax] \n\ +; mov dword ptr save_opcode, eax \n\ +; mov dword ptr save_pc, esi \n\ +; mov dword ptr save_tos, ebx \n\ +; mov dword ptr save_tsptr, edi \n\ +; mov dword ptr save_esp, esp \n\ +; mov dword ptr save_ebp, ebp \n\ + jmp OFFSET CODE32:optable[eax*4]" : "=r" (pccache) : "0" (pccache): "ax"); + +#define fast1_dispatcher() \ + asm volatile(" \n\ + mov eax,%0 \n\ + xor al,3 \n\ + inc %0 \n\ + movzx eax, BYTE PTR [eax] \n\ +; mov dword ptr save_opcode, eax \n\ +; mov dword ptr save_pc, esi \n\ +; mov dword ptr save_tos, ebx \n\ +; mov dword ptr save_tsptr, edi \n\ +; mov dword ptr save_esp, esp \n\ +; mov dword ptr save_ebp, ebp \n\ + jmp OFFSET CODE32:optable[eax*4]" : "=r" (pccache) : "0" (pccache): "ax"); + +#define fast2_dispatcher() \ + asm volatile(" \n\ + lea eax,1[%0] \n\ + add %0,2 \n\ + xor al,3 \n\ + movzx eax, BYTE PTR [eax] \n\ +; mov dword ptr save_opcode, eax \n\ +; mov dword ptr save_pc, esi \n\ +; mov dword ptr save_tos, ebx \n\ +; mov dword ptr save_tsptr, edi \n\ +; mov dword ptr save_esp, esp \n\ +; mov dword ptr save_ebp, ebp \n\ + jmp OFFSET CODE32:optable[eax*4]" : "=r" (pccache) : "0" (pccache): "ax"); + +#define fast3_dispatcher() \ + asm volatile(" \n\ + lea eax,2[%0] \n\ + add %0,3 \n\ + xor al,3 \n\ + movzx eax, BYTE PTR [eax] \n\ +; mov dword ptr save_opcode, eax \n\ +; mov dword ptr save_pc, esi \n\ +; mov dword ptr save_tos, ebx \n\ +; mov dword ptr save_tsptr, edi \n\ +; mov dword ptr save_esp, esp \n\ +; mov dword ptr save_ebp, ebp \n\ + jmp OFFSET CODE32:optable[eax*4]" : "=r" (pccache) : "0" (pccache): "ax"); + +#define fast4_dispatcher() \ + asm volatile(" \n\ + lea eax,3[%0] \n\ + add %0,4 \n\ + xor al,3 \n\ + movzx eax, BYTE PTR [eax] \n\ +; mov dword ptr save_opcode, eax \n\ +; mov dword ptr save_pc, esi \n\ +; mov dword ptr save_tos, ebx \n\ +; mov dword ptr save_tsptr, edi \n\ +; mov dword ptr save_esp, esp \n\ +; mov dword ptr save_ebp, ebp \n\ + jmp OFFSET CODE32:optable[eax*4]" : "=r" (pccache) : "0" (pccache): "ax"); + +#endif /* DOS */ + + + + + + + +#ifdef SPARCDISP +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 +#define nextop0 { fast_dispatcher(table, Get_BYTE(PCMAC)); goto nextopcode; } +#define nextop_n(n) { \ + PCMACL += n; \ + nextop0; \ +} +#define nextop1 { nextop_n(1); } +#define nextop2 { nextop_n(2); } +#define nextop3 { nextop_n(3); } +#define nextop4 { nextop_n(4); } +#endif /* SPARCDISP */ + + + + + + + + + diff --git a/inc/fp.h b/inc/fp.h new file mode 100755 index 0000000..5055db8 --- /dev/null +++ b/inc/fp.h @@ -0,0 +1,119 @@ +/* $Id: fp.h,v 1.2 1999/01/03 02:06:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifdef DOS +#include +#endif /* DOS */ +#ifdef ULTRIX +#include +#endif /* ULTRIX */ + +#ifdef RISCOS +/*#include */ +/*#define isnan isnand */ +#define isnan(x) 0 +#endif /* RISCOS */ + + +/* -------------------------------------------------- + FPCLEAR - clear status as necessary + FPTEST(result) - check result or status + + Sun 4 compiler w. -O2 moves too much code around + to use FLTINT. + -------------------------------------------------- */ + +#ifdef FLTINT +extern int FP_error; + +/* Note that a compiler may very likely move code around the arithmetic + operation, causing this test (set by an interrupt handler) to be + incorrect. For example, the Sun SPARC compiler with -O2 makes + this test incorrect. + */ + +#define FPCLEAR FP_error = 0; +#define FPTEST(result) FP_error + +#else + +/* fpstatus_ is a FORTRAN library routine (in libc) which + can be called to determine floating point status results. + Documented in the Sun manual, "Floating Point Programmer's Guide", + (Rev. A 19-Sep-86), pg. 34, it does *not* exist in libc for the + SPARC. + + For sparc, should also check for isnan? Don't know what isnormal + & issubnormal do (these are sunos4.0 only) + */ + +#ifdef OS5 + +#define FPCLEAR +#define FPTEST(result) (!finite(result)) + +#elif (defined(sparc) || defined(I386) || defined(HPUX)) + +#define FPCLEAR +#define FPTEST(result) (isinf(result) || isnan(result)) + +#elif APOLLO + /**********************************************************/ + /* Need values.h & nan.h, so we all parts of IsNANorINF */ + /* are defined. IsNANorINF uses structure aliasing to */ + /* get at pieces of the float to test it, so the item */ + /* being tested can't be a register variable. Sigh. */ + /**********************************************************/ +#include +#include +#define FPCLEAR +#define FPTEST(result) (IsNANorINF(result)) +#undef REGISTER +#define REGISTER + +#elif INDIGO +#include +#define FPCLEAR +#define FPTEST(result) (IsNANorINF(result)) +#else +#ifdef AIX +#define FPCLEAR +#define FPTEST(result) ((!finite(result)) || isnan(result)) +#elif DOS +#define FPCLEAR +#define FPTEST(result) (_getrealerror() & ( I87_ZERO_DIVIDE | I87_OVERFLOW | I87_UNDERFLOW)) +#else +static int constant0 = 0; +unsigned int fpstatus_(); + +#define FPCLEAR fpstatus_(&constant0); +#define FPTEST(result) (fpstatus_(&constant0) & 0xF0) + +#endif /* AIX */ + +#endif /* sparc | I386 */ + +#endif /* FLTINT */ + + + diff --git a/inc/gc.h b/inc/gc.h new file mode 100755 index 0000000..3ffbef1 --- /dev/null +++ b/inc/gc.h @@ -0,0 +1,270 @@ +/* $Id: gc.h,v 1.3 2001/12/24 01:08:57 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/**********************************************************************/ +/* + File Name : gc.h + + Define for garbage collector + +*/ +/**********************************************************************/ +#define ADDREF 0 /* for gclookup routine. */ +#define DELREF 1 /* for gclookup routine. */ +#define STKREF 2 /* for gclookup routine. */ +#define UNSTKREF 3 /* for htfind function. (T.T.) */ + + +#ifdef BIGVM + /* 32-bit HTmain, HTcoll, etc. entries */ +#define GETGC(x) *((LispPTR *) (x)) +#define GCENTRY LispPTR +#define GCPTR +#define MAX_GCCOUNT 0x7FFF /* = 32767 */ +#else + /* Old, 16-bit entries */ +#define GETGC GETWORD +#define GCENTRY DLword +#define GCPTR(x) WORDPTR(x) +#define MAX_GCCOUNT 0x3F /* = 63 */ +#endif /* BIGVM */ + + + + /* IncAllocCnt(n) decrements reclaim countdown by N + and signals interrupt if GC should happen soon */ + + /* IncAllocCnt is called only when *Reclaim_cnt_word != NIL */ + +#define IncAllocCnt(n) {\ + if ((*Reclaim_cnt_word -= n) <= S_POSITIVE) {\ + /* time for GC */\ + Irq_Stk_Check = Irq_Stk_End = 0;\ + *Reclaim_cnt_word = S_POSITIVE;\ + };\ +} + + /* DecAllocCnt only called when *Reclaim_cnt_word != NIL */ + +#define DecAllocCnt(n) { *Reclaim_cnt_word += n; } + +#define FreeLink(link) {\ + GETGC(link) = 0;\ + GETGC(link+1) = GETGC(HTcoll);\ + GETGC(HTcoll) = (link - HTcoll);\ +} + + + /* Given the contents of an HTMAIN or HTCOLL entry, + get the link pointer (i.e., turn off the low bit) */ +#define GetLinkptr(entry) (entry & 0x0fffffffe) + + +#define DelLink(link, prev, entry) { \ + if (prev != (GCENTRY *)0) \ + { \ + GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); \ + } \ + else \ + { \ + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link + 1) | 1; \ + } \ + FreeLink((GCENTRY *)link); \ + link = (GCENTRY *)(HTcoll + GetLinkptr(GETGC((GCENTRY *)entry))); \ + if (GETGC((GCENTRY *)link + 1) == 0) \ + { \ + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); \ + FreeLink((GCENTRY *)link); \ + } \ +} + +#define RefCntP(ptr) (!(GetTypeEntry((ptr)) & TT_NOREF) && \ + (*GcDisabled_word != ATOM_T)) + +#define GCLOOKUP(ptr, case) { \ + if (RefCntP(ptr)) { \ + if (*Reclaim_cnt_word != NIL) \ + htfind(ptr, case); \ + else \ + rec_htfind(ptr, case); \ + } \ +} + +#define GCLOOKUPV(ptr, case, val) { \ + if (RefCntP(ptr)) { \ + if (*Reclaim_cnt_word != NIL) \ + val = htfind(ptr, case); \ + else \ + val = rec_htfind(ptr, case); \ + } else val = NIL; \ +} + +#define REC_GCLOOKUP(ptr, case) { if (RefCntP(ptr)) rec_htfind(ptr, case); } +#define REC_GCLOOKUPV(ptr, case, val) { \ + if (RefCntP(ptr)) \ + val = rec_htfind(ptr, case); \ + else \ + val = NIL; \ +} + +#define FRPLPTR(old , new) { \ + GCLOOKUP(new, ADDREF); \ + GCLOOKUP(old, DELREF); \ + (old) = (new) ; } + + +#ifndef BYTESWAP + /********************************************************/ + /* Normal byte-order definitions, for e.g., 68020s */ + /********************************************************/ +#ifdef BIGVM +struct hashentry + { /* GC hastable entry */ + unsigned short count :15; + unsigned short stackref :1; + unsigned short segnum :15; + unsigned short collision :1; + }; + +struct htlinkptr + { /* overlay access method */ + LispPTR contents; + }; + +struct htcoll + { /* GC collision table entry */ + LispPTR free_ptr ; + LispPTR next_free ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned pcase :4; + unsigned ptr :28; + }; +#else +struct hashentry + { /* GC hastable entry */ + USHORT count :6; + USHORT stackref :1; + USHORT segnum :8; + USHORT collision :1; + }; + +struct htlinkptr + { /* overlay access method */ + DLword contents; + }; + +struct htcoll + { /* GC collision table entry */ + DLword free_ptr ; + DLword next_free ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned pcase :8; + unsigned ptr :24; + }; +#endif /* BIGVM */ + +#else + + /********************************************************/ + /* Byte-swapped definitions, for e.g., 80386s */ + /********************************************************/ +#ifdef BIGVM +struct hashentry + { /* GC hashtable entry */ + USHORT collision :1; + USHORT segnum :15; + USHORT stackref :1; + USHORT count :15; + }; + +struct htlinkptr + { /* overlay access method */ + LispPTR contents; + }; + +struct htcoll + { /* GC collision table entry */ + LispPTR free_ptr ; + LispPTR next_free ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned ptr :28; + unsigned pcase :4; + }; +#else +struct hashentry + { /* GC hashtable entry */ + USHORT collision :1; + USHORT segnum :8; + USHORT stackref :1; + USHORT count :6; + }; + +struct htlinkptr + { /* overlay access method */ + DLword contents; + }; + +struct htcoll + { /* GC collision table entry */ + DLword next_free ; + DLword free_ptr ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned ptr :24; + unsigned pcase :8; + }; +#endif /* BIGVM */ + +#endif /* BYTESWAP */ + + +extern LispPTR htfind(LispPTR ptr, int casep); +extern LispPTR rec_htfind(LispPTR ptr, int casep); diff --git a/inc/gc.h.save b/inc/gc.h.save new file mode 100755 index 0000000..7cabbbd --- /dev/null +++ b/inc/gc.h.save @@ -0,0 +1,270 @@ +/* $Id: gc.h,v 1.2 1999/01/03 02:06:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/**********************************************************************/ +/* + File Name : gc.h + + Define for garbage collector + +*/ +/**********************************************************************/ +#define ADDREF 0 /* for gclookup routine. */ +#define DELREF 1 /* for gclookup routine. */ +#define STKREF 2 /* for gclookup routine. */ +#define UNSTKREF 3 /* for htfind function. (T.T.) */ + + +#ifdef BIGVM + /* 32-bit HTmain, HTcoll, etc. entries */ +#define GETGC(x) *((LispPTR *) (x)) +#define GCENTRY LispPTR +#define GCPTR +#define MAX_GCCOUNT 0x7FFF /* = 32767 */ +#else + /* Old, 16-bit entries */ +#define GETGC GETWORD +#define GCENTRY DLword +#define GCPTR(x) WORDPTR(x) +#define MAX_GCCOUNT 0x3F /* = 63 */ +#endif /* BIGVM */ + + + + /* IncAllocCnt(n) decrements reclaim countdown by N + and signals interrupt if GC should happen soon */ + + /* IncAllocCnt is called only when *Reclaim_cnt_word != NIL */ + +#define IncAllocCnt(n) {\ + if ((*Reclaim_cnt_word -= n) <= S_POSITIVE) {\ + /* time for GC */\ + Irq_Stk_Check = Irq_Stk_End = 0;\ + *Reclaim_cnt_word = S_POSITIVE;\ + };\ +} + + /* DecAllocCnt only called when *Reclaim_cnt_word != NIL */ + +#define DecAllocCnt(n) { *Reclaim_cnt_word += n; } + +#define FreeLink(link) {\ + GETGC(link) = 0;\ + GETGC(link+1) = GETGC(HTcoll);\ + GETGC(HTcoll) = (link - HTcoll);\ +} + + + /* Given the contents of an HTMAIN or HTCOLL entry, + get the link pointer (i.e., turn off the low bit) */ +#define GetLinkptr(entry) (entry & 0x0fffffffe) + + +#define DelLink(link, prev, entry) { \ + if (prev != (GCENTRY *)0) \ + { \ + GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); \ + } \ + else \ + { \ + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link + 1) | 1; \ + } \ + FreeLink((GCENTRY *)link); \ + link = (GCENTRY *)(HTcoll + GetLinkptr(GETGC((GCENTRY *)entry))); \ + if (GETGC((GCENTRY *)link + 1) == 0) \ + { \ + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); \ + FreeLink((GCENTRY *)link); \ + } \ +} + +#define RefCntP(ptr) (!(GetTypeEntry((ptr)) & TT_NOREF) && \ + (*GcDisabled_word != ATOM_T)) + +#define GCLOOKUP(ptr, case) { \ + if (RefCntP(ptr)) { \ + if (*Reclaim_cnt_word != NIL) \ + htfind(ptr, case); \ + else \ + rec_htfind(ptr, case); \ + } \ +} + +#define GCLOOKUPV(ptr, case, val) { \ + if (RefCntP(ptr)) { \ + if (*Reclaim_cnt_word != NIL) \ + val = htfind(ptr, case); \ + else \ + val = rec_htfind(ptr, case); \ + } else val = NIL; \ +} + +#define REC_GCLOOKUP(ptr, case) { if (RefCntP(ptr)) rec_htfind(ptr, case); } +#define REC_GCLOOKUPV(ptr, case, val) { \ + if (RefCntP(ptr)) \ + val = rec_htfind(ptr, case); \ + else \ + val = NIL; \ +} + +#define FRPLPTR(old , new) { \ + GCLOOKUP(new, ADDREF); \ + GCLOOKUP(old, DELREF); \ + (old) = (new) ; } + + +#ifndef BYTESWAP + /********************************************************/ + /* Normal byte-order definitions, for e.g., 68020s */ + /********************************************************/ +#ifdef BIGVM +struct hashentry + { /* GC hastable entry */ + unsigned short count :15; + unsigned short stackref :1; + unsigned short segnum :15; + unsigned short collision :1; + }; + +struct htlinkptr + { /* overlay access method */ + LispPTR contents; + }; + +struct htcoll + { /* GC collision table entry */ + LispPTR free_ptr ; + LispPTR next_free ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned pcase :4; + unsigned ptr :28; + }; +#else +struct hashentry + { /* GC hastable entry */ + USHORT count :6; + USHORT stackref :1; + USHORT segnum :8; + USHORT collision :1; + }; + +struct htlinkptr + { /* overlay access method */ + DLword contents; + }; + +struct htcoll + { /* GC collision table entry */ + DLword free_ptr ; + DLword next_free ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned pcase :8; + unsigned ptr :24; + }; +#endif /* BIGVM */ + +#else + + /********************************************************/ + /* Byte-swapped definitions, for e.g., 80386s */ + /********************************************************/ +#ifdef BIGVM +struct hashentry + { /* GC hashtable entry */ + USHORT collision :1; + USHORT segnum :15; + USHORT stackref :1; + USHORT count :15; + }; + +struct htlinkptr + { /* overlay access method */ + LispPTR contents; + }; + +struct htcoll + { /* GC collision table entry */ + LispPTR free_ptr ; + LispPTR next_free ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned ptr :28; + unsigned pcase :4; + }; +#else +struct hashentry + { /* GC hashtable entry */ + USHORT collision :1; + USHORT segnum :8; + USHORT stackref :1; + USHORT count :6; + }; + +struct htlinkptr + { /* overlay access method */ + DLword contents; + }; + +struct htcoll + { /* GC collision table entry */ + DLword next_free ; + DLword free_ptr ; + }; + +struct gc_ovfl + { + LispPTR ovfl_ptr ; + unsigned int ovfl_cnt ; + }; + +struct htoverflow + { /* July-23-1987 by TT */ + unsigned ptr :24; + unsigned pcase :8; + }; +#endif /* BIGVM */ + +#endif /* BYTESWAP */ + + +extern LispPTR htfind(); +extern LispPTR rec_htfind(); diff --git a/inc/gcscan.h b/inc/gcscan.h new file mode 100755 index 0000000..2fa36b8 --- /dev/null +++ b/inc/gcscan.h @@ -0,0 +1,52 @@ +/* $Id: gcscan.h,v 1.2 1999/01/03 02:06:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +#define HTSTKBIT 0x200 /* = 512 */ +#define HTENDS ((struct hashentry *) htlptr) +#define GetStkCnt(entry1) (entry1 >> 9) + +/* extern DLword *HTmain; -- this is real method */ + + +const inline extern DLword gcscan1 (probe) +register int probe; /* probe is offset */ + { register struct htlinkptr *htlptr; /* overlay access method */ + register int contents; + while (--probe >= 0) /* End of HTmain Table ? */ + { + /* Start addr. of scanning */ + htlptr = (struct htlinkptr *)(HTmain+probe); + contents = ((struct htlinkptr *)WORDPTR(htlptr))->contents; + if (contents && (((struct hashentry *)WORDPTR(HTENDS))->collision || (GetStkCnt(contents) == 0))) + return(probe); + } + return(NIL); + } + +const inline extern DLword gcscan2 (probe) +register int probe; /* probe is offset */ + {register struct htlinkptr *htlptr; /* overlay access method */ + while (--probe >= 0) /* End of HTmain Table ? */ + { htlptr = (struct htlinkptr *)(HTmain+probe); + /* Start addr. of scanning */ + if (((HTSTKBIT | 1) & ((struct htlinkptr *)WORDPTR(htlptr))->contents) != 0) + return(probe); /* stackref or collision ON */ + } + return(NIL); + } diff --git a/inc/hdw_conf.h b/inc/hdw_conf.h new file mode 100755 index 0000000..58f7448 --- /dev/null +++ b/inc/hdw_conf.h @@ -0,0 +1,41 @@ +/* $Id: hdw_conf.h,v 1.2 1999/01/03 02:06:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + + +/**************************************************************/ +/* + File name : machineconfig.h + + Created : Aug-19-87 take + + Desc. : Define for Machine dependent param + +*/ +/**************************************************************/ +/* Machine Type */ + +#define KATANA 3 + +/* Lastvmempage(32Mbyte) */ +#ifdef BIGVM +#define LASTVMEMPAGE 0x1FFFF +#else +#define LASTVMEMPAGE (65535) +#endif + diff --git a/inc/ifpage.h b/inc/ifpage.h new file mode 100755 index 0000000..957a292 --- /dev/null +++ b/inc/ifpage.h @@ -0,0 +1,362 @@ +/* $Id: ifpage.h,v 1.2 1999/01/03 02:06:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#ifndef IFPAGE_DEFINED +#define IFPAGE_DEFINED (1) +#define IFPAGE_KEYVAL 0x15e3 +#ifndef BYTESWAP +#ifdef BIGVM + /* Normal definition, for big-indian BIGVM machines */ +typedef struct ifpage { + DLword currentfxp; + DLword resetfxp; + DLword subovfxp; + DLword kbdfxp; + DLword hardreturnfxp; + DLword gcfxp; + DLword faultfxp; + DLword endofstack; + DLword lversion; + DLword minrversion; + DLword minbversion; + DLword rversion; + DLword bversion; + DLword machinetype; + DLword miscfxp; + DLword key; + DLword serialnumber; + DLword emulatorspace; + DLword screenwidth; + DLword nxtpmaddr; + DLword ex_nactivepages; + DLword ex_ndirtypages; + DLword filepnpmp0; + DLword filepnpmt0; + DLword teleraidfxp; + DLword filler1; + DLword filler2; + DLword filler3; + DLword usernameaddr; + DLword userpswdaddr; + DLword stackbase; + DLword faulthi; + DLword faultlo; + DLword devconfig;/*wasrealpagetable;*/ + DLword rptsize; + DLword rpoffset; + DLword wasrptlast; + DLword embufvp; + DLword nshost0; + DLword nshost1; + DLword nshost2; + DLword mdszone; + DLword mdszonelength; + DLword emubuffers; + DLword emubuflength; +#ifdef NEW_STORAGE + DLword ex_process_size; /* was lastnumchars */ + DLword storagefullstate; /* was sysdisk */ +#else + DLword lastnumchars; + DLword sysdisk; +#endif /* NEW_STORAGE */ + DLword isfmap; + /* these are for \miscapply + * -- note that they are not ref counted, so don't pass the only pointer + * to something this way */ + LispPTR miscstackfn; + LispPTR miscstackarg1; + LispPTR miscstackarg2; + LispPTR miscstackresult; + DLword nrealpages; + DLword lastlockedfilepage; + DLword lastdominofilepage; + DLword fptovpstart; + DLword fakemousebits; + DLword dl24bitaddressable; + LispPTR realpagetableptr; + DLword ex_dllastvmempage; + DLword fullspaceused; + DLword fakekbdad4; + DLword fakekbdad5; + DLword d1nil1; + DLword dlnil2; + DLword dlnil3; + DLword dlnil4; + DLword dlnil5; + DLword dlnil6; + LispPTR dlnilp1; + LispPTR dlnilp2; + LispPTR dlnilp3; + int dllastvmempage; + int nactivepages; + int ndirtypages; + int process_size; /* was lastnumchars */ +} IFPAGE; +#else +/* Normal definition, for big-indian machines */ +typedef struct ifpage { + DLword currentfxp; + DLword resetfxp; + DLword subovfxp; + DLword kbdfxp; + DLword hardreturnfxp; + DLword gcfxp; + DLword faultfxp; + DLword endofstack; + DLword lversion; + DLword minrversion; + DLword minbversion; + DLword rversion; + DLword bversion; + DLword machinetype; + DLword miscfxp; + DLword key; + DLword serialnumber; + DLword emulatorspace; + DLword screenwidth; + DLword nxtpmaddr; + DLword nactivepages; + DLword ndirtypages; + DLword filepnpmp0; + DLword filepnpmt0; + DLword teleraidfxp; + DLword filler1; + DLword filler2; + DLword filler3; + DLword usernameaddr; + DLword userpswdaddr; + DLword stackbase; + DLword faulthi; + DLword faultlo; + DLword devconfig;/*wasrealpagetable;*/ + DLword rptsize; + DLword rpoffset; + DLword wasrptlast; + DLword embufvp; + DLword nshost0; + DLword nshost1; + DLword nshost2; + DLword mdszone; + DLword mdszonelength; + DLword emubuffers; + DLword emubuflength; +#ifdef NEW_STORAGE + DLword process_size; /* was lastnumchars */ + DLword storagefullstate; /* was sysdisk */ +#else + DLword lastnumchars; + DLword sysdisk; +#endif /* NEW_STORAGE */ + DLword isfmap; + /* these are for \miscapply + * -- note that they are not ref counted, so don't pass the only pointer + * to something this way */ + LispPTR miscstackfn; + LispPTR miscstackarg1; + LispPTR miscstackarg2; + LispPTR miscstackresult; + DLword nrealpages; + DLword lastlockedfilepage; + DLword lastdominofilepage; + DLword fptovpstart; + DLword fakemousebits; + DLword dl24bitaddressable; + LispPTR realpagetableptr; + DLword dllastvmempage; + DLword fullspaceused; + DLword fakekbdad4; + DLword fakekbdad5; +} IFPAGE; +#endif /* BIGVM */ +#else +#ifdef BIGVM + /***********************************************************/ + /* Byte-swapped/word-swapped BIGVM version */ + /***********************************************************/ +typedef struct ifpage { + DLword resetfxp; + DLword currentfxp; /* hi word */ + DLword kbdfxp; + DLword subovfxp; /* hi word */ + DLword gcfxp; + DLword hardreturnfxp; /* hi word */ + DLword endofstack; + DLword faultfxp; /* hi word */ + DLword minrversion; + DLword lversion; /* hi word */ + DLword rversion; + DLword minbversion; /* hi word */ + DLword machinetype; + DLword bversion; /* hi word */ + DLword key; + DLword miscfxp; /* hi word */ + DLword emulatorspace; + DLword serialnumber; /* hi word */ + DLword nxtpmaddr; + DLword screenwidth; /* hi word */ + DLword ex_ndirtypages; + DLword ex_nactivepages; /* hi word */ + DLword filepnpmt0; + DLword filepnpmp0; /* hi word */ + DLword filler1; + DLword teleraidfxp; /* hi word */ + DLword filler3; + DLword filler2; /* hi word */ + DLword userpswdaddr; + DLword usernameaddr; /* hi word */ + DLword faulthi; + DLword stackbase; /* hi word */ + DLword devconfig;/*wasrealpagetable;*/ + DLword faultlo; /* hi word */ + DLword rpoffset; + DLword rptsize; /* hi word */ + DLword embufvp; + DLword wasrptlast; /* hi word */ + DLword nshost1; + DLword nshost0; /* hi word */ + DLword mdszone; + DLword nshost2; /* hi word */ + DLword emubuffers; + DLword mdszonelength; /* hi word */ +#ifdef NEW_STORAGE + DLword ex_process_size; + DLword emubuflength; /* hi word */ + DLword isfmap; + DLword storagefullstate; /* hi word */ +#else + DLword lastnumchars; + DLword emubuflength; /* hi word */ + DLword isfmap; + DLword sys_disk; /* hi word */ +#endif /* NEW_STORAGE */ + /* these are for \miscapply + * -- note that they are not ref counted, so don't pass the only pointer + * to something this way */ + LispPTR miscstackfn; + LispPTR miscstackarg1; + LispPTR miscstackarg2; + LispPTR miscstackresult; + DLword lastlockedfilepage; + DLword nrealpages; /* hi word */ + DLword fptovpstart; + DLword lastdominofilepage; /* hi word */ + DLword dl24bitaddressable; + DLword fakemousebits; /* hi word */ + LispPTR realpagetableptr; + DLword fullspaceused; + DLword ex_dllastvmempage; /* hi word */ + DLword fakekbdad5; + DLword fakekbdad4; /* hi word */ + DLword d1nil1; + DLword dlnil2; + DLword dlnil3; + DLword dlnil4; + DLword dlnil5; + DLword dlnil6; + LispPTR dlnilp1; + LispPTR dlnilp2; + LispPTR dlnilp3; + int dllastvmempage; + int nactivepages; + int ndirtypages; + int process_size; /* was lastnumchars */ +} IFPAGE; +#else + /***********************************************************/ + /* Byte-swapped/word-swapped version, for 386i */ + /***********************************************************/ +typedef struct ifpage { + DLword resetfxp; + DLword currentfxp; /* hi word */ + DLword kbdfxp; + DLword subovfxp; /* hi word */ + DLword gcfxp; + DLword hardreturnfxp; /* hi word */ + DLword endofstack; + DLword faultfxp; /* hi word */ + DLword minrversion; + DLword lversion; /* hi word */ + DLword rversion; + DLword minbversion; /* hi word */ + DLword machinetype; + DLword bversion; /* hi word */ + DLword key; + DLword miscfxp; /* hi word */ + DLword emulatorspace; + DLword serialnumber; /* hi word */ + DLword nxtpmaddr; + DLword screenwidth; /* hi word */ + DLword ndirtypages; + DLword nactivepages; /* hi word */ + DLword filepnpmt0; + DLword filepnpmp0; /* hi word */ + DLword filler1; + DLword teleraidfxp; /* hi word */ + DLword filler3; + DLword filler2; /* hi word */ + DLword userpswdaddr; + DLword usernameaddr; /* hi word */ + DLword faulthi; + DLword stackbase; /* hi word */ + DLword devconfig;/*wasrealpagetable;*/ + DLword faultlo; /* hi word */ + DLword rpoffset; + DLword rptsize; /* hi word */ + DLword embufvp; + DLword wasrptlast; /* hi word */ + DLword nshost1; + DLword nshost0; /* hi word */ + DLword mdszone; + DLword nshost2; /* hi word */ + DLword emubuffers; + DLword mdszonelength; /* hi word */ +#ifdef NEW_STORAGE + DLword process_size; + DLword emubuflength; /* hi word */ + DLword isfmap; + DLword storagefullstate; /* hi word */ +#else + DLword lastnumchars; + DLword emubuflength; /* hi word */ + DLword isfmap; + DLword sys_disk; /* hi word */ +#endif /* NEW_STORAGE */ + /* these are for \miscapply + * -- note that they are not ref counted, so don't pass the only pointer + * to something this way */ + LispPTR miscstackfn; + LispPTR miscstackarg1; + LispPTR miscstackarg2; + LispPTR miscstackresult; + DLword lastlockedfilepage; + DLword nrealpages; /* hi word */ + DLword fptovpstart; + DLword lastdominofilepage; /* hi word */ + DLword dl24bitaddressable; + DLword fakemousebits; /* hi word */ + LispPTR realpagetableptr; + DLword fullspaceused; + DLword dllastvmempage; /* hi word */ + DLword fakekbdad5; + DLword fakekbdad4; /* hi word */ +} IFPAGE; +#endif /* BIGVM */ +#endif /* BYTESWAP */ +#endif diff --git a/inc/initatms.h b/inc/initatms.h new file mode 100755 index 0000000..943f9cc --- /dev/null +++ b/inc/initatms.h @@ -0,0 +1,44 @@ +/* $Id: initatms.h,v 1.2 1999/01/03 02:06:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +/* + * + * Author : Takeshi Shimizu + * Hiroshi Hayata + */ +/*********************************************************/ +/* + File : initatms.h + System ATOMs + + last changed : 5-Mar-87 (take) + 12-Aug-87 take + ** MERGED AT AIS + +*/ +/*********************************************************/ + +#define ATOM_EVALFORM 248 +#define ATOM_GCHANDLEOVERFLOW 249 +#define ATOM_INTERPRETER 256 + +#define ATOM_SMALLP 257 +#define ATOM_FIXP 258 +#define ATOM_FLOATP 259 +#define ATOM_LITATOM 260 +#define ATOM_LISTP 261 +#define ATOM_ARRAYP 262 +#define ATOM_STRINGP 263 +#define ATOM_STACKP 264 +#define ATOM_CHARACTER 265 +#define ATOM_VMEMPAGEP 266 diff --git a/inc/inlineC.h b/inc/inlineC.h new file mode 100755 index 0000000..c4fd376 --- /dev/null +++ b/inc/inlineC.h @@ -0,0 +1,1075 @@ +/* $Id: inlineC.h,v 1.3 1999/01/03 02:06:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* + These are the Macros Used to generate inline c code. + These are the goto ni definitions of the opcodes. +*/ + +/************************************************************************/ +/* */ +/* Macros for fetching bytes & words PC-relative */ +/* */ +/* These are this way so that they can be redefined for the 386i, */ +/* where it makes a difference in speed if you know in advance. */ +/* */ +/************************************************************************/ + +#define Get_BYTE_PCMAC0 Get_BYTE(PCMAC) +#define Get_BYTE_PCMAC1 Get_BYTE(PCMAC+1) +#define Get_BYTE_PCMAC2 Get_BYTE(PCMAC+2) +#define Get_BYTE_PCMAC3 Get_BYTE(PCMAC+3) + +#define Get_DLword_PCMAC0 Get_DLword(PCMAC) +#define Get_DLword_PCMAC1 Get_DLword(PCMAC+1) +#define Get_DLword_PCMAC2 Get_DLword(PCMAC+2) +#define Get_DLword_PCMAC3 Get_DLword(PCMAC+3) + +#define Get_Pointer_PCMAC0 +#define Get_Pointer_PCMAC1 Get_Pointer(PCMAC + 1) +#define Get_Pointer_PCMAC2 Get_Pointer(PCMAC + 2) + + /* For getting a signed byte */ +#define Get_SBYTE_PCMAC0 GETBYTE((s_char *)PCMAC) +#define Get_SBYTE_PCMAC1 GETBYTE((s_char *)PCMAC+1) + + /* for getting an atom number, e.g., for FNx or DTEST */ +#ifdef BIGATOMS +#define Get_AtomNo_PCMAC1 Get_Pointer_PCMAC1 +#define Get_AtomNo_PCMAC2 Get_Pointer_PCMAC2 +#ifdef BIGVM +#define nextop_atom nextop5 +#define nextop_ptr nextop5 +#else +#define nextop_atom nextop4 +#define nextop_ptr nextop4 +#endif /* BIGVM */ +#else +#define Get_AtomNo_PCMAC1 Get_DLword_PCMAC1 +#define Get_AtomNo_PCMAC2 Get_DLword_PCMAC2 +#define nextop_atom nextop3 +#define nextop_ptr nextop4 +#endif /* BIGATOMS */ + + + + +#define CHECK_INTERRUPT {if((UNSIGNED)CSTKPTR > Irq_Stk_Check) goto check_interrupt;} +#define SWAP_WORDS(x) (((unsigned int)x << 16) | (((unsigned int)x >> 16) & 0xFFFF)) + + +#define NATIVECHECK \ + {if (BCE_CURRENTFX->native) {goto gonative ;} nextop0; } + +#define nextop0 {goto nextopcode; } +#define nextop1 {PCMACL += 1; nextop0; } +#define nextop2 {PCMACL += 2; nextop0; } +#define nextop3 {PCMACL += 3; nextop0; } +#define nextop4 {PCMACL += 4; nextop0; } +#define nextop5 {PCMACL += 5; nextop0; } + +#define OPCAR \ + if (Listp(TOPOFSTACK))\ + {\ + register ConsCell *DATUM68K = (ConsCell *)(Addr68k_from_LADDR(TOPOFSTACK));\ + if (DATUM68K->cdr_code == CDR_INDIRECT)\ + {\ + TOPOFSTACK = ((LispPTR)((ConsCell *)Addr68k_from_LADDR(DATUM68K->car_field))->car_field);\ + nextop1; \ + }\ + else \ + { \ + TOPOFSTACK = ((LispPTR)DATUM68K->car_field);\ + nextop1; \ + } \ + }\ + else if (TOPOFSTACK == NIL_PTR)\ + { nextop1; } \ + else if ( TOPOFSTACK == ATOM_T)\ + { nextop1; } \ + else \ + {\ + goto op_ufn; \ + } /* end of OPCAR */ + +#ifdef NEWCDRCODING +#define OPCDR \ + if (Listp(TOPOFSTACK))\ + {\ +register ConsCell *DATUM68K = (ConsCell *)(Addr68k_from_LADDR(TOPOFSTACK));\ +register int CDRCODEX = DATUM68K->cdr_code;\ + if (CDRCODEX == CDR_NIL) {\ + /* cdr-nil */\ + TOPOFSTACK = (NIL_PTR);\ + nextop1; \ + } \ + else if (CDRCODEX> CDR_ONPAGE) {\ + /* cdr-samepage */\ + TOPOFSTACK = ((TOPOFSTACK) + ((CDRCODEX & 7) << 1));\ + nextop1; \ + } \ + else if (CDRCODEX == CDR_INDIRECT) { /* CDRCODEX < CDR_ONPAGE */\ + /* cdr-indirect */\ + TOPOFSTACK = (cdr ((LispPTR)(DATUM68K->car_field)));\ + nextop1; \ + } \ + else\ + {\ + /* cdr-differentpage */\ + TOPOFSTACK = ((ConsCell *)(Addr68k_from_LADDR \ + ((TOPOFSTACK) + (CDRCODEX << 1)))\ + )->car_field;\ + nextop1; \ + }\ + }\ + else if (TOPOFSTACK == NIL_PTR)\ + { nextop1; } \ + else\ + {\ + goto op_ufn; \ + } /* end of OPCDR */ +#else +#define OPCDR \ + if (Listp(TOPOFSTACK))\ + {\ +register ConsCell *DATUM68K = (ConsCell *)(Addr68k_from_LADDR(TOPOFSTACK));\ +register int CDRCODEX = DATUM68K->cdr_code;\ + if (CDRCODEX == CDR_NIL) {\ + /* cdr-nil */\ + TOPOFSTACK = (NIL_PTR);\ + nextop1; \ + } \ + else if (CDRCODEX> CDR_ONPAGE) {\ + /* cdr-samepage */\ + TOPOFSTACK = (POINTER_PAGEBASE(TOPOFSTACK) + \ + ((CDRCODEX & 127) << 1));\ + nextop1; \ + } \ + else if (CDRCODEX == CDR_INDIRECT) { /* CDRCODEX < CDR_ONPAGE */\ + /* cdr-indirect */\ + TOPOFSTACK = (cdr ((LispPTR)(DATUM68K->car_field)));\ + nextop1; \ + } \ + else\ + {\ + /* cdr-differentpage */\ + TOPOFSTACK = ((ConsCell *)(Addr68k_from_LADDR \ + (POINTER_PAGEBASE(TOPOFSTACK) + (CDRCODEX << 1)))\ + )->car_field;\ + nextop1; \ + }\ + }\ + else if (TOPOFSTACK == NIL_PTR)\ + { nextop1; } \ + else\ + {\ + goto op_ufn; \ + } /* end of OPCDR */ +#endif /* NEWCDRCODING */ + +#define IVARMACRO(x) {PUSH(IVAR[x]); nextop1;} +#define PVARMACRO(x) {PUSH(PVAR[x]); nextop1;} +#define PVARSETMACRO(x) {PVAR[x] = TOPOFSTACK; nextop1;} +#define PVARSETPOPMACRO(x) {PVAR[x] = TOPOFSTACK; POP; nextop1;} +#define PUSHATOM(x) {PUSH(x); nextop1;} + + +#define JUMPMACRO(x) {CHECK_INTERRUPT; PCMACL += x; nextop0;} + +#define FJUMPMACRO(x) {if(TOPOFSTACK != 0) {goto PopNextop1 ; } \ + {CHECK_INTERRUPT; POP; PCMACL += x; nextop0;} \ + } +#define TJUMPMACRO(x) {if(TOPOFSTACK == 0) {goto PopNextop1 ; } \ + {CHECK_INTERRUPT; POP; PCMACL += x; nextop0;} \ + } + +#define GETBASE_N(N) { \ + TOPOFSTACK = \ + (S_POSITIVE | GETWORD((DLword *) \ + Addr68k_from_LADDR((POINTERMASK & TOPOFSTACK) + N)));\ + nextop2; \ + } + +#define GETBASEPTR_N(N) { \ + TOPOFSTACK = \ + ( POINTERMASK & *((LispPTR *) \ + Addr68k_from_LADDR((POINTERMASK & TOPOFSTACK) + N)));\ + nextop2; \ + } +#define PUTBASEBYTE \ + { register int byteoffset; \ + register char *p_data; \ + if(((SEGMASK & TOPOFSTACK) != S_POSITIVE) || \ + ((unsigned short)TOPOFSTACK >= 256)) \ + goto op_ufn; \ + byteoffset = GET_TOS_1; \ + switch( (SEGMASK & byteoffset) ){ \ + case S_POSITIVE: \ + byteoffset &= 0x0000FFFF; \ + break; \ + case S_NEGATIVE: \ + byteoffset |= 0xFFFF0000; \ + break; \ + default: \ + goto op_ufn; \ + /*** if( GetTypeNumber(byteoffset) == TYPE_FIXP ) \ + byteoffset = *((int *)Addr68k_from_LADDR(byteoffset)); \ + else \ + goto op_ufn; ***/ \ + } \ + --CSTKPTRL; \ + p_data = (char*)Addr68k_from_LADDR(POINTERMASK & (POP_TOS_1)) + byteoffset; \ + GETBYTE(p_data) = 0xFF & TOPOFSTACK; \ + nextop1; \ + } + +#define GETBASEBYTE \ + {switch( (SEGMASK & TOPOFSTACK) ){ \ + case S_POSITIVE: \ + TOPOFSTACK &= 0x0000FFFF; \ + break; \ + case S_NEGATIVE: \ + TOPOFSTACK |= 0xFFFF0000; \ + break; \ + default: \ + if( GetTypeNumber(TOPOFSTACK) == TYPE_FIXP ) \ + TOPOFSTACK = *((int *)Addr68k_from_LADDR(TOPOFSTACK)); \ + else \ + goto op_ufn; \ + } \ + TOPOFSTACK = (0xFF & (GETBYTE((char*)Addr68k_from_LADDR((POINTERMASK & (POP_TOS_1))) + TOPOFSTACK))) | S_POSITIVE; \ + nextop1; \ + } + + +#define PUTBASEPTR_N(n) \ + { register int base; \ + base = POINTERMASK & POP_TOS_1; \ + *((LispPTR *)Addr68k_from_LADDR(base + n)) = TOPOFSTACK; \ + TOPOFSTACK = base; \ + nextop2; \ + } + +#define PUTBASE_N(n) \ + { register int base; \ + if (GetHiWord(TOPOFSTACK) != (S_POSITIVE >> 16)) \ + goto op_ufn; \ + base = POINTERMASK & POP_TOS_1; \ + GETWORD((DLword *)Addr68k_from_LADDR(base + n)) = GetLoWord(TOPOFSTACK);\ + TOPOFSTACK = base; \ + nextop2; \ + } + + +#define PVARX(x) { PUSH(GetLongWord((DLword *)PVAR + x)); nextop2; } +#define PVARX_(x) { *((LispPTR *)((DLword *)PVAR+x))=TOPOFSTACK; nextop2;} +#define IVARX(x) { PUSH(GetLongWord((DLword *)IVAR + x)); nextop2; } +#define IVARX_(x) { *((LispPTR *)((DLword *)IVAR+x))=TOPOFSTACK; nextop2;} + +#ifndef BIGATOMS +#define GVAR(x) { PUSH(GetLongWord(Valspace + ((x)<<1))); nextop_atom; } +#elif defined(BIGVM) +#define GVAR(x) \ + { register int tx = x; \ + if (tx & SEGMASK) \ + { \ + PUSH(GetLongWord( \ + Addr68k_from_LADDR((tx)+NEWATOM_VALUE_OFFSET))); \ + } \ + else PUSH(GetLongWord((LispPTR *)AtomSpace + (tx*5) + NEWATOM_VALUE_PTROFF)); \ + \ + nextop_atom; \ + } +#else +#define GVAR(x) \ + { register int tx = x; \ + if (tx & SEGMASK) \ + { \ + PUSH(GetLongWord( \ + Addr68k_from_LADDR((tx)+NEWATOM_VALUE_OFFSET))); \ + } \ + else PUSH(GetLongWord(Valspace + ((tx)<<1))); \ + \ + nextop_atom; \ + } +#endif /* BIGATOMS */ + + + +#define COPY { HARD_PUSH(TOPOFSTACK); nextop1; } + +#define SWAP { register LispPTR temp; \ + temp = GET_TOS_1; \ + GET_TOS_1 = TOPOFSTACK; \ + TOPOFSTACK = temp; \ + nextop1; \ + } + + /*********************************************/ + /* Note: No matter how smart it seems, don't */ + /* AND in POINTERMASK in VAG2, because there */ + /* is code that depends on VAG2 building */ + /* full, 32-bit pointers from 16-bit ints. */ + /*********************************************/ +#define N_OP_VAG2 { TOPOFSTACK = ((GET_TOS_1 << 16) \ + | (0xFFFF & TOPOFSTACK)); CSTKPTRL--; nextop1; } + +#define FN0 { OPFN(0, fn0_args, fn0_xna, fn0_native); } +#define FN1 { OPFN(1, fn1_args, fn1_xna, fn1_native); } +#define FN2 { OPFN(2, fn2_args, fn2_xna, fn2_native); } +#define FN3 { OPFN(3, fn3_args, fn3_xna, fn3_native); } +#define FN4 { OPFN(4, fn4_args, fn4_xna, fn4_native); } +#define FNX { OPFNX; nextop0; } +#define ENVCALL { OP_ENVCALL; nextop0; } +#define RETURN { OPRETURN; nextop0; } +#define APPLY { OPAPPLY;} +#define CHECKAPPLY { OPCHECKAPPLY; nextop1; } + +#define BIN \ +{ \ +register Stream *stream68k; /* stream instance on TOS */ \ +register char *buff68k; /* pointer to BUFF */ \ + \ + if ( GetTypeNumber(TOPOFSTACK) == TYPE_STREAM ) { \ + stream68k=(Stream *) Addr68k_from_LADDR(TOPOFSTACK); \ + if( ( !stream68k->BINABLE ) || \ + ( stream68k->COFFSET >= \ + stream68k->CBUFSIZE ) ) goto op_ufn; \ + \ + /* get BUFFER instance */ \ + buff68k =(char *)Addr68k_from_LADDR(stream68k->CBUFPTR); \ + \ + /* get BYTE data and set it to TOS */ \ + TOPOFSTACK = (S_POSITIVE | \ + (Get_BYTE(buff68k + (stream68k->COFFSET)++)) ); \ + nextop1; \ + } \ + else goto op_ufn; \ +} + +#ifdef RECLAIMINC +#define RECLAIMCELL { TOPOFSTACK = gcreclaimcell(TOPOFSTACK); nextop1; } +#else +#define RECLAIMCELL { goto op_ufn; } +#endif + +#define GCSCAN1 { TOPOFSTACK=gcscan1(TOPOFSTACK & 0xffff); \ + if (TOPOFSTACK) {TOPOFSTACK |= S_POSITIVE; };nextop1;} + +#define GCSCAN2 { TOPOFSTACK=gcscan2(TOPOFSTACK & 0xffff); \ + if (TOPOFSTACK) {TOPOFSTACK |=S_POSITIVE; };nextop1;} + + +#define CONTEXTSWITCH { EXT; OP_contextsw(); RET; \ + /*CHECK_INTERRUPT;*/ CLR_IRQ; \ + NATIVE_NEXTOP0; } + +#define NOP { nextop1; } +#define RESLIST(n) { goto op_ufn; } + +#define FINDKEY(x) \ + { \ + TOPOFSTACK = N_OP_findkey(TOPOFSTACK, x); \ + nextop2; \ + } + +#define RPLPTR(n) \ + { \ + TOPOFSTACK = N_OP_rplptr(POP_TOS_1, TOPOFSTACK, n); \ + nextop2; \ + } + +#define GVAR_(atom_index) \ + { \ + N_OP_gvar_(TOPOFSTACK, atom_index); \ + nextop_atom; \ + } + +#define BIND {register int byte = Get_BYTE_PCMAC1; \ + register int n1; \ + register int n2; \ + register LispPTR *ppvar; \ + register int i; \ + n1 = byte >> 4; \ + n2 = byte & 0xf; \ + ppvar = (LispPTR *)PVAR + 1 + Get_BYTE_PCMAC2; \ + for(i=n1; --i >= 0;){ *--ppvar = NIL_PTR; } \ + if(n2 == 0){ \ + *CSTKPTRL++ = TOPOFSTACK; \ + }else{ \ + *--ppvar = TOPOFSTACK; \ + for(i=1; i= 0 );); \ + value = *CSTKPTR; \ + num = (~value)>>16; \ + ppvar = (LispPTR *)((DLword *)PVAR + 2 + GetLoWord(value));\ + for(i=num; --i >= 0;){*--ppvar = 0xffffffff;} \ + nextop1; \ + } + +#define DUNBIND {register int num; \ + register LispPTR *ppvar; \ + register int i; \ + register LispPTR value; \ + if((int)TOPOFSTACK < 0){ \ + num =(~TOPOFSTACK)>>16; \ + if(num != 0){ \ + ppvar = (LispPTR *)((DLword *)PVAR + 2 + GetLoWord(TOPOFSTACK)); \ + for(i=num; --i >= 0;) { \ + *--ppvar = 0xffffffff; } \ + } \ + }else{ \ + for(; ( ((int)*--CSTKPTRL) >= 0 );); \ + value = *CSTKPTR; \ + num = (~value)>>16; \ + ppvar = (LispPTR *)((DLword *)PVAR + 2 + GetLoWord(value));\ + for(i=num; --i >= 0;) { \ + *--ppvar = 0xffffffff; } \ + } \ + POP; \ + nextop1; \ + } + +#define N_OP_HILOC \ + { \ + TOPOFSTACK = GetHiWord(TOPOFSTACK) | S_POSITIVE; \ + nextop1; \ + } +#define N_OP_LOLOC \ + { \ + TOPOFSTACK = GetLoWord(TOPOFSTACK) | S_POSITIVE; \ + nextop1; \ + } + +#define GETBITS_N_M(a, b) \ + {register int temp, bb = b; \ + temp = 0xF & bb; \ + TOPOFSTACK = S_POSITIVE | \ + (( (GETWORD(Addr68k_from_LADDR(POINTERMASK & (TOPOFSTACK+a)))) \ + >> (16 - ( (0xF & (bb >> 4)) + temp + 1)) ) \ + & n_mask_array[temp] ); \ + nextop3; \ + } + +#define PUTBITS_N_M(a, b) \ + { int base; \ + register int bb = b; \ + register DLword *pword; \ + register int shift_size, field_size, fmask; \ + if( (SEGMASK & TOPOFSTACK) != S_POSITIVE ){ goto op_ufn; }; \ + base = POINTERMASK & POP_TOS_1; \ + pword = (DLword*)Addr68k_from_LADDR( base + a ); \ + field_size = 0xF & bb; \ + shift_size = 15 - (0xF & (bb >> 4)) - field_size; \ + fmask = n_mask_array[field_size] << shift_size; \ + GETWORD(pword) = ( (TOPOFSTACK << shift_size) & fmask) | \ + (GETWORD(pword) & (~fmask)); \ + TOPOFSTACK = base; \ + nextop3; \ + } + + +#define CONS \ + { TOPOFSTACK = N_OP_cons(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + +#define MYALINK \ + { \ + PUSH(((( CURRENTFX->alink) & 0xfffe)-FRAMESIZE) | S_POSITIVE); \ + nextop1; \ + } + +#define MYARGCOUNT \ + { register UNSIGNED arg_num; \ + if (( CURRENTFX->alink & 1) == 0) \ + arg_num = (UNSIGNED)((LispPTR *)(CURRENTFX) - 1); \ + else \ + arg_num = (UNSIGNED)(Stackspace + CURRENTFX->blink); \ + PUSH( (DLword)((arg_num - (UNSIGNED)IVar) >> 2) | S_POSITIVE); \ + nextop1; \ + } + +#define RCLK \ + { \ + TOPOFSTACK = N_OP_rclk(TOPOFSTACK); \ + nextop1; \ + } + +#define LISTP { \ + if((DLword)GetTypeNumber(TOPOFSTACK) != TYPE_LISTP)\ + TOPOFSTACK = NIL_PTR; \ + nextop1; \ + } + +#define NTYPEX \ + { \ + TOPOFSTACK = S_POSITIVE | (DLword)(GetTypeNumber(TOPOFSTACK));\ + nextop1; \ + } + +#define TYPEP(n) \ + { \ + if((DLword)GetTypeNumber(TOPOFSTACK) != n) \ + TOPOFSTACK = NIL_PTR; \ + nextop2; \ + } + +#define TYPEMASK(n) \ + { \ + if( ( ((DLword)GetTypeEntry(TOPOFSTACK)) & \ + ( (DLword)n << 8)) == 0) \ + TOPOFSTACK = NIL_PTR; \ + nextop2; \ + } + +#define INSTANCEP(atom_index) \ + { \ + TOPOFSTACK = N_OP_instancep(TOPOFSTACK,atom_index); \ + nextop_atom; \ + } + +#define STOREN(n) \ + { *(CSTKPTR - ((n+2) >> 1)) = TOPOFSTACK; \ + nextop2; \ + } + +#define COPYN(n) \ + { PUSH(*(CSTKPTR - ((n+2) >> 1))); \ + nextop2; \ + } + +#define POPN(n) \ + {TOPOFSTACK = *(CSTKPTRL -= ((n)+1)); \ + nextop2; \ + } + +#define CLARITHEQUAL { \ +register int arg2; \ + SV; arg2 = POP_TOS_1; \ + if ((TOPOFSTACK & SEGMASK) == S_POSITIVE) \ + { \ + if (arg2 == TOPOFSTACK) {TOPOFSTACK = ATOM_T; nextop1;} \ + if ((arg2 & SEGMASK) == S_POSITIVE) {TOPOFSTACK = NIL; nextop1;} \ + } \ + N_OP_POPPED_CALL_2(N_OP_eqq, arg2); \ +} + +#define S_CHARACTER 0x70000 + +#define AREF1 { \ +LispPTR arrayarg; \ +register LispPTR baseL; \ +register int index; \ +register OneDArray *arrayblk; \ +DLword *createcell68k(); \ + SV; arrayarg = POP_TOS_1; \ + if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) goto aref_ufn; \ + arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); \ + if ((TOPOFSTACK & SEGMASK) != S_POSITIVE) goto aref_ufn; \ + index = TOPOFSTACK & 0xFFFF; \ + if (index >= arrayblk->totalsize) goto aref_ufn; \ + index += arrayblk->offset; \ + baseL = arrayblk->base; \ + switch (arrayblk->typenumber) { \ + case 38: /* pointer : 32 bits */ \ + TOPOFSTACK = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + nextop1; \ + case 20: /* signed : 16 bits */ \ + TOPOFSTACK = (GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF; \ + if (TOPOFSTACK & 0x8000) TOPOFSTACK |= S_NEGATIVE; \ + else TOPOFSTACK |= S_POSITIVE; \ + nextop1; \ + case 67: /* Character : 8 bits */ \ + TOPOFSTACK = S_CHARACTER | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF); \ + nextop1; \ + case 22: /* signed : 32 bits */ \ + TOPOFSTACK = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + switch(TOPOFSTACK & 0xFFFF0000){ \ + case 0: \ + TOPOFSTACK |= S_POSITIVE; \ + break; \ + case (unsigned)0xFFFF0000: \ + TOPOFSTACK &= S_NEGATIVE; \ + break; \ + default:{register DLword *wordp; \ + wordp = createcell68k(TYPE_FIXP); \ + *((int *)wordp) = TOPOFSTACK; \ + TOPOFSTACK = (LispPTR)LADDR_from_68k(wordp); \ + } \ + } \ + nextop1; \ + case 0: /* unsigned : 1 bit per element */ \ + TOPOFSTACK = S_POSITIVE | (((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + (index >> 3))) >> (7 - (index & 7))) & 1); \ + nextop1; \ + case 3: /* unsigned : 8 bits per element */ \ + TOPOFSTACK = S_POSITIVE | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF); \ + nextop1; \ + case 4: /* unsigned : 16 bits per element */ \ + TOPOFSTACK = S_POSITIVE | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF); \ + nextop1; \ + case 54: /* Float : 32 bits */{register DLword *wordp; \ + wordp = createcell68k(TYPE_FLOATP); \ + *((int *)wordp) = *(((int *)Addr68k_from_LADDR(baseL)) + index);\ + TOPOFSTACK = (LispPTR)LADDR_from_68k(wordp); \ + } \ + nextop1; \ + case 68: /* Character : 16 bits */ \ + TOPOFSTACK = S_CHARACTER | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF); \ + nextop1; \ + case 86: /* XPointer : 32 bits */ \ + TOPOFSTACK = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + nextop1; \ + default: /* Illegal or Unimplemented */ \ + goto aref_ufn; \ + }/* end switch typenumber */ \ +aref_ufn: \ + N_OP_POPPED_CALL_2(N_OP_aref1, arrayarg); \ +} + +#ifdef BIGVM +#define DTEST(n) \ +{ \ + register int atom_index; \ + register struct dtd *dtd68k ; \ + atom_index = n; \ + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(TOPOFSTACK)); \ + atom_index != dtd68k->dtd_name ; \ + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) \ + { \ + if( dtd68k->dtd_supertype == 0) \ + { \ + goto op_ufn; \ + } \ + } \ +nextop_atom; \ +} +#else /* BIGVM */ +#define DTEST(n) \ +{ \ + register int atom_index; \ + register struct dtd *dtd68k ; \ + atom_index = n; \ + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(TOPOFSTACK)); \ + atom_index != dtd68k->dtd_namelo +((int)(dtd68k->dtd_namehi)<<16) ; \ + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) \ + { \ + if( dtd68k->dtd_supertype == 0) \ + { \ + goto op_ufn; \ + } \ + } \ +nextop_atom; \ +} +#endif /* BIGVM */ + +#define FVAR(n) { \ +register LispPTR *chain; \ +chain = (LispPTR *) (PVar + n); \ +if(WBITSPTR(chain)->LSB){ \ + PUSH(GetLongWord(Addr68k_from_LADDR( \ + POINTERMASK & SWAP_WORDS(native_newframe(n >> 1))))); \ + nextop1; \ + }/* if(((WBITS */ \ +PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \ +nextop1; \ +} + +#define FVARX(n) { \ +register int nn = n; \ +register LispPTR *chain; \ +chain = (LispPTR *) (PVar + nn); \ +if(WBITSPTR(chain)->LSB){ \ + PUSH(GetLongWord(Addr68k_from_LADDR( \ + POINTERMASK & SWAP_WORDS(native_newframe(nn >> 1))))); \ + nextop2; \ + }/* if(((WBITS */ \ +PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \ +nextop2; \ +} + + +/* ******************************************************************** */ +/* THE FOLLOWING WAS IN n_op_inlinedefsC.h */ +/* ******************************************************************** */ + +#define GCREF(n) { \ + GCLOOKUPV(TOPOFSTACK, n, TOPOFSTACK); \ + nextop2;} + +#ifndef BIGATOMS +#define ATOMCELL_N(n) \ + {if ((unsigned int)TOPOFSTACK >> 16) {goto op_ufn;} \ + TOPOFSTACK = (n << 16) + (TOPOFSTACK << 1) ; \ + nextop2; \ + } +#elif defined(BIGVM) +#define ATOMCELL_N(n) \ + { register int nn = n; \ + if (0==((unsigned int)(TOPOFSTACK&= POINTERMASK) & SEGMASK)) \ + { /* old-symbol case; just add cell-number arg */ \ + switch (nn) \ + { \ + case PLIS_HI: /* PLIST entry for symbol */ \ + TOPOFSTACK = (ATOMS_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_PLIST_OFFSET; \ + break; \ + case PNP_HI: /* PNAME entry for symbol */ \ + TOPOFSTACK = (ATOMS_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_PNAME_OFFSET; \ + break; \ + case VALS_HI: /* VALUE cell for symbol */ \ + TOPOFSTACK = (ATOMS_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_VALUE_OFFSET; \ + break; \ + case DEFS_HI: /* DEFINITION for symbol */ \ + TOPOFSTACK = (ATOMS_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_DEFN_OFFSET; \ + break; \ + default: goto op_ufn; \ + } \ + nextop2; \ + } \ + else if (TYPE_NEWATOM == GetTypeNumber(TOPOFSTACK)) \ + { /* NEW-symbol case; it's an offset from the main ptr */ \ + switch (nn) \ + { \ + case PLIS_HI: /* PLIST entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PLIST_OFFSET; \ + break; \ + case PNP_HI: /* PNAME entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PNAME_OFFSET; \ + break; \ + case VALS_HI: /* VALUE cell for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_VALUE_OFFSET; \ + break; \ + case DEFS_HI: /* DEFINITION for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_DEFN_OFFSET; \ + break; \ + default: goto op_ufn; \ + } \ + nextop2; \ + } \ + else goto op_ufn; \ + } +#else /* */ + +#define ATOMCELL_N(n) \ + { register int nn = n; \ + if (0==((unsigned int)TOPOFSTACK & SEGMASK)) \ + { /* old-symbol case; just add cell-number arg */ \ + TOPOFSTACK = (nn << 16) + (TOPOFSTACK << 1) ; \ + nextop2; \ + } \ + else if (TYPE_NEWATOM == GetTypeNumber(TOPOFSTACK)) \ + { /* NEW-symbol case; it's an offset from the main ptr */ \ + switch (nn) \ + { \ + case PLIS_HI: /* PLIST entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PLIST_OFFSET; \ + break; \ + case PNP_HI: /* PNAME entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PNAME_OFFSET; \ + break; \ + case VALS_HI: /* VALUE cell for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_VALUE_OFFSET; \ + break; \ + case DEFS_HI: /* DEFINITION for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_DEFN_OFFSET; \ + break; \ + default: goto op_ufn; \ + } \ + nextop2; \ + } \ + else goto op_ufn; \ + } +#endif /* BIGATOMS */ + + +#define DIFFERENCE {N_OP_CALL_2(N_OP_difference);} +#define LOGOR {N_OP_CALL_2(N_OP_logor);} +#define LOGAND {N_OP_CALL_2(N_OP_logand);} +#define LOGXOR {N_OP_CALL_2(N_OP_logxor);} +#define PLUS2 {N_OP_CALL_2(N_OP_plus2);} +#define QUOTIENT {N_OP_CALL_2(N_OP_quot);} +#define TIMES2 {N_OP_CALL_2(N_OP_times2);} +#define GREATERP {N_OP_CALL_2(N_OP_greaterp);} +#define IDIFFERENCE {N_OP_CALL_2(N_OP_idifference);} +#define IPLUS2 {N_OP_CALL_2(N_OP_iplus2);} +#define IQUOTIENT {N_OP_CALL_2(N_OP_iquot);} +#define ITIMES2 {N_OP_CALL_2(N_OP_itimes2);} +#define IGREATERP {N_OP_CALL_2(N_OP_igreaterp);} +#define IREMAINDER {N_OP_CALL_2(N_OP_iremainder);} +#define IPLUS_N(n) {N_OP_CALL_1d(N_OP_iplusn, n)} +#define IDIFFERENCE_N(n) {N_OP_CALL_1d(N_OP_idifferencen, n);} +#define BOXIPLUS {N_OP_CALL_2(N_OP_boxiplus);} +#define BOXIDIFFERENCE {N_OP_CALL_2(N_OP_boxidiff);} +#define FPLUS2 {N_OP_CALL_2(N_OP_fplus2);} +#define FDIFFERENCE {N_OP_CALL_2(N_OP_fdifference);} +#define FTIMES2 {N_OP_CALL_2(N_OP_ftimes2);} +#define FQUOTIENT {N_OP_CALL_2(N_OP_fquotient);} +#define FGREATERP {N_OP_CALL_2(N_OP_fgreaterp);} +#define UBFLOAT1(n) {N_OP_UNBOXED_CALL_1d(N_OP_ubfloat1, n);} +#define UBFLOAT2(n) {N_OP_UNBOXED_CALL_2d(N_OP_ubfloat2, n);} +#define UBFLOAT3(n) {N_OP_UNBOXED_CALL_3d(N_OP_ubfloat3, n);} +#define LRSH1 {N_OP_CALL_1(N_OP_lrsh1);} +#define LRSH8 {N_OP_CALL_1(N_OP_lrsh8);} +#define LLSH1 {N_OP_CALL_1(N_OP_llsh1);} +#define LLSH8 {N_OP_CALL_1(N_OP_llsh8);} +#define LSH {N_OP_CALL_2(N_OP_lsh);} +#define RPLACA {N_OP_CALL_2(N_OP_rplaca);} +#define RPLACD {N_OP_CALL_2(N_OP_rplacd);} +#define RPLCONS {N_OP_CALL_2(N_OP_rplcons);} +#define MAKENUMBER {N_OP_CALL_2(N_OP_makenumber);} +#define EQLOP {N_OP_CALL_2(N_OP_eqlop);} +#define CLEQUAL {N_OP_CALL_2(N_OP_clequal);} +#define ILEQUAL {N_OP_CALL_2(N_OP_equal);} +#define CLFMEMB {N_OP_CALL_exception_2(N_OP_clfmemb);} +#define CLASSOC {N_OP_CALL_exception_2(N_OP_classoc);} +#define FMEMB {N_OP_CALL_exception_2(N_OP_fmemb);} +#define ASSOC {N_OP_CALL_exception_2(N_OP_assoc);} +#define ARG0 {N_OP_CALL_1(N_OP_arg0);} +#define LISTGET {N_OP_CALL_exception_2C(N_OP_listget);} +#define DRAWLINE {N_OP_CALL_9(N_OP_drawline);} +#define N_OP_ADDBASE {N_OP_CALL_2(N_OP_addbase);} + +#define UNWIND(n, m) \ + { \ + if ((INT)(CSTKPTRL = (LispPTR *) \ + N_OP_unwind(CSTKPTR, TOPOFSTACK, n, m)) < 0) \ + goto unwind_err; \ + POP; \ + nextop3; \ + } + +#define STKSCAN \ + {TOPOFSTACK = N_OP_stkscan(TOPOFSTACK); \ + nextop1; \ + } + +#define FVARX_(n) \ + {TOPOFSTACK = N_OP_fvar_(TOPOFSTACK, n); \ + nextop2; \ + } + +#define BLT {N_OP_CALL_3(N_OP_blt);} + +#define PILOTBITBLT \ + {TOPOFSTACK = N_OP_pilotbitblt(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + +#define CREATECELL {N_OP_CALL_1(N_OP_createcell);} + +#define RESTLIST(n) {TOPOFSTACK = N_OP_restlist(POP_TOS_1, TOPOFSTACK, n);\ + nextop2;} + + +#define ASET1 {N_OP_CALL_3(N_OP_aset1);} +#define ASET2 {N_OP_CALL_4(N_OP_aset2);} +#define MISC3(n) {N_OP_CALL_3d(N_OP_misc3, n);} +#define MISC4(n) {N_OP_CALL_4d(N_OP_misc4, n);} +#define MISC7(n) {N_OP_CALL_7d(N_OP_misc7, n);} +#define AREF2 {N_OP_CALL_3(N_OP_aref2);} +#define MISCN(index, args) \ +{ EXT; \ + if (OP_miscn(index,args)) { \ + RET; \ + /* PUSH(S_POSITIVE | (index << 8) | args); */ \ + goto op_ufn; \ + } \ + RET; \ + nextop0; \ +} + + +/* ******************************************************************** */ +/* Call Interface where -1 indicates an error return */ +/* ******************************************************************** */ + +/* SV need do no work */ +#define SV + +/* UFN_CALLS are inserted in xc.c. Note that only ufn_2 calls have decremented the stack at the time the UFN is called */ + +/* ufn_x there are x args from the Lisp stack + ufn_xd there are x args from the Lisp stack & + some from the code stream. +*/ +#define UFN_CALLS \ + \ +unwind_err: \ + CSTKPTRL = (LispPTR *) CurrentStackPTR; \ + Error_Exit = 0; \ + goto op_ufn; \ +ufn_2d: CSTKPTRL += 1; \ + goto fix_tos_ufn; \ +ufn_2d2:CSTKPTRL += 1; \ + goto fix_tos_ufn; \ +ufn_2: CSTKPTRL += 1; \ + goto fix_tos_ufn; \ +exception_2 : \ + Error_Exit = 0; \ + CSTKPTRL += 1; \ + TOPOFSTACK = TopOfStack; \ + if(!Irq_Stk_End){ \ + goto check_interrupt; \ + } \ + else goto op_ufn; \ +exception_2C : \ + Error_Exit = 0; \ + TOPOFSTACK = TopOfStack; \ + *CSTKPTRL = Scratch_CSTK; \ + CSTKPTRL += 1; \ + if(!Irq_Stk_End){ \ + goto check_interrupt; \ + } \ + else { \ + goto op_ufn; \ + } \ +fix_tos_ufn: \ + TOPOFSTACK = TopOfStack; \ + Error_Exit = 0; \ + goto op_ufn; + +#define N_OP_CALL_1(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(TOPOFSTACK)) < 0) goto fix_tos_ufn;\ +nextop1; + + +#define N_OP_CALL_1d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(TOPOFSTACK, n)) < 0) goto fix_tos_ufn;\ +nextop2; + +#define N_OP_UNBOXED_CALL_1d(op_name, n) \ +TOPOFSTACK = op_name(TOPOFSTACK, n); \ +if (Error_Exit) goto fix_tos_ufn; \ +nextop2; + + +#define N_OP_CALL_2(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK)) < 0) \ + goto ufn_2; \ +nextop1; + +#define N_OP_POPPED_CALL_2(op_name, popped_arg) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(popped_arg, TOPOFSTACK)) < 0) \ + goto ufn_2; \ +nextop1; + +#define N_OP_CALL_2d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK, n)) < 0) \ + goto ufn_2d; \ +nextop2; + +#define N_OP_UNBOXED_CALL_2d(op_name, n) \ +TOPOFSTACK = op_name(POP_TOS_1, TOPOFSTACK, n); \ +if (Error_Exit) goto ufn_2d; \ +nextop2; + +#define N_OP_CALL_2d2(op_name, a, b) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK, a, b)) < 0) \ + goto ufn_2d2; \ +nextop3; + +#define N_OP_CALL_exception_2(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK)) < 0) \ + goto exception_2; \ +nextop1; + +#define N_OP_CALL_exception_2C(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK)) < 0) \ + goto exception_2C; \ +nextop1; + +#define N_OP_CALL_3(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 2; \ +nextop1; + +#define N_OP_CALL_3d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 2; \ +nextop2; + +#define N_OP_UNBOXED_CALL_3d(op_name, n) \ +TOPOFSTACK = op_name(*(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n); \ +if (Error_Exit) goto fix_tos_ufn; \ +CSTKPTRL -= 2; \ +nextop2; + + +#define N_OP_CALL_4(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-3), *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 3; \ +nextop1; + + +#define N_OP_CALL_4d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-3), *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 3; \ +nextop2; + +#define N_OP_CALL_7d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-6), *(CSTKPTR-5), *(CSTKPTR-4), \ + *(CSTKPTR-3), *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 6; \ +nextop2; + + + +#define N_OP_CALL_9(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-8), *(CSTKPTR-7), *(CSTKPTR-6), \ + *(CSTKPTR-5), *(CSTKPTR-4), *(CSTKPTR-3), *(CSTKPTR-2),\ + *(CSTKPTR-1), TOPOFSTACK /*, fix_tos_ufn*/)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 8; \ +nextop1; + + +#ifdef SUN3_OS3_OR_OS4_IL + +/* need jump point for inline asm code, e.g., for IPLUS */ + +#define OPCODEFAIL \ + \ +fixtos1: \ + fixtos1_label(); \ + FIXTOS1; \ + goto op_ufn; + +#else + +/* no opcode fail point necessary */ + +#define OPCODEFAIL + +#endif diff --git a/inc/inln386i.h b/inc/inln386i.h new file mode 100755 index 0000000..4f4baaf --- /dev/null +++ b/inc/inln386i.h @@ -0,0 +1,261 @@ +/* $Id: inln386i.h,v 1.2 1999/01/03 02:06:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* inlinedefs386i.c */ +/* */ +/* Dispatch-loop macro devinitions specific to the Sun386i */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + /* use the swapx [inline] function to swap words in a dword */ +#undef SWAP_WORDS +#define SWAP_WORDS(x) swapx(x) + + + /* undefine these macros so we use the 386i inline code */ +#undef Get_BYTE_PCMAC0 +#undef Get_BYTE_PCMAC1 +#undef Get_BYTE_PCMAC2 +#undef Get_BYTE_PCMAC3 + +#undef Get_DLword_PCMAC0 +#undef Get_DLword_PCMAC1 +#undef Get_DLword_PCMAC2 +#undef Get_DLword_PCMAC3 + +#define Get_BYTE_PCMAC0 Get_BYTE_PCMAC0fn() +#define Get_BYTE_PCMAC1 Get_BYTE_PCMAC1fn() +#define Get_BYTE_PCMAC2 Get_BYTE_PCMAC2fn() +#define Get_BYTE_PCMAC3 Get_BYTE_PCMAC3fn() + +#define Get_DLword_PCMAC0 Get_DLword_PCMAC0fn() +#define Get_DLword_PCMAC1 Get_DLword_PCMAC1fn() +#define Get_DLword_PCMAC2 Get_DLword_PCMAC2fn() +#define Get_DLword_PCMAC3 Get_DLword_PCMAC3fn() + +#undef DIFFERENCE +#undef PLUS2 +#undef IDIFFERENCE +#undef IPLUS2 + +#define DIFFERENCE { \ + fast_op_difference(POP_TOS_1); \ + nextop1; \ +diff_err: \ + asm("diff_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + asm("popl %ecx"); \ + N_OP_POPPED_CALL_2(N_OP_difference, GET_POPPED); \ + } +#define IDIFFERENCE { \ + fast_op_idifference(POP_TOS_1); \ + nextop1; \ +idiff_err: \ + asm("idiff_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + asm("popl %ecx"); \ + N_OP_POPPED_CALL_2(N_OP_idifference, GET_POPPED); \ + } +#define IDIFFERENCE_N(n) { \ + fast_op_idifferencen(n); \ + nextop2; \ +idiffn_err: \ + asm("idiffn_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + asm("popl %ecx"); \ + N_OP_CALL_1d(N_OP_idifferencen, n); \ + } + +#define PLUS2 { \ + fast_op_plus(POP_TOS_1); \ + nextop1; \ +plus_err: \ + asm("plus_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + asm("popl %ecx"); \ + N_OP_POPPED_CALL_2(N_OP_plus2, GET_POPPED); \ + } + +#define IPLUS2 { \ + fast_op_iplus(POP_TOS_1); \ + nextop1; \ +iplus_err: \ + asm("iplus_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + asm("popl %ecx"); \ + N_OP_POPPED_CALL_2(N_OP_iplus2, GET_POPPED); \ + } +#define IPLUS_N(n) { \ + fast_op_iplusn(n); \ + nextop2; \ +iplusn_err: \ + asm("iplusn_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + asm("popl %ecx"); \ + N_OP_CALL_1d(N_OP_iplusn, n); \ + } + +#undef GREATERP +#define GREATERP { \ + fast_op_greaterp(POP_TOS_1); \ + nextop1; \ +greaterp_err: \ + asm("greaterp_err: popl %ecx"); \ + N_OP_POPPED_CALL_2(N_OP_greaterp, GET_POPPED); \ + } + +#undef IGREATERP +#define IGREATERP { \ + fast_op_igreaterp(POP_TOS_1); \ + nextop1; \ +igreaterp_err: \ + asm("igreaterp_err: popl %ecx"); \ + N_OP_POPPED_CALL_2(N_OP_igreaterp, GET_POPPED); \ + } + + +#undef LRSH8 +#define LRSH8 { \ + fast_op_lrsh8(); \ + nextop1; \ +lrsh8_err: \ + asm("lrsh8_err: "); \ + N_OP_CALL_1(N_OP_lrsh8); \ + } + +#undef LRSH1 +#define LRSH1 { \ + fast_op_lrsh1(); \ + nextop1; \ +lrsh1_err: \ + asm("lrsh1_err: "); \ + N_OP_CALL_1(N_OP_lrsh1); \ + } + +#undef LLSH8 +#define LLSH8 { \ + fast_op_llsh8(); \ + nextop1; \ +llsh8_err: \ + asm("llsh8_err: "); \ + N_OP_CALL_1(N_OP_llsh8); \ + } + +#undef LLSH1 +#define LLSH1 { \ + fast_op_llsh1(); \ + nextop1; \ +llsh1_err: \ + asm("llsh1_err: "); \ + N_OP_CALL_1(N_OP_llsh1); \ + } + + +#undef LOGOR +#define LOGOR { \ + fast_op_logor(POP_TOS_1); \ + nextop1; \ +logor_err: \ + asm("logor_err: popl %ecx"); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_logor, GET_POPPED); \ + } + +#undef LOGAND +#define LOGAND { \ + fast_op_logand(POP_TOS_1); \ + nextop1; \ +logand_err: \ + asm("logand_err: popl %ecx"); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_logand, GET_POPPED); \ + } + +#undef LOGXOR +#define LOGXOR { \ + fast_op_logxor(POP_TOS_1); \ + nextop1; \ +logxor_err: \ + asm("logxor_err: popl %ecx"); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_logxor, GET_POPPED); \ + } + +#undef N_OP_ADDBASE +#define N_OP_ADDBASE { \ + fast_op_addbase(POP_TOS_1); \ + nextop1; \ +addbase_err: \ + asm("addbase_err: popl %ecx"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_addbase, GET_POPPED); \ + } + + +#undef N_OP_LOLOC +#define N_OP_LOLOC { fast_op_loloc(); nextop1; } +#undef N_OP_HILOC +#define N_OP_HILOC { fast_op_hiloc(); nextop1; } + +#undef N_OP_VAG2 +#define N_OP_VAG2 \ + { \ + asm(" subl $4,%esi"); \ + asm(" movl (%esi),%eax"); \ + asm(" roll $16,%ebx"); \ + asm(" movw %ax,%bx"); \ + asm(" rorl $16,%ebx"); \ + nextop1; } + + +/***********/ +/* Fast function call */ + +#undef FN0 +#define FN0 fast_FN0() + +#undef FN1 +#define FN1 fast_FN1() + +#undef FN2 +#define FN2 fast_FN2() + +#undef FN3 +#define FN3 fast_FN3() + +#undef FN4 +#define FN4 fast_FN4() + +#undef FN5 +#define FN5 fast_FN5() + +#undef FN6 +#define FN6 fast_FN6() + +#undef FN7 +#define FN7 fast_FN7() + +#undef FN8 +#define FN8 fast_FN8() + +#undef FN9 +#define FN9 fast_FN9() + diff --git a/inc/inln68k+.h b/inc/inln68k+.h new file mode 100755 index 0000000..c67d2f1 --- /dev/null +++ b/inc/inln68k+.h @@ -0,0 +1,200 @@ +/* $Id: inln68k+.h,v 1.2 1999/01/03 02:06:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +/* These are the Macros Used to generate inline 68K assembly code. + The call inline code which really CHEATS! + BEWARE the inline code makes many register assumptions! + Such as: + D7 = TOPOFSTACK + D5 = 15 + A3 = CSTKPTR +*/ + +#undef DIFFERENCE +#define DIFFERENCE { \ + fast_op_difference(POP_TOS_1); \ + nextop1; \ +diff_err: \ + asm("diff_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_difference, GET_POPPED); \ + } + +#undef IDIFFERENCE +#define IDIFFERENCE { \ + fast_op_idifference(POP_TOS_1); \ + nextop1; \ +idiff_err: \ + asm("idiff_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_idifference, GET_POPPED); \ + } + +#undef IDIFFERENCE_N +#define IDIFFERENCE_N(n) { \ + fast_op_idifferencen(n); \ + nextop2; \ +idiffn_err: \ + asm("idiffn_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_CALL_1d(N_OP_idifferencen, n); \ + } + + + +#undef PLUS2 +#define PLUS2 { \ + fast_op_plus(POP_TOS_1); \ + nextop1; \ +plus_err: \ + asm("plus_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_plus2, GET_POPPED); \ + } + +#undef IPLUS2 +#define IPLUS2 { \ + fast_op_iplus(POP_TOS_1); \ + nextop1; \ +iplus_err: \ + asm("iplus_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_iplus2, GET_POPPED); \ + } + +#undef IPLUS_N +#define IPLUS_N(n) { \ + fast_op_iplusn(n); \ + nextop2; \ +iplusn_err: \ + asm("iplusn_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_CALL_1d(N_OP_iplusn, n); \ + } + + + +#undef GREATERP +#define GREATERP { \ + fast_op_greaterp(POP_TOS_1); \ + nextop1; \ +greaterp_err: \ + asm("greaterp_err:"); \ + N_OP_POPPED_CALL_2(N_OP_greaterp, GET_POPPED); \ + } + +#undef IGREATERP +#define IGREATERP { \ + fast_op_igreaterp(POP_TOS_1); \ + nextop1; \ +igreaterp_err: \ + asm("igreaterp_err:"); \ + N_OP_POPPED_CALL_2(N_OP_igreaterp, GET_POPPED); \ + } + + +#undef LRSH8 +#define LRSH8 { \ + fast_op_lrsh8(); \ + nextop1; \ +lrsh8_err: \ + asm("lrsh8_err:"); \ + N_OP_CALL_1(N_OP_lrsh8); \ + } + +#undef LRSH1 +#define LRSH1 { \ + fast_op_lrsh1(); \ + nextop1; \ +lrsh1_err: \ + asm("lrsh1_err:"); \ + N_OP_CALL_1(N_OP_lrsh1); \ + } + +#undef LLSH8 +#define LLSH8 { \ + fast_op_llsh8(); \ + nextop1; \ +llsh8_err: \ + asm("llsh8_err:"); \ + N_OP_CALL_1(N_OP_llsh8); \ + } + +#undef LLSH1 +#define LLSH1 { \ + fast_op_llsh1(); \ + nextop1; \ +llsh1_err: \ + asm("llsh1_err:"); \ + N_OP_CALL_1(N_OP_llsh1); \ + } + + +#undef LOGOR +#define LOGOR { \ + fast_op_logor(POP_TOS_1); \ + nextop1; \ +logor_err: \ + asm("logor_err:"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_logor, GET_POPPED); \ + } + +#undef LOGAND +#define LOGAND { \ + fast_op_logand(POP_TOS_1); \ + nextop1; \ +logand_err: \ + asm("logand_err:"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_logand, GET_POPPED); \ + } + +#undef LOGXOR +#define LOGXOR { \ + fast_op_logxor(POP_TOS_1); \ + nextop1; \ +logxor_err: \ + asm("logxor_err:"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_logxor, GET_POPPED); \ + } + +#undef N_OP_ADDBASE +#define N_OP_ADDBASE { \ + fast_op_addbase(POP_TOS_1); \ + nextop1; \ +addbase_err: \ + asm("addbase_err:"); \ + asm("addqb #7,d7"); \ + asm("rorl d5,d7"); \ + N_OP_POPPED_CALL_2(N_OP_addbase, GET_POPPED); \ + } + + +#undef N_OP_LOLOC +#define N_OP_LOLOC { fast_op_loloc(); nextop1; } +#undef N_OP_HILOC +#define N_OP_HILOC { fast_op_hiloc(); nextop1; } +#undef N_OP_VAG2 +#define N_OP_VAG2 { fast_op_vag2(POP_TOS_1); nextop1; } + + + + diff --git a/inc/inln68k.h b/inc/inln68k.h new file mode 100755 index 0000000..696bb8e --- /dev/null +++ b/inc/inln68k.h @@ -0,0 +1,162 @@ +/* $Id: inln68k.h,v 1.2 1999/01/03 02:06:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +/* inlinedefs68K.h */ +/* Bob Krivacic 2/23/88 */ + +/* These are the Macros used to generate inline 68K assembly code + to implement the opcodes. Used by both dispatch + loop and native code. +*/ + +#undef DIFFERENCE +#undef PLUS2 +#undef GREATERP +#undef IDIFFERENCE +#undef IPLUS2 +#undef IGREATERP +#undef LOGOR +#undef LOGAND +#undef LOGXOR +#undef LRSH8 +#undef LRSH1 +#undef LLSH8 +#undef LLSH1 +#undef N_OP_ADDBASE +#undef N_OP_LOLOC +#undef N_OP_HILOC +#undef N_OP_VAG2 +#undef LISTP +#undef NTYPEX +#undef TYPEP +#undef SWAP_WORDS +/* +#undef FN3 +#undef RETURN +*/ + +#define SWAP_WORDS(x) swapx(x) + +#define DIFFERENCE { \ + TOPOFSTACK = op_difference(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ +diff_err: \ + asm("diff_err:"); \ + N_OP_POPPED_CALL_2(N_OP_difference, GET_POPPED); \ + } + +#define PLUS2 { \ + TOPOFSTACK = op_plus(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ +plus_err: \ + asm("plus_err:"); \ + N_OP_POPPED_CALL_2(N_OP_plus2, GET_POPPED); \ + } + +#define GREATERP { \ + TOPOFSTACK = op_greaterp(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ +greaterp_err: \ + asm("greaterp_err:"); \ + N_OP_POPPED_CALL_2(N_OP_greaterp, GET_POPPED); \ + } + +#define IDIFFERENCE { \ + TOPOFSTACK = op_difference(POP_TOS_1, TOPOFSTACK); \ + } + +#define IPLUS2 { \ + TOPOFSTACK = op_plus(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + +#define IGREATERP { \ + TOPOFSTACK = op_greaterp(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + + +#define LOGOR { \ + TOPOFSTACK = op_logor(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ +logor_err: \ + asm("logor_err:"); \ + N_OP_POPPED_CALL_2(N_OP_logor, GET_POPPED); \ + } + +#define LOGAND { \ + TOPOFSTACK = op_logand(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ +logand_err: \ + asm("logand_err:"); \ + N_OP_POPPED_CALL_2(N_OP_logand, GET_POPPED); \ + } + +#define LOGXOR { \ + TOPOFSTACK = op_logxor(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ +logxor_err: \ + asm("logxor_err:"); \ + N_OP_POPPED_CALL_2(N_OP_logxor, GET_POPPED); \ + } + + +#define LRSH8 { \ + TOPOFSTACK = op_lrsh8(TOPOFSTACK); \ + nextop1; \ +lrsh8_err: \ + asm("lrsh8_err:"); \ + N_OP_CALL_1(N_OP_lrsh8); \ + } + +#define LRSH1 { \ + TOPOFSTACK = op_lrsh1(TOPOFSTACK); \ + nextop1; \ +lrsh1_err: \ + asm("lrsh1_err:"); \ + N_OP_CALL_1(N_OP_lrsh1); \ + } + +#define LLSH8 { \ + TOPOFSTACK = op_llsh8(TOPOFSTACK); \ + nextop1; \ +llsh8_err: \ + asm("llsh8_err:"); \ + N_OP_CALL_1(N_OP_llsh8); \ + } + +#define LLSH1 { \ + TOPOFSTACK = op_llsh1(TOPOFSTACK); \ + nextop1; \ +llsh1_err: \ + asm("llsh1_err:"); \ + N_OP_CALL_1(N_OP_llsh1); \ + } + +#define N_OP_ADDBASE { \ + TOPOFSTACK = addbase(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + + +#define N_OP_LOLOC { TOPOFSTACK = loloc(TOPOFSTACK); nextop1; } +#define N_OP_HILOC { TOPOFSTACK = hiloc(TOPOFSTACK); nextop1; } +#define N_OP_VAG2 { TOPOFSTACK = vag2(POP_TOS_1, TOPOFSTACK); nextop1; } + +#define LISTP { TOPOFSTACK = listp(TOPOFSTACK); nextop1;} +#define NTYPEX { TOPOFSTACK = ntypex(TOPOFSTACK); nextop1; } +#define TYPEP(n) { TOPOFSTACK = typep(TOPOFSTACK, Get_BYTE(PCMAC+1)); nextop2; } + + + + diff --git a/inc/inlnMIPS.h b/inc/inlnMIPS.h new file mode 100755 index 0000000..ff9ada9 --- /dev/null +++ b/inc/inlnMIPS.h @@ -0,0 +1,95 @@ +/* $Id: inlnMIPS.h,v 1.2 1999/01/03 02:06:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* I N L I N E F U N C T I O N S F O R M I P S */ +/* */ +/* These are GCC-style inline asm functions for use when */ +/* compiling Medley for MIPS RISCstations. */ +/* */ +/* JDS 28 Aug 91 Created; no valid defns yet. */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1991 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* R E G I S T E R C O N V E N T I O N S */ +/* */ +/* */ +/************************************************************************/ + +/* Copyright Venue 1991 All rights reserved. */ + +/* inline defs for MIPS */ + + + +extern inline const unsigned int swapx (unsigned int word) + { + asm("roll $16,%0" : "=g" (word) : "0" (word)); + return(word); + } + + + +extern inline const unsigned int word_swap_longword (unsigned int word) + { + asm("roll $16,%0" : "=g" (word) : "0" (word)); + + return(word); + } + + + +extern inline const unsigned short byte_swap_word (unsigned short word) + { + asm("rolw $8,%0" : "=g" (word) : "0" (word)); + + return(word); + } + + + +extern inline const void word_swap_page(unsigned short * page, int count) + { + asm("\ + pushl %ebp \n\ + movl %esp,%ebp \n\ + subl $4,%esp \n\ + pushl %edi \n\ + pushl %esi \n\ + pushl %ebx \n\ + cld \n\ + movl 8(%ebp),%esi // word pointer. \n\ + movl %esi,%edi \n\ + movl 12(%ebp),%ecx // count \n\ + \n\ +$0: lodsl \n\ + rolw $8,%ax \n\ + roll $16,%eax \n\ + rolw $8,%ax \n\ + stosl \n\ + loop $0 \n\ + \n\ + // epilogue. \n\ + leal -16(%ebp),%esp \n\ + popl %ebx \n\ + popl %esi \n\ + popl %edi \n\ + leave \n\ + ret"); + + } diff --git a/inc/inlnPS2.h b/inc/inlnPS2.h new file mode 100755 index 0000000..e9dc258 --- /dev/null +++ b/inc/inlnPS2.h @@ -0,0 +1,1112 @@ +/* $Id: inlnPS2.h,v 1.2 1999/01/03 02:06:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1991, 1992 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* I N L I N E P S 2 . H */ +/* */ +/* INLINE definitions for 386 machines, compiled with gcc. */ +/* */ +/* This file consists of 3 sections: */ +/* */ +/* inline static functions for use anywhere in Medley */ +/* (e.g., the byte-swapping functions) */ +/* */ +/* #defines and static inline functions for the dispatch */ +/* loop (e.g., IDIFFERENCE), relying on the register */ +/* conventions that hold in that part of the code */ +/* */ +/* #defines and static inline functions for other */ +/* specific files (e.g., the arithmetic functions, */ +/* free-variable lookup, etc.), relying on the register */ +/* conventions in the respective files. */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* R E G I S T E R C O N V E N T I O N S */ +/* */ +/* The following register conventions hold in the dispatch loop, */ +/* and are set up by register ... asm("...") decls in xc.c: */ +/* */ +/* esi pccache - the current PC */ +/* edi cspcache - the current lisp stack ptr. */ +/* ebx tscache - the top-of-stack item. */ +/* */ +/* */ +/* Rgister conventions within arithmetic functions in the files */ +/* arith2.c - arith4.c, etc.: */ +/* */ +/* esi first argument to the function */ +/* edi second argument to the function */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* G E N E R A L - P U R P O S E I N L I N E F U N C T I O N S */ +/* */ +/* These functions don't rely on register conventions. */ +/* */ +/************************************************************************/ + + +#undef SWAP_WORDS +#define SWAP_WORDS swapx + + +extern inline const unsigned int swapx (unsigned int word) + { + asm("roll $16,%0" : "=g" (word) : "0" (word)); + return(word); + } + + + +extern inline const unsigned int word_swap_longword (unsigned int word) + { + asm("roll $16,%0" : "=r" (word) : "0" (word)); + + return(word); + } + + + +extern inline const unsigned short byte_swap_word (unsigned short word) + { + asm("rolw $8,%0" : "=r" (word) : "0" (word)); + + return(word); + } + + + +extern inline const void word_swap_page(unsigned short * page, int count) + { + asm volatile("\ + pushl %edi \n\ + pushl %esi \n\ + pushl %ecx \n\ + cld"); + asm volatile(" + movl %0,%%esi // word pointer. \n\ + movl %%esi,%%edi \n\ + movl %1,%%ecx // count" : : "g" (page), "g" (count)); + asm volatile(" + lodsl \n\ + rolw $8,%ax \n\ + roll $16,%eax \n\ + rolw $8,%ax \n\ + stosl \n\ + loop .-13 \n\ + \n\ + // epilogue. \n\ + popl %ecx \n\ + popl %esi \n\ + popl %edi + "); + + } + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + /* undefine these macros so we use the 386i inline code */ + +#undef Get_BYTE_PCMAC0 +#undef Get_BYTE_PCMAC1 +#undef Get_BYTE_PCMAC2 +#undef Get_BYTE_PCMAC3 + +#define Get_BYTE_PCMAC0 Get_BYTE_PCMAC0fn(pccache) +#define Get_BYTE_PCMAC1 Get_BYTE_PCMAC1fn(pccache) +#define Get_BYTE_PCMAC2 Get_BYTE_PCMAC2fn(pccache) +#define Get_BYTE_PCMAC3 Get_BYTE_PCMAC3fn(pccache) + +extern inline const unsigned int Get_BYTE_PCMAC0fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("leal -1(%1),%0 \n\ + xorl $3,%0 \n\ + movzbl (%0),%0 \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + +extern inline const unsigned int Get_BYTE_PCMAC1fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("movl %1,%0 \n\ + xorl $3,%0 \n\ + movzbl (%0),%0 \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + +extern inline const unsigned int Get_BYTE_PCMAC2fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("leal 1(%1),%0 \n\ + xorl $3,%0 \n\ + movzbl (%0),%0 \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + +extern inline const unsigned int Get_BYTE_PCMAC3fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("leal 2(%1),%0 \n\ + xorl $3,%0 \n\ + movzbl (%0),%0 \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + + +#undef Get_DLword_PCMAC0 +#undef Get_DLword_PCMAC1 +#undef Get_DLword_PCMAC2 +#undef Get_DLword_PCMAC3 + + +#define Get_DLword_PCMAC0 Get_DLword_PCMAC0fn(pccache) +#define Get_DLword_PCMAC1 Get_DLword_PCMAC1fn(pccache) +#define Get_DLword_PCMAC2 Get_DLword_PCMAC2fn(pccache) +#define Get_DLword_PCMAC3 Get_DLword_PCMAC3fn(pccache) + +extern inline const unsigned int Get_DLword_PCMAC0fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("movl %1,%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + leal -1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + +extern inline const unsigned int Get_DLword_PCMAC1fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("leal 1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + leal (%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +extern inline const unsigned int Get_DLword_PCMAC2fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("leal 2(%1),%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + leal 1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + +extern inline const unsigned int Get_DLword_PCMAC3fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("leal 3(%1),%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + leal 2(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +#undef Get_Pointer_PCMAC0 +#undef Get_Pointer_PCMAC1 +#undef Get_Pointer_PCMAC2 + +#define Get_Pointer_PCMAC0 Get_Pointer_PCMAC0fn(pccache) +#define Get_Pointer_PCMAC1 Get_Pointer_PCMAC1fn(pccache) +#define Get_Pointer_PCMAC2 Get_Pointer_PCMAC2fn(pccache) + + +extern inline const unsigned int Get_Pointer_PCMAC0fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("leal -1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + shll $16,%%eax \n\ + leal 1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%al \n\ + leal (%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + +extern inline const unsigned int Get_Pointer_PCMAC1fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("leal (%1),%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + shll $16,%%eax \n\ + leal 2(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%al \n\ + leal 1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +extern inline const unsigned int Get_Pointer_PCMAC2fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("leal 1(%1),%%edx \n\ + xorb $3,%%dl \n\ + movzbl (%%edx),%%eax \n\ + shll $16,%%eax \n\ + leal 3(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%al \n\ + leal 2(%1),%%edx \n\ + xorb $3,%%dl \n\ + movb (%%edx),%%ah \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + + +#undef DIFFERENCE +#undef IDIFFERENCE + +#define DIFFERENCE { \ + fast_op_difference(POP_TOS_1); \ + fast1_dispatcher(); \ +diff_err: \ + asm volatile("diff_err:"); \ + asm volatile("addb $7,%bl"); \ + asm volatile("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_difference, GET_POPPED); \ + } + +extern inline const void fast_op_difference(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + subb $7,%%bl \n\ + jne diff_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne diff_err \n\ + subl %%ebx,%%eax \n\ + jo diff_err \n\ + rorl $15,%%eax \n\ + orl $917504,%%eax \n\ + movl %%eax,%%ebx \ + " : : "g" (value) : "ax" ); + + } + +#define IDIFFERENCE { \ + fast_op_idifference(POP_TOS_1); \ + fast1_dispatcher(); \ +idiff_err: \ + asm volatile("idiff_err:"); \ + asm volatile("addb $7,%bl"); \ + asm volatile("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_idifference, GET_POPPED); \ + } + +extern inline const void fast_op_idifference(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + subb $7,%%bl \n\ + jne idiff_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne idiff_err \n\ + subl %%ebx,%%eax \n\ + jo idiff_err \n\ + rorl $15,%%eax \n\ + orl $917504,%%eax \n\ + movl %%eax,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + +#undef IDIFFERENCE_N +#define IDIFFERENCE_N(n) { \ + fast_op_idifferencen(n); \ + fast2_dispatcher(); \ +idiffn_err: \ + asm("idiffn_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + N_OP_CALL_1d(N_OP_idifferencen, n); \ + } + +extern inline const void fast_op_idifferencen(LispPTR value) + { + asm volatile("\ + movl %0,%%eax + roll $15,%%eax + roll $15,%%ebx + subb $7,%%bl + jne idiffn_err + subl %%eax,%%ebx + jo idiffn_err + rorl $15,%%ebx + orl $917504,%%ebx + " : : "g" (value) : "ax" ); + + } + +#undef PLUS2 +#undef IPLUS2 + +#define PLUS2 { \ + fast_op_plus(POP_TOS_1); \ + fast1_dispatcher(); \ +plus_err: \ + asm volatile("plus_err:"); \ + asm volatile("addw $7,%bx"); \ + asm volatile("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_plus2, GET_POPPED); \ + } +extern inline const void fast_op_plus(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + subb $7,%%bl \n\ + jne plus_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne plus_err \n\ + addl %%ebx,%%eax \n\ + jo plus_err \n\ + rorl $15,%%eax \n\ + orl $917504,%%eax \n\ + movl %%eax,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + +#define IPLUS2 { \ + fast_op_iplus(POP_TOS_1); \ + fast1_dispatcher(); \ +iplus_err: \ + asm volatile("iplus_err:"); \ + asm volatile("addw $7,%bx"); \ + asm volatile("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_iplus2, GET_POPPED); \ + } +extern inline const void fast_op_iplus(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + subb $7,%%bl \n\ + jne iplus_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne iplus_err \n\ + addl %%ebx,%%eax \n\ + jo iplus_err \n\ + rorl $15,%%eax \n\ + orl $917504,%%eax \n\ + movl %%eax,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef IPLUS_N +#define IPLUS_N(n) { \ + fast_op_iplusn(n); \ + fast2_dispatcher(); \ +iplusn_err: \ + asm("iplusn_err:"); \ + asm("addw $7,%bx"); \ + asm("rorl $15,%ebx"); \ + N_OP_CALL_1d(N_OP_iplusn, n); \ + } + +extern inline const void fast_op_iplusn(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%eax \n\ + roll $15,%%ebx \n\ + subb $7,%%bl \n\ + jne iplusn_err \n\ + addl %%ebx,%%eax \n\ + jo iplusn_err \n\ + rorl $15,%%eax \n\ + orl $917504,%%eax \n\ + movl %%eax,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef GREATERP +#define GREATERP { \ + fast_op_greaterp(POP_TOS_1); \ + fast1_dispatcher(); \ +greaterp_err: \ + asm("greaterp_err:"); \ + N_OP_POPPED_CALL_2(N_OP_greaterp, GET_POPPED); \ + } + +extern inline const void fast_op_greaterp(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + movl %%ebx,%%edx \n\ + roll $15,%%edx \n\ + subb $7,%%dl \n\ + jne greaterp_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne greaterp_err \n\ + xorl %%ebx,%%ebx \n\ + cmpl %%edx,%%eax \n\ + jle greater_no \n\ + movl $76,%%ebx \n\ +greater_no: " : : "g" (value) ); + + } + + +#undef IGREATERP +#define IGREATERP { \ + fast_op_igreaterp(POP_TOS_1); \ + fast1_dispatcher(); \ +igreaterp_err: \ + asm("igreaterp_err: "); \ + N_OP_POPPED_CALL_2(N_OP_igreaterp, GET_POPPED); \ + } + +extern inline const void fast_op_igreaterp(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + movl %%ebx,%%edx \n\ + roll $15,%%edx \n\ + subb $7,%%dl \n\ + jne igreaterp_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne igreaterp_err \n\ + xorl %%ebx,%%ebx \n\ + cmpl %%edx,%%eax \n\ + jle igreater_no \n\ + movl $76,%%ebx \n\ +igreater_no: " : : "g" (value) ); + + } + + +#undef LRSH8 +#define LRSH8 { \ + asm volatile("\ + movl %%ebx,%%eax \n\ + roll $16,%%eax \n\ + cmpw $0xe,%%ax \n\ + jne lrsh8_err \n\ + shrw $8,%%bx \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +lrsh8_err: \ + asm("lrsh8_err: "); \ + N_OP_CALL_1(N_OP_lrsh8); \ + } + +#undef LRSH1 +#define LRSH1 { \ + asm volatile("\ + movl %%ebx,%%eax \n\ + roll $16,%%eax \n\ + cmpw $0xe,%%ax \n\ + jne lrsh1_err \n\ + shrw $1,%%bx \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +lrsh1_err: \ + asm("lrsh1_err: "); \ + N_OP_CALL_1(N_OP_lrsh1); \ + } + +#undef LLSH8 +#define LLSH8 { \ + asm volatile("\ + movl %%ebx,%%eax \n\ + roll $16,%%eax \n\ + cmpw $0xe,%%ax \n\ + jne llsh8_err \n\ + shlw $8,%%bx \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +llsh8_err: \ + asm("llsh8_err: "); \ + N_OP_CALL_1(N_OP_llsh8); \ + } + +#undef LLSH1 +#define LLSH1 { \ + asm volatile("\ + movl %%ebx,%%eax \n\ + roll $16,%%eax \n\ + cmpw $0xe,%%ax \n\ + jne llsh1_err \n\ + shlw $1,%%bx \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +llsh1_err: \ + asm("llsh1_err: "); \ + N_OP_CALL_1(N_OP_llsh1); \ + } + + +#undef LOGOR +#define LOGOR { \ + fast_op_logor(POP_TOS_1); \ + fast1_dispatcher(); \ +logor_err: \ + asm("logor_err:"); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_logor, GET_POPPED); \ + } + +extern inline const void fast_op_logor(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + cmpb $7,%%bl \n\ + jne logor_err \n\ + roll $15,%%eax \n\ + cmpb $7,%%al \n\ + jne logor_err \n\ + orl %%eax,%%ebx \n\ + rorl $15,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef LOGAND +#define LOGAND { \ + fast_op_logand(POP_TOS_1); \ + fast1_dispatcher(); \ +logand_err: \ + asm("logand_err: "); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_logand, GET_POPPED); \ + } + +extern inline const void fast_op_logand(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + cmpb $7,%%bl \n\ + jne logand_err \n\ + roll $15,%%eax \n\ + cmpb $7,%%al \n\ + jne logand_err \n\ + andl %%eax,%%ebx \n\ + rorl $15,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef LOGXOR +#define LOGXOR { \ + fast_op_logxor(POP_TOS_1); \ + fast1_dispatcher(); \ +logxor_err: \ + asm("logxor_err:"); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_logxor, GET_POPPED); \ + } + +extern inline const void fast_op_logxor(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + cmpb $7,%%bl \n\ + jne logxor_err \n\ + roll $15,%%eax \n\ + subb $7,%%al \n\ + jne logxor_err \n\ + xorl %%eax,%%ebx \n\ + rorl $15,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + + +#undef N_OP_ADDBASE +#define N_OP_ADDBASE { \ + fast_op_addbase(POP_TOS_1); \ + fast1_dispatcher(); \ +addbase_err: \ + asm("addbase_err: "); \ + asm("rorl $15,%ebx"); \ + N_OP_POPPED_CALL_2(N_OP_addbase, GET_POPPED); \ + } +extern inline const void fast_op_addbase(LispPTR value) + { + asm volatile("\ + movl %0,%%eax \n\ + roll $15,%%ebx \n\ + cmpb $7,%%bl \n\ + jne addbase_err \n\ + sarl $15,%%ebx \n\ + andl $0xFFFFFF,%%eax \n\ + addl %%eax,%%ebx \n\ + " : : "g" (value) : "ax" ); + + } + + + + +#undef N_OP_LOLOC +#define N_OP_LOLOC { \ + asm volatile(" \ + andl $0x0000FFFF,%0 \n\ + orl $0x000E0000,%0" : "=r" (tscache) : "0" (tscache)); \ + nextop1; } + +#undef N_OP_HILOC +#define N_OP_HILOC { \ + asm volatile(" \ + shrl $16,%0 \n\ + andl $0x0000FFFF,%0 \n\ + orl $0x000E0000,%0" : "=r" (tscache) : "0" (tscache)); \ + nextop1; } + +#undef N_OP_VAG2 +#define N_OP_VAG2 \ + { \ + asm(" subl $4,%edi"); \ + asm(" movl (%edi),%eax"); \ + asm(" roll $16,%ebx"); \ + asm(" movw %ax,%bx"); \ + asm(" rorl $16,%ebx"); \ + nextop1; } + + +/***********/ +/* Fast function call */ +#define asm_label_check_interrupt() asm volatile("check_interrupt:"); + +/* * These are the pieces of the function-call code. lbl is the label + to use to defeat the dead-code eliminator, lpfx is the string to + be used to disambiguate interior labels in the asm code, and nargs + is the number of args in this FN call (e.g. FN0 => 0) */ + +#define fn_section1(lbl,lpfx,nargs) \ + struct fnhead *LOCFNCELL; \ + int defcell_word; \ + int NEXTBLOCK; \ + int result; \ + int RESTARGS; \ + asm volatile(" \n\ + movl %%esi,%%eax // fn_atom_index = \n\ + xorb $3,%%al // get_AtomNo_PCMAC1 \n\ + movzbl (%%eax),%%edx \n\ + sall $16,%%edx \n\ + leal 1(%%esi),%%eax \n\ + xorb $3,%%al \n\ + movb (%%eax),%%dh \n\ + leal 2(%%esi),%%eax \n\ + xorb $3,%%al \n\ + movb (%%eax),%%dl \n\ + movl %%edx,%0 // fn_atom_index is in edx now. \n\ + " : "=g" (fn_atom_index) : : "ax", "cx", "dx"); \ + +#define fnx_section1(lbl,lpfx,nargs) \ + struct fnhead *LOCFNCELL; \ + int defcell_word; \ + int NEXTBLOCK; \ + int result, num_args; \ + int RESTARGS; \ + asm volatile(" \n\ + leal 0(%%esi),%%eax \n\ + xorb $3,%%al \n\ + movzbl (%%eax),%%edx \n\ + movl %%edx,%1 // num_args = Get_Byte_PCMAC1; \n\ + leal 1(%%esi),%%eax // fn_atom_index = \n\ + xorb $3,%%al // get_AtomNo_PCMAC1 \n\ + movzbl (%%eax),%%edx \n\ + sall $16,%%edx \n\ + leal 2(%%esi),%%eax \n\ + xorb $3,%%al \n\ + movb (%%eax),%%dh \n\ + leal 3(%%esi),%%eax \n\ + xorb $3,%%al \n\ + movb (%%eax),%%dl \n\ + movl %%edx,%0 // fn_atom_index is in edx now. \n\ + " : "=g" (fn_atom_index), "=g" (num_args) : : "ax", "cx", "dx"); \ + +#define fn_section1a(lbl,lpfx,nargs) \ + asm volatile(" \n\ + testl $16711680,%%edx \n\ + je ." lpfx "118 \n\ + addl %%edx,%%edx // new atom case \n\ + addl Lisp_world,%%edx \n\ + addl $8,%%edx \n\ + jmp ." lpfx "119 \n\ + .align 4 \n\ +." lpfx "118: \n\ + sall $2,%%edx \n\ + addl Defspace,%%edx \n\ +." lpfx "119: \n\ + movl %%edx,%0 // to -92 \n\ + " : "=g" (fn_defcell) : "g" (fn_atom_index) : "ax", "cx", "dx"); \ + \ + asm volatile(" \n\ + movl (%%edx),%%eax \n\ + movl %%eax,%0 // to -32 (must remain, it's used by C below) \n\ + testl %%eax,%%eax // if defcell_word>0 \n\ + jnl ." lpfx "120 \n\ + testl $0x4000000,%%eax / check for needs-byte-swapping \n\ + jnz ." lpfx "swap / if so, go do it out of line. \n\ + " : "=g" (defcell_word) : "g" (fn_defcell) : "ax", "dx"); \ +lbl: \ + asm volatile(" \n\ +/ .align 4 / this isn't usually the target of a branch. \n\ + andl $16777215,%%eax \n\ + movl %%eax,%1 \n\ + addl %%eax,%%eax \n\ + addl Lisp_world,%%eax \n\ + movl %%eax,%0 // to -80 \n\ + " : "=g" (LOCFNCELL), "=g" (defcell_word) : : "cx"); \ + \ + asm volatile(" \n\ + movw MachineState+20,%%dx // currentfx pc = \n\ + incw %%dx \n\ + movl %%esi,%%ecx // PCMAC - \n\ + subw %%dx,%%cx // funcobj \n\ + addw $4,%%cx // + opcode size \n\ + movl MachineState+4,%%edx \n\ + movw %%cx,-12(%%edx) // save in frame \n\ + movzwl 2(%%eax),%%edx \n\ + addl %%edx,%%edx \n\ + movl MachineState+32,%%eax \n\ + subl %%edx,%%eax \n\ + movl %%eax,MachineState+28 // Irq_Stk_Check = \n\ + cmpl %%eax,%%edi \n\ + jg check_interrupt //goto check_interrupt \n\ + " : : "g" (LOCFNCELL) : "ax", "dx", "cx"); + +#define fn_section2(lpfx) \ + asm volatile(" \n\ + movl %%ecx,MachineState \n\ + subl Stackspace,%%ecx \n\ + shrl $1,%%ecx // NEXTBLOCK in -88 \n\ + movl %%ecx,%0 \n\ + movl MachineState+4,%%edx \n\ + movw %%cx,-10(%%edx) // currentfx->nextblock = \n\ + movl %%ebx,(%%edi) // HARD_PUSH tos \n\ + addl $4,%%edi \n\ + " : "=g" (NEXTBLOCK) : : "ax", "dx", "cx"); \ + \ + asm volatile(" \n\ + movl %1,%%ecx // if LOCFNCELL->na \n\ + cmpw $0,(%%ecx) // >= 0 \n\ + jl ." lpfx "122 \n\ + // then \n\ + movswl (%%ecx),%%ecx // RESTARGS = #args(0) \n\ + " : "=g" (RESTARGS) : "g" (LOCFNCELL) : "ax", "dx", "cx"); + + /* Between these sections comes some code that subtracts */ + /* the true arg count from %ecx. It's safe to use eax if you need it */ + +#define fn_section3(lpfx,nargs) \ + asm volatile(" \n\ + jle ." lpfx "124 // if < 0, skip loop. \n\ + .align 4 \n\ +." lpfx "125: // while RESTARGS<0 \n\ + xorl %%eax,%%eax // storing NILs \n\ + cld // so stosl increments edi \n\ + rep // repeat for ecx count \n\ + stosl // store them. \n\ +." lpfx "124: \n\ + sall $2,%%ecx // RESTARGS \n\ + addl %%ecx,%%edi // ecx is <= 0 here.... \n\ + " : "=g" (RESTARGS) : "g" (LOCFNCELL) : "ax", "dx", "cx"); \ + \ + asm volatile(" \n\ +." lpfx "122: // na <0 ?? \n\ + movl %1,%%ecx // HARDPUSH(BFMARK | NEXTBLOCK) \n\ + orl $-2147483648,%%ecx \n\ + movl %%ecx,(%%edi) \n\ + movl MachineState+4,%%edx // * CSTKPTR = \n\ + subl Stackspace,%%edx // FXMARK<<16 | \n\ + shrl $1,%%edx // StkOffsetfrom68k(PVAR). \n\ + orl $-1073741824,%%edx \n\ + movl %%edx,4(%%edi) \n\ + \n\ + movl %3,%%eax // fnheader = \n\ + roll $16,%%eax // swapx(defcell_word) \n\ + movl %%eax,8(%%edi) \n\ + leal 24(%%edi),%%edi // CSTKPTRL = \n\ + movl %%edi,MachineState+4 // PVAR = CSTKPTR \n\ + \n\ + movl %2,%%edx // result = \n\ + movswl 6(%%edx),%%ecx // LOCFNCELL->pv \n\ + incl %%ecx // pv is (# of quadwords)-1, so inc it. \n\ + shll $1,%%ecx // and * 2 to get 32-bit words worth \n\ + cld // so stosl increments edi \n\ + movl $-1,%%eax // The UNBOUND_VALUE to be pushed \n\ + rep \n\ + stosl \n\ +." lpfx "127: \n\ + leal 4(%%edi),%%edi // CSTKPTRL += 1 \n\ + movl %2,%%ecx // PCMACL = LOCFNCELL \n\ + movzwl 4(%%ecx),%%ecx // + LOCFNCELL-> startpc \n\ + movl %2,%%edx \n\ + leal 1(%%ecx,%%edx),%%edx \n\ + movl %%edx,%%esi //replace above 2 inst \n\ + movl %2,%%eax //FuncObj = LOCFNCELL \n\ + movl %%eax,MachineState+20 \n\ + " : "=&g" (result) : "g" (NEXTBLOCK), "g" (LOCFNCELL), \ + "g" (defcell_word) : "ax", "dx", "cx"); \ + \ + fast0_dispatcher(); /* can't be nextop0, or the following */ \ + /* code winds up dead and removed. */ \ + asm volatile(" \n\ + .align 4 \n\ +." lpfx "swap: / Come here if we need to byte-swap the fn \n\ + pushl %%eax \n\ + pushl %%eax \n\ + call byte_swap_code_block / swap it \n\ + popl %%eax \n\ + popl %%eax \n\ + jmp %l0" : : "" (&&lbl)); \ + asm volatile(" \n\ + .align 4 \n\ +." lpfx "swap: / Come here if we need to byte-swap the fn \n\ + call byte_swap_ +." lpfx "120:"); + + +#define fn_section4(nargs) \ + { /* it's not a CCODEP */ \ + fn_num_args = nargs /* argcount*/; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + + + +#undef FN0 +#define FN0 \ + { \ + fn_section1(L0120,"0",0); \ + fn_section1a(L0120,"0",0); \ + asm volatile(" \n\ + leal 4(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("0"); \ + /* decl %%ecx's would go here, 1 per arg */ \ + fn_section3("0",0); \ + fn_section4(0); \ + } + + +#undef FN1 +#define FN1 \ + { \ + fn_section1(L1120,"1",1); \ + fn_section1a(L1120,"1",1); \ + asm volatile(" \n\ + leal (%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("1"); \ + asm volatile("decl %ecx"); \ + fn_section3("1",1); \ + fn_section4(1); \ + } + +#undef FN2 +#define FN2 \ + { \ + fn_section1(L2120,"2",2); \ + fn_section1a(L2120,"2",2); \ + asm volatile(" \n\ + leal -4(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("2"); \ + asm volatile("subl $2,%ecx"); \ + fn_section3("2",2); \ + fn_section4(2); \ + } + +#undef FN3 +#define FN3 \ + { \ + fn_section1(L3120,"3",3); \ + fn_section1a(L3120,"3",3); \ + asm volatile(" \n\ + leal -8(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("3"); \ + asm volatile("subl $3,%ecx"); \ + fn_section3("3",3); \ + fn_section4(3); \ + } + + +#undef FN4 +#define FN4 \ + { \ + fn_section1(L4120,"4",4); \ + fn_section1a(L4120,"4",4); \ + asm volatile(" \n\ + leal -12(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("4"); \ + asm volatile("subl $4,%ecx"); \ + fn_section3("4",4); \ + fn_section4(4); \ + } + +#undef xFNX +#define xFNX \ + { \ + fnx_section1(Lx120,"x",4); \ + fn_section1a(Lx120,"x",4); \ + asm volatile(" \n\ + movl %0,%%eax // get num_args \n\ + leal -4(,%%eax,4),%%eax \n\ + negl %%eax \n\ + leal (%%edi,%%eax),%%ecx // newivar = CSTKPTR-argcount+1" : : "g" (num_args)); \ + fn_section2("x"); \ + asm volatile("subl %0,%%ecx" : : "g" (num_args)); \ + fn_section3("x",4); \ + { /* it's not a CCODEP */ \ + fn_num_args = num_args; /* argcount*/ \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + } + + + + + +/************************************************************************/ +/* */ +/* o p r e t u r n */ +/* */ +/* Inline version of the RETURN opcode. */ +/* */ +/************************************************************************/ + +inline const extern void opreturn() + { + asm volatile(" \n\ + movl MachineState+4,%%edx \n\ + movzwl -20(%%edx),%%edx \n\ + testb $1,%%dl \n\ + jne opret_fail \n\ + movl MachineState,%%edi \n\ + movl Stackspace,%%ecx \n\ + leal 0(%%ecx,%%edx,2),%%eax \n\ + movl %%eax,MachineState+4 \n\ + leal -22(%%eax),%%edx \n\ + xorb $2,%%dl \n\ + movzwl (%%edx),%%edx \n\ + leal 0(%%ecx,%%edx,2),%%edx \n\ + movl %%edx,MachineState \n\ + movl -16(%%eax),%%ecx \n\ + roll $16,%%ecx \n\ + andl $16777215,%%ecx \n\ + addl %%ecx,%%ecx \n\ + addl Lisp_world,%%ecx \n\ + movl %%ecx,MachineState+20 \n\ + movzwl -12(%%eax),%%eax \n\ + leal 1(%%eax,%%ecx),%%esi \n\ + movzwl 2(%%ecx),%%edx \n\ + addl %%edx,%%edx \n\ + movl MachineState+24,%%eax \n\ + subl %%edx,%%eax \n\ + movl %%eax,MachineState+28 \n\ + cmpl %%eax,%%edi \n\ + jg check_interrupt \n\ + cmpl $0,MachineState+32 \n\ + jle check_interrupt \n\ + movl MachineState+24,%%ecx \n\ + movl %%ecx,MachineState+32 \n\ + \n\ + leal -1(%%esi),%%eax \n\ + xorb $3,%%al \n\ + movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4) \n\ + \n\ + .align 4 \n\ +opret_fail:" : : : "ax", "dx", "cx"); + } diff --git a/inc/inlnSPARC.h b/inc/inlnSPARC.h new file mode 100755 index 0000000..57544bd --- /dev/null +++ b/inc/inlnSPARC.h @@ -0,0 +1,177 @@ +/* $Id: inlnSPARC.h,v 1.2 1999/01/03 02:06:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +/* inlinedefsSPARC.h */ +/* Bob Krivacic, Steve Purcell */ + +/* These are the Macros Used to generate inline SPARC assembly code + to implement the opcodes. Used by both dispatch + loop and native code. +*/ + +/* this is *very* carefully written to generate optimal sun4 assembly code. Be very careful modifying it if you must do so. scp*/ + +/* + Get_BYTE(PCMAC+1); \ +xc.c: #define PCMAC pccache +xc.c: register InstPtr pccache; +xc.c: typedef ByteCode *InstPtr; CHANGED TO +xc.c: typedef BYTECODE *InstPtr; +lispemul.h: typedef char ByteCode; +lispemul.h: #define Get_BYTE(byteptr) (((BYTECODE *)(byteptr))->code) +lispemul.h: typedef struct {unsigned code : 8;} BYTECODE; + */ + +/* shuffle loads to go faster */ +#undef IVARMACRO +#define IVARMACRO(x) { \ + register LispPTR *var = (LispPTR *)IVar; \ + \ + HARD_PUSH(TOPOFSTACK); \ + {register unsigned char opcode; \ + opcode = *(unsigned char *)(PCMAC+1); \ + TOPOFSTACK = *(var + x); \ + PCMACL += 1; \ + fast_dispatcher(table, opcode);} \ + goto nextopcode; } + +#undef PVARMACRO +#define PVARMACRO(x) { \ + register LispPTR *var = (LispPTR *)PVar; \ + \ + HARD_PUSH(TOPOFSTACK); \ + {register unsigned char opcode; \ + opcode = *(unsigned char *)(PCMAC+1); \ + TOPOFSTACK = *(var + x); \ + PCMACL += 1; \ + fast_dispatcher(table, opcode);} \ + goto nextopcode; } + + +#define NSMALLP(x) (((x) >> 17) ^ 7) +#define NSMALLP_RANGE(x) (((x << 15) >>15) ^ x) + +#define UNBOX_SMALLP(sour) ( ((int)sour << 15) >> 15 ) + +#define HARD_CASE(fn) {SV; TOPOFSTACK = fn(POP_TOS_1, TOPOFSTACK, ufn_2); nextop1;} + +#define UNBOX_ELSE(sour, dest, otherwise){ \ + if (NSMALLP(sour)) \ + if (GetTypeNumber(sour) != TYPE_FIXP) otherwise; \ + else dest = FIXP_VALUE(sour); \ + else dest = UNBOX_SMALLP(sour);} + +#define UNBOX_ELSE_UFN(sour, dest) UNBOX_ELSE(sour, dest, goto op_ufn); + +#define BOX_INTO(result, dest){ \ + if (NSMALLP_RANGE(result))/* dest = box_fixp(result);*/ \ + {register LispPTR *wordp; \ + wordp = (LispPTR *) createcell68k(TYPE_FIXP); \ + *((int *)wordp) = result; \ + dest = (LADDR_from_68k(wordp)); } \ + else dest = (( (unsigned)result <<15) >>15) | S_POSITIVE;} + + +#define ARITH_OP(op, exceptions, handler) \ + {register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + if(!NSMALLP(TOPOFSTACK) && !NSMALLP(arg1)) { \ + arg2 = UNBOX_SMALLP(TOPOFSTACK); \ + arg1 = UNBOX_SMALLP(arg1); \ + result = arg1 op arg2; \ + BOX_INTO(result, TOPOFSTACK); \ + POP_TOS_1; \ + nextop1;} \ + N_OP_CALL_2(handler); } + +#define BINARY_OP(exp, exceptions) { \ + register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + UNBOX_ELSE_UFN(arg1, arg1); \ + result = exp; \ + if (exceptions) goto op_ufn; \ + BOX_INTO(result, TOPOFSTACK); \ + POP_TOS_1; nextop1;} + +#undef GREATERP +#undef IGREATERP + +#define GREATERP { \ + register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + UNBOX_ELSE_UFN(arg1, arg1); \ + TOPOFSTACK = (arg1>arg2? ATOM_T : NIL_PTR); \ + POP_TOS_1; nextop1;} + +#define IGREATERP { \ + register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + UNBOX_ELSE_UFN(arg1, arg1); \ + TOPOFSTACK = (arg1>arg2? ATOM_T : NIL_PTR); \ + POP_TOS_1; nextop1;} + +#define OVERFLOW(a,b,r) ( (int)((r^a) & (a^~b)) < 0) +#define SOVERFLOW(a,b,r) ( (int)((r^a) & (a^b)) < 0) +/* overflow is ((arg1>0) == (arg2>0)) && ((result>0) != (arg1>0)) */ + +#undef IPLUS2 +#undef PLUS2 +#define IPLUS2 ARITH_OP(+, OVERFLOW(arg1,arg2,result), N_OP_iplus2) +#define PLUS2 ARITH_OP(+, OVERFLOW(arg1,arg2,result), N_OP_plus2) + +#undef IDIFFERENCE +#undef DIFFERENCE +#define IDIFFERENCE ARITH_OP(-, SOVERFLOW(arg1,arg2,result), N_OP_idifference) +#define DIFFERENCE ARITH_OP(-, SOVERFLOW(arg1,arg2,result), N_OP_difference) + +#undef LOGOR +#undef LOGAND +#undef LOGXOR + +#define LOGOR BINARY_OP(arg1 | arg2, 0) +#define LOGAND BINARY_OP(arg1 & arg2, 0) +#define LOGXOR BINARY_OP(arg1 ^ arg2, 0) + +#define UNARY_OP(exp, exceptions) { \ + register int arg, result; \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg); \ + result = exp; \ + if (exceptions) goto op_ufn; \ + BOX_INTO(result, TOPOFSTACK); \ + nextop1;} + +#undef LRSH8 +#undef LRSH1 +#define LRSH8 UNARY_OP((unsigned)arg >> 8, 0) +#define LRSH1 UNARY_OP((unsigned)arg >> 1, 0) + +#undef LLSH8 +#undef LLSH1 +#define LLSH8 UNARY_OP(arg << 8, ((arg >> 24)!=0)) +#define LLSH1 UNARY_OP(arg << 1, (arg < 0)) + +#undef ADDBASE +#define ADDBASE { \ + register int arg1, arg2; \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + TOPOFSTACK = POP_TOS_1 + arg2; \ + nextop1;} + + +#undef SWAP_WORDS +#define SWAP_WORDS(x) swapx(x) diff --git a/inc/inlndos.h b/inc/inlndos.h new file mode 100755 index 0000000..93bc2c2 --- /dev/null +++ b/inc/inlndos.h @@ -0,0 +1,1125 @@ +/* $Id: inlndos.h,v 1.2 1999/01/03 02:06:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1991, 1992 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* I N L I N E P S 2 . H */ +/* */ +/* INLINE definitions for 386 machines, compiled with gcc. */ +/* */ +/* This file consists of 3 sections: */ +/* */ +/* inline static functions for use anywhere in Medley */ +/* (e.g., the byte-swapping functions) */ +/* */ +/* #defines and static inline functions for the dispatch */ +/* loop (e.g., IDIFFERENCE), relying on the register */ +/* conventions that hold in that part of the code */ +/* */ +/* #defines and static inline functions for other */ +/* specific files (e.g., the arithmetic functions, */ +/* free-variable lookup, etc.), relying on the register */ +/* conventions in the respective files. */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* R E G I S T E R C O N V E N T I O N S */ +/* */ +/* The following register conventions hold in the dispatch loop, */ +/* and are set up by register ... asm("...") decls in xc.c: */ +/* */ +/* esi pccache - the current PC */ +/* edi cspcache - the current lisp stack ptr. */ +/* ebx tscache - the top-of-stack item. */ +/* */ +/* */ +/* Rgister conventions within arithmetic functions in the files */ +/* arith2.c - arith4.c, etc.: */ +/* */ +/* esi first argument to the function */ +/* edi second argument to the function */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* G E N E R A L - P U R P O S E I N L I N E F U N C T I O N S */ +/* */ +/* These functions don't rely on register conventions. */ +/* */ +/************************************************************************/ + + +#undef SWAP_WORDS +#define SWAP_WORDS swapx + + +extern inline unsigned int swapx (unsigned int word) + { + asm("rol %0,16" : "=g" (word) : "0" (word)); + return(word); + } + + + +extern inline unsigned int word_swap_longword (unsigned int word) + { + asm("rol %0,16" : "=r" (word) : "0" (word)); + + return(word); + } + + + +extern inline unsigned short byte_swap_word (unsigned short word) + { + asm("rol %0,8" : "=r" (word) : "0" (word)); + + return(word); + } + + + +extern inline void word_swap_page(unsigned short * page, int count) + { + asm volatile("\ + pushl edi \n\ + pushl esi \n\ + pushl ecx \n\ + cld"); + asm volatile(" + movl esi,%0 // word pointer. \n\ + movl edi,esi \n\ + movl ecx,%1 // count" : : "g" (page), "g" (count)); + asm volatile(" \ + lodsl \n\ + rol ax,8 \n\ + rol eax,16 \n\ + rol ax,8 \n\ + stosl \n\ + loop .-13 \n\ + \n\ + // epilogue. \n\ + popl ecx \n\ + popl esi \n\ + popl edi \n\ + "); + + } + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + /* undefine these macros so we use the 386i inline code */ + +#undef Get_BYTE_PCMAC0 +#undef Get_BYTE_PCMAC1 +#undef Get_BYTE_PCMAC2 +#undef Get_BYTE_PCMAC3 + +#define Get_BYTE_PCMAC0 Get_BYTE_PCMAC0fn(pccache) +#define Get_BYTE_PCMAC1 Get_BYTE_PCMAC1fn(pccache) +#define Get_BYTE_PCMAC2 Get_BYTE_PCMAC2fn(pccache) +#define Get_BYTE_PCMAC3 Get_BYTE_PCMAC3fn(pccache) + +extern inline unsigned int Get_BYTE_PCMAC0fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("lea %0,-1[%1] \n\ + xor %0,3 \n\ + movzx %0,BYTE PTR [%0] \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + +extern inline unsigned int Get_BYTE_PCMAC1fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("lea %0,[%1] \n\ + xor %0,3 \n\ + movzx %0,BYTE PTR [%0] \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + +extern inline unsigned int Get_BYTE_PCMAC2fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("lea %0,1[%1] \n\ + xor %0,3 \n\ + movzx %0,BYTE PTR [%0] \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + +extern inline unsigned int Get_BYTE_PCMAC3fn (pccache) +unsigned int pccache; + { + register unsigned int word; + asm("lea %0,2[%1] \n\ + xor %0,3 \n\ + movzx %0,BYTE PTR [%0] \n\ + " : "=r" (word) : "r" (pccache) ); + return(word); + } + + +#undef Get_DLword_PCMAC0 +#undef Get_DLword_PCMAC1 +#undef Get_DLword_PCMAC2 +#undef Get_DLword_PCMAC3 + + +#define Get_DLword_PCMAC0 Get_DLword_PCMAC0fn(pccache) +#define Get_DLword_PCMAC1 Get_DLword_PCMAC1fn(pccache) +#define Get_DLword_PCMAC2 Get_DLword_PCMAC2fn(pccache) +#define Get_DLword_PCMAC3 Get_DLword_PCMAC3fn(pccache) + +extern inline unsigned int Get_DLword_PCMAC0fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("mov edx,%1 \n\ + xor dl,3 \n\ + movzx eax, byte ptr [edx] \n\ + lea edx,-1[%1] \n\ + xor dl,3 \n\ + mov ah, byte ptr [edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + +extern inline unsigned int Get_DLword_PCMAC1fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("lea edx,1[%1] \n\ + xor dl,3 \n\ + movzx eax, byte ptr [edx] \n\ + lea edx,[%1] \n\ + xor dl,3 \n\ + mov ah, byte ptr [edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +extern inline unsigned int Get_DLword_PCMAC2fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("lea edx,2[%1] \n\ + xor dl,3 \n\ + movzx eax, byte ptr [edx] \n\ + lea edx,1[%1] \n\ + xor dl,3 \n\ + mov ah, byte ptr [edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + +extern inline unsigned int Get_DLword_PCMAC3fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("lea edx,3[%1] \n\ + xor dl,3 \n\ + movzx eax, byte ptr [edx] \n\ + lea edx,2[%1] \n\ + xor dl,3 \n\ + mov ah, byte ptr [edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +#undef Get_Pointer_PCMAC0 +#undef Get_Pointer_PCMAC1 +#undef Get_Pointer_PCMAC2 + +#define Get_Pointer_PCMAC0 Get_Pointer_PCMAC0fn(pccache) +#define Get_Pointer_PCMAC1 Get_Pointer_PCMAC1fn(pccache) +#define Get_Pointer_PCMAC2 Get_Pointer_PCMAC2fn(pccache) + + +extern inline const unsigned int Get_Pointer_PCMAC0fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("lea edx,-1[%1] \n\ + xor dl,3 \n\ + movzx eax,byte ptr [edx] \n\ + shl eax,16 \n\ + lea edx,1[%1] \n\ + xor dl,3 \n\ + mov al,[edx] \n\ + lea edx,[%1] \n\ + xor dl,3 \n\ + mov ah,[edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + +extern inline const unsigned int Get_Pointer_PCMAC1fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("lea edx,[%1] \n\ + xor dl,3 \n\ + movzx eax,byte ptr [edx] \n\ + shl eax,16 \n\ + lea edx,2[%1] \n\ + xor dl,3 \n\ + mov al,[edx] \n\ + lea edx,1[%1] \n\ + xor dl,3 \n\ + mov ah,[edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +extern inline const unsigned int Get_Pointer_PCMAC2fn(pccache) +unsigned int pccache; + { + register unsigned int word asm("ax"); + asm("lea edx,1[%1] \n\ + xor dl,3 \n\ + movzx eax,byte ptr [edx] \n\ + shl eax,16 \n\ + lea edx,3[%1] \n\ + xor dl,3 \n\ + mov al,[edx] \n\ + lea edx,2[%1] \n\ + xor dl,3 \n\ + mov ah,[edx] \n\ + " : "=r" (word) : "r" (pccache) : "dx" ); + return(word); + } + + +#undef DIFFERENCE +#undef IDIFFERENCE + +#define DIFFERENCE { \ + fast_op_difference(POP_TOS_1); \ + fast1_dispatcher(); \ +diff_err: \ + asm volatile("diff_err:"); \ + asm volatile("add bl,7"); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_difference, GET_POPPED); \ + } + +extern inline void fast_op_difference(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + sub bl,7 \n\ + jne diff_err \n\ + rol eax,17 \n\ + sub al,7 \n\ + jne diff_err \n\ + sub eax,ebx \n\ + jo diff_err \n\ + ror eax,15 \n\ + or eax,917504 \n\ + mov ebx,eax \ + " : : "g" (value) : "ax" ); + + } + +#define IDIFFERENCE { \ + fast_op_idifference(POP_TOS_1); \ + fast1_dispatcher(); \ +idiff_err: \ + asm volatile("idiff_err:"); \ + asm volatile("add bl,7"); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_idifference, GET_POPPED); \ + } + +extern inline void fast_op_idifference(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + sub bl,7 \n\ + jne idiff_err \n\ + rol eax,17 \n\ + sub al,7 \n\ + jne idiff_err \n\ + sub eax,ebx \n\ + jo idiff_err \n\ + ror eax,15 \n\ + or eax,917504 \n\ + mov ebx,eax \ + " : : "g" (value) : "ax" ); + + } + + +#undef IDIFFERENCE_N +#define IDIFFERENCE_N(n) { \ + fast_op_idifferencen(n); \ + fast2_dispatcher(); \ +idiffn_err: \ + asm("idiffn_err2:"); \ + asm volatile("add ebx,eax ; undo the sub"); \ + asm("idiffn_err:"); \ + asm volatile("add bl,7"); \ + asm volatile("ror ebx,15"); \ + N_OP_CALL_1d(N_OP_idifferencen, n); \ + } + +extern inline void fast_op_idifferencen(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol eax,15 \n\ + rol ebx,15 \n\ + sub bl,7 \n\ + jne idiffn_err \n\ + sub ebx,eax \n\ + jo idiffn_err2 \n\ + ror ebx,15 \n\ + or ebx,917504 \n\ + " : : "g" (value) : "ax" ); + + } + +#undef PLUS2 +#undef IPLUS2 + +#define PLUS2 { \ + fast_op_plus(POP_TOS_1); \ + fast1_dispatcher(); \ +plus_err: \ + asm volatile("plus_err:"); \ + asm volatile("add bl,7"); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_plus2, GET_POPPED); \ + } +extern inline void fast_op_plus(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + sub bl,7 \n\ + jne plus_err \n\ + rol eax,15 \n\ + sub al,7 \n\ + jne plus_err \n\ + add eax,ebx \n\ + jo plus_err \n\ + ror eax,15 \n\ + or eax,917504 \n\ + mov ebx,eax \n\ + " : : "g" (value) : "ax" ); + + } + + +#define IPLUS2 { \ + fast_op_iplus(POP_TOS_1); \ + fast1_dispatcher(); \ +iplus_err: \ + asm volatile("iplus_err:"); \ + asm volatile("add bl,7"); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_iplus2, GET_POPPED); \ + } +extern inline void fast_op_iplus(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + sub bl,7 \n\ + jne iplus_err \n\ + rol eax,15 \n\ + sub al,7 \n\ + jne iplus_err \n\ + add eax,ebx \n\ + jo iplus_err \n\ + ror eax,15 \n\ + or eax,917504 \n\ + mov ebx,eax \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef IPLUS_N +#define IPLUS_N(n) { \ + fast_op_iplusn(n); \ + fast2_dispatcher(); \ +iplusn_err: \ + asm("iplusn_err:"); \ + asm volatile("add bl,7"); \ + asm volatile("ror ebx,15"); \ + N_OP_CALL_1d(N_OP_iplusn, n); \ + } + +extern inline void fast_op_iplusn(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol eax,15 \n\ + rol ebx,15 \n\ + sub bl,7 \n\ + jne iplusn_err \n\ + add eax,ebx \n\ + jo iplusn_err \n\ + ror eax,15 \n\ + or eax,917504 \n\ + mov ebx,eax \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef GREATERP +#define GREATERP { \ + fast_op_greaterp(POP_TOS_1); \ + fast1_dispatcher(); \ +greaterp_err: \ + asm("greaterp_err:"); \ + N_OP_POPPED_CALL_2(N_OP_greaterp, GET_POPPED); \ + } + +extern inline void fast_op_greaterp(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + mov edx,ebx \n\ + rol edx,15 \n\ + sub dl,7 \n\ + jne greaterp_err \n\ + rol eax,15 \n\ + sub al,7 \n\ + jne greaterp_err \n\ + xor ebx,ebx \n\ + cmp eax,edx \n\ + jle greater_no \n\ + mov ebx,76 \n\ +greater_no: " : : "g" (value) ); + + } + + +#undef IGREATERP +#define IGREATERP { \ + fast_op_igreaterp(POP_TOS_1); \ + fast1_dispatcher(); \ +igreaterp_err: \ + asm("igreaterp_err: "); \ + N_OP_POPPED_CALL_2(N_OP_igreaterp, GET_POPPED); \ + } + +extern inline void fast_op_igreaterp(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + mov edx,ebx \n\ + rol edx,15 \n\ + sub dl,7 \n\ + jne igreaterp_err \n\ + rol eax,15 \n\ + sub al,7 \n\ + jne igreaterp_err \n\ + xor ebx,ebx \n\ + cmp eax,edx \n\ + jle igreater_no \n\ + mov ebx,76 \n\ +igreater_no: " : : "g" (value) ); + + } + + +#undef LRSH8 +#define LRSH8 { \ + asm volatile("\ + mov eax,ebx \n\ + rol eax,16 \n\ + cmp ax,0eh \n\ + jne lrsh8_err \n\ + shr bx,8 \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +lrsh8_err: \ + asm("lrsh8_err: "); \ + N_OP_CALL_1(N_OP_lrsh8); \ + } + +#undef LRSH1 +#define LRSH1 { \ + asm volatile("\ + mov eax,ebx \n\ + rol eax,16 \n\ + cmp ax,0eh \n\ + jne lrsh1_err \n\ + shr bx,1 \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +lrsh1_err: \ + asm("lrsh1_err: "); \ + N_OP_CALL_1(N_OP_lrsh1); \ + } + +#undef LLSH8 +#define LLSH8 { \ + asm volatile("\ + mov eax,ebx \n\ + rol eax,16 \n\ + cmp ax,0eh \n\ + jne llsh8_err \n\ + or bh,bh \n\ + jne llsh8_err \n\ + shl bx,8 \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +llsh8_err: \ + asm("llsh8_err: "); \ + N_OP_CALL_1(N_OP_llsh8); \ + } + +#undef LLSH1 +#define LLSH1 { \ + asm volatile("\ + mov eax,ebx \n\ + rol eax,16 \n\ + cmp ax,0eh \n\ + jne llsh1_err \n\ + test bh,80h \n\ + jne llsh1_err \n\ + shl bx,1 \n\ + " : : : "ax" ); \ + fast1_dispatcher(); \ +llsh1_err: \ + asm("llsh1_err: "); \ + N_OP_CALL_1(N_OP_llsh1); \ + } + + +#undef LOGOR +#define LOGOR { \ + fast_op_logor(POP_TOS_1); \ + fast1_dispatcher(); \ +logor_err: \ + asm("logor_err:"); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_logor, GET_POPPED); \ + } + +extern inline void fast_op_logor(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + cmp bl,7 \n\ + jne logor_err \n\ + rol eax,15 \n\ + cmp al,7 \n\ + jne logor_err \n\ + or ebx,eax \n\ + ror ebx,15 \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef LOGAND +#define LOGAND { \ + fast_op_logand(POP_TOS_1); \ + fast1_dispatcher(); \ +logand_err: \ + asm("logand_err: "); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_logand, GET_POPPED); \ + } + +extern inline void fast_op_logand(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + cmp bl,7 \n\ + jne logand_err \n\ + rol eax,15 \n\ + cmp al,7 \n\ + jne logand_err \n\ + and ebx,eax \n\ + ror ebx,15 \n\ + " : : "g" (value) : "ax" ); + + } + + +#undef LOGXOR +#define LOGXOR { \ + fast_op_logxor(POP_TOS_1); \ + fast1_dispatcher(); \ +logxor_err: \ + asm("logxor_err:"); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_logxor, GET_POPPED); \ + } + +extern inline void fast_op_logxor(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + cmp bl,7 \n\ + jne logxor_err \n\ + rol eax,15 \n\ + sub al,7 \n\ + jne logxor_err \n\ + xor ebx,eax \n\ + ror ebx,15 \n\ + " : : "g" (value) : "ax" ); + + } + + + +#undef N_OP_ADDBASE +#define N_OP_ADDBASE { \ + fast_op_addbase(POP_TOS_1); \ + fast1_dispatcher(); \ +addbase_err: \ + asm("addbase_err: "); \ + asm volatile("ror ebx,15"); \ + N_OP_POPPED_CALL_2(N_OP_addbase, GET_POPPED); \ + } +extern inline void fast_op_addbase(LispPTR value) + { + asm volatile("\ + mov eax,%0 \n\ + rol ebx,15 \n\ + cmp bl,7 \n\ + jne addbase_err \n\ + sar ebx,15 \n\ + and eax,0ffffffh \n\ + add ebx,eax \n\ + " : : "g" (value) : "ax" ); + + } + + + + +#undef N_OP_LOLOC +#define N_OP_LOLOC { \ + asm volatile(" \ + and %0,0ffffh \n\ + or %0,0e0000h" : "=r" (tscache) : "0" (tscache)); \ + nextop1; } + +#undef N_OP_HILOC +#define N_OP_HILOC { \ + asm volatile(" \ + shr %0,16 \n\ + and %0,0ffffh \n\ + or %0,0e0000h" : "=r" (tscache) : "0" (tscache)); \ + nextop1; } + +#undef N_OP_VAG2 +#define N_OP_VAG2 \ + { \ + asm(" sub edi,4"); \ + asm(" mov eax,[edi]"); \ + asm(" rol ebx,16"); \ + asm(" mov bx,ax"); \ + asm(" ror ebx,16"); \ + nextop1; } + + + +#ifdef NOTYET +TO FIX FIXME: Need to fix instruction names, and operand order. +TO FIX FIXME: $constant -> constant, (edi) -> [edi], + +/***********/ +/* Fast function call */ +#define asm_label_check_interrupt() asm volatile("check_interrupt:"); + +/* * These are the pieces of the function-call code. lbl is the label + to use to defeat the dead-code eliminator, lpfx is the string to + be used to disambiguate interior labels in the asm code, and nargs + is the number of args in this FN call (e.g. FN0 => 0) */ + +#define fn_section1(lbl,lpfx,nargs) \ + struct fnhead *LOCFNCELL; \ + int defcell_word; \ + int NEXTBLOCK; \ + int result; \ + int RESTARGS; \ + asm volatile(" \n\ + mov eax,esi // fn_atom_index = \n\ + xor al,3 // get_AtomNo_PCMAC1 \n\ + movz edx, byte ptr [eax] \n\ + sal edx,16 \n\ + leal eax,1[esi] \n\ + xorb al,3 \n\ + movb dh,[eax] \n\ + leal eax,2[esi] \n\ + xorb al,3 \n\ + movb dl,[eax] \n\ + movl %0,edx // fn_atom_index is in edx now. \n\ + " : "=g" (fn_atom_index) : : "ax", "cx", "dx"); \ + +#define fnx_section1(lbl,lpfx,nargs) \ + struct fnhead *LOCFNCELL; \ + int defcell_word; \ + int NEXTBLOCK; \ + int result, num_args; \ + int RESTARGS; \ + asm volatile(" \n\ + lea eax,0[esi] \n\ + xor al,3 \n\ + movz edx, byte ptr [eax] \n\ + mov %1,edx // num_args = Get_Byte_PCMAC1; \n\ + lea eax,1[esi] // fn_atom_index = \n\ + xor al,$3 // get_AtomNo_PCMAC1 \n\ + movz edx, byte ptr [eax] \n\ + sal edx,16 \n\ + lea eax,2[esi] \n\ + xor al,3 \n\ + mov dh, byte ptr [eax] \n\ + lea eax,3[esi] \n\ + xor al,3 \n\ + mov dl, byte ptr [eax] \n\ + mov %0,edx // fn_atom_index is in edx now. \n\ + " : "=g" (fn_atom_index), "=g" (num_args) : : "ax", "cx", "dx"); \ + +#define fn_section1a(lbl,lpfx,nargs) \ + asm volatile(" \n\ + test edx,16711680 \n\ + je ." lpfx "118 \n\ + add edx,edx // new atom case \n\ + add edx, dword ptr Lisp_world \n\ + add edx,8 \n\ + jmp ." lpfx "119 \n\ + .align 4 \n\ +." lpfx "118: \n\ + sal edx,2 \n\ + add edx, dword ptr Defspace \n\ +." lpfx "119: \n\ + mov %0,edx // to -92 \n\ + " : "=g" (fn_defcell) : "g" (fn_atom_index) : "ax", "cx", "dx"); \ + \ + asm volatile(" \n\ + movl eax,(edx) \n\ + movl %0,eax // to -32 (must remain, it's used by C below) \n\ + testl eax,eax // if defcell_word>0 \n\ + jnl ." lpfx "120 \n\ + testl eax,$0x4000000 / check for needs-byte-swapping \n\ + jnz ." lpfx "swap / if so, go do it out of line. \n\ + " : "=g" (defcell_word) : "g" (fn_defcell) : "ax", "dx"); \ +lbl: \ + asm volatile(" \n\ +/ .align 4 / this isn't usually the target of a branch. \n\ + andl eax,$16777215 \n\ + movl %1,eax \n\ + addl eax,eax \n\ + addl eax,Lisp_world \n\ + movl %0,eax // to -80 \n\ + " : "=g" (LOCFNCELL), "=g" (defcell_word) : : "cx"); \ + \ + asm volatile(" \n\ + movw MachineState+20,dx // currentfx pc = \n\ + incw dx \n\ + movl esi,ecx // PCMAC - \n\ + subw dx,cx // funcobj \n\ + addw $4,cx // + opcode size \n\ + movl MachineState+4,edx \n\ + movw cx,-12(edx) // save in frame \n\ + movzwl 2(eax),edx \n\ + addl edx,edx \n\ + movl MachineState+32,eax \n\ + subl edx,eax \n\ + movl eax,MachineState+28 // Irq_Stk_Check = \n\ + cmpl eax,edi \n\ + jg check_interrupt //goto check_interrupt \n\ + " : : "g" (LOCFNCELL) : "ax", "dx", "cx"); + +#define fn_section2(lpfx) \ + asm volatile(" \n\ + movl ecx,MachineState \n\ + subl Stackspace,ecx \n\ + shrl $1,ecx // NEXTBLOCK in -88 \n\ + movl ecx,%0 \n\ + movl MachineState+4,edx \n\ + movw cx,-10(edx) // currentfx->nextblock = \n\ + movl ebx,(edi) // HARD_PUSH tos \n\ + addl $4,edi \n\ + " : "=g" (NEXTBLOCK) : : "ax", "dx", "cx"); \ + \ + asm volatile(" \n\ + movl %1,ecx // if LOCFNCELL->na \n\ + cmpw $0,(ecx) // >= 0 \n\ + jl ." lpfx "122 \n\ + // then \n\ + movswl (ecx),ecx // RESTARGS = #args(0) \n\ + " : "=g" (RESTARGS) : "g" (LOCFNCELL) : "ax", "dx", "cx"); + + /* Between these sections comes some code that subtracts */ + /* the true arg count from %ecx. It's safe to use eax if you need it */ + +#define fn_section3(lpfx,nargs,lbl) \ + asm volatile(" \n\ + jle ." lpfx "124 // if < 0, skip loop. \n\ + .align 4 \n\ +." lpfx "125: // while RESTARGS<0 \n\ + xorl eax,eax // storing NILs \n\ + cld // so stosl increments edi \n\ + rep // repeat for ecx count \n\ + stosl // store them. \n\ +." lpfx "124: \n\ + sall $2,ecx // RESTARGS \n\ + addl ecx,edi // ecx is <= 0 here.... \n\ + " : "=g" (RESTARGS) : "g" (LOCFNCELL) : "ax", "dx", "cx"); \ + \ + asm volatile(" \n\ +." lpfx "122: // na <0 ?? \n\ + movl %1,ecx // HARDPUSH(BFMARK | NEXTBLOCK) \n\ + orl $-2147483648,ecx \n\ + movl ecx,(edi) \n\ + movl MachineState+4,edx // * CSTKPTR = \n\ + subl Stackspace,edx // FXMARK<<16 | \n\ + shrl $1,edx // StkOffsetfrom68k(PVAR). \n\ + orl $-1073741824,edx \n\ + movl edx,4(edi) \n\ + \n\ + movl %3,eax // fnheader = \n\ + roll $16,eax // swapx(defcell_word) \n\ + movl eax,8(edi) \n\ + leal 24(edi),edi // CSTKPTRL = \n\ + movl edi,MachineState+4 // PVAR = CSTKPTR \n\ + \n\ + movl %2,edx // result = \n\ + movswl 6(edx),ecx // LOCFNCELL->pv \n\ + incl ecx // pv is (# of quadwords)-1, so inc it. \n\ + shll $1,ecx // and * 2 to get 32-bit words worth \n\ + cld // so stosl increments edi \n\ + movl $-1,eax // The UNBOUND_VALUE to be pushed \n\ + rep \n\ + stosl \n\ +." lpfx "127: \n\ + leal 4(edi),edi // CSTKPTRL += 1 \n\ + movl %2,ecx // PCMACL = LOCFNCELL \n\ + movzwl 4(ecx),ecx // + LOCFNCELL-> startpc \n\ + movl %2,edx \n\ + leal 1(ecx,edx),edx \n\ + movl edx,esi //replace above 2 inst \n\ + movl %2,eax //FuncObj = LOCFNCELL \n\ + movl eax,MachineState+20 \n\ + " : "=&g" (result) : "g" (NEXTBLOCK), "g" (LOCFNCELL), \ + "g" (defcell_word) : "ax", "dx", "cx"); \ + \ + fast0_dispatcher(); /* can't be nextop0, or the following */ \ + /* code winds up dead and removed. */ \ + asm volatile(" \n\ + .align 4 \n\ +." lpfx "swap: / Come here if we need to byte-swap the fn \n\ + pushl eax \n\ + pushl eax \n\ + call byte_swap_code_block / swap it \n\ + popl eax \n\ + popl eax \n\ + jmp %l0" : : "" (&&lbl)); \ + asm volatile(" \n\ + .align 4 \n\ +." lpfx "swap: / Come here if we need to byte-swap the fn \n\ + call byte_swap_ +." lpfx "120:"); + + +#define fn_section4(nargs) \ + { /* it's not a CCODEP */ \ + fn_num_args = nargs /* argcount*/; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + + + +#undef FN0 +#define FN0 \ + { \ + fn_section1(L0120,"0",0); \ + fn_section1a(L0120,"0",0); \ + asm volatile(" \n\ + leal 4(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("0"); \ + /* decl ecx's would go here, 1 per arg */ \ + fn_section3("0",0,L0120); \ + fn_section4(0); \ + } + + +#undef FN1 +#define FN1 \ + { \ + fn_section1(L1120,"1",1); \ + fn_section1a(L1120,"1",1); \ + asm volatile(" \n\ + leal (%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("1"); \ + asm volatile("decl %ecx"); \ + fn_section3("1",1,L1120); \ + fn_section4(1); \ + } + +#undef FN2 +#define FN2 \ + { \ + fn_section1(L2120,"2",2); \ + fn_section1a(L2120,"2",2); \ + asm volatile(" \n\ + leal -4(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("2"); \ + asm volatile("subl $2,%ecx"); \ + fn_section3("2",2,L2120); \ + fn_section4(2); \ + } + +#undef FN3 +#define FN3 \ + { \ + fn_section1(L3120,"3",3); \ + fn_section1a(L3120,"3",3); \ + asm volatile(" \n\ + leal -8(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("3"); \ + asm volatile("subl $3,%ecx"); \ + fn_section3("3",3,L3120); \ + fn_section4(3); \ + } + + +#undef FN4 +#define FN4 \ + { \ + fn_section1(L4120,"4",4); \ + fn_section1a(L4120,"4",4); \ + asm volatile(" \n\ + leal -12(%edi),%ecx // newivar = CSTKPTR-argcount+1"); \ + fn_section2("4"); \ + asm volatile("subl $4,%ecx"); \ + fn_section3("4",4,L4120); \ + fn_section4(4); \ + } + +#undef xFNX +#define xFNX \ + { \ + fnx_section1(Lx120,"x",4); \ + fn_section1a(Lx120,"x",4); \ + asm volatile(" \n\ + movl %0,eax // get num_args \n\ + leal -4(,eax,4),eax \n\ + negl eax \n\ + leal (edi,eax),ecx // newivar = CSTKPTR-argcount+1" : : "g" (num_args)); \ + fn_section2("x"); \ + asm volatile("subl %0,ecx" : : "g" (num_args)); \ + fn_section3("x",4,Lx120); \ + { /* it's not a CCODEP */ \ + fn_num_args = num_args; /* argcount*/ \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + } + + + + + +/************************************************************************/ +/* */ +/* o p r e t u r n */ +/* */ +/* Inline version of the RETURN opcode. */ +/* */ +/************************************************************************/ + +inline extern void opreturn() + { + asm volatile(" \n\ + movl MachineState+4,edx \n\ + movzwl -20(edx),edx \n\ + testb $1,dl \n\ + jne opret_fail \n\ + movl MachineState,edi \n\ + movl Stackspace,ecx \n\ + leal 0(ecx,edx,2),eax \n\ + movl eax,MachineState+4 \n\ + leal -22(eax),edx \n\ + xorb $2,dl \n\ + movzwl (edx),edx \n\ + leal 0(ecx,edx,2),edx \n\ + movl edx,MachineState \n\ + movl -16(eax),ecx \n\ + roll $16,ecx \n\ + andl $16777215,ecx \n\ + addl ecx,ecx \n\ + addl Lisp_world,ecx \n\ + movl ecx,MachineState+20 \n\ + movzwl -12(eax),eax \n\ + leal 1(eax,ecx),esi \n\ + movzwl 2(ecx),edx \n\ + addl edx,edx \n\ + movl MachineState+24,eax \n\ + subl edx,eax \n\ + movl eax,MachineState+28 \n\ + cmpl eax,edi \n\ + jg check_interrupt \n\ + cmpl $0,MachineState+32 \n\ + jle check_interrupt \n\ + movl MachineState+24,ecx \n\ + movl ecx,MachineState+32 \n\ + \n\ + leal -1(esi),eax \n\ + xorb $3,al \n\ + movzbl (eax),eax \n\ + jmp *optable(,eax,4) \n\ + \n\ + .align 4 \n\ +opret_fail:" : : : "ax", "dx", "cx"); + } + +#endif NEVER diff --git a/inc/inlsparc.h b/inc/inlsparc.h new file mode 100755 index 0000000..43ac5b0 --- /dev/null +++ b/inc/inlsparc.h @@ -0,0 +1,175 @@ +/* $Id: inlsparc.h,v 1.2 1999/01/03 02:06:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +/* inlinedefsSPARC.h */ +/* Bob Krivacic, Steve Purcell */ + +/* These are the Macros Used to generate inline SPARC assembly code + to implement the opcodes. Used by both dispatch + loop and native code. +*/ + +/* this is *very* carefully written to generate optimal sun4 assembly code. Be very careful modifying it if you must do so. scp*/ + +/* + Get_BYTE(PCMAC+1); \ +xc.c: #define PCMAC pccache +xc.c: register InstPtr pccache; +xc.c: typedef ByteCode *InstPtr; CHANGED TO +xc.c: typedef BYTECODE *InstPtr; +lispemul.h: typedef char ByteCode; +lispemul.h: #define Get_BYTE(byteptr) (((BYTECODE *)(byteptr))->code) +lispemul.h: typedef struct {unsigned code : 8;} BYTECODE; + */ + +/* shuffle loads to go faster */ +#undef IVARMACRO +#define IVARMACRO(x) { \ + register LispPTR *var = (LispPTR *)IVar; \ + \ + HARD_PUSH(TOPOFSTACK); \ + {register unsigned char opcode; \ + opcode = *(unsigned char *)(PCMAC+1); \ + TOPOFSTACK = *(var + x); \ + PCMACL += 1; \ + fast_dispatcher(table, opcode);} \ + goto nextopcode; } + +#undef PVARMACRO +#define PVARMACRO(x) { \ + register LispPTR *var = (LispPTR *)PVar; \ + \ + HARD_PUSH(TOPOFSTACK); \ + {register unsigned char opcode; \ + opcode = *(unsigned char *)(PCMAC+1); \ + TOPOFSTACK = *(var + x); \ + PCMACL += 1; \ + fast_dispatcher(table, opcode);} \ + goto nextopcode; } + + +#define NSMALLP(x) (((x) >> 17) ^ 7) +#define NSMALLP_RANGE(x) (((x << 15) >>15) ^ x) + +#define UNBOX_SMALLP(sour) ( ((int)sour << 15) >> 15 ) + +#define HARD_CASE(fn) {SV; TOPOFSTACK = fn(POP_TOS_1, TOPOFSTACK, ufn_2); nextop1;} + +#define UNBOX_ELSE(sour, dest, otherwise){ \ + if (NSMALLP(sour)) \ + if (GetTypeNumber(sour) != TYPE_FIXP) otherwise; \ + else dest = FIXP_VALUE(sour); \ + else dest = UNBOX_SMALLP(sour);} + +#define UNBOX_ELSE_UFN(sour, dest) UNBOX_ELSE(sour, dest, goto op_ufn); + +#define BOX_INTO(result, dest){ \ + if (NSMALLP_RANGE(result))/* dest = box_fixp(result);*/ \ + {register LispPTR *wordp; \ + wordp = (LispPTR *) createcell68k(TYPE_FIXP); \ + *((int *)wordp) = result; \ + dest = (LADDR_from_68k(wordp)); } \ + else dest = (( (unsigned)result <<15) >>15) | S_POSITIVE;} + + +#define ARITH_OP(op, exceptions, handler) \ + {register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + if(!NSMALLP(TOPOFSTACK) && !NSMALLP(arg1)) { \ + arg2 = UNBOX_SMALLP(TOPOFSTACK); \ + arg1 = UNBOX_SMALLP(arg1); \ + result = arg1 op arg2; \ + BOX_INTO(result, TOPOFSTACK); \ + POP_TOS_1; \ + nextop1;} \ + N_OP_CALL_2(handler); } + +#define BINARY_OP(exp, exceptions) { \ + register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + UNBOX_ELSE_UFN(arg1, arg1); \ + result = exp; \ + if (exceptions) goto op_ufn; \ + BOX_INTO(result, TOPOFSTACK); \ + POP_TOS_1; nextop1;} + +#undef GREATERP +#undef IGREATERP + +#define GREATERP { \ + register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + UNBOX_ELSE_UFN(arg1, arg1); \ + TOPOFSTACK = (arg1>arg2? ATOM_T : NIL_PTR); \ + POP_TOS_1; nextop1;} + +#define IGREATERP { \ + register int arg1, arg2, result; \ + arg1 = GET_TOS_1; /* w/o side effect */ \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + UNBOX_ELSE_UFN(arg1, arg1); \ + TOPOFSTACK = (arg1>arg2? ATOM_T : NIL_PTR); \ + POP_TOS_1; nextop1;} + +#define OVERFLOW(a,b,r) ( (int)((r^a) & (a^~b)) < 0) +#define SOVERFLOW(a,b,r) ( (int)((r^a) & (a^b)) < 0) +/* overflow is ((arg1>0) == (arg2>0)) && ((result>0) != (arg1>0)) */ + +#undef IPLUS2 +#undef PLUS2 +#define IPLUS2 ARITH_OP(+, OVERFLOW(arg1,arg2,result), N_OP_iplus2) +#define PLUS2 ARITH_OP(+, OVERFLOW(arg1,arg2,result), N_OP_plus2) + +#undef IDIFFERENCE +#undef DIFFERENCE +#define IDIFFERENCE ARITH_OP(-, SOVERFLOW(arg1,arg2,result), N_OP_idifference) +#define DIFFERENCE ARITH_OP(-, SOVERFLOW(arg1,arg2,result), N_OP_difference) + +#undef LOGOR +#undef LOGAND +#undef LOGXOR + +#define LOGOR BINARY_OP(arg1 | arg2, 0) +#define LOGAND BINARY_OP(arg1 & arg2, 0) +#define LOGXOR BINARY_OP(arg1 ^ arg2, 0) + +#define UNARY_OP(exp, exceptions) { \ + register int arg, result; \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg); \ + result = exp; \ + if (exceptions) goto op_ufn; \ + BOX_INTO(result, TOPOFSTACK); \ + nextop1;} + +#undef LRSH8 +#undef LRSH1 +#define LRSH8 UNARY_OP((unsigned)arg >> 8, 0) +#define LRSH1 UNARY_OP((unsigned)arg >> 1, 0) + +#undef LLSH8 +#undef LLSH1 +#define LLSH8 UNARY_OP(arg << 8, ((arg >> 24)!=0)) +#define LLSH1 UNARY_OP(arg << 1, (arg < 0)) + +#undef ADDBASE +#define ADDBASE { \ + register int arg1, arg2; \ + UNBOX_ELSE_UFN(TOPOFSTACK, arg2); \ + TOPOFSTACK = POP_TOS_1 + arg2; \ + nextop1;} + + +#undef SWAP_WORDS +#define SWAP_WORDS(x) swapx(x) diff --git a/inc/iopage.h b/inc/iopage.h new file mode 100755 index 0000000..b882630 --- /dev/null +++ b/inc/iopage.h @@ -0,0 +1,156 @@ +/* $Id: iopage.h,v 1.2 1999/01/03 02:06:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ +#ifndef IOPAGE_DEFINED +#define IOPAGE_DEFINED (1) +#ifndef BYTESWAP +/* Normal definition, for big-indian machines */ +typedef struct iopage { + DLword dummy0[022]; + DLword dlmaintpanel; + DLword dlfloppycmd; + DLword dlttyportcmd; + DLword dlprocessorcmd; + DLword newmousestate; + DLword dlbeepcmd; + DLword dlrs232cmisccommand; + DLword dlrs232cputflag; + DLword dlrs232cgetflag; + DLword dummy1[6]; + DLword dlfloppy; + DLword dlttyout; + DLword dummy2; + DLword dlttyin; + DLword dummy3; + DLword dlprocessor2; + DLword dlprocessor1; + DLword dlprocessor0; + DLword newmousex; + DLword newmousey; + DLword dlbeepfreq; + DLword dlrs232cparametercsblo; + DLword dlrs232cparametercsbhi; + DLword dlrs232csetrs366status[3]; + DLword dlrs232cputcsblo; + DLword dlrs232cputcsbhi; + DLword dlrs232cgetcsblo; + DLword dlrs232cgetcsbhi; + DLword dlrs232cdevicestatus; + DLword dlrs232cparameteroutcome; + DLword dltodvalid; + DLword dltodlo; + DLword dltodhi; + DLword dltodlo2; + DLword dlmousex; + DLword dlmousey; + DLword dlutilin; + DLword dlkbdad0; + DLword dlkbdad1; + DLword dlkbdad2; + DLword dlkbdad3; + DLword dlkbdad4; + DLword dlkbdad5; + DLword dllsepimagecsb[040]; + DLword dliophardwareconfig; + DLword dummy4[013]; + DLword dlrs232cparametercsblo_11; + DLword dlrs232cparametercsbhi_11; + DLword dlrs232csetrs366status_11[016] ; + DLword dummy5[074]; + DLword dlmagtape[4]; + DLword dlethernet[014]; + DLword dummy6[037]; + DLword dldispinterrupt; + DLword dldispcontrol; + DLword dldispborder; + DLword dlcursorx; + DLword dlcursory; + DLword dlcursorbitmap[020]; +} IOPAGE; +#else + /***********************************************************/ + /* Byte-swapped/word-swapped version, for 386i */ + /***********************************************************/ +typedef struct iopage { + DLword dummy0[022]; + DLword dlfloppycmd; + DLword dlmaintpanel; /* hi */ + DLword dlprocessorcmd; + DLword dlttyportcmd; /* hi */ + DLword dlbeepcmd; + DLword newmousestate; /* hi */ + DLword dlrs232cputflag; + DLword dlrs232cmisccommand; /* hi */ + DLword dummy1b; + DLword dlrs232cgetflag; /* hi */ + DLword dummy1[4]; + DLword dlfloppy; + DLword dummy1a; /* hi */ + DLword dummy2; + DLword dlttyout; /* hi */ + DLword dummy3; + DLword dlttyin; /* hi */ + DLword dlprocessor1; + DLword dlprocessor2; /* hi */ + DLword newmousex; + DLword dlprocessor0; /* hi */ + DLword dlbeepfreq; + DLword newmousey; /* hi */ + DLword dlrs232cparametercsbhi; + DLword dlrs232cparametercsblo; /* hi */ + DLword dlrs232csetrs366status[2]; + DLword dlrs232cputcsblo; + DLword dlrs232csetrs366statusa; /* hi */ + DLword dlrs232cgetcsblo; + DLword dlrs232cputcsbhi; /* hi */ + DLword dlrs232cdevicestatus; + DLword dlrs232cgetcsbhi; /* hi */ + DLword dltodvalid; + DLword dlrs232cparameteroutcome; /* hi */ + DLword dltodhi; + DLword dltodlo; /* hi */ + DLword dlmousex; + DLword dltodlo2; /* hi */ + DLword dlutilin; + DLword dlmousey; /* hi */ + DLword dlkbdad1; + DLword dlkbdad0; /* hi */ + DLword dlkbdad3; + DLword dlkbdad2; /* hi */ + DLword dlkbdad5; + DLword dlkbdad4; /* hi */ + DLword dllsepimagecsb[040]; + DLword dummy4a; + DLword dliophardwareconfig; /* hi */ + DLword dummy4[012]; + DLword dlrs232cparametercsbhi_11; + DLword dlrs232cparametercsblo_11; /* hi */ + DLword dlrs232csetrs366status_11[016] ; + DLword dummy5[074]; + DLword dlmagtape[4]; + DLword dlethernet[014]; + DLword dummy6[036]; + DLword dldispinterrupt; + DLword dummy6a; + DLword dldispborder; + DLword dldispcontrol; /* hi */ + DLword dlcursory; + DLword dlcursorx; /* hi */ + DLword dlcursorbitmap[020]; +} IOPAGE; +#endif /* BYTESWAP */ + +#endif diff --git a/inc/kbdif.h b/inc/kbdif.h new file mode 100755 index 0000000..ef7960b --- /dev/null +++ b/inc/kbdif.h @@ -0,0 +1,46 @@ +/* $Id: kbdif.h,v 1.2 1999/01/03 02:06:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/* The Keyboard structure. */ + +typedef struct { + u_char KeyMap[0x80]; +#ifdef DOS + u_char lastbyte; + void (*prev_handler)(); +#endif /* DOS */ + void (* sync_device)(); /* Make reality and emualtor coinside with eachother */ + void (* enter_device)(); + void (* exit_device)(); + void (* device_event)(); + void (* before_raid)(); + void (* after_raid)(); + int lispkeycode; +#ifdef DOS + int device_active; + int device_locked; +#endif /* DOS */ +} KbdInterfaceRec, *KbdInterface; + + +#ifndef TRUE +#define FALSE 0 +#define TRUE !FALSE +#endif /* TRUE */ diff --git a/inc/keyboard.h b/inc/keyboard.h new file mode 100755 index 0000000..9ff76b8 --- /dev/null +++ b/inc/keyboard.h @@ -0,0 +1,196 @@ +/* $Id: keyboard.h,v 1.2 1999/01/03 02:06:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/** Header File for K/B MOUSE */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define MOUSE_LEFT 13 +#define MOUSE_MIDDLE 15 +#define MOUSE_RIGHT 14 +#define CAPSKEY 16 +#define DLMOUSEUP 0 +#define DLMOUSEWAITING 1 +#define DLMOUSENORMAL 2 +#define MOUSE_ALLBITS 7 +#define KB_ALLUP 0xffff +#define HARDCURSORHEIGHT 16 + +#ifndef BYTESWAP +typedef struct + { + DLword read; + DLword write; + } RING; +#else +typedef struct + { + DLword write; + DLword read; + } RING; +#endif /* BYTESWAP */ + + + /* macros for getting to the next-read and next-write ring buf ptrs */ +#define RING_READ(head68k) (((RING*)(head68k))->read) +#define RING_WRITE(head68k) (((RING*)(head68k))->write) + + +/* for feature use */ +#ifndef BYTESWAP +typedef struct + { + DLword mousex; + DLword mousey; + DLword utilin; + DLword kbdad0; + DLword kbdad1; + DLword kbdad2; + DLword kbdad3; + DLword kbdad4; + DLword kbdad5; + DLword nil; + } IOState; + + /* Corresponds to the Lisp KEYBOARDEVENT structure */ +typedef struct + { + DLword W0; + DLword W1; + DLword W2; + DLword W3; + DLword WU; + DLword W4; + DLword W5; + /* int time; */ + short timehi; + short timelo; + unsigned mousestate : 3; + unsigned shift1 : 1; + unsigned shift2 : 1; + unsigned lock : 1; + unsigned ctrl : 1; + unsigned meta : 1; + unsigned font : 1; + unsigned usermode1 : 1; + unsigned usermode2 : 1; + unsigned usermode3 : 1; + unsigned altgr : 1; + unsigned deadkey : 1; + unsigned nil : 2; + DLword mousex; + DLword mousey; + /* DLword nil2; */ + LispPTR deadkeyalist; + } KBEVENT; + +#define RCLK(place) { struct timeval time;\ + gettimeofday(&time,NULL);\ + (place)=(time.tv_sec * 1000000)+time.tv_usec;} + +#else +typedef struct + { + DLword mousey; + DLword mousex; + DLword kbdad0; + DLword utilin; + DLword kbdad2; + DLword kbdad1; + DLword kbdad4; + DLword kbdad3; + DLword nil; + DLword kbdad5; + } IOState; + + /* Corresponds to the Lisp KEYBOARDEVENT structure */ +typedef struct + { + DLword W1; + DLword W0; + DLword W3; + DLword W2; + DLword W4; + DLword WU; + DLword timehi; + DLword W5; + short timelo; + + DLword mousex; + unsigned nil : 4; + unsigned usermode3 : 1; + unsigned usermode2 : 1; + unsigned usermode1 : 1; + unsigned font : 1; + unsigned meta : 1; + unsigned ctrl : 1; + unsigned lock : 1; + unsigned shift2 : 1; + unsigned shift1 : 1; + unsigned mousestate : 3; +/* DLword nil2; */ + DLword mousey; + LispPTR deadkeyalist; + } KBEVENT; /* CHANGED-BY-TAKE ***/ + +/*** OBSLOETE +**#define RCLK(hi,lo) \ + { \ + struct timeval time;\ + int timetemp; \ + gettimeofday(&time,NULL);\ + timetemp = (time.tv_sec * 1000000)+time.tv_usec; \ + (hi)=(DLword)(timetemp>>16); \ + (lo) = (DLword)(timetemp & 0xFFFF); \ +} +******/ +#define RCLK(place) { struct timeval time;\ + gettimeofday(&time,NULL);\ + (place)=(time.tv_sec * 1000000)+time.tv_usec;} + +#endif /* BYTESWAP */ + + + + + /* Size of a KEYBOARDEVENT structure, and */ + /* the size of the kbd-event ring buffer */ +#define MINKEYEVENT 2 /* leave 2 words for read,write offsets */ +#ifdef NOEUROKBD /* set to disable new european kbd support */ +#define KEYEVENTSIZE 12 +#else +#define KEYEVENTSIZE ((sizeof(KBEVENT)+1)>>1) +#endif + /* Offset of the end of the ring buffer */ +#define MAXKEYEVENT (MINKEYEVENT + (383*KEYEVENTSIZE)) +#define NOEUROKEYEVENTSIZE 12 +#define EUROKEYEVENTSIZE ((sizeof(KBEVENT) + 1) >> 1) +#define NUMBEROFKEYEVENTS 383 + + +typedef union +{ + struct + { + RING vectorindex; /* Index for the vector of DLwords in this structure */ + KBEVENT event[NUMBEROFKEYEVENTS + 1]; + } ring; + /* The array of KBEVENTS (indexed by DLword) for euro */ + DLword euro[MINKEYEVENT + (NUMBEROFKEYEVENTS * EUROKEYEVENTSIZE)]; + /* The array of KBEVENTS (indexed by DLword) for noeuro */ + DLword noeuro[MINKEYEVENT + (NUMBEROFKEYEVENTS * NOEUROKEYEVENTSIZE)]; + } keybuffer; + diff --git a/inc/keyboard.h% b/inc/keyboard.h% new file mode 100755 index 0000000..31a5f25 --- /dev/null +++ b/inc/keyboard.h% @@ -0,0 +1,195 @@ +/* %Z% %M% Version %I% (%G%). copyright venue */ + + +/** Header File for K/B MOUSE */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define MOUSE_LEFT 13 +#define MOUSE_MIDDLE 15 +#define MOUSE_RIGHT 14 +#define CAPSKEY 16 +#define DLMOUSEUP 0 +#define DLMOUSEWAITING 1 +#define DLMOUSENORMAL 2 +#define MOUSE_ALLBITS 7 +#define KB_ALLUP 0xffff +#define HARDCURSORHEIGHT 16 + +#ifndef BYTESWAP +typedef struct + { + DLword read; + DLword write; + } RING; +#else +typedef struct + { + DLword write; + DLword read; + } RING; +#endif /* BYTESWAP */ + + + /* macros for getting to the next-read and next-write ring buf ptrs */ +#define RING_READ(head68k) (((RING*)(head68k))->read) +#define RING_WRITE(head68k) (((RING*)(head68k))->write) + + +/* for feature use */ +#ifndef BYTESWAP +typedef struct + { + DLword mousex; + DLword mousey; + DLword utilin; + DLword kbdad0; + DLword kbdad1; + DLword kbdad2; + DLword kbdad3; + DLword kbdad4; + DLword kbdad5; + DLword nil; + } IOState; + + /* Corresponds to the Lisp KEYBOARDEVENT structure */ +typedef struct + { + DLword W0; + DLword W1; + DLword W2; + DLword W3; + DLword WU; + DLword W4; + DLword W5; + /* int time; */ + short timehi; + short timelo; + unsigned mousestate : 3; + unsigned shift1 : 1; + unsigned shift2 : 1; + unsigned lock : 1; + unsigned ctrl : 1; + unsigned meta : 1; + unsigned font : 1; + unsigned usermode1 : 1; + unsigned usermode2 : 1; + unsigned usermode3 : 1; + unsigned altgr : 1; + unsigned deadkey : 1; + unsigned nil : 2; + DLword mousex; + DLword mousey; + /* DLword nil2; */ + LispPTR deadkeyalist; + } KBEVENT; + +#define RCLK(place) { struct timeval time;\ + gettimeofday(&time,NULL);\ + (place)=(time.tv_sec * 1000000)+time.tv_usec;} + +#else +typedef struct + { + DLword mousey; + DLword mousex; + DLword kbdad0; + DLword utilin; + DLword kbdad2; + DLword kbdad1; + DLword kbdad4; + DLword kbdad3; + DLword nil; + DLword kbdad5; + } IOState; + + /* Corresponds to the Lisp KEYBOARDEVENT structure */ +typedef struct + { + DLword W1; + DLword W0; + DLword W3; + DLword W2; + DLword W4; + DLword WU; + DLword timehi; + DLword W5; + short timelo; + + DLword mousex; + unsigned nil : 4; + unsigned usermode3 : 1; + unsigned usermode2 : 1; + unsigned usermode1 : 1; + unsigned font : 1; + unsigned meta : 1; + unsigned ctrl : 1; + unsigned lock : 1; + unsigned shift2 : 1; + unsigned shift1 : 1; + unsigned mousestate : 3; +/* DLword nil2; */ + DLword mousey; + LispPTR deadkeyalist; + } KBEVENT; /* CHANGED-BY-TAKE ***/ + +/*** OBSLOETE +**#define RCLK(hi,lo) \ + { \ + struct timeval time;\ + int timetemp; \ + gettimeofday(&time,NULL);\ + timetemp = (time.tv_sec * 1000000)+time.tv_usec; \ + (hi)=(DLword)(timetemp>>16); \ + (lo) = (DLword)(timetemp & 0xFFFF); \ +} +******/ +#define RCLK(place) { struct timeval time;\ + gettimeofday(&time,NULL);\ + (place)=(time.tv_sec * 1000000)+time.tv_usec;} + +#endif /* BYTESWAP */ + + + + + /* Size of a KEYBOARDEVENT structure, and */ + /* the size of the kbd-event ring buffer */ +#define MINKEYEVENT 2 /* leave 2 words for read,write offsets */ +#ifdef NOEUROKBD /* set to disable new european kbd support */ +#define KEYEVENTSIZE 12 +#else +#define KEYEVENTSIZE ((sizeof(KBEVENT)+1)>>1) +#endif + /* Offset of the end of the ring buffer */ +#define MAXKEYEVENT (MINKEYEVENT + (383*KEYEVENTSIZE)) +#define NOEUROKEYEVENTSIZE 12 +#define EUROKEYEVENTSIZE ((sizeof(KBEVENT) + 1) >> 1) + + +typedef union +{ + struct + { + RING vectorindex; /* Index for the vector of DLwords in this structure */ + KBEVENT event[NUMBEROFKEYEVENTS + 1]; + } ring; + /* The array of KBEVENTS (indexed by DLword) for euro */ + DLword euro[MINKEYEVENT + (NUMBEROFKEYEVENTS * EUROKEYEVENTSIZE)]; + /* The array of KBEVENTS (indexed by DLword) for noeuro */ + DLword noeuro[MINKEYEVENT + (NUMBEROFKEYEVENTS * NOEUROKEYEVENTSIZE)]; + } keybuffer; + diff --git a/inc/keysym.h b/inc/keysym.h new file mode 100755 index 0000000..b745ad9 --- /dev/null +++ b/inc/keysym.h @@ -0,0 +1,133 @@ +/* $Id: keysym.h,v 1.2 1999/01/03 02:06:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* * * * D O S K E Y B O A R D M A P P I N G S * * * */ + + +#define KEY_5 0 +#define KEY_4 1 +#define KEY_6 2 +#define KEY_E 3 +#define KEY_7 4 +#define KEY_D 5 +#define KEY_U 6 +#define KEY_V 7 +#define KEY_0 8 +#define KEY_K 9 +#define KEY_MINUS 10 +#define KEY_P 11 +#define KEY_SLASH 12 +#define KEY_BACKSPACE 13 +#define KEY_SAME 14 +#define KEY_DEL 15 +#define KEY_3 16 +#define KEY_2 17 +#define KEY_W 18 +#define KEY_Q 19 +#define KEY_S 20 +#define KEY_A 21 +#define KEY_9 22 +#define KEY_I 23 +#define KEY_X 24 +#define KEY_O 25 +#define KEY_L 26 +#define KEY_COMMA 27 +#define KEY_QUOTE 28 +#define KEY_CLOSEBRACK 29 +/* KEY_NOT_USED 30 */ +#define KEY_LEFTMETA 31 +#define KEY_1 32 +#define KEY_ESC 33 +#define KEY_TAB 34 +#define KEY_F 35 +#define KEY_CTRL 36 +#define KEY_C 37 +#define KEY_J 38 +#define KEY_B 39 +#define KEY_Z 40 +#define KEY_LEFTSHIFT 41 +#define KEY_PERIOD 42 +#define KEY_SEMICOLON 43 +#define KEY_RETURN 44 +#define KEY_BACKQUOTE 45 +/* #define KEY_DEL 46 */ +#define KEY_NEXT 47 +#define KEY_R 48 +#define KEY_T 49 +#define KEY_G 50 +#define KEY_Y 51 +#define KEY_H 52 +#define KEY_8 53 +#define KEY_N 54 +#define KEY_M 55 +/* #define KEY_CAPSLOCK 56 */ +#define KEY_SPACE 57 +#define KEY_OPENBRACK 58 +#define KEY_EQUAL 59 +#define KEY_RIGHTSHIFT 60 +#define KEY_STOP 61 +#define KEY_MOVE 62 +#define KEY_UNDO 63 +#define KEY_PK_EQUAL 64 +#define KEY_KP_SLASH 65 +#define KEY_SUPERSCRIPT 66 +#define KEY_CASE 67 +#define KEY_STRIKEOUT 68 +#define KEY_KP_2 69 +#define KEY_KP_3 70 +#define KEY_LINEFEED 71 +#define KEY_CAPSLOCK 72 +#define KEY_NUMLOCK 73 +#define KEY_SCROLLOCK 74 +#define KEY_BREAK 75 +#define KEY_DOIT 76 +/* KEY_NOT_USED 77 */ +/* KEY_NOT_USED 78 */ +/* KEY_NOT_USED 79 */ +#define KEY_MARGIN 80 +#define KEY_KP_HOME 81 +#define KEY_KP_8 82 +#define KEY_KP_9 83 +#define KEY_KP_4 84 +#define KEY_KP_5 85 +#define KEEY_LEFT_SPC 86 +#define KEY_KP_6 87 +#define KEY_RIGHT_SPC 88 +#define KEY_COPY 89 +#define KEY_FIND 90 +#define KEY_AGAIN 91 +#define KEY_HELP 92 +#define KEY_EXPAND 93 +#define KEY_KP_END 94 +#define KEY_KP_TIMES 95 +#define KEY_KP_MINUS 96 +#define KEY_CENTER 97 +#define KEY_KP_INS 98 +#define KEY_BOLD 99 +#define KEY_ITALIC 100 +#define KEY_UNDERLINE 101 +#define KEY_KP_PLUS 102 +/* KEY_NOT_USED 103 */ +#define KEY_LARGER 104 +#define KEY_BACKSLASH 105 +#define KEY_LOOKS 106 +#define KEY_F11 107 +#define KEY_F12 108 +#define KEY_PROPS 109 +#define KEY_PRSC 110 +#define KEY_OPEN 111 diff --git a/inc/ldeXdefs.h b/inc/ldeXdefs.h new file mode 100755 index 0000000..f441c8c --- /dev/null +++ b/inc/ldeXdefs.h @@ -0,0 +1,43 @@ +/* $Id: ldeXdefs.h,v 1.2 1999/01/03 02:06:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* * * * * X defs for all files in Medley * * * * */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef __LDEXDEF__ + +#define __LDEXDEF__ 1 +#include +#ifdef LOCK_X_UPDATES +#define XLOCK { XLocked++; /* printf("L"); fflush(stdout);*/} +#define XUNLOCK \ + { XLocked--;/* printf("U"); fflush(stdout);*/ \ + if (XNeedSignal) \ + { \ + XNeedSignal = 0; \ + kill(getpid(), SIGPOLL); \ + }; \ + } +#else +#define XLOCK +#define XUNLOCK +#endif /* LOCK_X_UPDATES */ + +extern int XLocked; +extern int XNeedSignal; +/* this is !0 if we're locked; it should be 0 or larger always */ +#endif + diff --git a/inc/lispemul.h b/inc/lispemul.h new file mode 100755 index 0000000..b72494a --- /dev/null +++ b/inc/lispemul.h @@ -0,0 +1,640 @@ +/* $Id: lispemul.h,v 1.4 2001/12/24 01:08:57 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + + +#ifndef BYTESWAP + /*** Normal byte-order type decls */ +typedef struct {unsigned char code;} BYTECODE; +typedef char ByteCode; +typedef unsigned short DLword; +typedef char DLbyte; +typedef unsigned int LispPTR; +/* 32 bit Cell Chang. 14 Jan 87 take */ +typedef DLword mds_page; /* Top word of the MDS */ +typedef (*CFuncPTR)(); + +#ifdef BIGVM +typedef struct consstr + { + unsigned cdr_code : 4; + unsigned car_field : 28; + } ConsCell; + +typedef struct ufn_entry + { + DLword atom_name; /* UFN's atomindex */ + unsigned byte_num : 8; /* num of byte code */ + unsigned arg_num : 8; /* num of argments */ + } UFN; + +typedef struct closure_type + { + unsigned nil1 : 4; + unsigned def_ptr : 28; /* LispPTR to definition cell */ + unsigned nil2 : 4; + unsigned env_ptr : 28; /* LispPTR to environment */ + } Closure; + +#else /* not BIGVM */ +typedef struct consstr + { + unsigned cdr_code : 8; + unsigned car_field : 24; + } ConsCell; + +typedef struct ufn_entry + { + DLword atom_name; /* UFN's atomindex */ + unsigned byte_num : 8; /* num of byte code */ + unsigned arg_num : 8; /* num of argments */ + } UFN; + +typedef struct closure_type + { + unsigned nil1 : 8; + unsigned def_ptr : 24; /* LispPTR to definition cell */ + unsigned nil2 : 8; + unsigned env_ptr : 24; /* LispPTR to environment */ + } Closure; +#endif /* BIGVM */ + +typedef struct interrupt_state + { /* Interrupt-request mask to communicate with INTERRUPTED */ + unsigned LogFileIO :1; /* console msg arrived to print */ + unsigned ETHERInterrupt :1; /* 10MB activity happened */ + unsigned IOInterrupt :1; /* I/O happened (not used yet) */ + unsigned gcdisabled :1; + unsigned vmemfull :1; + unsigned stackoverflow :1; + unsigned storagefull :1; + unsigned waitinginterrupt :1; + unsigned nil :8; /* mask of ints being processes */ + DLword intcharcode; + } INTSTAT; + +typedef struct interrupt_state_2 + { /* alternate view of the interrupt state */ + unsigned pendingmask :8; + unsigned handledmask :8; + DLword nil; + } INTSTAT2; + +struct state + { + DLword *ivar; /* + 0 */ + DLword *pvar; /* + 4 */ + DLword *csp; /* + 8 */ + LispPTR tosvalue; /* + 12 */ + ByteCode *currentpc; /* + 16 */ + struct fnhead *currentfunc; /* + 20*/ + DLword *endofstack; /* + 24*/ + UNSIGNED irqcheck; /* + 28 */ + UNSIGNED irqend; /* + 32 */ + LispPTR scratch_cstk; /* + 34 */ + int errorexit; /* + 38 */ + }; + +/***** Get_DLword(ptr) ptr is char* ***/ +#ifndef UNALIGNED_FETCH_OK +#define Get_DLword(ptr) ((Get_BYTE(ptr) <<8) | Get_BYTE(ptr+1)) +#else +#define Get_DLword(ptr) *(((DLword *)WORDPTR(ptr))) +#endif + +#ifdef BIGVM +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 24) | \ + (Get_BYTE(ptr+1) << 16) | \ + (Get_BYTE(ptr+2) << 8) | Get_BYTE(ptr+3)) +#else +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 16) | \ + (Get_BYTE(ptr+1) << 8) | \ + Get_BYTE(ptr+2)) +#endif /* BIGVM */ + +#define Get_code_BYTE Get_BYTE +#define Get_code_DLword Get_DLword +#define Get_code_AtomNo Get_AtomNo +#define Get_code_Pointer Get_Pointer + +#ifdef BIGATOMS +#define Get_AtomNo(ptr) Get_Pointer(ptr) +#else +#define Get_AtomNo(ptr) Get_DLword(ptr) +#endif /* BIGATOMS */ + + +/* For bit test */ +typedef struct wbits + { + unsigned xMSB :1; + unsigned B1 :1; + unsigned B2 :1; + unsigned B3 :1; + unsigned B4 :1; + unsigned B5 :1; + unsigned B6 :1; + unsigned B7 :1; + unsigned B8 :1; + unsigned B9 :1; + unsigned B10 :1; + unsigned B11 :1; + unsigned B12 :1; + unsigned B13 :1; + unsigned B14 :1; + unsigned LSB :1; + }WBITS; + +typedef struct lbits + { + unsigned xMSB :1; + unsigned MIDDLE :30; + unsigned LSB :1; + }LBITS; + +#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ + if( bitvalue) \ + *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ + |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ + else \ + *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ + &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ + } + +#else + /*** Byte-swapped structure declarations, for 80386 ***/ +typedef struct {unsigned char code;} BYTECODE; +typedef char ByteCode; +typedef unsigned short DLword; +typedef char DLbyte; +typedef unsigned int LispPTR; +/* 32 bit Cell Chang. 14 Jan 87 take */ +typedef DLword mds_page; /* Top word of the MDS */ +typedef (*CFuncPTR)(); + +#ifdef BIGVM +typedef struct consstr + { + unsigned car_field : 28; + unsigned cdr_code : 4; + } ConsCell; + +typedef struct ufn_entry + { + unsigned arg_num : 8; /* num of argments */ + unsigned byte_num : 8; /* num of byte code */ + DLword atom_name; /* UFN's atomindex */ + } UFN; + +typedef struct closure_type + { + unsigned def_ptr : 28; /* LispPTR to definition cell */ + unsigned nil1 : 4; + unsigned env_ptr : 28; /* LispPTR to environment */ + unsigned nil2 : 4; + } Closure; +#else /* BIGVM */ +typedef struct consstr + { + unsigned car_field : 24; + unsigned cdr_code : 8; + } ConsCell; + +typedef struct ufn_entry + { + unsigned arg_num : 8; /* num of argments */ + unsigned byte_num : 8; /* num of byte code */ + DLword atom_name; /* UFN's atomindex */ + } UFN; + +typedef struct closure_type + { + unsigned def_ptr : 24; /* LispPTR to definition cell */ + unsigned nil1 : 8; + unsigned env_ptr : 24; /* LispPTR to environment */ + unsigned nil2 : 8; + } Closure; +#endif /* BIGVM */ + +typedef struct interrupt_state + { /* Interrupt-request mask to communicate with INTERRUPTED */ + DLword intcharcode; + unsigned nil :8; + unsigned waitinginterrupt :1; + unsigned storagefull :1; + unsigned stackoverflow :1; + unsigned vmemfull :1; + unsigned gcdisabled :1; + unsigned IOInterrupt :1; /* I/O happened (not used yet) */ + unsigned ETHERInterrupt :1; /* 10MB activity happened */ + unsigned LogFileIO :1; /* console msg arrived to print */ + } INTSTAT; + +typedef struct interrupt_state_2 + { /* alternate view of the interrupt state */ + DLword nil; + unsigned handledmask :8; + unsigned pendingmask :8; + } INTSTAT2; + + +struct state + { + DLword *ivar; /* + 0 */ + DLword *pvar; /* + 4 */ + DLword *csp; /* + 8 */ + LispPTR tosvalue; /* + 12 */ + ByteCode *currentpc; /* + 16 */ + struct fnhead *currentfunc; /* + 20*/ + DLword *endofstack; /* + 24*/ + UNSIGNED irqcheck; /* + 28 */ + UNSIGNED irqend; /* + 32 */ + LispPTR scratch_cstk; /* + 34 */ + int errorexit; /* + 38 */ + }; + +/* Fetching 2 bytes to make a word -- always do it the hard way */ +/* if we're byte-swapped: You can't rely on byte ordering!! */ +#define Get_DLword(ptr) ((Get_BYTE(ptr) <<8) | Get_BYTE(ptr+1)) + +#ifdef BIGVM +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 24) | \ + (Get_BYTE(ptr+1) << 16) | \ + (Get_BYTE(ptr+2) << 8) | Get_BYTE(ptr+3)) +#else +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 16) | \ + (Get_BYTE(ptr+1) << 8) | \ + Get_BYTE(ptr+2)) +#endif /* BIGVM */ + +#ifndef RESWAPPEDCODESTREAM +#define Get_code_BYTE(ptr) Get_BYTE(ptr) +#define Get_code_AtomNo Get_AtomNo +#define Get_code_DLword Get_DLword +#else +#define Get_code_BYTE(ptr) (((BYTECODE *)(ptr))->code) + +#define Get_code_Pointer(ptr) ((Get_code_BYTE(ptr) << 16) | \ + (Get_code_BYTE(ptr+1) << 8) | \ + Get_code_BYTE(ptr+2)) +#define Get_code_DLword(ptr) ((Get_code_BYTE(ptr) << 8) | Get_code_BYTE(ptr+1)) +#define Get_code_AtomNo Get_code_Pointer +#endif /* RESWAPPEDCODESTREAM */ + + +#ifdef BIGATOMS +#define Get_AtomNo(ptr) Get_Pointer(ptr) +#else +#define Get_AtomNo(ptr) Get_DLword(ptr) +#endif /* BIGATOMS */ + + +/* For bit test */ +typedef struct wbits + { + USHORT LSB :1; + USHORT B14 :1; + USHORT B13 :1; + USHORT B12 :1; + USHORT B11 :1; + USHORT B10 :1; + USHORT B9 :1; + USHORT B8 :1; + USHORT B7 :1; + USHORT B6 :1; + USHORT B5 :1; + USHORT B4 :1; + USHORT B3 :1; + USHORT B2 :1; + USHORT B1 :1; + USHORT xMSB :1; + } WBITS; + +typedef struct lbits + { + unsigned LSB :1; + unsigned MIDDLE :30; + unsigned xMSB :1; /* xMSB b/c HPUX defined MSB in a header */ + } LBITS; + +#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ + UNSIGNED real68kbase; \ + real68kbase = 2 ^ ((UNSIGNED)(base68k)); \ + if( bitvalue) \ + (* (DLword *) (2^(UNSIGNED)((DLword*)(real68kbase) + (((u_short)(offset))>>4 )))) \ + |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ + else \ + (* (DLword *) (2^(UNSIGNED)((DLword*)(real68kbase) + (((u_short)(offset))>>4 )))) \ + &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ + } + +#endif /* BYTESWAP */ + + + + /* Because a WBITS is only 1 word long, need byte-swapped */ + /* access to it. Use WBITSPTR(x) instead of ((WBITS *) x) */ + +#define WBITSPTR(ptr) ((WBITS *) WORDPTR(ptr)) + + +extern struct state MachineState; + +#define MState (&MachineState) +#define CURRENTFX ((struct frameex1 *)(((DLword *) PVar) - FRAMESIZE)) +#define IVar (MState->ivar) +#define PVar (MState->pvar) +#define CurrentStackPTR (MState->csp) +#define TopOfStack (MState->tosvalue) +#define PC (MState->currentpc) +#define FuncObj (MState->currentfunc) +#define EndSTKP (MState->endofstack) +#define Irq_Stk_Check (MState->irqcheck) +#define Irq_Stk_End (MState->irqend) +#define Scratch_CSTK (MState->scratch_cstk) +#define Error_Exit (MState->errorexit) + +/* Typedef for IFPAGE */ +#include "ifpage.h" + +/* Typedef for IOPAGE */ +#include "iopage.h" + + +/* Typedef for MISCSTAT */ +#include "miscstat.h" + +/**************************************************** + MakeAddr: + base: DLword* + offset: word offset from base + return: DLword* +****************************************************/ +#define MakeAddr(base, offset) ((DLword *)(base + (int)offset)) + + +/**************************************************** +GetHiWord: +*****************************************************/ +#define GetHiWord(x) ((DLword)((x)>>16)) + +/**************************************************** +GetLoWord: +*****************************************************/ +#define GetLoWord(x) ((DLword)(x)) + +/**************************************************** +GetLongWord: + address: DLword* + retrun: int +*****************************************************/ +#define GetLongWord(address) (*((LispPTR *) (address))) + + +/**************************************************** +PopCStack: +#define PopCStack {TopOfStack = *((LispPTR *)(--CurrentStackPTR)); --CurrentStackPTR;} +*****************************************************/ +#define PopCStack {TopOfStack = *((LispPTR *)(CurrentStackPTR)); CurrentStackPTR -= 2;} + +/**************************************************** +PopStackTo: CSTK -> Place +#define PopStackTo(Place) {Place= *((LispPTR *)(--CurrentStackPTR)); CurrentStackPTR--; } +*****************************************************/ +#define PopStackTo(Place) {Place= *((LispPTR *)(CurrentStackPTR)); CurrentStackPTR -= 2; } + +/**************************************************** +PushCStack: +#define PushCStack {*((int *)(++CurrentStackPTR)) = TopOfStack; ++CurrentStackPTR;} +*****************************************************/ +#define PushCStack {CurrentStackPTR += 2;*((LispPTR *)(CurrentStackPTR)) = TopOfStack; } + +/**************************************************** +PushStack: +#define PushStack(x) {*((LispPTR *)(++CurrentStackPTR))=x;CurrentStackPTR++;} +*****************************************************/ +#define PushStack(x) {CurrentStackPTR += 2;*((LispPTR *)(CurrentStackPTR))=x;} + +/**************************************************** +SmashStack: +#define SmashStack(x) (*((LispPTR *)(CurrentStackPTR-1))=x) +*****************************************************/ +#define SmashStack(x) (*((LispPTR *)(CurrentStackPTR))=x) + +/********************************************************* +Get_BYTE(byteptr) byteptr: pointer to 8 bit data +**********************************************************/ +/***** OLD definition ************* 13 Nov 1987 takeshi *** +#define Get_BYTE(byteptr) (((unsigned)(*(byteptr))) & 0xff) +**********************************************/ +#define Get_BYTE(byteptr) (((BYTECODE *)BYTEPTR(byteptr))->code) + +/********************************************************** +DOSTACKOVERFLOW(argnum,bytenum) if it needs hardreturn-cleanup + then upnt to contextsw and immediately return +**********************************************************/ +#define DOSTACKOVERFLOW(argnum,bytenum) { \ + if(do_stackoverflow(T)) \ + { PushStack(S_POSITIVE | argnum); \ + contextsw(SubovFXP,bytenum,1); \ + return;\ + } \ + } + + + + +/************************************************************************/ +/* */ +/* E X T E R N A L F U N C T I O N S */ +/* */ +/* Declare all functions that will default incorrectly under */ +/* normal C inference rules. These functions are the ones */ +/* that return pointers, because on DEC Alpha, a pointer is 8 */ +/* bytes--but the default fn decl is int, a 4-byte return. */ +/* */ +/************************************************************************/ + +extern DLword *createcell68k(unsigned int type); +extern LispPTR *alloc_mdspage(register short int type); +extern UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep); +extern char *getenv(const char *); +#include + + + +/************************************************************************/ +/* */ +/* E R R O R & T I M E R P U N T C A S E S */ +/* */ +/* Set up the top-of-stack so we can continue gracefully after */ +/* handling the timer interrupt (e.g., FMEMB, which walks down */ +/* the list being searched, pushes its current state on TOS */ +/* so that it picks up where it left off after the interrupt. */ +/* */ +/* Call Interface where neg number indicates an error return */ +/* */ +/************************************************************************/ + +#define ERROR_EXIT(tos) {TopOfStack=tos; Error_Exit = 1; return(-1);} +#ifdef ISC +#define INLINE_ERROR_EXIT(tos,retlbl) {TopOfStack=tos; Error_Exit=1 asm("movl $-1,%0\n" retlbl ":" : "=g" (result) : "0" (result)); return(result); } +#endif + +#define TIMER_EXIT(tos) {TopOfStack=tos; Error_Exit = 1; return(-2);} + + +#define WARN(message,operation) {warn(message);operation;return;} +#define NO_WOP {} + +#define NIL 0 /* added 29-jan */ +#define T 1 +#define ATOM_T 0114 /* T's AtomIndex Number 114Q */ + +#define NIL_PTR 0 /* from cell.h 24-mar-87 take */ +#define NOBIND_PTR 1 + +#define STKLIM 0x1FFFF +#define FRAMESIZE 10 /* size of frameex1: 10 words */ +#define FNHEADSIZE 8 /* size of fnhead: 8 words */ +#define BFSIZE 2 /* size of basci frame pointer: 2 words */ + +#define BITSPER_DLWORD 16 +#define BITSPER_CELL 32 +#define BYTESPER_DLWORD 2 +#define BYTESPER_CELL 4 +#define BYTESPER_QUAD 8 +#define BYTESPER_PAGE 512 +#define CELLSPER_QUAD 2 +#define CELLSPER_PAGE 128 +#define CELLSPER_SEGMENT 32768 +#define DLWORDSPER_CELL 2 +#define DLWORDSPER_QUAD 4 +#define DLWORDSPER_PAGE 256 +#define DLWORDSPER_SEGMENT 65536 +#define PAGESPER_SEGMENT 256 +#define PAGESPER_MDSUNIT 2 +#define MDSINCREMENT 512 + +#define GUARDSTORAGEFULL 128 +#define GUARD1STORAGEFULL 64 + +#define SFS_NOTSWITCHABLE 1 +#define SFS_SWITCHABLE 2 +#define SFS_ARRAYSWITCHED 3 +#define SFS_FULLYSWITCHED 4 + + +#define AtomHTSIZE 256 * DLWORDSPER_PAGE + +#define MAXPNCHARS 255 /* Maximam length of PnChars */ + +#define GET_NATIVE_ADDR(fnobject) \ + *((int *) ((UNSIGNED)fnobject + fnobject->startpc - 4)) + + +#define FALSE 0 +#define TRUE !FALSE + +typedef unsigned int boolean; + + +/************************************************************************/ +/* Define sizes of FN and FNX opcodes; depends on atom size */ +/************************************************************************/ + +#ifdef BIGVM +#define FN_OPCODE_SIZE 5 +#define FNX_OPCODE_SIZE 6 +#elif defined(BIGATOMS) +#define FN_OPCODE_SIZE 4 +#define FNX_OPCODE_SIZE 5 +#else +#define FN_OPCODE_SIZE 3 +#define FNX_OPCODE_SIZE 4 +#endif /* BIGATOMS */ + + + +/************************************************************************/ +/* */ +/* Definitions for "NEW" Symbols */ +/* */ +/* Offsets within the "New symbols that go with 3-byte atoms. */ +/* */ +/************************************************************************/ +#ifdef BIGATOMS + +typedef struct newatom + { + LispPTR na_pname; /* Pointer to the print name */ + LispPTR na_value; /* The value cell */ + LispPTR na_defn; /* The definition cell */ + LispPTR na_plist; /* The property list */ + LispPTR na_flags; /* flags from other cells, to make BIGVM work ok */ + } NEWATOM; + + /* Offsets, in WORDS, from the start of the NEWATOM structure */ +#define NEWATOM_PNAME_OFFSET 0 +#define NEWATOM_VALUE_OFFSET 2 +#define NEWATOM_DEFN_OFFSET 4 +#define NEWATOM_PLIST_OFFSET 6 + + + /* Offsets, in cells from start of the NEWATOM structure */ +#define NEWATOM_PNAME_PTROFF 0 +#define NEWATOM_VALUE_PTROFF 1 +#define NEWATOM_DEFN_PTROFF 2 +#define NEWATOM_PLIST_PTROFF 3 +#endif + + + +/************************************************************************/ +/* */ +/* Mask to mask off relevant bits in a pointer. */ +/* */ +/************************************************************************/ +#ifdef BIGVM +#define POINTERMASK 0xfffffff +#define SEGMASK 0xfff0000 +#define mPAGEMASK 0xfffff00 +#else +#define POINTERMASK 0xffffff +#define SEGMASK 0xff0000 +#define mPAGEMASK 0xffff00 +#endif /* BIGVM */ + + + + +/************************************************************************/ +/* */ +/* F P t o V P M a n i p u l a t i o n */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifdef BIGVM +#define GETFPTOVP(b,o) b[o] +#define GETPAGEOK(b,o) (b[o]>>16) +#else +#define GETFPTOVP GETWORDBASEWORD +#define GETPAGEOK GETWORDBASEWORD +#endif diff --git a/inc/lispemul.h.save b/inc/lispemul.h.save new file mode 100755 index 0000000..5f5b966 --- /dev/null +++ b/inc/lispemul.h.save @@ -0,0 +1,640 @@ +/* $Id: lispemul.h,v 1.3 1999/01/03 02:06:08 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + + +#ifndef BYTESWAP + /*** Normal byte-order type decls */ +typedef struct {unsigned char code;} BYTECODE; +typedef char ByteCode; +typedef unsigned short DLword; +typedef char DLbyte; +typedef unsigned int LispPTR; +/* 32 bit Cell Chang. 14 Jan 87 take */ +typedef DLword mds_page; /* Top word of the MDS */ +typedef (*CFuncPTR)(); + +#ifdef BIGVM +typedef struct consstr + { + unsigned cdr_code : 4; + unsigned car_field : 28; + } ConsCell; + +typedef struct ufn_entry + { + DLword atom_name; /* UFN's atomindex */ + unsigned byte_num : 8; /* num of byte code */ + unsigned arg_num : 8; /* num of argments */ + } UFN; + +typedef struct closure_type + { + unsigned nil1 : 4; + unsigned def_ptr : 28; /* LispPTR to definition cell */ + unsigned nil2 : 4; + unsigned env_ptr : 28; /* LispPTR to environment */ + } Closure; + +#else /* not BIGVM */ +typedef struct consstr + { + unsigned cdr_code : 8; + unsigned car_field : 24; + } ConsCell; + +typedef struct ufn_entry + { + DLword atom_name; /* UFN's atomindex */ + unsigned byte_num : 8; /* num of byte code */ + unsigned arg_num : 8; /* num of argments */ + } UFN; + +typedef struct closure_type + { + unsigned nil1 : 8; + unsigned def_ptr : 24; /* LispPTR to definition cell */ + unsigned nil2 : 8; + unsigned env_ptr : 24; /* LispPTR to environment */ + } Closure; +#endif /* BIGVM */ + +typedef struct interrupt_state + { /* Interrupt-request mask to communicate with INTERRUPTED */ + unsigned LogFileIO :1; /* console msg arrived to print */ + unsigned ETHERInterrupt :1; /* 10MB activity happened */ + unsigned IOInterrupt :1; /* I/O happened (not used yet) */ + unsigned gcdisabled :1; + unsigned vmemfull :1; + unsigned stackoverflow :1; + unsigned storagefull :1; + unsigned waitinginterrupt :1; + unsigned nil :8; /* mask of ints being processes */ + DLword intcharcode; + } INTSTAT; + +typedef struct interrupt_state_2 + { /* alternate view of the interrupt state */ + unsigned pendingmask :8; + unsigned handledmask :8; + DLword nil; + } INTSTAT2; + +struct state + { + DLword *ivar; /* + 0 */ + DLword *pvar; /* + 4 */ + DLword *csp; /* + 8 */ + LispPTR tosvalue; /* + 12 */ + ByteCode *currentpc; /* + 16 */ + struct fnhead *currentfunc; /* + 20*/ + DLword *endofstack; /* + 24*/ + UNSIGNED irqcheck; /* + 28 */ + UNSIGNED irqend; /* + 32 */ + LispPTR scratch_cstk; /* + 34 */ + int errorexit; /* + 38 */ + }; + +/***** Get_DLword(ptr) ptr is char* ***/ +#ifndef UNALIGNED_FETCH_OK +#define Get_DLword(ptr) ((Get_BYTE(ptr) <<8) | Get_BYTE(ptr+1)) +#else +#define Get_DLword(ptr) *(((DLword *)WORDPTR(ptr))) +#endif + +#ifdef BIGVM +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 24) | \ + (Get_BYTE(ptr+1) << 16) | \ + (Get_BYTE(ptr+2) << 8) | Get_BYTE(ptr+3)) +#else +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 16) | \ + (Get_BYTE(ptr+1) << 8) | \ + Get_BYTE(ptr+2)) +#endif /* BIGVM */ + +#define Get_code_BYTE Get_BYTE +#define Get_code_DLword Get_DLword +#define Get_code_AtomNo Get_AtomNo +#define Get_code_Pointer Get_Pointer + +#ifdef BIGATOMS +#define Get_AtomNo(ptr) Get_Pointer(ptr) +#else +#define Get_AtomNo(ptr) Get_DLword(ptr) +#endif /* BIGATOMS */ + + +/* For bit test */ +typedef struct wbits + { + unsigned xMSB :1; + unsigned B1 :1; + unsigned B2 :1; + unsigned B3 :1; + unsigned B4 :1; + unsigned B5 :1; + unsigned B6 :1; + unsigned B7 :1; + unsigned B8 :1; + unsigned B9 :1; + unsigned B10 :1; + unsigned B11 :1; + unsigned B12 :1; + unsigned B13 :1; + unsigned B14 :1; + unsigned LSB :1; + }WBITS; + +typedef struct lbits + { + unsigned xMSB :1; + unsigned MIDDLE :30; + unsigned LSB :1; + }LBITS; + +#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ + if( bitvalue) \ + *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ + |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ + else \ + *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ + &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ + } + +#else + /*** Byte-swapped structure declarations, for 80386 ***/ +typedef struct {unsigned char code;} BYTECODE; +typedef char ByteCode; +typedef unsigned short DLword; +typedef char DLbyte; +typedef unsigned int LispPTR; +/* 32 bit Cell Chang. 14 Jan 87 take */ +typedef DLword mds_page; /* Top word of the MDS */ +typedef (*CFuncPTR)(); + +#ifdef BIGVM +typedef struct consstr + { + unsigned car_field : 28; + unsigned cdr_code : 4; + } ConsCell; + +typedef struct ufn_entry + { + unsigned arg_num : 8; /* num of argments */ + unsigned byte_num : 8; /* num of byte code */ + DLword atom_name; /* UFN's atomindex */ + } UFN; + +typedef struct closure_type + { + unsigned def_ptr : 28; /* LispPTR to definition cell */ + unsigned nil1 : 4; + unsigned env_ptr : 28; /* LispPTR to environment */ + unsigned nil2 : 4; + } Closure; +#else /* BIGVM */ +typedef struct consstr + { + unsigned car_field : 24; + unsigned cdr_code : 8; + } ConsCell; + +typedef struct ufn_entry + { + unsigned arg_num : 8; /* num of argments */ + unsigned byte_num : 8; /* num of byte code */ + DLword atom_name; /* UFN's atomindex */ + } UFN; + +typedef struct closure_type + { + unsigned def_ptr : 24; /* LispPTR to definition cell */ + unsigned nil1 : 8; + unsigned env_ptr : 24; /* LispPTR to environment */ + unsigned nil2 : 8; + } Closure; +#endif /* BIGVM */ + +typedef struct interrupt_state + { /* Interrupt-request mask to communicate with INTERRUPTED */ + DLword intcharcode; + unsigned nil :8; + unsigned waitinginterrupt :1; + unsigned storagefull :1; + unsigned stackoverflow :1; + unsigned vmemfull :1; + unsigned gcdisabled :1; + unsigned IOInterrupt :1; /* I/O happened (not used yet) */ + unsigned ETHERInterrupt :1; /* 10MB activity happened */ + unsigned LogFileIO :1; /* console msg arrived to print */ + } INTSTAT; + +typedef struct interrupt_state_2 + { /* alternate view of the interrupt state */ + DLword nil; + unsigned handledmask :8; + unsigned pendingmask :8; + } INTSTAT2; + + +struct state + { + DLword *ivar; /* + 0 */ + DLword *pvar; /* + 4 */ + DLword *csp; /* + 8 */ + LispPTR tosvalue; /* + 12 */ + ByteCode *currentpc; /* + 16 */ + struct fnhead *currentfunc; /* + 20*/ + DLword *endofstack; /* + 24*/ + UNSIGNED irqcheck; /* + 28 */ + UNSIGNED irqend; /* + 32 */ + LispPTR scratch_cstk; /* + 34 */ + int errorexit; /* + 38 */ + }; + +/* Fetching 2 bytes to make a word -- always do it the hard way */ +/* if we're byte-swapped: You can't rely on byte ordering!! */ +#define Get_DLword(ptr) ((Get_BYTE(ptr) <<8) | Get_BYTE(ptr+1)) + +#ifdef BIGVM +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 24) | \ + (Get_BYTE(ptr+1) << 16) | \ + (Get_BYTE(ptr+2) << 8) | Get_BYTE(ptr+3)) +#else +#define Get_Pointer(ptr) ((Get_BYTE(ptr) << 16) | \ + (Get_BYTE(ptr+1) << 8) | \ + Get_BYTE(ptr+2)) +#endif /* BIGVM */ + +#ifndef RESWAPPEDCODESTREAM +#define Get_code_BYTE(ptr) Get_BYTE(ptr) +#define Get_code_AtomNo Get_AtomNo +#define Get_code_DLword Get_DLword +#else +#define Get_code_BYTE(ptr) (((BYTECODE *)(ptr))->code) + +#define Get_code_Pointer(ptr) ((Get_code_BYTE(ptr) << 16) | \ + (Get_code_BYTE(ptr+1) << 8) | \ + Get_code_BYTE(ptr+2)) +#define Get_code_DLword(ptr) ((Get_code_BYTE(ptr) << 8) | Get_code_BYTE(ptr+1)) +#define Get_code_AtomNo Get_code_Pointer +#endif /* RESWAPPEDCODESTREAM */ + + +#ifdef BIGATOMS +#define Get_AtomNo(ptr) Get_Pointer(ptr) +#else +#define Get_AtomNo(ptr) Get_DLword(ptr) +#endif /* BIGATOMS */ + + +/* For bit test */ +typedef struct wbits + { + USHORT LSB :1; + USHORT B14 :1; + USHORT B13 :1; + USHORT B12 :1; + USHORT B11 :1; + USHORT B10 :1; + USHORT B9 :1; + USHORT B8 :1; + USHORT B7 :1; + USHORT B6 :1; + USHORT B5 :1; + USHORT B4 :1; + USHORT B3 :1; + USHORT B2 :1; + USHORT B1 :1; + USHORT xMSB :1; + } WBITS; + +typedef struct lbits + { + unsigned LSB :1; + unsigned MIDDLE :30; + unsigned xMSB :1; /* xMSB b/c HPUX defined MSB in a header */ + } LBITS; + +#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ + UNSIGNED real68kbase; \ + real68kbase = 2 ^ ((UNSIGNED)(base68k)); \ + if( bitvalue) \ + (* (DLword *) (2^(UNSIGNED)((DLword*)(real68kbase) + (((u_short)(offset))>>4 )))) \ + |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ + else \ + (* (DLword *) (2^(UNSIGNED)((DLword*)(real68kbase) + (((u_short)(offset))>>4 )))) \ + &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ + } + +#endif /* BYTESWAP */ + + + + /* Because a WBITS is only 1 word long, need byte-swapped */ + /* access to it. Use WBITSPTR(x) instead of ((WBITS *) x) */ + +#define WBITSPTR(ptr) ((WBITS *) WORDPTR(ptr)) + + +extern struct state MachineState; + +#define MState (&MachineState) +#define CURRENTFX ((struct frameex1 *)(((DLword *) PVar) - FRAMESIZE)) +#define IVar (MState->ivar) +#define PVar (MState->pvar) +#define CurrentStackPTR (MState->csp) +#define TopOfStack (MState->tosvalue) +#define PC (MState->currentpc) +#define FuncObj (MState->currentfunc) +#define EndSTKP (MState->endofstack) +#define Irq_Stk_Check (MState->irqcheck) +#define Irq_Stk_End (MState->irqend) +#define Scratch_CSTK (MState->scratch_cstk) +#define Error_Exit (MState->errorexit) + +/* Typedef for IFPAGE */ +#include "ifpage.h" + +/* Typedef for IOPAGE */ +#include "iopage.h" + + +/* Typedef for MISCSTAT */ +#include "miscstat.h" + +/**************************************************** + MakeAddr: + base: DLword* + offset: word offset from base + return: DLword* +****************************************************/ +#define MakeAddr(base, offset) ((DLword *)(base + (int)offset)) + + +/**************************************************** +GetHiWord: +*****************************************************/ +#define GetHiWord(x) ((DLword)((x)>>16)) + +/**************************************************** +GetLoWord: +*****************************************************/ +#define GetLoWord(x) ((DLword)(x)) + +/**************************************************** +GetLongWord: + address: DLword* + retrun: int +*****************************************************/ +#define GetLongWord(address) (*((LispPTR *) (address))) + + +/**************************************************** +PopCStack: +#define PopCStack {TopOfStack = *((LispPTR *)(--CurrentStackPTR)); --CurrentStackPTR;} +*****************************************************/ +#define PopCStack {TopOfStack = *((LispPTR *)(CurrentStackPTR)); CurrentStackPTR -= 2;} + +/**************************************************** +PopStackTo: CSTK -> Place +#define PopStackTo(Place) {Place= *((LispPTR *)(--CurrentStackPTR)); CurrentStackPTR--; } +*****************************************************/ +#define PopStackTo(Place) {Place= *((LispPTR *)(CurrentStackPTR)); CurrentStackPTR -= 2; } + +/**************************************************** +PushCStack: +#define PushCStack {*((int *)(++CurrentStackPTR)) = TopOfStack; ++CurrentStackPTR;} +*****************************************************/ +#define PushCStack {CurrentStackPTR += 2;*((LispPTR *)(CurrentStackPTR)) = TopOfStack; } + +/**************************************************** +PushStack: +#define PushStack(x) {*((LispPTR *)(++CurrentStackPTR))=x;CurrentStackPTR++;} +*****************************************************/ +#define PushStack(x) {CurrentStackPTR += 2;*((LispPTR *)(CurrentStackPTR))=x;} + +/**************************************************** +SmashStack: +#define SmashStack(x) (*((LispPTR *)(CurrentStackPTR-1))=x) +*****************************************************/ +#define SmashStack(x) (*((LispPTR *)(CurrentStackPTR))=x) + +/********************************************************* +Get_BYTE(byteptr) byteptr: pointer to 8 bit data +**********************************************************/ +/***** OLD definition ************* 13 Nov 1987 takeshi *** +#define Get_BYTE(byteptr) (((unsigned)(*(byteptr))) & 0xff) +**********************************************/ +#define Get_BYTE(byteptr) (((BYTECODE *)BYTEPTR(byteptr))->code) + +/********************************************************** +DOSTACKOVERFLOW(argnum,bytenum) if it needs hardreturn-cleanup + then upnt to contextsw and immediately return +**********************************************************/ +#define DOSTACKOVERFLOW(argnum,bytenum) { \ + if(do_stackoverflow(T)) \ + { PushStack(S_POSITIVE | argnum); \ + contextsw(SubovFXP,bytenum,1); \ + return;\ + } \ + } + + + + +/************************************************************************/ +/* */ +/* E X T E R N A L F U N C T I O N S */ +/* */ +/* Declare all functions that will default incorrectly under */ +/* normal C inference rules. These functions are the ones */ +/* that return pointers, because on DEC Alpha, a pointer is 8 */ +/* bytes--but the default fn decl is int, a 4-byte return. */ +/* */ +/************************************************************************/ + +extern DLword *createcell68k(); +extern LispPTR *alloc_mdspage(); +extern UNSIGNED N_OP_unwind(); +extern char *getenv(); +#include + + + +/************************************************************************/ +/* */ +/* E R R O R & T I M E R P U N T C A S E S */ +/* */ +/* Set up the top-of-stack so we can continue gracefully after */ +/* handling the timer interrupt (e.g., FMEMB, which walks down */ +/* the list being searched, pushes its current state on TOS */ +/* so that it picks up where it left off after the interrupt. */ +/* */ +/* Call Interface where neg number indicates an error return */ +/* */ +/************************************************************************/ + +#define ERROR_EXIT(tos) {TopOfStack=tos; Error_Exit = 1; return(-1);} +#ifdef ISC +#define INLINE_ERROR_EXIT(tos,retlbl) {TopOfStack=tos; Error_Exit=1 asm("movl $-1,%0\n" retlbl ":" : "=g" (result) : "0" (result)); return(result); } +#endif + +#define TIMER_EXIT(tos) {TopOfStack=tos; Error_Exit = 1; return(-2);} + + +#define WARN(message,operation) {warn(message);operation;return;} +#define NO_WOP {} + +#define NIL 0 /* added 29-jan */ +#define T 1 +#define ATOM_T 0114 /* T's AtomIndex Number 114Q */ + +#define NIL_PTR 0 /* from cell.h 24-mar-87 take */ +#define NOBIND_PTR 1 + +#define STKLIM 0x1FFFF +#define FRAMESIZE 10 /* size of frameex1: 10 words */ +#define FNHEADSIZE 8 /* size of fnhead: 8 words */ +#define BFSIZE 2 /* size of basci frame pointer: 2 words */ + +#define BITSPER_DLWORD 16 +#define BITSPER_CELL 32 +#define BYTESPER_DLWORD 2 +#define BYTESPER_CELL 4 +#define BYTESPER_QUAD 8 +#define BYTESPER_PAGE 512 +#define CELLSPER_QUAD 2 +#define CELLSPER_PAGE 128 +#define CELLSPER_SEGMENT 32768 +#define DLWORDSPER_CELL 2 +#define DLWORDSPER_QUAD 4 +#define DLWORDSPER_PAGE 256 +#define DLWORDSPER_SEGMENT 65536 +#define PAGESPER_SEGMENT 256 +#define PAGESPER_MDSUNIT 2 +#define MDSINCREMENT 512 + +#define GUARDSTORAGEFULL 128 +#define GUARD1STORAGEFULL 64 + +#define SFS_NOTSWITCHABLE 1 +#define SFS_SWITCHABLE 2 +#define SFS_ARRAYSWITCHED 3 +#define SFS_FULLYSWITCHED 4 + + +#define AtomHTSIZE 256 * DLWORDSPER_PAGE + +#define MAXPNCHARS 255 /* Maximam length of PnChars */ + +#define GET_NATIVE_ADDR(fnobject) \ + *((int *) ((UNSIGNED)fnobject + fnobject->startpc - 4)) + + +#define FALSE 0 +#define TRUE !FALSE + +typedef unsigned int boolean; + + +/************************************************************************/ +/* Define sizes of FN and FNX opcodes; depends on atom size */ +/************************************************************************/ + +#ifdef BIGVM +#define FN_OPCODE_SIZE 5 +#define FNX_OPCODE_SIZE 6 +#elif defined(BIGATOMS) +#define FN_OPCODE_SIZE 4 +#define FNX_OPCODE_SIZE 5 +#else +#define FN_OPCODE_SIZE 3 +#define FNX_OPCODE_SIZE 4 +#endif /* BIGATOMS */ + + + +/************************************************************************/ +/* */ +/* Definitions for "NEW" Symbols */ +/* */ +/* Offsets within the "New symbols that go with 3-byte atoms. */ +/* */ +/************************************************************************/ +#ifdef BIGATOMS + +typedef struct newatom + { + LispPTR na_pname; /* Pointer to the print name */ + LispPTR na_value; /* The value cell */ + LispPTR na_defn; /* The definition cell */ + LispPTR na_plist; /* The property list */ + LispPTR na_flags; /* flags from other cells, to make BIGVM work ok */ + } NEWATOM; + + /* Offsets, in WORDS, from the start of the NEWATOM structure */ +#define NEWATOM_PNAME_OFFSET 0 +#define NEWATOM_VALUE_OFFSET 2 +#define NEWATOM_DEFN_OFFSET 4 +#define NEWATOM_PLIST_OFFSET 6 + + + /* Offsets, in cells from start of the NEWATOM structure */ +#define NEWATOM_PNAME_PTROFF 0 +#define NEWATOM_VALUE_PTROFF 1 +#define NEWATOM_DEFN_PTROFF 2 +#define NEWATOM_PLIST_PTROFF 3 +#endif + + + +/************************************************************************/ +/* */ +/* Mask to mask off relevant bits in a pointer. */ +/* */ +/************************************************************************/ +#ifdef BIGVM +#define POINTERMASK 0xfffffff +#define SEGMASK 0xfff0000 +#define PAGEMASK 0xfffff00 +#else +#define POINTERMASK 0xffffff +#define SEGMASK 0xff0000 +#define PAGEMASK 0xffff00 +#endif /* BIGVM */ + + + + +/************************************************************************/ +/* */ +/* F P t o V P M a n i p u l a t i o n */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifdef BIGVM +#define GETFPTOVP(b,o) b[o] +#define GETPAGEOK(b,o) (b[o]>>16) +#else +#define GETFPTOVP GETWORDBASEWORD +#define GETPAGEOK GETWORDBASEWORD +#endif diff --git a/inc/lispmap.h b/inc/lispmap.h new file mode 100755 index 0000000..c15b7d8 --- /dev/null +++ b/inc/lispmap.h @@ -0,0 +1,388 @@ +/* $Id: lispmap.h,v 1.3 1999/01/03 02:06:08 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +/* + File Name : lispmap.h(for TEST) + + **************NOTE***************** + OLD DEFs are MOVED to lispmap.FULL + **************NOTE***************** + + Global variables for LispSYSOUT + + Date : December 18, 1986 + Edited by : Takeshi Shimizu + +*/ + + + + + /* Whole Lisp size */ +#define LWORLD_SIZE 0x420000 /* byte */ + +/* 1 MDS entry size is 2(page) * 512 Byte */ +#define MDSTT_SIZE (LWORLD_SIZE >> 10 ) + +/* if you want to use the ATOMSPACE for Dummy then it must be 0x10000 take */ +#define MAP_SHIFT 0x0 + +/* Following constants mean LISP word offset. */ +/* these correspond with lisp mem map */ +/* for IOCBPAGE */ +#define IOCBPAGE_OFFSET 256 +#define IOCB_SIZE 1 + + +#ifdef BIGBIGVM + +/**********************************************/ +/* */ +/* BIG-BIG-VM sysout layout (256Mb sysout) */ +/* */ +/**********************************************/ + +/* for ATOMSPACE */ +#define ATOM_HI 0 +#define ATOM_OFFSET 0x00000 +#define ATOM_SIZE 0x10000 + +/* for IOPAGE */ +#define IOPAGE_OFFSET 0x0FF00 +#define IOPAGE_SIZE 1 + +/* for STACKSPACE */ +#define STK_HI 1 +#define STK_OFFSET 0x10000 +#define STK_SIZE 0x10000 + +/* for PLISTSPACE */ +#define PLIS_HI 2 /* place holder, really -- keep the olde value, even though it's inconsistent with the OFFSET, because it's known by LISP, and is used as a dispatch constant. */ +#define PLIS_OFFSET 0x30000 +#define PLIS_SIZE 0x10 + + + +#define FPTOVP_HI 4 /* again, inconsistent with OFFSET. */ +#define FPTOVP_OFFSET 0x20000 +#define FPTOVP_SIZE 0x100000 + + +/*for PAGEMAP */ +#define PAGEMAP_HI 5 /* Again, fake */ +#define PAGEMAP_OFFSET 0x50000 +#define PAGEMAP_SIZE 0x10000 + +/* for InterfacePage */ +#define IFPAGE_HI 20 +#define IFPAGE_OFFSET 0x140000 +#define IFPAGE_SIZE 0x200 + +/* for PageMapTBL */ +#define PAGEMAPTBL_OFFSET 0x140200 +#define PAGEMAPTBL_SIZE 0x800 + +/* for MISCSTATS */ +#define MISCSTATS_OFFSET 0x140A00 +#define MISCSTATS_SIZE 0x200 + +/* for UFNTable */ +#define UFNTBL_OFFSET 0x140C00 +#define UFNTBL_SIZE 0x200 + +/* for DTDspace */ +#define DTD_HI 20 +#define DTD_OFFSET 0x141000 +#define DTD_SIZE 0x1000 + +/* for LOCKEDPAGETBL */ +#define LOCKEDPAGETBL_OFFSET 0x147000 +#define LOCKEDPAGETBL_SIZE 0x1000 + +/* for MDSTT */ + +#define MDS_HI 24 +#define MDS_OFFSET 0x180000 +#define MDS_SIZE 0x40000 + + +/* for AtomHashTable */ +#define ATMHT_HI 21 +#define ATMHT_OFFSET 0x150000 +#define ATMHT_SIZE 0x10000 + +/* for PNPSPACE */ +/* Now used to hold initial atoms */ +#define PNP_HI 8 /* Fake */ +#define PNP_OFFSET 0x80000 +#define PNP_SIZE 0x20000 + +#define ATOMS_HI 44 +#define ATOMS_OFFSET 0x2c0000 +#define ATOMS_SIZE 0x20000 + +/* for DEFSPACE */ +#define DEFS_HI 10 /* Fake */ +#define DEFS_OFFSET 0xA0000 +#define DEFS_SIZE 0x20000 + +/* for VALSPACE */ +#define VALS_HI 12 /* Fake */ +#define VALS_OFFSET 0xC0000 +#define VALS_SIZE 0x20000 + +/* for Small Positive */ +#define SPOS_HI 14 /* Fake */ +#define S_POSITIVE 0xE0000 +#define SPOS_SIZE 0x10000 + +/* for Small Negative */ +#define SNEG_HI 15 /* Fake */ +#define S_NEGATIVE 0xF0000 +#define SNEG_SIZE 0x10000 + +/* for characters */ +#define S_CHAR 0x70000 + +/* for HTMAIN */ +#define HTMAIN_HI 22 +#define HTMAIN_OFFSET 0x160000 +#define HTMAIN_SIZE 0x10000 + +/* for HTOVERFLOW */ +#define HTOVERFLOW_OFFSET 0x170000 +#define HTOVERFLOW_SIZE 0x100 + +/* for HTBIGCOUNT */ +#define HTBIG_HI 23 +#define HTBIG_OFFSET 0x170100 +#define HTBIG_SIZE 0x8000 + +/* for HTCOLL */ +#define HTCOLL_HI 28 +#define HTCOLL_OFFSET 0x1C0000 +#define HTCOLL_SIZE 0x100000 + + +/* DISPLAYREGION */ + +#define DISPLAY_HI 18 +#define DISPLAY_OFFSET 0x120000 + + + +#define ARRAY_OFFSET 0x2e0000 + + +/* #define MDS_BOTTOM_OFFSET 0x200000 NOT USED ANYWHERE 1/29/98 JDS */ + +#else + +/* NOT BIG-BIG VM */ + + +/* for ATOMSPACE */ +#define ATOM_HI 0 +#define ATOM_OFFSET 0x00000 +#define ATOM_SIZE 0x10000 + +/* for IOPAGE */ +#define IOPAGE_OFFSET 0x0FF00 +#define IOPAGE_SIZE 1 + +/* for STACKSPACE */ +#define STK_HI 1 +#define STK_OFFSET 0x10000 +#define STK_SIZE 0x10000 + +/* for PLISTSPACE */ +#ifndef BIGVM +#define PLIS_HI 2 +#define PLIS_OFFSET 0x20000 +#define PLIS_SIZE 0x20000 +#else +#define PLIS_HI 2 /* place holder, really -- keep the olde value, even though it's inconsistent with the OFFSET, because it's known by LISP, and is used as a dispatch constant. */ +#define PLIS_OFFSET 0x30000 +#define PLIS_SIZE 0x10 +#endif + +#ifdef BIGVM +#define FPTOVP_HI 4 /* again, inconsistent with OFFSET. */ +#define FPTOVP_OFFSET 0x20000 +#define FPTOVP_SIZE 0x40000 +#else +/* for FPTOVP */ +#define FPTOVP_HI 4 +#define FPTOVP_OFFSET 0x40000 +#define FPTOVP_SIZE 0x10000 +#endif /* BIGVM */ + +/*for PAGEMAP */ +#define PAGEMAP_HI 5 +#define PAGEMAP_OFFSET 0x50000 +#define PAGEMAP_SIZE 0x10000 + +/* for InterfacePage */ +#define IFPAGE_HI 6 +#define IFPAGE_OFFSET 0x60000 +#define IFPAGE_SIZE 0x200 + +/* for PageMapTBL */ +#define PAGEMAPTBL_OFFSET 0x60200 +#define PAGEMAPTBL_SIZE 0x800 + +/* for MISCSTATS */ +#define MISCSTATS_OFFSET 0x60A00 +#define MISCSTATS_SIZE 0x200 + +/* for UFNTable */ +#define UFNTBL_OFFSET 0x60C00 +#define UFNTBL_SIZE 0x200 + +/* for DTDspace */ +#define DTD_HI 6 +#define DTD_OFFSET 0x61000 +#define DTD_SIZE 0x1000 + +/* for LOCKEDPAGETBL */ +#define LOCKEDPAGETBL_OFFSET 0x67000 +#define LOCKEDPAGETBL_SIZE 0x1000 + +/* for MDSTT */ +#ifdef BIGVM + /* In BIGVM, MDS type table is at 19.,,0 for 1 segment */ +#define MDS_HI 20 +#define MDS_OFFSET 0x140000 +#define MDS_SIZE 0x10000 +#else +#define MDS_HI 6 +#define MDS_OFFSET 0x68000 +#define MDS_SIZE 0x8000 +#endif /* BIGVM */ + +/* for AtomHashTable */ +#define ATMHT_HI 7 +#define ATMHT_OFFSET 0x70000 +#define ATMHT_SIZE 0x10000 + +/* for PNPSPACE */ +#define PNP_HI 8 +#define PNP_OFFSET 0x80000 +#define PNP_SIZE 0x20000 + +#define ATOMS_HI 8 +#define ATOMS_OFFSET 0x80000 +#define ATOMS_SIZE 0x20000 + +/* for DEFSPACE */ +#define DEFS_HI 10 +#define DEFS_OFFSET 0xA0000 +#define DEFS_SIZE 0x20000 + +/* for VALSPACE */ +#define VALS_HI 12 +#define VALS_OFFSET 0xC0000 +#define VALS_SIZE 0x20000 + +/* for Small Positive */ +#define SPOS_HI 14 +#define S_POSITIVE 0xE0000 +#define SPOS_SIZE 0x10000 + +/* for Small Negative */ +#define SNEG_HI 15 +#define S_NEGATIVE 0xF0000 +#define SNEG_SIZE 0x10000 + +/* for characters */ +#define S_CHAR 0x70000 + +#ifdef BIGVM +/* for HTMAIN */ +#define HTMAIN_HI 16 +#define HTMAIN_OFFSET 0x100000 +#define HTMAIN_SIZE 0x10000 + +/* for HTOVERFLOW */ +#define HTOVERFLOW_OFFSET 0x110000 +#define HTOVERFLOW_SIZE 0x100 + +/* for HTBIGCOUNT */ +#define HTBIG_HI 16 +#define HTBIG_OFFSET 0x110100 +#define HTBIG_SIZE 0x8000 + +/* for HTCOLL */ +#define HTCOLL_HI 10 +#define HTCOLL_OFFSET 0xA0000 +#define HTCOLL_SIZE 0x40000 +#else +/* for HTMAIN */ +#define HTMAIN_HI 16 +#define HTMAIN_OFFSET 0x100000 +#define HTMAIN_SIZE 0x8000 + +/* for HTOVERFLOW */ +#define HTOVERFLOW_OFFSET 0x108000 +#define HTOVERFLOW_SIZE 0x100 + +/* for HTBIGCOUNT */ +#define HTBIG_HI 16 +#define HTBIG_OFFSET 0x108100 +#define HTBIG_SIZE 0x8000 + +/* for HTCOLL */ +#define HTCOLL_HI 17 +#define HTCOLL_OFFSET 0x110000 +#define HTCOLL_SIZE 0x10000 +#endif /* BIGVM */ + + +/* DISPLAYREGION */ + +#define DISPLAY_HI 18 +#define DISPLAY_OFFSET 0x120000 + + +#ifdef MEDLEY +/* for ARRAYSPACE & MDS for PROT-LISP */ +#define ARRAY_OFFSET 0x150000 +#elif defined(BIGVM) +#define ARRAY_OFFSET 0x150000 +#else +#define ARRAY_OFFSET 0x130000 +#endif + +/* #define MDS_BOTTOM_OFFSET 0x200000 NOT used anywhere JDS 1/29/98 */ + +#endif /* BIGBIGVM */ + + + +/* for PnCharSpace(use only PROT-LISP ) */ +#define PNCHAR_HI 0x20 +#define PNCHAR_OFFSET 0x200000 +#define PNCHAR_SIZE 0x10000 + + +/***** SEG definitions for AtomCellN *****/ +/* following defs correspond with D machine memory layout */ +/**** NOTE!! if D's layout changes, modify following defs */ +#define D_PLISHI 2 +#define D_PNHI 010 +#define D_DEFSHI 012 +#define D_VALSHI 014 diff --git a/inc/lispver1.h b/inc/lispver1.h new file mode 100755 index 0000000..c6ec6ca --- /dev/null +++ b/inc/lispver1.h @@ -0,0 +1,44 @@ +/* $Id: lispver1.h,v 1.2 1999/01/03 02:06:08 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* DOS version of LispVersionToUnixVersion */ +#define LispVersionToUnixVersion(pathname, ver) \ + { \ + \ + register char *cp; \ + register char *vp; \ + char ver_buf[VERSIONLEN]; \ + \ + cp = pathname; \ + vp = NULL; \ + while (*cp) \ + { \ + switch (*cp) \ + { \ + \ + case ';': \ + *cp = 0; \ + cp++; \ + vp = cp; \ + break; \ + \ + case '\'': \ + if (*(cp + 1) != 0) cp += 2; \ + else cp++; \ + break; \ + \ + default: \ + cp++; \ + break; \ + } \ + } \ + \ + if (vp) \ + { \ + NumericStringP(vp, YES, NO); \ + NO: *vp = 0; \ + YES: \ + if ((*vp)) ver = atoi(vp); \ + else ver = -1; \ + } \ + else ver = -1; \ + } diff --git a/inc/lispver2.h b/inc/lispver2.h new file mode 100755 index 0000000..1abaf55 --- /dev/null +++ b/inc/lispver2.h @@ -0,0 +1,71 @@ +/* $Id: lispver2.h,v 1.2 1999/01/03 02:06:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* non-DOS version of LispVersionToUnixVersion */ + +#define LispVersionToUnixVersion(pathname){ \ + \ + register char *cp; \ + register char *vp; \ + register int ver; \ + char ver_buf[VERSIONLEN]; \ + \ + cp = pathname; \ + vp = NULL; \ + while (*cp) { \ + switch (*cp) { \ + \ + case ';': \ + vp = cp; \ + cp++; \ + break; \ + \ + case '\'': \ + if (*(cp + 1) != 0) cp += 2; \ + else cp++; \ + break; \ + \ + default: \ + cp++; \ + break; \ + } \ + } \ + \ + if (vp != NULL) { \ + /* \ + * A semicolon which is not quoted has been found. \ + */ \ + if (*(vp + 1) == 0) { \ + /* \ + * The empty version field. \ + * This is regared as a versionless file. \ + */ \ + *vp = 0; \ + } else { \ + NumericStringP((vp + 1), YES, NO); \ + YES: \ + /* \ + * Convert the remaining field to digit. \ + */ \ + ver = atoi(vp + 1); \ + if (ver == 0) { \ + /* versionless */ \ + *vp = 0; \ + } else { \ + sprintf(ver_buf, ".~%d~", ver); \ + *vp = 0; \ + strcat(pathname, ver_buf); \ + } \ + goto CONT; \ + \ + NO: \ + strcpy(ver_buf, vp + 1); \ + strcat(ver_buf, "~"); \ + *vp++ = '.'; \ + *vp++ = '~'; \ + *vp = 0; \ + strcat(pathname, ver_buf); \ + CONT: \ + vp--; /* Just for label */ \ + } \ + } \ +} diff --git a/inc/lldsp.h b/inc/lldsp.h new file mode 100755 index 0000000..befd7d4 --- /dev/null +++ b/inc/lldsp.h @@ -0,0 +1,219 @@ +/* $Id: lldsp.h,v 1.2 1999/01/03 02:06:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/***************************************************************/ +/* + lldsp.h + By Takeshi Shimizu + + typedef for + FONTDESC,CHARSETINFO,SCREEN,WINDOW + +*/ +/***************************************************************/ +#ifndef BYTESWAP +#ifdef BIGVM +typedef struct { + LispPTR FONTDEVICE; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + DLword SFAscent; + DLword SFDescent; + DLword SFHeight; + DLword ROTATION; + short FBBOX; + short FBBOY; + short FBBDX; + short FBBDY; + LispPTR SFLKerns; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + unsigned SFFACECODE : 8; + unsigned nil : 8; + DLword FONTAVGCHARWIDTH; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; +#else +typedef struct { + LispPTR FONTDEVICE; + LispPTR SFObsolete1; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + LispPTR SFObsolete2; + LispPTR SFObsolete3; + LispPTR SFObsolete4; + DLword SFObsolete5; + DLword SFObsolete6; + DLword SFAscent; + DLword SFDescent; + DLword SFHeight; + DLword ROTATION; + short FBBOX; + short FBBOY; + short FBBDX; + short FBBDY; + unsigned SFFACECODE : 8; + unsigned SFLKerns :24; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + DLword FONTAVGCHARWIDTH; + DLword dum; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; +#endif /* BIGVM */ +typedef struct { + LispPTR WIDTHS; + LispPTR OFFSETS; + LispPTR IMAGEWIDTHS; + LispPTR CHARSETBITMAP; + LispPTR YWIDTHS; + DLword CHARSETASCENT; + DLword CHARSETDESCENT; + LispPTR LEFTKERN; + } CHARSETINFO; + +#else /* BYTESWAP */ +#ifdef BIGVM +typedef struct { + LispPTR FONTDEVICE; + LispPTR SFObsolete1; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + LispPTR SFObsolete2; + LispPTR SFObsolete3; + LispPTR SFObsolete4; + DLword SFObsolete6; + DLword SFObsolete5; + DLword SFDscent; + DLword SFAescent; + DLword ROTATION; + DLword SFHeight; + short FBBOY; + short FBBOX; + short FBBDY; + short FBBDX; + unsigned SFLKerns :24; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + DLword FONTAVGCHARWIDTH; + unsigned nil : 8; + unsigned SFFACECODE : 8; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; +#else +typedef struct { + LispPTR FONTDEVICE; + LispPTR SFObsolete1; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + LispPTR SFObsolete2; + LispPTR SFObsolete3; + LispPTR SFObsolete4; + DLword SFObsolete6; + DLword SFObsolete5; + DLword SFDscent; + DLword SFAescent; + DLword ROTATION; + DLword SFHeight; + short FBBOY; + short FBBOX; + short FBBDY; + short FBBDX; + unsigned SFLKerns :24; + unsigned SFFACECODE : 8; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + DLword dum; + DLword FONTAVGCHARWIDTH; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; +#endif /* BIGVM */ +typedef struct { + LispPTR WIDTHS; + LispPTR OFFSETS; + LispPTR IMAGEWIDTHS; + LispPTR CHARSETBITMAP; + LispPTR YWIDTHS; + DLword CHARSETDESCENT; + DLword CHARSETASCENT; + LispPTR LEFTKERN; + } CHARSETINFO; + +#endif /* BYTESWAP */ + + + +typedef struct { + LispPTR SCONOFF; + LispPTR SCDESTINATION; + LispPTR SCWIDTH; + LispPTR SCHEIGHT; + LispPTR SCTOPW; + LispPTR SCTOPWDS; + LispPTR SCTITLEDS; + LispPTR SCFDEV; + LispPTR SCDS; + LispPTR SCDATA; + } SCREEN; +typedef struct { + LispPTR DSP; + LispPTR NEXTW; + LispPTR SAVE; + LispPTR REG; + LispPTR BUTTONEVENTFN; + LispPTR RIGHTBUTTONFN; + LispPTR CURSORINFN; + LispPTR CURSOROUTFN; + LispPTR CURSORMOVEFN; + LispPTR REPAINTFN; + LispPTR RESHAPEFN; + LispPTR EXTENT; + LispPTR USERDATA; + LispPTR VERTSCROLLREG; + LispPTR HORIZSCROLLREG; + LispPTR SCROLLFN; + LispPTR VERTSCROLLWINDOW; + LispPTR HORIZSCROLLWINDOW; + LispPTR CLOSEFN; + LispPTR MOVEFN; + LispPTR WTITLE; + LispPTR NEWREGION; + LispPTR WBORDER; + LispPTR PROCESS; + LispPTR WINDOWENTRYFN; + LispPTR SCREEN; +} WINDOW; diff --git a/inc/lnk-Xdeflt.h b/inc/lnk-Xdeflt.h new file mode 100755 index 0000000..df5128c --- /dev/null +++ b/inc/lnk-Xdeflt.h @@ -0,0 +1,35 @@ +/* $Id: lnk-Xdeflt.h,v 1.2 1999/01/03 02:06:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/* +* +* Define the X window Medley runs in. +* +*/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define DEF_WIN_X 20 +#define DEF_WIN_Y 20 +#define DEF_WIN_WIDTH 565 +#define DEF_WIN_HEIGHT 430 +#define WIN_MIN_WIDTH 150 +#define WIN_MIN_HEIGHT 100 +#define DEF_BDRWIDE 2 +#define SCROLL_WIDTH 18 +#define WINDOW_NAME "Medley (C) Copyright 1980-94 Venue" +#define ICON_NAME "Medley" + diff --git a/inc/lnk-debug.h b/inc/lnk-debug.h new file mode 100755 index 0000000..387f62a --- /dev/null +++ b/inc/lnk-debug.h @@ -0,0 +1,443 @@ +/* $Id: lnk-debug.h,v 1.2 1999/01/03 02:06:10 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + /************************************************/ + /* Normal byte-order version of definitions */ + /************************************************/ + +typedef struct{ + DLword W0; + DLword W1; + DLword W2; + DLword W3; + DLword WU; + DLword W4; + DLword W5; + int TIME; + unsigned MOUSESTATE : 3; + unsigned SHIFT1 : 1; + unsigned SHIFT2 : 1; + unsigned keLOCK : 1; + unsigned keCTRL : 1; + unsigned keMETA : 1; + unsigned keFONT : 1; + unsigned USERMODE1 : 1; + unsigned USERMODE2 : 1; + unsigned USERMODE3 : 1; + unsigned NIL1 : 4; + DLword MOUSEX; + DLword MOUSEY; +} KEYBOARDEVENT; + +typedef struct{ + DLword READ; + DLword WRITE; +} RING; + +typedef struct{ + LispPTR FLAGS; + LispPTR CODES; + LispPTR SHIFTCODES; + LispPTR ARMED; + LispPTR INTERRUPTLIST; +} KEYACTION; + +typedef struct{ + unsigned int EVENTWAKEUPPENDING : 1; + unsigned int nil1 : 7; + unsigned int EVENTQUEUETAIL : 24; + LispPTR EVENTNAME; +} EVENT; + +typedef struct{ + unsigned int nil1 : 1; + unsigned int MLOCKPERPROCESS : 1; + unsigned int nil2 : 6; + unsigned int MLOCKQUEUETAIL : 24; + LispPTR MLOCKOWNER; + LispPTR MLOCKNAME; + LispPTR MLOCKLINK; +} MONITORLOCK; + +typedef struct{ + DLword PROCFX0; + DLword PROCFX; + unsigned int PROCSTATUS : 8; + unsigned int PROCNAME : 24; + unsigned int PROCPRIORITY : 8; + unsigned int PROCQUEUE : 24; + unsigned int nil1 : 8; + unsigned int NEXTPROCHANDLE : 24; + unsigned int PROCTIMERSET : 1; + unsigned int PROCBEINGDELETED : 1; + unsigned int PROCDELETED : 1; + unsigned int PROCSYSTEMP : 1; + unsigned int PROCNEVERSTARTED : 1; + unsigned int nil2 : 3; + unsigned int PROCWAKEUPTIMER : 24; + LispPTR PROCTIMERLINK; + LispPTR PROCTIMERBOX; + LispPTR WAKEREASON; + LispPTR PROCEVENTORLOCK; + LispPTR PROCFORM; + LispPTR RESTARTABLE; + LispPTR PROCWINDOW; + LispPTR PROCFINISHED; + LispPTR PROCRESULT; + LispPTR PROCFINISHEVENT; + LispPTR PROCMAILBOX; + LispPTR PROCDRIBBLEOUTPUT; + LispPTR PROCINFOHOOK; + LispPTR PROCTYPEAHEAD; + LispPTR PROCREMOTEINFO; + LispPTR PROCUSERDATA; + LispPTR PROCEVENTLINK; + LispPTR PROCAFTEREXIT; + LispPTR PROCBEFOREEXIT; + LispPTR PROCOWNEDLOCKS; + LispPTR PROCEVAPPLYRESULT; + LispPTR PROCTTYENTRYFN; + LispPTR PROCEXITFN; + LispPTR PROCHARDRESETINFO; + LispPTR PROCRESTARTFORM; + LispPTR PROCOLDTTYPROC; + LispPTR nil3; +} PROCESS; + +typedef struct{ + unsigned int PQPRIORITY : 8; + unsigned int PQHIGHER : 24; + LispPTR PQLOWER; + LispPTR PQNEXT; + LispPTR PQLAST; +} PROCESSQUEUE; + +typedef struct fdev{ + unsigned RESETABLE : 1; + unsigned RANDOMACCESSP : 1; + unsigned NODIRECTORIES : 1; + unsigned PAGEMAPPED : 1; + unsigned FDBINABLE : 1; + unsigned FDBOUTABLE : 1; + unsigned FDEXTENDABLE : 1; + unsigned BUFFERED : 1; + unsigned DEVICENAME : 24; + unsigned REMOTEP : 1; + unsigned SUBDIRECTORIES : 1; + unsigned INPUT_INDIRECTED : 1; + unsigned OUTPUT_INDIRECTED : 1; + unsigned NIL1 : 4; + unsigned DEVICEINFO : 24; + LispPTR OPENFILELST ; + LispPTR HOSTNAMEP ; + LispPTR EVENTFN ; + LispPTR DIRECTORYNAMEP ; + LispPTR OPENFILE ; + LispPTR CLOSEFILE ; + LispPTR REOPENFILE ; + LispPTR GETFILENAME ; + LispPTR DELETEFILE ; + LispPTR GENERATEFILES ; + LispPTR RENAMEFILE ; + LispPTR OPENP ; + LispPTR REGISTERFILE ; + LispPTR UNREGISTERFILE ; + LispPTR FREEPAGECOUNT ; + LispPTR MAKEDIRECTORY ; + LispPTR CHECKFILENAME ; + LispPTR HOSTALIVEP ; + LispPTR BREAKCONNECTION ; + LispPTR BIN ; + LispPTR BOUT ; + LispPTR PEEKBIN ; + LispPTR READCHAR ; + LispPTR WRITECHAR ; + LispPTR PEEKCHAR ; + LispPTR UNREADCHAR ; + LispPTR READP ; + LispPTR EOFP ; + LispPTR BLOCKIN ; + LispPTR BLOCKOUT ; + LispPTR FORCEOUTPUT ; + LispPTR GETFILEINFO ; + LispPTR SETFILEINFO ; + LispPTR CHARSETFN ; + LispPTR INPUTSTREAM ; + LispPTR OUTPUTSTREAM ; + LispPTR GETFILEPTR ; + LispPTR GETEOFPTR ; + LispPTR SETFILEPTR ; + LispPTR BACKFILEPTR ; + LispPTR SETEOFPTR ; + LispPTR LASTC ; + LispPTR GETNEXTBUFFER ; + LispPTR RELEASEBUFFER ; + LispPTR READPAGES ; + LispPTR WRITEPAGES ; + LispPTR TRUNCATEFILE ; + LispPTR WINDOWOPS ; + LispPTR WINDOWDATA ; +}FDEV; +typedef struct package{ + LispPTR INDEX ; + LispPTR TABLES ; + LispPTR NAME ; + LispPTR NAMESYMBOL ; + LispPTR NICKNAMES ; + LispPTR USE_LIST ; + LispPTR USED_BY_LIST ; + LispPTR EXTERNAL_ONLY ; + LispPTR INTERNAL_SYMBOLS ; + LispPTR EXTERNAL_SYMBOLS ; + LispPTR SHADOWING_SYMBOLS ; +} PACKAGE; + +#ifdef NEVER +typedef struct { + unsigned nil1 : 8 ; + unsigned BASE : 24 ; + unsigned READ_ONLY_P : 1 ; + unsigned nil2 : 1 ; + unsigned BIT_P : 1 ; + unsigned STRING_P : 1 ; + unsigned nil3 : 1 ; + unsigned DISPLACED_P : 1 ; + unsigned FILL_POINTER_P : 1 ; + unsigned EXTENDABLE_P : 1 ; + unsigned TYPE_NUMBER : 8 ; + DLword OFFSET; + DLword FILL_POINTER; + DLword TOTAL_SIZE; +} ONED_ARRAY; +#endif /* NEVER */ +#else + + /****************************************************************/ + /* Byte-swapped, word-swapped definitions, for e.g. 80386's */ + /****************************************************************/ + +typedef struct{ + DLword W1; + DLword W0; + DLword W3; + DLword W2; + DLword W4; + DLword WU; + /* only swapped down to here, and MOUSEX & Y -- there */ + /* looks like a missing word in the block at this point. */ + DLword W5; + int TIME; + unsigned MOUSESTATE : 3; + unsigned SHIFT1 : 1; + unsigned SHIFT2 : 1; + unsigned LOCK : 1; + unsigned CTRL : 1; + unsigned META : 1; + unsigned FONT : 1; + unsigned USERMODE1 : 1; + unsigned USERMODE2 : 1; + unsigned USERMODE3 : 1; + unsigned NIL1 : 4; + DLword MOUSEY; + DLword MOUSEX; +} KEYBOARDEVENT; + +typedef struct{ + DLword WRITE; + DLword READ; +} RING; + +typedef struct{ + LispPTR FLAGS; + LispPTR CODES; + LispPTR SHIFTCODES; + LispPTR ARMED; + LispPTR INTERRUPTLIST; +} KEYACTION; + +typedef struct{ + unsigned int EVENTQUEUETAIL : 24; + unsigned int nil1 : 7; + unsigned int EVENTWAKEUPPENDING : 1; + LispPTR EVENTNAME; +} EVENT; + +typedef struct{ + unsigned int MLOCKQUEUETAIL : 24; + unsigned int nil2 : 6; + unsigned int MLOCKPERPROCESS : 1; + unsigned int nil1 : 1; + LispPTR MLOCKOWNER; + LispPTR MLOCKNAME; + LispPTR MLOCKLINK; +} MONITORLOCK; + +typedef struct{ + DLword PROCFX; + DLword PROCFX0; + unsigned int PROCNAME : 24; + unsigned int PROCSTATUS : 8; + unsigned int PROCQUEUE : 24; + unsigned int PROCPRIORITY : 8; + unsigned int NEXTPROCHANDLE : 24; + unsigned int nil1 : 8; + unsigned int PROCWAKEUPTIMER : 24; + unsigned int nil2 : 3; + unsigned int PROCNEVERSTARTED : 1; + unsigned int PROCSYSTEMP : 1; + unsigned int PROCDELETED : 1; + unsigned int PROCBEINGDELETED : 1; + unsigned int PROCTIMERSET : 1; + LispPTR PROCTIMERLINK; + LispPTR PROCTIMERBOX; + LispPTR WAKEREASON; + LispPTR PROCEVENTORLOCK; + LispPTR PROCFORM; + LispPTR RESTARTABLE; + LispPTR PROCWINDOW; + LispPTR PROCFINISHED; + LispPTR PROCRESULT; + LispPTR PROCFINISHEVENT; + LispPTR PROCMAILBOX; + LispPTR PROCDRIBBLEOUTPUT; + LispPTR PROCINFOHOOK; + LispPTR PROCTYPEAHEAD; + LispPTR PROCREMOTEINFO; + LispPTR PROCUSERDATA; + LispPTR PROCEVENTLINK; + LispPTR PROCAFTEREXIT; + LispPTR PROCBEFOREEXIT; + LispPTR PROCOWNEDLOCKS; + LispPTR PROCEVAPPLYRESULT; + LispPTR PROCTTYENTRYFN; + LispPTR PROCEXITFN; + LispPTR PROCHARDRESETINFO; + LispPTR PROCRESTARTFORM; + LispPTR PROCOLDTTYPROC; + LispPTR nil3; +} PROCESS; + +typedef struct{ + unsigned int PQHIGHER : 24; + unsigned int PQPRIORITY : 8; + LispPTR PQLOWER; + LispPTR PQNEXT; + LispPTR PQLAST; +} PROCESSQUEUE; + +typedef struct fdev{ + unsigned DEVICENAME : 24; + unsigned BUFFERED : 1; + unsigned FDEXTENDABLE : 1; + unsigned FDBOUTABLE : 1; + unsigned FDBINABLE : 1; + unsigned PAGEMAPPED : 1; + unsigned NODIRECTORIES : 1; + unsigned RANDOMACCESSP : 1; + unsigned RESETABLE : 1; + unsigned DEVICEINFO : 24; + unsigned NIL1 : 4; + unsigned OUTPUT_INDIRECTED : 1; + unsigned INPUT_INDIRECTED : 1; + unsigned SUBDIRECTORIES : 1; + unsigned REMOTEP : 1; + LispPTR OPENFILELST ; + LispPTR HOSTNAMEP ; + LispPTR EVENTFN ; + LispPTR DIRECTORYNAMEP ; + LispPTR OPENFILE ; + LispPTR CLOSEFILE ; + LispPTR REOPENFILE ; + LispPTR GETFILENAME ; + LispPTR DELETEFILE ; + LispPTR GENERATEFILES ; + LispPTR RENAMEFILE ; + LispPTR OPENP ; + LispPTR REGISTERFILE ; + LispPTR UNREGISTERFILE ; + LispPTR FREEPAGECOUNT ; + LispPTR MAKEDIRECTORY ; + LispPTR CHECKFILENAME ; + LispPTR HOSTALIVEP ; + LispPTR BREAKCONNECTION ; + LispPTR BIN ; + LispPTR BOUT ; + LispPTR PEEKBIN ; + LispPTR READCHAR ; + LispPTR WRITECHAR ; + LispPTR PEEKCHAR ; + LispPTR UNREADCHAR ; + LispPTR READP ; + LispPTR EOFP ; + LispPTR BLOCKIN ; + LispPTR BLOCKOUT ; + LispPTR FORCEOUTPUT ; + LispPTR GETFILEINFO ; + LispPTR SETFILEINFO ; + LispPTR CHARSETFN ; + LispPTR INPUTSTREAM ; + LispPTR OUTPUTSTREAM ; + LispPTR GETFILEPTR ; + LispPTR GETEOFPTR ; + LispPTR SETFILEPTR ; + LispPTR BACKFILEPTR ; + LispPTR SETEOFPTR ; + LispPTR LASTC ; + LispPTR GETNEXTBUFFER ; + LispPTR RELEASEBUFFER ; + LispPTR READPAGES ; + LispPTR WRITEPAGES ; + LispPTR TRUNCATEFILE ; + LispPTR WINDOWOPS ; + LispPTR WINDOWDATA ; +}FDEV; +typedef struct package{ + LispPTR INDEX ; + LispPTR TABLES ; + LispPTR NAME ; + LispPTR NAMESYMBOL ; + LispPTR NICKNAMES ; + LispPTR USE_LIST ; + LispPTR USED_BY_LIST ; + LispPTR EXTERNAL_ONLY ; + LispPTR INTERNAL_SYMBOLS ; + LispPTR EXTERNAL_SYMBOLS ; + LispPTR SHADOWING_SYMBOLS ; +} PACKAGE; +#ifdef NEVER +typedef struct { + unsigned BASE : 24 ; + unsigned nil1 : 8 ; + DLword OFFSET; + unsigned TYPE_NUMBER : 8 ; + unsigned EXTENDABLE_P : 1 ; + unsigned FILL_POINTER_P : 1 ; + unsigned DISPLACED_P : 1 ; + unsigned nil3 : 1 ; + unsigned STRING_P : 1 ; + unsigned BIT_P : 1 ; + unsigned nil2 : 1 ; + unsigned READ_ONLY_P : 1 ; + DLword TOTAL_SIZE; + DLword FILL_POINTER; +} ONED_ARRAY; +#endif /* NEVER */ + +#endif /* BYTESWAP */ + diff --git a/inc/lnk-fast_dsp.h b/inc/lnk-fast_dsp.h new file mode 100755 index 0000000..0ff657f --- /dev/null +++ b/inc/lnk-fast_dsp.h @@ -0,0 +1,166 @@ +/* $Id: lnk-fast_dsp.h,v 1.2 1999/01/03 02:06:10 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* These are the Macros Used to generate fast dispatch inline code. +*/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1991 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* F A S T O P C O D E D I S P A T C H M A C R O S */ +/* */ +/* These macros generate better opcode-dispatch code than the */ +/* native compiler will. The difference may be only one or */ +/* two instructions, but in the inner loop, that's a LOT. */ +/* */ +/* To add a new architecture, you must define 5 macros: */ +/* */ +/* nextop0 - for single-byte opcodes */ +/* nextop1 - skip a byte and grab an opcode */ +/* nextop2 - skip 2 bytes and grab an opcode */ +/* nextop3 - skip 3 bytes and grab an opcode */ +/* nextop4 - skip 4 bytes and grab an opcode */ +/* */ +/* (These macros are already defined naively, so undef them.) */ +/* */ +/* For existing implementations, these often expand out to */ +/* calls to inline functions. */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifdef OPDISP /* Only do any of this if OPDISP is set. */ + + /* Sun 3 */ +#ifdef mc68020 +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 +/* JRB - fast case is now nextop1 */ +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast1_dispatcher2(); } +#define nextop3 { PCMACL += 2; nextop1; } +#define nextop4 { PCMACL += 3; nextop1; } +#endif + + /* Sun 386i */ +#ifdef I386 +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 +/* JRB - fast case is now nextop1 */ +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast2_dispatcher(); } +#define nextop3 { PCMACL += 2; nextop1; } +#define nextop4 { PCMACL += 3; nextop1; } +#endif + + + /* ISC 386 using gcc */ +#ifdef ISC +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 + +#define nextop0 { fast0_dispatcher(); goto nextopcode; } +#define nextop1 { fast1_dispatcher(); goto nextopcode; } +#define nextop2 { fast2_dispatcher(); goto nextopcode;} +#define nextop3 { fast3_dispatcher(); goto nextopcode;} +#define nextop4 { fast4_dispatcher(); goto nextopcode;} + +#define fast0_dispatcher() \ + asm volatile(" \n\ +// leal -1(%0),%%eax \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + movzbl -1(%0),%%eax \n\ + jmp *optable(,%%eax,4)" : : "r" (pccache): "ax"); + +#define fast1_dispatcher() \ + asm volatile(" \n\ +/ movl %0,%%eax \n\ +/ xorb $3,%%al \n\ + movzbl (%0),%%eax \n\ + incl %0 \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" : "=r" (pccache) : "0" (pccache): "ax"); + +#define fast2_dispatcher() \ + asm volatile(" \n\ +/ leal 1(%0),%%eax \n\ + movzbl 1(%0),%%eax \n\ + addl $2,%0 \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" :"=r" (pccache) : "0" (pccache): "ax"); + +#define fast3_dispatcher() \ + asm volatile(" \n\ +/ leal 2(%0),%%eax \n\ + movzbl 2(%0),%%eax \n\ + addl $3,%0 \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" :"=r" (pccache) : "0" (pccache): "ax"); +#define fast4_dispatcher() \ + asm volatile(" \n\ +/ leal 3(%0),%%eax \n\ + movzbl 3(%0),%%eax \n\ + addl $4,%0 \n\ +/ xorb $3,%%al \n\ +/ movzbl (%%eax),%%eax \n\ + jmp *optable(,%%eax,4)" :"=r" (pccache) : "0" (pccache): "ax"); + +#endif + +#endif /* OPDISP */ + + + + +#ifdef SPARCDISP +#undef nextop0 +#undef nextop1 +#undef nextop2 +#undef nextop3 +#undef nextop4 +#define nextop0 { fast_dispatcher(table, Get_BYTE(PCMAC)); goto nextopcode; } +#define nextop_n(n) { \ + PCMACL += n; \ + nextop0; \ +} +#define nextop1 { nextop_n(1); } +#define nextop2 { nextop_n(2); } +#define nextop3 { nextop_n(3); } +#define nextop4 { nextop_n(4); } +#endif /* SPARCDISP */ + + + + + + + + + diff --git a/inc/lnk-inlineC.h b/inc/lnk-inlineC.h new file mode 100755 index 0000000..f8ba52f --- /dev/null +++ b/inc/lnk-inlineC.h @@ -0,0 +1,1074 @@ +/* $Id: lnk-inlineC.h,v 1.2 1999/01/03 02:06:11 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* + These are the Macros Used to generate inline c code. + These are the goto ni definitions of the opcodes. +*/ + +/************************************************************************/ +/* */ +/* Macros for fetching bytes & words PC-relative */ +/* */ +/* These are this way so that they can be redefined for the 386i, */ +/* where it makes a difference in speed if you know in advance. */ +/* */ +/************************************************************************/ + +#define Get_BYTE_PCMAC0 Get_BYTE(PCMAC) +#define Get_BYTE_PCMAC1 Get_BYTE(PCMAC+1) +#define Get_BYTE_PCMAC2 Get_BYTE(PCMAC+2) +#define Get_BYTE_PCMAC3 Get_BYTE(PCMAC+3) + +#define Get_DLword_PCMAC0 Get_DLword(PCMAC) +#define Get_DLword_PCMAC1 Get_DLword(PCMAC+1) +#define Get_DLword_PCMAC2 Get_DLword(PCMAC+2) +#define Get_DLword_PCMAC3 Get_DLword(PCMAC+3) + +#define Get_Pointer_PCMAC0 +#define Get_Pointer_PCMAC1 Get_Pointer(PCMAC + 1) +#define Get_Pointer_PCMAC2 Get_Pointer(PCMAC + 2) + + /* For getting a signed byte */ +#define Get_SBYTE_PCMAC0 GETBYTE((s_char *)PCMAC) +#define Get_SBYTE_PCMAC1 GETBYTE((s_char *)PCMAC+1) + + /* for getting an atom number, e.g., for FNx or DTEST */ +#ifdef BIGATOMS +#define Get_AtomNo_PCMAC1 Get_Pointer_PCMAC1 +#define Get_AtomNo_PCMAC2 Get_Pointer_PCMAC2 +#ifdef BIGVM +#define nextop_atom nextop5 +#define nextop_ptr nextop5 +#else +#define nextop_atom nextop4 +#define nextop_ptr nextop4 +#endif /* BIGVM */ +#else +#define Get_AtomNo_PCMAC1 Get_DLword_PCMAC1 +#define Get_AtomNo_PCMAC2 Get_DLword_PCMAC2 +#define nextop_atom nextop3 +#define nextop_ptr nextop4 +#endif /* BIGATOMS */ + + + + +#define CHECK_INTERRUPT {if((int)CSTKPTR > Irq_Stk_Check) goto check_interrupt;} +#define SWAP_WORDS(x) (((unsigned int)x << 16) | (((unsigned int)x >> 16) & 0xFFFF)) + + +#define NATIVECHECK \ + {if (BCE_CURRENTFX->native) {goto gonative ;} nextop0; } + +#define nextop0 {goto nextopcode; } +#define nextop1 {PCMACL += 1; nextop0; } +#define nextop2 {PCMACL += 2; nextop0; } +#define nextop3 {PCMACL += 3; nextop0; } +#define nextop4 {PCMACL += 4; nextop0; } +#define nextop5 {PCMACL += 5; nextop0; } + +#define OPCAR \ + if (Listp(TOPOFSTACK))\ + {\ + register ConsCell *DATUM68K = (ConsCell *)(Addr68k_from_LADDR(TOPOFSTACK));\ + if (DATUM68K->cdr_code == CDR_INDIRECT)\ + {\ + TOPOFSTACK = ((LispPTR)((ConsCell *)Addr68k_from_LADDR(DATUM68K->car_field))->car_field);\ + nextop1; \ + }\ + else \ + { \ + TOPOFSTACK = ((LispPTR)DATUM68K->car_field);\ + nextop1; \ + } \ + }\ + else if (TOPOFSTACK == NIL_PTR)\ + { nextop1; } \ + else if ( TOPOFSTACK == ATOM_T)\ + { nextop1; } \ + else \ + {\ + goto op_ufn; \ + } /* end of OPCAR */ + +#ifdef NEWCDRCODING +#define OPCDR \ + if (Listp(TOPOFSTACK))\ + {\ +register ConsCell *DATUM68K = (ConsCell *)(Addr68k_from_LADDR(TOPOFSTACK));\ +register int CDRCODEX = DATUM68K->cdr_code;\ + if (CDRCODEX == CDR_NIL) {\ + /* cdr-nil */\ + TOPOFSTACK = (NIL_PTR);\ + nextop1; \ + } \ + else if (CDRCODEX> CDR_ONPAGE) {\ + /* cdr-samepage */\ + TOPOFSTACK = ((TOPOFSTACK) + ((CDRCODEX & 7) << 1));\ + nextop1; \ + } \ + else if (CDRCODEX == CDR_INDIRECT) { /* CDRCODEX < CDR_ONPAGE */\ + /* cdr-indirect */\ + TOPOFSTACK = (cdr ((LispPTR)(DATUM68K->car_field)));\ + nextop1; \ + } \ + else\ + {\ + /* cdr-differentpage */\ + TOPOFSTACK = ((ConsCell *)(Addr68k_from_LADDR \ + ((TOPOFSTACK) + (CDRCODEX << 1)))\ + )->car_field;\ + nextop1; \ + }\ + }\ + else if (TOPOFSTACK == NIL_PTR)\ + { nextop1; } \ + else\ + {\ + goto op_ufn; \ + } /* end of OPCDR */ +#else +#define OPCDR \ + if (Listp(TOPOFSTACK))\ + {\ +register ConsCell *DATUM68K = (ConsCell *)(Addr68k_from_LADDR(TOPOFSTACK));\ +register int CDRCODEX = DATUM68K->cdr_code;\ + if (CDRCODEX == CDR_NIL) {\ + /* cdr-nil */\ + TOPOFSTACK = (NIL_PTR);\ + nextop1; \ + } \ + else if (CDRCODEX> CDR_ONPAGE) {\ + /* cdr-samepage */\ + TOPOFSTACK = (POINTER_PAGEBASE(TOPOFSTACK) + \ + ((CDRCODEX & 127) << 1));\ + nextop1; \ + } \ + else if (CDRCODEX == CDR_INDIRECT) { /* CDRCODEX < CDR_ONPAGE */\ + /* cdr-indirect */\ + TOPOFSTACK = (cdr ((LispPTR)(DATUM68K->car_field)));\ + nextop1; \ + } \ + else\ + {\ + /* cdr-differentpage */\ + TOPOFSTACK = ((ConsCell *)(Addr68k_from_LADDR \ + (POINTER_PAGEBASE(TOPOFSTACK) + (CDRCODEX << 1)))\ + )->car_field;\ + nextop1; \ + }\ + }\ + else if (TOPOFSTACK == NIL_PTR)\ + { nextop1; } \ + else\ + {\ + goto op_ufn; \ + } /* end of OPCDR */ +#endif /* NEWCDRCODING */ + +#define IVARMACRO(x) {PUSH(IVAR[x]); nextop1;} +#define PVARMACRO(x) {PUSH(PVAR[x]); nextop1;} +#define PVARSETMACRO(x) {PVAR[x] = TOPOFSTACK; nextop1;} +#define PVARSETPOPMACRO(x) {PVAR[x] = TOPOFSTACK; POP; nextop1;} +#define PUSHATOM(x) {PUSH(x); nextop1;} + + +#define JUMPMACRO(x) {CHECK_INTERRUPT; PCMACL += x; nextop0;} + +#define FJUMPMACRO(x) {if(TOPOFSTACK != 0) {goto PopNextop1 ; } \ + {CHECK_INTERRUPT; POP; PCMACL += x; nextop0;} \ + } +#define TJUMPMACRO(x) {if(TOPOFSTACK == 0) {goto PopNextop1 ; } \ + {CHECK_INTERRUPT; POP; PCMACL += x; nextop0;} \ + } + +#define GETBASE_N(N) { \ + TOPOFSTACK = \ + (S_POSITIVE | GETWORD((DLword *) \ + Addr68k_from_LADDR((POINTERMASK & TOPOFSTACK) + N)));\ + nextop2; \ + } + +#define GETBASEPTR_N(N) { \ + TOPOFSTACK = \ + ( POINTERMASK & *((LispPTR *) \ + Addr68k_from_LADDR((POINTERMASK & TOPOFSTACK) + N)));\ + nextop2; \ + } +#define PUTBASEBYTE \ + { register int byteoffset; \ + register char *p_data; \ + if(((SEGMASK & TOPOFSTACK) != S_POSITIVE) || \ + ((unsigned short)TOPOFSTACK >= 256)) \ + goto op_ufn; \ + byteoffset = GET_TOS_1; \ + switch( (SEGMASK & byteoffset) ){ \ + case S_POSITIVE: \ + byteoffset &= 0x0000FFFF; \ + break; \ + case S_NEGATIVE: \ + byteoffset |= 0xFFFF0000; \ + break; \ + default: \ + goto op_ufn; \ + /*** if( GetTypeNumber(byteoffset) == TYPE_FIXP ) \ + byteoffset = *((int *)Addr68k_from_LADDR(byteoffset)); \ + else \ + goto op_ufn; ***/ \ + } \ + --CSTKPTRL; \ + p_data = (char*)Addr68k_from_LADDR(POINTERMASK & (POP_TOS_1)) + byteoffset; \ + GETBYTE(p_data) = 0xFF & TOPOFSTACK; \ + nextop1; \ + } + +#define GETBASEBYTE \ + {switch( (SEGMASK & TOPOFSTACK) ){ \ + case S_POSITIVE: \ + TOPOFSTACK &= 0x0000FFFF; \ + break; \ + case S_NEGATIVE: \ + TOPOFSTACK |= 0xFFFF0000; \ + break; \ + default: \ + if( GetTypeNumber(TOPOFSTACK) == TYPE_FIXP ) \ + TOPOFSTACK = *((int *)Addr68k_from_LADDR(TOPOFSTACK)); \ + else \ + goto op_ufn; \ + } \ + TOPOFSTACK = (0xFF & (GETBYTE((char*)Addr68k_from_LADDR((POINTERMASK & (POP_TOS_1))) + TOPOFSTACK))) | S_POSITIVE; \ + nextop1; \ + } + + +#define PUTBASEPTR_N(n) \ + { register int base; \ + base = POINTERMASK & POP_TOS_1; \ + *((LispPTR *)Addr68k_from_LADDR(base + n)) = TOPOFSTACK; \ + TOPOFSTACK = base; \ + nextop2; \ + } + +#define PUTBASE_N(n) \ + { register int base; \ + if (GetHiWord(TOPOFSTACK) != (S_POSITIVE >> 16)) \ + goto op_ufn; \ + base = POINTERMASK & POP_TOS_1; \ + GETWORD((DLword *)Addr68k_from_LADDR(base + n)) = GetLoWord(TOPOFSTACK);\ + TOPOFSTACK = base; \ + nextop2; \ + } + + +#define PVARX(x) { PUSH(GetLongWord((DLword *)PVAR + x)); nextop2; } +#define PVARX_(x) { *((LispPTR *)((DLword *)PVAR+x))=TOPOFSTACK; nextop2;} +#define IVARX(x) { PUSH(GetLongWord((DLword *)IVAR + x)); nextop2; } +#define IVARX_(x) { *((LispPTR *)((DLword *)IVAR+x))=TOPOFSTACK; nextop2;} + +#ifndef BIGATOMS +#define GVAR(x) { PUSH(GetLongWord(Valspace + ((x)<<1))); nextop_atom; } +#elif defined(BIGVM) +#define GVAR(x) \ + { register int tx = x; \ + if (tx & SEGMASK) \ + { \ + PUSH(GetLongWord( \ + Addr68k_from_LADDR((tx)+NEWATOM_VALUE_OFFSET))); \ + } \ + else PUSH(GetLongWord((LispPTR *)Pnamespace + (tx*5) + NEWATOM_VALUE_PTROFF)); \ + \ + nextop_atom; \ + } +#else +#define GVAR(x) \ + { register int tx = x; \ + if (tx & SEGMASK) \ + { \ + PUSH(GetLongWord( \ + Addr68k_from_LADDR((tx)+NEWATOM_VALUE_OFFSET))); \ + } \ + else PUSH(GetLongWord(Valspace + ((tx)<<1))); \ + \ + nextop_atom; \ + } +#endif /* BIGATOMS */ + + + +#define COPY { HARD_PUSH(TOPOFSTACK); nextop1; } + +#define SWAP { register LispPTR temp; \ + temp = GET_TOS_1; \ + GET_TOS_1 = TOPOFSTACK; \ + TOPOFSTACK = temp; \ + nextop1; \ + } + + /*********************************************/ + /* Note: No matter how smart it seems, don't */ + /* AND in POINTERMASK in VAG2, because there */ + /* is code that depends on VAG2 building */ + /* full, 32-bit pointers from 16-bit ints. */ + /*********************************************/ +#define N_OP_VAG2 { TOPOFSTACK = ((GET_TOS_1 << 16) \ + | (0xFFFF & TOPOFSTACK)); CSTKPTRL--; nextop1; } + +#define FN0 { OPFN(0, fn0_args, fn0_xna, fn0_native); } +#define FN1 { OPFN(1, fn1_args, fn1_xna, fn1_native); } +#define FN2 { OPFN(2, fn2_args, fn2_xna, fn2_native); } +#define FN3 { OPFN(3, fn3_args, fn3_xna, fn3_native); } +#define FN4 { OPFN(4, fn4_args, fn4_xna, fn4_native); } +#define FNX { OPFNX; nextop0; } +#define ENVCALL { OP_ENVCALL; nextop0; } +#define RETURN { OPRETURN; nextop0; } +#define APPLY { OPAPPLY;} +#define CHECKAPPLY { OPCHECKAPPLY; nextop1; } + +#define BIN \ +{ \ +register Stream *stream68k; /* stream instance on TOS */ \ +register char *buff68k; /* pointer to BUFF */ \ + \ + if ( GetTypeNumber(TOPOFSTACK) == TYPE_STREAM ) { \ + stream68k=(Stream *) Addr68k_from_LADDR(TOPOFSTACK); \ + if( ( !stream68k->BINABLE ) || \ + ( stream68k->COFFSET >= \ + stream68k->CBUFSIZE ) ) goto op_ufn; \ + \ + /* get BUFFER instance */ \ + buff68k =(char *)Addr68k_from_LADDR(stream68k->CBUFPTR); \ + \ + /* get BYTE data and set it to TOS */ \ + TOPOFSTACK = (S_POSITIVE | \ + (Get_BYTE(buff68k + (stream68k->COFFSET)++)) ); \ + nextop1; \ + } \ + else goto op_ufn; \ +} + +#ifdef RECLAIMINC +#define RECLAIMCELL { TOPOFSTACK = gcreclaimcell(TOPOFSTACK); nextop1; } +#else +#define RECLAIMCELL { goto op_ufn; } +#endif + +#define GCSCAN1 { TOPOFSTACK=gcscan1(TOPOFSTACK & 0xffff); \ + if (TOPOFSTACK) {TOPOFSTACK |= S_POSITIVE; };nextop1;} + +#define GCSCAN2 { TOPOFSTACK=gcscan2(TOPOFSTACK & 0xffff); \ + if (TOPOFSTACK) {TOPOFSTACK |=S_POSITIVE; };nextop1;} + + +#define CONTEXTSWITCH { EXT; OP_contextsw(); RET; \ + /*CHECK_INTERRUPT;*/ CLR_IRQ; \ + NATIVE_NEXTOP0; } + +#define NOP { nextop1; } +#define RESLIST(n) { goto op_ufn; } + +#define FINDKEY(x) \ + { \ + TOPOFSTACK = N_OP_findkey(TOPOFSTACK, x); \ + nextop2; \ + } + +#define RPLPTR(n) \ + { \ + TOPOFSTACK = N_OP_rplptr(POP_TOS_1, TOPOFSTACK, n); \ + nextop2; \ + } + +#define GVAR_(atom_index) \ + { \ + N_OP_gvar_(TOPOFSTACK, atom_index); \ + nextop_atom; \ + } + +#define BIND {register int n1; \ + register int n2; \ + register LispPTR *ppvar; \ + register int i; \ + n1 = Get_BYTE_PCMAC1 >> 4; \ + n2 = Get_BYTE_PCMAC1 & 0xf; \ + ppvar = (LispPTR *)PVAR + 1 + Get_BYTE_PCMAC2; \ + for(i=n1; --i >= 0;){ *--ppvar = NIL_PTR; } \ + if(n2 == 0){ \ + *CSTKPTRL++ = TOPOFSTACK; \ + }else{ \ + *--ppvar = TOPOFSTACK; \ + for(i=1; i= 0 );); \ + value = *CSTKPTR; \ + num = (~value)>>16; \ + ppvar = (LispPTR *)((DLword *)PVAR + 2 + GetLoWord(value));\ + for(i=num; --i >= 0;){*--ppvar = 0xffffffff;} \ + nextop1; \ + } + +#define DUNBIND {register int num; \ + register LispPTR *ppvar; \ + register int i; \ + register LispPTR value; \ + if((int)TOPOFSTACK < 0){ \ + num =(~TOPOFSTACK)>>16; \ + if(num != 0){ \ + ppvar = (LispPTR *)((DLword *)PVAR + 2 + GetLoWord(TOPOFSTACK)); \ + for(i=num; --i >= 0;) { \ + *--ppvar = 0xffffffff; } \ + } \ + }else{ \ + for(; ( ((int)*--CSTKPTRL) >= 0 );); \ + value = *CSTKPTR; \ + num = (~value)>>16; \ + ppvar = (LispPTR *)((DLword *)PVAR + 2 + GetLoWord(value));\ + for(i=num; --i >= 0;) { \ + *--ppvar = 0xffffffff; } \ + } \ + POP; \ + nextop1; \ + } + +#define N_OP_HILOC \ + { \ + TOPOFSTACK = GetHiWord(TOPOFSTACK) | S_POSITIVE; \ + nextop1; \ + } +#define N_OP_LOLOC \ + { \ + TOPOFSTACK = GetLoWord(TOPOFSTACK) | S_POSITIVE; \ + nextop1; \ + } + +#define GETBITS_N_M(a, b) \ + {register int temp, bb = b; \ + temp = 0xF & bb; \ + TOPOFSTACK = S_POSITIVE | \ + (( (GETWORD(Addr68k_from_LADDR(POINTERMASK & (TOPOFSTACK+a)))) \ + >> (16 - ( (0xF & (bb >> 4)) + temp + 1)) ) \ + & n_mask_array[temp] ); \ + nextop3; \ + } + +#define PUTBITS_N_M(a, b) \ + { int base; \ + register int bb = b; \ + register DLword *pword; \ + register int shift_size, field_size, fmask; \ + if( (SEGMASK & TOPOFSTACK) != S_POSITIVE ){ goto op_ufn; }; \ + base = POINTERMASK & POP_TOS_1; \ + pword = (DLword*)Addr68k_from_LADDR( base + a ); \ + field_size = 0xF & bb; \ + shift_size = 15 - (0xF & (bb >> 4)) - field_size; \ + fmask = n_mask_array[field_size] << shift_size; \ + GETWORD(pword) = ( (TOPOFSTACK << shift_size) & fmask) | \ + (GETWORD(pword) & (~fmask)); \ + TOPOFSTACK = base; \ + nextop3; \ + } + + +#define CONS \ + { TOPOFSTACK = N_OP_cons(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + +#define MYALINK \ + { \ + PUSH(((( CURRENTFX->alink) & 0xfffe)-FRAMESIZE) | S_POSITIVE); \ + nextop1; \ + } + +#define MYARGCOUNT \ + { register int arg_num; \ + if (( CURRENTFX->alink & 1) == 0) \ + arg_num = (int)((LispPTR *)(CURRENTFX) - 1); \ + else \ + arg_num = (int)(Stackspace + CURRENTFX->blink); \ + PUSH( (DLword)((arg_num - (int)IVar) >> 2) | S_POSITIVE); \ + nextop1; \ + } + +#define RCLK \ + { \ + TOPOFSTACK = N_OP_rclk(TOPOFSTACK); \ + nextop1; \ + } + +#define LISTP { \ + if((DLword)GetTypeNumber(TOPOFSTACK) != TYPE_LISTP)\ + TOPOFSTACK = NIL_PTR; \ + nextop1; \ + } + +#define NTYPEX \ + { \ + TOPOFSTACK = S_POSITIVE | (DLword)(GetTypeNumber(TOPOFSTACK));\ + nextop1; \ + } + +#define TYPEP(n) \ + { \ + if((DLword)GetTypeNumber(TOPOFSTACK) != n) \ + TOPOFSTACK = NIL_PTR; \ + nextop2; \ + } + +#define TYPEMASK(n) \ + { \ + if( ( ((DLword)GetTypeEntry(TOPOFSTACK)) & \ + ( (DLword)n << 8)) == 0) \ + TOPOFSTACK = NIL_PTR; \ + nextop2; \ + } + +#define INSTANCEP(atom_index) \ + { \ + TOPOFSTACK = N_OP_instancep(TOPOFSTACK,atom_index); \ + nextop_atom; \ + } + +#define STOREN(n) \ + { *(CSTKPTR - ((n+2) >> 1)) = TOPOFSTACK; \ + nextop2; \ + } + +#define COPYN(n) \ + { PUSH(*(CSTKPTR - ((n+2) >> 1))); \ + nextop2; \ + } + +#define POPN(n) \ + {TOPOFSTACK = *(CSTKPTRL -= ((n)+1)); \ + nextop2; \ + } + +#define CLARITHEQUAL { \ +register int arg2; \ + SV; arg2 = POP_TOS_1; \ + if ((TOPOFSTACK & SEGMASK) == S_POSITIVE) \ + { \ + if (arg2 == TOPOFSTACK) {TOPOFSTACK = ATOM_T; nextop1;} \ + if ((arg2 & SEGMASK) == S_POSITIVE) {TOPOFSTACK = NIL; nextop1;} \ + } \ + N_OP_POPPED_CALL_2(N_OP_eqq, arg2); \ +} + +#define S_CHARACTER 0x70000 + +#define AREF1 { \ +LispPTR arrayarg; \ +register LispPTR baseL; \ +register int index; \ +register OneDArray *arrayblk; \ +DLword *createcell68k(); \ + SV; arrayarg = POP_TOS_1; \ + if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) goto aref_ufn; \ + arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); \ + if ((TOPOFSTACK & SEGMASK) != S_POSITIVE) goto aref_ufn; \ + index = TOPOFSTACK & 0xFFFF; \ + if (index >= arrayblk->totalsize) goto aref_ufn; \ + index += arrayblk->offset; \ + baseL = arrayblk->base; \ + switch (arrayblk->typenumber) { \ + case 38: /* pointer : 32 bits */ \ + TOPOFSTACK = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + nextop1; \ + case 20: /* signed : 16 bits */ \ + TOPOFSTACK = (GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF; \ + if (TOPOFSTACK & 0x8000) TOPOFSTACK |= S_NEGATIVE; \ + else TOPOFSTACK |= S_POSITIVE; \ + nextop1; \ + case 67: /* Character : 8 bits */ \ + TOPOFSTACK = S_CHARACTER | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF); \ + nextop1; \ + case 22: /* signed : 32 bits */ \ + TOPOFSTACK = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + switch(TOPOFSTACK & 0xFFFF0000){ \ + case 0: \ + TOPOFSTACK |= S_POSITIVE; \ + break; \ + case (unsigned)0xFFFF0000: \ + TOPOFSTACK &= S_NEGATIVE; \ + break; \ + default:{register DLword *wordp; \ + wordp = createcell68k(TYPE_FIXP); \ + *((int *)wordp) = TOPOFSTACK; \ + TOPOFSTACK = (LispPTR)LADDR_from_68k(wordp); \ + } \ + } \ + nextop1; \ + case 0: /* unsigned : 1 bit per element */ \ + TOPOFSTACK = S_POSITIVE | (((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + (index >> 3))) >> (7 - (index & 7))) & 1); \ + nextop1; \ + case 3: /* unsigned : 8 bits per element */ \ + TOPOFSTACK = S_POSITIVE | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF); \ + nextop1; \ + case 4: /* unsigned : 16 bits per element */ \ + TOPOFSTACK = S_POSITIVE | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF); \ + nextop1; \ + case 54: /* Float : 32 bits */{register DLword *wordp; \ + wordp = createcell68k(TYPE_FLOATP); \ + *((int *)wordp) = *(((int *)Addr68k_from_LADDR(baseL)) + index);\ + TOPOFSTACK = (LispPTR)LADDR_from_68k(wordp); \ + } \ + nextop1; \ + case 68: /* Character : 16 bits */ \ + TOPOFSTACK = S_CHARACTER | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF); \ + nextop1; \ + case 86: /* XPointer : 32 bits */ \ + TOPOFSTACK = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + nextop1; \ + default: /* Illegal or Unimplemented */ \ + goto aref_ufn; \ + }/* end switch typenumber */ \ +aref_ufn: \ + N_OP_POPPED_CALL_2(N_OP_aref1, arrayarg); \ +} + +#ifdef BIGVM +#define DTEST(n) \ +{ \ + register int atom_index; \ + register struct dtd *dtd68k ; \ + atom_index = n; \ + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(TOPOFSTACK)); \ + atom_index != dtd68k->dtd_name ; \ + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) \ + { \ + if( dtd68k->dtd_supertype == 0) \ + { \ + goto op_ufn; \ + } \ + } \ +nextop_atom; \ +} +#else /* BIGVM */ +#define DTEST(n) \ +{ \ + register int atom_index; \ + register struct dtd *dtd68k ; \ + atom_index = n; \ + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(TOPOFSTACK)); \ + atom_index != dtd68k->dtd_namelo +((int)(dtd68k->dtd_namehi)<<16) ; \ + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) \ + { \ + if( dtd68k->dtd_supertype == 0) \ + { \ + goto op_ufn; \ + } \ + } \ +nextop_atom; \ +} +#endif /* BIGVM */ + +#define FVAR(n) { \ +register LispPTR *chain; \ +chain = (LispPTR *) (PVar + n); \ +if(WBITSPTR(chain)->LSB){ \ + PUSH(GetLongWord(Addr68k_from_LADDR( \ + POINTERMASK & SWAP_WORDS(native_newframe(n >> 1))))); \ + nextop1; \ + }/* if(((WBITS */ \ +PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \ +nextop1; \ +} + +#define FVARX(n) { \ +register int nn = n; \ +register LispPTR *chain; \ +chain = (LispPTR *) (PVar + nn); \ +if(WBITSPTR(chain)->LSB){ \ + PUSH(GetLongWord(Addr68k_from_LADDR( \ + POINTERMASK & SWAP_WORDS(native_newframe(nn >> 1))))); \ + nextop2; \ + }/* if(((WBITS */ \ +PUSH(GetLongWord(Addr68k_from_LADDR(POINTERMASK & SWAP_WORDS(*chain)))); \ +nextop2; \ +} + + +/* ******************************************************************** */ +/* THE FOLLOWING WAS IN n_op_inlinedefsC.h */ +/* ******************************************************************** */ + +#define GCREF(n) { \ + GCLOOKUPV(TOPOFSTACK, n, TOPOFSTACK); \ + nextop2;} + +#ifndef BIGATOMS +#define ATOMCELL_N(n) \ + {if ((unsigned int)TOPOFSTACK >> 16) {goto op_ufn;} \ + TOPOFSTACK = (n << 16) + (TOPOFSTACK << 1) ; \ + nextop2; \ + } +#elif defined(BIGVM) +#define ATOMCELL_N(n) \ + { register int nn = n; \ + if (0==((unsigned int)(TOPOFSTACK&= POINTERMASK) & SEGMASK)) \ + { /* old-symbol case; just add cell-number arg */ \ + switch (nn) \ + { \ + case PLIS_HI: /* PLIST entry for symbol */ \ + TOPOFSTACK = (PNP_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_PLIST_OFFSET; \ + break; \ + case PNP_HI: /* PNAME entry for symbol */ \ + TOPOFSTACK = (PNP_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_PNAME_OFFSET; \ + break; \ + case VALS_HI: /* VALUE cell for symbol */ \ + TOPOFSTACK = (PNP_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_VALUE_OFFSET; \ + break; \ + case DEFS_HI: /* DEFINITION for symbol */ \ + TOPOFSTACK = (PNP_HI << 16) + (10*(unsigned int)TOPOFSTACK) + NEWATOM_DEFN_OFFSET; \ + break; \ + default: goto op_ufn; \ + } \ + nextop2; \ + } \ + else if (TYPE_NEWATOM == GetTypeNumber(TOPOFSTACK)) \ + { /* NEW-symbol case; it's an offset from the main ptr */ \ + switch (nn) \ + { \ + case PLIS_HI: /* PLIST entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PLIST_OFFSET; \ + break; \ + case PNP_HI: /* PNAME entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PNAME_OFFSET; \ + break; \ + case VALS_HI: /* VALUE cell for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_VALUE_OFFSET; \ + break; \ + case DEFS_HI: /* DEFINITION for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_DEFN_OFFSET; \ + break; \ + default: goto op_ufn; \ + } \ + nextop2; \ + } \ + else goto op_ufn; \ + } +#else /* */ + +#define ATOMCELL_N(n) \ + { register int nn = n; \ + if (0==((unsigned int)TOPOFSTACK & SEGMASK)) \ + { /* old-symbol case; just add cell-number arg */ \ + TOPOFSTACK = (nn << 16) + (TOPOFSTACK << 1) ; \ + nextop2; \ + } \ + else if (TYPE_NEWATOM == GetTypeNumber(TOPOFSTACK)) \ + { /* NEW-symbol case; it's an offset from the main ptr */ \ + switch (nn) \ + { \ + case PLIS_HI: /* PLIST entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PLIST_OFFSET; \ + break; \ + case PNP_HI: /* PNAME entry for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_PNAME_OFFSET; \ + break; \ + case VALS_HI: /* VALUE cell for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_VALUE_OFFSET; \ + break; \ + case DEFS_HI: /* DEFINITION for symbol */ \ + TOPOFSTACK = TOPOFSTACK + NEWATOM_DEFN_OFFSET; \ + break; \ + default: goto op_ufn; \ + } \ + nextop2; \ + } \ + else goto op_ufn; \ + } +#endif /* BIGATOMS */ + + +#define DIFFERENCE {N_OP_CALL_2(N_OP_difference);} +#define LOGOR {N_OP_CALL_2(N_OP_logor);} +#define LOGAND {N_OP_CALL_2(N_OP_logand);} +#define LOGXOR {N_OP_CALL_2(N_OP_logxor);} +#define PLUS2 {N_OP_CALL_2(N_OP_plus2);} +#define QUOTIENT {N_OP_CALL_2(N_OP_quot);} +#define TIMES2 {N_OP_CALL_2(N_OP_times2);} +#define GREATERP {N_OP_CALL_2(N_OP_greaterp);} +#define IDIFFERENCE {N_OP_CALL_2(N_OP_idifference);} +#define IPLUS2 {N_OP_CALL_2(N_OP_iplus2);} +#define IQUOTIENT {N_OP_CALL_2(N_OP_iquot);} +#define ITIMES2 {N_OP_CALL_2(N_OP_itimes2);} +#define IGREATERP {N_OP_CALL_2(N_OP_igreaterp);} +#define IREMAINDER {N_OP_CALL_2(N_OP_iremainder);} +#define IPLUS_N(n) {N_OP_CALL_1d(N_OP_iplusn, n)} +#define IDIFFERENCE_N(n) {N_OP_CALL_1d(N_OP_idifferencen, n);} +#define BOXIPLUS {N_OP_CALL_2(N_OP_boxiplus);} +#define BOXIDIFFERENCE {N_OP_CALL_2(N_OP_boxidiff);} +#define FPLUS2 {N_OP_CALL_2(N_OP_fplus2);} +#define FDIFFERENCE {N_OP_CALL_2(N_OP_fdifference);} +#define FTIMES2 {N_OP_CALL_2(N_OP_ftimes2);} +#define FQUOTIENT {N_OP_CALL_2(N_OP_fquotient);} +#define FGREATERP {N_OP_CALL_2(N_OP_fgreaterp);} +#define UBFLOAT1(n) {N_OP_UNBOXED_CALL_1d(N_OP_ubfloat1, n);} +#define UBFLOAT2(n) {N_OP_UNBOXED_CALL_2d(N_OP_ubfloat2, n);} +#define UBFLOAT3(n) {N_OP_UNBOXED_CALL_3d(N_OP_ubfloat3, n);} +#define LRSH1 {N_OP_CALL_1(N_OP_lrsh1);} +#define LRSH8 {N_OP_CALL_1(N_OP_lrsh8);} +#define LLSH1 {N_OP_CALL_1(N_OP_llsh1);} +#define LLSH8 {N_OP_CALL_1(N_OP_llsh8);} +#define LSH {N_OP_CALL_2(N_OP_lsh);} +#define RPLACA {N_OP_CALL_2(N_OP_rplaca);} +#define RPLACD {N_OP_CALL_2(N_OP_rplacd);} +#define RPLCONS {N_OP_CALL_2(N_OP_rplcons);} +#define MAKENUMBER {N_OP_CALL_2(N_OP_makenumber);} +#define EQLOP {N_OP_CALL_2(N_OP_eqlop);} +#define CLEQUAL {N_OP_CALL_2(N_OP_clequal);} +#define ILEQUAL {N_OP_CALL_2(N_OP_equal);} +#define CLFMEMB {N_OP_CALL_exception_2(N_OP_clfmemb);} +#define CLASSOC {N_OP_CALL_exception_2(N_OP_classoc);} +#define FMEMB {N_OP_CALL_exception_2(N_OP_fmemb);} +#define ASSOC {N_OP_CALL_exception_2(N_OP_assoc);} +#define ARG0 {N_OP_CALL_1(N_OP_arg0);} +#define LISTGET {N_OP_CALL_exception_2C(N_OP_listget);} +#define DRAWLINE {N_OP_CALL_9(N_OP_drawline);} +#define N_OP_ADDBASE {N_OP_CALL_2(N_OP_addbase);} + +#define UNWIND(n, m) \ + { \ + if ((int)(CSTKPTRL = (LispPTR *) \ + N_OP_unwind(CSTKPTR, TOPOFSTACK, n, m)) < 0) \ + goto unwind_err; \ + POP; \ + nextop3; \ + } + +#define STKSCAN \ + {TOPOFSTACK = N_OP_stkscan(TOPOFSTACK); \ + nextop1; \ + } + +#define FVARX_(n) \ + {TOPOFSTACK = N_OP_fvar_(TOPOFSTACK, n); \ + nextop2; \ + } + +#define BLT {N_OP_CALL_3(N_OP_blt);} + +#define PILOTBITBLT \ + {TOPOFSTACK = N_OP_pilotbitblt(POP_TOS_1, TOPOFSTACK); \ + nextop1; \ + } + +#define CREATECELL {N_OP_CALL_1(N_OP_createcell);} + +#define RESTLIST(n) {TOPOFSTACK = N_OP_restlist(POP_TOS_1, TOPOFSTACK, n);\ + nextop2;} + + +#define ASET1 {N_OP_CALL_3(N_OP_aset1);} +#define ASET2 {N_OP_CALL_4(N_OP_aset2);} +#define MISC3(n) {N_OP_CALL_3d(N_OP_misc3, n);} +#define MISC4(n) {N_OP_CALL_4d(N_OP_misc4, n);} +#define MISC7(n) {N_OP_CALL_7d(N_OP_misc7, n);} +#define AREF2 {N_OP_CALL_3(N_OP_aref2);} +#define MISCN(index, args) \ +{ EXT; \ + if (OP_miscn(index,args)) { \ + RET; \ + /* PUSH(S_POSITIVE | (index << 8) | args); */ \ + goto op_ufn; \ + } \ + RET; \ + nextop0; \ +} + + +/* ******************************************************************** */ +/* Call Interface where -1 indicates an error return */ +/* ******************************************************************** */ + +/* SV need do no work */ +#define SV + +/* UFN_CALLS are inserted in xc.c. Note that only ufn_2 calls have decremented the stack at the time the UFN is called */ + +/* ufn_x there are x args from the Lisp stack + ufn_xd there are x args from the Lisp stack & + some from the code stream. +*/ +#define UFN_CALLS \ + \ +unwind_err: \ + CSTKPTRL = (LispPTR *) CurrentStackPTR; \ + Error_Exit = 0; \ + goto op_ufn; \ +ufn_2d: CSTKPTRL += 1; \ + goto fix_tos_ufn; \ +ufn_2d2:CSTKPTRL += 1; \ + goto fix_tos_ufn; \ +ufn_2: CSTKPTRL += 1; \ + goto fix_tos_ufn; \ +exception_2 : \ + Error_Exit = 0; \ + CSTKPTRL += 1; \ + TOPOFSTACK = TopOfStack; \ + if(!Irq_Stk_End){ \ + goto check_interrupt; \ + } \ + else goto op_ufn; \ +exception_2C : \ + Error_Exit = 0; \ + TOPOFSTACK = TopOfStack; \ + *CSTKPTRL = Scratch_CSTK; \ + CSTKPTRL += 1; \ + if(!Irq_Stk_End){ \ + goto check_interrupt; \ + } \ + else { \ + goto op_ufn; \ + } \ +fix_tos_ufn: \ + TOPOFSTACK = TopOfStack; \ + Error_Exit = 0; \ + goto op_ufn; + +#define N_OP_CALL_1(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(TOPOFSTACK)) < 0) goto fix_tos_ufn;\ +nextop1; + + +#define N_OP_CALL_1d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(TOPOFSTACK, n)) < 0) goto fix_tos_ufn;\ +nextop2; + +#define N_OP_UNBOXED_CALL_1d(op_name, n) \ +TOPOFSTACK = op_name(TOPOFSTACK, n); \ +if (Error_Exit) goto fix_tos_ufn; \ +nextop2; + + +#define N_OP_CALL_2(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK)) < 0) \ + goto ufn_2; \ +nextop1; + +#define N_OP_POPPED_CALL_2(op_name, popped_arg) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(popped_arg, TOPOFSTACK)) < 0) \ + goto ufn_2; \ +nextop1; + +#define N_OP_CALL_2d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK, n)) < 0) \ + goto ufn_2d; \ +nextop2; + +#define N_OP_UNBOXED_CALL_2d(op_name, n) \ +TOPOFSTACK = op_name(POP_TOS_1, TOPOFSTACK, n); \ +if (Error_Exit) goto ufn_2d; \ +nextop2; + +#define N_OP_CALL_2d2(op_name, a, b) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK, a, b)) < 0) \ + goto ufn_2d2; \ +nextop3; + +#define N_OP_CALL_exception_2(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK)) < 0) \ + goto exception_2; \ +nextop1; + +#define N_OP_CALL_exception_2C(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name(POP_TOS_1, TOPOFSTACK)) < 0) \ + goto exception_2C; \ +nextop1; + +#define N_OP_CALL_3(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 2; \ +nextop1; + +#define N_OP_CALL_3d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 2; \ +nextop2; + +#define N_OP_UNBOXED_CALL_3d(op_name, n) \ +TOPOFSTACK = op_name(*(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n); \ +if (Error_Exit) goto fix_tos_ufn; \ +CSTKPTRL -= 2; \ +nextop2; + + +#define N_OP_CALL_4(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-3), *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 3; \ +nextop1; + + +#define N_OP_CALL_4d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-3), *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 3; \ +nextop2; + +#define N_OP_CALL_7d(op_name, n) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-6), *(CSTKPTR-5), *(CSTKPTR-4), \ + *(CSTKPTR-3), *(CSTKPTR-2), *(CSTKPTR-1), TOPOFSTACK, n)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 6; \ +nextop2; + + + +#define N_OP_CALL_9(op_name) \ +if ((int)(TOPOFSTACK = (LispPTR)op_name( \ + *(CSTKPTR-8), *(CSTKPTR-7), *(CSTKPTR-6), \ + *(CSTKPTR-5), *(CSTKPTR-4), *(CSTKPTR-3), *(CSTKPTR-2),\ + *(CSTKPTR-1), TOPOFSTACK /*, fix_tos_ufn*/)) < 0) \ + goto fix_tos_ufn; \ +CSTKPTRL -= 8; \ +nextop1; + + +#ifdef SUN3_OS3_OR_OS4_IL + +/* need jump point for inline asm code, e.g., for IPLUS */ + +#define OPCODEFAIL \ + \ +fixtos1: \ + fixtos1_label(); \ + FIXTOS1; \ + goto op_ufn; + +#else + +/* no opcode fail point necessary */ + +#define OPCODEFAIL + +#endif diff --git a/inc/lnk-lispmap.h b/inc/lnk-lispmap.h new file mode 100755 index 0000000..b834716 --- /dev/null +++ b/inc/lnk-lispmap.h @@ -0,0 +1,247 @@ +/* $Id: lnk-lispmap.h,v 1.2 1999/01/03 02:06:11 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +/* + File Name : lispmap.h(for TEST) + + **************NOTE***************** + OLD DEFs are MOVED to lispmap.FULL + **************NOTE***************** + + Global variables for LispSYSOUT + + Date : December 18, 1986 + Edited by : Takeshi Shimizu + +*/ +/**********************************************************************/ + + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + + + /* Whole Lisp size */ +#define LWORLD_SIZE 0x420000 /* byte */ + +/* 1 MDS entry size is 2(page) * 512 Byte */ +#define MDSTT_SIZE (LWORLD_SIZE >> 10 ) + +/* if you want to use the ATOMSPACE for Dummy then it must be 0x10000 take */ +#define MAP_SHIFT 0x0 + +/* Following constants mean LISP word offset. */ +/* these correspond with lisp mem map */ +/* for IOCBPAGE */ +#define IOCBPAGE_OFFSET 256 +#define IOCB_SIZE 1 + +/* for ATOMSPACE */ +#define ATOMS_HI 0 +#define ATOMS_OFFSET 0x00000 +#define ATOMS_SIZE 0x10000 + +/* for IOPAGE */ +#define IOPAGE_OFFSET 0x0FF00 +#define IOPAGE_SIZE 1 + +/* for STACKSPACE */ +#define STK_HI 1 +#define STK_OFFSET 0x10000 +#define STK_SIZE 0x10000 + +/* for PLISTSPACE */ +#ifndef BIGVM +#define PLIS_HI 2 +#define PLIS_OFFSET 0x20000 +#define PLIS_SIZE 0x20000 +#else +#define PLIS_HI 2 /* place holder, really -- keep the olde value, even though it's inconsistent with the OFFSET, because it's known by LISP, and is used as a dispatch constant. */ +#define PLIS_OFFSET 0x30000 +#define PLIS_SIZE 0x10 +#endif + +#ifdef BIGVM +#define FPTOVP_HI 4 /* again, inconsistent with OFFSET. */ +#define FPTOVP_OFFSET 0x20000 +#define FPTOVP_SIZE 0x40000 +#else +/* for FPTOVP */ +#define FPTOVP_HI 4 +#define FPTOVP_OFFSET 0x40000 +#define FPTOVP_SIZE 0x10000 +#endif /* BIGVM */ + +/*for PAGEMAP */ +#define PAGEMAP_HI 5 +#define PAGEMAP_OFFSET 0x50000 +#define PAGEMAP_SIZE 0x10000 + +/* for InterfacePage */ +#define IFPAGE_HI 6 +#define IFPAGE_OFFSET 0x60000 +#define IFPAGE_SIZE 0x200 + +/* for PageMapTBL */ +#define PAGEMAPTBL_OFFSET 0x60200 +#define PAGEMAPTBL_SIZE 0x800 + +/* for MISCSTATS */ +#define MISCSTATS_OFFSET 0x60A00 +#define MISCSTATS_SIZE 0x200 + +/* for UFNTable */ +#define UFNTBL_OFFSET 0x60C00 +#define UFNTBL_SIZE 0x200 + +/* for DTDspace */ +#define DTD_HI 6 +#define DTD_OFFSET 0x61000 +#define DTD_SIZE 0x1000 + +/* for LOCKEDPAGETBL */ +#define LOCKEDPAGETBL_OFFSET 0x67000 +#define LOCKEDPAGETBL_SIZE 0x1000 + +/* for MDSTT */ +#ifdef BIGVM + /* In BIGVM, MDS type table is at 19.,,0 for 1 segment */ +#define MDS_HI 20 +#define MDS_OFFSET 0x140000 +#define MDS_SIZE 0x10000 +#else +#define MDS_HI 6 +#define MDS_OFFSET 0x68000 +#define MDS_SIZE 0x8000 +#endif /* BIGVM */ + +/* for AtomHashTable */ +#define ATMHT_HI 7 +#define ATMHT_OFFSET 0x70000 +#define ATMHT_SIZE 0x10000 + +/* for PNPSPACE */ +#define PNP_HI 8 +#define PNP_OFFSET 0x80000 +#define PNP_SIZE 0x20000 + +/* for DEFSPACE */ +#define DEFS_HI 10 +#define DEFS_OFFSET 0xA0000 +#define DEFS_SIZE 0x20000 + +/* for VALSPACE */ +#define VALS_HI 12 +#define VALS_OFFSET 0xC0000 +#define VALS_SIZE 0x20000 + +/* for Small Positive */ +#define SPOS_HI 14 +#define S_POSITIVE 0xE0000 +#define SPOS_SIZE 0x10000 + +/* for Small Negative */ +#define SNEG_HI 15 +#define S_NEGATIVE 0xF0000 +#define SNEG_SIZE 0x10000 + +/* for characters */ +#define S_CHAR 0x70000 + +#ifdef BIGVM +/* for HTMAIN */ +#define HTMAIN_HI 16 +#define HTMAIN_OFFSET 0x100000 +#define HTMAIN_SIZE 0x10000 + +/* for HTOVERFLOW */ +#define HTOVERFLOW_OFFSET 0x110000 +#define HTOVERFLOW_SIZE 0x100 + +/* for HTBIGCOUNT */ +#define HTBIG_HI 16 +#define HTBIG_OFFSET 0x110100 +#define HTBIG_SIZE 0x8000 + +/* for HTCOLL */ +#define HTCOLL_HI 10 +#define HTCOLL_OFFSET 0xA0000 +#define HTCOLL_SIZE 0x40000 +#else +/* for HTMAIN */ +#define HTMAIN_HI 16 +#define HTMAIN_OFFSET 0x100000 +#define HTMAIN_SIZE 0x8000 + +/* for HTOVERFLOW */ +#define HTOVERFLOW_OFFSET 0x108000 +#define HTOVERFLOW_SIZE 0x100 + +/* for HTBIGCOUNT */ +#define HTBIG_HI 16 +#define HTBIG_OFFSET 0x108100 +#define HTBIG_SIZE 0x8000 + +/* for HTCOLL */ +#define HTCOLL_HI 17 +#define HTCOLL_OFFSET 0x110000 +#define HTCOLL_SIZE 0x10000 +#endif /* BIGVM */ + + +/* DISPLAYREGION */ + +#define DISPLAY_HI 18 +#define DISPLAY_OFFSET 0x120000 + + +#ifdef MEDLEY +/* for ARRAYSPACE & MDS for PROT-LISP */ +#define ARRAY_OFFSET 0x150000 +#elif defined(BIGVM) +#define ARRAY_OFFSET 0x150000 +#else +#define ARRAY_OFFSET 0x130000 +#endif + +#define MDS_BOTTOM_OFFSET 0x200000 + +/* for PnCharSpace(use only PROT-LISP ) */ +#define PNCHAR_HI 0x20 +#define PNCHAR_OFFSET 0x200000 +#define PNCHAR_SIZE 0x10000 + + +/***** SEG definitions for AtomCellN *****/ +/* following defs correspond with D machine memory layout */ +/**** NOTE!! if D's layout changes, modify following defs */ +#define D_PLISHI 2 +#define D_PNHI 010 +#define D_DEFSHI 012 +#define D_VALSHI 014 diff --git a/inc/lnk-tosfns.h b/inc/lnk-tosfns.h new file mode 100755 index 0000000..4a1b3cc --- /dev/null +++ b/inc/lnk-tosfns.h @@ -0,0 +1,794 @@ +/* $Id: lnk-tosfns.h,v 1.2 1999/01/03 02:06:11 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1994 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +/****************************************************************/ +/****** CURRENT Stack Overflow checks ********/ +/****************************************************************/ + +#define FN_STACK_CHECK \ + if ((int)CSTKPTR > (Irq_Stk_Check=(Irq_Stk_End-STK_MIN(LOCFNCELL)))) \ + goto check_interrupt; + + + +/****************************************************************/ +/****** LOCAL MACROS ********/ +/****************************************************************/ + +#ifdef BIGVM +#define SWAP_FNHEAD +#else +#undef SWAP_FNHEAD +#define SWAP_FNHEAD(x) SWAP_WORDS(x) +#endif /* BIGVM */ + + + +#ifdef NATIVETRAN +#define FN_CALL_NATIVE_CHECK(fncell, args, extra_code) \ +{ \ + if (fncell->native) \ + { \ + extra_code; \ + FuncObj = fncell; \ + HARD_PUSH(TOPOFSTACK); \ + CALL_NATIVE(fncell, args); \ + } \ +} + +#define FN_CALL_NATIVE_CHECK2(fncell, args, extra_code) \ +{ \ + if (fncell->native) \ + { \ + extra_code; \ + (int) PC = args; \ + FuncObj = fncell; \ + HARD_PUSH(TOPOFSTACK); \ + CALL_NATIVE2(fncell, args); \ + } \ +} + +#define ASM_LABEL_OF_FN_COMMON asm_label_op_fn_common() + +#else +#ifdef GCC386 +#define ASM_LABEL_OF_FN_COMMON asm("fn_common:"); +#else +#define ASM_LABEL_OF_FN_COMMON +#endif /* GCC386 */ + +#define FN_CALL_NATIVE_CHECK(fncell, args, extra_code) +#define FN_CALL_NATIVE_CHECK2(fncell, args, extra_code) +#endif /* NATIVETRAN */ + + + +/************************************************************************/ +/* */ +/* A P P L Y _ P O P _ P U S H _ T E S T */ +/* */ +/* Part of op_fn_common; decide what to do to the stack, depending */ +/* on whether we're FNcalling, APPLYing, or calling a UFN. What */ +/* happens depends on the value of fn_apply, which is set by */ +/* the various opcode macros, as follows: */ +/* */ +/* 0 Normal function calls; do nothing additional. */ +/* 1 APPLY: POP the #ARGS and FN-NAME arguments. */ +/* 2 UFN with 0 args from the opcode byte stream. Do nothing. */ +/* 3 UFN with 1 byte of arg from the code stream as a SMALLP */ +/* 4 UFN with 2 bytes of arg from the code stream as a SMALLP */ +/* 5 UFN with 3 bytes of arg from the code stream as a SMALLP */ +/* or as a symbol (for big atoms, e.g.) */ +/* 6 UFN with 4 bytes of arg from the code stream as a SMALLP */ +/* or as a symbol (for big atoms, e.g.) */ +/* */ +/* The latter 3 cases push the additional argument; THE 3-BYTE */ +/* CASE IS INCOMPLETE: IT SHOULD BOX ANY NON-SMALLP VALUES! */ +/* */ +/************************************************************************/ + +#ifdef BIGATOMS +#define APPLY_POP_PUSH_TEST \ + { \ + switch (fn_apply) \ + { \ + case 0: break; /* do nothing */ \ + case 1: POP; POP; break; /* from apply */ \ + case 2: break; /* ufn 0 args */ \ + case 3: PUSH(S_POSITIVE | Get_BYTE_PCMAC1); break; \ + case 4: PUSH(S_POSITIVE | Get_DLword_PCMAC1); break; \ + case 6: /* BIGVM possibility */ \ + case 5: { \ + unsigned int atm = Get_AtomNo_PCMAC1; \ + if (atm & SEGMASK) PUSH(atm) /* new atom */ \ + else PUSH(S_POSITIVE | atm); /* old atom as SMALLP*/\ + } \ + break; \ + default: error("Storage error: invalid UFN entry"); \ + } \ + if (needpush) PUSH(fn_atom_index); \ + } +#else /* not big atoms */ +#define APPLY_POP_PUSH_TEST \ + { \ + switch (fn_apply) \ + { \ + case 0: break; /* do nothing */ \ + case 1: POP; POP; break; /* from apply */ \ + case 2: break; /* ufn 0 args */ \ + case 3: PUSH(S_POSITIVE | Get_BYTE_PCMAC1); break; \ + case 4: PUSH(S_POSITIVE | Get_DLword_PCMAC1); break; \ + case 5: PUSH(S_POSITIVE | Get_AtomNo_PCMAC1); break; \ + default: error("Storage error: invalid UFN entry"); \ + } \ + if (needpush) PUSH(fn_atom_index); \ + } + +#endif /* BIGATOMS */ + + + +#define N_APPLY_POP_PUSH_TEST { \ + APPLY_POP_PUSH_TEST; \ + native_closure_env=closure_env; \ + } + +#define N_ENVCALL_POP_TEST { \ + CSTKPTRL -=2; \ + native_closure_env=closure_env; \ + } + + + +/****************************************************************/ +/****** OPAPPLY ********/ +/****************************************************************/ +#ifndef BIGATOMS +#define OPAPPLY { \ + if ( GET_TOS_1_HI == SPOS_HI ) { \ + fn_num_args = GET_TOS_1_LO; \ + fn_opcode_size = 1; \ + fn_apply = 1; \ + fn_atom_index = TOPOFSTACK; \ + FNTRACER(Trace_APPLY(fn_atom_index)); \ + FNCHECKER(if (quick_stack_check()) Trace_APPLY(fn_atom_index)); \ + if ( (SEGMASK & TOPOFSTACK) == 0) \ + { fn_defcell = (DefCell *) GetDEFCELL68k(TOPOFSTACK); \ + goto op_fn_common; \ + } \ + else \ + if (GetTypeNumber(TOPOFSTACK)==TYPE_COMPILED_CLOSURE) \ + { TopOfStack=TOPOFSTACK; \ + fn_defcell = (DefCell *) &TopOfStack; \ + goto op_fn_common; \ + } \ + else { fn_defcell = (DefCell *) GetDEFCELL68k(NIL_PTR); \ + goto op_fn_common; \ + } \ + } \ + goto op_ufn; \ +} /* OPAPPLY */ +#else +#define OPAPPLY { \ + if ( GET_TOS_1_HI == SPOS_HI ) { \ + fn_num_args = GET_TOS_1_LO; \ + fn_opcode_size = 1; \ + fn_apply = 1; \ + fn_atom_index = TOPOFSTACK; \ + FNTRACER(Trace_APPLY(fn_atom_index)); \ + FNCHECKER(if (quick_stack_check()) Trace_APPLY(fn_atom_index)); \ + if ( (SEGMASK & TOPOFSTACK) == 0) \ + { fn_defcell = (DefCell *) GetDEFCELLlitatom(TOPOFSTACK); \ + goto op_fn_common; \ + } \ + else switch (GetTypeNumber(TOPOFSTACK)) \ + { \ + case TYPE_NEWATOM: \ + fn_defcell = (DefCell *) GetDEFCELLnew(TOPOFSTACK); \ + goto op_fn_common; \ + case TYPE_COMPILED_CLOSURE: \ + TopOfStack=TOPOFSTACK; \ + fn_defcell = (DefCell *) &TopOfStack; \ + goto op_fn_common; \ + default: fn_defcell = (DefCell *) GetDEFCELL68k(NIL_PTR); \ + goto op_fn_common; \ + } /* end of switch */ \ + } \ + goto op_ufn; \ +} /* OPAPPLY */ +#endif /* BIGATOMS */ + + + +/****************************************************************/ +/****** OPFN(x) ********/ +/****************************************************************/ + +#if (defined(SUN3_OS3_OR_OS4_IL) && !(defined(NOASMFNCALL)) ) + +#ifdef NATIVETRAN + +#define OPFN(x, num_args_fn, fn_xna_args, fn_native) \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around). */ \ + fn_section1(); \ + fn_section2(); \ + num_args_fn(); \ + fn_native_test(); \ + fn_section3(); \ + fn_xna_args(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fn_native(); \ + fn_section5(); \ + /* asm code jumps here when not ccodep */ \ + { fn_atom_index = Get_AtomNo_PCMAC1; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = x; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ +} + +#define OPFNX \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around. */ \ + fnx_section1(); \ + fn_section2(); \ + fnx_args(); \ + fn_native_test(); \ + fn_section3(); \ + fnx_xna(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fnx_native(); \ + fn_section5(); \ + fn_atom_index = Get_AtomNo_PCMAC2; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = Get_BYTE_PCMAC1; \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + /* *** these carefully arranged to satisfy optimizer */ \ +label1: fast1_dispatcher(); \ +label2: to_native_label(); \ + \ +} +#else + +#define OPFN(x, num_args_fn, fn_xna_args, fn_native) \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around). */ \ + fn_section1(); \ + fn_section2(); \ + num_args_fn(); \ + fn_section3(); \ + fn_xna_args(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fn_section5(); \ + /* asm code jumps here when not ccodep */ \ + { fn_atom_index = Get_AtomNo_PCMAC1; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = x; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ +} + +#define OPFNX \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around. */ \ + fnx_section1(); \ + fn_section2(); \ + fnx_args(); \ + fn_section3(); \ + fnx_xna(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fn_section5(); \ + fn_atom_index = Get_AtomNo_PCMAC2; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = Get_BYTE_PCMAC1; \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + /* *** these carefully arranged to satisfy optimizer */ \ +label1: fast1_dispatcher(); \ + \ +} + +#endif /* NATIVETRAN */ + + +#else + +#define OPFN(argcount, num_args_fn, fn_xna_args, fn_native) \ +{ /* argcount is a number of the arguments on stack */ \ + register struct fnhead *LOCFNCELL; \ + register int defcell_word; \ + register int NEXTBLOCK; \ + FNTRACER(Trace_FNCall(argcount, Get_AtomNo_PCMAC1, TOPOFSTACK, CSTKPTR-1)); \ + FNCHECKER(if (quick_stack_check()) Trace_FNCall(argcount, Get_AtomNo_PCMAC1, TOPOFSTACK,CSTKPTR-1)); \ + fn_defcell = (DefCell *)GetDEFCELL68k(fn_atom_index = Get_AtomNo_PCMAC1); \ + defcell_word = *(int *)fn_defcell; \ + FNTPRINT((" def cell = 0x%x.\n", defcell_word)); \ + if(!(fn_defcell->ccodep)) \ + { /* it's not a CCODEP */ \ + fn_num_args = argcount; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR((defcell_word &= POINTERMASK));\ + BCE_CURRENTFX->pc = ((unsigned int)PCMAC - (unsigned int)FuncObj) + FN_OPCODE_SIZE;\ + FN_CALL_NATIVE_CHECK(LOCFNCELL,-argcount,{}); \ + FN_STACK_CHECK; \ + {register int newivar; \ + newivar = (int) (IVARL = (DLword *)(CSTKPTR-argcount+1)); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + HARD_PUSH(TOPOFSTACK); /* save TOS */ \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = argcount - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(defcell_word); \ + CSTKPTRL = (LispPTR *)(((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + result = LOCFNCELL->pv; \ + if (result >= 0) \ + {register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + if (result > 0) \ + {HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + result-=1; \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } \ + } \ + } \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ + nextop0; \ +} /* end OPFN */ + + +/*************** OPFNX *************/ +#define OPFNX { \ + register struct fnhead *LOCFNCELL; \ + register DefCell *defcell; /* this reg is not allocated */ \ + register int NEXTBLOCK; \ + int num_args = Get_BYTE_PCMAC1; \ + defcell = (DefCell *) GetDEFCELL68k(Get_AtomNo_PCMAC2); \ + FNTRACER(Trace_FNCall(num_args, Get_AtomNo_PCMAC2, TOPOFSTACK, CSTKPTR-1)); \ + FNCHECKER(if (quick_stack_check()) Trace_FNCall(num_args, Get_AtomNo_PCMAC2, TOPOFSTACK, CSTKPTR-1)); \ + if( defcell->ccodep == 0 ) \ + { fn_defcell = defcell; \ + fn_num_args = num_args; \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_atom_index = Get_AtomNo_PCMAC2; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(defcell->defpointer); \ + BCE_CURRENTFX->pc = ((unsigned int)PCMAC - (unsigned int)FuncObj) + FNX_OPCODE_SIZE;\ + FN_CALL_NATIVE_CHECK2(LOCFNCELL, - num_args, {}); \ + FN_STACK_CHECK; \ + {register int newivar; \ + newivar = (int)(IVARL = (DLword *)(CSTKPTR-num_args+1)); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + HARD_PUSH(TOPOFSTACK); /* save TOS */ \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = num_args - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(defcell->defpointer);\ + CSTKPTRL = (LispPTR *) (((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + result = LOCFNCELL->pv; \ + if (result >= 0) \ + {register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + if (result > 0) \ + {HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + result-=1; \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } \ + } \ + } \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ +} /* end OPFN */ + +#endif /* NOASMFNCALL */ + + + + + +/****************************************************************/ +/****** OPCHECKAPPLY ********/ +/****************************************************************/ +#ifdef BIGATOMS +#define OPCHECKAPPLY { \ + register DefCell *defcell; \ + defcell = (DefCell *) GetDEFCELL68k(TOPOFSTACK & POINTERMASK); \ + if (!( defcell->ccodep && (((TOPOFSTACK & SEGMASK) == 0) || (GetTypeNumber(TOPOFSTACK) == TYPE_NEWATOM)) && \ + ( ( defcell->argtype == 0 ) || ( defcell->argtype == 2 ) ) ) ) \ + goto op_ufn; \ +} +#else +#define OPCHECKAPPLY { \ + register DefCell *defcell; \ + defcell = (DefCell *) GetDEFCELL68k(TOPOFSTACK & POINTERMASK); \ + if (!( defcell->ccodep && ((TOPOFSTACK & SEGMASK) == 0) ) && \ + ( ( defcell->argtype == 0 ) || ( defcell->argtype == 2 ) ) ) \ + goto op_ufn; \ +} +#endif /* BIGATOMS */ + + +/****************************************************************/ +/* UFN_COMMON at op_ufn / +/****************************************************************/ +#define GetUFNEntry(num) (((UFN *)UFNTable) + (num)) + +#define UFN_COMMON \ +op_ufn: use code in XC.c \ +{ register UFN *entry68k; \ + entry68k = (UFN *)GetUFNEntry(Get_BYTE_PCMAC0); \ + fn_num_args = entry68k->arg_num; \ + fn_opcode_size = entry68k->byte_num+1; \ + fn_atom_index = entry68k->atom_name; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_apply = 0; \ + goto op_fn_common; \ + }; + + + +/****************************************************************/ +/****** OP_FN_COMMON ********/ +/* vars: */ +/* fn_atom_index */ +/* fn_num_args */ +/* fn_opcode_size */ +/* fn_defcell */ +/* fn_apply */ +/* */ +/* All Closure Calls go through here */ +/****************************************************************/ +#define needpush NEXTBLOCK +#define OP_FN_COMMON \ +op_fn_common: \ + ASM_LABEL_OF_FN_COMMON; \ +{ register struct fnhead *LOCFNCELL; \ + register DefCell *defcell; /* this reg is not allocated */ \ + CClosure *closure; \ + LispPTR closure_env = (LispPTR) 0xffffffff; \ + {register int NEXTBLOCK = NIL; \ + defcell = fn_defcell; \ + if( (defcell->ccodep == 0) ) \ + if(GetTypeNumber(defcell->defpointer)==TYPE_COMPILED_CLOSURE) \ + { /* setup closure */ \ + closure=(CClosure *)Addr68k_from_LADDR(defcell->defpointer);\ + defcell=(DefCell *)closure; \ + /* not a closure if closure's env is NIL */ \ + if(closure->env_ptr ) \ + {closure_env = (LispPTR) (closure->env_ptr); \ + } \ + } /* if end */ \ + else { \ + /* NOT compiled object . We must use Interpreter*/ \ + defcell = (DefCell *)GetDEFCELL68k(ATOM_INTERPRETER); \ + needpush = 1; \ + } /*else end */ \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(defcell->defpointer); \ + BCE_CURRENTFX->pc = ((unsigned int)PCMAC \ + - (unsigned int)FuncObj) + fn_opcode_size; \ + FNTPRINT(("Saving PC = 0%o (0x%x).\n", \ + BCE_CURRENTFX->pc, PCMAC+fn_opcode_size)); \ + FN_CALL_NATIVE_CHECK2(LOCFNCELL, -fn_num_args, N_APPLY_POP_PUSH_TEST) \ + FN_STACK_CHECK; \ + APPLY_POP_PUSH_TEST; \ + {register int newivar; \ + newivar = (int)(IVARL = (DLword *) (CSTKPTR+(1-fn_num_args-needpush))); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + HARD_PUSH(TOPOFSTACK); /* save TOS */ \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = fn_num_args - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + } /* NEXTBLOCK BLOCK */ \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(defcell->defpointer);\ + CSTKPTRL = (LispPTR *) (((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + result = LOCFNCELL->pv; \ + HARD_PUSH(closure_env); \ + HARD_PUSH(unboundval); \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } /* result, unboundval block */ \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ + SWAPPED_FN_CHECK; /* see if callee needs swapping */ \ + CHECK_INTERRUPT; \ + nextop0; \ +} /* end OP_FN_COMMON */ + + + +/************************************************************************/ +/* */ +/* O P _ E N V C A L L */ +/* */ +/* Environment call on a code object. Takes an arg count on */ +/* the stack, along with a pointer to an environment. If non- */ +/* NIL, the environment is stuffed into the PVAR0 slot of the */ +/* frame. [This NIL check is in the UFN, and seems to be meant */ +/* to allow closures to be called without an environment, without */ +/* the compiler having to emit special code.] */ +/* */ +/************************************************************************/ + +#define OP_ENVCALL { \ + register struct fnhead *LOCFNCELL; \ + register int NEXTBLOCK; \ + register LispPTR closure_env = TOPOFSTACK; \ + register int num_args; \ + register LispPTR Fn_DefCell= GET_TOS_1; \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(Fn_DefCell); \ + FNTPRINT(("ENVCall.\n")); \ + FNCHECKER(if (quick_stack_check()) printf("In ENVCALL.\n")); \ + N_GETNUMBER(GET_TOS_2, num_args, op_ufn); \ + BCE_CURRENTFX->pc = ((unsigned int)PCMAC - (unsigned int)FuncObj) + 1;\ + FN_CALL_NATIVE_CHECK2(LOCFNCELL, -num_args, N_ENVCALL_POP_TEST); \ + FN_STACK_CHECK; \ + CSTKPTRL -= 2; \ + {register int newivar; \ + newivar = (int) (IVARL = (DLword *) (CSTKPTR-num_args)); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = num_args - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(Fn_DefCell); \ + CSTKPTRL = (LispPTR *)(((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + result = LOCFNCELL->pv; \ + if (result >= 0) \ + {register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + if (closure_env == NIL_PTR) HARD_PUSH(unboundval); \ + else HARD_PUSH(closure_env); \ + HARD_PUSH(unboundval); \ + if (result > 0) \ + {HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + result-=1; \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } \ + } \ + } \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ + SWAPPED_FN_CHECK; \ +} /* end OP_ENVCALL */ + + + /***************************/ + /* */ + /* Check a code block to make sure, on a byte-swapped */ + /* machine, that the code stream has been put back */ + /* in "natural order" for faster fetching. */ + /* (Only in on ISC, now. */ + /********************************************************/ +#ifdef RESWAPPEDCODESTREAM +#define SWAPPED_FN_CHECK \ + if (!FuncObj->byteswapped) { byte_swap_code_block(FuncObj); FuncObj->byteswapped = 1;} +#else +#define SWAPPED_FN_CHECK +#endif /* RESWAPPEDCODESTREAM */ + + + + +/****************************************************************/ +/****** EVAL ********/ +/****************************************************************/ +#ifndef BIGATOMS +#define EVAL \ + { \ + LispPTR scratch; \ + register LispPTR work; \ + register LispPTR lookuped; /* keep looked up value */ \ + \ + switch(TOPOFSTACK & SEGMASK) \ + { \ + case S_POSITIVE: \ + case S_NEGATIVE: nextop1; \ + \ + case ATOMS_OFFSET: if( (TOPOFSTACK==NIL_PTR) \ + ||(TOPOFSTACK==ATOM_T)) \ + goto Hack_Label; \ + nnewframe(CURRENTFX,&scratch, \ + TOPOFSTACK & 0xffff); \ + work = ((scratch & 0xffff0000)>> 16) | \ + ((scratch & 0x00ff) <<16); \ + lookuped = *((LispPTR *) \ + (Addr68k_from_LADDR(work))); \ + if(lookuped==NOBIND_PTR) goto op_ufn; \ + TOPOFSTACK = lookuped; \ + Hack_Label: nextop1; \ + \ + default: switch(GetTypeNumber(TOPOFSTACK)) \ + { \ + case TYPE_FIXP : \ + case TYPE_FLOATP : \ + case TYPE_STRINGP : \ + case TYPE_ONED_ARRAY : \ + case TYPE_GENERAL_ARRAY : nextop1; \ + \ + case TYPE_LISTP : \ + fn_atom_index = ATOM_EVALFORM; \ + fn_num_args = 1; \ + fn_opcode_size = 1; \ + fn_defcell = (DefCell *) \ + GetDEFCELL68k(ATOM_EVALFORM); \ + fn_apply = 0; \ + goto op_fn_common; \ + \ + default : goto op_ufn; \ + } \ + \ + } /* end switch */ \ + \ +}/* EVAL end */ + +#else + +#define EVAL \ + { \ + LispPTR scratch; \ + register LispPTR work; \ + register LispPTR lookuped; /* keep looked up value */ \ + \ + switch(TOPOFSTACK & SEGMASK) \ + { \ + case S_POSITIVE: \ + case S_NEGATIVE: nextop1; \ + \ + case ATOMS_OFFSET: if( (TOPOFSTACK==NIL_PTR) \ + ||(TOPOFSTACK==ATOM_T)) \ + goto Hack_Label; \ + nnewframe(CURRENTFX,&scratch, \ + TOPOFSTACK & 0xffff); \ + work = ((scratch & 0xffff0000)>> 16) | \ + ((scratch & 0x0fff) <<16); \ + lookuped = *((LispPTR *) \ + (Addr68k_from_LADDR(work))); \ + if(lookuped==NOBIND_PTR) goto op_ufn; \ + TOPOFSTACK = lookuped; \ + Hack_Label: nextop1; \ + \ + default: switch(GetTypeNumber(TOPOFSTACK)) \ + { \ + case TYPE_FIXP : \ + case TYPE_FLOATP : \ + case TYPE_STRINGP : \ + case TYPE_ONED_ARRAY : \ + case TYPE_GENERAL_ARRAY : nextop1; \ + \ + case TYPE_LISTP : \ + fn_atom_index = ATOM_EVALFORM; \ + fn_num_args = 1; \ + fn_opcode_size = 1; \ + fn_defcell = (DefCell *) \ + GetDEFCELL68k(ATOM_EVALFORM); \ + fn_apply = 0; \ + goto op_fn_common; \ + \ + case TYPE_NEWATOM: \ + nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \ + work = POINTERMASK & SWAP_WORDS(scratch); \ + lookuped = *((LispPTR *) \ + (Addr68k_from_LADDR(work))); \ + if(lookuped==NOBIND_PTR) goto op_ufn; \ + TOPOFSTACK = lookuped; \ + nextop1; \ + default : goto op_ufn; \ + } \ + \ + } /* end switch */ \ + \ +}/* EVAL end */ +#endif /* BIGATOMS */ + diff --git a/inc/lnk-tosret.h b/inc/lnk-tosret.h new file mode 100755 index 0000000..2830198 --- /dev/null +++ b/inc/lnk-tosret.h @@ -0,0 +1,90 @@ +/* $Id: lnk-tosret.h,v 1.2 1999/01/03 02:06:12 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1992 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* t o s r e t m a c r o . h */ +/* */ +/* Implements RETURN for the inner evaluation loop. There are */ +/* two versions--one for when hand optimization has been done, */ +/* and one for the naive case. To use the hand-optimization */ +/* version, you'll need to define an inline function or macro */ +/* called opreturn(). It must fall thru if alink is odd, but */ +/* must handle all other cases. You can rely on check_interrupt */ +/* being a defined label. */ +/* */ +/************************************************************************/ + +#ifdef NATIVETRAN +#define RETD6 SaveD6 = 0x100 +#define RET_CHECK_NATIVE(x) if(x ->native) { RET_TO_NATIVE; } +#else +#define RETD6 +#define RET_CHECK_NATIVE(x) +#endif + + +#if ((defined(ISC) || defined(SUN3_OS3_OR_OS4_IL)) && !(defined(NOASMFNCALL)) ) + +#define OPRETURN \ +{ opreturn(); \ + EXT; if(slowreturn()) goto stackoverflow_help; RET; \ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,FuncObj); \ + if (((int)(CSTKPTR) > Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + { RETD6; goto check_interrupt; } \ + Irq_Stk_End = (int) EndSTKP; \ + RET_CHECK_NATIVE(BCE_CURRENTFX); \ + } + +#else + +#define OPRETURN { \ + register struct frameex2 *returnFX ; \ + register int alink; \ + alink = ((struct frameex2 *) BCE_CURRENTFX)->alink; \ + FNTPRINT(("RETURN = 0x%x, ", TOPOFSTACK)); \ + FNTRACER(prindatum(TOPOFSTACK); printf("\n"); fflush(stdout);) \ + if (alink & 1) { EXT; if(slowreturn()) goto stackoverflow_help; RET; \ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,FuncObj); \ + if (((int)(CSTKPTR) > Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + { RETD6; goto check_interrupt; } \ + Irq_Stk_End = (int) EndSTKP; \ + RET_CHECK_NATIVE(BCE_CURRENTFX); \ + goto retxit; \ + }; \ + CSTKPTRL = (LispPTR *) IVAR; \ + returnFX = (struct frameex2 *) \ + ((DLword *) \ + (PVARL = (DLword *) Addr68k_from_StkOffset(alink)) \ + - FRAMESIZE); \ + IVARL = (DLword *) \ + Addr68k_from_StkOffset(GETWORD((DLword *)returnFX -1)); \ + /* Get PC from Retunee's pc slot in FX */ \ + PCMACL = returnFX->pc + (ByteCode *) \ + (FuncObj = (struct fnhead *) \ + Addr68k_from_LADDR(SWAP_FNHEAD(returnFX->fnheader) & POINTERMASK)) + 1;\ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,FuncObj); \ + FNCHECKER(if (quick_stack_check()) printf("In RETURN.\n")); \ + if (((int)(CSTKPTR) > Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + { RETD6; goto check_interrupt; } \ + Irq_Stk_End = (int) EndSTKP; \ + RET_CHECK_NATIVE(returnFX); \ +retxit: {} \ +} /* OPRETURN end */ + +#endif diff --git a/inc/lnk-version.h b/inc/lnk-version.h new file mode 100755 index 0000000..98613d6 --- /dev/null +++ b/inc/lnk-version.h @@ -0,0 +1,99 @@ +/* $Id: lnk-version.h,v 1.2 1999/01/03 02:06:12 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* V E R S I O N . H */ +/* */ +/* Version control: Set the two values that keep sysouts and emul- */ +/* ators in sync: The LVERSION and MINBVERSION fields in the IFPAGE */ +/* */ +/* MINBVERSION is the current emulator version, incremented with each */ +/* modification. This must be >= a sysout's ifpage.minbversion. */ +/* */ +/* LVERSION is the minimum lisp version that will run with this emu- */ +/* lator. This must be <= a sysouts's ifpage.lversion. */ +/* */ +/* The loadup process sets both of these values in the sysout. */ +/* */ +/* */ +/* */ +/* C O N F I G U R A T I O N / O P T I O N C O N T R O L */ +/* */ +/* Given a release specification, set flags for the features */ +/* that release has. This lets us set one flag in the make- */ +/* file, rather than remembering all the options that must change. */ +/* */ +/* -DRELEASE=115 Medley 1.15, small atoms */ +/* -DRELEASE=200 Medley 2.0 as released */ +/* -DRELEASE=201 Medley with DOS & European kbd support */ +/* -DRELEASE=210 Medley with big VM */ +/* -DRELEASE=300 Medley bigvm as released. */ +/* */ +/* */ +/************************************************************************/ + + + /* The current values */ + +#define LVERSION 21000 +#define MINBVERSION 21001 + + + /* But remember old values, if we can figure them out from ifdef's */ + +#if (RELEASE == 115) + +#undef LVERSION +#undef MINBVERSION +#define LVERSION 15000 +#define MINBVERSION 15000 +#undef BIGATOMS +#define NOEUROKBD +#define NOFORN +#define NOVERSION + +#elif (RELEASE == 200) + + /* Medley 2.0 as released */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 20000 +#define MINBVERSION 20000 + +#define BIGATOMS +#define NOEUROKBD +#define NOVERSION + +#elif (RELEASE == 201 ) + + + /* Medley 2.0 with EUROKBD modification */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 20100 +#define MINBVERSION 20100 + +#define BIGATOMS +#undef NOEUROKBD +#define NOVERSION + +#elif (RELEASE == 210) + + /* Medley 2.1, big-vm Medley while in beta-test */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 21000 +#define MINBVERSION 21000 + +#define BIGATOMS +#define BIGVM +#define NEWCDRCODING + + +# elif (RELEASE == 300 ) + + +#endif + + diff --git a/inc/locfile.h b/inc/locfile.h new file mode 100755 index 0000000..fc3a0d2 --- /dev/null +++ b/inc/locfile.h @@ -0,0 +1,707 @@ +/* $Id: locfile.h,v 1.2 1999/01/03 02:06:13 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#define PAGE_SIZE 512 /* 1 page == 512 byte */ + +#define RECOG_OLD S_POSITIVE | 0 +#define RECOG_OLDEST S_POSITIVE | 1 +#define RECOG_NEW S_POSITIVE | 2 +#define RECOG_OLD_NEW S_POSITIVE | 3 +#define RECOG_NON S_POSITIVE | 5 + +#define ACCESS_INPUT S_POSITIVE | 0 +#define ACCESS_OUTPUT S_POSITIVE | 1 +#define ACCESS_BOTH S_POSITIVE | 2 +#define ACCESS_APPEND S_POSITIVE | 3 + +/* For getfileinfo */ +#define LENGTH S_POSITIVE | 1 +#define WDATE S_POSITIVE | 2 +#define RDATE S_POSITIVE | 3 +#define AUTHOR S_POSITIVE | 5 +#define PROTECTION S_POSITIVE | 6 +#define EOL S_POSITIVE | 7 +#define ALL S_POSITIVE | 8 + + +extern DLword *Lisp_world; /* To access LispSysout area */ + + +#define ToLispTime(x) ((int)x + 29969152) + /* For getfileinfo. For WDATE&RDATE */ + /* 29969152 == (timer.c)LISP_UNIX_TIME_DIFF */ + /* - 61200 == - 17hours */ + +#define ToUnixTime(x) ((int)x - 29969152) + /* For getfileinfo. For WDATE&RDATE */ + /* 29969152 == (timer.c)LISP_UNIX_TIME_DIFF */ + +#define StrNCpyFromCToLisp(lispbuf, cbuf ,len) { register int i; \ + register char *sptr,*dptr; \ + for(i=0,sptr=(cbuf),dptr =(lispbuf);i<(len);i++)\ + GETBYTE(dptr++) = *sptr++; \ + } + +#define StrNCpyFromLispToC(cbuf , lispbuf, len) { register int i; \ + register char *sptr,*dptr; \ + for(i=0,sptr=(lispbuf),dptr =(cbuf);i<(len);i++)\ + *dptr++ = GETBYTE(sptr++); \ + } + +#define FGetNum(ptr, place) { \ + if(((ptr) & SEGMASK)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ + else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ + else {return(NIL);}} + + +/************************************************************************/ +/* */ +/* L i s p S t r i n g T o C S t r i n g */ +/* */ +/* Convert the Lisp string in Lisp into a null-terminated C */ +/* string in C. MaxLen is, for safety, the maximum length of */ +/* the resulting string, so the buffer doesn't overflow and */ +/* smash memory. */ +/* */ +/* WARNINGS: The Lisp string is truncated to fit the C string */ +/* without warning to the user. FAT Lisp strings have only */ +/* the low 8 bits of each character copied over. */ +/* */ +/************************************************************************/ +#ifndef BYTESWAP +#define LispStringToCString(Lisp, C, MaxLen) \ + { \ + OneDArray *arrayp; \ + char *base, *dp; \ + short *sbase; \ + int i, length; \ + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); \ + length = min(MaxLen, arrayp->fillpointer); \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + strncpy(C, base, length); \ + C[length] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0,dp=C;i<(length);i++) \ + *dp++ = (char)(*sbase++); \ + *dp = '\0'; \ + break; \ + default: \ + error("LispStringToCString: Not a character array.\n"); \ + } \ + } +#else /* BYTESWAP == T CHANGED-BY-TAKE */ +#define LispStringToCString(Lisp, C, MaxLen) \ + { \ + OneDArray *arrayp; \ + char *base, *dp; \ + short *sbase; \ + int i, length; \ + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); \ + length = min(MaxLen, arrayp->fillpointer); \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) \ + + ((int)(arrayp->offset)); \ + /*for(i=0,dp=C;ibase))) \ + + ((int)(arrayp->offset)); \ + for(i=0,dp=C;i<(length);i++,sbase++) \ + *dp++ = (char)(GETWORD(sbase)); \ + *dp = '\0'; \ + break; \ + default: \ + error("LispStringToCString: Not a character array.\n"); \ + } \ + } + +#endif /* BYTESWAP */ + + +/************************************************************************/ +/* */ +/* L i s p S t r i n g L e n g t h */ +/* */ +/* Get the byte length of the string in Lisp. */ +/* */ +/* As a side effect, sets FatP to 1 if LispString is fat, 0 otherwise */ +/* Errors if LispString isn't a string (1-d array of characters) */ +/* */ +/************************************************************************/ +#define LispStringLength(LispString, Length, FatP) \ + { \ + OneDArray *arrayp; \ + arrayp = (OneDArray *)(Addr68k_from_LADDR(LispString)); \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + Length = arrayp->fillpointer; \ + FatP = 0; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + Length = arrayp->fillpointer * 2; \ + FatP = 1; \ + break; \ + default: \ + error("LispStringLength: Not a character array.\n"); \ + } \ + } + + + + +/************************************************************************/ +/* */ +/* S T R I N G _ B A S E */ +/* */ +/* Return (C-pointer) to the characters in lstringp, in cstringp. */ +/* */ +/************************************************************************/ +#define STRING_BASE(lstringp, cstringp) \ + { \ + register LispPTR *naddress; \ + naddress = (LispPTR *)(Addr68k_from_LADDR(lstringp)); \ + cstringp = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); \ + } + +#ifndef min +#define min(a, b) ((a <= b)?a:b) +#endif /* min */ + +#define LispNumToCInt(Lisp) \ + ( ((Lisp & SEGMASK) == S_POSITIVE) ? \ + (Lisp & 0xFFFF) : (*((int *)(Addr68k_from_LADDR(Lisp)))) ); + +#define UPLOWDIFF 0x20 + +#define DOWNCASE(name){ \ + \ + register char *cp; \ + \ + for(cp = name; *cp!='\0'; ++cp) \ + if((*cp >= 'A') && (*cp <= 'Z')) *cp += UPLOWDIFF; \ +} + +#define UPCASE(name){ \ + \ + register char *cp; \ + \ + for(cp = name; *cp!='\0'; ++cp) \ + if((*cp >= 'a') && (*cp <= 'z')) *cp -= UPLOWDIFF; \ +} + +#define DIR_OR_FILE_P(name, type){ \ + register int result; \ + struct stat sbuf; \ + \ + TIMEOUT(result = stat(name, &sbuf)); \ + if (result < 0) { \ + *Lisp_errno = errno; \ + type = 0; \ + } else { \ + switch (sbuf.st_mode & S_IFMT) { \ + \ + case S_IFDIR: \ + type = -1; \ + break; \ + \ + case S_IFREG: \ + type = 1; \ + break; \ + \ + default: \ + /* \ + * Should we deal with the other \ + * types? \ + */ \ + type = 0; \ + break; \ + } \ + } \ +} + +#ifdef FSERROR +#define DIRP(path, dir, buf){ \ + int rval; \ + struct stat statbuf; \ + strcpy(buf, path); \ + strcat(buf, dir); \ + TIMEOUT( rval=stat(buf, &statbuf) ); \ + if( rval == 0){ \ + if( (statbuf.st_mode & S_IFMT) == S_IFDIR ){ \ + strcat(path, dir); \ + return(1); \ + } \ + } \ + if( rval == -1 && errno == 60){ \ + *Lisp_errno = 60; \ + return(0); \ + } \ + } +#else +#define DIRP(path, dir, buf){ \ + int rval; \ + struct stat statbuf; \ + strcpy(buf, path); \ + strcat(buf, dir); \ + TIMEOUT( rval=stat(buf, &statbuf) ); \ + if( rval == 0){ \ + if( (statbuf.st_mode & S_IFMT) == S_IFDIR ){ \ + strcat(path, dir); \ + return(1); \ + } \ + } \ + } +#endif + +#define FILEP(path, file, buf){ \ + int rval; \ + strcpy(buf, path); \ + strcat(buf, file); \ + TIMEOUT( rval=access(buf, F_OK) ); \ + if( access(buf, F_OK) == 0){ \ + strcat(path, file); \ + return(1); \ + } \ + } + +#define STREQ(name1, name2)( \ + (*name1 == *name2) && (strcmp(name1, name2) == 0) \ + ) + +#define SPECIALFILEMARK -1 + +#define NumericStringP(str, truetag, falsetag) { \ + register char *cp; \ + \ + if (*str == '\0') goto falsetag; \ + \ + for(cp = str; *cp!='\0'; ++cp) \ + if(*cp < '0' || '9' < *cp) \ + goto falsetag; \ + goto truetag; \ +} + +/* + * Name: LispVersionToUnixVersion + * + * Argument: char *pathname + * Xerox Lisp syntax pathname. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: The version part of pathname is destructively modified. + * + * Description: + * + * Destructively modify the version part of pathname which is following the + * Xerox Lisp file naming convention to UNIX one. + * If the file name which is passed from Lisp has the version part, it must be + * a valid one (i.e. construected with only number). This is guaranteed by Lisp + * code. + * This macro should be called at the top of the routines which accept the + * file name from lisp before converting it into UNIX file name, because + * locating the version part, the informations about quoted characters are needed. + * They might be lost in the course of the conversion. + * + */ +#ifdef DOS + +/* DOS version of LispVersionToUnixVersion */ +/* * * * * This is done this way because DOS can't handle the non-DOS version -- */ +/* * * * * it gived "Too many characters in a character constant" errors! */ +#include "lispver1.h" +#else /* DOS */ +/* NON-DOS version of the macro LispVersionToUnixVersion */ +#include "lispver2.h" +#endif /* DOS */ + + +/* + * Name: UnixVersionToLispVersion + * + * Argument: char *pathname + * UNIX syntax pathname. + * int vlessp + * If 0, versionless file is converted to version 1. + * Otherwise, remains as versionless. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: The version part of pathname is destructively modified. + * + * Description: + * + * Destructively modify the version part of pathname which is following the + * UNIX file naming convention to Xerox Lisp one. + * This macro should be called, in the routines which convert the UNIX pathname + * to Lisp one, just before it returns the result to Lisp, because converting + * version field will append a semicolon and it might make the routine be + * confused. + * The file which has not a valid version field, that is ".~##~" form, is + * dealt with as version 1. + */ + +#define UnixVersionToLispVersion(pathname, vlessp){ \ + \ + register char *start; \ + register char *end; \ + register char *cp; \ + register int len, ver_no; \ + char ver_buf[VERSIONLEN]; \ + \ + if ((start = strchr(pathname, '~')) != NULL) { \ + /* First of all, find the version field in pathname. */ \ + end = start; \ + cp = start + 1; \ + while (*cp) { \ + if (*cp == '~') { \ + start = end; \ + end = cp; \ + cp++; \ + } else { \ + cp++; \ + } \ + } \ + \ + if (start != end && *(start - 1) == '.' && end == (cp - 1)) { \ + /* \ + * pathname ends in the form ".~###~". But we \ + * check ### is a valid number or not. \ + */ \ + len = (int)end - (int)start - 1; \ + strncpy(ver_buf, start + 1, len); \ + ver_buf[len] = '\0'; \ + NumericStringP(ver_buf, YES, NO); \ + YES: \ + *(start - 1) = ';'; \ + *start = '\0'; \ + *end = '\0'; \ + /* call ato i to eliminate leading 0s. */ \ + ver_no = atoi(start + 1); \ + sprintf(ver_buf, "%d", ver_no); \ + strcat(pathname, ver_buf); \ + goto CONT; \ + \ + NO: \ + /* Dealt with as version 1 unless vlessp */ \ + if (!vlessp) strcat(pathname, ";1"); \ + CONT: \ + cp--; /* Just for label */ \ + } else { \ + /* Dealt with as version 1 unless vlessp. */ \ + if (!vlessp) strcat(pathname, ";1"); \ + } \ + } else { \ + /* Dealt with as version 1 unless vlessp. */ \ + if (!vlessp) strcat(pathname, ";1"); \ + } \ +} + +/* + * Name: ConcDirAndName + * + * Argument: char *dir The name of the directory. + * char *name The name of a file. + * char *fname The place where the full file name should be + * stored. + * Value: N/A + * + * Side Effect: fname is replaced with the full file name. + * + * Description: + * + * Concatenate the directory name and root file name. Checks if dir contains + * the trail directory delimiter or not. + * + */ + +#define ConcDirAndName(dir, name, fname){ \ + \ + register char *cp1, *cp2; \ + \ + cp1 = dir; \ + cp2 = dir; \ + \ + while (*cp2 != '\0') { \ + switch (*cp2) { \ + \ + case '/': \ + cp1 = cp2; \ + cp2++; \ + break; \ + \ + default: \ + cp2++; \ + break; \ + } \ + } \ + if (cp1 == (cp2 - 1)) { \ + if (cp1 == dir) { \ + /* dir is a root directory. */ \ + strcpy(fname, "/"); \ + strcat(fname, name); \ + } else { \ + /* The trail directory is included. */ \ + strcpy(fname, dir); \ + strcat(fname, name); \ + } \ + } else { \ + /* The trail directory is not included */ \ + strcpy(fname, dir); \ + strcat(fname, "/"); \ + strcat(fname, name); \ + } \ +} + +/* + * Name: ConcNameAndVersion + * + * Argument: char *name The root file name. + * char *ver The file version. + * char *rname The place where the concatenated file name will be + * stored. + * Value: N/A + * + * Side Effect: rname is replaced with the concatenated file name. + * + * Description: + * + * Concatenate the root file name and its version in UNIX format. + * + */ + +#define ConcNameAndVersion(name, ver, rname){ \ + if (*ver != '\0') { \ + strcpy(rname, name); \ + strcat(rname, ".~"); \ + strcat(rname, ver); \ + strcat(rname, "~"); \ + } else { \ + strcpy(rname, name); \ + } \ +} + +#define VERSIONLEN 16 + +#define MAXVERSION 999999999 + +#define LASTVERSIONARRAY 0xFFFFFFFF +#define VERSIONARRAYLENGTH 200 + +#define NoFileP(varray) \ + ((varray->version_no == LASTVERSIONARRAY)? 1 : 0) + + +#ifdef DOS +#define OnlyVersionlessP(varray) 0 +#else +#define OnlyVersionlessP(varray) \ + ((varray->version_no == 0 && (varray + 1)->version_no == LASTVERSIONARRAY) ? \ + 1 : 0) +#endif /* DOS */ + +/* An argument of AddDodNoExtention must be LispVersion convention */ +/* Like "foo/fee.fee;3" or "/foo/foo;3" */ +/* AddDodNoExtention must be put after UnixVersionToLispVersion */ + +#define AddDodNoExtention(file){ \ + register char *cp; \ + register char *cp1; \ + if( (strrchr(file,'.')== 0) && ((cp=strrchr(file,';'))!=0) ){ \ + for(cp1=cp;*cp1!='\0';cp1++); \ + *(cp1+1) = '\0'; \ + for(;cp!=cp1;cp1--) \ + *cp1 = *(cp1-1); \ + *cp = '.'; \ + } \ + } + +/* An argument of RemoveDodNoExtenstion must be LispVersion convention */ +/* Like "foo/fee.fee;3" or "/foo/foo.;3" */ +/* RemoveDodNoExtenstion must be put before LispVersionToUnixVersion */ + +#define RemoveDodNoExtenstion(file){ \ + register char *cp; \ + if( ((cp=strrchr(file, ';'))!=0) && (*(cp-1)=='.') ){ \ + for(;*cp!='\0';++cp) \ + *(cp-1) = *cp; \ + *(cp-1) = '\0'; \ + } \ + } + + +extern int errno; + +#define ChangeToVersionless(pathname){ \ + register char *cp; \ + if( (cp=strrchr(pathname, ';')) != 0) \ + *cp = '\0'; \ + } + + +#ifdef FSERROR +#define UNLINK(x){ \ + TIMEOUT(rval=unlink(x)); \ + if(rval == -1){ \ + err_mess("unlink", errno); \ + *Lisp_errno = errno; \ + return(0); \ + } \ + } +#else +#define UNLINK(x){ \ + TIMEOUT(rval=unlink(x)); \ + if(rval == -1){ \ + err_mess("unlink", errno); \ + return(0); \ + } \ + } +#endif + +#ifdef FSERROR +#define LINK(x,y){ \ + TIMEOUT(rval=link(x, y)); \ + if(rval == -1){ \ + if(errno == 2) \ + return(1); \ + else{ \ + err_mess("link", errno);\ + *Lisp_errno = errno; \ + return(0); \ + } \ + } \ + } +#else +#define LINK(x,y){ \ + TIMEOUT(rval=link(x, y)); \ + if(rval == -1){ \ + if(errno == 2) \ + return(1); \ + else{ \ + err_mess("link", errno);\ + return(0); \ + } \ + } \ + } +#endif + +#ifdef FSERROR +#define RENAME(x,y){ \ + TIMEOUT(rval=rename(x, y)); \ + if(rval == -1){ \ + switch(errno){ \ + case 2: \ + return(1); \ + case 18: \ + *Lisp_errno = errno; \ + return(0); \ + default: \ + err_mess("rename", errno);\ + *Lisp_errno = errno; \ + return(0); \ + } \ + } \ + } +#else +#define RENAME(x,y){ \ + TIMEOUT(rval=rename(x, y)); \ + if(rval == -1){ \ + switch(errno){ \ + case 2: \ + return(1); \ + default: \ + err_mess("rename", errno);\ + return(0); \ + } \ + } \ + } +#endif + +#ifdef FSERROR +#define STAT(x,y){ \ + TIMEOUT(rval=stat(x, y)); \ + if(rval != 0){ \ + err_mess("stat", errno); \ + *Lisp_errno = errno; \ + return(-1); \ + } \ + } +#else +#define STAT(x,y){ \ + TIMEOUT(rval=stat(x, y)); \ + if(rval != 0){ \ + err_mess("stat", errno); \ + return(-1); \ + } \ + } +#endif + +/* + * For file name length check + */ +#define FNAMETOOLONG 200 + +#define FileNameTooLong(val) { \ + *Lisp_errno = FNAMETOOLONG; \ + return((val)); \ +} + + + + + + + + + +/********************************************************/ +/* file-system-specific defns */ +/* */ +/* DIRSEP = OS-specific directory separator character. */ +/* UNIXDIRSEP = UNIX's " */ +/* DRIVESEP = OS-specific drive separator character. */ +/* (only used with DOS as of 3/93) */ +/********************************************************/ +#ifdef DOS +#define DIRSEP '\\' +#define DIRSEPSTR "\\" +#define DRIVESEP ':' +#define UNIXDIRSEP '/' +#define MAXNAMLEN _MAX_PATH +#else +#define DIRSEPSTR "/" +#define DIRSEP '/' +#define UNIXDIRSEP '/' +#endif + diff --git a/inc/lpdefs.h b/inc/lpdefs.h new file mode 100755 index 0000000..b9f4ae2 --- /dev/null +++ b/inc/lpdefs.h @@ -0,0 +1,195 @@ +/* $Id: lpdefs.h,v 1.2 1999/01/03 02:06:13 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include +#include +#include +#ifndef OS4 +#include +#else +#include +#endif /* OS4 */ +#include +#include + + +#define HASHSIZE 10007 /* prime number is better, MB */ +#define ETA_START_SIZE 10000 /* start size of array Eta. Realloced if needed */ +#define FNAMLEN 64 +#define NAMELEN 25 +#define MAXSTRL (NAMELEN-1) +#define STD_ROW_NAME_PREFIX "r_" + +#define FALSE 0 +#define TRUE 1 + +#define LE 0 +#define EQ 1 +#define GE 2 +#define OF 3 + +#define OPTIMAL 0 +#define MILP_FAIL 1 +#define INFEASIBLE 2 +#define UNBOUNDED 3 +#define TIMEOUT 4 +#define INT_SOLN 5 + +#define my_abs(x) ((x) < 0 ? -(x) : (x)) +#define my_min(x, y) ((x) < (y) ? (x) : (y)) +#define my_max(x, y) ((x) > (y) ? (x) : (y)) + +#define CALLOC(ptr, nr, type) if(!(ptr = calloc((size_t)(nr),\ + sizeof(type)))) { fprintf(stderr, "calloc failed\n"); ERROR(ERR_NOMEM); } + +#define MALLOC(ptr, nr, type) if(!(ptr = malloc((size_t)((nr) * \ + sizeof(type))))) { fprintf(stderr, "malloc failed\n"); ERROR(ERR_NOMEM); } + +#define DEFAULT_INFINITE 1.0e24 /* limit for dynamic range */ +#define DEFAULT_EPSB 0.0001 /* for rounding RHS values to 0 */ +#define DEFAULT_EPSEL 1.0e-8 /* for rounding other values to 0 */ +#define DEFAULT_EPSD 0.0001 /* ?? MB */ +#define DEFAULT_EPSILON 1e-6 /* to determine if a float value is integer */ + +#define INVITER 50 /* number of iterations between inversions */ + +#ifndef REAL /* to allow -DREAL= while compiling */ +#define REAL double +#endif + +typedef char nstring[NAMELEN]; + +typedef struct _column +{ + int row; + float value; + struct _column *next ; +} column; + +typedef struct _constraint_name +{ + char name[NAMELEN]; + int row; + struct _constraint_name *next; +} constraint_name; + +typedef struct _bound +{ + REAL upbo; + REAL lowbo; +} bound; + +typedef struct _hashelem +{ + nstring colname; + struct _hashelem *next; + struct _column *col; + struct _bound *bnd; + int must_be_int; +} hashelem; + +typedef struct _rside /* contains relational operator and rhs value */ +{ + REAL value; + struct _rside *next; + short relat; +} rside; + +/* structure or final data-storage */ + +typedef struct _matrec +{ + int rownr; + REAL value; +} matrec; + +typedef struct _lispmr + { + int rownr; + float value; + } lispmr; + + + +typedef struct _tmp_store_struct +{ + nstring name; + int row; + REAL value; + REAL rhs_value; + short relat; +} tmp_store_struct; + +typedef struct _intrec +{ + int varnr; + struct _intrec *next; +} +intrec; + + +/************************************************************************/ +/* */ +/* S T A T E - S A V I N G F O R T I M E - O U T S */ +/* */ +/* */ +/* */ +/************************************************************************/ + +typedef struct solve_state + { + int saved; /* 0 = not used, else states below */ + int notint; /* variable # of the non-integer var chosen */ + int bound; /* integer lower bound for variable notint */ + int res1, res2; + struct solve_state *next; /* The next state holder in the chain */ + } sstate; + +#define ST_LO 1 /* We got to before calling solve on the lower bound side */ +#define ST_HI 2 /* We got to before calling solve on the upper bound side */ +#define ST_SOLN 3 /* We got past calling solve, not to analyzing */ + + + +/*************************************************************************/ +/* */ +/* E R R O R H A N D L I N G F O R L I B R A R Y */ +/* */ +/* */ +/* */ +/* */ +/* */ +/*************************************************************************/ + +#define ERROR(x) longjmp(LP_jmpbuf,256|x) + +#define ERR_NOMEM 0x10 /* Any out-of-memory problem */ +#define ERR_ST 0x11 /* ran out allocating State-infos */ + +#define ERR_NUM 0x20 /* Any numeric stability problem */ + +#define ERR_BUG 0x40 /* Any lp_solve-bug exit */ +#define ERR_BUG_CONDCOL 0x41 /* Condensecol out-of-bounds */ + + + + + + + + diff --git a/inc/lpglob.h b/inc/lpglob.h new file mode 100755 index 0000000..c3599fc --- /dev/null +++ b/inc/lpglob.h @@ -0,0 +1,79 @@ +/* $Id: lpglob.h,v 1.2 1999/01/03 02:06:13 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* Globals */ +extern lprec *Lp; /* extern pointer to active problem */ +extern int Rows; +extern int Columns; +extern int Sum; +extern int Non_zeros; +extern int Level; +extern matrec *Mat; +extern int *Col_no; +extern int *Col_end; +extern int *Row_end; +extern REAL *Orig_rh; +extern REAL *Rh; +extern REAL *Rhs; +extern short *Must_be_int; +extern REAL *Orig_upbo; +extern REAL *Orig_lowbo; +extern REAL *Upbo; +extern REAL *Lowbo; +extern int *Bas; +extern short *Basis; +extern short *Lower; +extern int Eta_alloc; +extern int Eta_size; +extern int Num_inv; +extern REAL *Eta_value; +extern int *Eta_row_nr; +extern int *Eta_col_end; +extern REAL *Solution; +extern REAL *Best_solution; +extern REAL Infinite; +extern REAL Epsilon; +extern REAL Epsb; +extern REAL Epsd; +extern REAL Epsel; + +extern REAL TREJ; +extern REAL TINV; + +extern short Maximise; +extern short Floor_first; +extern REAL Extrad; + +extern int Warn_count; + +extern short just_inverted; +extern short status; +extern short do_iter; +extern short do_invert; + + +/* Globals for parser */ +extern FILE *yyin; +extern FILE *lpfilename; +extern short Molve_dual; +extern short Maximise; +extern short *relat; +extern int Verbose; +extern int yylineno; +extern int yyleng; +extern int Lin_term_count; +extern int Sign; +extern constraint_name *First_constraint_name; +/* I hate #ifdefs, but there seems to be no "standard" way to do this */ +#if defined(__hpux) || defined(__apollo) || defined(_AIX) +/* for HP and Apollo (and possibly others) */ +extern unsigned char yytext[]; +#else +/* For other computers */ +extern char yytext[]; +#endif + +extern hashelem *Hash_tab[]; +extern rside *First_rside; +extern short Ignore_decl; + +extern tmp_store_struct tmp_store; diff --git a/inc/lpglobl.h b/inc/lpglobl.h new file mode 100755 index 0000000..bf2ee1e --- /dev/null +++ b/inc/lpglobl.h @@ -0,0 +1,82 @@ +/* $Id: lpglobl.h,v 1.2 1999/01/03 02:06:14 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* function declarations */ +#include "lpproto.h" + +/* global variables */ +extern int Rows, Columns, Nonnuls, Sum; +extern double Extrad; +extern double *Pcol; /* [Rows+1] */ +extern nstring Probname; +extern int Totnum, Classnr, Linenr; +extern short Bounds, Ranges, Verbose, Debug, Show_results, Print_duals; +extern unsigned Cur_eta_size; +extern double *Eta_value; +extern int *Eta_rownr; +extern constraint_name *First_constraint_name; + +extern matrec *Mat; +extern double *Upbo, *Lowbo; +extern nstring *Names; +extern int *Cend; +extern double *Rh; +extern short *Relat; + +extern short *Chsign; +extern int *Endetacol; +extern int *Rend, *Bas; +extern double *Rhs; +extern int *Colno; +extern short *Basis, *Lower; +extern short Maximise; + +extern double *Solution, *Best_solution, *Orig_rh, *Orig_upbo, *Orig_lowbo; +extern short *Must_be_int; +extern short Having_ints; +extern matrec *Orig_mat; +extern int Level; +extern short Floorfirst; + +extern intrec *First_int; + + /* external variables for yy_trans and the yacc parser */ +extern int yylineno; +extern int yyleng; +extern int Lin_term_count; +extern int Sign; + + +/* I hate #ifdefs, but there seems to be no "standard" way to do this */ +#if defined(__hpux) || defined(__apollo) +/* for HP and Apollo (and possibly others) */ +extern unsigned char yytext[]; +#else +/* For other computers */ +extern char yytext[]; +#endif + +/*extern hashelem *Hash_tab[HASH_SIZE];*/ +extern rside *First_rside; +extern short Ignore_decl; + +extern tmp_store_struct tmp_store; + +extern int SolveCount; +extern jmp_buf LP_jmpbuf; + + diff --git a/inc/lpkit.h b/inc/lpkit.h new file mode 100755 index 0000000..ab989c5 --- /dev/null +++ b/inc/lpkit.h @@ -0,0 +1,537 @@ +/* $Id: lpkit.h,v 1.2 1999/01/03 02:06:14 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* + Main header file of the LP_SOLVE toolkit. + + By Jeroen Dirks, 21-2-95 + + include this file in your program and link with liblps.a +*/ + +#include +#include +#include +#define FAIL -1 + +#define NULL 0 +#define FALSE 0 +#define TRUE 1 + +#define DEFNUMINV 50 + +/* solve status values */ +#define OPTIMAL 0 +#define MILP_FAIL 1 +#define INFEASIBLE 2 +#define UNBOUNDED 3 +#define FAILURE 4 +#define RUNNING 5 +#define INT_SOLN 6 +#define TIMEOUT 7 + +/* lag_solve extra status values */ +#define FEAS_FOUND 6 +#define NO_FEAS_FOUND 7 +#define BREAK_BB 8 + +#define FIRST_NI 0 +#define RAND_NI 1 + +#define LE 0 +#define EQ 1 +#define GE 2 +#define OF 3 + +#define my_abs(x) ((x) < 0 ? -(x) : (x)) +#define my_min(x, y) ((x) < (y) ? (x) : (y)) +#define my_max(x, y) ((x) > (y) ? (x) : (y)) + +#define MAX_WARN_COUNT 20 + +#ifdef CHECK +#define my_round(val, eps) { \ + REAL absv; \ + absv = ((val) < 0 ? -(val) : (val)); \ + if(absv < (eps)) \ + val = 0; \ + if(Warn_count < MAX_WARN_COUNT) \ + { \ + if(absv > 0.5 * (eps) && absv < 2 * (eps)) \ + { \ + Warn_count++; \ + fprintf(stderr, \ + "Warning Value close to epsilon V: %e E: %e\n", \ + (double)absv, (double)(eps)); \ + if(Warn_count == MAX_WARN_COUNT) \ + { \ + fprintf(stderr, \ + "*** Surpressing further rounding warnings\n"); \ + } \ + } \ + } \ +} + +#else +#define my_round(val,eps) { \ + if (((val) < 0 ? -(val) : (val)) < (eps)) \ + val = 0; \ +} +#endif + + + +#define debug_print(x,y,z,w,e,r,t,q) +#define debug_print_bounds(x,y) +#define debug_print_solution() + + + +#define DEF_INFINITE 1e24 /* limit for dynamic range */ +#define DEF_EPSB 5.01e-7 /* for rounding RHS values to 0 determine + infeasibility basis */ +#define DEF_EPSEL 1e-8 /* for rounding other values (vectors) to 0 */ +#define DEF_EPSD 1e-6 /* for rounding reduced costs to zero */ +#define DEF_EPSILON 1e-3 /* to determine if a float value is integer */ + +#define PREJ 1e-3 /* pivot reject (try others first) */ + +#ifndef REAL /* to allow -DREAL= while compiling */ +#define REAL double +#endif + +#define HASHSIZE 10007 /* prime number is better, MB */ +#define ETA_START_SIZE 10000 /* start size of array Eta. Realloced if needed */ +#define FNAMLEN 64 +#define NAMELEN 25 +#define MAXSTRL (NAMELEN-1) +#define STD_ROW_NAME_PREFIX "r_" + +#define CALLOC(ptr, nr, type) \ + if (!(ptr = (type *) calloc((size_t)(nr), sizeof(type)))) \ + { fprintf(stderr, "calloc failed on line %d of file %s\n", __LINE__, __FILE__); \ + ERROR(ERR_NOMEM); } + +#define MALLOC(ptr, nr, type) if(!(ptr = (type *) malloc((size_t)((nr) * sizeof(type))))) { fprintf(stderr, "malloc failed on line %d of file %s\n", __LINE__, __FILE__); ERROR(ERR_NOMEM); } + +#define REALLOC(ptr, nr, type) if(!(ptr = (type *) realloc(ptr,(size_t)(nr)*sizeof(type)))) { fprintf(stderr, "realloc failed on line %d of file %s\n", __LINE__, __FILE__); ERROR(ERR_NOMEM); } + +#define MALLOCCPY(nptr,optr,nr,type) {MALLOC(nptr, nr, type); memcpy(nptr, optr, (size_t)((nr) * sizeof(type)));} + +#define MEMCPY(nptr,optr,nr,type) {memcpy(nptr,optr, (size_t)((nr) * sizeof(type)));} + +typedef char nstring[NAMELEN]; + +typedef struct _matrec +{ + int row_nr; + REAL value; +} matrec; + +typedef struct _lispmr +{ + int rownr; + float value; +} lispmr; + +typedef struct _column +{ + int row; + float value; + struct _column *next ; +} column; + +typedef struct _constraint_name +{ + char name[NAMELEN]; + int row; + struct _constraint_name *next; +} constraint_name; + +typedef struct _bound +{ + REAL upbo; + REAL lowbo; +} bound; + +typedef struct _tmp_store_struct +{ + nstring name; + int row; + REAL value; + REAL rhs_value; + short relat; +} tmp_store_struct; + +typedef struct _hashelem +{ + nstring colname; + struct _hashelem *next; + struct _column *col; + struct _bound *bnd; + int must_be_int; +} hashelem; + +typedef struct _rside /* contains relational operator and rhs value */ +{ + REAL value; + struct _rside *next; + short relat; +} rside; + + +/************************************************************************/ +/* */ +/* S T A T E - S A V I N G F O R T I M E - O U T S */ +/* */ +/* */ +/* */ +/************************************************************************/ + +typedef struct solve_state + { + int saved; /* 0 = not used, else states below */ + int notint; /* variable # of the non-integer var chosen */ + int bound; /* integer lower bound for variable notint */ + int res1, res2; + struct solve_state *next; /* The next state holder in the chain */ + } sstate; + +#define ST_LO 1 /* We got to before calling solve on the lower bound side */ +#define ST_HI 2 /* We got to before calling solve on the upper bound side */ +#define ST_SOLN 3 /* We got past calling solve, not to analyzing */ + + + + +/* fields indicated with ## may be modified directly */ +/* pointers will have there size in the comments */ + +typedef struct _lprec +{ + nstring lp_name; /* the name of the lp */ + + short active; /*TRUE if the globals point to this structure*/ + short verbose; /* ## Verbose flag */ + short print_duals; /* ## PrintDuals flag for PrintSolution */ + short print_sol; /* ## used in lp_solve */ + short debug; /* ## Print B&B information */ + short print_at_invert; /* ## Print information at every reinversion */ + short trace; /* ## Print information on pivot selection */ + short anti_degen; /* ## Do perturbations */ + + int rows; /* Nr of constraint rows in the problem */ + int rows_alloc; /* The allocated memory for Rows sized data */ + int columns; /* The number of columns (= variables) */ + int columns_alloc; + int sum; /* The size of the variables + the slacks */ + int sum_alloc; + + short names_used; /* Flag to indecate if names for rows and + columns are used */ + nstring *row_name; /* rows_alloc+1 */ + nstring *col_name; /* columns_alloc+1 */ + + /* Row[0] of the sparce matrix is the objective function */ + + int non_zeros; /* The number of elements in the sparce matrix*/ + int mat_alloc; /* The allocated size for matrix sized + structures */ + matrec *mat; /* mat_alloc :The sparse matrix */ + int *col_end; /* columns_alloc+1 :Cend[i] is the index of the + first element after column i. + column[i] is stored in elements + col_end[i-1] to col_end[i]-1 */ + int *col_no; /* mat_alloc :From Row 1 on, col_no contains the + column nr. of the + nonzero elements, row by row */ + short row_end_valid; /* true if row_end & col_no are valid */ + int *row_end; /* rows_alloc+1 :row_end[i] is the index of the + first element in Colno after row i */ + REAL *orig_rh; /* rows_alloc+1 :The RHS after scaling & sign + changing, but before `Bound transformation' */ + REAL *rh; /* rows_alloc+1 :As orig_rh, but after Bound + transformation */ + REAL *rhs; /* rows_alloc+1 :The RHS of the curent simplex + tableau */ + short *must_be_int; /* sum_alloc+1 :TRUE if variable must be + Integer */ + REAL *orig_upbo; /* sum_alloc+1 :Bound before transformations */ + REAL *orig_lowbo; /* " " */ + REAL *upbo; /* " " :Upper bound after transformation + & B&B work*/ + REAL *lowbo; /* " " :Lower bound after transformation + & B&B work */ + + short basis_valid; /* TRUE is the basis is still valid */ + int *bas; /* rows_alloc+1 :The basis column list */ + short *basis; /* sum_alloc+1 : basis[i] is TRUE if the column + is in the basis */ + short *lower; /* " " :TRUE is the variable is at its + lower bound (or in the basis), it is FALSE + if the variable is at its upper bound */ + + short eta_valid; /* TRUE if current Eta structures are valid */ + int eta_alloc; /* The allocated memory for Eta */ + int eta_size; /* The number of Eta columns */ + int num_inv; /* The number of real pivots */ + int max_num_inv; /* ## The number of real pivots between + reinvertions */ + REAL *eta_value; /* eta_alloc :The Structure containing the + values of Eta */ + int *eta_row_nr; /* " " :The Structure containing the Row + indexes of Eta */ + int *eta_col_end; /* rows_alloc + MaxNumInv : eta_col_end[i] is + the start index of the next Eta column */ + + short bb_rule; /* what rule for selecting B&B variables */ + + short break_at_int; /* TRUE if stop at first integer better than + break_value */ + REAL break_value; + + REAL obj_bound; /* ## Objective function bound for speedup of + B&B */ + int iter; /* The number of iterations in the simplex + solver (LP) */ + int total_iter; /* The total number of iterations (B&B) (ILP)*/ + int max_level; /* The Deepest B&B level of the last solution */ + int total_nodes; /* total number of nodes processed in b&b */ + REAL *solution; /* sum_alloc+1 :The Solution of the last LP, + 0 = The Optimal Value, + 1..rows The Slacks, + rows+1..sum The Variables */ + REAL *best_solution; /* " " :The Best 'Integer' Solution */ + REAL *duals; /* rows_alloc+1 :The dual variables of the + last LP */ + + short maximise; /* TRUE if the goal is to maximise the + objective function */ + short floor_first; /* TRUE if B&B does floor bound first */ + short *ch_sign; /* rows_alloc+1 :TRUE if the Row in the matrix + has changed sign + (a`x > b, x>=0) is translated to + s + -a`x = -b with x>=0, s>=0) */ + + short scaling_used; /* TRUE if scaling is used */ + short columns_scaled; /* TRUE is the columns are scaled too, Only use + if all variables are non-integer */ + REAL *scale; /* sum_alloc+1 :0..Rows the scaling of the Rows, + Rows+1..Sum the scaling of the columns */ + + int nr_lagrange; /* Nr. of Langrangian relaxation constraints */ + REAL **lag_row; /* NumLagrange, columns+1:Pointer to pointer of + rows */ + REAL *lag_rhs; /* NumLagrange :Pointer to pointer of Rhs */ + REAL *lambda; /* NumLagrange :Lambda Values */ + short *lag_con_type; /* NumLagrange :TRUE if constraint type EQ */ + REAL lag_bound; /* the lagrangian lower bound */ + + short valid; /* Has this lp pased the 'test' */ + REAL infinite; /* ## numercal stuff */ + REAL epsilon; /* ## */ + REAL epsb; /* ## */ + REAL epsd; /* ## */ + REAL epsel; /* ## */ + sstate *solve_states; /* for time out */ +} lprec; + + + +/* function interface for the user */ + +lprec *make_lp(int rows, int columns); +/* create and initialise a lprec structure + defaults: + Empty (Rows * Columns) matrix, + Minimise the objective function + constraints all type <= + Upperbounds all Infinite + no integer variables + floor first in B&B + no scaling + default basis */ + +lprec *read_lp_file(FILE *input, short verbose, nstring lp_name); +/* create and read an .lp file from input (input must be open) */ + +void delete_lp(lprec *lp); +/* Remove problem from memory */ + +lprec *copy_lp(lprec *lp); +/* copy a lp structure */ + +void set_mat(lprec *lp, int row, int column, REAL value); +/* fill in element (Row,Column) of the matrix + Row in [0..Rows] and Column in [1..Columns] */ + +void set_obj_fn(lprec *lp, REAL *row); +/* set the objective function (Row 0) of the matrix */ +void str_set_obj_fn(lprec *lp, char *row); +/* The same, but with string input */ + +void add_constraint(lprec *lp, REAL *row, short constr_type, REAL rh); +/* Add a constraint to the problem, + row is the constraint row, + rh is the right hand side, + constr_type is the type of constraint (LE (<=), GE(>=), EQ(=)) */ +void str_add_constraint(lprec *lp, char *row_string ,short constr_type, REAL rh); +/* The same, but with string input */ + +void del_constraint(lprec *lp,int del_row); +/* Remove constrain nr del_row from the problem */ + +void add_lag_con(lprec *lp, REAL *row, short con_type, REAL rhs); +/* add a Lagrangian constraint of form Row' x contype Rhs */ +void str_add_lag_con(lprec *lp, char *row, short con_type, REAL rhs); +/* The same, but with string input */ + +void add_column(lprec *lp, REAL *column); +/* Add a Column to the problem */ +void str_add_column(lprec *lp, char *col_string); +/* The same, but with string input */ + +void del_column(lprec *lp, int column); +/* Delete a column */ + +void set_upbo(lprec *lp, int column, REAL value); +/* Set the upperbound of a variable */ + +void set_lowbo(lprec *lp, int column, REAL value); +/* Set the lowerbound of a variable */ + +void set_int(lprec *lp, int column, short must_be_int); +/* Set the type of variable, if must_be_int = TRUE then the variable must be integer */ + +void set_rh(lprec *lp, int row, REAL value); +/* Set the right hand side of a constraint row */ + +void set_rh_vec(lprec *lp, REAL *rh); +/* Set the right hand side vector */ +void str_set_rh_vec(lprec *lp, char *rh_string); +/* The same, but with string input */ + +void set_maxim(lprec *lp); +/* maximise the objective function */ + +void set_minim(lprec *lp); +/* minimise the objective function */ + +void set_constr_type(lprec *lp, int row, short con_type); +/* Set the type of constraint in row Row (LE, GE, EQ) */ + +void set_row_name(lprec *lp, int row, nstring new_name); +/* Set the name of a constraint row, make sure that the name has < 25 characters */ + +void set_col_name(lprec *lp, int column, nstring new_name); +/* Set the name of a varaible column, make sure that the name has < 25 characters */ + +void auto_scale(lprec *lp); +/* Automatic scaling of the problem */ + +void unscale(lprec *lp); +/* Remove all scaling from the problem */ + +int solve(lprec *lp); +/* Solve the problem */ + +short Isvalid(lprec *lp); +int milpsolve (sstate *st, REAL *upbo, REAL *lowbo, short *sbasis, short *slower, int *sbas); + +int lag_solve(lprec *lp, REAL start_bound, int num_iter, short verbose); +/* Do NumIter iterations with Lagrangian relaxation constraints */ + +void reset_basis(lprec *lp); +/* Reset the basis of a problem, can be usefull in case of degeneracy - JD */ + +REAL mat_elm(lprec *lp, int row, int column); +/* get a single element from the matrix */ + +void get_row(lprec *lp, int row_nr, REAL *row); +/* fill row with the row row_nr from the problem */ + +void get_column(lprec *lp, int col_nr, REAL *column); +/* fill column with the column col_nr from the problem */ + +void get_reduced_costs(lprec *lp, REAL *rc); +/* get the reduced costs vector */ + +short is_feasible(lprec *lp, REAL *values); +/* returns TRUE if the vector in values is a feasible solution to the lp */ + +short column_in_lp(lprec *lp, REAL *column); +/* returns TRUE if column is already present in lp. (Does not look at bounds + and types, only looks at matrix values */ + +lprec *read_mps(FILE *input, short verbose); +/* read a MPS file */ + +void write_MPS(lprec *lp, FILE *output); +/* write a MPS file to output */ + +void write_LP(lprec *lp, FILE *output); +/* write a LP file to output */ + +void print_lp(lprec *lp); +/* Print the current problem, only usefull in very small (test) problems. + Shows the effect of scaling */ + +void print_solution(lprec *lp); +/* Print the solution to stdout */ + +void print_duals(lprec *lp); +/* Print the dual variables of the solution */ + +void print_scales(lprec *lp); +/* If scaling is used, print the scaling factors */ + + + + +/* functions used internaly by the lp toolkit */ +void error(char *format, ...); +void inc_mat_space(lprec *lp, int max_extra); +void inc_row_space(lprec *lp); +void inc_col_space(lprec *lp); +static REAL minmax_to_scale(REAL min, REAL max); +void unscale_columns(lprec *lp); +void set_globals(lprec *lp); +void ftran(int start, int end, REAL *pcol); +void btran(REAL *row); +void invert(void); + + + + + + +/*************************************************************************/ +/* */ +/* E R R O R H A N D L I N G F O R L I B R A R Y */ +/* */ +/* */ +/* */ +/* */ +/* */ +/*************************************************************************/ + +#define ERROR(x) longjmp(LP_jmpbuf,256|x) + +#define ERR_NOMEM 0x10 /* Any out-of-memory problem */ +#define ERR_ST 0x11 /* ran out allocating State-infos */ + +#define ERR_NUM 0x20 /* Any numeric stability problem */ + +#define ERR_BUG 0x40 /* Any lp_solve-bug exit */ +#define ERR_BUG_CONDCOL 0x41 /* Condensecol out-of-bounds */ + +#include +extern jmp_buf LP_jmpbuf; +extern int SolveCount; + + + + + + + + diff --git a/inc/lppatch.h b/inc/lppatch.h new file mode 100755 index 0000000..8b3d5e0 --- /dev/null +++ b/inc/lppatch.h @@ -0,0 +1,2 @@ +/* $Id: lppatch.h,v 1.2 1999/01/03 02:06:15 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +#define PATCHLEVEL "1.5" diff --git a/inc/lpproto.h b/inc/lpproto.h new file mode 100755 index 0000000..be6d973 --- /dev/null +++ b/inc/lpproto.h @@ -0,0 +1,36 @@ +/* $Id: lpproto.h,v 1.2 1999/01/03 02:06:15 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* dual.c */ +void rowdual(int *rownr); +short coldual(int rownr, int *colnr, short minit, REAL *prow, REAL *drow); + +/* lp.c */ +int yyparse(void); + +/* read.c */ +void yyerror(char *string); +void check_decl(char *str); +void add_int_var(char *name); +void init_read(void); +void null_tmp_store(void); +void store_re_op(void); +void rhs_store(REAL value); +void var_store(char *var, int row, REAL value); +int store_bounds(void); +void add_constraint_name(char *name, int row); +void readinput(int *cend, REAL *rh, short *relat, REAL *lowbo, REAL *upbo, matrec *mat, nstring *names); + +/* tran.c */ +void ftran(int start, int end, REAL *pcol); +void btran(int numc, REAL *row); + +/* main.c */ + +/* solve.c */ +int solve(REAL *upbo, REAL *lowbo, short *sbasis, short *slower, int *sbas, + sstate *t); + +/* write.c */ +void print_solution(FILE *stream, REAL *sol, REAL *duals); +void debug_print_solution(REAL *sol); +void debug_print_bounds(REAL *upbo, REAL *lowbo); +void debug_print(char *format, ...); diff --git a/inc/lspglob.h b/inc/lspglob.h new file mode 100755 index 0000000..64420ce --- /dev/null +++ b/inc/lspglob.h @@ -0,0 +1,192 @@ +/* $Id: lspglob.h,v 1.2 1999/01/03 02:06:15 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/**********************************************************************/ +/* + File Name : lspglob.h + + Global variables for LispSYSOUT + + Date : December 16, 1986 + Edited by : Takeshi Shimizu + Changed : Jan 13 1987 Take. + Changed : Feb 16 1987 Take. + Changed : Mar 25 1987 Take. + Changed : Apr 24 1987 take + Changed : Jul 02 1987 take +*/ +/**********************************************************************/ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + extern DLword *Atomspace; /* ATOMSPACE */ + extern DLword *Stackspace; /* STACKSPACE*/ + extern DLword *Plistspace; /* PLISTSPACE */ + extern DLword *DTDspace; /* DTDSPACE */ + extern DLword *MDStypetbl; /* MDSTT */ + extern DLword *AtomHT; /* AtomHashTable */ + extern DLword *Pnamespace; /* PNSPACE */ + extern DLword *AtomSpace; /* New atoms, initial set */ + extern DLword *Defspace; /* DEFSPACE */ + extern DLword *Valspace; /* VALSPACE */ + extern DLword *Spospspace; /* POSITIVE Smallp */ + extern DLword *Snegspace; /* NEGATIVE Smallp */ + +/* For Virtual Mem Management */ +#ifdef BIGVM +extern LispPTR *FPtoVP; +#else +extern DLword *FPtoVP ; +#endif /* BIGVM */ +extern DLword *PAGEMap; +extern DLword *PageMapTBL ; +extern DLword *LockedPageTable; + +/* For Interface to Micro or Device */ +extern DLword *IOCBPage ; +extern IOPAGE *IOPage ; +extern IFPAGE *InterfacePage ; +extern MISCSTATS *MiscStats ; + +/* UFN Tbl */ +extern DLword *UFNTable ; + +/* Internal Hash Table for GC */ +#ifdef BIGVM + extern LispPTR *HTmain; + extern LispPTR *HToverflow; + extern LispPTR *HTbigcount; + extern LispPTR *HTcoll; +#else + extern DLword *HTmain; + extern DLword *HToverflow; + extern DLword *HTbigcount; + extern DLword *HTcoll; +#endif /* BIGVM */ + + +/* DISPLAY */ + extern DLword *DisplayRegion ; + + +/* FLEX STORAGES */ + extern DLword *Arrayspace; /* Start of ARRAYSPACE */ + extern DLword *MDS_space_bottom; /* Start of MDS (pre -2) */ + extern DLword *PnCharspace ; /* Space for PN char codes (Thin only) */ + + extern struct dtd *ListpDTD ; /* DTD for LISTP chang. 25-mar-87 take */ + extern DLword *Next_Array ; /* Next available ARRAY space */ + extern DLword *Next_MDSpage; /* Next available MDS space */ + + /* Pointers in Cell or any object means DLword offset from Lisp_world. + So, 24 bit Lisp pointers can points 32Mbyte area. + But, ATOMSPACE may be treated as special index space for LITATOM. In another way, it means that the Pointers points ATOMSPACE has no allocated memory, and Thease are used as index for access one of ATOM's prop. */ + extern DLword *Lisp_world; /* Lisp Start BASE */ + + + +/******* CACHE 68k address for LISP SYSVAL *******/ +extern LispPTR *Next_MDSpage_word; +extern LispPTR *Next_Array_word; +extern LispPTR *MDS_free_page_word; + +extern LispPTR *Reclaim_cnt_word ; + + +extern int FileIOFlag, TimerFlag; + +/*** cache values for array reclaimer by Tomtom 30-Sep-1987 ***/ + +extern LispPTR *GcDisabled_word; +extern LispPTR *CdrCoding_word; +extern LispPTR *FreeBlockBuckets_word; +extern LispPTR *Array_Block_Checking_word; +extern LispPTR *ArrayMerging_word; +extern LispPTR *ArraySpace_word; +extern LispPTR *ArraySpace2_word; +extern LispPTR *ArrayFrLst_word; +extern LispPTR *ArrayFrLst2_word; +extern LispPTR *Hunk_word; +extern LispPTR *System_Buffer_List_word; + +/*** The end of the addition of cache values for reclaimer by Tomtom ***/ + +/*** cashe valuses for top level reclaimer Tomtom 15-Oct-1987 ***/ +extern LispPTR *GcMess_word; +extern LispPTR *ReclaimMin_word; +extern LispPTR *GcTime1_word; +extern LispPTR *GcTime2_word; +extern LispPTR *MaxTypeNumber_word; +/*** The end of the addition of cashe values for the top level reclaimer ***/ + +/*** The addition cache for closure-caching ***/ + +extern LispPTR *Package_from_Index_word; +extern LispPTR *Package_from_Name_word; +extern LispPTR *Keyword_Package_word; +extern LispPTR *Deleted_Implicit_Hash_Slot_word; +extern LispPTR *Closure_Cache_Enabled_word; +extern LispPTR *Closure_Cache_word; +extern LispPTR First_index; +/*** The end of cache value for closure-caching ***/ + +/* CACHE values for 32Mb MDS/Array by Take */ +extern LispPTR *STORAGEFULLSTATE_word; +extern LispPTR *STORAGEFULL_word; +extern LispPTR *PENDINGINTERRUPT_word; +extern LispPTR *LeastMDSPage_word; +extern LispPTR *SecondMDSPage_word; +extern LispPTR *SecondArrayPage_word; +extern LispPTR *INTERRUPTSTATE_word; +extern LispPTR *SYSTEMCACHEVARS_word; +extern LispPTR *MACHINETYPE_word; + +extern LispPTR STORAGEFULLSTATE_index; +/******* 7-Oct-87 take********/ +extern LispPTR *LASTVMEMFILEPAGE_word; +extern LispPTR *VMEM_FULL_STATE_word; + +/* Array for N-tran */ +extern int native_load_address; +extern LispPTR native_closure_env; + +/* Vars for Stack operations */ +extern LispPTR *STACKOVERFLOW_word; +extern LispPTR *GuardStackAddr_word; +extern LispPTR *LastStackAddr_word; +extern LispPTR *NeedHardreturnCleanup_word; + +/* I/O Pipe for Unix Interface */ +extern int UnixPipeIn; +extern int UnixPipeOut; +extern int UnixPID; + +/* Atom index for IL:\MVLIST, for the VALUES opcode */ +extern LispPTR MVLIST_index; diff --git a/inc/lsptypes.h b/inc/lsptypes.h new file mode 100755 index 0000000..0f6c012 --- /dev/null +++ b/inc/lsptypes.h @@ -0,0 +1,718 @@ +/* @(#) lsptypes.h Version 1.4 (12/29/94). copyright Venue */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/**********************************************************************/ +/* + File Name : lsptypes.h + + Define Constants for Datatype + +*/ +/**********************************************************************/ + +/************************************************************************/ +/* */ +/* T Y P E T A B L E M A S K B I T S */ +/* */ +/* These are used for quick type checks, and are ORed into the type */ +/* number in the DTD. */ +/* */ +/* [TT_LISPREF renamed to TT_SYMBOLP 2/7/91 by JDS for 3-byte atoms] */ +/* */ +/************************************************************************/ + +#define TT_ATOM 0x0800 /* ATOM in CL sense */ +#define TT_NUMBERP 0x1000 /* It's a number. */ +#define TT_FIXP 0x2000 /* It's an integer. */ +#define TT_SYMBOLP 0x4000 /* It's a symbol (LITATOM or NEWATOM. */ +#define TT_NOREF 0x8000 /* Don't Refcount these objects. */ + + + + +/************************************************************************/ +/* */ +/* T Y P E N U M B E R S */ +/* */ +/* These are the type numbers "known to the microcode". This must */ +/* match the list \BUILT-IN-SYSTEM-TYPES, in LLDATATYPE. It's the */ +/* list of types that MUST be known to microcode or emulator, and */ +/* which can't rely on the luck of what's loaded when for assignment. */ +/* */ +/* Change History: 2/27/89 Sybalsky Added BIGNUM-PATHNAME, to */ +/* support SXHASH opcode. */ +/* 3/1/89 Sybalsky Added type #s for hunked */ +/* storage, for use in GC, in */ +/* place of absolute #s (!!) */ +/* 7/25/90 Osamu Added type# for NEWATOM. */ +/************************************************************************/ + +#define TYPE_ARRAYBLOCK 0 /* Pseudo type # for array blocks */ +#define TYPE_SMALLP 1 +#define TYPE_FIXP 2 +#define TYPE_FLOATP 3 +#define TYPE_LITATOM 4 +#define TYPE_LISTP 5 +#define TYPE_ARRAYP 6 +#define TYPE_STRINGP 7 /* old IL strings (obs) */ +#define TYPE_STACKP 8 +#define TYPE_CHARACTERP 9 +#define TYPE_VMEMPAGEP 10 +#define TYPE_STREAM 11 + +#define TYPE_BITMAP 12 +#define TYPE_COMPILED_CLOSURE 13 +#define TYPE_ONED_ARRAY 14 /* array, string */ +#define TYPE_TWOD_ARRAY 15 +#define TYPE_GENERAL_ARRAY 16 + +#define TYPE_BIGNUM 17 /* Bignums */ +#define TYPE_RATIO 18 /* Commonlisp rationals */ +#define TYPE_COMPLEX 19 /* Commonlisp complex's */ +#define TYPE_PATHNAME 20 /* CL path-name structure */ + +#ifdef BIGATOMS +#define TYPE_NEWATOM 21 /* New Atom */ + +/* type number 22~30 reserved for future use */ + +#define TYPE_PTRHUNK1 31 /********************************/ +#define TYPE_PTRHUNK2 32 /* */ +#define TYPE_PTRHUNK3 33 /* Type numbers for "hunked" */ +#define TYPE_PTRHUNK4 34 /* Storage region, used for */ +#define TYPE_PTRHUNK5 35 /* small arrays. This range */ +#define TYPE_PTRHUNK6 36 /* is for arrays of pointers. */ +#define TYPE_PTRHUNK7 37 /* */ +#define TYPE_PTRHUNK8 38 /********************************/ +#define TYPE_PTRHUNK9 39 +#define TYPE_PTRHUNK10 40 +#define TYPE_PTRHUNK11 41 +#define TYPE_PTRHUNK12 42 +#define TYPE_PTRHUNK13 43 + +#define TYPE_UNBOXEDHUNK1 44 /********************************/ +#define TYPE_UNBOXEDHUNK2 45 /* */ +#define TYPE_UNBOXEDHUNK3 46 /* This range is for arrays */ +#define TYPE_UNBOXEDHUNK4 47 /* of unboxed items -- the */ +#define TYPE_UNBOXEDHUNK5 48 /* contents are not GC'd */ +#define TYPE_UNBOXEDHUNK6 49 /* */ +#define TYPE_UNBOXEDHUNK7 50 /********************************/ +#define TYPE_UNBOXEDHUNK8 51 +#define TYPE_UNBOXEDHUNK9 52 +#define TYPE_UNBOXEDHUNK10 53 +#define TYPE_UNBOXEDHUNK11 54 +#define TYPE_UNBOXEDHUNK12 55 +#define TYPE_UNBOXEDHUNK13 56 +#define TYPE_UNBOXEDHUNK14 57 +#define TYPE_UNBOXEDHUNK15 58 +#define TYPE_UNBOXEDHUNK16 59 +#define TYPE_UNBOXEDHUNK17 60 +#define TYPE_UNBOXEDHUNK18 61 +#define TYPE_UNBOXEDHUNK19 62 +#define TYPE_UNBOXEDHUNK20 63 + +#define TYPE_CODEHUNK1 64 /********************************/ +#define TYPE_CODEHUNK2 65 /* */ +#define TYPE_CODEHUNK3 66 /* This range is for small */ +#define TYPE_CODEHUNK4 67 /* CODE blocks -- the code */ +#define TYPE_CODEHUNK5 68 /* for small functions. It */ +#define TYPE_CODEHUNK6 69 /* gets reclaimed using the */ +#define TYPE_CODEHUNK7 70 /* function reclaimcodeblock. */ +#define TYPE_CODEHUNK8 71 /* */ +#define TYPE_CODEHUNK9 72 /********************************/ +#define TYPE_CODEHUNK10 73 + + +#define INIT_TYPENUM 74 + +#else +#define TYPE_PTRHUNK1 21 /********************************/ +#define TYPE_PTRHUNK2 22 /* */ +#define TYPE_PTRHUNK3 23 /* Type numbers for "hunked" */ +#define TYPE_PTRHUNK4 24 /* Storage region, used for */ +#define TYPE_PTRHUNK5 25 /* small arrays. This range */ +#define TYPE_PTRHUNK6 26 /* is for arrays of pointers. */ +#define TYPE_PTRHUNK7 27 /* */ +#define TYPE_PTRHUNK8 28 /********************************/ +#define TYPE_PTRHUNK9 29 +#define TYPE_PTRHUNK10 30 +#define TYPE_PTRHUNK11 31 +#define TYPE_PTRHUNK12 32 +#define TYPE_PTRHUNK13 33 + +#define TYPE_UNBOXEDHUNK1 34 /********************************/ +#define TYPE_UNBOXEDHUNK2 35 /* */ +#define TYPE_UNBOXEDHUNK3 36 /* This range is for arrays */ +#define TYPE_UNBOXEDHUNK4 37 /* of unboxed items -- the */ +#define TYPE_UNBOXEDHUNK5 38 /* contents are not GC'd */ +#define TYPE_UNBOXEDHUNK6 39 /* */ +#define TYPE_UNBOXEDHUNK7 40 /********************************/ +#define TYPE_UNBOXEDHUNK8 41 +#define TYPE_UNBOXEDHUNK9 42 +#define TYPE_UNBOXEDHUNK10 43 +#define TYPE_UNBOXEDHUNK11 44 +#define TYPE_UNBOXEDHUNK12 45 +#define TYPE_UNBOXEDHUNK13 46 +#define TYPE_UNBOXEDHUNK14 47 +#define TYPE_UNBOXEDHUNK15 48 +#define TYPE_UNBOXEDHUNK16 49 +#define TYPE_UNBOXEDHUNK17 50 +#define TYPE_UNBOXEDHUNK18 51 +#define TYPE_UNBOXEDHUNK19 52 +#define TYPE_UNBOXEDHUNK20 53 + +#define TYPE_CODEHUNK1 54 /********************************/ +#define TYPE_CODEHUNK2 55 /* */ +#define TYPE_CODEHUNK3 56 /* This range is for small */ +#define TYPE_CODEHUNK4 57 /* CODE blocks -- the code */ +#define TYPE_CODEHUNK5 58 /* for small functions. It */ +#define TYPE_CODEHUNK6 59 /* gets reclaimed using the */ +#define TYPE_CODEHUNK7 60 /* function reclaimcodeblock. */ +#define TYPE_CODEHUNK8 61 /* */ +#define TYPE_CODEHUNK9 62 /********************************/ +#define TYPE_CODEHUNK10 63 + + +#define INIT_TYPENUM 64 + +#endif /* BIGATOMS */ + + + +#ifndef BYTESWAP + /* Normal byte-order versions of declarations */ +#ifdef BIGVM +struct dtd { + unsigned unuse :2 ; + unsigned dtd_obsolate :1 ; + unsigned dtd_finalizable :1 ; + unsigned dtd_name: 28 ; /* type name */ + DLword dtd_cnt0 ; + DLword dtd_size ; + LispPTR dtd_free ; /* really a FULLXPOINTER */ + unsigned dtd_lockedp : 1 ; + unsigned dtd_hunkp : 1 ; + unsigned dtd_gctype :2 ; + unsigned dtd_descrs: 28; + LispPTR dtd_typespecs; + LispPTR dtd_ptrs ; + int dtd_oldcnt; + int dtd_nextpage ; + DLword dtd_typeentry ; + DLword dtd_supertype ; +}; + +typedef struct stringp { + + unsigned origin : 1 ; + unsigned substringed : 1 ; + unsigned readonly : 1 ; + unsigned nil : 1 ; + + unsigned base : 28 ; + unsigned type : 4 ; + unsigned length: 28 ; + LispPTR offset ; + } STRINGP ; + +typedef struct oned_array { + unsigned int nil1 : 4 ; + unsigned int base : 28 ; + unsigned int readonlyp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int bitp :1 ; + unsigned int stringp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int displacedp : 1; + unsigned int fillpointerp :1; + unsigned int extendablep : 1; + unsigned int typenumber : 8 ; + DLword offset; + LispPTR fillpointer ; + LispPTR totalsize ; } OneDArray; + +typedef struct oned_array NEWSTRINGP; + +typedef struct general_array { + unsigned int nil1 : 4 ; + unsigned int base : 28 ; + unsigned int readonlyp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int bitp :1 ; + unsigned int stringp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int displacedp : 1; + unsigned int fillpointerp :1; + unsigned int extendablep : 1; + unsigned int typenumber : 8 ; + unsigned int nil2:16; + LispPTR Dim0; + LispPTR totalsize; + LispPTR Dim1 ; + LispPTR Dim2 ; } LispArray; + +typedef struct compiled_closure { + unsigned int nil1 : 4 ; + unsigned int def_ptr : 28; /* function */ + unsigned int nil2 : 4 ; + unsigned int env_ptr : 28; /* environment */ + } CClosure ; +#else +/* Structure for DTD */ +struct dtd { + DLword dtd_namelo ; + DLword dtd_size ; + LispPTR dtd_free ; /* really a FULLXPOINTER */ + unsigned unuse :2 ; + unsigned dtd_obsolate :1 ; + unsigned dtd_finalizable :1 ; + unsigned dtd_lockedp : 1 ; + unsigned dtd_hunkp : 1 ; + unsigned dtd_gctype :2 ; + unsigned dtd_descrs : 24; + unsigned dtd_namehi : 8; + unsigned dtd_typespecs : 24 ; + LispPTR dtd_ptrs ; + int dtd_oldcnt; + DLword dtd_cnt0 ; + DLword dtd_nextpage ; + DLword dtd_typeentry ; + DLword dtd_supertype ; +}; + +typedef struct stringp { + unsigned origin : 1 ; + unsigned substringed : 1 ; + unsigned readonly : 1 ; + unsigned nil : 1 ; + unsigned type : 4 ; + + unsigned base : 24 ; + DLword length ; + DLword offset ; + } STRINGP ; + +typedef struct oned_array { + unsigned int nil1 : 8 ; + unsigned int base : 24 ; + unsigned int readonlyp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int bitp :1 ; + unsigned int stringp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int displacedp : 1; + unsigned int fillpointerp :1; + unsigned int extendablep : 1; + unsigned int typenumber : 8 ; + DLword offset; + DLword fillpointer ; + DLword totalsize ; } OneDArray; + +typedef struct oned_array NEWSTRINGP; + +typedef struct general_array { + unsigned int nil1 : 8 ; + unsigned int base : 24 ; + unsigned int readonlyp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int bitp :1 ; + unsigned int stringp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int displacedp : 1; + unsigned int fillpointerp :1; + unsigned int extendablep : 1; + unsigned int typenumber : 8 ; + DLword Dim0; + DLword totalsize; + DLword Dim1 ; + DLword Dim2 ; } LispArray; + +typedef struct compiled_closure { + unsigned int nil1 : 8 ; + unsigned int def_ptr : 24; /* function */ + unsigned int nil2 : 8 ; + unsigned int env_ptr : 24; /* environment */ + } CClosure ; +#endif /* BIGVM */ + +/* Structure for initialdtdcontents */ + struct system_dtd_contents { + char *dtd_name ; /* type name string >> changed 4-feb-87 */ + DLword name_len ; /* type name length in BYTE 27-Mar-87 take */ + DLword dtd_size ; +}; + +typedef struct{ + LispPTR bmbase; + DLword bmrasterwidth; + DLword bmheight; + DLword bmwidth; + DLword bmbitperpixel; +}BITMAP; + + + /****************************************************************/ + /* Byte- and Word-array access macros */ + /* */ + /* Use these macros instead of dereferencing a char pointer */ + /* so we can encapsulate byte-ordering effects on different */ + /* hardware! */ + /* */ + /****************************************************************/ + +#define GETBYTE(base) (* (base)) +/* GETBASEWORD only works if base points to a 32-bit bounday */ +#define GETBASEWORD(base, offset) (* ((base)+(offset))) + /* GETWORDBASEWORD works right with base on a 16-bit boundary. */ +#define GETWORDBASEWORD(base, offset) (* (((DLword *)(base))+(offset))) +#define GETWORD(base) (* (base)) +#define WORDPTR(base) (base) +#define BYTEPTR(base) (base) + +#else + /********************************************************/ + /* */ + /* Byte-swapped structure definitions, for 80386 &c */ + /* */ + /********************************************************/ + +#ifdef BIGVM +struct dtd { + unsigned dtd_name: 28 ; /* type name */ + unsigned dtd_finalizable :1 ; + unsigned dtd_obsolate :1 ; + unsigned unuse :2 ; + DLword dtd_size ; + DLword dtd_cnt0 ; + LispPTR dtd_free ; /* really a FULLXPOINTER */ + unsigned dtd_descrs: 28; + unsigned dtd_gctype :2 ; + unsigned dtd_hunkp : 1 ; + unsigned dtd_lockedp : 1 ; + LispPTR dtd_typespecs; + LispPTR dtd_ptrs ; + int dtd_oldcnt; + int dtd_nextpage ; + DLword dtd_supertype ; + DLword dtd_typeentry ; +}; + +typedef struct stringp { + + unsigned base : 28 ; + unsigned nil : 1 ; + unsigned readonly : 1 ; + unsigned substringed : 1 ; + unsigned origin : 1 ; + + unsigned length: 28 ; + unsigned type : 4 ; + LispPTR offset ; + } STRINGP ; + + +typedef struct oned_array { + unsigned int base : 28 ; + unsigned int nil1 : 4 ; + DLword offset; + unsigned int typenumber : 8 ; + unsigned int extendablep : 1; + unsigned int fillpointerp :1; + unsigned int displacedp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int stringp : 1; + unsigned int bitp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int readonlyp :1 ; + LispPTR fillpointer ; + LispPTR totalsize ; } OneDArray; + + +typedef struct oned_array NEWSTRINGP; + +typedef struct general_array { + unsigned int base : 28 ; + unsigned int nil1 : 4 ; + unsigned int nil2:16; + unsigned int typenumber : 8 ; + unsigned int extendablep : 1; + unsigned int fillpointerp :1; + unsigned int displacedp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int stringp : 1; + unsigned int bitp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int readonlyp :1 ; + LispPTR Dim0; + LispPTR totalsize; + LispPTR Dim1 ; + LispPTR Dim2 ; } LispArray; + +typedef struct compiled_closure { + unsigned int def_ptr : 28; /* function */ + unsigned int nil1 : 4 ; + unsigned int env_ptr : 28; /* environment */ + unsigned int nil2 : 4 ; + } CClosure ; +#else +/* Structure for DTD */ +struct dtd { + DLword dtd_size ; + DLword dtd_namelo ; + LispPTR dtd_free ; /* really a FULLXPOINTER */ + unsigned dtd_descrs : 24; + unsigned dtd_gctype :2 ; + unsigned dtd_hunkp : 1 ; + unsigned dtd_lockedp : 1 ; + unsigned dtd_finalizable :1 ; + unsigned dtd_obsolate :1 ; + unsigned unuse :2 ; + unsigned dtd_typespecs : 24 ; + unsigned dtd_namehi : 8; + LispPTR dtd_ptrs ; + int dtd_oldcnt; + DLword dtd_nextpage ; + DLword dtd_cnt0 ; + DLword dtd_supertype ; + DLword dtd_typeentry ; +}; + +typedef struct stringp + { + unsigned base : 24 ; + unsigned type : 4 ; + unsigned nil : 1 ; + unsigned readonly : 1 ; + unsigned substringed : 1 ; + unsigned origin : 1 ; + DLword offset ; + DLword length ; + } STRINGP ; + +typedef struct oned_array + { + unsigned int base : 24 ; + unsigned int nil1 : 8 ; + DLword offset; + unsigned int typenumber : 8 ; + unsigned int extendablep : 1; + unsigned int fillpointerp :1; + unsigned int displacedp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int stringp : 1; + unsigned int bitp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int readonlyp :1 ; + DLword totalsize ; + DLword fillpointer ; + } OneDArray; + +typedef struct oned_array NEWSTRINGP; + +typedef struct general_array + { + unsigned int base : 24 ; + unsigned int nil1 : 8 ; + DLword Dim0; + unsigned int typenumber : 8 ; + unsigned int extendablep : 1; + unsigned int fillpointerp :1; + unsigned int displacedp : 1; + unsigned int ajustablep : 1; /* as used arrayheader */ + unsigned int stringp : 1; + unsigned int bitp :1 ; + unsigned int indirectp : 1; /* as used arrayheader */ + unsigned int readonlyp :1 ; + DLword Dim2 ; + DLword Dim1 ; + } LispArray; + +typedef struct compiled_closure + { + unsigned int def_ptr : 24; /* function */ + unsigned int nil1 : 8 ; + unsigned int env_ptr: 24; /* environment */ + unsigned int nil2 : 8 ; + } CClosure ; +#endif /* BIGVM */ +/* Structure for initialdtdcontents */ + + struct system_dtd_contents + { + char *dtd_name ; /* type name string >> changed 4-feb-87 */ + DLword dtd_size ; + DLword name_len ; /* type name length in BYTE 27-Mar-87 take */ + }; + +typedef struct + { + LispPTR bmbase; + DLword bmheight; + DLword bmrasterwidth; + DLword bmbitperpixel; + DLword bmwidth; + }BITMAP; + + + /****************************************************************/ + /* Byte- and Word-array access macros */ + /* */ + /* Use these macros instead of dereferencing a char pointer */ + /* so we can encapsulate byte-ordering effects on different */ + /* hardware! */ + /* */ + /****************************************************************/ + +#define GETBYTE(base) (* (char *) (3^(UNSIGNED)(base))) + /* GETBASEWORD only works if base points to a 32-bit bounday */ +#define GETBASEWORD(base, offset) GETWORDBASEWORD((base),(offset)) +#define GETWORDBASEWORD(base, offset) (* (DLword *) (2^(UNSIGNED)((base)+(offset)))) +#define GETWORD(base) (* (DLword *) (2^(UNSIGNED)(base))) +#define WORDPTR(base) ((DLword *)(2^(UNSIGNED)(base))) +#define BYTEPTR(base) ((char *) (3^(UNSIGNED)(base))) + +#endif /* BYTESWAP */ + + + +#define ST_POS16 1 +#define ST_BYTE 0 +#define THIN_CHAR_TYPENUMBER 67 +#define FAT_CHAR_TYPENUMBER 68 + + +/************************************************************************/ +/* */ +/* T Y P E E N T R Y A C C E S S O R S */ +/* */ +/* GetDTD Gets the (C-native) address for the DTD */ +/* (Data Type Descriptor) for the type whose */ +/* number you hand it (LESS the mask bits!). */ +/* */ +/* GetTypeEntry Gets the entire 16-bit "type number" field */ +/* from the DTD, including type-mask bits. */ +/* Use this one when you want the mask bits for */ +/* a quick category check. */ +/* */ +/* GetTypeNumber Gets only the Type Number (without mask bits) */ +/* from the DTD for the object you give it. */ +/* Use this one for doing type checks and */ +/* dispatching. */ +/* */ +/* Listp If 'address' is the address of a cons cell, */ +/* returns TRUE. Equivalent to the LISTP pred. */ +/* */ +/************************************************************************/ + +#ifndef I386 + +/* Get DTD pointer(68k) from typenum */ +#ifdef BIGVM +#define GetDTD(typnum) (DTDspace + ((typnum)<<4)+((typnum)<<1)) +#else +#define GetDTD(typnum) (DTDspace + ((typnum)<<4)) +#endif /* BIGVM */ + +/* Get all type entry */ +#define GetTypeEntry(address) ( GETWORD(MDStypetbl+((address)>>9)) ) + +#else + /* Because the 386i's code generator does bettter with them */ + /* in this order (does an add, rather than mov-add) */ + /* JDS 22-mar-90 */ + +/* Get DTD pointer(68k) from typenum */ +#define GetDTD(typnum) (((typnum)<<4) + DTDspace) + +/* Get all type entry */ +#define GetTypeEntry(address) ( GETWORD(((address)>>9) + MDStypetbl) ) + +#endif /* I386 */ + + +/* the type number is in the low 11 bits */ +#define GetTypeNumber(address) (GetTypeEntry(address) & 0x7ff) + +/* This MACRO is similar to LISTP */ +#define Listp(address) (GetTypeNumber(address) == TYPE_LISTP) + + + /******************************************/ + /* Lisp's PATHNAME datatype */ + /* */ + /* This MUST change whenever the Lisp */ + /* definition of the PATHNAME structure */ + /* changes. */ + /* */ + /******************************************/ +typedef + struct + { + LispPTR host; + LispPTR device; + LispPTR directory; + LispPTR name; + LispPTR type; + LispPTR version; + } PATHNAME; + + /******************************************/ + /* Lisp's COMPLEX datatype */ + /* */ + /* This MUST change whenever the Lisp */ + /* definition of the COMPLEX structure */ + /* changes. */ + /* */ + /******************************************/ +typedef + struct + { + LispPTR real; + LispPTR imaginary; + } COMPLEX; + + + /******************************************/ + /* Lisp's RATIO datatype */ + /* */ + /* This MUST change whenever the Lisp */ + /* definition of the RATIO structure */ + /* changes. */ + /* */ + /******************************************/ +typedef + struct + { + LispPTR numerator; + LispPTR denominator; + } RATIO; + + + /******************************************/ + /* Lisp's BIGNUM datatype */ + /* */ + /* This MUST change whenever the Lisp */ + /* definition of the BIGNUM structure */ + /* changes. */ + /* */ + /******************************************/ +typedef + struct + { + LispPTR contents; /* a list of 12-bit segments of value, */ + /* low-order 12 bits first. */ + } BIGNUM; + diff --git a/inc/medleyfp.h b/inc/medleyfp.h new file mode 100755 index 0000000..9192c24 --- /dev/null +++ b/inc/medleyfp.h @@ -0,0 +1,126 @@ +/* $Id: medleyfp.h,v 1.2 1999/01/03 02:06:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifdef DOS +#include +#endif /* DOS */ +#ifdef ULTRIX +#include +#endif /* ULTRIX */ + +#ifdef RISCOS +/*#include */ +/*#define isnan isnand */ +#define isnan(x) 0 +#endif /* RISCOS */ + + +/* -------------------------------------------------- + FPCLEAR - clear status as necessary + FPTEST(result) - check result or status + + Sun 4 compiler w. -O2 moves too much code around + to use FLTINT. + -------------------------------------------------- */ + +#ifdef FLTINT +volatile extern int FP_error; + + +/* Note that a compiler may very likely move code around the arithmetic + operation, causing this test (set by an interrupt handler) to be + incorrect. For example, the Sun SPARC compiler with -O2 makes + this test incorrect. + */ + +#define FPCLEAR FP_error = 0; +#define FPTEST(result) FP_error + +#else + +/* fpstatus_ is a FORTRAN library routine (in libc) which + can be called to determine floating point status results. + Documented in the Sun manual, "Floating Point Programmer's Guide", + (Rev. A 19-Sep-86), pg. 34, it does *not* exist in libc for the + SPARC. + + For sparc, should also check for isnan? Don't know what isnormal + & issubnormal do (these are sunos4.0 only) + */ + +#ifdef OS5 + +#define FPCLEAR +#define FPTEST(result) (!finite(result)) + +#elif (defined(sparc) || defined(I386) || defined(HPUX)) + +#define FPCLEAR +#define FPTEST(result) (isinf(result) || isnan(result)) + +#elif APOLLO + /**********************************************************/ + /* Need values.h & nan.h, so we all parts of IsNANorINF */ + /* are defined. IsNANorINF uses structure aliasing to */ + /* get at pieces of the float to test it, so the item */ + /* being tested can't be a register variable. Sigh. */ + /**********************************************************/ +#include +#include +#define FPCLEAR +#define FPTEST(result) (IsNANorINF(result)) +#undef REGISTER +#define REGISTER + +#elif OSF1 +#include +#define FPCLEAR +#define FPTEST(result) (!FINITE(result)) + + +#elif INDIGO +#include +#define FPCLEAR +#define FPTEST(result) (IsNANorINF(result)) +#else +#ifdef AIX +#define FPCLEAR +#define FPTEST(result) ((!finite(result)) || isnan(result)) +#elif DOS +#define FPCLEAR +#define FPTEST(result) (_getrealerror() & ( I87_ZERO_DIVIDE | I87_OVERFLOW | I87_UNDERFLOW)) +#else +static int constant0 = 0; +unsigned int fpstatus_(); + +#define FPCLEAR fpstatus_(&constant0); +#define FPTEST(result) (fpstatus_(&constant0) & 0xF0) + +#endif /* AIX */ + +#endif /* sparc | I386 */ + +#endif /* FLTINT */ + + + diff --git a/inc/miscstat.h b/inc/miscstat.h new file mode 100755 index 0000000..116e2bb --- /dev/null +++ b/inc/miscstat.h @@ -0,0 +1,53 @@ +/* $Id: miscstat.h,v 1.2 1999/01/03 02:06:17 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* + * Copyright (C) 1987 by Fuji Xerox Co., Ltd. All rights reserved. + * + * by : Yasuhiko Kiuchi + */ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +typedef struct misc + { + int starttime; + int totaltime; + int swapwaittime; + int pagefaults; + int swapwrites; + int diskiotime; + int diskops; + int keyboardwaittime; + int gctime; + int netiotime; + int netioops; + int swaptemp0; + int swaptemp1; + unsigned int rclksecond; + unsigned int secondsclock; + unsigned int millisecondsclock; + unsigned int baseclock; + unsigned int rclktemp0; + unsigned int secondstmp; + unsigned int millisecondstmp; + unsigned int basetmp; + int excesstimetmp; + int clocktemp0; + int disktemp0; + int disktemp1; + int teleraidtemp1; + int teleraidtemp2; + int teleraidtemp3; + int lastuseraction; + int dlmousetimer; + int dlmousetemp; + } MISCSTATS; diff --git a/inc/mnxdefs.h b/inc/mnxdefs.h new file mode 100755 index 0000000..9688606 --- /dev/null +++ b/inc/mnxdefs.h @@ -0,0 +1,529 @@ +/* $Id: mnxdefs.h,v 1.2 1999/01/03 02:06:17 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifdef XTK +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* XTK */ + +typedef void (*PFV)(); /* Pointer to Function returning Void */ +typedef int (*PFI)(); /* Pointer to Function returning Int */ +typedef char (*PFC)(); /* Pointer to Function returning Char */ +typedef float (*PFF)(); /* Pointer to Function returning Float */ +typedef int (*PFP)(); /* Pointer to Function returning a Pointer */ +typedef unsigned long (*PFUL)(); /* Pointer to Function returning an unsigned long */ + + +typedef struct { + int x; + int y; + int width; + int height; +} MRegion; + + +typedef struct { + int x; + int y; +} MPoint, + MPosition; + + +typedef struct { + unsigned left:1; + unsigned middle:1; + unsigned right:1; + unsigned nil:28; +} MButton; + +typedef union +{ + struct { + PFI InitW; /* Initialize a window */ + PFI Openw; + PFI Closew; + PFI MoveW; + PFI ShapeW; + PFI TotopW; + PFI BuryW; + PFI ShrinkW; + PFI ExpandW; + PFI DestroyW; /* Finalize a window */ + PFI GCIndicator; + PFI Query; + PFI DestroyMe; /* Finalize self */ + PFI MakePromptW; + PFI BBTtoWin; /* Bitblt cases lisp -> native window, */ + PFI BBTfromWin; /* native window -> lisp bitmap */ + PFI BBTWinWin; /* native window -> native window */ + PFI GetWindowProp; + PFI PutWindowProp; + PFI GrabPointer; + PFI UngrabPointer; + PFI DrawBox; + PFI MovePointer; + PFI MouseConfirm; + PFI SetCursor; + } Method; + PFI vector[ 25 ]; +} DisplayDispatchTableRec, *DisplayDispatchTable; + + + + +typedef union +{ + struct { + PFI CloseFn; + PFI XPosition; + PFI YPosItion; + PFI Font; + PFI FontCreate; + PFI StringWidth; + PFI CharWidth; + PFI CharWidthY; + PFI LeftMargin; + PFI RightMargin; + PFI TopMargin; + PFI BottomMargin; + PFI ClippingRegion; + PFI PushState; + PFI PopState; + PFI DefaultState; + PFI Scale; + PFI Scale2; + PFI Translate; + PFI Rotate; + PFI Color; + PFI BackColor; + PFI Operation; + PFI MoveTo; + PFI Reset; + PFI NewPage; + PFI LineFeed; + PFI TerPri; + PFI ScaleFactor; + PFI OutcharFn; + PFI CharSet; + PFI DrawPoint; + PFI DrawLine; + PFI DrawCurve; + PFI DrawCircle; + PFI DrawElips; + PFI DrawPolygon; + PFI FillPolygon; + PFI FillCircle; + PFI DrawArc; + PFI BltShade; + PFI BitBlt; + PFI ScaledBitBlt; + PFI WritePixel; + PFI BitmapSize; + PFI Offsets; + } Method; + PFI vector[ 44 ]; +} ImageOpDispatchTableRec, *ImageOpDispatchTable; + + +typedef struct wifrec +{ + int error; /* Place to save error number for diagnosis */ + MRegion windowreg; /* The position Lisp thinks the window is in, LISP coordinates! */ + MRegion topregion; /* The toplevel widget's size. */ + MRegion outerregion; /* The window's outer size. */ + MRegion innerregion; /* The window's inner size. */ + MRegion extent; /* The extent of the whole window. */ + int whiteborder; /* The white border of the window. */ + int blackborder2; + Window blackframe; /* The black part of the windowframe */ + Window handle; /* The actual X window for displaying things */ + Pixmap backing; /* Pixmap to store window image / temp results */ + GC ReplaceGC; /* GC for operations in REPLACE mode */ + GC InvertGC; /* GC for operations in INVERT mode */ + GC PaintGC1; /* Gc #1 for operations in PAINT mode */ + GC PaintGC2; /* GC #2 for operations in PAINT mode */ + GC EraseGC1; /* GC #1 for operations in ERASE mode */ + GC EraseGC2; /* GC #2 for operations in ERASE mode */ + GC gc; /* GC for random use */ + /* Window Methods */ + ImageOpDispatchTable Dispatch; + LispPTR MedleyWindow; /* The Lisp WINDOW this corresponds to */ + LispPTR MedleyScreen; /* The Lisp SCREEN this corresponds to */ + Screen *screen; /* The X screen this uses */ + int depth; /* Depth of the window */ + + int op; /* current OP of window (0 = replace, etc) */ + int xoffset; /* X offset, from the stream */ + int yoffset; /* Y offset, from the stream */ + LispPTR FGcolor; /* Foreground color (fixp or bitmap for fill ops) */ + LispPTR BGcolor; /* Background color (fixp or bitmap for fill ops) */ + + Pixmap fgpixmap; /* These two slots are caches to make sure that */ + Pixmap bgpixmap; /* the pixmaps in them a) stay around till they */ + /* are needed, and (b) get garbage collected */ + unsigned not_exposed:1; /* T if next Expose should decache SAVE bitmap */ + unsigned moving:1; /* T if lisp MOVEW called, so ignore X event */ + unsigned reshaping:1; /* T if lisp SHAPEW called, so ignore X event */ + unsigned scrollfn:1; /* T if we have a scrollfn */ + unsigned noscrollbars:1; /* T if windowprop NOSCROLLBARS is set. */ + unsigned open:1; /* T if this window is open; NIL if not */ + unsigned move_pend:1; /* T if we moved this window while closed */ + unsigned shape_pend:1; /* T if we reshaped this window while closed */ + unsigned nil:24; /* space for future flags */ + struct wifrec *next; /* Thread all windows on this screen */ + Window parent; /* The parent window of this window */ + struct dspifrec *dspif; /* the dspif for this window */ +#ifdef XTK + Widget topwidget; /* The hold on the widget of this window */ + Widget formwidget; + Widget framewidget; /* The widget to represent the frame */ + Widget windowwidget; /* The white region of the window */ + char gstring[32]; /* A string to hold geometry strings in. */ +#endif /*XTK */ +} WindowInterfaceRec, *WindowInterface; + + + + /******************************************************/ + /* */ + /* D S P I N T E R F A C E R E C */ + /* */ + /* Display-interface record: The interface from */ + /* Medley to the X display for a given Medley- */ + /* Native-Windows screen. */ + /* */ + /******************************************************/ + +typedef struct dspifrec +{ + int error; /* A generic errornumber */ + Display *handle; /* The X Display this dspif describes */ + Mask DisableEventMask; + Mask EnableEventMask; + XImage image; /* The scratch image structure (used in blt'ing) */ + XImage tmpimage; /* The tmp image (used for depth conversion) */ + GC TitleGC; /* The gc for title blitting. */ + DisplayDispatchTableRec Dispatch; /* The methods for the display */ + ImageOpDispatchTableRec ImageOp; + LispPTR screen; /* The lisp SCREEN this display corresponds to */ + Screen *xscreen; /* The X screen we're on on this display */ + Window root; /* The root window for this screen */ + Cursor cursor; /* The cursor in effect on this screen */ + int black; /* black pixel for this screen */ + int white; /* white pixel for this screen */ + int width; /* Width of the screen, in pixels */ + int height; /* Height of the screen, in pixels */ + int depth; /* SCDEPTH for this screen -- Medley's view */ + WindowInterface CreatedWifs; /* A list of all windows on this screen */ + WindowInterface promptw; /* The PROMPTWINDOW for this screen */ +#ifdef XTK + XtAppContext xtcontext; /* The application context for this display */ +#endif /*XTK */ + + int bw_plane; /* plane-mask for the plane that distinguishes B & W */ + int bw_inverted; /* T if B & W are backwards from Lisp */ + + GC PixRGC; /* GC for blt'ing FROM window in REPLACE mode */ + GC PixPGC; /* GC for blt'ing FROM window in PAINT mode */ + GC PixIGC; /* GC for blt'ing FROM window in INVERT mode */ + GC PixEGC; /* GC for blt'ing FROM window in ERASE mode */ + GC BoxingGC; /* GC for drawing boxes on full screen */ + Widget gcindicator; + Widget legatewidget; +} DspInterfaceRec, *DspInterface; + +#ifdef NEVER + +/******************************************/ +/* The Legate window structure is a */ +/* WindowInterfaceRec with some stuff on */ +/* the tail end of the record. This is */ +/* to be viewed as the subclassing of the */ +/* ordinary WindowInterfaceRec. */ +/******************************************/ +typedef struct +{ + WindowInterfaceRec promptw; /* The prompt window. */ + Widget barwidget; /* A place to hold the bar widgets. */ + Widget gcindicator; /* The garbage collector status window */ + Widget menuwindow; /* The background popup menu window */ +} LegateWindowInterfaceRec, *LegateWindowInterface; +#endif /* NEVER */ + + + +typedef struct{ + LispPTR SCONOFF; + LispPTR SCDESTINATION; + LispPTR SCWIDTH; + LispPTR SCHEIGHT; + LispPTR SCTOPW; + LispPTR SCTOPWDS; + LispPTR SCTITLEDS; + LispPTR SCFDEV; + LispPTR SCDS; + LispPTR SCDATA; + DspInterface NativeIf; +#ifdef THIRTYTWOBITS + int junk; +#endif /* BITS */ + LispPTR NATIVE_INFO; + LispPTR NATIVETYPE; + LispPTR WINIMAGEOPS; + LispPTR WINFDEV; + LispPTR CREATEWFN; + LispPTR OPENWFN; + LispPTR CLOSEWFN; + LispPTR MOVEWFN; + LispPTR RELMOVEWFN; + LispPTR SHRINKWFN; + LispPTR EXPANDWFN; + LispPTR SHAPEWFN; + LispPTR REDISPLAYFN; + LispPTR GETWINDOWPROPFN; + LispPTR SETWINDOWPROPFN; + LispPTR BURYWFN; + LispPTR TOTOPWFN; + LispPTR IMPORTWFN; + LispPTR EXPORTWFN; + LispPTR DESTROYFN; + LispPTR SETCURSORFN; + LispPTR PROMPTW; + LispPTR SHOWGCFN; + LispPTR DSPCREATEFN; + LispPTR BBTTOWIN; + LispPTR BBTFROMWIN; + LispPTR BBTWINWIN; + LispPTR SCCURSOR; + LispPTR SCKEYBOARD; + LispPTR SCDEPTH; +} MedleyScreenRec, *MedleyScreen; + + + + +typedef struct{ + LispPTR DSP; + LispPTR NEXTW; + LispPTR SAVE; + LispPTR REG; + LispPTR BUTTONEVENTFN; + LispPTR RIGHTBUTTONFN; + LispPTR CURSORINFN; + LispPTR CURSOROUTFN; + LispPTR CURSORMOVEFN; + LispPTR REPAINTFN; + LispPTR RESHAPEFN; + LispPTR EXTENT; + LispPTR USERDATA; + LispPTR VERTSCROLLREG; + LispPTR HORIZSCROLLREG; + LispPTR SCROLLFN; + LispPTR VERTSCROLLWINDOW; + LispPTR HORIZSCROLLWINDOW; + LispPTR CLOSEFN; + LispPTR MOVEFN; + LispPTR WTITLE; + LispPTR NEWREGION; + LispPTR WBORDER; /* Assumed to allways be a SMALLP */ + LispPTR PROCESS; + LispPTR WINDOWENTRYFN; + LispPTR SCREEN; + WindowInterface NativeIf; +#ifdef THIRTYTWOBITS + int junk1; +#endif /* THIRTYTWOBITS */ + LispPTR MISCNATIVE; +#ifdef THIRTYTWOBITS + int junk2; +#endif /* THIRTYTWOBITS */ + LispPTR NATIVE_P1; +} MedleyWindowRec, *MedleyWindow; + +typedef LispPTR *LispArgs; + + +typedef struct WinList + { + struct WinList *prior; + struct WinList *next; + WindowInterfaceRec *thiswin; + } winlist; + + + + /* Structure that defines an entry in the ring buffer of MNW events */ + /* This uses the same ring-buffer scheme as keyboard codes do */ + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + int pad[4]; /* Ad hoc fields to be able to access slots by */ + /* position in the struct rather than name. */ +} MNWAnyEvent, + MNWCloseEvent, + MNWFocusEvent, + MNWFocusInEvent, + MNWFocusOutEvent, + MNWToTopEvent; + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + MPosition pos; +} MNWMoveEvent, + MNWPointerMotionEvent; + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + MRegion reg; +} MNWReshapeEvent, + MNWShapeReqEvent; + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + MPosition pos; + MButton button; +} MNWButtonEvent, + MNWButtonDownEvent, + MNWButtonUpEvent; + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + MPosition pos; + MButton button; +} MNWMouseEvent, + MNWMouseInEvent, + MNWMouseOutEvent; + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + int dx; + int dy; +} MNWScrollReqEvent; + +typedef struct { + LispPTR screen; /* lisp SCREEN this event happened for */ + LispPTR window; /* lisp WINDOW this event happened for */ + int event; /* What kind of event this is (see defs below for code) */ + float xpercent; + float ypercent; +} MNWJumpScrollReqEvent; + +typedef union mnwevenT + { + MNWAnyEvent Any; + MNWCloseEvent Close; + MNWFocusEvent Focus; + MNWFocusInEvent FocusBegin; + MNWFocusOutEvent FocusEnd; + MNWToTopEvent Top; + MNWMoveEvent Move; + MNWReshapeEvent Reshape; + MNWShapeReqEvent ShapeReq; + MNWButtonEvent Button; + MNWButtonDownEvent ButtonDown; + MNWButtonUpEvent ButtonUp; + MNWMouseEvent Mouse; + MNWMouseInEvent MouseIn; + MNWMouseOutEvent MouseOut; + MNWScrollReqEvent ScrollReq; + MNWJumpScrollReqEvent JumpScrollReq; + } MNWEvent; + +#define MNWClose 1 +#define MNWMove 2 +#define MNWReshape 3 /* This window was reshaped */ +#define MNWFocusIn 4 /* Focus moved into this window */ +#define MNWFocusOut 5 /* Focus moved out of this window */ +#define MNWButton 6 +#define MNWButtonUp 7 +#define MNWMouseIn 8 +#define MNWMouseOut 9 /* Mouse moved out of this window */ +#define MNWToTop 10 /* This window brought to top */ +#define MNWShapeReq 11 /* Window mgr asked to reshape this window */ +#define MNWScrollReq 12 /* Window widget asked for incremental scroll. */ +#define MNWScrollJmpReq 13 /* Window widget asked for jmp scroll. */ +#define MNWPointerMotion 14 + +#define MINMNWEVENT 2 /* allow 2 words for the ring buffer */ +#define MNWEVENTSIZE ((sizeof(MNWEvent)+1)>>1) +#define MAXMNWEVENT (MINMNWEVENT + (100* MNWEVENTSIZE)) + +#define MNWTitle 0 +#define MNWScrollFn 1 +#define MNWNoScrollbars 2 +#define MNWScrollExtent 3 +#define MNWScrollExtentUse 4 +#define MNWBorder 5 + +#define REPLACE 0 /* Operations for BITBLT, etc, as they come from lisp */ +#define PAINT 1 +#define INVERT 2 +#define ERASE 3 + + +/***************************************************/ +/* Macros for dealing with pointer complexity. */ +/***************************************************/ + + +/***************************************************/ +/* The argument for all these macros is a LispPTR */ +/* to a Medley window structure. */ +/* The result of the calculation is a C pointer. */ +/***************************************************/ +#define Cptr(LADDR) Addr68k_from_LADDR(LADDR) +#define WIfFromMw(win) (((MedleyWindow)Cptr(win))->NativeIf) +#define ScrnFromMw(win) ((MedleyScreenRec *)Cptr(((MedleyWindow)Cptr(win))->SCREEN)) +#define DspstreamFromMw(win) ((Stream *)Cptr(((MedleyWindow)Cptr(win))->DSP)) +#define ImDataFromMw(win) ((DISPLAYDATA *)Cptr(DspstreamFromMw(win)->IMAGEDATA)) +#define MScrFromMw(win) ((MedleyScreen)Cptr(((MedleyWindow)Cptr(win))->SCREEN)) +#define TitleDSFromMw(win) ((Stream *)Cptr(MScrFromMw(win)->SCTITLEDS)) +#define TitleDDFromMw(win) ((DISPLAYDATA *)Cptr(TitleDSFromMw(win)->IMAGEDATA)) +#define DspIfFromMw(win) (MScrFromMw(win)->NativeIf) +#define XDisplayFromMw(win) (DspIfFromMw(win)->handle) +#define XWindowFromMw(win) (WIfFromMw(win)->handle) + +#define DspIfFromMscr(scr) (((MedleyScreen)Cptr(scr))->NativeIf) + +#ifndef max +#define max( a, b ) (((a)>(b))?(a):(b)) +#endif /* max */ + +#ifndef min +#define min( a, b ) (((a)<(b))?(a):(b)) +#endif /* min */ diff --git a/inc/my.h b/inc/my.h new file mode 100755 index 0000000..9672fce --- /dev/null +++ b/inc/my.h @@ -0,0 +1,236 @@ +/* @(#) my.h Version 2.15 (2/8/93). copyright venue */ + +/************************************************************************/ +/* */ +/* M Y . H */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#define S_CHARACTER 0x70000 +#ifdef BIGVM +#define IsNumber(address) ((GETWORD(MDStypetbl +(((address) & 0x0fffff00)>>9))) & 0x1000) +#else +#define IsNumber(address) ((GETWORD(MDStypetbl +(((address) & 0x0ffff00)>>9))) & 0x1000) +#endif + + +/************************************************************************/ +/* */ +/* N _ M a k e F l o a t */ +/* */ +/* Get a numeric argument as a flowting-point number, converting */ +/* from SMALLP or FIXP, if necessary. */ +/* */ +/************************************************************************/ +#ifndef I386 +#define N_MakeFloat(arg, dest, tos){ \ + switch (SEGMASK & (LispPTR)arg) { \ + case S_POSITIVE: \ + dest = (float)(0xFFFF & (LispPTR)arg); \ + break; \ + case S_NEGATIVE: \ + dest = (float)((int)(0xFFFF0000 | (LispPTR)arg)); \ + break; \ + default: \ + switch (GetTypeNumber(arg)) { \ + case TYPE_FLOATP: \ + dest = *((float *)Addr68k_from_LADDR(arg)); \ + break; \ + case TYPE_FIXP: \ + dest = (float)(*((int *)Addr68k_from_LADDR(arg))); \ + break; \ + default: ERROR_EXIT(tos); \ + } \ + } \ +} +#else +#define N_MakeFloat(arg, dest, tos){ I386Reset; \ + switch (SEGMASK & (int)arg) { \ + case S_POSITIVE: \ + dest = (float)(0xFFFF & (int)arg); \ + break; \ + case S_NEGATIVE: \ + dest = (float)((int)(0xFFFF0000 | (int)arg)); \ + break; \ + default: \ + switch (GetTypeNumber(arg)) { \ + case TYPE_FLOATP: I386Reset; \ + dest = *((float *)Addr68k_from_LADDR(arg)); \ + break; \ + case TYPE_FIXP: \ + dest = (float)(*((int *)Addr68k_from_LADDR(arg))); \ + break; \ + default: ERROR_EXIT(tos); \ + } \ + } \ +} +#endif /* I386 */ + + + +#define N_GetPos(arg, dest, tos){ \ + if ((arg & SEGMASK) == S_POSITIVE) \ + dest = arg & 0xFFFF; \ + else { \ + if (GetTypeNumber(arg) != TYPE_FIXP) ERROR_EXIT(tos); \ + if ((dest = *((int *)Addr68k_from_LADDR(arg))) & 0x80000000) \ + ERROR_EXIT(tos); \ + } \ + } + +#ifdef OS4 +#define aref_switch(type, tos, baseL, index) \ +{ \ + LispPTR result; \ + DLword *wordp; \ + \ + switch (type) { \ + case 38: /* pointer : 32 bits */ \ + return(*(((int *)Addr68k_from_LADDR(baseL)) + index)); \ + case 20: /* signed : 16 bits */ \ + result = (GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF; \ + if (result & 0x8000) return(result | S_NEGATIVE); \ + else return(result | S_POSITIVE); \ + case 67: /* Character : 8 bits */ \ + return(S_CHARACTER | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF)); \ + case 22: /* signed : 32 bits */ \ + result = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + N_ARITH_SWITCH(result); \ + case 0: /* unsigned : 1 bit per element */ \ + return(S_POSITIVE | (((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + (index >> 3))) >> (7 - (index & 7))) & 1)); \ + case 3: /* unsigned : 8 bits per element */ \ + return(S_POSITIVE | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF)); \ + case 4: /* unsigned : 16 bits per element */ \ + return(S_POSITIVE | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF)); \ + case 54: /* Float : 32 bits */ \ + wordp = createcell68k(TYPE_FLOATP); \ + *((int *)wordp) = *(((int *)Addr68k_from_LADDR(baseL)) + index); \ + return(LADDR_from_68k(wordp)); \ + case 68: /* Character : 16 bits */ \ + return(S_CHARACTER | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF)); \ + case 86: /* XPointer : 32 bits */ \ + return(*(((int *)Addr68k_from_LADDR(baseL)) + index)); \ + default: /* Illegal or Unimplemented */ \ + ERROR_EXIT(tos); \ + }/* end switch typenumber */ \ +} +#else +static LispPTR __inline__ +aref_switch(int type, LispPTR tos, LispPTR baseL, int index) +{ + LispPTR result; + DLword *wordp; + + switch (type) + { + case 38: /* pointer : 32 bits */ + return(*(((LispPTR *)Addr68k_from_LADDR(baseL)) + index)); + case 20: /* signed : 16 bits */ + result = (GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF; + if (result & 0x8000) return(result | S_NEGATIVE); + else return(result | S_POSITIVE); + case 67: /* Character : 8 bits */ + return(S_CHARACTER | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF)); + case 22: /* signed : 32 bits */ + result = *(((LispPTR *)Addr68k_from_LADDR(baseL)) + index); + N_ARITH_SWITCH(result); + case 0: /* unsigned : 1 bit per element */ + return(S_POSITIVE | (((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + (index >> 3))) >> (7 - (index & 7))) & 1)); + case 3: /* unsigned : 8 bits per element */ + return(S_POSITIVE | ((GETBYTE(((char *)Addr68k_from_LADDR(baseL)) + index)) & 0xFF)); + case 4: /* unsigned : 16 bits per element */ + return(S_POSITIVE | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF)); + case 54: /* Float : 32 bits */ + wordp = createcell68k(TYPE_FLOATP); + *((LispPTR *)wordp) = *(((LispPTR *)Addr68k_from_LADDR(baseL)) + index); + return(LADDR_from_68k(wordp)); + case 68: /* Character : 16 bits */ + return(S_CHARACTER | ((GETWORD(((DLword *)Addr68k_from_LADDR(baseL)) + index)) & 0xFFFF)); + case 86: /* XPointer : 32 bits */ + return(*(((LispPTR *)Addr68k_from_LADDR(baseL)) + index)); + default: /* Illegal or Unimplemented */ + ERROR_EXIT(tos); + }/* end switch typenumber */ +} +#endif /* NEVER */ + +#define aset_switch(type, tos) \ +{ \ + switch (type) { \ + case 38: /* pointer : 32 bits */ \ + GCLOOKUP(*(((int *)Addr68k_from_LADDR(base)) + index), DELREF); \ + GCLOOKUP(data, ADDREF); \ + *(((int *)Addr68k_from_LADDR(base)) + index) = data; \ + return(data); \ + case 20: /* signed : 16 bits */ \ + new = data & 0xFFFF; \ + if ((((data & SEGMASK) == S_POSITIVE) && ((data & 0x8000) == 0)) ||\ + (((data & SEGMASK) == S_NEGATIVE) && (data & 0x8000))) \ + GETWORD(((DLword *)Addr68k_from_LADDR(base)) + index) = new; \ + else ERROR_EXIT(tos); \ + return(data); \ + case 67: /* Character : 8 bits */ \ + if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ + new = data & 0xFFFF; \ + if (new > 0xFF) ERROR_EXIT(tos); \ + GETBYTE(((char *)Addr68k_from_LADDR(base)) + index) = new; \ + return(data); \ + case 22: /* signed : 32 bits */ \ + N_GETNUMBER(data, new, doufn); \ + *(((int *)Addr68k_from_LADDR(base)) + index) = new; \ + return(data); \ + case 0: /* unsigned : 1 bit per element */ \ + N_GetPos(data, new, tos); \ + if (new > 1) ERROR_EXIT(tos); \ + if (new) { \ + new = (1 << (7 - (index & 7))); \ + GETBYTE(((char *)Addr68k_from_LADDR(base)) + (index >> 3)) |= new; \ + } \ + else { \ + new = 0xFF - (1 << (7 - (index & 7))); \ + GETBYTE(((char *)Addr68k_from_LADDR(base)) + (index >> 3)) &= new; \ + } \ + return(data); \ + case 3: /* unsigned : 8 bits per element */ \ + N_GetPos(data, new, tos); \ + if (new > 0xFF) ERROR_EXIT(tos); \ + GETBYTE(((char *)Addr68k_from_LADDR(base)) + index) = new; \ + return(data); \ + case 4: /* unsigned : 16 bits per element */ \ + N_GetPos(data, new, tos); \ + if (new > 0xFFFF) ERROR_EXIT(tos); \ + GETWORD(((DLword *)Addr68k_from_LADDR(base)) + index) = new; \ + return(data); \ + case 54: /* Float : 32 bits */ \ + if (GetTypeNumber(data) != TYPE_FLOATP) ERROR_EXIT(tos); \ + *(((int *)Addr68k_from_LADDR(base)) + index) = *((int *)Addr68k_from_LADDR(data)); \ + return(data); \ + case 68: /* Character : 16 bits */ \ + if ((data & SEGMASK) != S_CHARACTER) ERROR_EXIT(tos); \ + new = data & 0xFFFF; \ + GETWORD(((DLword *)Addr68k_from_LADDR(base)) + index) = new; \ + return(data); \ + case 86: /* XPointer : 32 bits */ \ + *(((int *)Addr68k_from_LADDR(base)) + index) = data; \ + return(data); \ + default: /* Illegal or Unimplemented */ \ + ERROR_EXIT(tos); \ + }/* end switch typenumber */ \ +} diff --git a/inc/native.h b/inc/native.h new file mode 100755 index 0000000..44dbaea --- /dev/null +++ b/inc/native.h @@ -0,0 +1,829 @@ +/* $Id: native.h,v 1.2 1999/01/03 02:06:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* ****** + +#include "lispemul.h" +#include "emlglob.h" +#include "address.h" +#include "adr68k.h" +#include "stack.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "cell.h" + +****** */ + +/* ************************************************************************* */ +/* ************** EMULATOR MACROS ************ */ +/* ************************************************************************* */ + + +typedef char ByteCode; +typedef unsigned short DLword; +typedef unsigned int LispPTR; + +typedef struct consstr { + unsigned cdr_code : 8 ; + unsigned car_field : 24 ; + } ConsCell; + +#define CDR_INDIRECT 0 +#define CDR_NIL 128 +#define CDR_ONPAGE 128 + + +struct state{ + DLword *ivar; + DLword *pvar; +}; + +#define ATOM_T 0114 /* T's AtomIndex Number 114Q */ +#define NIL_PTR 0 /* from cell.h 24-mar-87 take */ +#define NOBIND_PTR 1 +#define FRAMESIZE 10 /* size of frameex1: 10 words */ +#define FNHEADSIZE 8 /* size of fnhead: 8 words */ + +#define GET_NATIVE_ADDR(fnobject) \ + *((int *) ((int)fnobject + fnobject->startpc - 4)) + +#define CALL_NATIVE(defcell, num_args) \ + asmgoto(((int *)(GET_NATIVE_ADDR(defcell)))[num_args+(6+2)]); + + +#define CURRENTFX ((struct frameex1 *)((DLword *) PVar - FRAMESIZE)) +#define IVar MachineState.ivar +#define PVar MachineState.pvar + +#define GetLongWord(address) (*((int *) (address))) +#define LADDR_from_68k(ptr68k) (((unsigned int)(ptr68k) - (unsigned int)Lisp_world) >>1) +#define Addr68k_from_LADDR(Lisp_addr) (Lisp_world + (Lisp_addr)) +#define StkOffset_from_68K(ptr68k)\ + (((unsigned int)(ptr68k) - (unsigned int)Stackspace) >>1) + +#define Addr68k_from_StkOffset(stkoffset)\ + (Stackspace + (stkoffset)) +#define POINTER_PAGEBASE(datum) ((datum) & 0x0ffff00) + +#define GetDTD(typnum) (DTDspace + ((typnum)<<4)) +#define GetTypeEntry(address) *(MDStypetbl + ((((int)address) & 0x0ffff00)>>9)) +#define GetTypeNumber(address) ((*(MDStypetbl +((((int)address) & 0x0ffff00)>>9))) & 2047) +#define Listp(address) (GetTypeNumber(address) == TYPE_LISTP) + +#define BF_MARK 0x8000 +#define BF_MARK32 0x80000000 +#define FX_MARK 0xc000 +#define FX_MARK_NATIVE 0xc800 +#define STK_SAFE 32 /* added with stkmin */ + + +struct fnhead{ + DLword stkmin; /* ?? */ + short na; /* Numbers of arguments */ + short pv; /* ?? */ + DLword startpc; + /* head of ByteCodes, DLword offset from stkmin */ + unsigned native :1; /* native translated? */ + unsigned nil1 :1 ; /* not used */ + unsigned argtype : 2; /* ?? */ + unsigned nil2 :4 ; /* not used */ + unsigned framename : 24; /* index in AtomSpace */ + DLword ntsize; /* size of NameTable */ + unsigned nlocals :8; /* ?? */ + unsigned fvaroffset :8; + /* DLword offset from head of NameTable */ + /* NameTable of variavle length is follwing with this structure. */ +}; + + +typedef struct frameex1{ + unsigned flags :3; + unsigned fast :1; + unsigned native :1; /* This frame treats N-func */ + unsigned incall :1; + unsigned validnametable :1; + /* 0: look for FunctionHeader + 1: look for NameTable on this FrameEx */ + unsigned nopush :1; + unsigned usecount :8; + DLword alink; /* alink pointer (Low addr) */ + DLword lofnheader; /* pointer to FunctionHeader (Low addr) */ + unsigned hi1fnheader : 8; /* pointer to FunctionHeader (Hi1 addr) */ + unsigned hi2fnheader : 8; /* pointer to FunctionHeader (Hi2 addr) */ + DLword nextblock; /* pointer to FreeStackBlock */ + DLword pc; /* Program counter */ + DLword lonametable; /* pointer to NameTable of this FrameEx (Low addr) */ + unsigned hi1nametable :8; /* pointer to NameTable of this FrameEx (Hi1 addr) */ + unsigned hi2nametable :8; /* pointer to NameTable of this FrameEx (Hi2 addr) */ + DLword blink; /* blink pointer (Low addr) */ + DLword clink; /* clink pointer (Low addr) */ +} FX ; + +typedef struct frameex2{ + unsigned flags :3; + unsigned fast :1; + unsigned native :1; /* This frame treats N-func */ + unsigned incall :1; + unsigned validnametable :1; + /* 0: look for FunctionHeader + 1: look for NameTable on this FrameEx */ + unsigned nopush :1; + unsigned usecount :8; + DLword alink; /* alink pointer (Low addr) */ + LispPTR fnheader; /* pointer to FunctionHeader (swapped) */ + DLword nextblock; /* pointer to FreeStackBlock */ + DLword pc; /* Program counter */ + LispPTR nativera; /* address of native ra */ + DLword blink; /* blink pointer (Low addr) */ + DLword clink; /* clink pointer (Low addr) */ +} FX2 ; + + + + +typedef struct basic_frame { + unsigned flags : 3 ; + unsigned nil : 3 ; + unsigned residual :1 ; + unsigned padding : 1 ; + unsigned usecnt : 8 ; + DLword ivar ; + +} Bframe ; + + +/* Structure for DTD */ +struct dtd { + DLword dtd_name ; + DLword dtd_size ; + LispPTR dtd_free ; + unsigned unuse :2 ; + unsigned dtd_obsolate :1 ; + unsigned dtd_finalizable :1 ; + unsigned dtd_lockedp : 1 ; + unsigned dtd_hunkp : 1 ; + unsigned dtd_gctype :2 ; + unsigned dtd_descrs : 24; + LispPTR dtd_typespecs ; + LispPTR dtd_ptrs ; + int dtd_oldcnt; + DLword dtd_cnt0 ; + DLword dtd_nextpage ; + DLword dtd_typeentry ; + DLword dtd_supertype ; +}; + + + + +#define TYPE_SMALLP 1 +#define TYPE_FIXP 2 +#define TYPE_FLOATP 3 +#define TYPE_LITATOM 4 +#define TYPE_LISTP 5 +#define TYPE_ARRAYP 6 +#define TYPE_STRINGP 7 +#define TYPE_STACKP 8 +#define TYPE_CHARACTERP 9 +#define TYPE_VMEMPAGEP 10 +#define TYPE_STREAM 11 + +#define TYPE_BITMAP 12 +#define TYPE_COMPILED_CLOSURE 13 +#define TYPE_ONED_ARRAY 14 +#define TYPE_TWOD_ARRAY 15 +#define TYPE_GENERAL_ARRAY 16 + + +typedef struct compiled_closure { + unsigned int nil1 : 8 ; + unsigned int def_ptr : 24; /* function */ + unsigned int nil2 : 8 ; + unsigned int env_ptr : 24; /* environment */ + } CClosure ; + +typedef struct definition_cell { + unsigned ccodep : 1 ; + unsigned fastp : 1 ; + unsigned argtype : 2 ; + unsigned pseudocodep : 1 ; + unsigned nil : 3 ; + unsigned defpointer : 24; + +} DefCell ; + +#define GetDEFCELL68k(index) ((LispPTR *)Defspace + (index) ) +#define GetVALCELL68k(index) ((LispPTR *)Valspace + (index)) + +#define S_POSITIVE 0xE0000 +#define S_NEGATIVE 0xF0000 +#define S_CHARACTER 0x70000 + + +/* ************************************************************************* */ +/* ************** NATIVE ONLY MACROS ************ */ +/* ************************************************************************* */ + + + +/************************************************************************/ +/* TOP OF STACK OPERATIONS */ +/************************************************************************/ + +#define PUSH(x) {*((LispPTR *) CSTKPTR++) = (LispPTR) x;} +#define PUSH16(x) *((DLword *) CSTKPTR++) = x; +#define PUSH16s(x, y) { PUSH16(x); PUSH16(y); } +#define PUSH_SWAPED(x) { register LispPTR temp;\ + temp = x; \ + PUSH16(temp); \ + PUSH16(swapx(temp)); \ + } + + + +#define POP *((LispPTR *) --CSTKPTR) +#define TOS *((LispPTR *) CSTKPTR-1) +#define COPY_TOP TOS +#define SAVE_PUSH_TOP TOS +#define PREV_TOS *((LispPTR *) CSTKPTR-2) +#define GET_POPPED *CSTKPTR +#define GET_POPPED_2 *((LispPTR *) CSTKPTR+1) +#define LSTACK (CSTKPTR - 1) + + +/************************************************************************/ +/* MACROS TO SAVE & RESTORE STATE FOR OP_xx OPCODE ROUTINES */ +/* TO CALL OLD STYLE OPCODE ROUTINE */ +/************************************************************************/ + +#define NATIVE_EXT(call_pc) \ +{ PC = (ByteCode *) call_pc; \ + TopOfStack = POP; \ + CurrentStackPTR = (DLword *) (CSTKPTR-1); \ +} + +#define NATIVE_RET \ +{ CSTKPTR = (LispPTR *) CurrentStackPTR + 1; \ + PUSH(TopOfStack); \ +} + +#define CALL_OP_FN(callpc, nextpc, opcodefn) { \ + NATIVE_EXT(callpc); \ + opcodefn(); \ + NATIVE_RET; \ + if (nextpc != (unsigned int) PC) { \ + QUIT_NATIVE(PC); \ + } \ +} + +/************************************************************************/ +/* RETURN TO DISPATCH TO EXECUTE NEW FRAME */ +/************************************************************************/ + +#define NATIVE_CURRENTFX ((struct frameex1 *)((DLword *) PVAR - FRAMESIZE)) + +#define C_RETURN_TO_DISPATCH \ +{ \ + asmgoto(&c_ret_to_dispatch); \ +} + +/************************************************************************/ +/* RETURN TO DISPATCH TO EXECUTE OPCODE & RETURN TO NATIVE CODE */ +/************************************************************************/ + +#define BCE(ret_pc) { \ + setpc_jmp(ret_pc, &ret_to_unimpl); \ +} + +/************************************************************************/ +/* RETURN TO DISPATCH TO EXECUTE OPCODE & STAY IN EMULATOR */ +/************************************************************************/ + +#define QUIT_NATIVE(ret_pc) \ +{ \ + setpc_jmp(ret_pc, &ret_to_dispatch); \ +} + +/************************************************************************/ +/* RETURN TO DISPATCH TO EXECUTE FN CALL */ +/************************************************************************/ + +#define RETURN_TO_FN_CALL(ret_pc, golabel) \ +{ \ + setpc_jmp(ret_pc, &golabel); \ +} + +/************************************************************************/ +/* RETURN TO DISPATCH TO EXECUTE UFN CALL */ +/************************************************************************/ + +#define CALL_UFN(call_pc, opcode) \ +{ \ + setpc_jmp(call_pc, &ret_to_ufn); \ +} + + +/************************************************************************/ +/* RETURN TO DISPATCH TO EXECUTE TIMER INTERRUPT */ +/************************************************************************/ + +#define RETURN_TO_TIMER(call_pc) \ +{ \ + setpc_jmp(call_pc, &ret_to_timer); \ +} + +/************************************************************************/ +/* STACK OVERFLOW & TIMER CHECKS */ +/************************************************************************/ + +#define STK_MIN(fnobj) ((fnobj->stkmin+STK_SAFE) << 1) + +#define STK_END_COMPUTE(stk_end,fnobj) \ + ( (int)stk_end - STK_MIN(fnobj) ) + + +#define CLR_IRQ \ + {Irq_Stk_Check = STK_END_COMPUTE((Irq_Stk_End = (int) EndSTKP), \ + FuncObj); \ + } + +#define STACK_ONLY_CHECK(stkmin) \ +{ if ((int) CSTKPTR > (EndSTKP - ((stkmin+STK_SAFE) << 1))){ \ + IVar = (DLword *) IVAR; \ + PVar = (DLword *) PVAR; \ + TopOfStack = POP; \ + CurrentStackPTR = (DLword *) (CSTKPTR-1); \ + if (do_stackoverflow(0)) { \ + printf("REAL STACK OVERFLOW\n"); \ + asmgoto(&ret_to_dispatch); \ + } \ + CSTKPTR = (LispPTR *) CurrentStackPTR + 1; \ + PUSH(TopOfStack); \ + IVAR = CSTKPTR + entry_pc; \ + PVAR = (LispPTR *) PVar; \ + } \ +} + +#define TIMER_STACK_CHECK(pc) \ +{ if ( (int) CSTKPTR > Irq_Stk_Check ) {if(pc ==1) {printf("before timer exit\n"); do_brk();} RETURN_TO_TIMER(pc);} } + +/************************************************************************/ +/* FUNCTION ENTRY SETUP */ +/************************************************************************/ + +/* The code generator must expand this differently, depending on + the number of paramaters available to the function. +*/ + +#define framesetup(x, stkmin, swapped_func_obj) { \ + register int NEXTBLOCK; \ + { \ + register struct frameex1 *LocFX; \ + LocFX = NATIVE_CURRENTFX; \ + LocFX->nextblock = NEXTBLOCK = StkOffset_from_68K(IVAR); \ + } \ + IVar = (DLword *) IVAR ; \ + Irq_Stk_Check = ( (int)Irq_Stk_End - ( (stkmin+STK_SAFE) << 1) ); \ + \ + /* Set up BF */ \ + PUSH((BF_MARK << 16) | NEXTBLOCK); \ + PUSH((FX_MARK_NATIVE << 16) | StkOffset_from_68K(PVAR)); \ + PUSH(swapped_func_obj); \ + (DLword *) PVAR = PVar = (DLword *) CSTKPTR = (((DLword *) CSTKPTR) + (FRAMESIZE-4)) ; \ +} /* end framesetup */ + + +/************************************************************************/ +/* FUNCTION CALL & RETURN */ +/************************************************************************/ + +#define fncall_self(args, pc_assign, newpcval, golabel) { \ + NATIVE_CURRENTFX->pc = newpcval; \ + IVAR = CSTKPTR - args; \ + pc_assign; \ + goto golabel; \ +} /* end fncall */ + + +#define newdefcell ((struct fnhead *) DATUM68K) +#define fncall_other(args, call_args, pc_assign, currpc, newpcval, atom_index, fn_def_cell_addr_68K, return_label) {\ + /* register struct fnhead *newdefcell; */ \ + if ( (((DefCell *)fn_def_cell_addr_68K)->ccodep ) && \ + ( newdefcell = (struct fnhead *)Addr68k_from_LADDR( \ + ((DefCell *) fn_def_cell_addr_68K)->defpointer))->native) \ + { \ + NATIVE_CURRENTFX->pc = newpcval; \ + FuncObj = (struct fnhead *)newdefcell; \ + IVAR = CSTKPTR - args; \ + pc_assign; \ + CALL_NATIVE(newdefcell, -call_args); \ + }; \ + RETURN_TO_FN_CALL(currpc, return_label); \ +} /* end fncall */ + + + + +#define envcall_native(retpcval, args, fncell, native_addr_slot, environment) {\ + FuncObj = (struct fnhead *) fncell; \ + native_closure_env = environment; \ + NATIVE_CURRENTFX->pc = retpcval; \ + IVAR = CSTKPTR - args; \ + IF (args > 5) {(int) PC = -args; CALL_NATIVE(fncell, -6);} \ + CALL_NATIVE(fncell, -args); \ +} /* end envcall */ + +#define returnFX ((struct frameex2 *) DATUM68K) + +#define return_op(pcval, swapped_func_obj, ret_result, slow_ret_result) \ +{ \ + /* *** op_return(pcval,swapped_func_obj); */ \ + register DLword alink; \ + alink = NATIVE_CURRENTFX->alink; \ + if ( alink & 1 ) { slow_ret_result; BCE(pcval); } \ + ret_result; /* NOTE: this smashes the BF word if fn called with 0 args */\ + CSTKPTR = IVAR + 1; \ + returnFX = (struct frameex2 *) \ + ((DLword *) \ + (PVAR = (LispPTR *) Addr68k_from_StkOffset(alink)) \ + - FRAMESIZE); \ + IVAR = (LispPTR *) Addr68k_from_StkOffset(*((DLword *)returnFX -1)) ; \ + IVar = (DLword *) IVAR; \ + PVar = (DLword *) PVAR; \ + if (returnFX->native) { \ + if (returnFX->fnheader == swapped_func_obj) \ + {(unsigned int) PC = (unsigned int) returnFX->pc; \ + goto switchlabel; \ + } \ + else \ + {register struct fnhead *newfncell; \ + newfncell = FuncObj = (struct fnhead *) \ + Addr68k_from_LADDR(0x0ffffff & swapx(returnFX->fnheader));\ + CALL_NATIVE(newfncell, (unsigned int) returnFX->pc); \ + } \ + } \ + else \ + {register struct fnhead *LocFnObj; \ + FuncObj = LocFnObj = (struct fnhead *) \ + Addr68k_from_LADDR(0x0ffffff & swapx(returnFX->fnheader)); \ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,LocFnObj); \ + if (((int)(CSTKPTR) > Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + RETURN_TO_TIMER(returnFX->pc + (int) FuncObj); \ + C_RETURN_TO_DISPATCH; \ + } \ +} /* return_op end */ + + +/************************************************************************/ +/* MACORS FOR OPCODES */ +/************************************************************************/ + + +#define MYARGCOUNT \ +( ( ( \ + ( ((NATIVE_CURRENTFX->alink & 1) == 0) \ + ? (int) ((LispPTR *)NATIVE_CURRENTFX - 1) \ + : (int) (Stackspace + NATIVE_CURRENTFX->blink) \ + ) \ + - (int) IVAR) >> 2) ) + +#define N_OP_CHECKAPPLY(tos, abs_pc) { \ + register DefCell *defcell; \ + defcell = (DefCell *) GetDEFCELL68k(tos & 0xffff) ; \ + if (!( defcell->ccodep && ((tos & 0xffff0000) == 0) && \ + ( ( defcell->argtype == 0 ) || ( defcell->argtype == 2 ) ) ) ) \ + BCE(abs_pc); \ +} + +#define N_OP_TYPEMASK(n) \ +( ( ( ((DLword)GetTypeEntry(TEMPREG = TOS)) & (DLword)n) == 0) \ + ? NIL_PTR \ + : TEMPREG \ +) + +#define GETBASE_N(ptr, n)\ + ( *((DLword *)Addr68k_from_LADDR((0xFFFFFF & ptr) + n))) + + +#define GETBASEPTR_N(ptr, n)\ + (0xFFFFFF & *((LispPTR *)Addr68k_from_LADDR((0xFFFFFF & ptr) + n))) + +#define N_OP_PUTBASEPTR_N(tos_1, tos, n) \ + *((LispPTR *)((DLword *)Addr68k_from_LADDR(0xffffff & tos_1) + n)) = tos; + + + +#define N_OP_PUTBASE_N(tos_1, tos, n, error_label) \ +{ \ + if ( ((unsigned short)(swapx(TEMPREG = (LispPTR)tos))) != (S_POSITIVE >> 16)) \ + goto error_label; \ + *((DLword *)Addr68k_from_LADDR(0xffffff & tos_1) + n) = (DLword) TEMPREG; \ +} + +#define N_OP_GETBITS_N_FD(tos, offset, bit_mask, shift_amount) \ + ( \ + (( ( *((DLword *)Addr68k_from_LADDR(0xFFFFFF & tos) + offset)) \ + >> shift_amount ) \ + & bit_mask ) \ + ) + + +#define N_OP_PUTBITS_N_FD(tos_1, tos, offset, bit_mask, shift_amount, error_label)\ +{register LispPTR toscache, base; \ + if ( ((unsigned short)(swapx(toscache = (LispPTR)tos))) != (S_POSITIVE >> 16)) \ + goto error_label; \ + (DLword *) DATUM68K = (DLword *)Addr68k_from_LADDR(base = 0xffffff & tos_1) + offset;\ + *((DLword *)DATUM68K )= \ + ( (toscache << shift_amount) & \ + (bit_mask << shift_amount)) | \ + (*((DLword *)DATUM68K ) & (~(bit_mask << shift_amount)));\ +} + +#define N_OP_GETBASEBYTE(tos_1, tos, error_label) \ +(( ((TEMPREG = (TOS_CACHE = tos) & 0xffff0000) == S_POSITIVE)\ + ? (*((char *) Addr68k_from_LADDR(0xffffff & tos_1) + (unsigned short) TOS_CACHE))\ + :( (TEMPREG == S_NEGATIVE)\ + ? (*((char *) Addr68k_from_LADDR(0xffffff & tos_1) + (0xffff0000 | TOS_CACHE)))\ + :( ( GetTypeNumber(TOS_CACHE) == TYPE_FIXP )\ + ? (*((char *) Addr68k_from_LADDR(0xffffff & tos_1) + \ + *((int *)Addr68k_from_LADDR(TOS_CACHE))))\ + : asmgoto(error_label)\ + )\ + )\ +)) + + +#define N_OP_PUTBASEBYTE(tos_2, tos_1, tos, error_label) \ +{register LispPTR toscache, base; \ + toscache = tos; \ + TEMPREG = tos_1; \ + base = 0xffffff & tos_2; \ + if( ((0xFFFF0000 & toscache ) != S_POSITIVE) || \ + ((unsigned short)toscache >= 256)) \ + goto error_label; \ + switch( (0xFFFF0000 & TEMPREG) ){ \ + case S_POSITIVE: \ + TEMPREG &= 0x0000FFFF; \ + break; \ + case S_NEGATIVE: \ + TEMPREG |= 0xFFFF0000; \ + break; \ + default: \ + goto error_label; \ + } \ + *((char*)Addr68k_from_LADDR(0xFFFFFF & base) + TEMPREG) = \ + 0xFF & toscache; \ +} + +#define N_OP_CAR(tos, error_label) \ + (Listp(TOS_CACHE = tos) \ + ? ( \ + (((ConsCell *) \ + (DATUM68K = (LispPTR *)(Addr68k_from_LADDR(TOS_CACHE))))\ + ->cdr_code == CDR_INDIRECT) \ + ? ((LispPTR) ( ((ConsCell *) \ + Addr68k_from_LADDR( ((ConsCell *)DATUM68K)->car_field))->car_field))\ + : ((LispPTR)(((ConsCell *)DATUM68K)->car_field)) \ + ) \ + : ( (TOS_CACHE == NIL_PTR) \ + ? TOS_CACHE \ + : \ + ( ( TOS_CACHE == ATOM_T) \ + ? TOS_CACHE \ + : asmgoto(error_label) \ + ) \ + ) \ + ) + + +#define N_OP_CDR(tos, error_label) \ + (Listp(TOS_CACHE = tos) \ + ? ( ((TEMPREG = (LispPTR) \ + ( ((ConsCell *) \ + (DATUM68K = ((LispPTR *)(Addr68k_from_LADDR(TOS_CACHE)))))\ + ->cdr_code)) == CDR_NIL) \ + ? (LispPTR) NIL_PTR \ + : (LispPTR) ( (TEMPREG > CDR_ONPAGE) \ + ? \ + /* cdr-samepage */ \ + (POINTER_PAGEBASE(TOS_CACHE) + \ + ((TEMPREG & 127) << 1)) \ + : (LispPTR) ( (TEMPREG == CDR_INDIRECT) \ + ? ((LispPTR) cdr (((ConsCell *)DATUM68K)->car_field)) \ + : (LispPTR) ((ConsCell *)(Addr68k_from_LADDR \ + (POINTER_PAGEBASE(TOS_CACHE) + (TEMPREG << 1))))->car_field\ + ) \ + ) \ + ) \ + : (LispPTR) ( (TOS_CACHE == NIL_PTR) ? NIL_PTR : asmgoto(error_label)) \ + ) + +#define N_OP_CDDR(tos, error_label) \ + (Listp(TOS_CACHE = tos) \ + ? ( ((TEMPREG = (LispPTR) \ + ( ((ConsCell *) \ + (DATUM68K = ((LispPTR *)(Addr68k_from_LADDR(TOS_CACHE)))))\ + ->cdr_code)) == CDR_NIL) \ + ? (LispPTR) NIL_PTR \ + : (LispPTR) ( (TEMPREG > CDR_ONPAGE) \ + ? \ + /* cdr-samepage */ \ + (SAME_PAGE_CDR) \ + : (LispPTR) ( (TEMPREG == CDR_INDIRECT) \ + ? N_OP_CDR(cdr(((ConsCell *)DATUM68K)->car_field),error_label)\ + : N_OP_CDR( \ + ((ConsCell *) \ + (Addr68k_from_LADDR \ + (POINTER_PAGEBASE(TOS_CACHE) + \ + (TEMPREG << 1) \ + ) \ + ) \ + )->car_field \ + , error_label) \ + ) \ + ) \ + ) \ + : (LispPTR) ( (TOS_CACHE == NIL_PTR) ? NIL_PTR : asmgoto(error_label)) \ + ) + +#define SAME_PAGE_CDR \ +/* take CDR of List Cell */ \ +( ((TEMPREG = (LispPTR) \ + ( ((ConsCell *) \ + (DATUM68K = (LispPTR *) \ + (((int)DATUM68K & 0xfffffe00) | \ + (((int) TEMPREG & 127) << 2)) \ + )) \ + ->cdr_code)) == CDR_NIL) \ + ? (LispPTR) NIL_PTR \ + : (LispPTR) ( (TEMPREG > CDR_ONPAGE) \ + ? /* cdr-samepage */ \ + (POINTER_PAGEBASE(TOS_CACHE) + \ + ((TEMPREG & 127) << 1)) \ + : (LispPTR) ( (TEMPREG == CDR_INDIRECT) \ + ? ((LispPTR) cdr (((ConsCell *)DATUM68K)->car_field)) \ + : (LispPTR) ((ConsCell *)(Addr68k_from_LADDR \ + (POINTER_PAGEBASE(TOS_CACHE) + (TEMPREG << 1))))->car_field\ + ) \ + ) \ +) + + +#define N_OP_FVAR(slot, dl_slot) \ +( GetLongWord(Addr68k_from_LADDR(swapx( \ + ( ( ((DLword *)PVAR)[dl_slot] & 1 ) \ + ? native_newframe(slot) \ + : PVAR[slot] \ +))))) + + +#define N_OP_UNBIND(tos) \ +/* {register LispPTR SAVE_TOS = tos; CSTKPTR = (LispPTR *) N_OP_unbind(CSTKPTR); PUSH(SAVE_TOS);} */ \ + nop_unbind(tos); + +#define N_OP_DUNBIND \ +/* { CSTKPTR = (LispPTR *) N_OP_dunbind(CSTKPTR); } THIS MAY NOT WORK */ \ + nop_dunbind(); + +#define N_OP_CLARITHEQUAL(tos_1, tos, error_addr) \ +( (((TEMPREG = tos) & 0xfffe0000) == (S_POSITIVE & 0xfffe0000)) \ + ? ((TEMPREG == tos_1) ? ATOM_T : NIL_PTR) \ + : ((((int) DATUM68K = GetTypeNumber(TEMPREG)) == TYPE_FIXP)\ + ? ((TEMPREG == tos_1) ? ATOM_T : NIL_PTR) \ + : (((int) DATUM68K == TYPE_FLOATP) \ + ? ((TEMPREG == tos_1) ? ATOM_T : NIL_PTR) \ + : (N_OP_eqq(tos_1, TEMPREG, error_addr)) \ + ) \ + ) \ +) + +#define N_OP_CLEQUAL_ILEQL(tos_1, tos, error_addr, op_function) \ +( (((TOS_CACHE = tos) & 0xfffe0000) <= (S_POSITIVE & 0xfffe0000)) \ + ? ((TOS_CACHE == tos_1) ? ATOM_T : NIL_PTR) \ + :( (((TEMPREG = tos_1) & 0xfffe0000) <= \ + (S_POSITIVE & 0xfffe0000)) \ + ? ((TOS_CACHE == TEMPREG) ? ATOM_T : NIL_PTR) \ + : op_function(TEMPREG, TOS_CACHE, error_addr) \ + ) \ +) + +#define N_OP_EQUAL(tos_1, tos, error_addr) \ +( (((TOS_CACHE = tos) & 0xffff0000) <= S_CHARACTER) \ + ? ((TOS_CACHE == tos_1) ? ATOM_T : NIL_PTR) \ + :( (((TEMPREG = tos_1) & 0xffff0000) <= S_CHARACTER) \ + ? ((TOS_CACHE == TEMPREG) ? ATOM_T : NIL_PTR) \ + : N_OP_equal(TEMPREG, TOS_CACHE, error_addr) \ + ) \ +) + + +#define N_OP_DTEST(atom_index, exit_pc, opcode) \ +{ /* must have stack up to date */ \ + register struct dtd *dtd68k ; \ + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(TOS)); \ + atom_index != dtd68k->dtd_name ; \ + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) \ + { \ + if( dtd68k->dtd_supertype == 0) \ + { \ + CALL_UFN(exit_pc, opcode); \ + } \ + } \ +} + +#ifdef sun3 + /* these take advantage of the Shift Amount Register d5 */ +#define NSMALLP_RANGE(x) nop_nsmallp_range(x) +#define SMALLP_UNBOX(x) nop_smallp_unbox(x) +#define SMALL_BOX(x) nop_smallp_box(x) +#else +#define NSMALLP_RANGE(x) (((int)((int)x << 15) >> 15) ^ x) +#define SMALLP_UNBOX(x) ( (int) (x << 15) >> 15) +#define SMALL_BOX(x) (((unsigned int)(x << 15) >> 15) | S_POSITIVE) +#endif + +#define NSMALLP(x) (((x) >> 17) ^ 7) +#define MAKE_BOX(type, value) Create_n_Set_Cell(type, value) +#define GET_BOX(type, laddr) (* ((type *) (Addr68k_from_LADDR(laddr)))) + +#define FIXP_UNBOX(value) \ +( NSMALLP((TEMPREG = value)) \ + ? GET_BOX(int, TEMPREG) \ + : SMALLP_UNBOX(TEMPREG) \ +) + +#define FIXP_UNBOX_UFN(value, errorlabel) \ +( NSMALLP((TEMPREG = value)) \ + ?( (GetTypeNumber(TEMPREG) == TYPE_FIXP) \ + ?GET_BOX(int, TEMPREG) \ + :asmgoto(errorlabel) \ + ) \ + : SMALLP_UNBOX(TEMPREG) \ +) + + +#define FLOATP_UNBOX(value) \ + GET_BOX(floatvalue) + + +#define FIXP_BOX(x) \ +( NSMALLP_RANGE((TEMPREG = x)) \ + ? MAKE_BOX(TYPE_FIXP, TEMPREG) \ + : SMALL_BOX(TEMPREG) \ +) + +#define FLOATP_BOX(x) Create_n_Set_Cell(TYPE_FLOATP, x) + + +/************************************************************************/ +/* EXTERNAL ENTRY POINTS */ +/************************************************************************/ + +extern DLword *Atomspace; /* ATOMSPACE */ +extern DLword *Stackspace; /* STACKSPACE*/ +extern DLword *Defspace; /* DEFSPACE */ +extern DLword *Valspace; /* VALSPACE */ +extern DLword *Lisp_world; /* Lisp Start BASE */ +extern DLword *MDStypetbl; +extern DLword *DTDspace; /* DTDSPACE */ + +extern DLword *CurrentStackPTR; /* rhS,S */ +extern LispPTR TopOfStack ; /* TOSH(high 16),TOS (lo 16) */ +extern LispPTR Scratch_CSTK ; +extern ByteCode *PC; /* Pointer to executing Byte Code */ +extern struct state MachineState; +extern struct fnhead *FuncObj; /* Pointer to current ccode obj */ +extern int EndSTKP; /* End of Current Frame */ + +extern int *c_ret_to_dispatch; +extern int *ret_to_dispatch; +extern int *ret_to_unimpl; +extern int *ret_to_timer; +extern int *ret_to_fn0; +extern int *ret_to_fn1; +extern int *ret_to_fn2; +extern int *ret_to_fn3; +extern int *ret_to_fn4; +extern int *ret_to_fnx; +extern int *ret_to_apply; +extern int *ret_to_envcall; +extern int *ret_to_ufn; + +extern int Irq_Stk_End; +extern int Irq_Stk_Check; +extern LispPTR native_closure_env; + diff --git a/inc/nfsfh.h b/inc/nfsfh.h new file mode 100755 index 0000000..d8093a8 --- /dev/null +++ b/inc/nfsfh.h @@ -0,0 +1,43 @@ +/* $Id: nfsfh.h,v 1.2 1999/01/03 02:06:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* + * + * nfsfh.h - NFS file handle definitions (for portable use) + * + * Jeffrey C. Mogul + * Digital Equipment Corporation + * Western Research Laboratory + * + * $Log: nfsfh.h,v $ + * Revision 1.2 1999/01/03 02:06:18 sybalsky + * Add ID comments / static to files for CVS use + * + * Revision 1.1.1.1 1998/12/17 05:03:18 sybalsky + * Import of Medley 3.5 emulator + * + * Revision 1.1 93/10/01 16:09:01 mogul + * Initial revision + * + */ + +/* + * Internal representation of dev_t, because different NFS servers + * that we might be spying upon use different external representations. + */ +typedef struct { + u_long Minor; /* upper case to avoid clashing with macro names */ + u_long Major; +} my_devt; + +#define dev_eq(a,b) ((a.Minor == b.Minor) && (a.Major == b.Major)) + +/* + * Many file servers now use a large file system ID. This is + * our internal representation of that. + */ +typedef struct { + my_devt fsid_dev; + u_long fsid_code; +} my_fsid; + +#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\ + dev_eq(a.fsid_dev, b.fsid_dev)) diff --git a/inc/nfswatch.h b/inc/nfswatch.h new file mode 100755 index 0000000..f659596 --- /dev/null +++ b/inc/nfswatch.h @@ -0,0 +1,430 @@ +/* $Id: nfswatch.h,v 1.2 1999/01/03 02:06:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* + * $Header: /disk/disk3/cvsroot/medley/inc/nfswatch.h,v 1.2 1999/01/03 02:06:18 sybalsky Exp $ + * + * nfswatch.h - definitions for nfswatch. + * + * David A. Curry Jeffrey C. Mogul + * Purdue University Digital Equipment Corporation + * Engineering Computer Network Western Research Laboratory + * 1285 Electrical Engineering Building 250 University Avenue + * West Lafayette, IN 47907-1285 Palo Alto, CA 94301 + * davy@ecn.purdue.edu mogul@decwrl.dec.com + * + * $Log: nfswatch.h,v $ + * Revision 1.2 1999/01/03 02:06:18 sybalsky + * Add ID comments / static to files for CVS use + * + * Revision 1.1.1.1 1998/12/17 05:03:18 sybalsky + * Import of Medley 3.5 emulator + * + * Revision 4.8 1996/02/12 13:22:29 davy + * Updated version number. + * + * Revision 4.7 1995/03/20 01:07:34 davy + * Upped version number. + * + * Revision 4.6 1995/03/20 01:05:20 davy + * Fixed int32 declaration. + * + * Revision 4.5 1993/11/30 21:55:38 davy + * Upgraded version number. + * + * Revision 4.4 1993/10/01 14:56:51 mogul + * Bugfix to compile on SunOS + * + * Revision 4.3 93/10/01 10:45:54 mogul + * Revert to int32, u_int32 names + * + * Revision 4.2 93/09/30 20:33:44 davy + * Increased MAXCLIENTS, MAXEXPORTS, MAXAUTHS. + * Fixed the int32 and u_int32 type names for portability. + * + * Revision 4.1 1993/09/28 21:27:40 mogul + * Portable internal representation for file handle info + * explicit 32-bit data types + * explicit data type for IP addresses + * + * Revision 4.0 1993/03/01 19:59:00 davy + * NFSWATCH Version 4.0. + * + * Revision 3.9 1993/02/24 17:44:45 davy + * Added -auth mode, changes to -proc mode, -map option, -server option. + * + * Revision 3.8 1993/01/16 19:12:54 davy + * Moved cpp controls to left margin. + * + * Revision 3.7 1993/01/16 19:08:59 davy + * Corrected Jeff's address. + * + * Revision 3.6 1993/01/15 19:33:39 davy + * Miscellaneous cleanups. + * + * Revision 3.5 1993/01/15 15:43:36 davy + * Assorted changes for porting to Solaris 2.x/SVR4. + * + * Revision 3.4 1993/01/13 21:24:40 davy + * Portability change. + * + * Revision 3.3 1993/01/13 20:18:17 davy + * Put in OS-specific define scheme, and merged in Tim Hudson's code for + * SGI systems (as yet untested). + * + * Revision 3.2 1992/07/24 18:49:09 mogul + * Changed version number to 3.1 + * + * Revision 3.1 1992/07/24 18:47:57 mogul + * Added FDDI support + * + * Revision 3.0 1991/01/23 08:23:13 davy + * NFSWATCH Version 3.0. + * + * Revision 1.4 91/01/17 10:12:29 davy + * New features from Jeff Mogul. + * + * Revision 1.6 91/01/07 15:34:42 mogul + * Support for client hash table + * + * Revision 1.5 91/01/07 14:10:01 mogul + * Added SHOWHELP, SHOW_MAXCODE + * + * Revision 1.4 91/01/04 14:12:11 mogul + * Support for client counters + * + * Revision 1.3 91/01/03 17:38:18 mogul + * Support for per-procedure counters + * + * Revision 1.2 90/08/17 15:47:04 davy + * NFSWATCH Version 2.0. + * + * Revision 1.1 88/11/29 11:20:28 davy + * NFSWATCH Release 1.0 + * + */ + +/* + * Version number. + */ +#define VERSION "4.3 of 12 February 1996" + +/* + * Stuff for representing NFS file handles + */ +#include "nfsfh.h" + +/* + * General definitions. + */ +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +/* + * Declarations of several data types that must be 32 bits wide, + * no matter what machine we are running on. "long" is unsafe + * because on DEC Alpha machines that means 64 bits. "int" is + * unsafe because on some machines that means 16 bits. + * + * Use int32 or u_int32 whenever you mean "32 bits" and not + * "some large number of bits". + * + * NEVER use int or int32 or u_int32 (or, for that matter, long) + * when the variable might contain a pointer value. + */ +#if defined(pdp11) +/* other 16-bit machines? */ +typedef long int32; +typedef unsigned long u_int32; +#else +/* works almost everywhere */ +#if !defined(SUNOS54) + /* SunOS 5.4 declares int32 in */ +typedef int int32; +#endif +#if !defined(U_INT32_DECLARED_IN_AUTH) || !defined(AUTH_UNIX) + /* SunOS declares u_int32 in */ +typedef unsigned int u_int32; +#endif +#endif + +/* Define a specific type for representing IP addresses */ +typedef u_int32 ipaddrt; + +#ifdef SVR4 +#define MOUNTTABLE "/etc/mnttab" /* mounted file systems */ +#define SHARETAB "/etc/dfs/sharetab" /* shared file systems */ +#endif + +#define PROMPT "nfswatch>" /* prompt string */ +#define LOGFILE "nfswatch.log" /* log file name */ +#define MAXEXPORT 1024 /* max exported file systems */ +#define CYCLETIME 10 /* screen update cycle time */ +#define PACKETSIZE 4096 /* max size of a packet */ +#define MAXNFSPROC 18 /* max number of NFS procedures */ +#define MAXHOSTADDR 16 /* max. network addrs per host */ +#define MAXCLIENTS 1024 /* max. # of client counters */ + /* MUST be even number */ +#define MAXAUTHS 1024 /* max. # of auth counters */ + /* MUST be even number */ +#define MAXINTERFACES 16 /* Max. number of interfaces */ +#define SNAPSHOTFILE "nfswatch.snap" /* snapshot file name */ + +#define SHOWINDVFILES 1 /* show individual files */ +#define SHOWFILESYSTEM 2 /* show NFS file systems */ +#define SHOWNFSPROCS 3 /* show NFS procedure counts */ +#define SHOWCLIENTS 4 /* show client host names */ +#define SHOWAUTH 5 /* show authorizations */ +#define SHOWHELP 6 /* show help text */ +#define SHOW_MAXCODE 6 /* number of different displays */ + +/* + * Network Interface Tap (NIT) definitions. + */ +#ifdef USE_NIT +#define NIT_DEV "/dev/nit" /* network interface tap device */ +#define NIT_BUF "nbuf" /* nit stream buffering module */ +#define NIT_CHUNKSIZE 8192 /* chunk size for grabbing pkts */ +#endif + +/* + * Pfilt definitions. + */ +#ifdef USE_PFILT +#define PFILT_CHUNKSIZE 8192 /* chunk size for grabbing pkts */ +#endif + +/* + * Snoop definitions. + */ +#ifdef USE_SNOOP +#define SNOOP_BUFFER_SIZE (55 * 1024) /* for grabbing packets */ +#endif + +/* + * Data Link Provider Interface (DLPI) definitions. + */ +#ifdef USE_DLPI +#define DLPI_DEVDIR "/dev/" /* path to device dir */ +#define DLPI_BUFMOD "bufmod" /* streams buffering */ +#define DLPI_MAXWAIT 15 /* max timeout */ +#define DLPI_MAXDLBUF 8192 /* buffer size */ +#define DLPI_MAXDLADDR 1024 /* max address size */ +#define DLPI_CHUNKSIZE (8192 * sizeof(long)) /* buffer size */ +#define DLPI_DEFAULTSAP 0x0800 /* IP protocol */ +#endif /* USE_DLPI */ + +/* + * Packet counter definitions. + */ +#define PKT_NCOUNTERS 16 /* number of packet counters */ + +#define PKT_NDREAD 0 /* ND read requests */ +#define PKT_NDWRITE 1 /* ND write requests */ +#define PKT_NFSREAD 2 /* NFS read requests */ +#define PKT_NFSWRITE 3 /* NFS write requests */ +#define PKT_NFSMOUNT 4 /* NFS mount requests */ +#define PKT_YELLOWPAGES 5 /* Yellow Pages requests */ +#define PKT_RPCAUTH 6 /* RPC authorization requests */ +#define PKT_OTHERRPC 7 /* other RPC requests */ +#define PKT_TCP 8 /* TCP packets */ +#define PKT_UDP 9 /* UDP packets */ +#define PKT_ICMP 10 /* ICMP packets */ +#define PKT_ROUTING 11 /* routing control packets */ +#define PKT_ARP 12 /* address resolution packets */ +#define PKT_RARP 13 /* reverse addr resol packets */ +#define PKT_BROADCAST 14 /* ethernet broadcast packets */ +#define PKT_OTHER 15 /* none of the above packets */ + +typedef unsigned long Counter; + +/* + * Packet counting structure. + */ +typedef struct { + char *pc_name; /* name of counter */ + + Counter pc_interval; /* packets this interval */ + Counter pc_total; /* packets since start */ + + short pc_intx, pc_inty; /* screen coords of pc_interval */ + short pc_totx, pc_toty; /* screen coords of pc_total */ + short pc_pctx, pc_pcty; /* screen coords of percentage */ + short pc_namex, pc_namey; /* screen coords of pc_name */ +} PacketCounter; + +/* + * NFS request counting structure. + */ +typedef struct { + my_devt nc_dev; /* device numbers of file sys */ + my_fsid nc_fsid; /* for "learning" file systems */ + ipaddrt nc_ipaddr; /* keep track of server address */ + char *nc_name; /* name of file system */ + + Counter nc_total; /* requests since start */ + Counter nc_interval; /* requests this interval */ + Counter nc_proc[MAXNFSPROC]; /* each nfs proc counters */ + + short nc_intx, nc_inty; /* screen coords of nc_interval */ + short nc_totx, nc_toty; /* screen coords of nc_total */ + short nc_pctx, nc_pcty; /* screen coords of percentage */ + short nc_namex, nc_namey; /* screen coords of nc_name */ +} NFSCounter; + +/* + * Specific file request counting structure. + */ +typedef struct { + my_devt fc_dev; /* device number of file sys */ + ino_t fc_ino; /* inode number of file */ + char *fc_name; /* file name */ + + Counter fc_total; /* requests since start */ + Counter fc_interval; /* requests this interval */ + Counter fc_proc[MAXNFSPROC]; /* each nfs proc counters */ + + short fc_intx, fc_inty; /* screen coords of fc_interval */ + short fc_totx, fc_toty; /* screen coords of fc_total */ + short fc_pctx, fc_pcty; /* screen coords of percentage */ + short fc_namex, fc_namey; /* screen coords of fc_name */ +} FileCounter; + +/* + * Per-procedure counting structure. + */ +typedef struct { + int pr_type; /* procedure type */ + char *pr_name; /* procedure name */ + Counter pr_total; /* requests since start */ + Counter pr_interval; /* requests this interval */ + + Counter pr_complete; /* requests with replies */ + double pr_response; /* sum of all response times */ + double pr_respsqr; /* sum of squares of resp times */ + double pr_maxresp; /* maximum response time */ + + short pr_intx, pr_inty; /* screen coords of pr_interval */ + short pr_totx, pr_toty; /* screen coords of pr_total */ + short pr_pctx, pr_pcty; /* screen coords of percentage */ + short pr_namex, pr_namey; /* screen coords of pr_name */ + + short pr_compx, pr_compy; /* screen coords of pr_complete */ + short pr_respx, pr_respy; /* screen coords of pr_response */ + short pr_rsqrx, pr_rsqry; /* screen coords of pr_respsqr */ + short pr_rmaxx, pr_rmaxy; /* screen coords of pr_maxresp */ +} ProcCounter; + +/* + * NFS client counting structure. + */ +typedef struct _cl_ { + ipaddrt cl_ipaddr; /* client IP address */ + char *cl_name; /* name of client system */ + + Counter cl_total; /* requests since start */ + Counter cl_interval; /* requests this interval */ + + short cl_intx, cl_inty; /* screen coords of cl_interval */ + short cl_totx, cl_toty; /* screen coords of cl_total */ + short cl_pctx, cl_pcty; /* screen coords of percentage */ + short cl_namex, cl_namey; /* screen coords of cl_name */ + + struct _cl_ *cl_next; /* hash chain link */ +} ClientCounter; + +/* + * NFS authentication counting structure. + */ +typedef struct _ac_ { + long ac_uid; /* authorization type */ + char *ac_name; /* name of user id */ + + Counter ac_total; /* requests since start */ + Counter ac_interval; /* requests this interval */ + + short ac_intx, ac_inty; /* screen coords of ac_interval */ + short ac_totx, ac_toty; /* screen coords of ac_total */ + short ac_pctx, ac_pcty; /* screen coords of percentage */ + short ac_namex, ac_namey; /* screen coords of ac_name */ + + struct _ac_ *ac_next; /* hash chain link */ +} AuthCounter; + +/* + * NFS call structure, for remembering relevant timing information. + */ +#define NFSCALLHASHSIZE 255 + +typedef struct _nc_ { + int used; + ipaddrt client; + u_short clientport; + u_int32 xid; + u_long proc; + u_long time_sec; + u_long time_usec; +} NFSCall; + +/* + * Device type definitions (borrowed from the Berkeley Packet Filter) + */ +#ifndef DLT_NULL +#define DLT_NULL 0 /* no link-layer encapsulation */ +#define DLT_EN10MB 1 /* Ethernet (10Mb) */ +#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ +#define DLT_AX25 3 /* Amateur Radio AX.25 */ +#define DLT_PRONET 4 /* Proteon ProNET Token Ring */ +#define DLT_CHAOS 5 /* Chaos */ +#define DLT_IEEE802 6 /* IEEE 802 Networks */ +#define DLT_ARCNET 7 /* ARCNET */ +#define DLT_SLIP 8 /* Serial Line IP */ +#define DLT_PPP 9 /* Point-to-point Protocol */ +#define DLT_FDDI 10 /* FDDI */ +#endif + +/* + * Definitions for earlier systems which don't have these from 4.3BSD. + */ +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + +#ifndef NFDBITS +typedef long fd_mask; + +#define NFDBITS (sizeof(fd_mask) * NBBY) + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_ZERO(p) (void) bzero((char *)(p), sizeof(*(p))) +#endif /* NFDBITS */ + + + + +/* + * Maximum control/data buffer size (in long's !!) for getmsg(). + */ +#define MAXDLBUF 8192 + +/* + * Maximum number of seconds we'll wait for any + * particular DLPI acknowledgment from the provider + * after issuing a request. + */ +#define MAXWAIT 15 + +/* + * Maximum address buffer length. + */ +#define MAXDLADDR 1024 + + +/* + * Handy macro. + */ +#define OFFADDR(s, n) (u_char*)((char*)(s) + (int)(n)) + diff --git a/inc/ocr.h b/inc/ocr.h new file mode 100755 index 0000000..4dea9e8 --- /dev/null +++ b/inc/ocr.h @@ -0,0 +1,259 @@ +/* $Id: ocr.h,v 1.2 1999/01/03 02:06:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifdef OCR + +extern int OCR_sock; +extern int OCR_sv; +extern int OCR_fd; +extern int OCR_procID; + +/* + * Device file for OCR + */ + +#define OCRDEV "/dev/ocr0" + +/* + * SUBR_OCR_COMM alpha byte + */ + +#define DO_OPEN 0 +#define DO_SCAN 1 +#define DO_IMG_INFO 2 +#define DO_IMG_UPLD 3 +#define DO_SET_RPARA 4 +#define DO_CLR_RPARA 5 +#define DO_READ 6 +#define DO_READ_INFO 7 +#define DO_GET_RESULT 8 +#define DO_ABORT 9 +#define DO_CLOSE 10 +#define DO_CODE_CONV 11 +#define DO_TEST 12 + +/* + * OCR state indicated in IL:\OCR.STATE.FLAGS + */ + +#define OCR_ST_FAIL 1 +#define OCR_ST_SCANNING 2 +#define OCR_ST_UPLDING 3 +#define OCR_ST_PROC_DEAD 4 +#define OCR_ST_READING 5 + + +/* + * OCR SCAN parameter. In Lisp, BLOCKRECORD OCR.SCAN.PARAMS + */ + +struct ocr_scan_para { + u_char size : 3, + direction : 1, + dencity : 3, + binary : 1; + u_char resolution : 3, + adf : 1, + filter : 1, + threshold : 3; + u_char noise : 3, + doc : 1, + smooth : 1, + compo : 3; +}; + +#define OCR_SIZE_A4 0 +#define OCR_SIZE_B4 1 +#define OCR_SIZE_A5 2 +#define OCR_SIZE_B5 3 +#define OCR_SIZE_LG 4 +#define OCR_SIZE_LT 5 + +#define OCR_DIRECT_VT 0 +#define OCR_DIRECT_HR 1 + +#define OCR_RES_200 0 +#define OCR_RES_240 1 +#define OCR_RES_300 2 +#define OCR_RES_400 3 + +#define OCR_DENC_0 0 +#define OCR_DENC_1 1 +#define OCR_DENC_2 2 +#define OCR_DENC_3 3 +#define OCR_DENC_4 4 +#define OCR_DENC_5 5 +#define OCR_DENC_6 6 +#define OCR_DENC_7 7 + +#define OCR_SCANNER_FL 0 +#define OCR_SCANNER_AD 1 + +#define OCR_FILTER_NR 0 +#define OCR_FILTER_BP 1 + +#define OCR_THRES_0 0 +#define OCR_THRES_1 1 +#define OCR_THRES_2 2 +#define OCR_THRES_3 3 +#define OCR_THRES_4 4 +#define OCR_THRES_5 5 + +#define OCR_NOISE_0 0 +#define OCR_NOISE_2 1 +#define OCR_NOISE_3 2 +#define OCR_NOISE_4 3 +#define OCR_NOISE_5 4 + +#define OCR_DOC_NR 0 +#define OCR_DOC_NW 1 + +#define OCR_SMTH_CH 0 +#define OCR_SMTH_IM 1 + +#define OCR_COMPO_LD 0 +#define OCR_COMPO_PN 1 +#define OCR_COMPO_PH 2 +#define OCR_COMPO_PL 3 + +/* + * OCR Image Info structure. In Lisp, BLOCKRECORD OCR.IMG.INFO + * On SPARC, the size of this structure is 20. + */ + +struct ocr_image_info { + u_short xs; + u_short ys; + u_short xe; + u_short ye; + u_short line_width; + u_int size; + u_char resolution : 3, + compress : 3, + : 2; +}; + +/* + * OCR Image Upload parameter. In Lisp, BLOCKRECORD OCR.IMG.UPLD.PARA + * On SPARC, the size of this structure is 10. + */ + +struct ocr_up_para { + u_short xs; + u_short ys; + u_short xe; + u_short ye; + u_char resolution : 3, + compress : 3, + : 2; +}; + +#define OCR_COMP_NONE 0 +#define OCR_COMP_2 1 +#define OCR_COMP_4 2 +#define OCR_COMP_8 3 + +/* + * Maximum number of regions to read per page + */ + +#define OCR_MAX_RD_PARAMS 200 + +/* + * OCR Read Parameter. In Lisp, BLOCKRECORD OCR.IMG.READ.PARA + * On SPARC, the size of this structure is 14. + */ + +struct ocr_read_para { + u_short xs; + u_short ys; + u_short xe; + u_short ye; + u_char format; + u_char csize; + u_char reject; + u_char cunit : 2, + deform : 4, + : 2; + u_char ck_num : 1, + ck_alph : 1, + ck_grk : 1, + ck_jvt : 1, + ck_jhr : 1, + ck_sym : 1, + ck_kana : 1, + ck_joyou : 1; + u_char ck_jis1 : 1, + ck_jmisc : 1, + ck_gaiji : 1, + : 5; +}; + +#define OCR_FMT_H1 0 +#define OCR_FMT_H2 1 +#define OCR_FMT_H3 2 +#define OCR_FMT_H4 3 +#define OCR_FMT_V1 4 +#define OCR_FMT_V2 5 +#define OCR_FMT_V3 6 +#define OCR_FMT_V4 7 + +#define OCR_CUNIT_PO 0 +#define OCR_CUNIT_KY 1 +#define OCR_CUNIT_MM 2 + +#define OCR_REJ_0 0 +#define OCR_REJ_1 1 +#define OCR_REJ_2 2 +#define OCR_REJ_3 3 +#define OCR_REJ_4 4 +#define OCR_REJ_5 5 + +#define OCR_DFRM_1 0 +#define OCR_DFRM_2 1 +#define OCR_DFRM_3 2 +#define OCR_DFRM_4 3 +#define OCR_DFRM_NR 4 +#define OCR_DFRM_6 5 +#define OCR_DFRM_7 6 +#define OCR_DFRM_8 7 +#define OCR_DFRM_9 8 + +/* + * Header for bulk data transfer + */ + +struct bd_header { + u_int len; + u_int cont; +}; + +#define BD_LAST 0 +#define BD_CONT 1 + +/* + * The comm/res packet length used by OCR process + */ + +#define PKTLEN 3 +#define EPKTLEN 65536 + +#endif /* OCR */ + diff --git a/inc/opcodes.h b/inc/opcodes.h new file mode 100755 index 0000000..7e23984 --- /dev/null +++ b/inc/opcodes.h @@ -0,0 +1,44 @@ +/* $Id: opcodes.h,v 1.2 1999/01/03 02:06:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/************************************************************************/ +/* */ +/* O P C O D E D E F I N I T I O N S */ +/* */ +/* Symbolic equivalents for Lisp Opcodes */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +#define opc_X 000 +#define opc_CAR 001 +#define opc_CDR 002 +#define opc_LISTP 003 +#define opc_NTYPEX 004 +#define opc_TYPEP 005 +#define opc_UNWIND 007 +#define opc_FN0 010 +#define opc_FN1 011 +#define opc_FN2 012 +#define opc_FN3 013 +#define opc_FN4 014 +#define opc_FNX 015 +#define opc_APPLY 016 +#define opc_RETURN 020 +#define opc_UNBIND 022 +#define opc_DUNBIND 023 +#define opc_SLRETURN 077 +#define opc_JUMP 0200 +#define opc_FJUMP 0220 +#define opc_TJUMP 0240 +#define opc_JUMPX 0260 +#define opc_JUMPXX 0261 diff --git a/inc/os.h b/inc/os.h new file mode 100755 index 0000000..c38c701 --- /dev/null +++ b/inc/os.h @@ -0,0 +1,126 @@ +/* $Id: os.h,v 1.2 1999/01/03 02:06:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* + * + * os.h - operating system definitions. + * + * David A. Curry Jeffrey C. Mogul + * Purdue University Digital Equipment Corporation + * Engineering Computer Network Western Research Laboratory + * 1285 Electrical Engineering Building 250 University Avenue + * West Lafayette, IN 47907-1285 Palo Alto, CA 94301 + * davy@ecn.purdue.edu mogul@decwrl.dec.com + * + * $Log: os.h,v $ + * Revision 1.2 1999/01/03 02:06:19 sybalsky + * Add ID comments / static to files for CVS use + * + * Revision 1.1.1.1 1998/12/17 05:03:18 sybalsky + * Import of Medley 3.5 emulator + * + * Revision 4.5 1996/02/12 13:20:26 davy + * Updated for Solaris 2.5 + * + * Revision 4.4 1993/10/13 01:13:25 mogul + * IRIX40 fix + * + * Revision 4.3 1993/10/01 14:56:38 mogul + * Bugfix to compile on SunOS + * + * Revision 4.2 93/10/01 10:45:55 mogul + * Revert to int32, u_int32 names + * + * Revision 4.1 93/09/28 21:17:14 mogul + * Added support for DECOSF + * + * Revision 4.0 1993/03/01 19:59:00 davy + * NFSWATCH Version 4.0. + * + * Revision 1.6 1993/01/16 19:12:54 davy + * Moved cpp controls to left margin. + * + * Revision 1.5 1993/01/16 19:08:59 davy + * Corrected Jeff's address. + * + * Revision 1.4 1993/01/15 19:33:39 davy + * Miscellaneous cleanups. + * + * Revision 1.3 1993/01/13 21:41:37 davy + * Got rid of old IRIX versions. + * + * Revision 1.2 1993/01/13 21:24:54 davy + * Added IRIX40. + * + * Revision 1.1 1993/01/13 20:18:17 davy + * Initial revision + * + */ +#ifdef IRIX40 +#ifndef USE_SNOOP +#define USE_SNOOP 1 +#endif +#define signal sigset +#define U_INT32_DECLARED_IN_AUTH 1 +#endif + +#ifdef SUNOS4 +#ifndef USE_NIT +#define USE_NIT 1 +#endif +#define U_INT32_DECLARED_IN_AUTH 1 +#endif + +#ifdef OS5 +#ifndef SVR4 +#define SVR4 1 +#endif +#ifndef USE_DLPI +#define USE_DLPI 1 +#endif +#define U_INT32_DECLARED_IN_AUTH 1 +#endif + +#ifdef SUNOS5 +#ifndef SVR4 +#define SVR4 1 +#endif +#ifndef USE_DLPI +#define USE_DLPI 1 +#endif +#define U_INT32_DECLARED_IN_AUTH 1 +#endif + +#ifdef SUNOS55 +#ifndef SUNOS54 +#define SUNOS54 1 +#endif +#undef U_INT32_DECLARED_IN_AUTH +#define index strchr +#define rindex strrchr +#define bzero(b,n) memset(b,0,n) +#define bcmp(a,b,n) memcmp(a,b,n) +#define bcopy(a,b,n) memcpy(b,a,n) +#endif + +#ifdef SVR4 +#ifndef USE_DLPI +#define USE_DLPI 1 +#endif +#define index strchr +#define rindex strrchr +#define signal sigset +#define bzero(b,n) memset(b,0,n) +#define bcmp(a,b,n) memcmp(a,b,n) +#define bcopy(a,b,n) memcpy(b,a,n) +#endif + +#ifdef ULTRIX +#ifndef USE_PFILT +#define USE_PFILT 1 +#endif +#endif + +#ifdef DECOSF +#ifndef USE_PFILT +#define USE_PFILT 1 +#endif +#endif diff --git a/inc/osmsg.h b/inc/osmsg.h new file mode 100755 index 0000000..a911aa1 --- /dev/null +++ b/inc/osmsg.h @@ -0,0 +1,27 @@ +/* $Id: osmsg.h,v 1.2 1999/01/03 02:06:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************* + This is OSMESSAGE stuf. + + Print a console message. +*************************************************/ + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#define OSMESSAGE_PRINT(print_exp) \ + { \ + flush_pty(); \ + print_exp; \ + } + diff --git a/inc/picture.h b/inc/picture.h new file mode 100755 index 0000000..5ab4048 --- /dev/null +++ b/inc/picture.h @@ -0,0 +1,24 @@ +/* $Id: picture.h,v 1.2 1999/01/03 02:06:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +typedef struct _picture{ + DLword width; + DLword height; + DLword bitsperpixel; + DLword nil; + unsigned int storage; + LispPTR userdata; +} LispPicture; diff --git a/inc/pilotbbt.h b/inc/pilotbbt.h new file mode 100755 index 0000000..ee68583 --- /dev/null +++ b/inc/pilotbbt.h @@ -0,0 +1,145 @@ +/* $Id: pilotbbt.h,v 1.2 1999/01/03 02:06:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +/**************************************************************** + * * + * pilotbbt.h July 6, 1987 by Osamu Nakamura * + * * + ****************************************************************/ + +#ifndef BYTESWAP + /**********************************/ + /* Normal byte-order declarations */ + /**********************************/ +typedef struct pilotbbt{ + DLword pbtdestlo; + DLword pbtdesthi; + DLword pbtdestbit; /* destination bit address */ + short pbtdestbpl; /* destination bits per line + * -- distance in bits to move between items */ + DLword pbtsourcelo; + DLword pbtsourcehi; + DLword pbtsourcebit; /* source bit address */ + short pbtsourcebpl; /* source bits per line */ + DLword pbtwidth; /* width of an item in bits */ + DLword pbtheight; /* number of items -- height in scanlines */ + unsigned pbtbackward : 1; + unsigned pbtdisjoint : 1; + unsigned pbtdisjointitems : 1; + unsigned pbtusegray : 1; + unsigned pbtsourcetype : 1; + unsigned pbtoperation : 2; + unsigned nil : 9; + DLword dummy[5]; /* unused, needed to make 16-alignment */ +} PILOTBBT; + + +typedef struct texturebbt{ + DLword pbtdestlo; + DLword pbtdesthi; + DLword pbtdestbit; /* destination bit address */ + short pbtdestbpl; /* destination bits per line + * -- distance in bits to move between items */ + DLword pbtsourcelo; + DLword pbtsourcehi; + DLword pbtsourcebit; /* source bit address */ + unsigned dummy2 : 4; + /* overlay on pbtsourcebpl when pbtusegray */ + unsigned pbtgrayoffset : 4; + /* offset in gray block where bitblt should start */ + unsigned pbtgraywidthlessone : 4; + /* width-1 of gray block in words */ + unsigned pbtgrayheightlessone : 4; + /* height-1 of gray block */ + DLword pbtwidth; /* width of an item in bits */ + DLword pbtheight; /* number of items -- height in scanlines */ + unsigned pbtbackward : 1; + unsigned pbtdisjoint : 1; + unsigned pbtdisjointitems : 1; + unsigned pbtusegray : 1; + unsigned pbtsourcetype : 1; + unsigned pbtoperation : 2; + unsigned nil : 9; + DLword dummy[5]; /* unused, needed to make 16-alignment */ +} TEXTUREBBT; + +#else + /****************************/ + /* Byte-swapped definitions */ + /****************************/ + +typedef struct pilotbbt + { + DLword pbtdesthi; + DLword pbtdestlo; + short pbtdestbpl; /* destination bits per line + * -- distance in bits to move between items */ + DLword pbtdestbit; /* destination bit address */ + DLword pbtsourcehi; + DLword pbtsourcelo; + short pbtsourcebpl; /* source bits per line */ + DLword pbtsourcebit; /* source bit address */ + DLword pbtheight; /* number of items -- height in scanlines */ + DLword pbtwidth; /* width of an item in bits */ + DLword dummy1; + unsigned nil : 9; + unsigned pbtoperation : 2; + unsigned pbtsourcetype : 1; + unsigned pbtusegray : 1; + unsigned pbtdisjointitems : 1; + unsigned pbtdisjoint : 1; + unsigned pbtbackward : 1; + DLword dummy[4]; /* unused, needed to make 16-alignment */ + } PILOTBBT; + + +typedef struct texturebbt + { + DLword pbtdesthi; + DLword pbtdestlo; + short pbtdestbpl; /* destination bits per line + * -- distance in bits to move between items */ + DLword pbtdestbit; /* destination bit address */ + DLword pbtsourcehi; + DLword pbtsourcelo; + unsigned pbtgrayheightlessone : 4; + /* height-1 of gray block */ + unsigned pbtgraywidthlessone : 4; + /* width-1 of gray block in words */ + unsigned pbtgrayoffset : 4; + /* offset in gray block where bitblt should start */ + unsigned dummy2 : 4; + /* overlay on pbtsourcebpl when pbtusegray */ + DLword pbtsourcebit; /* source bit address */ + DLword pbtheight; /* number of items -- height in scanlines */ + DLword pbtwidth; /* width of an item in bits */ + DLword dummy1; + unsigned nil : 9; + unsigned pbtoperation : 2; + unsigned pbtsourcetype : 1; + unsigned pbtusegray : 1; + unsigned pbtdisjointitems : 1; + unsigned pbtdisjoint : 1; + unsigned pbtbackward : 1; + DLword dummy[4]; /* unused, needed to make 16-alignment */ +} TEXTUREBBT; + + +#endif /* BYTESWAP */ + diff --git a/inc/print.h b/inc/print.h new file mode 100755 index 0000000..62b0dd9 --- /dev/null +++ b/inc/print.h @@ -0,0 +1,44 @@ +/* $Id: print.h,v 1.2 1999/01/03 02:06:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* Syntax-class & character defns for PRINT code in C. */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +#define LEFT_PAREN 40 +#define RIGHT_PAREN 41 +#define SPACE 32 +#define PERCENT 37 +#define DOTCODE 46 +#define DOUBLEQUOTE 34 +#define ATOMINDEXDOT 48 + diff --git a/inc/profile.h b/inc/profile.h new file mode 100755 index 0000000..e419c46 --- /dev/null +++ b/inc/profile.h @@ -0,0 +1,290 @@ +/* $Id: profile.h,v 1.2 1999/01/03 02:06:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* DEFINE PROFILE if you want to turn on profiling */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifdef PROFILE +#define ASM(OPT,OPT2) asm(OPT2); asm(OPT) +#else +#ifdef ISC + /* ISC 386 version needs assembler labels to make the dispatch table */ +#define ASM(OPT,OPT2) asm(OPT) +#else +#define ASM(OPT,OPT2) +#endif /* ISC */ + +#endif /* PROFILE */ + + + +#define CASE000 ASM("_op000:", " .globl _op000"); case000 +#define CASE001 ASM("_op001:", " .globl _op001"); case001 +#define CASE002 ASM("_op002:", " .globl _op002"); case002 +#define CASE003 ASM("_op003:", " .globl _op003"); case003 +#define CASE004 ASM("_op004:", " .globl _op004"); case004 +#define CASE005 ASM("_op005:", " .globl _op005"); case005 +#define CASE006 ASM("_op006:", " .globl _op006"); case006 +#define CASE007 ASM("_op007:", " .globl _op007"); case007 +#define CASE010 ASM("_op010:", " .globl _op010"); case010 +#define CASE011 ASM("_op011:", " .globl _op011"); case011 +#define CASE012 ASM("_op012:", " .globl _op012"); case012 +#define CASE013 ASM("_op013:", " .globl _op013"); case013 +#define CASE014 ASM("_op014:", " .globl _op014"); case014 +#define CASE015 ASM("_op015:", " .globl _op015"); case015 +#define CASE016 ASM("_op016:", " .globl _op016"); case016 +#define CASE017 ASM("_op017:", " .globl _op017"); case017 +#define CASE020 ASM("_op020:", " .globl _op020"); case020 +#define CASE021 ASM("_op021:", " .globl _op021"); case021 +#define CASE022 ASM("_op022:", " .globl _op022"); case022 +#define CASE023 ASM("_op023:", " .globl _op023"); case023 +#define CASE024 ASM("_op024:", " .globl _op024"); case024 +#define CASE025 ASM("_op025:", " .globl _op025"); case025 +#define CASE026 ASM("_op026:", " .globl _op026"); case026 +#define CASE027 ASM("_op027:", " .globl _op027"); case027 +#define CASE030 ASM("_op030:", " .globl _op030"); case030 +#define CASE031 ASM("_op031:", " .globl _op031"); case031 +#define CASE032 ASM("_op032:", " .globl _op032"); case032 +#define CASE033 ASM("_op033:", " .globl _op033"); case033 +#define CASE034 ASM("_op034:", " .globl _op034"); case034 +#define CASE035 ASM("_op035:", " .globl _op035"); case035 +#define CASE036 ASM("_op036:", " .globl _op036"); case036 +#define CASE037 ASM("_op037:", " .globl _op037"); case037 +#define CASE040 ASM("_op040:", " .globl _op040"); case040 +#define CASE041 ASM("_op041:", " .globl _op041"); case041 +#define CASE042 ASM("_op042:", " .globl _op042"); case042 +#define CASE043 ASM("_op043:", " .globl _op043"); case043 +#define CASE044 ASM("_op044:", " .globl _op044"); case044 +#define CASE045 ASM("_op045:", " .globl _op045"); case045 +#define CASE046 ASM("_op046:", " .globl _op046"); case046 +#define CASE047 ASM("_op047:", " .globl _op047"); case047 +#define CASE050 ASM("_op050:", " .globl _op050"); case050 +#define CASE051 ASM("_op051:", " .globl _op051"); case051 +#define CASE052 ASM("_op052:", " .globl _op052"); case052 +#define CASE053 ASM("_op053:", " .globl _op053"); case053 +#define CASE054 ASM("_op054:", " .globl _op054"); case054 +#define CASE055 ASM("_op055:", " .globl _op055"); case055 +#define CASE056 ASM("_op056:", " .globl _op056"); case056 +#define CASE057 ASM("_op057:", " .globl _op057"); case057 +#define CASE060 ASM("_op060:", " .globl _op060"); case060 +#define CASE061 ASM("_op061:", " .globl _op061"); case061 +#define CASE062 ASM("_op062:", " .globl _op062"); case062 +#define CASE063 ASM("_op063:", " .globl _op063"); case063 +#define CASE064 ASM("_op064:", " .globl _op064"); case064 +#define CASE065 ASM("_op065:", " .globl _op065"); case065 +#define CASE066 ASM("_op066:", " .globl _op066"); case066 +#define CASE067 ASM("_op067:", " .globl _op067"); case067 +#define CASE070 ASM("_op070:", " .globl _op070"); case070 +#define CASE071 ASM("_op071:", " .globl _op071"); case071 +#define CASE072 ASM("_op072:", " .globl _op072"); case072 +#define CASE073 ASM("_op073:", " .globl _op073"); case073 +#define CASE074 ASM("_op074:", " .globl _op074"); case074 +#define CASE075 ASM("_op075:", " .globl _op075"); case075 +#define CASE076 ASM("_op076:", " .globl _op076"); case076 +#define CASE077 ASM("_op077:", " .globl _op077"); case077 +#define CASE100 ASM("_op100:", " .globl _op100"); case100 +#define CASE101 ASM("_op101:", " .globl _op101"); case101 +#define CASE102 ASM("_op102:", " .globl _op102"); case102 +#define CASE103 ASM("_op103:", " .globl _op103"); case103 +#define CASE104 ASM("_op104:", " .globl _op104"); case104 +#define CASE105 ASM("_op105:", " .globl _op105"); case105 +#define CASE106 ASM("_op106:", " .globl _op106"); case106 +#define CASE107 ASM("_op107:", " .globl _op107"); case107 +#define CASE110 ASM("_op110:", " .globl _op110"); case110 +#define CASE111 ASM("_op111:", " .globl _op111"); case111 +#define CASE112 ASM("_op112:", " .globl _op112"); case112 +#define CASE113 ASM("_op113:", " .globl _op113"); case113 +#define CASE114 ASM("_op114:", " .globl _op114"); case114 +#define CASE115 ASM("_op115:", " .globl _op115"); case115 +#define CASE116 ASM("_op116:", " .globl _op116"); case116 +#define CASE117 ASM("_op117:", " .globl _op117"); case117 +#define CASE120 ASM("_op120:", " .globl _op120"); case120 +#define CASE121 ASM("_op121:", " .globl _op121"); case121 +#define CASE122 ASM("_op122:", " .globl _op122"); case122 +#define CASE123 ASM("_op123:", " .globl _op123"); case123 +#define CASE124 ASM("_op124:", " .globl _op124"); case124 +#define CASE125 ASM("_op125:", " .globl _op125"); case125 +#define CASE126 ASM("_op126:", " .globl _op126"); case126 +#define CASE127 ASM("_op127:", " .globl _op127"); case127 +#define CASE130 ASM("_op130:", " .globl _op130"); case130 +#define CASE131 ASM("_op131:", " .globl _op131"); case131 +#define CASE132 ASM("_op132:", " .globl _op132"); case132 +#define CASE133 ASM("_op133:", " .globl _op133"); case133 +#define CASE134 ASM("_op134:", " .globl _op134"); case134 +#define CASE135 ASM("_op135:", " .globl _op135"); case135 +#define CASE136 ASM("_op136:", " .globl _op136"); case136 +#define CASE137 ASM("_op137:", " .globl _op137"); case137 +#define CASE140 ASM("_op140:", " .globl _op140"); case140 +#define CASE141 ASM("_op141:", " .globl _op141"); case141 +#define CASE142 ASM("_op142:", " .globl _op142"); case142 +#define CASE143 ASM("_op143:", " .globl _op143"); case143 +#define CASE144 ASM("_op144:", " .globl _op144"); case144 +#define CASE145 ASM("_op145:", " .globl _op145"); case145 +#define CASE146 ASM("_op146:", " .globl _op146"); case146 +#define CASE147 ASM("_op147:", " .globl _op147"); case147 +#define CASE150 ASM("_op150:", " .globl _op150"); case150 +#define CASE151 ASM("_op151:", " .globl _op151"); case151 +#define CASE152 ASM("_op152:", " .globl _op152"); case152 +#define CASE153 ASM("_op153:", " .globl _op153"); case153 +#define CASE154 ASM("_op154:", " .globl _op154"); case154 +#define CASE155 ASM("_op155:", " .globl _op155"); case155 +#define CASE156 ASM("_op156:", " .globl _op156"); case156 +#define CASE157 ASM("_op157:", " .globl _op157"); case157 +#define CASE160 ASM("_op160:", " .globl _op160"); case160 +#define CASE161 ASM("_op161:", " .globl _op161"); case161 +#define CASE162 ASM("_op162:", " .globl _op162"); case162 +#define CASE163 ASM("_op163:", " .globl _op163"); case163 +#define CASE164 ASM("_op164:", " .globl _op164"); case164 +#define CASE165 ASM("_op165:", " .globl _op165"); case165 +#define CASE166 ASM("_op166:", " .globl _op166"); case166 +#define CASE167 ASM("_op167:", " .globl _op167"); case167 +#define CASE170 ASM("_op170:", " .globl _op170"); case170 +#define CASE171 ASM("_op171:", " .globl _op171"); case171 +#define CASE172 ASM("_op172:", " .globl _op172"); case172 +#define CASE173 ASM("_op173:", " .globl _op173"); case173 +#define CASE174 ASM("_op174:", " .globl _op174"); case174 +#define CASE175 ASM("_op175:", " .globl _op175"); case175 +#define CASE176 ASM("_op176:", " .globl _op176"); case176 +#define CASE177 ASM("_op177:", " .globl _op177"); case177 +#define CASE200 ASM("_op200:", " .globl _op200"); case200 +#define CASE201 ASM("_op201:", " .globl _op201"); case201 +#define CASE202 ASM("_op202:", " .globl _op202"); case202 +#define CASE203 ASM("_op203:", " .globl _op203"); case203 +#define CASE204 ASM("_op204:", " .globl _op204"); case204 +#define CASE205 ASM("_op205:", " .globl _op205"); case205 +#define CASE206 ASM("_op206:", " .globl _op206"); case206 +#define CASE207 ASM("_op207:", " .globl _op207"); case207 +#define CASE210 ASM("_op210:", " .globl _op210"); case210 +#define CASE211 ASM("_op211:", " .globl _op211"); case211 +#define CASE212 ASM("_op212:", " .globl _op212"); case212 +#define CASE213 ASM("_op213:", " .globl _op213"); case213 +#define CASE214 ASM("_op214:", " .globl _op214"); case214 +#define CASE215 ASM("_op215:", " .globl _op215"); case215 +#define CASE216 ASM("_op216:", " .globl _op216"); case216 +#define CASE217 ASM("_op217:", " .globl _op217"); case217 +#define CASE220 ASM("_op220:", " .globl _op220"); case220 +#define CASE221 ASM("_op221:", " .globl _op221"); case221 +#define CASE222 ASM("_op222:", " .globl _op222"); case222 +#define CASE223 ASM("_op223:", " .globl _op223"); case223 +#define CASE224 ASM("_op224:", " .globl _op224"); case224 +#define CASE225 ASM("_op225:", " .globl _op225"); case225 +#define CASE226 ASM("_op226:", " .globl _op226"); case226 +#define CASE227 ASM("_op227:", " .globl _op227"); case227 +#define CASE230 ASM("_op230:", " .globl _op230"); case230 +#define CASE231 ASM("_op231:", " .globl _op231"); case231 +#define CASE232 ASM("_op232:", " .globl _op232"); case232 +#define CASE233 ASM("_op233:", " .globl _op233"); case233 +#define CASE234 ASM("_op234:", " .globl _op234"); case234 +#define CASE235 ASM("_op235:", " .globl _op235"); case235 +#define CASE236 ASM("_op236:", " .globl _op236"); case236 +#define CASE237 ASM("_op237:", " .globl _op237"); case237 +#define CASE240 ASM("_op240:", " .globl _op240"); case240 +#define CASE241 ASM("_op241:", " .globl _op241"); case241 +#define CASE242 ASM("_op242:", " .globl _op242"); case242 +#define CASE243 ASM("_op243:", " .globl _op243"); case243 +#define CASE244 ASM("_op244:", " .globl _op244"); case244 +#define CASE245 ASM("_op245:", " .globl _op245"); case245 +#define CASE246 ASM("_op246:", " .globl _op246"); case246 +#define CASE247 ASM("_op247:", " .globl _op247"); case247 +#define CASE250 ASM("_op250:", " .globl _op250"); case250 +#define CASE251 ASM("_op251:", " .globl _op251"); case251 +#define CASE252 ASM("_op252:", " .globl _op252"); case252 +#define CASE253 ASM("_op253:", " .globl _op253"); case253 +#define CASE254 ASM("_op254:", " .globl _op254"); case254 +#define CASE255 ASM("_op255:", " .globl _op255"); case255 +#define CASE256 ASM("_op256:", " .globl _op256"); case256 +#define CASE257 ASM("_op257:", " .globl _op257"); case257 +#define CASE260 ASM("_op260:", " .globl _op260"); case260 +#define CASE261 ASM("_op261:", " .globl _op261"); case261 +#define CASE262 ASM("_op262:", " .globl _op262"); case262 +#define CASE263 ASM("_op263:", " .globl _op263"); case263 +#define CASE264 ASM("_op264:", " .globl _op264"); case264 +#define CASE265 ASM("_op265:", " .globl _op265"); case265 +#define CASE266 ASM("_op266:", " .globl _op266"); case266 +#define CASE267 ASM("_op267:", " .globl _op267"); case267 +#define CASE270 ASM("_op270:", " .globl _op270"); case270 +#define CASE271 ASM("_op271:", " .globl _op271"); case271 +#define CASE272 ASM("_op272:", " .globl _op272"); case272 +#define CASE273 ASM("_op273:", " .globl _op273"); case273 +#define CASE274 ASM("_op274:", " .globl _op274"); case274 +#define CASE275 ASM("_op275:", " .globl _op275"); case275 +#define CASE276 ASM("_op276:", " .globl _op276"); case276 +#define CASE277 ASM("_op277:", " .globl _op277"); case277 +#define CASE300 ASM("_op300:", " .globl _op300"); case300 +#define CASE301 ASM("_op301:", " .globl _op301"); case301 +#define CASE302 ASM("_op302:", " .globl _op302"); case302 +#define CASE303 ASM("_op303:", " .globl _op303"); case303 +#define CASE304 ASM("_op304:", " .globl _op304"); case304 +#define CASE305 ASM("_op305:", " .globl _op305"); case305 +#define CASE306 ASM("_op306:", " .globl _op306"); case306 +#define CASE307 ASM("_op307:", " .globl _op307"); case307 +#define CASE310 ASM("_op310:", " .globl _op310"); case310 +#define CASE311 ASM("_op311:", " .globl _op311"); case311 +#define CASE312 ASM("_op312:", " .globl _op312"); case312 +#define CASE313 ASM("_op313:", " .globl _op313"); case313 +#define CASE314 ASM("_op314:", " .globl _op314"); case314 +#define CASE315 ASM("_op315:", " .globl _op315"); case315 +#define CASE316 ASM("_op316:", " .globl _op316"); case316 +#define CASE317 ASM("_op317:", " .globl _op317"); case317 +#define CASE320 ASM("_op320:", " .globl _op320"); case320 +#define CASE321 ASM("_op321:", " .globl _op321"); case321 +#define CASE322 ASM("_op322:", " .globl _op322"); case322 +#define CASE323 ASM("_op323:", " .globl _op323"); case323 +#define CASE324 ASM("_op324:", " .globl _op324"); case324 +#define CASE325 ASM("_op325:", " .globl _op325"); case325 +#define CASE326 ASM("_op326:", " .globl _op326"); case326 +#define CASE327 ASM("_op327:", " .globl _op327"); case327 +#define CASE330 ASM("_op330:", " .globl _op330"); case330 +#define CASE331 ASM("_op331:", " .globl _op331"); case331 +#define CASE332 ASM("_op332:", " .globl _op332"); case332 +#define CASE333 ASM("_op333:", " .globl _op333"); case333 +#define CASE334 ASM("_op334:", " .globl _op334"); case334 +#define CASE335 ASM("_op335:", " .globl _op335"); case335 +#define CASE336 ASM("_op336:", " .globl _op336"); case336 +#define CASE337 ASM("_op337:", " .globl _op337"); case337 +#define CASE340 ASM("_op340:", " .globl _op340"); case340 +#define CASE341 ASM("_op341:", " .globl _op341"); case341 +#define CASE342 ASM("_op342:", " .globl _op342"); case342 +#define CASE343 ASM("_op343:", " .globl _op343"); case343 +#define CASE344 ASM("_op344:", " .globl _op344"); case344 +#define CASE345 ASM("_op345:", " .globl _op345"); case345 +#define CASE346 ASM("_op346:", " .globl _op346"); case346 +#define CASE347 ASM("_op347:", " .globl _op347"); case347 +#define CASE350 ASM("_op350:", " .globl _op350"); case350 +#define CASE351 ASM("_op351:", " .globl _op351"); case351 +#define CASE352 ASM("_op352:", " .globl _op352"); case352 +#define CASE353 ASM("_op353:", " .globl _op353"); case353 +#define CASE354 ASM("_op354:", " .globl _op354"); case354 +#define CASE355 ASM("_op355:", " .globl _op355"); case355 +#define CASE356 ASM("_op356:", " .globl _op356"); case356 +#define CASE357 ASM("_op357:", " .globl _op357"); case357 +#define CASE360 ASM("_op360:", " .globl _op360"); case360 +#define CASE361 ASM("_op361:", " .globl _op361"); case361 +#define CASE362 ASM("_op362:", " .globl _op362"); case362 +#define CASE363 ASM("_op363:", " .globl _op363"); case363 +#define CASE364 ASM("_op364:", " .globl _op364"); case364 +#define CASE365 ASM("_op365:", " .globl _op365"); case365 +#define CASE366 ASM("_op366:", " .globl _op366"); case366 +#define CASE367 ASM("_op367:", " .globl _op367"); case367 +#define CASE370 ASM("_op370:", " .globl _op370"); case370 +#define CASE371 ASM("_op371:", " .globl _op371"); case371 +#define CASE372 ASM("_op372:", " .globl _op372"); case372 +#define CASE373 ASM("_op373:", " .globl _op373"); case373 +#define CASE374 ASM("_op374:", " .globl _op374"); case374 +#define CASE375 ASM("_op375:", " .globl _op375"); case375 +#define CASE376 ASM("_op376:", " .globl _op376"); case376 +#define CASE377 ASM("_op377:", " .globl _op377"); case377 diff --git a/inc/rawrs232c.h b/inc/rawrs232c.h new file mode 100755 index 0000000..a2f2d53 --- /dev/null +++ b/inc/rawrs232c.h @@ -0,0 +1,41 @@ +/* $Id: rawrs232c.h,v 1.2 1999/01/03 02:06:22 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +typedef struct raw232cparam { +LispPTR BauRate; +LispPTR BitsPerChar; +LispPTR Parity; +LispPTR LocalLine; +LispPTR NoOfStopBits; +LispPTR FlowCnt; +LispPTR InEOL; +LispPTR OutEOL; +LispPTR InputMaxBell; +LispPTR Canon; +LispPTR Echo; +LispPTR ModemStatusLine; +LispPTR RTSCTSCnt; +} RawRSParam; + + +#define RAW_RS_NONE 1 +#define RAW_RS_ODD 2 +#define RAW_RS_EVEN 3 +#define RAW_RS_XON 2 +#define RAW_RS_CR 1 +#define RAW_RS_LF 2 +#define RAW_RS_CRLF 3 + diff --git a/inc/return.h b/inc/return.h new file mode 100755 index 0000000..ba9ed8f --- /dev/null +++ b/inc/return.h @@ -0,0 +1,118 @@ +/* $Id: return.h,v 1.2 1999/01/03 02:06:22 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/**************************************************************/ +/* + + File Name : return.h + Desc. : Macros for return,contextsw + + Written by : Takeshi Shimizu + 11-May-88 + +*/ +/**************************************************************/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifdef BIGVM +#define FX_FNHEADER CURRENTFX->fnheader +#else +#define FX_FNHEADER (CURRENTFX->hi2fnheader << 16) | CURRENTFX->lofnheader +#endif /* BIGVM */ + + + +/* FAST case return use */ +#ifndef ISC +#define FastRetCALL \ + { \ + /* Get IVar from Retunee's IVAR offset slot(BF) */ \ + IVar = Addr68k_from_LADDR(STK_OFFSET | GETWORD((DLword *)CURRENTFX -1)); \ + /* Get FuncObj from Retunee's FNHEAD slot in FX */ \ + FuncObj = (struct fnhead *) \ + Addr68k_from_LADDR(FX_FNHEADER); \ + /* Get PC from Retunee's pc slot in FX */ \ + PC = (ByteCode *)FuncObj + CURRENTFX->pc ; \ + } +#else +#define FastRetCALL \ + { \ + /* Get IVar from Retunee's IVAR offset slot(BF) */ \ + IVar = Addr68k_from_LADDR(STK_OFFSET | GETWORD((DLword *)CURRENTFX -1)); \ + /* Get FuncObj from Retunee's FNHEAD slot in FX */ \ + FuncObj = (struct fnhead *) \ + Addr68k_from_LADDR(FX_FNHEADER); \ + /* Get PC from Retunee's pc slot in FX */ \ + PC = (ByteCode *)FuncObj + CURRENTFX->pc ; \ + if (!(FuncObj->byteswapped)) \ + { \ + byte_swap_code_block(FuncObj); \ + FuncObj->byteswapped = 1; \ + } \ + } +#endif /* ISC */ + + + +/** in CONTEXTSW , for exchanging context **/ + +#define Midpunt(fxnum) \ + { register DLword midpunt; \ + midpunt = LOLOC(LADDR_from_68k(CURRENTFX)); \ + PVar=(DLword *) \ + Addr68k_from_StkOffset( \ + (GETWORD(((DLword *)InterfacePage) +fxnum))) \ + + FRAMESIZE; \ + GETWORD(((DLword *)InterfacePage) +fxnum) = midpunt ; \ + } + + +#define CHECKFX \ + if (((UNSIGNED)PVar -(UNSIGNED)CURRENTFX) != 20) \ + { printf("Invalid FX(0x%x) and PV(0x%x) \n", \ + LADDR_from_68k(CURRENTFX),LADDR_from_68k(PVar)); \ + } + + + +/**** Calls when invoke the function is assumed + that it is called by CONTEXTSW in orginal LISP code **/ + +#define BEFORE_CONTEXTSW \ + { CurrentStackPTR += 2; \ + CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR); \ + GETWORD(CurrentStackPTR)=STK_FSB_WORD; \ + GETWORD(CurrentStackPTR+1)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR))>>1); \ + if (GETWORD(CurrentStackPTR+1) == 0) error("0-long free block."); \ + } + + +#define AFTER_CONTEXTSW \ + { register DLword *ptr68k,*freeptr; \ + ptr68k = (DLword*)Addr68k_from_StkOffset(CURRENTFX->nextblock); \ + if(GETWORD(ptr68k) != STK_FSB_WORD) error("pre_moveframe: MP9316"); \ + CHECK_FX(CURRENTFX); \ + freeptr=ptr68k; \ + while(GETWORD(freeptr) == STK_FSB_WORD) \ + EndSTKP=freeptr=freeptr+ GETWORD(freeptr+1); \ + S_CHECK(CURRENTFX->incall== NIL, "CONTEXTSW during fn call"); \ + /*S_CHECK(CURRENTFX->nopush== NIL, "CONTEXTSW, NOPUSH is set"); ** JDS 4/9/96 this seems not to matter, so I removed it. */\ + CurrentStackPTR = ptr68k- 2 ; \ + CHECK_FX(CURRENTFX); \ + S_CHECK( EndSTKP > CurrentStackPTR, \ + "End of stack isn't beyond current stk pointer."); \ + } + diff --git a/inc/rs232c.h b/inc/rs232c.h new file mode 100755 index 0000000..f9efe8b --- /dev/null +++ b/inc/rs232c.h @@ -0,0 +1,172 @@ +/* $Id: rs232c.h,v 1.2 1999/01/03 02:06:22 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include +#include +#include + +#include "lispemul.h" +#include "adr68k.h" +#include "lispmap.h" + +/* + RS232C Buffer Status +*/ + +#define INACTIVE 0 +#define ACTIVE 1 +#define TERMINATED 2 + +/* + DLRS232C.IOP.COMMANDS +*/ + +#define ON 0 +#define OFF 1 +#define BREAK_ON 2 +#define BREAK_OFF 3 +#define ABORT_INPUT 4 +#define ABORT_OUTPUT 5 +#define SET_RS366_STATUS 6 +#define GET_STATUS 7 +#define MAJOR_SET_PARAMETERS 8 +#define MINOR_SET_PARAMETERS 14 +#define SET_CHANNEL_RESET_FLAG 15 + +/* + Devise Status +*/ + +#define IOP_DATA_LINE.OCCUPIED 4096 +#define PRESENT_NEXT_DIGIT 2048 +#define CALL_ORIGINATION_STATUS 1024 +#define ABANDON_CALL_AND_RETRY 512 +#define POWER_INDICATION 256 +#define REAK_DETECTED 128 +#define DATA_LOST 64 +#define CLEAR_TO.SEND 32 +#define NOT_DEFINED 16 +#define CARRIER_DETECT 8 +#define RING_HEARD 4 +#define DATA_SET.READY 2 +#define RING_INDICATOR 1 + +/* + RS232C Data Structure +*/ + +typedef struct { + DLword frame_timeout; + DLbyte correspondent; + DLbyte synch_char; + unsigned reset_ring_heard : 1; + unsigned reset_break_detected : 1; + unsigned reset_data_lost : 1; + unsigned request_to_send : 1; + unsigned data_terminal_ready : 1; + unsigned stop_bits : 1; + unsigned line_type : 2; + unsigned parity : 3; + unsigned char_length : 2; + unsigned synch_count : 3; + unsigned nil1 : 3; + unsigned line_speed : 5; + DLbyte nil2; + DLword interrupt_mask; + DLword flowcontrol_on; + DLword flowcontrol_xon_char; + DLword flowcontrol_xoff_char; +} DLRS232C_PARAMETER_CSB; + +typedef struct { + DLword block_pointer_lo; + DLword block_pointer_hi; + DLword byte_count; + DLword returned_byte_count; + DLword transfer_status; + DLword nil1; + unsigned completed : 1; + unsigned put : 1; + unsigned nil2 : 6; + LispPTR synch_event; + LispPTR next; +} DLRS232C_IOCB; + +typedef struct { + unsigned success : 1; + unsigned nil2 : 6; + unsigned data_lost : 1; + unsigned device_error : 1; + unsigned frame_timeout : 1; + unsigned checksum_error : 1; + unsigned parity_error : 1; + unsigned asynch_frame_error : 1; + unsigned invalid_character : 1; + unsigned aborted : 1; + unsigned disaster : 1; +} DLRS232C_IOCB_TRANSFER_STATUS; + +typedef struct { + unsigned rs232c_absent : 1; + unsigned nil : 15; +} DLRS232C_HDW_CONF; + +typedef struct { + unsigned busy : 1; + unsigned nil : 15; +} DLRS232C_IOP_GET_FLAG; + +typedef struct { + unsigned busy : 1; + unsigned nil : 15; +} DLRS232C_IOP_PUT_FLAG; + +typedef struct { + unsigned busy : 1; + unsigned nil : 11; + unsigned command : 4; +} DLRS232C_IOP_MISC_CMD; + +typedef struct { + unsigned success : 1; + unsigned nil : 14; + unsigned unimplemented : 1; +} DLRS232C_PARAMETER_OUTCOME; + +typedef struct { + unsigned nil1 : 3; + unsigned data_line_occupied : 1; + unsigned present_next_digit : 1; + unsigned call_origination_status : 1; + unsigned abandon_call_and_retry : 1; + unsigned power_indication : 1; + unsigned break_detected : 1; + unsigned data_lost : 1; + unsigned clear_to_send : 1; + unsigned nil2 : 1; + unsigned carrier_detect : 1; + unsigned ring_heard : 1; + unsigned data_set_ready : 1; + unsigned ring_indicator : 1; +} DLRS232C_DEVICE_STATUS; + +typedef struct { + DLword nil[22]; + DLword rs232c_length; + char rs232c_data; +} RS232C_ENCAPSULATION; + +extern DLword *Lisp_world; diff --git a/inc/sccsid.c b/inc/sccsid.c new file mode 100755 index 0000000..3635e8f --- /dev/null +++ b/inc/sccsid.c @@ -0,0 +1,2 @@ +/* %Z% %M% Version %I% (%G%). copyright venue & Fuji Xerox */ +static char *id = "%Z% %M% %I% %G% (venue & Fuji Xerox)"; diff --git a/inc/sccsid.c% b/inc/sccsid.c% new file mode 100755 index 0000000..7394289 --- /dev/null +++ b/inc/sccsid.c% @@ -0,0 +1,2 @@ +/* %Z% %M% Version %I% (%G%). copyright envos & Fuji Xerox */ +static char *id = "%Z% %M% %I% %G% (envos & Fuji Xerox)"; diff --git a/inc/sccsid.h b/inc/sccsid.h new file mode 100755 index 0000000..0864359 --- /dev/null +++ b/inc/sccsid.h @@ -0,0 +1 @@ +/* $Id: sccsid.h,v 1.2 1999/01/03 02:06:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ diff --git a/inc/sccsid.h% b/inc/sccsid.h% new file mode 100755 index 0000000..a99aac1 --- /dev/null +++ b/inc/sccsid.h% @@ -0,0 +1 @@ +/* %Z% %M% Version %I% (%G%). copyright Venue & Fuji Xerox */ diff --git a/inc/sccsid.s b/inc/sccsid.s new file mode 100755 index 0000000..5f59381 --- /dev/null +++ b/inc/sccsid.s @@ -0,0 +1 @@ +# %Z% %M% Version %I% (%G%). copyright Venue & Fuji Xerox # diff --git a/inc/stack.h b/inc/stack.h new file mode 100755 index 0000000..cc2b79d --- /dev/null +++ b/inc/stack.h @@ -0,0 +1,454 @@ +/* $Id: stack.h,v 1.2 1999/01/03 02:06:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/* ContextSW frame number */ +#define CurrentFXP 0 +#define ResetFXP 1 +#define SubovFXP 2 +#define KbdFXP 3 +#define HardReturnFXP 4 +#define GCFXP 5 +#define FAULTFXP 6 + +#define STK_FSB_WORD 0xA000 +#define STK_FSB_32 0xA0000000 + +#define STK_GUARD_WORD 0xE000 +#define STK_GUARD_32 0xE0000000 +#define BF_MARK0 0x8000 +#define BF_MARK 0x8000 +#define BF_MARK32 0x80000000 +#define FX_MARK 0xc000 +#define FX_MARK_NATIVE 0xc800 + +#define STK_GUARD 7 +#define STK_FX 6 +#define STK_FSB 5 +#define STK_BF 4 +#define STK_NOTFLG 0 + +#define STK_SAFE 32 /* added with stkmin */ +#define MINEXTRASTACKWORDS 32 +#define STACKAREA_SIZE 768 + +/* For Fvar operations */ +#define FVSTACK 2 +#define FVGLOBAL 6 +#define FVUBNBOUND 3 +#define FVIVAR 0x0 +#define FVPVAR 0x80 +#define FVFVAR 0xC0 +#define ENDSTACKMARK 0xb + +#define FXPTR(base) ((struct frameex1 *) WORDPTR(base)) + +#ifndef BYTESWAP + + /*******************************************************/ + /* Normal definitions for structures on stack */ + /*******************************************************/ +typedef struct fnhead{ + DLword stkmin; /* ?? */ + short na; /* Numbers of arguments */ + short pv; /* ?? */ + DLword startpc; + /* head of ByteCodes, DLword offset from stkmin */ + unsigned native : 1; /* native translated? */ + unsigned byteswapped : 1; /* code was reswapped. */ + unsigned argtype : 2; /* ?? */ +#ifdef BIGVM + unsigned framename :28; /* index in AtomSpace */ +#else + unsigned nil2 : 2; /* not used */ + unsigned nil3 : 2; /* not used */ + unsigned framename :24; /* index in AtomSpace */ +#endif /* BIGVM */ + DLword ntsize; /* size of NameTable */ + unsigned nlocals : 8; /* ?? */ + unsigned fvaroffset : 8; + /* DLword offset from head of NameTable */ + /* NameTable of variavle length is follwing with this structure. */ +} FNHEAD; + + +typedef struct frameex1{ + unsigned flags :3; + unsigned fast :1; + unsigned native :1; /* This frame treats N-func */ + unsigned incall :1; + unsigned validnametable :1; + /* 0: look for FunctionHeader + 1: look for NameTable on this FrameEx */ + unsigned nopush :1; + unsigned usecount :8; + DLword alink; /* alink pointer (Low addr) */ +#ifdef BIGVM + LispPTR fnheader; /* pointer to FunctionHeader (Hi2 addr) */ +#else + DLword lofnheader; /* pointer to FunctionHeader (Low addr) */ + unsigned hi1fnheader : 8; /* pointer to FunctionHeader (Hi1 addr) */ + unsigned hi2fnheader : 8; /* pointer to FunctionHeader (Hi2 addr) */ +#endif /* BIGVM */ + DLword nextblock; /* pointer to FreeStackBlock */ + DLword pc; /* Program counter */ +#ifdef BIGVM + LispPTR nametable; /* ptr to NameTable of this FrameEx (Hi2 addr) */ +#else + DLword lonametable; /* ptr to NameTable of this FrameEx (Low addr) */ + unsigned hi1nametable :8; /* ptr to NameTable of this FrameEx (Hi1 addr) */ + unsigned hi2nametable :8; /* ptr to NameTable of this FrameEx (Hi2 addr) */ +#endif /* BIGVM */ + DLword blink; /* blink pointer (Low addr) */ + DLword clink; /* clink pointer (Low addr) */ +} FX; + +typedef struct frameex2{ + unsigned flags :3; + unsigned fast :1; + unsigned native :1; /* This frame treats N-func */ + unsigned incall :1; + unsigned validnametable :1; + /* 0: look for FunctionHeader + 1: look for NameTable on this FrameEx */ + unsigned nopush :1; + unsigned usecount :8; + DLword alink; /* alink pointer (Low addr) */ + LispPTR fnheader; /* pointer to FunctionHeader */ + DLword nextblock; /* pointer to FreeStackBlock */ + DLword pc; /* Program counter */ + LispPTR nametable; /* address of NameTable */ + DLword blink; /* blink pointer (Low addr) */ + DLword clink; /* clink pointer (Low addr) */ +} FX2; + + + + +typedef struct fxblock { + unsigned flagbyte : 8; + unsigned nil : 23; + unsigned slowp : 1; +} FXBLOCK; + + + +typedef struct basic_frame { + unsigned flags : 3; + unsigned nil : 3; + unsigned residual: 1; + unsigned padding : 1; + unsigned usecnt : 8; + DLword ivar; /* stk offset of IVARs for this frame ?? */ + +} Bframe; + +typedef struct stkword { + unsigned short flags :3; + unsigned short nil :5; + unsigned short usecount :8; + } StackWord; + + + typedef struct stack_block { + DLword flagword; + DLword size; + } STKBLK; + +/* Lisp DATATYPE STACKP */ +typedef struct stackp { + DLword stackp0; + DLword edfxp; +} STACKP; + + + /*************************************************************/ + /* Pointer-dereferencing macros for one-word structure ptrs */ + /*************************************************************/ +#define BFRAMEPTR(ptr) ((Bframe *)(ptr)) +#define STKWORDPTR(ptr) ((StackWord *)(ptr)) + +#else + + /*******************************************************/ + /* Byte-swapped/Word-swapped definitions of stack */ + /*******************************************************/ +typedef struct fnhead + { + short na; /* Numbers of arguments */ + DLword stkmin; /* ?? */ + DLword startpc; + /* head of ByteCodes, DLword offset from stkmin */ + short pv; /* ?? */ +#ifdef BIGVM + unsigned framename :28; /* index in AtomSpace */ +#else + unsigned framename :24; /* index in AtomSpace */ + unsigned nil3 : 2; /* not used */ + unsigned nil2 : 2; /* not used */ +#endif /* BIGVM */ + unsigned argtype : 2; /* ?? */ + unsigned byteswapped : 1; /* code was reswapped. */ + unsigned native : 1; /* native translated? */ + unsigned fvaroffset : 8; + /* DLword offset from head of NameTable */ + unsigned nlocals :8; /* ?? */ + DLword ntsize; /* size of NameTable */ + /* NameTable of variavle length is follwing with this structure. */ + } FNHEAD; + + +typedef struct frameex1{ + DLword alink; /* alink pointer (Low addr) */ + unsigned usecount :8; + unsigned nopush :1; + unsigned validnametable :1; + /* 0: look for FunctionHeader + 1: look for NameTable on this FrameEx */ + unsigned incall :1; + unsigned native :1; /* This frame treats N-func */ + unsigned fast :1; + unsigned flags :3; /* hi word */ + +#ifdef BIGVM + LispPTR fnheader; /* pointer to FunctionHeader (Hi2 addr) */ +#else + unsigned hi2fnheader : 8; /* pointer to FunctionHeader (Hi2 addr) */ + unsigned hi1fnheader : 8; /* pointer to FunctionHeader (Hi1 addr) */ + DLword lofnheader; /* pointer to FunctionHeader (Low addr) */ +#endif /* BIGVM */ + + DLword pc; /* Program counter */ + DLword nextblock; /* pointer to FreeStackBlock */ + +#ifdef BIGVM + LispPTR nametable; /* pointer to NameTable of this FX (Hi2 addr) */ +#else + unsigned hi2nametable :8; /* pointer to NameTable of this FX (Hi2 addr) */ + unsigned hi1nametable :8; /* pointer to NameTable of this FX (Hi1 addr) */ + DLword lonametable; /* pointer to NameTable of this FX (Low addr) */ +#endif /* BIGVM */ + + DLword clink; /* clink pointer (Low addr) */ + DLword blink; /* blink pointer (Low addr) */ +} FX; + +typedef struct frameex2{ + DLword alink; /* alink pointer (Low addr) */ + unsigned usecount :8; + unsigned nopush :1; + unsigned validnametable :1; + /* 0: look for FunctionHeader + 1: look for NameTable on this FrameEx */ + unsigned incall :1; + unsigned native :1; /* This frame treats N-func */ + unsigned fast :1; + unsigned flags :3; + + LispPTR fnheader; /* pointer to FunctionHeader (swapped) */ + + DLword pc; /* Program counter */ + DLword nextblock; /* pointer to FreeStackBlock */ + + LispPTR nametable; /* address of NameTable (swapped) */ + + DLword clink; /* clink pointer (Low addr) */ + DLword blink; /* blink pointer (Low addr) */ +} FX2; + + + + +typedef struct fxblock { + unsigned slowp : 1; + unsigned nil : 23; + unsigned flagbyte : 8; +} FXBLOCK; + +typedef struct basic_frame { + DLword ivar; + unsigned usecnt : 8; + unsigned padding : 1; + unsigned residual: 1; + unsigned nil : 3; + unsigned flags : 3; + +} Bframe; + +typedef struct stkword + { + USHORT usecount :8; + USHORT nil :5; + USHORT flags :3; + } StackWord; + +typedef struct stack_block + { + DLword size; + DLword flagword; + } STKBLK; + +/* Lisp DATATYPE STACKP */ +typedef struct stackp + { + DLword edfxp; + DLword stackp0; + } STACKP; + + + /*************************************************************/ + /* Pointer-dereferencing macros for one-word structure ptrs */ + /*************************************************************/ +#define BFRAMEPTR(ptr) ((Bframe *)(ptr)) +#define STKWORDPTR(ptr) ((StackWord *) (2^(UNSIGNED)(ptr))) + +#endif + +#define STKWORD(stkptr) ((StackWord *)WORDPTR(stkptr)) + +#define FX_INVALIDP(fx68k) (((fx68k)==0) || ((DLword*)(fx68k)==Stackspace)) +#define FX_size(fx68k) (((FX*)(fx68k))->nextblock - LOLOC(LADDR_from_68k(fx68k))) +#define FSBP(ptr68k) ( ((STKBLK*)(ptr68k))->flagword == STK_FSB_WORD ) +#define FSB_size(ptr68k) (((STKBLK*)(ptr68k))->size) +/** Following suff assumes fx is 68kptr and val is LISP_LO_OFFSET **/ +#define DUMMYBF(fx) ( ((DLword*)(fx))-DLWORDSPER_CELL ) +#define SLOWP(fx) (((FXBLOCK*)(fx))->slowp) +#define FASTP(fx) (!SLOWP(fx)) +#define SET_FASTP_NIL(fx68k) { \ + if(FASTP(fx68k)){ \ + ((FX*)fx68k)->blink=StkOffset_from_68K(DUMMYBF(fx68k));\ + ((FX*)fx68k)->clink=((FX*)fx68k)->alink;\ + SLOWP(fx68k)=T; }} + +#define GETALINK(fx) ((((fx)->alink) & 0xfffe)-FRAMESIZE) +#define SETALINK(fx,val) {if(FASTP(fx)) \ + {((FX*)(fx))->blink=LADDR_from_68k(DUMMYBF(fx));\ + ((FX*)(fx))->clink=((FX*)(fx))->alink;}\ + ((FX*)(fx))->alink=(val)+FRAMESIZE+1;} + +#define GETBLINK(fx) (SLOWP(fx) ? ((FX*)(fx))->blink : LOLOC(LADDR_from_68k(DUMMYBF(fx)))) +#define SETBLINK(fx,val) { ((FX*)(fx))->blink =(val);\ + if(FASTP(fx)){\ + ((FX*)(fx))->clink=((FX*)(fx))->alink; \ + SLOWP(fx)=1;}} + +#define GETCLINK(fx) (SLOWP(fx) ? (((FX*)(fx))->clink -FRAMESIZE):(((FX*)(fx))->alink -FRAMESIZE)) +#define SETCLINK(fx,val) { ((FX*)(fx))->clink = (val) +FRAMESIZE;\ + if(FASTP((fx))){\ + ((FX*)(fx))->blink=LADDR_from_68k(DUMMYBF(fx));\ + SLOWP(fx)=1;}} + +#define SETACLINK(fx,val) {if(FASTP(fx)) \ + {((FX*)(fx))->blink=LADDR_from_68k(DUMMYBF(fx));}\ + ((FX*)(fx))->clink= (val) + FRAMESIZE;\ + ((FX*)(fx))->alink= ((FX*)(fx))->clink +1; } + +#ifdef BIGVM +#define SWAP_FNHEAD +#else +#define SWAP_FNHEAD(x) swapx(x) +#endif /* BIGVM */ + +#define GETNAMETABLE(fx) \ + ((struct fnhead *) Addr68k_from_LADDR(SWAP_FNHEAD( \ + ((((FX2 *)fx)->validnametable) \ + ? ((FX2 *)fx)->nametable \ + : ((FX2 *)fx)->fnheader \ + )) & POINTERMASK)) + +#define MAKEFREEBLOCK(ptr68k,size) \ + { \ + if ((size) <= 0) error("creating 0 long FSP"); \ + *((LispPTR*)(ptr68k))=STK_FSB_32| ((DLword)(size)); \ + } + +#define SETUPGUARDBLOCK(ptr68k,size) \ + { \ + if ((size) <= 0) error("creating 0 long Guard block"); \ + ( *((LispPTR*)(ptr68k))=STK_GUARD_32| ((DLword)(size)) ); \ + } + + + + +/************************************************************************/ +/* */ +/* Stack-checking macros */ +/* */ +/* Enabled when STACKCHECK compile flag is set. */ +/* */ +/************************************************************************/ + +#ifdef STACKCHECK + +#define S_CHECK(condition, msg) \ + { \ + if(!(condition)) \ + { \ + printf("\n\nStack check failed: %s.\n\n", (msg)); \ + error("S_Check.."); \ + } \ + } + +#define S_WARN(condition, msg, scanptr) \ + { \ + if(!(condition)) \ + { \ + printf("\n\nStack check failed at 0x%x: %s.\n\n", (scanptr), (msg)); \ + } \ + } + +#define CHECK_BF(bf68k) check_BF(bf68k) + +#define CHECK_FX(fx68k) check_FX(fx68k) + +#define PreMoveFrameCheck(fx68k) \ + { LispPTR *tos_on_stack; \ + if(check_stack_rooms(fx68k) > 1000) \ + { \ + warn("moveframe:there is more than 100 words SPACE for FX"); \ + printf("# When calling "); \ + tos_on_stack=(LispPTR*)Addr68k_from_StkOffset((fx68k)->nextblock - 2); \ + print_atomname(*tos_on_stack); \ + printf("\n"); \ + stack_check(0); \ + } \ + } + +#else /* STACKCHECK */ + + +#define S_CHECK(condition,msg) {} +#define S_WARN(condition, msg, scanptr) {} +#define PreMoveFrameCheck(fx68k) {} +#define CHECK_BF(bf68k) {} +#define CHECK_FX(fx68k) {} + +#endif /* STACKCHECK */ + + + + +#define STK_MIN(fnobj) ((fnobj->stkmin /* NOT NEEDED in stkmin +STK_SAFE */) << 1) + +#define STK_END_COMPUTE(stk_end,fnobj) \ + ( (UNSIGNED)(stk_end) - STK_MIN(fnobj) ) + + +#define CLR_IRQ \ + {Irq_Stk_Check = STK_END_COMPUTE((Irq_Stk_End = (UNSIGNED) EndSTKP), \ + FuncObj); \ + } diff --git a/inc/stream.h b/inc/stream.h new file mode 100755 index 0000000..418b0e6 --- /dev/null +++ b/inc/stream.h @@ -0,0 +1,183 @@ +/* $Id: stream.h,v 1.2 1999/01/03 02:06:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + /********************************/ + /* Normal byte-order definition */ + /********************************/ +typedef struct stream{ + DLword COFFSET; + DLword CBUFSIZE; +#ifndef BIGVM + unsigned BINABLE :1; + unsigned BOUTABLE :1; + unsigned EXTENDABLE :1; + unsigned CBUFDIRTY :1; + unsigned PEEKEDCHARP :1; + unsigned ACCESS :3; + unsigned CBUFPTR :24; +#else + unsigned PEEKEDCHARP :1; + unsigned ACCESS :3; + unsigned CBUFPTR :28; +#endif /* BIGVM */ + DLbyte BYTESIZE; + DLbyte CHARSET; + DLword PEEKEDCHAR; + DLword CHARPOSITION; + DLword CBUFMAXSIZE; + unsigned NONDEFAULTDATEFLG :1; + unsigned REVALIDATEFLG :1; + unsigned MULTIBUFFERHINT :1; + unsigned USERCLOSEABLE :1; +#ifndef BIGVM + unsigned USERVISIBLE :1; + unsigned EOLCONVENTION :2; + unsigned NIL1 :1; + unsigned FULLFILENAME :24; +#else + unsigned FULLFILENAME :28; +#endif /* BIGVM */ +#ifdef BIGVM + unsigned BINABLE :1; + unsigned BOUTABLE :1; + unsigned EXTENDABLE :1; + unsigned CBUFDIRTY :1; + unsigned DEVICE: 28; +#else + LispPTR DEVICE; +#endif /* BIGVM */ +#ifdef BIGVM + unsigned USERVISIBLE :1; + unsigned EOLCONVENTION :2; + unsigned NIL1 :1; + unsigned VALIDATION: 28; +#else + LispPTR VALIDATION; +#endif /* BIGVM */ + LispPTR CPAGE; + LispPTR EPAGE; + DLword EOFFSET; + DLword LINELENGTH; + LispPTR F1; + LispPTR F2; + LispPTR F3; + LispPTR F4; + LispPTR F5; + DLword FW6; + DLword FW7; + DLword FW8; + DLword FW9; + LispPTR F10; + LispPTR STRMBINFN; + LispPTR STRMBOUTFN; + LispPTR OUTCHARFN; + LispPTR ENDOFSTREAMOP; + LispPTR OTHERPROPS; + LispPTR IMAGEOPS; + LispPTR IMAGEDATA; + LispPTR BUFFS; + DLword MAXBUFFERS; + DLword NIL2; + LispPTR EXTRASTREAMOP; +}Stream; + +#else + + /***************************/ + /* Byte-swapped definition */ + /***************************/ +typedef struct stream + { + DLword CBUFSIZE; + DLword COFFSET; +#ifndef BIGVM + unsigned CBUFPTR :24; + unsigned ACCESS :3; + unsigned PEEKEDCHARP :1; + unsigned CBUFDIRTY :1; + unsigned EXTENDABLE :1; + unsigned BOUTABLE :1; + unsigned BINABLE :1; +#else + unsigned CBUFPTR :28; + unsigned ACCESS :3; + unsigned PEEKEDCHARP :1; +#endif /* BIGVM */ + DLword PEEKEDCHAR; + DLbyte CHARSET; + DLbyte BYTESIZE; + DLword CBUFMAXSIZE; + DLword CHARPOSITION; +#ifdef BIGVM + unsigned FULLFILENAME :28; +#else + unsigned FULLFILENAME :24; + unsigned NIL1 :1; + unsigned EOLCONVENTION :2; + unsigned USERVISIBLE :1; +#endif /* BIGVM */ + unsigned USERCLOSEABLE :1; + unsigned MULTIBUFFERHINT :1; + unsigned REVALIDATEFLG :1; + unsigned NONDEFAULTDATEFLG :1; +#ifndef BIGVM + LispPTR DEVICE; +#else + unsigned DEVICE: 28; + unsigned CBUFDIRTY :1; + unsigned EXTENDABLE :1; + unsigned BOUTABLE :1; + unsigned BINABLE :1; +#endif /* BIGVM */ +#ifndef BIGVM + LispPTR VALIDATION; +#else + unsigned VALIDATION: 28; + unsigned NIL1 :1; + unsigned EOLCONVENTION :2; + unsigned USERVISIBLE :1; +#endif /* BIGVM */ + LispPTR CPAGE; + LispPTR EPAGE; + DLword LINELENGTH; + DLword EOFFSET; + LispPTR F1; + LispPTR F2; + LispPTR F3; + LispPTR F4; + LispPTR F5; + DLword FW7; + DLword FW6; + DLword FW9; + DLword FW8; + LispPTR F10; + LispPTR STRMBINFN; + LispPTR STRMBOUTFN; + LispPTR OUTCHARFN; + LispPTR ENDOFSTREAMOP; + LispPTR OTHERPROPS; + LispPTR IMAGEOPS; + LispPTR IMAGEDATA; + LispPTR BUFFS; + DLword NIL2; + DLword MAXBUFFERS; + LispPTR EXTRASTREAMOP; +}Stream; + +#endif /* BYTESWAP */ + diff --git a/inc/stream.h% b/inc/stream.h% new file mode 100755 index 0000000..6db3cf2 --- /dev/null +++ b/inc/stream.h% @@ -0,0 +1,158 @@ +/* @(#) stream.h Version 2.7 (2/8/93). copyright Venue */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + /********************************/ + /* Normal byte-order definition */ + /********************************/ +typedef struct stream{ + DLword COFFSET; + DLword CBUFSIZE; +#ifndef BIGVM + unsigned BINABLE :1; + unsigned BOUTABLE :1; + unsigned EXTENDABLE :1; + unsigned CBUFDIRTY :1; + unsigned PEEKEDCHARP :1; + unsigned ACCESS :3; + unsigned CBUFPTR :24; +#else + unsigned PEEKEDCHARP :1; + unsigned ACCESS :3; + unsigned CBUFPTR :28; +#endif /* BIGVM */ + DLbyte BYTESIZE; + DLbyte CHARSET; + DLword PEEKEDCHAR; + DLword CHARPOSITION; + DLword CBUFMAXSIZE; + unsigned NONDEFAULTDATEFLG :1; + unsigned REVALIDATEFLG :1; + unsigned MULTIBUFFERHINT :1; + unsigned USERCLOSEABLE :1; +#ifndef BIGVM + unsigned USERVISIBLE :1; + unsigned EOLCONVENTION :2; + unsigned NIL1 :1; + unsigned FULLFILENAME :24; +#else + unsigned FULLFILENAME :28; +#endif /* BIGVM */ +#ifdef BIGVM + unsigned BINABLE :1; + unsigned BOUTABLE :1; + unsigned EXTENDABLE :1; + unsigned CBUFDIRTY :1; + unsigned DEVICE: 28; +#else + LispPTR DEVICE; +#endif /* BIGVM */ +#ifdef BIGVM + unsigned USERVISIBLE :1; + unsigned EOLCONVENTION :2; + unsigned NIL1 :1; + unsigned VALIDATION: 28; +#else + LispPTR VALIDATION; +#endif /* BIGVM */ + LispPTR CPAGE; + LispPTR EPAGE; + DLword EOFFSET; + DLword LINELENGTH; + LispPTR F1; + LispPTR F2; + LispPTR F3; + LispPTR F4; + LispPTR F5; + DLword FW6; + DLword FW7; + DLword FW8; + DLword FW9; + LispPTR F10; + LispPTR STRMBINFN; + LispPTR STRMBOUTFN; + LispPTR OUTCHARFN; + LispPTR ENDOFSTREAMOP; + LispPTR OTHERPROPS; + LispPTR IMAGEOPS; + LispPTR IMAGEDATA; + LispPTR BUFFS; + DLword MAXBUFFERS; + DLword NIL2; + LispPTR EXTRASTREAMOP; +}Stream; + +#else + + /***************************/ + /* Byte-swapped definition */ + /***************************/ +typedef struct stream + { + DLword CBUFSIZE; + DLword COFFSET; + unsigned CBUFPTR :24; + unsigned ACCESS :3; + unsigned PEEKEDCHARP :1; + unsigned CBUFDIRTY :1; + unsigned EXTENDABLE :1; + unsigned BOUTABLE :1; + unsigned BINABLE :1; + DLword PEEKEDCHAR; + DLbyte CHARSET; + DLbyte BYTESIZE; + DLword CBUFMAXSIZE; + DLword CHARPOSITION; + unsigned FULLFILENAME :24; + unsigned NIL1 :1; + unsigned EOLCONVENTION :2; + unsigned USERVISIBLE :1; + unsigned USERCLOSEABLE :1; + unsigned MULTIBUFFERHINT :1; + unsigned REVALIDATEFLG :1; + unsigned NONDEFAULTDATEFLG :1; + LispPTR DEVICE; + LispPTR VALIDATION; + LispPTR CPAGE; + LispPTR EPAGE; + DLword LINELENGTH; + DLword EOFFSET; + LispPTR F1; + LispPTR F2; + LispPTR F3; + LispPTR F4; + LispPTR F5; + DLword FW7; + DLword FW6; + DLword FW9; + DLword FW8; + LispPTR F10; + LispPTR STRMBINFN; + LispPTR STRMBOUTFN; + LispPTR OUTCHARFN; + LispPTR ENDOFSTREAMOP; + LispPTR OTHERPROPS; + LispPTR IMAGEOPS; + LispPTR IMAGEDATA; + LispPTR BUFFS; + DLword NIL2; + DLword MAXBUFFERS; + LispPTR EXTRASTREAMOP; +}Stream; + +#endif /* BYTESWAP */ + diff --git a/inc/stream.h2 b/inc/stream.h2 new file mode 100755 index 0000000..f7f405e --- /dev/null +++ b/inc/stream.h2 @@ -0,0 +1,183 @@ +/* @(#) stream.h Version 2.7 (2/8/93). copyright Venue */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#ifndef BYTESWAP + /********************************/ + /* Normal byte-order definition */ + /********************************/ +typedef struct stream{ + DLword COFFSET; + DLword CBUFSIZE; +#ifndef BIGVM + unsigned BINABLE :1; + unsigned BOUTABLE :1; + unsigned EXTENDABLE :1; + unsigned CBUFDIRTY :1; + unsigned PEEKEDCHARP :1; + unsigned ACCESS :3; + unsigned CBUFPTR :24; +#else + unsigned PEEKEDCHARP :1; + unsigned ACCESS :3; + unsigned CBUFPTR :28; +#endif /* BIGVM */ + DLbyte BYTESIZE; + DLbyte CHARSET; + DLword PEEKEDCHAR; + DLword CHARPOSITION; + DLword CBUFMAXSIZE; + unsigned NONDEFAULTDATEFLG :1; + unsigned REVALIDATEFLG :1; + unsigned MULTIBUFFERHINT :1; + unsigned USERCLOSEABLE :1; +#ifndef BIGVM + unsigned USERVISIBLE :1; + unsigned EOLCONVENTION :2; + unsigned NIL1 :1; + unsigned FULLFILENAME :24; +#else + unsigned FULLFILENAME :28; +#endif /* BIGVM */ +#ifdef BIGVM + unsigned BINABLE :1; + unsigned BOUTABLE :1; + unsigned EXTENDABLE :1; + unsigned CBUFDIRTY :1; + unsigned DEVICE: 28; +#else + LispPTR DEVICE; +#endif /* BIGVM */ +#ifdef BIGVM + unsigned USERVISIBLE :1; + unsigned EOLCONVENTION :2; + unsigned NIL1 :1; + unsigned VALIDATION: 28; +#else + LispPTR VALIDATION; +#endif /* BIGVM */ + LispPTR CPAGE; + LispPTR EPAGE; + DLword EOFFSET; + DLword LINELENGTH; + LispPTR F1; + LispPTR F2; + LispPTR F3; + LispPTR F4; + LispPTR F5; + DLword FW6; + DLword FW7; + DLword FW8; + DLword FW9; + LispPTR F10; + LispPTR STRMBINFN; + LispPTR STRMBOUTFN; + LispPTR OUTCHARFN; + LispPTR ENDOFSTREAMOP; + LispPTR OTHERPROPS; + LispPTR IMAGEOPS; + LispPTR IMAGEDATA; + LispPTR BUFFS; + DLword MAXBUFFERS; + DLword NIL2; + LispPTR EXTRASTREAMOP; +}Stream; + +#else + + /***************************/ + /* Byte-swapped definition */ + /***************************/ +typedef struct stream + { + DLword CBUFSIZE; + DLword COFFSET; +#ifndef BIGVM + unsigned CBUFPTR :24; + unsigned ACCESS :3; + unsigned PEEKEDCHARP :1; + unsigned CBUFDIRTY :1; + unsigned EXTENDABLE :1; + unsigned BOUTABLE :1; + unsigned BINABLE :1; +#else + unsigned CBUFPTR :28; + unsigned ACCESS :3; + unsigned PEEKEDCHARP :1; +#endif /* BIGVM */ + DLword PEEKEDCHAR; + DLbyte CHARSET; + DLbyte BYTESIZE; + DLword CBUFMAXSIZE; + DLword CHARPOSITION; +#ifdef BIGVM + unsigned FULLFILENAME :28; +#else + unsigned FULLFILENAME :24; + unsigned NIL1 :1; + unsigned EOLCONVENTION :2; + unsigned USERVISIBLE :1; +#endif /* BIGVM */ + unsigned USERCLOSEABLE :1; + unsigned MULTIBUFFERHINT :1; + unsigned REVALIDATEFLG :1; + unsigned NONDEFAULTDATEFLG :1; +#ifndef BIGVM + LispPTR DEVICE; +#else + unsigned DEVICE: 28; + unsigned CBUFDIRTY :1; + unsigned EXTENDABLE :1; + unsigned BOUTABLE :1; + unsigned BINABLE :1; +#endif /* BIGVM */ +#ifndef BIGVM + LispPTR VALIDATION; +#else + unsigned VALIDATION: 28; + unsigned NIL1 :1; + unsigned EOLCONVENTION :2; + unsigned USERVISIBLE :1; +#endif /* BIGVM */ + LispPTR CPAGE; + LispPTR EPAGE; + DLword LINELENGTH; + DLword EOFFSET; + LispPTR F1; + LispPTR F2; + LispPTR F3; + LispPTR F4; + LispPTR F5; + DLword FW7; + DLword FW6; + DLword FW9; + DLword FW8; + LispPTR F10; + LispPTR STRMBINFN; + LispPTR STRMBOUTFN; + LispPTR OUTCHARFN; + LispPTR ENDOFSTREAMOP; + LispPTR OTHERPROPS; + LispPTR IMAGEOPS; + LispPTR IMAGEDATA; + LispPTR BUFFS; + DLword NIL2; + DLword MAXBUFFERS; + LispPTR EXTRASTREAMOP; +}Stream; + +#endif /* BYTESWAP */ + diff --git a/inc/subrs.h b/inc/subrs.h new file mode 100755 index 0000000..d848eca --- /dev/null +++ b/inc/subrs.h @@ -0,0 +1,193 @@ +/* $Id: subrs.h,v 1.2 1999/01/03 02:06:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + +/* Do not edit this file! Instead, edit the list \initsubrs */ +/* on the lisp file LLSUBRS and then call WRITECALLSUBRS to */ +/* generate a new version. */ +#define sb_BACKGROUNDSUBR 06 +#define sb_CHECKBCPLPASSWORD 07 +#define sb_DISKPARTITION 010 +#define sb_DSPBOUT 011 +#define sb_DSPRATE 012 +#define sb_GATHERSTATS 013 +#define sb_GETPACKETBUFFER 014 +#define sb_LISPFINISH 015 +#define sb_MOREVMEMFILE 016 +#define sb_RAID 017 +#define sb_READRAWPBI 020 +#define sb_WRITERAWPBI 021 +#define sb_SETSCREENCOLOR 022 +#define sb_SHOWDISPLAY 023 +#define sb_PUPLEVEL1STATE 024 +#define sb_WRITESTATS 025 +#define sb_CONTEXTSWITCH 026 +#define sb_COPYSYS0SUBR 027 +#define sb_WRITEMAP 030 + +#define sb_UFS_GETFILENAME 042 +#define sb_UFS_DELETEFILE 043 +#define sb_UFS_RENAMEFILE 044 +#define sb_COM_READPAGES 045 +#define sb_COM_WRITEPAGES 046 +#define sb_COM_TRUNCATEFILE 047 + +#define sb_UFS_DIRECTORYNAMEP 051 +#define sb_COM_GETFREEBLOCK 055 +#define sb_SETUNIXTIME 060 +#define sb_GETUNIXTIME 061 +#define sb_COPYTIMESTATS 062 +#define sb_UNIX_USERNAME 063 +#define sb_UNIX_FULLNAME 064 +#define sb_UNIX_GETENV 065 +#define sb_UNIX_GETPARM 066 +#define sb_CHECK_SUM 067 +#define sb_ETHER_SUSPEND 070 +#define sb_ETHER_RESUME 071 +#define sb_ETHER_AVAILABLE 072 +#define sb_ETHER_RESET 073 +#define sb_ETHER_GET 074 +#define sb_ETHER_SEND 075 +#define sb_ETHER_SETFILTER 076 +#define sb_ETHER_CHECK 077 +#define sb_DSPCURSOR 0100 +#define sb_SETMOUSEXY 0101 +#define sb_DSP_VIDEOCOLOR 0102 +#define sb_DSP_SCREENWIDTH 0103 +#define sb_DSP_SCREENHEIGHT 0104 +#define sb_BITBLTSUB 0105 +#define sb_BLTCHAR 0106 +#define sb_TEDIT_BLTCHAR 0107 +#define sb_BITBLT_BITMAP 0110 +#define sb_BLTSHADE_BITMAP 0111 + +#define sb_RS232C_CMD 0112 +#define sb_RS232C_READ_INIT 0113 +#define sb_RS232C_WRITE 0114 + +#define sb_KEYBOARDBEEP 0120 +#define sb_KEYBOARDMAP 0121 +#define sb_KEYBOARDSTATE 0122 + +#define sb_VMEMSAVE 0131 +#define sb_LISP_FINISH 0132 +#define sb_NEWPAGE 0133 +#define sb_DORECLAIM 0134 +#define sb_DUMMY_135Q 0135 +#define sb_NATIVE_MEMORY_REFERENCE 0136 +#define sb_OLD_COMPILE_LOAD_NATIVE 0137 +#define sb_DISABLEGC 0140 + +#define sb_COM_SETFILEINFO 0147 +#define sb_COM_OPENFILE 0150 +#define sb_COM_CLOSEFILE 0151 +#define sb_DSK_GETFILENAME 0152 +#define sb_DSK_DELETEFILE 0153 +#define sb_DSK_RENAMEFILE 0154 +#define sb_COM_NEXT_FILE 0156 +#define sb_COM_FINISH_FINFO 0157 +#define sb_COM_GEN_FILES 0160 +#define sb_DSK_DIRECTORYNAMEP 0161 +#define sb_COM_GETFILEINFO 0162 +#define sb_COM_CHANGEDIR 0164 +#define sb_UNIX_HANDLECOMM 0165 +#define sb_OCR_COMM 0166 +#define sb_RPC_CALL 0167 +#define sb_MESSAGE_READP 0170 +#define sb_MESSAGE_READ 0171 +#define sb_MONITOR_CONTROL 0200 +#define sb_GET_NATIVE_ADDR_FROM_LISP_PTR 0203 +#define sb_GET_LISP_PTR_FROM_NATIVE_ADDR 0204 +#define sb_LOAD_NATIVE_FILE 0205 +#define sb_SUSPEND_LISP 0206 +#define sb_NEW_BLTCHAR 0207 +#define sb_COLOR_INIT 0210 +#define sb_COLOR_SCREENMODE 0211 +#define sb_COLOR_MAP 0212 +#define sb_COLOR_BASE 0213 +#define sb_C_SlowBltChar 0214 +#define sb_TCP_OP 0220 +#define sb_WITH_SYMBOL 0221 + + /* For linear-programming interface */ +#define sb_LP_SETUP 0230 +#define sb_LP_RUN 0231 + + /* For Native Windows */ +#define sb_MNW_OP 0244 +#define sb_QUERY_WINDOWS 0245 +#define sb_FILL_IN 0246 + + +/* DLD codes */ +#define sb_CALL_C_FN 0247 +#define sb_DLD_LINK 0250 +#define sb_DLD_UNLINK_BY_FILE 0251 +#define sb_DLD_UNLINK_BY_SYMBOL 0252 +#define sb_DLD_GET_SYMBOL 0253 +#define sb_DLD_GET_FUNC 0254 +#define sb_DLD_FUNCTION_EXECUTABLE_P 0255 +#define sb_DLD_LIST_UNDEFINED_SYM 0256 +#define sb_MALLOC 0257 +#define sb_FREE 0260 +#define sb_PUT_C_BASEBYTE 0261 +#define sb_GET_C_BASEBYTE 0262 +#define sb_SMASHING_APPLY 0263 + +#ifdef TRUECOLOR +#define sb_PICTURE_OP 0250 +#define sb_TRUE_COLOR_OP 0251 +#ifdef VIDEO +#define sb_VIDEO_OP 0252 +#endif /* VIDEO */ + +#endif /* TRUECOLOR */ + + +#define sb_CHAR_OPENFILE 0310 +#define sb_CHAR_BIN 0311 +#define sb_CHAR_BOUT 0312 +#define sb_CHAR_IOCTL 0313 +#define sb_CHAR_CLOSEFILE 0314 +#define sb_CHAR_EOFP 0315 +#define sb_CHAR_READP 0316 +#define sb_CHAR_BINS 0317 +#define sb_CHAR_BOUTS 0320 +#define sb_CHAR_FILLBUFFER 0321 + + + +/* MISCN opcodes */ +#define miscn_USER_SUBR 00 +#define miscn_VALUES 01 +#define miscn_SXHASH 02 +#define miscn_EQLHASHBITSFN 03 +#define miscn_STRINGHASHBITS 04 +#define miscn_STRING_EQUAL_HASHBITS 05 +#define miscn_VALUES_LIST 06 +#define miscn_LCFetchMethod 07 +#define miscn_LCFetchMethodOrHelp 010 +#define miscn_LCFindVarIndex 011 +#define miscn_LCGetIVValue 012 +#define miscn_LCPutIVValue 013 + +/* for accessing RAW RS232C port */ +#define miscn_RAW_RS232C_OPEN 050 +#define miscn_RAW_RS232C_CLOSE 051 +#define miscn_RAW_RS232C_SETPARAM 052 +#define miscn_RAW_RS232C_GETPARAM 053 +#define miscn_RAW_RS232C_READ 054 +#define miscn_RAW_RS232C_WRITE 055 +#define miscn_RAW_RS232C_SETINT 056 + +/* for CHATTER */ +#define miscn_CHATTER 040 + +/* for EJLISP */ +#define miscn_EJLISP 060 + +/* for CD-ROM */ +#define miscn_CDAUDIO 070 +#define miscn_CDROM 071 + +/* Assigned USER SUBR numbers */ +#define user_subr_DUMMY 012 +#define user_subr_SAMPLE_USER_SUBR 00 diff --git a/inc/sunerrno.h b/inc/sunerrno.h new file mode 100755 index 0000000..2aff1e7 --- /dev/null +++ b/inc/sunerrno.h @@ -0,0 +1,121 @@ +/* $Id: sunerrno.h,v 1.2 1999/01/03 02:06:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)errno.h 2.11 88/02/08 SMI; from UCB 4.1 82/12/28 */ + +/* + * Error codes + */ + +#define sunEPERM 1 /* Not owner */ +#define sunENOENT 2 /* No such file or directory */ +#define sunESRCH 3 /* No such process */ +#define sunEINTR 4 /* Interrupted system call */ +#define sunEIO 5 /* I/O error */ +#define sunENXIO 6 /* No such device or address */ +#define sunE2BIG 7 /* Arg list too long */ +#define sunENOEXEC 8 /* Exec format error */ +#define sunEBADF 9 /* Bad file number */ +#define sunECHILD 10 /* No children */ +#define sunEAGAIN 11 /* No more processes */ +#define sunENOMEM 12 /* Not enough core */ +#define sunEACCES 13 /* Permission denied */ +#define sunEFAULT 14 /* Bad address */ +#define sunENOTBLK 15 /* Block device required */ +#define sunEBUSY 16 /* Mount device busy */ +#define sunEEXIST 17 /* File exists */ +#define sunEXDEV 18 /* Cross-device link */ +#define sunENODEV 19 /* No such device */ +#define sunENOTDIR 20 /* Not a directory*/ +#define sunEISDIR 21 /* Is a directory */ +#define sunEINVAL 22 /* Invalid argument */ +#define sunENFILE 23 /* File table overflow */ +#define sunEMFILE 24 /* Too many open files */ +#define sunENOTTY 25 /* Not a typewriter */ +#define sunETXTBSY 26 /* Text file busy */ +#define sunEFBIG 27 /* File too large */ +#define sunENOSPC 28 /* No space left on device */ +#define sunESPIPE 29 /* Illegal seek */ +#define sunEROFS 30 /* Read-only file system */ +#define sunEMLINK 31 /* Too many links */ +#define sunEPIPE 32 /* Broken pipe */ + +/* math software */ +#define sunEDOM 33 /* Argument too large */ +#define sunERANGE 34 /* Result too large */ + +/* non-blocking and interrupt i/o */ +#define sunEWOULDBLOCK 35 /* Operation would block */ +#define sunEINPROGRESS 36 /* Operation now in progress */ +#define sunEALREADY 37 /* Operation already in progress */ +/* ipc/network software */ + + /* argument errors */ +#define sunENOTSOCK 38 /* Socket operation on non-socket */ +#define sunEDESTADDRREQ 39 /* Destination address required */ +#define sunEMSGSIZE 40 /* Message too long */ +#define sunEPROTOTYPE 41 /* Protocol wrong type for socket */ +#define sunENOPROTOOPT 42 /* Protocol not available */ +#define sunEPROTONOSUPPORT 43 /* Protocol not supported */ +#define sunESOCKTNOSUPPORT 44 /* Socket type not supported */ +#define sunEOPNOTSUPP 45 /* Operation not supported on socket */ +#define sunEPFNOSUPPORT 46 /* Protocol family not supported */ +#define sunEAFNOSUPPORT 47 /* Address family not supported by protocol family */ +#define sunEADDRINUSE 48 /* Address already in use */ +#define sunEADDRNOTAVAIL 49 /* Can't assign requested address */ + + /* operational errors */ +#define sunENETDOWN 50 /* Network is down */ +#define sunENETUNREACH 51 /* Network is unreachable */ +#define sunENETRESET 52 /* Network dropped connection on reset */ +#define sunECONNABORTED 53 /* Software caused connection abort */ +#define sunECONNRESET 54 /* Connection reset by peer */ +#define sunENOBUFS 55 /* No buffer space available */ +#define sunEISCONN 56 /* Socket is already connected */ +#define sunENOTCONN 57 /* Socket is not connected */ +#define sunESHUTDOWN 58 /* Can't send after socket shutdown */ +#define sunETOOMANYREFS 59 /* Too many references: can't splice */ +#define sunETIMEDOUT 60 /* Connection timed out */ +#define sunECONNREFUSED 61 /* Connection refused */ + + /* */ +#define sunELOOP 62 /* Too many levels of symbolic links */ +#define sunENAMETOOLONG 63 /* File name too long */ + +/* should be rearranged */ +#define sunEHOSTDOWN 64 /* Host is down */ +#define sunEHOSTUNREACH 65 /* No route to host */ +#define sunENOTEMPTY 66 /* Directory not empty */ + +/* quotas & mush */ +#define sunEPROCLIM 67 /* Too many processes */ +#define sunEUSERS 68 /* Too many users */ +#define sunEDQUOT 69 /* Disc quota exceeded */ + +/* Network File System */ +#define sunESTALE 70 /* Stale NFS file handle */ +#define sunEREMOTE 71 /* Too many levels of remote in path */ + +/* streams */ +#define sunENOSTR 72 /* Device is not a stream */ +#define sunETIME 73 /* Timer expired */ +#define sunENOSR 74 /* Out of streams resources */ +#define sunENOMSG 75 /* No message of desired type */ +#define sunEBADMSG 76 /* Trying to read unreadable message */ + +/* SystemV IPC */ +#define sunEIDRM 77 /* Identifier removed */ + +/* SystemV Record Locking */ +#define sunEDEADLK 78 /* Deadlock condition. */ +#define sunENOLCK 79 /* No record locks available. */ + +/* RFS */ +#define sunENONET 80 /* Machine is not on the network */ +#define sunERREMOTE 81 /* Object is remote */ +#define sunENOLINK 82 /* the link has been severed */ +#define sunEADV 83 /* advertise error */ +#define sunESRMNT 84 /* srmount error */ +#define sunECOMM 85 /* Communication error on send */ +#define sunEPROTO 86 /* Protocol error */ +#define sunEMULTIHOP 87 /* multihop attempted */ +#define sunEDOTDOT 88 /* Cross mount point (not an error) */ +#define sunEREMCHG 89 /* Remote address changed */ diff --git a/inc/sunfilio.h b/inc/sunfilio.h new file mode 100755 index 0000000..ab1257c --- /dev/null +++ b/inc/sunfilio.h @@ -0,0 +1,27 @@ +/* $Id: sunfilio.h,v 1.2 1999/01/03 02:06:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)filio.h 1.3 88/02/08 SMI; from UCB ioctl.h 7.1 6/4/86 */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +/* + * General file ioctl definitions. + */ +#ifndef _filio_h +#define _filio_h + +#include + +#define sunFIOCLEX _sunIO(f, 1) /* set exclusive use on fd */ +#define sunFIONCLEX _sunIO(f, 2) /* remove exclusive use */ +/* another local */ +#define sunFIONREAD _sunIOR(f, 127, int) /* get # bytes to read */ +#define sunFIONBIO _sunIOW(f, 126, int) /* set/clear non-blocking i/o */ +#define sunFIOASYNC _sunIOW(f, 125, int) /* set/clear async i/o */ +#define sunFIOSETOWN _sunIOW(f, 124, int) /* set owner */ +#define sunFIOGETOWN _sunIOR(f, 123, int) /* get owner */ + +#endif diff --git a/inc/sunioccom.h b/inc/sunioccom.h new file mode 100755 index 0000000..8feae5d --- /dev/null +++ b/inc/sunioccom.h @@ -0,0 +1,33 @@ +/* $Id: sunioccom.h,v 1.2 1999/01/03 02:06:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)ioccom.h 1.3 88/02/08 SMI; from UCB ioctl.h 7.1 6/4/86 */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef _sunIO + +/* + * Ioctl's have the command encoded in the lower word, + * and the size of any in or out parameters in the upper + * word. The high 2 bits of the upper word are used + * to encode the in/out status of the parameter; for now + * we restrict parameters to at most 255 bytes. + */ +#define sunIOCPARM_MASK 0xff /* parameters must be < 256 bytes */ +#define sunIOC_VOID 0x20000000 /* no parameters */ +#define sunIOC_OUT 0x40000000 /* copy out parameters */ +#define sunIOC_IN 0x80000000 /* copy in parameters */ +#define sunIOC_INOUT (sunIOC_IN|sunIOC_OUT) +/* the 0x20000000 is so we can distinguish new ioctl's from old */ +#define _sunIO(x,y) (sunIOC_VOID|('x'<<8)|y) +#define _sunIOR(x,y,t) (sunIOC_OUT|((sizeof(t)&sunIOCPARM_MASK)<<16)|('x'<<8)|y) +#define _sunIORN(x,y,t) (sunIOC_OUT|(((t)&sunIOCPARM_MASK)<<16)|('x'<<8)|y) +#define _sunIOW(x,y,t) (sunIOC_IN|((sizeof(t)&sunIOCPARM_MASK)<<16)|('x'<<8)|y) +#define _sunIOWN(x,y,t) (sunIOC_IN|(((t)&sunIOCPARM_MASK)<<16)|('x'<<8)|y) +/* this should be _sunIORW, but stdio got there first */ +#define _sunIOWR(x,y,t) (sunIOC_INOUT|((sizeof(t)&sunIOCPARM_MASK)<<16)|('x'<<8)|y) + +#endif diff --git a/inc/suntermios.h b/inc/suntermios.h new file mode 100755 index 0000000..876ecf0 --- /dev/null +++ b/inc/suntermios.h @@ -0,0 +1,119 @@ +/* $Id: suntermios.h,v 1.2 1999/01/03 02:06:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)termios.h 1.8 88/02/08 SMI */ + +#ifndef sun_TERMIOS_ +#define sun_TERMIOS_ + + +/* input modes */ +#define sunIGNBRK 0x00000001 +#define sunBRKINT 0x00000002 +#define sunIGNPAR 0x00000004 +#define sunPARMRK 0x00000008 +#define sunINPCK 0x00000010 +#define sunISTRIP 0x00000020 +#define sunINLCR 0x00000040 +#define sunIGNCR 0x00000080 +#define sunICRNL 0x00000100 +#define sunIUCLC 0x00000200 +#define sunIXON 0x00000400 +#define sunIXANY 0x00000800 +#define sunIXOFF 0x00001000 +#define sunIMAXBEL 0x00002000 + +/* output modes */ +#define sunOPOST 0x00000001 +#define sunOLCUC 0x00000002 +#define sunONLCR 0x00000004 +#define sunOCRNL 0x00000008 +#define sunONOCR 0x00000010 +#define sunONLRET 0x00000020 +#define sunOFILL 0x00000040 +#define sunOFDEL 0x00000080 +#define sunNLDLY 0x00000100 +#define sunNL0 0 +#define sunNL1 0x00000100 +#define sunCRDLY 0x00000600 +#define sunCR0 0 +#define sunCR1 0x00000200 +#define sunCR2 0x00000400 +#define sunCR3 0x00000600 +#define sunTABDLY 0x00001800 +#define sunTAB0 0 +#define sunTAB1 0x00000800 +#define sunTAB2 0x00001000 +#define sunXTABS 0x00001800 +#define sunTAB3 sunXTABS +#define sunBSDLY 0x00002000 +#define sunBS0 0 +#define sunBS1 0x00002000 +#define sunVTDLY 0x00004000 +#define sunVT0 0 +#define sunVT1 0x00004000 +#define sunFFDLY 0x00008000 +#define sunFF0 0 +#define sunFF1 0x00008000 +#define sunPAGEOUT 0x00010000 +#define sunWRAP 0x00020000 + +/* control modes */ +#define sunCBAUD 0x0000000f +#define sunCSIZE 0x00000030 +#define sunCS5 0 +#define sunCS6 0x00000010 +#define sunCS7 0x00000020 +#define sunCS8 0x00000030 +#define sunCSTOPB 0x00000040 +#define sunCREAD 0x00000080 +#define sunPARENB 0x00000100 +#define sunPARODD 0x00000200 +#define sunHUPCL 0x00000400 +#define sunCLOCAL 0x00000800 +#define sunLOBLK 0x00001000 +#define sunCIBAUD 0x000f0000 +#define sunCRTSCTS 0x80000000 + +#define sunIBSHIFT 16 + +/* line discipline 0 modes */ +#define sunISIG 0x00000001 +#define sunICANON 0x00000002 +#define sunXCASE 0x00000004 +#define sunECHO 0x00000008 +#define sunECHOE 0x00000010 +#define sunECHOK 0x00000020 +#define sunECHONL 0x00000040 +#define sunNOFLSH 0x00000080 +#define sunTOSTOP 0x00000100 +#define sunECHOCTL 0x00000200 +#define sunECHOPRT 0x00000400 +#define sunECHOKE 0x00000800 +#define sunDEFECHO 0x00001000 +#define sunFLUSHO 0x00002000 +#define sunPENDIN 0x00004000 /* sigh */ + +/* + * sunIoctl control packet + */ +struct suntermios { + unsigned long sunc_iflag; /* input modes */ + unsigned long sunc_oflag; /* output modes */ + unsigned long sunc_cflag; /* control modes */ + unsigned long sunc_lflag; /* line discipline modes */ + char sunc_line; /* line discipline XXX */ + unsigned char sunc_cc[037]; /* control chars */ +}; + +/* codes 1 through 5 are old "termio" calls */ +#define sunTCXONC _sunIO(T, 6) +#define sunTCFLSH _sunIO(T, 7) +#define sunTCGETS _sunIOR(T, 8, struct suntermios) +#define sunTCSETS _sunIOW(T, 9, struct suntermios) +#define sunTCSETSW _sunIOW(T, 10, struct suntermios) +#define sunTCSETSF _sunIOW(T, 11, struct suntermios) +#define sunTCSNDBRK _sunIO(T, 12) +#define sunTCDRAIN _sunIO(T, 13) + +#include "sunttycom.h" + +#endif diff --git a/inc/sunttold.h b/inc/sunttold.h new file mode 100755 index 0000000..5c70cf1 --- /dev/null +++ b/inc/sunttold.h @@ -0,0 +1,170 @@ +/* $Id: sunttold.h,v 1.2 1999/01/03 02:06:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)ttold.h 1.6 88/02/08 SMI; from S5R2 6.1 */ + +#ifndef sun_TTOLD_ +#define _sunTTOLD_ + +struct suntchars { + char t_intrc; /* interrupt */ + char t_quitc; /* quit */ + char t_startc; /* start output */ + char t_stopc; /* stop output */ + char t_eofc; /* end-of-file */ + char t_brkc; /* input delimiter (like nl) */ +}; + +struct sunltchars { + char t_suspc; /* stop process signal */ + char t_dsuspc; /* delayed stop process signal */ + char t_rprntc; /* reprint line */ + char t_flushc; /* flush output (toggles) */ + char t_werasc; /* word erase */ + char t_lnextc; /* literal next character */ +}; + +/* + * Structure for TIOCGETP and TIOCSETP ioctls. + */ + +#ifndef _sunSGTTYB_ +#define _sunSGTTYB_ +struct sunsgttyb { + char sunsg_ispeed; /* input speed */ + char sunsg_ospeed; /* output speed */ + char sunsg_erase; /* erase character */ + char sunsg_kill; /* kill character */ + short sunsg_flags; /* mode flags */ +}; +#endif + +#include + +/* + * 4.3BSD tty ioctl commands that are either: + * 1) deprecated + * 2) not implemented (and never were implemented) + * 3) implemented on top of new-style "ioctl"s. + */ +#define sunTIOCGETD _sunIOR(t, 0, int) /* get line discipline */ +#define sunTIOCSETD _sunIOW(t, 1, int) /* set line discipline */ +#define sunTIOCHPCL _sunIO(t, 2) /* hang up on last close */ +#define sunTIOCMODG _sunIOR(t, 3, int) /* get modem state - OBSOLETE */ +#define sunTIOCMODS _sunIOW(t, 4, int) /* set modem state - OBSOLETE */ +#define sunTIOCGETP _sunIOR(t, 8,struct sunsgttyb)/* get parameters -- gtty */ +#define sunTIOCSETP _sunIOW(t, 9,struct sunsgttyb)/* set parameters -- stty */ +#define sunTIOCSETN _sunIOW(t,10,struct sunsgttyb)/* as above, but no flushtty */ +#define sunTIOCEXCL _sunIO(t, 13) /* set exclusive use of tty */ +#define sunTIOCNXCL _sunIO(t, 14) /* reset exclusive use of tty */ +#define sunTIOCFLUSH _sunIOW(t, 16, int) /* flush buffers */ +#define sunTIOCSETC _sunIOW(t,17,struct suntchars)/* set special characters */ +#define sunTIOCGETC _sunIOR(t,18,struct suntchars)/* get special characters */ +#define sunO_TANDEM 0x00000001 /* send stopc on out q full */ +#define sunO_CBREAK 0x00000002 /* half-cooked mode */ +#define sunO_LCASE 0x00000004 /* simulate lower case */ +#define sunO_ECHO 0x00000008 /* echo input */ +#define sunO_CRMOD 0x00000010 /* map \r to \r\n on output */ +#define sunO_RAW 0x00000020 /* no i/o processing */ +#define sunO_ODDP 0x00000040 /* get/send odd parity */ +#define sunO_EVENP 0x00000080 /* get/send even parity */ +#define sunO_ANYP 0x000000c0 /* get any parity/send none */ +#define sunO_NLDELAY 0x00000300 /* \n delay */ +#define sunO_NL0 0x00000000 +#define sunO_NL1 0x00000100 /* tty 37 */ +#define sunO_NL2 0x00000200 /* vt05 */ +#define sunO_NL3 0x00000300 +#define sunO_TBDELAY 0x00000c00 /* horizontal tab delay */ +#define sunO_TAB0 0x00000000 +#define sunO_TAB1 0x00000400 /* tty 37 */ +#define sunO_TAB2 0x00000800 +#define sunO_XTABS 0x00000c00 /* expand tabs on output */ +#define sunO_CRDELAY 0x00003000 /* \r delay */ +#define sunO_CR0 0x00000000 +#define sunO_CR1 0x00001000 /* tn 300 */ +#define sunO_CR2 0x00002000 /* tty 37 */ +#define sunO_CR3 0x00003000 /* concept 100 */ +#define sunO_VTDELAY 0x00004000 /* vertical tab delay */ +#define sunO_FF0 0x00000000 +#define sunO_FF1 0x00004000 /* tty 37 */ +#define sunO_BSDELAY 0x00008000 /* \b delay */ +#define sunO_BS0 0x00000000 +#define sunO_BS1 0x00008000 +#define sunO_ALLDELAY (sunO_NLDELAY|sunO_TBDELAY|sunO_CRDELAY|sunO_VTDELAY|sunO_BSDELAY) +#define sunO_CRTBS 0x00010000 /* do backspacing for crt */ +#define sunO_PRTERA 0x00020000 /* \ ... / erase */ +#define sunO_CRTERA 0x00040000 /* " \b " to wipe out char */ +#define sunO_TILDE 0x00080000 /* hazeltine tilde kludge */ +#define sunO_MDMBUF 0x00100000 /* start/stop output on carrier intr */ +#define sunO_LITOUT 0x00200000 /* literal output */ +#define sunO_TOSTOP 0x00400000 /* SIGSTOP on background output */ +#define sunO_FLUSHO 0x00800000 /* flush output to terminal */ +#define sunO_NOHANG 0x01000000 /* no SIGHUP on carrier drop */ +#define sunO_L001000 0x02000000 +#define sunO_CRTKIL 0x04000000 /* kill line with " \b " */ +#define sunO_PASS8 0x08000000 +#define sunO_CTLECH 0x10000000 /* echo control chars as ^X */ +#define sunO_PENDIN 0x20000000 /* tp->t_rawq needs reread */ +#define sunO_DECCTQ 0x40000000 /* only ^Q starts after ^S */ +#define sunO_NOFLSH 0x80000000 /* no output flush on signal */ +/* locals, from 127 down */ +#define sunTIOCLBIS _sunIOW(t, 127, int) /* bis local mode bits */ +#define sunTIOCLBIC _sunIOW(t, 126, int) /* bic local mode bits */ +#define sunTIOCLSET _sunIOW(t, 125, int) /* set entire local mode word */ +#define sunTIOCLGET _sunIOR(t, 124, int) /* get local modes */ +#define sunLCRTBS (sunO_CRTBS>>16) +#define sunLPRTERA (sunO_PRTERA>>16) +#define sunLCRTERA (sunO_CRTERA>>16) +#define sunLTILDE (sunO_TILDE>>16) +#define sunLMDMBUF (sunO_MDMBUF>>16) +#define sunLLITOUT (sunO_LITOUT>>16) +#define sunLTOSTOP (sunO_TOSTOP>>16) +#define sunLFLUSHO (sunO_FLUSHO>>16) +#define sunLNOHANG (sunO_NOHANG>>16) +#define sunLCRTKIL (sunO_CRTKIL>>16) +#define sunLPASS8 (sunO_PASS8>>16) +#define sunLCTLECH (sunO_CTLECH>>16) +#define sunLPENDIN (sunO_PENDIN>>16) +#define sunLDECCTQ (sunO_DECCTQ>>16) +#define sunLNOFLSH (sunO_NOFLSH>>16) +#define sunTIOCSBRK _sunIO(t, 123) /* set break bit */ +#define sunTIOCCBRK _sunIO(t, 122) /* clear break bit */ +#define sunTIOCSDTR _sunIO(t, 121) /* set data terminal ready */ +#define sunTIOCCDTR _sunIO(t, 120) /* clear data terminal ready */ +#define sunTIOCSLTC _sunIOW(t,117,struct sunltchars)/* set local special chars */ +#define sunTIOCGLTC _sunIOR(t,116,struct sunltchars)/* get local special chars */ +#define sunTIOCSTOP _sunIO(t, 111) /* stop output, like ^S */ +#define sunTIOCSTART _sunIO(t, 110) /* start output, like ^Q */ + +/* + * Sun-specific ioctls, which have been moved to the Sun-specific range. + * The old codes will be kept around for binary compatibility; the + * codes for TIOCCONS and TIOCGSIZE don't collide with the 4.3BSD codes + * because the structure size and copy direction fields are different. + * Unfortunately, the old TIOCSSIZE code does collide with TIOCSWINSZ, + * but they can be disambiguated by checking whether a "struct ttysize" + * structure's "ts_lines" field is greater than 64K or not. If so, + * it's almost certainly a "struct winsize" instead. + */ +#define sun_O_TIOCCONS _sunIO(t, 104) /* get console I/O */ +#define sun_O_TIOCSSIZE _sunIOW(t,103,struct ttysize)/* get tty size */ +#define sun_O_TIOCGSIZE _sunIOR(t,102,struct ttysize)/* get tty size */ + +/* + * Sun-specific ioctls. + */ +#define sunTIOCSETX _sunIOW(t, 34, int) /* set extra modes for S5 compatibility */ +#define sunTIOCGETX _sunIOR(t, 35, int) /* get extra modes for S5 compatibility */ +#define sunNOPOST 0x00000001 /* no processing on output (LITOUT with 7 bits + parity) */ +#define sunNOISIG 0x00000002 /* disable all signal-generating characters */ +#define sunSTOPB 0x00000004 /* two stop bits */ + +#define sunOTTYDISC 0 /* old, v7 std tty driver */ +#define sunNETLDISC 1 /* line discip for berk net */ +#define sunNTTYDISC 2 /* new tty discipline */ +#define sunTABLDISC 3 /* hitachi tablet discipline */ +#define sunNTABLDISC 4 /* gtco tablet discipline */ +#define sunMOUSELDISC 5 /* mouse discipline */ +#define sunKBDLDISC 6 /* up/down keyboard trans (console) */ + +#include + +#endif diff --git a/inc/sunttycom.h b/inc/sunttycom.h new file mode 100755 index 0000000..a2cd297 --- /dev/null +++ b/inc/sunttycom.h @@ -0,0 +1,69 @@ +/* $Id: sunttycom.h,v 1.2 1999/01/03 02:06:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)ttycom.h 1.5 88/02/08 SMI */ + +#ifndef _sunTTYCOM_ +#define _sunTTYCOM_ + +/* + * Window/terminal size structure. + * This information is stored by the kernel + * in order to provide a consistent interface, + * but is not used by the kernel. + * + */ + +#define sunTIOCGWINSZ _sunIOR(t, 104, struct winsize) /* get window size */ +#define sunTIOCSWINSZ _sunIOW(t, 103, struct winsize) /* set window size */ + + +#define sunTIOCSSIZE _sunIOW(t,37,struct ttysize)/* set tty size */ +#define sunTIOCGSIZE _sunIOR(t,38,struct ttysize)/* get tty size */ + +/* + * 4.3BSD and SunOS terminal "ioctl"s with no "termios" equivalents. + * This file is included by and indirectly by + * so that programs that include either one have these "ioctl"s defined. + */ +#define sunTIOCGPGRP _sunIOR(t, 119, int) /* get pgrp of tty */ +#define sunTIOCSPGRP _sunIOW(t, 118, int) /* set pgrp of tty */ +#define sunTIOCOUTQ _sunIOR(t, 115, int) /* output queue size */ +#define sunTIOCSTI _sunIOW(t, 114, char) /* simulate terminal input */ +#define sunTIOCNOTTY _sunIO(t, 113) /* void tty association */ +#define sunTIOCPKT _sunIOW(t, 112, int) /* pty: set/clear packet mode */ +#define sunTIOCPKT_DATA 0x00 /* data packet */ +#define sunTIOCPKT_FLUSHREAD 0x01 /* flush data not yet written to controller */ +#define sunTIOCPKT_FLUSHWRITE 0x02 /* flush data read from controller but not yet processed */ +#define sunTIOCPKT_STOP 0x04 /* stop output */ +#define sunTIOCPKT_START 0x08 /* start output */ +#define sunTIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ +#define sunTIOCPKT_DOSTOP 0x20 /* now do ^S, ^Q */ +#define sunTIOCPKT_IOCTL 0x40 /* "ioctl" packet */ +#define sunTIOCMSET _sunIOW(t, 109, int) /* set all modem bits */ +#define sunTIOCMBIS _sunIOW(t, 108, int) /* bis modem bits */ +#define sunTIOCMBIC _sunIOW(t, 107, int) /* bic modem bits */ +#define sunTIOCMGET _sunIOR(t, 106, int) /* get all modem bits */ +#define sunTIOCM_LE 0001 /* line enable */ +#define sunTIOCM_DTR 0002 /* data terminal ready */ +#define sunTIOCM_RTS 0004 /* request to send */ +#define sunTIOCM_ST 0010 /* secondary transmit */ +#define sunTIOCM_SR 0020 /* secondary receive */ +#define sunTIOCM_CTS 0040 /* clear to send */ +#define sunTIOCM_CAR 0100 /* carrier detect */ +#define sunTIOCM_CD sunTIOCM_CAR +#define sunTIOCM_RNG 0200 /* ring */ +#define sunTIOCM_RI sunTIOCM_RNG +#define sunTIOCM_DSR 0400 /* data set ready */ + +#define sunTIOCREMOTE _sunIOW(t, 105, int) /* remote input editing */ +#define sunTIOCUCNTL _sunIOW(t, 102, int) /* pty: set/clr usr cntl mode */ + +/* + * Sun-specific ioctls with no "termios" equivalents. + */ +#define sunTIOCTCNTL _sunIOW(t, 32, int) /* pty: set/clr intercept ioctl mode */ +#define sunTIOCSIGNAL _sunIOW(t, 33, int) /* pty: send signal to slave */ +#define sunTIOCCONS _sunIO(t, 36) /* get console I/O */ +#define sunTIOCSSOFTCAR _sunIOW(t, 101, int) /* set soft carrier flag */ +#define sunTIOCGSOFTCAR _sunIOR(t, 100, int) /* get soft carrier flag */ + +#endif diff --git a/inc/sunttydev.h b/inc/sunttydev.h new file mode 100755 index 0000000..e02eb88 --- /dev/null +++ b/inc/sunttydev.h @@ -0,0 +1,29 @@ +/* $Id: sunttydev.h,v 1.2 1999/01/03 02:06:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* @(#)ttydev.h 2.6 88/02/08 SMI; from UCB 4.3 83/05/18 */ + +/* + * Terminal definitions related to underlying hardware. + */ +#ifndef sun_TTYDEV_ +#define sun_TTYDEV_ + +/* + * Speeds + */ +#define sunB0 0 +#define sunB50 1 +#define sunB75 2 +#define sunB110 3 +#define sunB134 4 +#define sunB150 5 +#define sunB200 6 +#define sunB300 7 +#define sunB600 8 +#define sunB1200 9 +#define sunB1800 10 +#define sunB2400 11 +#define sunB4800 12 +#define sunB9600 13 +#define sunB19200 14 +#define sunB38400 15 +#endif diff --git a/inc/sysatms.h b/inc/sysatms.h new file mode 100755 index 0000000..0e7aaaa --- /dev/null +++ b/inc/sysatms.h @@ -0,0 +1,35 @@ +/* $Id: sysatms.h,v 1.2 1999/01/03 02:06:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************/ +/* + File Name : systematoms.h + + Created : Takeshi Shimizu (Aug-20-87) + Last edited: Yasuhiko Kiuchi (Aug-24-87) for init.sun(21-Aug-87) + ver: Aug 20 87 + +*/ +/************************************************************/ + + + + +#define ATOM_MDSFREEPAGE 05353 /* \MDSFREELISTPAGE */ +#define ATOM_NxtMDSPage 03553 /* \NxtMDSPage */ +#define ATOM_NxtArrayPage 03551 /* \NxtArrayPage */ +#define ATOM_LeastMDSPage 03567 /* \LeastMDSPage */ +#define ATOM_ArrayFrLst 03552 /* \ArrayFrLst */ +#define ATOM_RECLAIMCOUNTDOWN 02113 /* \RECLAIM.COUNTDOWN */ diff --git a/inc/sysatms.h- b/inc/sysatms.h- new file mode 100755 index 0000000..c42aa6c --- /dev/null +++ b/inc/sysatms.h- @@ -0,0 +1,36 @@ +/* %Z% %M% Version %I% (%G%). copyright envos & Fuji Xerox */ + +/* + * Copyright (C) 1987 by Fuji Xerox Co., Ltd. All rights reserved. + * + * Author : Takeshi Shimizu + * Hiroshi Hayata + */ +/************************************************************/ +/* + File Name : sysatms.c + + Created : Takeshi Shimizu (Aug-20-87) + Last edited: Yasuhiko Kiuchi (Aug-24-87) for init.sun(21-Aug-87) + ver: Aug 20 87 + +*/ +/************************************************************/ + + +/************************************************************************/ +/* */ +/* Copyright 1989, 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + +#define ATOM_MDSFREEPAGE 05353 /* \MDSFREELISTPAGE */ +#define ATOM_NxtMDSPage 03553 /* \NxtMDSPage */ +#define ATOM_NxtArrayPage 03551 /* \NxtArrayPage */ +#define ATOM_LeastMDSPage 03567 /* \LeastMDSPage */ +#define ATOM_ArrayFrLst 03552 /* \ArrayFrLst */ +#define ATOM_RECLAIMCOUNTDOWN 02113 /* \RECLAIM.COUNTDOWN */ diff --git a/inc/timeout.h b/inc/timeout.h new file mode 100755 index 0000000..b28756b --- /dev/null +++ b/inc/timeout.h @@ -0,0 +1,82 @@ +/* $Id: timeout.h,v 1.2 1999/01/03 02:06:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +extern jmp_buf jmpbuf; + + + + +/*** TIMEOUT_TIME is changeable by UNIX env var LDEFILETIMEOUT. +#define TIMEOUT_TIME 10 **/ + +extern int TIMEOUT_TIME; + + +#define SETJMP(x) \ + { \ + if(setjmp(jmpbuf) != 0) return(x); \ + } + +#define TIMEOUT(exp) \ + { \ + alarm(TIMEOUT_TIME); \ + INTRSAFE(exp); \ + alarm(0); \ + } + +#define TIMEOUT0(exp) \ + { \ + alarm(TIMEOUT_TIME); \ + INTRSAFE0(exp); \ + alarm(0); \ + } + +#define S_TOUT(exp) \ + alarm(TIMEOUT_TIME),\ + (exp), \ + alarm(0) + +#define ERRSETJMP(rval) \ + { \ + if(setjmp(jmpbuf) != 0) \ + { \ + *Lisp_errno = 100; \ + return(rval); \ + } \ + } + + +/************************************************************************/ +/* */ +/* INTRSAFE */ +/* */ +/* Put a check for EINTR around a system call, and keep executing */ +/* the call until we don't get that error any more. */ +/* */ +/************************************************************************/ + +#define INTRSAFE(exp) \ + do {} while ((int)(exp) == -1 && errno == EINTR) + +#define INTRSAFE0(exp) \ + do {} while ((int)(exp) == 0 && errno == EINTR) + +#ifdef OS5 +#define INTRCHECK(exp,var) \ + while ((int)var == 0 && errno == EINTR) { exp; } +#else +#define INTRCHECK(exp,var) +#endif diff --git a/inc/tos1defs.h b/inc/tos1defs.h new file mode 100755 index 0000000..744c4bc --- /dev/null +++ b/inc/tos1defs.h @@ -0,0 +1,129 @@ +/* $Id: tos1defs.h,v 1.2 1999/01/03 02:06:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* T O P - O F - S T A C K D E F I N I T I O N S */ +/* */ +/* TOPOFSTACK cached top of stack value. */ +/* CSTKPTR points to where TOPOFSTACK should be stored. */ +/* */ +/************************************************************************/ + +#ifndef BYTESWAP + /********************************************************/ + /* Normal byte-order definitions, for e.g., 68020s */ + /********************************************************/ + +/* These are the TOS manipulation Macros */ + +#define HARD_PUSH(x) *(CSTKPTRL++) = x +#define PUSH(x) {HARD_PUSH(TOPOFSTACK); TOPOFSTACK = x;} +#define POP TOPOFSTACK = *(--CSTKPTRL) +#define GET_TOS_1 *(CSTKPTR - 1) +#define GET_TOS_2 *(CSTKPTR - 2) +#define GET_POPPED *CSTKPTR +#define POP_TOS_1 *(--CSTKPTRL) +#define TOPOFSTACK tscache +#define FIXTOS1 CSTKPTRL++ +#define GET_TOS_1_HI *((DLword *)(CSTKPTR - 1)) +#define GET_TOS_1_LO *((DLword *)(CSTKPTR - 1)+1) + +#else + + /********************************************************/ + /* Byte-swapped definitions, for e.g., 80386s */ + /********************************************************/ + +/* These are the TOS manipulation Macros */ + +#define HARD_PUSH(x) *(CSTKPTRL++) = x +#define PUSH(x) {HARD_PUSH(TOPOFSTACK); TOPOFSTACK = x;} +#define POP TOPOFSTACK = *(--CSTKPTRL) +#define GET_TOS_1 *(CSTKPTR - 1) +#define GET_TOS_2 *(CSTKPTR - 2) +#define GET_POPPED *CSTKPTR +#define POP_TOS_1 *(--CSTKPTRL) +#define TOPOFSTACK tscache +#define FIXTOS1 CSTKPTRL++ +#define GET_TOS_1_HI GETWORD((DLword *)(CSTKPTR - 1)) +#define GET_TOS_1_LO GETWORD((DLword *)(CSTKPTR - 1)+1) + +#endif /* BYTESWAP */ + + +/* OPCODE interface routines */ + +#define StackPtrSave {CurrentStackPTR = (DLword *) (CSTKPTR-1);} +#define StackPtrRestore {CSTKPTRL = ((LispPTR *) CurrentStackPTR)+1;} + + + +#define EXT { PC=pccache-1; \ + TopOfStack=TOPOFSTACK; \ + StackPtrSave; } + +#define RET { pccache=PC+1; \ + StackPtrRestore; \ + TOPOFSTACK = TopOfStack; } + +#define NRET { RET; nextop0; } + + +#define RET_FROM_NATIVE \ +{ \ + POP; \ + PCMACL += 1; \ + table = optable; \ +} + + +#ifdef NATIVETRAN +#define NATIVE_NEXTOP0 { \ + if (BCE_CURRENTFX->native) { RET_TO_NATIVE; } \ + nextop0; \ + } +#else +#define NATIVE_NEXTOP0 nextop0 +#endif + + +#define CALL_NATIVE(defcell, num_args) \ +{ \ + setivar_pvar_jmp(CSTKPTR + num_args, PVAR, \ + ((int *)(GET_NATIVE_ADDR(defcell)))[num_args+(6+2)]); \ +} + +#define CALL_NATIVE2(defcell, num_args) \ +{ \ + setivar_pvar_jmp(CSTKPTR + num_args, PVAR, \ + ((int *)(GET_NATIVE_ADDR(defcell))) \ + [(num_args <= -6) ? ((6+2)-6) : (num_args+(6+2))]); \ +} + + +#define RET_TO_NATIVE { \ + register int native_addr; \ + register struct fnhead *LocFuncObj = FuncObj; \ + if (native_addr = \ + ((int *)(GET_NATIVE_ADDR(LocFuncObj))) \ + [((UNSIGNED) PCMAC - (UNSIGNED) LocFuncObj)+(6+2)]) \ + { \ + HARD_PUSH(TOPOFSTACK); \ + setivar_pvar_jmp(IVAR, PVAR, native_addr); \ + }; \ + nextop0; \ + } diff --git a/inc/tosfns.h b/inc/tosfns.h new file mode 100755 index 0000000..a1029c6 --- /dev/null +++ b/inc/tosfns.h @@ -0,0 +1,806 @@ +/* $Id: tosfns.h,v 1.2 1999/01/03 02:06:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1998 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +/****************************************************************/ +/****** CURRENT Stack Overflow checks ********/ +/****************************************************************/ +/* JDS 22 May 96 this used to be just >, but were getting stack-overflow + with last frame right against the edge of the stack, which caused + lots of trouble w/ 0-length free blocks, etc. */ +#if 0 +#define FN_STACK_CHECK \ + if ((UNSIGNED)CSTKPTR >= (Irq_Stk_Check=(Irq_Stk_End-STK_MIN(LOCFNCELL)))) \ + goto check_interrupt; +#else +/* JDS 13 Feb 98 -- with Irq_Stk_Chk being unsigned, need to revise */ +/* the test; if Irq_Stk_Chk == 0, can't just do the subtraction now */ +/* or we get a HUGE unsigned, and the test doesn't work right. */ + +#define FN_STACK_CHECK \ + if ((Irq_Stk_End == 0) || \ + ((UNSIGNED)CSTKPTR > \ + (Irq_Stk_Check=(Irq_Stk_End-STK_MIN(LOCFNCELL))))) \ + goto check_interrupt; +#endif /* 0 */ + + +/****************************************************************/ +/****** LOCAL MACROS ********/ +/****************************************************************/ + +#ifdef BIGVM +#define SWAP_FNHEAD +#else +#undef SWAP_FNHEAD +#define SWAP_FNHEAD(x) SWAP_WORDS(x) +#endif /* BIGVM */ + + + +#ifdef NATIVETRAN +#define FN_CALL_NATIVE_CHECK(fncell, args, extra_code) \ +{ \ + if (fncell->native) \ + { \ + extra_code; \ + FuncObj = fncell; \ + HARD_PUSH(TOPOFSTACK); \ + CALL_NATIVE(fncell, args); \ + } \ +} + +#define FN_CALL_NATIVE_CHECK2(fncell, args, extra_code) \ +{ \ + if (fncell->native) \ + { \ + extra_code; \ + (UNSIGNED) PC = args; \ + FuncObj = fncell; \ + HARD_PUSH(TOPOFSTACK); \ + CALL_NATIVE2(fncell, args); \ + } \ +} + +#define ASM_LABEL_OF_FN_COMMON asm_label_op_fn_common() + +#else +#ifdef GCC386 +#define ASM_LABEL_OF_FN_COMMON asm("fn_common:"); +#else +#define ASM_LABEL_OF_FN_COMMON +#endif /* GCC386 */ + +#define FN_CALL_NATIVE_CHECK(fncell, args, extra_code) +#define FN_CALL_NATIVE_CHECK2(fncell, args, extra_code) +#endif /* NATIVETRAN */ + + + +/************************************************************************/ +/* */ +/* A P P L Y _ P O P _ P U S H _ T E S T */ +/* */ +/* Part of op_fn_common; decide what to do to the stack, depending */ +/* on whether we're FNcalling, APPLYing, or calling a UFN. What */ +/* happens depends on the value of fn_apply, which is set by */ +/* the various opcode macros, as follows: */ +/* */ +/* 0 Normal function calls; do nothing additional. */ +/* 1 APPLY: POP the #ARGS and FN-NAME arguments. */ +/* 2 UFN with 0 args from the opcode byte stream. Do nothing. */ +/* 3 UFN with 1 byte of arg from the code stream as a SMALLP */ +/* 4 UFN with 2 bytes of arg from the code stream as a SMALLP */ +/* 5 UFN with 3 bytes of arg from the code stream as a SMALLP */ +/* or as a symbol (for big atoms, e.g.) */ +/* 6 UFN with 4 bytes of arg from the code stream as a SMALLP */ +/* or as a symbol (for big atoms, e.g.) */ +/* */ +/* The latter 3 cases push the additional argument; THE 3-BYTE */ +/* CASE IS INCOMPLETE: IT SHOULD BOX ANY NON-SMALLP VALUES! */ +/* */ +/************************************************************************/ + +#ifdef BIGATOMS +#define APPLY_POP_PUSH_TEST \ + { \ + switch (fn_apply) \ + { \ + case 0: break; /* do nothing */ \ + case 1: POP; POP; break; /* from apply */ \ + case 2: break; /* ufn 0 args */ \ + case 3: PUSH(S_POSITIVE | Get_BYTE_PCMAC1); break; \ + case 4: PUSH(S_POSITIVE | Get_DLword_PCMAC1); break; \ + case 6: /* BIGVM possibility */ \ + case 5: { \ + unsigned int atm = Get_AtomNo_PCMAC1; \ + if (atm & SEGMASK) PUSH(atm) /* new atom */ \ + else PUSH(S_POSITIVE | atm); /* old atom as SMALLP*/\ + } \ + break; \ + default: error("Storage error: invalid UFN entry"); \ + } \ + if (needpush) PUSH(fn_atom_index); \ + } +#else /* not big atoms */ +#define APPLY_POP_PUSH_TEST \ + { \ + switch (fn_apply) \ + { \ + case 0: break; /* do nothing */ \ + case 1: POP; POP; break; /* from apply */ \ + case 2: break; /* ufn 0 args */ \ + case 3: PUSH(S_POSITIVE | Get_BYTE_PCMAC1); break; \ + case 4: PUSH(S_POSITIVE | Get_DLword_PCMAC1); break; \ + case 5: PUSH(S_POSITIVE | Get_AtomNo_PCMAC1); break; \ + default: error("Storage error: invalid UFN entry"); \ + } \ + if (needpush) PUSH(fn_atom_index); \ + } + +#endif /* BIGATOMS */ + + + +#define N_APPLY_POP_PUSH_TEST { \ + APPLY_POP_PUSH_TEST; \ + native_closure_env=closure_env; \ + } + +#define N_ENVCALL_POP_TEST { \ + CSTKPTRL -=2; \ + native_closure_env=closure_env; \ + } + + + +/****************************************************************/ +/****** OPAPPLY ********/ +/****************************************************************/ +#ifndef BIGATOMS +#define OPAPPLY { \ + if ( GET_TOS_1_HI == SPOS_HI ) { \ + fn_num_args = GET_TOS_1_LO; \ + fn_opcode_size = 1; \ + fn_apply = 1; \ + fn_atom_index = TOPOFSTACK; \ + FNTRACER(Trace_APPLY(fn_atom_index)); \ + FNCHECKER(if (quick_stack_check()) Trace_APPLY(fn_atom_index)); \ + if ( (SEGMASK & TOPOFSTACK) == 0) \ + { fn_defcell = (DefCell *) GetDEFCELL68k(TOPOFSTACK); \ + goto op_fn_common; \ + } \ + else \ + if (GetTypeNumber(TOPOFSTACK)==TYPE_COMPILED_CLOSURE) \ + { TopOfStack=TOPOFSTACK; \ + fn_defcell = (DefCell *) &TopOfStack; \ + goto op_fn_common; \ + } \ + else { fn_defcell = (DefCell *) GetDEFCELL68k(NIL_PTR); \ + goto op_fn_common; \ + } \ + } \ + goto op_ufn; \ +} /* OPAPPLY */ +#else +#define OPAPPLY { \ + if ( GET_TOS_1_HI == SPOS_HI ) { \ + fn_num_args = GET_TOS_1_LO; \ + fn_opcode_size = 1; \ + fn_apply = 1; \ + fn_atom_index = TOPOFSTACK; \ + FNTRACER(Trace_APPLY(fn_atom_index)); \ + FNCHECKER(if (quick_stack_check()) Trace_APPLY(fn_atom_index)); \ + if ( (SEGMASK & TOPOFSTACK) == 0) \ + { fn_defcell = (DefCell *) GetDEFCELLlitatom(TOPOFSTACK); \ + goto op_fn_common; \ + } \ + else switch (GetTypeNumber(TOPOFSTACK)) \ + { \ + case TYPE_NEWATOM: \ + fn_defcell = (DefCell *) GetDEFCELLnew(TOPOFSTACK); \ + goto op_fn_common; \ + case TYPE_COMPILED_CLOSURE: \ + TopOfStack=TOPOFSTACK; \ + fn_defcell = (DefCell *) &TopOfStack; \ + goto op_fn_common; \ + default: fn_defcell = (DefCell *) GetDEFCELL68k(NIL_PTR); \ + goto op_fn_common; \ + } /* end of switch */ \ + } \ + goto op_ufn; \ +} /* OPAPPLY */ +#endif /* BIGATOMS */ + + + +/****************************************************************/ +/****** OPFN(x) ********/ +/****************************************************************/ + +#if (defined(SUN3_OS3_OR_OS4_IL) && !(defined(NOASMFNCALL)) ) + +#ifdef NATIVETRAN + +#define OPFN(x, num_args_fn, fn_xna_args, fn_native) \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around). */ \ + fn_section1(); \ + fn_section2(); \ + num_args_fn(); \ + fn_native_test(); \ + fn_section3(); \ + fn_xna_args(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fn_native(); \ + fn_section5(); \ + /* asm code jumps here when not ccodep */ \ + { fn_atom_index = Get_AtomNo_PCMAC1; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = x; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ +} + +#define OPFNX \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around. */ \ + fnx_section1(); \ + fn_section2(); \ + fnx_args(); \ + fn_native_test(); \ + fn_section3(); \ + fnx_xna(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fnx_native(); \ + fn_section5(); \ + fn_atom_index = Get_AtomNo_PCMAC2; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = Get_BYTE_PCMAC1; \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + /* *** these carefully arranged to satisfy optimizer */ \ +label1: fast1_dispatcher(); \ +label2: to_native_label(); \ + \ +} +#else + +#define OPFN(x, num_args_fn, fn_xna_args, fn_native) \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around). */ \ + fn_section1(); \ + fn_section2(); \ + num_args_fn(); \ + fn_section3(); \ + fn_xna_args(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fn_section5(); \ + /* asm code jumps here when not ccodep */ \ + { fn_atom_index = Get_AtomNo_PCMAC1; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = x; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ +} + +#define OPFNX \ +{ /* asm inlines for fn call (much care put into keeping optimizer \ + from moving things around. */ \ + fnx_section1(); \ + fn_section2(); \ + fnx_args(); \ + fn_section3(); \ + fnx_xna(); \ + fn_section4(); \ + fast1_dispatcher(); /* nextop0 don't work here */ \ + fn_section5(); \ + fn_atom_index = Get_AtomNo_PCMAC2; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_num_args = Get_BYTE_PCMAC1; \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + /* *** these carefully arranged to satisfy optimizer */ \ +label1: fast1_dispatcher(); \ + \ +} + +#endif /* NATIVETRAN */ + + +#else + +#define OPFN(argcount, num_args_fn, fn_xna_args, fn_native) \ +{ /* argcount is a number of the arguments on stack */ \ + register struct fnhead *LOCFNCELL; \ + register int defcell_word; \ + register int NEXTBLOCK; \ + FNTRACER(Trace_FNCall(argcount, Get_AtomNo_PCMAC1, TOPOFSTACK, CSTKPTR-1)); \ + FNCHECKER(if (quick_stack_check()) Trace_FNCall(argcount, Get_AtomNo_PCMAC1, TOPOFSTACK,CSTKPTR-1)); \ + fn_defcell = (DefCell *)GetDEFCELL68k(fn_atom_index = Get_AtomNo_PCMAC1); \ + defcell_word = *(int *)fn_defcell; \ + FNTPRINT((" def cell = 0x%x.\n", defcell_word)); \ + if(!(fn_defcell->ccodep)) \ + { /* it's not a CCODEP */ \ + fn_num_args = argcount; \ + fn_opcode_size = FN_OPCODE_SIZE; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR((defcell_word &= POINTERMASK));\ + BCE_CURRENTFX->pc = ((UNSIGNED)PCMAC - (UNSIGNED)FuncObj) + FN_OPCODE_SIZE;\ + FN_CALL_NATIVE_CHECK(LOCFNCELL,-argcount,{}); \ + FN_STACK_CHECK; \ + {register UNSIGNED newivar; \ + newivar = (UNSIGNED) (IVARL = (DLword *)(CSTKPTR-argcount+1)); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + HARD_PUSH(TOPOFSTACK); /* save TOS */ \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = argcount - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(defcell_word); \ + CSTKPTRL = (LispPTR *)(((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + result = LOCFNCELL->pv; \ + if (result >= 0) \ + {register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + if (result > 0) \ + {HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + result-=1; \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } \ + } \ + } \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ + nextop0; \ +} /* end OPFN */ + + +/*************** OPFNX *************/ +#define OPFNX { \ + register struct fnhead *LOCFNCELL; \ + register DefCell *defcell; /* this reg is not allocated */ \ + register int NEXTBLOCK; \ + int num_args = Get_BYTE_PCMAC1; \ + defcell = (DefCell *) GetDEFCELL68k(Get_AtomNo_PCMAC2); \ + FNTRACER(Trace_FNCall(num_args, Get_AtomNo_PCMAC2, TOPOFSTACK, CSTKPTR-1)); \ + FNCHECKER(if (quick_stack_check()) Trace_FNCall(num_args, Get_AtomNo_PCMAC2, TOPOFSTACK, CSTKPTR-1)); \ + if( defcell->ccodep == 0 ) \ + { fn_defcell = defcell; \ + fn_num_args = num_args; \ + fn_opcode_size = FNX_OPCODE_SIZE; \ + fn_atom_index = Get_AtomNo_PCMAC2; \ + fn_apply = 0; \ + goto op_fn_common; \ + } \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(defcell->defpointer); \ + BCE_CURRENTFX->pc = ((UNSIGNED)PCMAC - (UNSIGNED)FuncObj) + FNX_OPCODE_SIZE;\ + FN_CALL_NATIVE_CHECK2(LOCFNCELL, - num_args, {}); \ + FN_STACK_CHECK; \ + {register UNSIGNED newivar; \ + newivar = (UNSIGNED)(IVARL = (DLword *)(CSTKPTR-num_args+1)); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + HARD_PUSH(TOPOFSTACK); /* save TOS */ \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = num_args - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(defcell->defpointer);\ + CSTKPTRL = (LispPTR *) (((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + result = LOCFNCELL->pv; \ + if (result >= 0) \ + {register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + if (result > 0) \ + {HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + result-=1; \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } \ + } \ + } \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ +} /* end OPFN */ + +#endif /* NOASMFNCALL */ + + + + + +/****************************************************************/ +/****** OPCHECKAPPLY ********/ +/****************************************************************/ +#ifdef BIGATOMS +#define OPCHECKAPPLY { \ + register DefCell *defcell; \ + defcell = (DefCell *) GetDEFCELL68k(TOPOFSTACK & POINTERMASK); \ + if (!( defcell->ccodep && (((TOPOFSTACK & SEGMASK) == 0) || (GetTypeNumber(TOPOFSTACK) == TYPE_NEWATOM)) && \ + ( ( defcell->argtype == 0 ) || ( defcell->argtype == 2 ) ) ) ) \ + goto op_ufn; \ +} +#else +#define OPCHECKAPPLY { \ + register DefCell *defcell; \ + defcell = (DefCell *) GetDEFCELL68k(TOPOFSTACK & POINTERMASK); \ + if (!( defcell->ccodep && ((TOPOFSTACK & SEGMASK) == 0) ) && \ + ( ( defcell->argtype == 0 ) || ( defcell->argtype == 2 ) ) ) \ + goto op_ufn; \ +} +#endif /* BIGATOMS */ + + +/****************************************************************/ +/* UFN_COMMON at op_ufn */ +/****************************************************************/ +#define GetUFNEntry(num) (((UFN *)UFNTable) + (num)) + +#define UFN_COMMON \ +op_ufn: use code in XC.c \ +{ register UFN *entry68k; \ + entry68k = (UFN *)GetUFNEntry(Get_BYTE_PCMAC0); \ + fn_num_args = entry68k->arg_num; \ + fn_opcode_size = entry68k->byte_num+1; \ + fn_atom_index = entry68k->atom_name; \ + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); \ + fn_apply = 0; \ + goto op_fn_common; \ + }; + + + +/****************************************************************/ +/****** OP_FN_COMMON ********/ +/* vars: */ +/* fn_atom_index */ +/* fn_num_args */ +/* fn_opcode_size */ +/* fn_defcell */ +/* fn_apply */ +/* */ +/* All Closure Calls go through here */ +/****************************************************************/ +#define needpush NEXTBLOCK +#define OP_FN_COMMON \ +op_fn_common: \ + ASM_LABEL_OF_FN_COMMON; \ +{ register struct fnhead *LOCFNCELL; \ + register DefCell *defcell; /* this reg is not allocated */ \ + CClosure *closure; \ + LispPTR closure_env = (LispPTR) 0xffffffff; \ + {register int NEXTBLOCK = NIL; \ + defcell = fn_defcell; \ + if( (defcell->ccodep == 0) ) \ + if(GetTypeNumber(defcell->defpointer)==TYPE_COMPILED_CLOSURE) \ + { /* setup closure */ \ + closure=(CClosure *)Addr68k_from_LADDR(defcell->defpointer);\ + defcell=(DefCell *)closure; \ + /* not a closure if closure's env is NIL */ \ + if(closure->env_ptr ) \ + {closure_env = (LispPTR) (closure->env_ptr); \ + } \ + } /* if end */ \ + else { \ + /* NOT compiled object . We must use Interpreter*/ \ + defcell = (DefCell *)GetDEFCELL68k(ATOM_INTERPRETER); \ + needpush = 1; \ + } /*else end */ \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(defcell->defpointer); \ + BCE_CURRENTFX->pc = ((UNSIGNED)PCMAC \ + - (UNSIGNED)FuncObj) + fn_opcode_size; \ + FNTPRINT(("Saving PC = 0%o (0x%x).\n", \ + BCE_CURRENTFX->pc, PCMAC+fn_opcode_size)); \ + FN_CALL_NATIVE_CHECK2(LOCFNCELL, -fn_num_args, N_APPLY_POP_PUSH_TEST) \ + FN_STACK_CHECK; \ + APPLY_POP_PUSH_TEST; \ + {register UNSIGNED newivar; \ + newivar = (UNSIGNED)(IVARL = (DLword *) (CSTKPTR+(1-fn_num_args-needpush))); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + HARD_PUSH(TOPOFSTACK); /* save TOS */ \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = fn_num_args - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + } /* NEXTBLOCK BLOCK */ \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(defcell->defpointer);\ + CSTKPTRL = (LispPTR *) (((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + result = LOCFNCELL->pv; \ + HARD_PUSH(closure_env); \ + HARD_PUSH(unboundval); \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } /* result, unboundval block */ \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ + SWAPPED_FN_CHECK; /* see if callee needs swapping */ \ + CHECK_INTERRUPT; \ + nextop0; \ +} /* end OP_FN_COMMON */ + + + +/************************************************************************/ +/* */ +/* O P _ E N V C A L L */ +/* */ +/* Environment call on a code object. Takes an arg count on */ +/* the stack, along with a pointer to an environment. If non- */ +/* NIL, the environment is stuffed into the PVAR0 slot of the */ +/* frame. [This NIL check is in the UFN, and seems to be meant */ +/* to allow closures to be called without an environment, without */ +/* the compiler having to emit special code.] */ +/* */ +/************************************************************************/ + +#define OP_ENVCALL { \ + register struct fnhead *LOCFNCELL; \ + register int NEXTBLOCK; \ + register LispPTR closure_env = TOPOFSTACK; \ + register int num_args; \ + register LispPTR Fn_DefCell= GET_TOS_1; \ + LOCFNCELL = (struct fnhead *)Addr68k_from_LADDR(Fn_DefCell); \ + FNTPRINT(("ENVCall.\n")); \ + FNCHECKER(if (quick_stack_check()) printf("In ENVCALL.\n")); \ + N_GETNUMBER(GET_TOS_2, num_args, op_ufn); \ + BCE_CURRENTFX->pc = ((UNSIGNED)PCMAC - (UNSIGNED)FuncObj) + 1;\ + FN_CALL_NATIVE_CHECK2(LOCFNCELL, -num_args, N_ENVCALL_POP_TEST); \ + FN_STACK_CHECK; \ + CSTKPTRL -= 2; \ + {register UNSIGNED newivar; \ + newivar = (UNSIGNED) (IVARL = (DLword *) (CSTKPTR-num_args)); \ + BCE_CURRENTFX->nextblock = \ + NEXTBLOCK = \ + StkOffset_from_68K(newivar); \ + } \ + if( LOCFNCELL->na >= 0 ) \ + {register int RESTARGS; \ + RESTARGS = num_args - LOCFNCELL->na; \ + while(RESTARGS <0) { \ + HARD_PUSH(NIL_PTR); \ + RESTARGS++; \ + } \ + CSTKPTRL -= (RESTARGS); \ + } /* if end */ \ + /* Set up BF */ \ + HARD_PUSH(BF_MARK32 | NEXTBLOCK); \ + *((LispPTR *)CSTKPTR) = (FX_MARK << 16) | (StkOffset_from_68K(PVAR)); \ + ((struct frameex2 *)CSTKPTR)->fnheader = SWAP_FNHEAD(Fn_DefCell); \ + CSTKPTRL = (LispPTR *)(((DLword *)CSTKPTR) + FRAMESIZE); \ + PVARL = (DLword *) CSTKPTR; \ + {register int result; \ + result = LOCFNCELL->pv; \ + if (result >= 0) \ + {register LispPTR unboundval; \ + unboundval = (LispPTR) 0xffffffff; \ + if (closure_env == NIL_PTR) HARD_PUSH(unboundval); \ + else HARD_PUSH(closure_env); \ + HARD_PUSH(unboundval); \ + if (result > 0) \ + {HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + result-=1; \ + for (; --result >= 0;) { \ + HARD_PUSH(unboundval); \ + HARD_PUSH(unboundval); \ + } \ + } \ + } \ + } \ + CSTKPTRL += 1; \ + PCMACL = (ByteCode *)LOCFNCELL + LOCFNCELL->startpc + 1; \ + FuncObj = LOCFNCELL; \ + SWAPPED_FN_CHECK; \ +} /* end OP_ENVCALL */ + + + /***************************/ + /* */ + /* Check a code block to make sure, on a byte-swapped */ + /* machine, that the code stream has been put back */ + /* in "natural order" for faster fetching. */ + /* (Only in on ISC, now. */ + /********************************************************/ +#ifdef RESWAPPEDCODESTREAM +#define SWAPPED_FN_CHECK \ + if (!FuncObj->byteswapped) { byte_swap_code_block(FuncObj); FuncObj->byteswapped = 1;} +#else +#define SWAPPED_FN_CHECK +#endif /* RESWAPPEDCODESTREAM */ + + + + +/****************************************************************/ +/****** EVAL ********/ +/****************************************************************/ +#ifndef BIGATOMS +#define EVAL \ + { \ + LispPTR scratch; \ + register LispPTR work; \ + register LispPTR lookuped; /* keep looked up value */ \ + \ + switch(TOPOFSTACK & SEGMASK) \ + { \ + case S_POSITIVE: \ + case S_NEGATIVE: nextop1; \ + \ + case ATOM_OFFSET: if( (TOPOFSTACK==NIL_PTR) \ + ||(TOPOFSTACK==ATOM_T)) \ + goto Hack_Label; \ + nnewframe(CURRENTFX,&scratch, \ + TOPOFSTACK & 0xffff); \ + work = ((scratch & 0xffff0000)>> 16) | \ + ((scratch & 0x00ff) <<16); \ + lookuped = *((LispPTR *) \ + (Addr68k_from_LADDR(work))); \ + if(lookuped==NOBIND_PTR) goto op_ufn; \ + TOPOFSTACK = lookuped; \ + Hack_Label: nextop1; \ + \ + default: switch(GetTypeNumber(TOPOFSTACK)) \ + { \ + case TYPE_FIXP : \ + case TYPE_FLOATP : \ + case TYPE_STRINGP : \ + case TYPE_ONED_ARRAY : \ + case TYPE_GENERAL_ARRAY : nextop1; \ + \ + case TYPE_LISTP : \ + fn_atom_index = ATOM_EVALFORM; \ + fn_num_args = 1; \ + fn_opcode_size = 1; \ + fn_defcell = (DefCell *) \ + GetDEFCELL68k(ATOM_EVALFORM); \ + fn_apply = 0; \ + goto op_fn_common; \ + \ + default : goto op_ufn; \ + } \ + \ + } /* end switch */ \ + \ +}/* EVAL end */ + +#else + +#define EVAL \ + { \ + LispPTR scratch; \ + register LispPTR work; \ + register LispPTR lookuped; /* keep looked up value */ \ + \ + switch(TOPOFSTACK & SEGMASK) \ + { \ + case S_POSITIVE: \ + case S_NEGATIVE: nextop1; \ + \ + case ATOM_OFFSET: if( (TOPOFSTACK==NIL_PTR) \ + ||(TOPOFSTACK==ATOM_T)) \ + goto Hack_Label; \ + nnewframe(CURRENTFX,&scratch, \ + TOPOFSTACK & 0xffff); \ + work = ((scratch & 0xffff0000)>> 16) | \ + ((scratch & 0x0fff) <<16); \ + lookuped = *((LispPTR *) \ + (Addr68k_from_LADDR(work))); \ + if(lookuped==NOBIND_PTR) goto op_ufn; \ + TOPOFSTACK = lookuped; \ + Hack_Label: nextop1; \ + \ + default: switch(GetTypeNumber(TOPOFSTACK)) \ + { \ + case TYPE_FIXP : \ + case TYPE_FLOATP : \ + case TYPE_STRINGP : \ + case TYPE_ONED_ARRAY : \ + case TYPE_GENERAL_ARRAY : nextop1; \ + \ + case TYPE_LISTP : \ + fn_atom_index = ATOM_EVALFORM; \ + fn_num_args = 1; \ + fn_opcode_size = 1; \ + fn_defcell = (DefCell *) \ + GetDEFCELL68k(ATOM_EVALFORM); \ + fn_apply = 0; \ + goto op_fn_common; \ + \ + case TYPE_NEWATOM: \ + nnewframe(CURRENTFX, &scratch, TOPOFSTACK); \ + work = POINTERMASK & SWAP_WORDS(scratch); \ + lookuped = *((LispPTR *) \ + (Addr68k_from_LADDR(work))); \ + if(lookuped==NOBIND_PTR) goto op_ufn; \ + TOPOFSTACK = lookuped; \ + nextop1; \ + default : goto op_ufn; \ + } \ + \ + } /* end switch */ \ + \ +}/* EVAL end */ +#endif /* BIGATOMS */ + diff --git a/inc/tosret.h b/inc/tosret.h new file mode 100755 index 0000000..ff43df0 --- /dev/null +++ b/inc/tosret.h @@ -0,0 +1,93 @@ +/* $Id: tosret.h,v 1.2 1999/01/03 02:06:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1998 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* */ +/* t o s r e t m a c r o . h */ +/* */ +/* Implements RETURN for the inner evaluation loop. There are */ +/* two versions--one for when hand optimization has been done, */ +/* and one for the naive case. To use the hand-optimization */ +/* version, you'll need to define an inline function or macro */ +/* called opreturn(). It must fall thru if alink is odd, but */ +/* must handle all other cases. You can rely on check_interrupt */ +/* being a defined label. */ +/* */ +/************************************************************************/ + +#ifdef NATIVETRAN +#define RETD6 SaveD6 = 0x100 +#define RET_CHECK_NATIVE(x) if(x ->native) { RET_TO_NATIVE; } +#else +#define RETD6 +#define RET_CHECK_NATIVE(x) +#endif + + +#if ((defined(ISC) || defined(SUN3_OS3_OR_OS4_IL)) && !(defined(NOASMFNCALL)) ) + +/* JDS 22 May 96 CSTKPTR >- Irq... was just >, but got overflows with last + frame right against endofstack, causing 0-long free blocks, inf loops... */ +#define OPRETURN \ +{ opreturn(); \ + EXT; if(slowreturn()) goto stackoverflow_help; RET; \ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,FuncObj); \ + if (((UNSIGNED)(CSTKPTR) >= Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + { RETD6; goto check_interrupt; } \ + Irq_Stk_End = (UNSIGNED) EndSTKP; \ + RET_CHECK_NATIVE(BCE_CURRENTFX); \ + } + +#else + +#define OPRETURN { \ + register struct frameex2 *returnFX ; \ + register int alink; \ + FNCHECKER(struct frameex2 *old_bce_fx = (struct frameex2 *) BCE_CURRENTFX); \ + alink = ((struct frameex2 *) BCE_CURRENTFX)->alink; \ + FNTPRINT(("RETURN = 0x%x, ", TOPOFSTACK)); \ + FNTRACER(prindatum(TOPOFSTACK); printf("\n"); fflush(stdout);) \ + if (alink & 1) { EXT; if(slowreturn()) goto stackoverflow_help; RET; \ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,FuncObj); \ + if (((UNSIGNED)(CSTKPTR) >= Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + { RETD6; goto check_interrupt; } \ + Irq_Stk_End = (UNSIGNED) EndSTKP; \ + RET_CHECK_NATIVE(BCE_CURRENTFX); \ + goto retxit; \ + }; \ + CSTKPTRL = (LispPTR *) IVAR; \ + returnFX = (struct frameex2 *) \ + ((DLword *) \ + (PVARL = (DLword *) Addr68k_from_StkOffset(alink)) \ + - FRAMESIZE); \ + IVARL = (DLword *) \ + Addr68k_from_StkOffset(GETWORD((DLword *)returnFX -1)); \ + /* Get PC from Retunee's pc slot in FX */ \ + PCMACL = returnFX->pc + (ByteCode *) \ + (FuncObj = (struct fnhead *) \ + Addr68k_from_LADDR(SWAP_FNHEAD(returnFX->fnheader) & POINTERMASK)) + 1;\ + Irq_Stk_Check = STK_END_COMPUTE(EndSTKP,FuncObj); \ + FNCHECKER(if (quick_stack_check()) printf("In RETURN.\n")); \ + if (((UNSIGNED)(CSTKPTR) >= Irq_Stk_Check) || (Irq_Stk_End <= 0)) \ + { RETD6; goto check_interrupt; } \ + Irq_Stk_End = (UNSIGNED) EndSTKP; \ + RET_CHECK_NATIVE(returnFX); \ +retxit: {} \ +} /* OPRETURN end */ + +#endif diff --git a/inc/tty.h b/inc/tty.h new file mode 100755 index 0000000..7d854c2 --- /dev/null +++ b/inc/tty.h @@ -0,0 +1,81 @@ +/* $Id: tty.h,v 1.2 1999/01/03 02:06:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include +#include +#include +#include "lispemul.h" +#include "adr68k.h" + +#include "lispmap.h" + +/* + TTY Command +*/ + +#define TTY_GET_STATUS 33280>>8 +#define TTY_ON 33536>>8 +#define TTY_OFF 33792>>8 +#define TTY_BREAK_ON 34304>>8 +#define TTY_BREAK_OFF 34560>>8 +#define PUT_CHAR 128 +#define ABORT_PUT 133 +#define SET_PARAM 129 +#define SET_DSR 33025 +#define SET_CTS 33026 +#define SET_CHAR_LENGTH 33028 +#define SET_PARITY 33032 +#define SET_STOP_BITS 33040 +#define SET_BAUD_RATE 33056 +#define SET_ALL_PARAMETERS 33087 + +typedef struct { + unsigned command : 8; + unsigned outdata : 8; +} DLTTY_OUT_COMMAND; + +typedef struct { + unsigned on_off : 4; + unsigned line_speed : 4; + unsigned stop_bits : 2; + unsigned parity : 2; + unsigned char_length : 2; + unsigned clear_to_send : 1; + unsigned data_set_ready : 1; + DLword notify_mask; +} DLTTY_OUT_CSB; + +typedef struct { + unsigned state : 1; + unsigned nil1 : 7; + unsigned success : 1; + unsigned break_detected : 1; + unsigned framing_error : 1; + unsigned data_lost : 1; + unsigned parity_error : 1; + unsigned nil2 : 2; + unsigned not_ready : 1; + char in_data; + unsigned data_terminal_ready : 1; + unsigned nil3 : 4; + unsigned request_to_send : 1; + unsigned rx_ready : 1; + unsigned tx_ready : 1; +} DLTTY_IN_CSB; + + +extern DLword *Lisp_world; + diff --git a/inc/version.h b/inc/version.h new file mode 100755 index 0000000..2905050 --- /dev/null +++ b/inc/version.h @@ -0,0 +1,473 @@ +/* $Id: version.h,v 1.5 2001/12/26 22:17:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* V E R S I O N . H */ +/* */ +/* Version control: Set the two values that keep sysouts and emul- */ +/* ators in sync: The LVERSION and MINBVERSION fields in the IFPAGE */ +/* */ +/* MINBVERSION is the current emulator version, incremented with each */ +/* modification. This must be >= a sysout's ifpage.minbversion. */ +/* */ +/* LVERSION is the minimum lisp version that will run with this emu- */ +/* lator. This must be <= a sysouts's ifpage.lversion. */ +/* */ +/* The loadup process sets both of these values in the sysout. */ +/* */ +/* */ +/* */ +/* C O N F I G U R A T I O N / O P T I O N C O N T R O L */ +/* */ +/* Given a release specification, set flags for the features */ +/* that release has. This lets us set one flag in the make- */ +/* file, rather than remembering all the options that must change. */ +/* */ +/* -DRELEASE=115 Medley 1.15, small atoms */ +/* -DRELEASE=200 Medley 2.0 as released */ +/* -DRELEASE=201 Medley with DOS & European kbd support */ +/* -DRELEASE=210 Medley with big VM */ +/* -DRELEASE=300 Medley bigvm as released. */ +/* -DRELEASE=350 Medley with 256MB vm. */ +/* -DRELEASE=351 Medley with 256MB vm and cursor fix */ +/* */ +/* */ +/************************************************************************/ + + + /* The current values */ + +#define LVERSION 21000 +#define MINBVERSION 21001 + + + /* But remember old values, if we can figure them out from ifdef's */ + +#if (RELEASE == 115) + +#undef LVERSION +#undef MINBVERSION +#define LVERSION 15000 +#define MINBVERSION 15000 +#undef BIGATOMS +#define NOEUROKBD +#define NOFORN +#define NOVERSION + +#elif (RELEASE == 200) + + /* Medley 2.0 as released */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 20000 +#define MINBVERSION 20000 + +#define BIGATOMS +#define NOEUROKBD +#define NOVERSION + +#elif (RELEASE == 201 ) + + + /* Medley 2.0 with EUROKBD modification */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 20100 +#define MINBVERSION 20100 + +#define BIGATOMS +#undef NOEUROKBD +#define NOVERSION + +#elif (RELEASE == 210) + + /* Medley 2.1, big-vm Medley while in beta-test */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 21000 +#define MINBVERSION 21000 + +#define BIGATOMS +#define BIGVM 1 +#define NEWCDRCODING + + +# elif (RELEASE == 300 ) + + /* Medley 301, big-vm Medley in release?? */ +#undef LVERSION +#undef MINBVERSION +#define LVERSION 30000 +#define MINBVERSION 30000 + +#define BIGATOMS +#define BIGVM +#define NEWCDRCODING + + +#elif (RELEASE == 350) + + /* Medley 3.5, 256Mb version */ + +#undef LVERSION +#undef MINBVERSION +#define LVERSION 35000 +#define MINBVERSION 35000 + +#define BIGATOMS +#define BIGVM +#define BIGBIGVM +#define NEWCDRCODING + + +#elif (RELEASE == 351) + + /* Medley 3.5, 256Mb version, X cursor hotspot fix 1/00 */ + +#undef LVERSION +#undef MINBVERSION +#define LVERSION 35010 +#define MINBVERSION 35010 + +#define BIGATOMS +#define BIGVM +#define BIGBIGVM +#define NEWCDRCODING +#define NEWXCURSOR + + +#else +error Must specify RELEASE to build Medley. +#endif + + + + /****************************************************************/ + /* */ + /* Architecture-specific flags: Set flags */ + /* based on thing we know about the architecture */ + /* or idiosyncracies of the machine we're compiling for. */ + /* */ + /* Defaults: Unaligned fetches OK UNALIGNED_FETCH_OK */ + /* type char is signed SIGNED_CHARS */ + /* fp values used with */ + /* FPTEST can be in regs. REGISTER */ + /* CC supports "void" VOID */ + /* Use asm inline arith USE_INLINE_ARITH */ + /* pointer-wide unsigned UNSIGNED */ + /* pointer-wide int INT */ + /* */ + /* */ + /* */ + /****************************************************************/ + + + + +#ifdef NOASM +#undef SUN3_OS3_IL +#undef SUN3_OS4_IL +#undef SUN4_OS4_IL +#undef OPDISP +#undef NATIVETRAN +#undef UNSAFE +#undef PROFILE +#define NOASMFNCALL 1 +#endif + +#ifdef SUN3_OS3_IL +#define SUN3_OS3_OR_OS4_IL 1 +#define USE_INLINE_ARITH 1 +#endif + +#ifdef SUN3_OS4_IL +#define SUN3_OS3_OR_OS4_IL 1 +#define USE_INLINE_ARITH 1 +#endif + + + + + + /* Set up defaults */ +#define UNALIGNED_FETCH_OK +#define REGISTER register +#define HAS_GETHOSTID +#undef USE_UTIME +#define UNSIGNED unsigned long +#define INT long +#define VOID void + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef sun +typedef char s_char; +#endif /* sun */ + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef sparc + /* SPARCs and MIPSs can't do unaligned word-loads */ +#undef UNALIGNED_FETCH_OK +#endif /* SPARC */ + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef DEC3100 +#undef UNALIGNED_FETCH_OK +#ifdef OSF1 +typedef signed char s_char; +#undef UNSIGNED +#undef INT +#define UNSIGNED unsigned long long +#define INT long long +#undef REGISTER +#define REGISTER +#endif /* OSF1 */ +#endif /* DEC3100 */ + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef AIXPS2 +typedef signed char s_char; +#define GCC386 +#endif + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef HPUX +typedef char s_char; +typedef unsigned short u_short; +typedef unsigned long u_long; +#define O_NDELAY FNDELAY +#define valloc malloc +#undef UNALIGNED_FETCH_OK +#undef HAS_GETHOSTID +#define seteuid(x) setresuid(-1, (x), -1) +#define getwd(x) getcwd((x), MAXPATHLEN) +#define getrusage(x, y) +#define getpagesize() 4096 +#define USE_UTIME +#endif + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef RS6000 +typedef signed char s_char; +#endif /* RS6000 */ + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef RISCOS +typedef signed char s_char; +#undef UNALIGNED_FETCH_OK +#define USE_UTIME +#define LOCK_X_UPDATES 1 +#endif + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef ISC +typedef signed char s_char; +#undef UNALIGNED_FETCH_OK +#define MAXPATHLEN MAXNAMLEN +#define EWOULDBLOCK EAGAIN +#define getwd(x) getcwd((x), MAXPATHLEN) + /* we compile on a 386 with GCC, so can use optimizations. */ +#define GCC386 +#define RESWAPPEDCODESTREAM +#undef HAS_GETHOSTID +#define LOCK_X_UPDATES 1 +#endif /* ISC */ + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef INDIGO +typedef signed char s_char; +#undef UNALIGNED_FETCH_OK +#undef REGISTER +#define REGISTER +#endif /* INDIGO */ + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef APOLLO +typedef signed char s_char; +#endif /* APOLLO */ + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef OS5 + /* Solaris, sort of SYSV-ish */ +#undef HAS_GETHOSTID +#define SYSVONLY 1 +#define SYSVSIGNALS 1 +#define index strchr +#define rindex strrchr +#define bzero(b,n) memset(b,0,n) +#define bcmp(a,b,n) memcmp(a,b,n) +#define bcopy(a,b,n) memcpy(b,a,n) +#define L_SET SEEK_SET +#define NOFORN +#define LOCK_X_UPDATES 1 +#endif /* OS5 */ + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef LINUX + /* LINUX, the free POSIX-compliant Unix */ +#define SYSVONLY 1 +#define NOETHER 1 +#define XWINDOWS 1 +/* JDS trial 12/22/01 #define USETIMEFN 1 */ + +#undef REGISTER +#define REGISTER + +typedef signed char s_char; + +#undef UNALIGNED_FETCH_OK + +/* #define sigvec sigaction */ +/* #define sigmask __sigmask */ +/* #define sv_handler sa_handler */ +/* #define sv_mask sa_mask */ +/* #define sv_flags sa_flags */ + +#define MAXNAMLEN NAME_MAX + +#endif /* LINUX */ + + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef I386 +#define USE_INLINE_AIRTH 1 +#endif /* I386 */ + + + + + /********************************************************/ + /* */ + /********************************************************/ +#ifdef DOS +typedef unsigned char u_char; +typedef unsigned long u_int; +typedef signed char s_char; +typedef unsigned short u_short; + /* DOS doesn't have the BSD bzero &c functions */ +#define bzero(place,len) memset(place, 0, len) +#undef UNALIGNED_FETCH_OK +#undef HAS_GETHOSTID +#undef REGISTER +#define REGISTER +#define SYSVONLY 1 +#define SYSVSIGNALS 1 +#define NOETHER 1 +#define getwd(x) getcwd((x), MAXPATHLEN) +#define USHORT unsigned +#else +#define USHORT unsigned short +#endif /* DOS */ + + + + /********************************************************/ + /* */ + /********************************************************/ + + +#ifdef OS4 +#define __inline__ +#endif + + + + /****************************************************************/ + /* End of architecture-specific flag settings */ + /* --Start of system-specific flags (e.g. SYSVONLY)-- */ + /* */ + /****************************************************************/ + +#ifdef SYSVONLY +#if defined INDIGO +#elif OS5 +#elif defined(LINUX) +#else +#define seteuid(x) setresuid(-1, (x), -1) +#endif /* INDIGO does have seteuid */ +#define getwd(x) getcwd((x), MAXPATHLEN) +#define getrusage(x, y) +#define getpagesize() 4096 +#ifdef LINUX +#undef getrusage +#undef getpagesize +#undef getwd +#endif /* LINUX */ +#endif /* SYSVONLY */ + + + /****************************************************************/ + /* End of architecture-specific flag settings */ + /****************************************************************/ + diff --git a/inc/vmemsave.h b/inc/vmemsave.h new file mode 100755 index 0000000..a0187ff --- /dev/null +++ b/inc/vmemsave.h @@ -0,0 +1,27 @@ +/* $Id: vmemsave.h,v 1.2 1999/01/03 02:06:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/* + File Name : vmemsave.h + DEfinition for vmemsave +*/ + +#define FP_IFPAGE 512 /* IFPAGE address in sysoutfile by Byte */ +#define DOMINOPAGES 301 /* skip dominopages in fptovp */ +#define SKIPPAGES 301 /* save first filepage */ +#define SKIP_DOMINOPAGES 153600 /* Byte size in sysoutfile for dominocode */ +#define SAVE_IFPAGE 223 /* Virtual address for IFPAGES's buffer page. This value is \EMUSWAPBUFFERS in lisp. */ diff --git a/inc/xbitmaps.h b/inc/xbitmaps.h new file mode 100755 index 0000000..f617a50 --- /dev/null +++ b/inc/xbitmaps.h @@ -0,0 +1,405 @@ +/* $Id: xbitmaps.h,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + + + + +typedef struct { + short cubitsprepixel; /* bits per pixel in the cursor, mostly 1 */ + char *cuimage; /* the image bitmap */ + char *cumask; /* the mask bitmap */ + short cuhotspotx; /* hot-spot X coordinate */ + short cuhotspoty; /* hot-spot Y coordinate */ + short cudata; /* ?? */ +} LISP_CURSOR; + +char defaultcursor_bitmap[]= + { + 0x80, 0, 0xc0, 0, 0xe0, 0, 0xf0, 0 + , 0xf8, 0, 0xfc, 0, 0xfe, 0, 0xf0, 0 + , 0xd8, 0, 0x98, 0, 0x0c, 0, 0x0c, 0 + , 0x06, 0, 0x06, 0, 0x03, 0, 0x03, 0 + }; + +LISP_CURSOR default_cursor = + { + 1 + , defaultcursor_bitmap + , defaultcursor_bitmap + , 0 + , 15 + , 0 + }; + + +char waitcursor_bitmap[]= + { + 0xFF, 0xFE, 0xC0, 0x06, 0x60, 0x1C, 0x3D, 0x78 + , 0x1F, 0xF0, 0x0F, 0xE0, 0x06, 0xC0, 0x03, 0x80 + , 0x02, 0x80, 0x03, 0xC0, 0x0D, 0x60, 0x19, 0x30 + , 0x37, 0xD8, 0x67, 0xEC, 0xFF, 0xFE, 0xFF, 0xFE + }; + +LISP_CURSOR wait_cursor = + { + 1 + , waitcursor_bitmap + , waitcursor_bitmap + , 7 + , 8 + , 0 + }; + +char horizscrollcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x08, 0x20 + , 0x18, 0x30 + , 0x38, 0x38 + , 0x78, 0x3C + , 0xFF, 0xFE + , 0xFF, 0xFE + , 0x78, 0x3C + , 0x38, 0x38 + , 0x18, 0x30 + , 0x08, 0x20 +}; + +LISP_CURSOR horizscroll_cursor = { + 1 + , horizscrollcursor_bitmap + , horizscrollcursor_bitmap + , 7 + , 5 + , 0 +}; + + + +char horizthumbcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x02, 0x00 + , 0x02, 0x00 + , 0x0A, 0x80 + , 0x0A, 0x80 + , 0x0A, 0x80 + , 0x2A, 0xA0 + , 0x2A, 0xA0 + , 0x2A, 0xA0 + , 0xAA, 0xA8 + , 0xAA, 0xA8 + , 0xAA, 0xA8 + , 0xAA, 0xA8 + , 0xAA, 0xA8 +}; + +LISP_CURSOR horizthumb_cursor = { + 1 + , horizthumbcursor_bitmap + , horizthumbcursor_bitmap + , 6 + , 8 + , 0 +}; + + + +char scrolldowncursor_bitmap[]={ + 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x1F, 0xF0 + , 0x1F, 0xF0 + , 0x0F, 0xE0 + , 0x0F, 0xE0 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x01, 0x00 +}; + +LISP_CURSOR scrolldown_cursor = { + 1 + , scrolldowncursor_bitmap + , scrolldowncursor_bitmap + , 7 + , 15 + , 0 +}; + + + +char scrollleftcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x80 + , 0x03, 0x80 + , 0x0F, 0x80 + , 0x3F, 0x80 + , 0xFF, 0xFF + , 0xFF, 0xFF + , 0x3F, 0x80 + , 0x0F, 0x80 + , 0x03, 0x80 + , 0x00, 0x80 +}; + +LISP_CURSOR scrollleft_cursor = { + 1 + , scrollleftcursor_bitmap + , scrollleftcursor_bitmap + , 8 + , 5 + , 0 +}; + + + +char scrollrightcursor_bitmap[]={ + 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x00, 0x00 + , 0x01, 0x00 + , 0x01, 0xC0 + , 0x01, 0xF0 + , 0x01, 0xFC + , 0xFF, 0xFF + , 0xFF, 0xFF + , 0x01, 0xFC + , 0x01, 0xF0 + , 0x01, 0xC0 + , 0x01, 0x00 +}; + +LISP_CURSOR scrollright_cursor = { + 1 + , scrollrightcursor_bitmap + , scrollrightcursor_bitmap + , 7 + , 5 + , 0 +}; + + + +char scrollupcursor_bitmap[]={ + 0x01, 0x00 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x0F, 0xE0 + , 0x0F, 0xE0 + , 0x1F, 0xF0 + , 0x1F, 0xF0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 +}; + +LISP_CURSOR scrollup_cursor = { + 1 + , scrollupcursor_bitmap + , scrollupcursor_bitmap + , 7 + , 15 + , 0 +}; + + + +char vertscrollcursor_bitmap[]={ + 0x01, 0x00 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x0F, 0xE0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x0F, 0xE0 + , 0x07, 0xC0 + , 0x07, 0xC0 + , 0x03, 0x80 + , 0x03, 0x80 + , 0x01, 0x00 +}; + +LISP_CURSOR vertscroll_cursor = { + 1 + , vertscrollcursor_bitmap + , vertscrollcursor_bitmap + , 7 + , 15 + , 0 +}; + + + +char vertthumbcursor_bitmap[]={ + 0x00,0x00 + ,0x00,0x1f + ,0x00,0x00 + ,0x00,0xff + ,0x00,0x00 + ,0x07,0xff + ,0x00,0x00 + ,0x1f,0xff + ,0x00,0x00 + ,0x07,0xff + ,0x00,0x00 + ,0x00,0xff + ,0x00,0x00 + ,0x00,0x1f + ,0x00,0x00 + ,0x00,0x00 +}; + +LISP_CURSOR vertthumb_cursor = { + 1 + , vertthumbcursor_bitmap + , vertthumbcursor_bitmap + , 8 + , 8 + , 0 +}; + +int check_width = 16; +int check_height = 16; + +static char check_bits[] = { 0x88, 0x88, + 0x00, 0x00, + 0x22, 0x22, + 0x00, 0x00, + 0x88, 0x88, + 0x00, 0x00, + 0x22, 0x22, + 0x00, 0x00, + 0x88, 0x88, + 0x00, 0x00, + 0x22, 0x22, + 0x00, 0x00, + 0x88, 0x88, + 0x00, 0x00, + 0x22, 0x22, + 0x00, 0x00 }; +static char plain_bits[] = { 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00 }; + +int Lisp_icon_width = 88; +int Lisp_icon_height = 58; + +char Lisp_icon[] = + { + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, + 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x3f, 0xe2, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x20, + 0xbf, 0xff, 0xff, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x97, 0xa8, + 0x3f, 0xff, 0xff, 0xa0, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x22, + 0x20, 0x00, 0x00, 0x88, 0x20, 0x82, 0x08, 0x20, 0x83, 0xf0, 0x20, + 0xa0, 0x00, 0x00, 0x82, 0x08, 0x20, 0x82, 0x08, 0x21, 0x10, 0x28, + 0x24, 0x01, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0x1f, 0xe2, + 0x29, 0xb2, 0x00, 0x88, 0x24, 0x00, 0x00, 0x60, 0x83, 0x04, 0x20, + 0xa9, 0xb2, 0x50, 0x82, 0x0c, 0x00, 0x00, 0x48, 0x21, 0x06, 0x08, + 0x29, 0xb2, 0x00, 0xa0, 0x87, 0xff, 0xff, 0xc2, 0x09, 0xfc, 0x82, + 0x24, 0x01, 0x00, 0xbf, 0xff, 0xff, 0xff, 0xe0, 0x82, 0x08, 0x20, + 0xa0, 0x00, 0x00, 0xbf, 0xff, 0xe0, 0x08, 0x48, 0x21, 0xfe, 0x08, + 0x20, 0x01, 0x20, 0xe0, 0x00, 0x20, 0x0f, 0x42, 0x0a, 0x02, 0x82, + 0x20, 0x00, 0x90, 0xe0, 0x00, 0x3f, 0xf8, 0x60, 0x83, 0xfe, 0x20, + 0xa5, 0x48, 0x90, 0xbf, 0xff, 0xff, 0xff, 0x48, 0x20, 0x82, 0x08, + 0x20, 0x00, 0x90, 0xbf, 0xff, 0xe0, 0x08, 0x42, 0x08, 0x20, 0x82, + 0x20, 0x01, 0x20, 0xa0, 0x00, 0x35, 0x4f, 0x7f, 0xff, 0xff, 0xe0, + 0xa0, 0x00, 0x00, 0xaa, 0xa0, 0x20, 0x08, 0x5f, 0xff, 0xff, 0xe8, + 0x20, 0x00, 0x00, 0xa0, 0x00, 0x35, 0x4f, 0x50, 0x00, 0x00, 0x22, + 0x3f, 0xff, 0xff, 0xab, 0x56, 0x20, 0x08, 0x70, 0x07, 0xc0, 0x20, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x0f, 0xd0, 0x0c, 0x47, 0xa8, + 0x22, 0x00, 0x00, 0x2d, 0x5a, 0xa0, 0x08, 0x90, 0x0f, 0xcc, 0xa2, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x34, 0x08, 0x30, 0x10, 0x17, 0xa0, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x20, 0x0a, 0x10, 0x17, 0xd0, 0x28, + 0x22, 0x00, 0x00, 0x20, 0x00, 0x35, 0x08, 0x90, 0x2c, 0x67, 0xa2, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x30, 0x37, 0xdc, 0xa0, + 0x82, 0x00, 0x00, 0x20, 0x00, 0x35, 0x4a, 0x17, 0xe0, 0x07, 0xa8, + 0x22, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x94, 0x57, 0xc0, 0x22, + 0x0a, 0x00, 0x00, 0x20, 0x00, 0x20, 0x08, 0x37, 0xec, 0x40, 0x20, + 0x83, 0xff, 0xff, 0xe0, 0x00, 0x20, 0x0a, 0x10, 0x27, 0xc0, 0x28, + 0x20, 0x82, 0x08, 0x20, 0x00, 0x20, 0x08, 0x90, 0x10, 0x00, 0x22, + 0x08, 0x20, 0x82, 0x20, 0x00, 0x3f, 0xf8, 0x30, 0x1f, 0xc0, 0x20, + 0x82, 0x08, 0x20, 0xa0, 0x00, 0x20, 0x82, 0x10, 0x0c, 0x40, 0x28, + 0x20, 0x82, 0x08, 0x3f, 0xff, 0xe8, 0x20, 0x90, 0x07, 0xc0, 0x22, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x30, 0x00, 0x00, 0x20, + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x10, 0x00, 0x00, 0x28, + 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x9f, 0xff, 0xff, 0xe2, + 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, + 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x20, 0x82, 0x08, 0x20, 0x82, + 0x42, 0x13, 0x18, 0xc7, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x99, 0x34, 0xa5, 0x24, 0x29, 0x26, 0x38, 0xc5, 0x04, 0x00, 0x00, + 0xa1, 0x14, 0x99, 0x27, 0x35, 0x29, 0x40, 0x26, 0x9c, 0x00, 0x00, + 0xa1, 0x13, 0xa4, 0xe4, 0x25, 0x29, 0x30, 0xe4, 0xa4, 0x00, 0x00, + 0xa1, 0x10, 0xa4, 0x24, 0x24, 0xc9, 0x09, 0x24, 0xa4, 0x00, 0x00, + 0x5a, 0x13, 0x18, 0xc7, 0xa4, 0xc6, 0x70, 0xd4, 0x9c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xc0, 0x50, 0x84, 0x00, 0x00, 0x01, 0xc0, 0x02, 0x10, 0x20, + 0x02, 0x12, 0x00, 0x48, 0xcb, 0x32, 0x22, 0x0c, 0x02, 0x38, 0x20, + 0x03, 0x92, 0x50, 0x31, 0x2c, 0x49, 0x42, 0x12, 0x02, 0x10, 0xe0, + 0x02, 0x12, 0x50, 0x31, 0xe8, 0x48, 0x82, 0x12, 0x02, 0x11, 0x20, + 0x02, 0x16, 0x50, 0x49, 0x08, 0x49, 0x42, 0x12, 0x02, 0x15, 0x20, + 0x02, 0x0a, 0x50, 0x84, 0xc8, 0x32, 0x21, 0xcc, 0x93, 0xc8, 0xe0, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; diff --git a/inc/xdefs.h b/inc/xdefs.h new file mode 100755 index 0000000..3b6e85d --- /dev/null +++ b/inc/xdefs.h @@ -0,0 +1,89 @@ +/* $Id: xdefs.h,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-2001 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#define DEF_WIN_X 20 +#define DEF_WIN_Y 20 +#define DEF_WIN_WIDTH 565 +#define DEF_WIN_HEIGHT 430 +#define WIN_MIN_WIDTH 150 +#define WIN_MIN_HEIGHT 100 +#define DEF_BDRWIDE 2 +#define SCROLL_WIDTH 18 +#define WINDOW_NAME "Medley (C) Copyright 1980-2001 Venue" +#define ICON_NAME "Medley" + + +#define WIN_MAX_WIDTH 2048 +#define WIN_MAX_HEIGHT 2048 +#define SCROLL_PITCH 30 + + +#ifndef __LDEXDEF__ + +#define __LDEXDEF__ 1 +#include +#ifdef LOCK_X_UPDATES +#define XLOCK { XLocked++; /* printf("L"); fflush(stdout);*/} +#define XUNLOCK \ + { XLocked--;/* printf("U"); fflush(stdout);*/ \ + if (XNeedSignal) \ + { \ + XNeedSignal = 0; \ + kill(getpid(), SIGPOLL); \ + }; \ + } +#else +#define XLOCK +#define XUNLOCK +#endif /* LOCK_X_UPDATES */ + +extern int XLocked; +extern int XNeedSignal; +/* this is !0 if we're locked; it should be 0 or larger always */ +#endif + +#ifdef XWINDOW +#ifdef XV11R4 +#undef XV11R1 +#undef XV11R2 +#undef XV11R3 +#endif /* XV11R4 */ + +#ifdef XV11R3 +#undef XV11R1 +#undef XV11R2 +#undef XV11R4 +#endif /* XV11R3 */ + +#ifdef XV11R2 +#undef XV11R1 +#undef XV11R3 +#undef XV11R4 +#endif /* XV11R2 */ + +#ifdef XV11R1 +#undef XV11R2 +#undef XV11R3 +#undef XV11R4 +#endif /* XV11R1 */ + +#if ( !(defined( XV11R1 )) \ + && !(defined( XV11R2 )) \ + && !(defined( XV11R3 )) \ + && !(defined( XV11R4 )) ) +#define XV11R4 /* newest version */ +#endif +#endif /* XWINDOW */ diff --git a/include/README b/include/README new file mode 100644 index 0000000..a05b667 --- /dev/null +++ b/include/README @@ -0,0 +1,7 @@ +This directory contains header files that are generated by the build +process itself. E.g., if DLD creates include files for outside use, +they'd go here. + +This directory is not CVS controlled, apart from this file. + +21 April 2000 diff --git a/include/ansidecl.h b/include/ansidecl.h new file mode 100644 index 0000000..3c0dcb3 --- /dev/null +++ b/include/ansidecl.h @@ -0,0 +1,141 @@ +/* ANSI and traditional C compatability macros + Copyright 1991, 1992 Free Software Foundation, Inc. + This file is part of the GNU C Library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macro ANSI C definition Traditional C definition + ----- ---- - ---------- ----------- - ---------- + PTR `void *' `char *' + LONG_DOUBLE `long double' `double' + VOLATILE `volatile' `' + SIGNED `signed' `' + PTRCONST `void *const' `char *' + ANSI_PROTOTYPES 1 not defined + + CONST is also defined, but is obsolete. Just use const. + + DEFUN (name, arglist, args) + + Defines function NAME. + + ARGLIST lists the arguments, separated by commas and enclosed in + parentheses. ARGLIST becomes the argument list in traditional C. + + ARGS list the arguments with their types. It becomes a prototype in + ANSI C, and the type declarations in traditional C. Arguments should + be separated with `AND'. For functions with a variable number of + arguments, the last thing listed should be `DOTS'. + + DEFUN_VOID (name) + + Defines a function NAME, which takes no arguments. + + obsolete -- EXFUN (name, (prototype)) -- obsolete. + + Replaced by PARAMS. Do not use; will disappear someday soon. + Was used in external function declarations. + In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in + parentheses). In traditional C it is `NAME()'. + For a function that takes no arguments, PROTOTYPE should be `(void)'. + + PARAMS ((args)) + + We could use the EXFUN macro to handle prototype declarations, but + the name is misleading and the result is ugly. So we just define a + simple macro to handle the parameter lists, as in: + + static int foo PARAMS ((int, char)); + + This produces: `static int foo();' or `static int foo (int, char);' + + EXFUN would have done it like this: + + static int EXFUN (foo, (int, char)); + + but the function is not external...and it's hard to visually parse + the function name out of the mess. EXFUN should be considered + obsolete; new code should be written to use PARAMS. + + For example: + extern int printf PARAMS ((CONST char *format DOTS)); + int DEFUN(fprintf, (stream, format), + FILE *stream AND CONST char *format DOTS) { ... } + void DEFUN_VOID(abort) { ... } +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) +/* All known AIX compilers implement these things (but don't always + define __STDC__). The RISC/OS MIPS compiler defines these things + in SVR4 mode, but does not define __STDC__. */ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#define AND , +#define NOARGS void +#define CONST const +#define VOLATILE volatile +#define SIGNED signed +#define DOTS , ... + +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(void) + +#define PROTO(type, name, arglist) type name arglist +#define PARAMS(paramlist) paramlist +#define ANSI_PROTOTYPES 1 + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#define CONST +#ifndef const /* some systems define it in header files for non-ansi mode */ +#define const +#endif +#define VOLATILE +#define SIGNED +#define DOTS + +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() +#define PROTO(type, name, arglist) type name () +#define PARAMS(paramlist) () + +#endif /* ANSI C. */ + +#endif /* ansidecl.h */ diff --git a/include/dld.h b/include/dld.h new file mode 100644 index 0000000..236c01b --- /dev/null +++ b/include/dld.h @@ -0,0 +1,157 @@ +/* dld.h -- dynamic link editor library interface header. + Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1990 by W. Wilson Ho. + This file is part of the GNU Dld Library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by W. Wilson Ho */ + +#include + +/* Error codes */ + +#define DLD_ENOFILE 1 /* Cannot open file. */ +#define DLD_EBADMAGIC 2 /* Bad magic number. */ +#define DLD_EBADHEADER 3 /* Failure reading header. */ +#define DLD_ENOTEXT 4 /* Premature end of file in text section. */ +#define DLD_ENOSYMBOLS 5 /* Premature EOF in symbol section. */ +#define DLD_ENOSTRINGS 6 /* Bad string table. */ +#define DLD_ENOTXTRELOC 7 /* Premature EOF in text relocation. */ +#define DLD_ENODATA 8 /* Premature EOF in data section. */ +#define DLD_ENODATRELOC 9 /* Premature EOF in data relocation. */ +#define DLD_EMULTDEFS 10 /* A symbol was multiply defined. */ +#define DLD_EBADLIBRARY 11 /* Malformed library archive. */ +#define DLD_EBADCOMMON 12 /* Common block not supported. */ +#define DLD_EBADOBJECT 13 /* Malformed input file + (not relocatable or archive). */ +#define DLD_EBADRELOC 14 /* Bad relocation info. */ +#define DLD_ENOMEMORY 15 /* Virtual memory exhausted. */ +#define DLD_EUNDEFSYM 16 /* Undefined symbol. */ + +#define DLD_ELAST 16 /* Must equal largest errno. */ + +/* Most recent error code returned by dld. */ +extern int dld_errno; + +/* The symbol name that was multiply defined. Valid only if DLD_ERRNO is + DLD_EMULTDEFS. */ +extern char *dld_errname; + +/* The number of undefined global symbols. */ +extern int dld_undefined_sym_count; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initialize the dld routines. PROGNAME is the name of the currently + running program, as given by argv[0]. If PROGNAME is not an + absolute path, then dld_init will automatically invoke + dld_find_program (PROGNAME). */ +extern int dld_init PARAMS ((CONST char *progname)); + +/* Dynamically load and link the object file named FILE into the + current process. */ +extern int dld_link PARAMS ((CONST char *file)); + +/* Return the address of the identifier named ID. This function + automatically prepends an underscore to the identifier, if C + identifiers usually use them. */ +extern PTR dld_get_symbol PARAMS ((CONST char *id)); + +/* Return the address of the identifier named ID. Use this function + to locate symbols defined by assembly routines, since it doesn't + prepend and underscore to the symbol name. */ +extern PTR dld_get_bare_symbol PARAMS ((CONST char *id)); + +/* Return the address of the function named FUNC. */ +extern PTR dld_get_func PARAMS ((CONST char *func)); + +/* Unlink the module in the current process defined by the file FILE. + If FORCE is nonzero, then the module is removed from memory even if + it is referenced by other modules. */ +extern int dld_unlink_by_file PARAMS ((CONST char *file, int force)); + +/* Unlink the module in the current process that defines the symbol + ID. If FORCE is nonzero, then the module is removed from memory + even if it is referenced by other modules. */ +extern int dld_unlink_by_symbol PARAMS ((CONST char *id, int force)); + +/* Explicitly create a reference to the symbol named ID. */ +extern int dld_create_reference PARAMS ((CONST char *id)); + +/* Explicitly define the symbol named ID, of SIZE bytes. */ +extern int dld_define_sym PARAMS ((CONST char *id, int size)); + +/* Remove the explicitly defined symbol named ID. */ +extern int dld_remove_defined_symbol PARAMS ((CONST char *id)); + +/* Return an array that lists the undefined symbols in the current + process, or NULL if there are none. The caller is responsible for + freeing this array. */ +extern char **dld_list_undefined_sym PARAMS ((NOARGS)); + +/* Return true (nonzero) if the function named FUNC may be safely + executed. */ +extern int dld_function_executable_p PARAMS ((CONST char *func)); + +/* Return the absolute name of the program named NAME. This function + searches the directories in the PATH environment variable if PROG + has no directory components. */ +extern char *dld_find_executable PARAMS ((CONST char *name)); + +/* Return the absolute name of the shared library named NAME. This + function searches: + a) in an absolute location, if NAME is an absolute path. + b) relative to the current working directory, if NAME is a relative path. + c) in the current directory + d) if all the above fail, then look for a file named "libNAME.so" + (depending on the system): + i) in the directories named in the LIBPATH array, if it is non-NULL + ii) in the directories named in the LD_LIBRARY_PATH (or equivalent) + environment variable. + + If all the above fails, then dld_find_library returns the NULL pointer. + + See the dld documentation for a description of MAJOR, DELTA, and + REVISION version numbers, or set them all to zero if the shared library + was not built by libtool. */ +extern char *dld_find_library PARAMS ((CONST char *name, CONST char **libpath, + int major, int delta, int revision)); + +/* Print MSG followed by a colon and dld_strerror (DLD_ERRNO). May be + used as a simple way to report errors. */ +extern void dld_perror PARAMS ((CONST char *MSG)); + +/* Return the string corresponding to the error code CODE. */ +extern CONST char *dld_strerror PARAMS ((int code)); + +#if 0 +/* FIXME: these functions have been removed from dld due to legal problems. */ + +/* A replacement for dld_link that invokes g++ constructors. */ +extern void dyn_load PARAMS ((CONST char *name)); + +/* A replacement for dld_unlink that invoke g++ destructors. */ +extern void dyn_unload PARAMS ((CONST char *name)); + +/* A list of libraries to be loaded by dyn_load. */ +extern char *dyn_libraries[]; +#endif + +#ifdef __cplusplus +} +#endif diff --git a/src/#ldeboot.c# b/src/#ldeboot.c# new file mode 100755 index 0000000..7f0965c --- /dev/null +++ b/src/#ldeboot.c# @@ -0,0 +1,290 @@ +/* @(#) ldeboot.c Version 1.14 (9/6/95). copyright Venue & Fuji Xerox */ +static char *id = "@(#) ldeboot.c 1.14 9/6/95 (Venue & Fuji Xerox)"; + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#if defined(sun) && !defined(OS5) +#define USESUNSCREEN +#else +#undef USESUNSCREEN +#endif + +#include +#include + +#include +#ifdef USESUNSCREEN +#ifdef OS5 +#include +#else +#include +#endif /* OS5 */ +#endif /* USESUNSCREEN */ + +#include +#include + +#ifdef XWINDOW +#ifndef SYSVONLY +#include +#endif /* SYSVONLY */ + +#include +#include +#include "XVersion.h" +#define LDEX "ldex" +extern char *getenv(); +#endif /* XWINDOW */ + + +#define LDEMONO "ldesingle" +#define LDECOLOR "ldemulti" +#define LDETRUECOLOR "ldetruecolor" + +#define FBTYPE_SUNFAST_COLOR 12 + +char filetorun[30]; + + + +/************************************************************************/ +/* */ +/* m a i n */ +/* */ +/* Kick-start program for the "Lisp Development Environment" (lde) */ +/* */ +/************************************************************************/ + +main(argc, argv) + int argc; char **argv; + { + char Earg[30], Ename[30], **newargv; + int i; +#ifdef USESUNSCREEN + struct fbtype my_screen; +#endif /* USESUNSCREEN */ + + + int FrameBufferFd; + +#ifdef USESUNSCREEN + struct fbinfo FB_info; + struct fbgattr FBattr; +#endif /* USESUNSCREEN */ + + + + /* Kickstart program for the Lisp Development Environment (LDE). + Display Device emulator + CG3, CG6 lde.multi + BW2, CG2, CG4, CG9 lde.single + + FB-TYPE REAL-TYPE + BW2 2 x + CG2 3 3 + CG3 8 6 + CG4 2 8 + CG6 8 12 + CG8 6 7 + CG9(GP1) 4 4 ;gpconfig -f -b + CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 + ;We assume This config for GXP model + */ + +#ifdef XWINDOW + /* If X-Server exists on the host specified in -display option + or environment variable DISPLAY, ldex is started. Othewise + ldesingle or ldemulti. + */ + { + char *Display_Name = (char *)NULL ; + Display *Xdisplay = (Display *)NULL; + int i , option; + char *pos; + + for( i=1; i= 0) + { + if( FBattr.real_type == FBTYPE_SUN3COLOR || /* cg3 */ + FBattr.real_type == FBTYPE_SUNFAST_COLOR ) /* cg6 */ + { + strcpy(filetorun, LDECOLOR); + } + } + else + { /* if( ioctl... */ + perror("lde: This Display Model does not supported\n"); + exit( -1 ); + } + } + else if( my_screen.fb_type == FBTYPE_SUN2BW ) + { /* bw2, cg4 or cg9 */ + strcpy(filetorun, LDEMONO); + } + else if( my_screen.fb_type == FBTYPE_SUN3COLOR ) + { + if(ioctl(FrameBufferFd,FBIOGATTR,&FBattr) >= 0) + { + if( FBattr.real_type == FBTYPE_MEMCOLOR ) /* cg8 */ + { + strcpy(filetorun, LDETRUECOLOR); + } + } + else + { /* if( ioctl... */ + perror("lde: This Display Model does not supported\n"); + exit( -1 ); + } + + } + else if( my_screen.fb_type == FBTYPE_SUN2COLOR ) + { /* cg2 */ + strcpy(filetorun, LDEMONO); + } + else + { + perror("lde: This Display Model does not supported\n"); + exit (-1); + }; /* endif( my_screen... */ + + close(FrameBufferFd); + +#endif /* USESUNSCREEN */ + + + + +#ifdef FORKCOMM +/* JRB - call fork_Unix here, while we're REALLY small, unless -NF is + specified, of course... */ + for(i=0; i +#include +#include +#include +#include +#ifdef OS4 +#include +#endif /* OS4 */ + +#include +#include +#include +#include +#include +#include +#ifdef OS4 +#include +#include +#include +#endif /* OS4 */ + +#include +#include +#include + +int ether_fd = -1; /* file descriptor for ether socket */ +unsigned char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address */ +char filetorun[30] = "ldecolor"; + +main(argc, argv, envp) int argc; char **argv, **envp; +{ + char Earg[30], Ename[30], **newargv; + int i; + int flags; +/* Kickstart program for the Lisp Development Environment (LDE). + Run this as setuid root to open the LDE ether socket. + Passes all arguments through to LDE plus -E + to communicate open ether socket. + + looks like this: + ::::::: + + where is the number of the open + socket (decimal), and - are hex of the socket's + 48-bit Ethernet address, and is the name of the + Ethernet device as found by SIOCGIFCONF. +*/ + +if (!geteuid()){ +#ifndef OS4 + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { +#else /* OS4 */ + + if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { +#endif /* OS4 */ + + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + +#ifdef OS4 + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } +#endif /* OS4 */ + + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; +#ifndef OS4 + if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ + + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + (void) close(s); + } + if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + strcpy(Ename, if_data.ifc_req[0].ifr_name); + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + + +#ifdef DEBUG + printf("init_ether: **** Ethernet starts ****\n"); +#endif + } else { +I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + /* exit(); */ + } + seteuid(getuid()); + } + +/* OK, right here do other stuff like scan args */ +/* finally crank up LDE; first copy the original args */ + +newargv = (char **) malloc((argc + 1 + (ether_fd > 0)*2) * sizeof (char **)); +newargv[0] = filetorun; /* or whatever... */ +for(i=1; i 0) { + newargv[i++] = "-E"; + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, + ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); + newargv[i++] = Earg; +} +newargv[i] = 0; + +/* then execve the LDE executable */ +execvp(filetorun, newargv); +perror(filetorun); +exit(1); +} diff --git a/src/allocmds.c b/src/allocmds.c new file mode 100755 index 0000000..42f65c3 --- /dev/null +++ b/src/allocmds.c @@ -0,0 +1,212 @@ +/* $Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/**********************************************************************/ +/* + File Name : allocmds.c + + Allocate Data Type(MDS) + + Date : August 18, 1987 + Edited by : Takeshi Shimizu + + Including : initmdspage + alloc_mdspage + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "cell.h" +#include "lispmap.h" +#include "initatms.h" +#include "sysatms.h" +#include "lspglob.h" + + + + + + +/************************************************************************/ +/* */ +/* Make_MDSEntry */ +/* */ +/* Fill in the MDS type-table entry for a new page (see */ +/* lsptypes.h for the meaning of the entry bits). */ +/* */ +/************************************************************************/ +/* I consider that there is no case the variable named \GCDISABLED is set to T */ +/* #define Make_MDSentry(page,pattern) GETWORD((DLword *)MDStypetbl+(page>>1)) = (DLword)pattern */ + +static void __inline__ +Make_MDSentry( UNSIGNED page, DLword pattern) +{ + GETWORD((DLword *)MDStypetbl+(page>>1)) = (DLword)pattern; +} + + + +/**********************************************************************/ +/* + Func name : initmdspage + + Write the specified MDSTT entry with specified pattern. + returns Top entry for free chain lisp address + + Date : December 24, 1986 + Edited by : Takeshi Shimizu + Changed : Jun. 5 87 take + +*/ +/**********************************************************************/ + +LispPTR +initmdspage(register LispPTR *base, register DLword size, register LispPTR prev) + /* MDS page base */ + /* object cell size you need (WORD) */ + /* keeping top of previous MDS cell */ + +{ + extern DLword *MDStypetbl; + + register int remain_size; /* (IREMAINDER WORDSPERPAGE SIZE) */ + register short num_pages; + register int limit; + int used; /* used space in MDS page */ + register int i; + +#ifdef TRACE2 + printf("TRACE: initmdspage()\n"); +#endif + + remain_size = DLWORDSPER_PAGE % size; + + if( (remain_size != 0) + && (remain_size < (size >> 1) + && (size < DLWORDSPER_PAGE))) + { + num_pages = MDSINCREMENT / DLWORDSPER_PAGE; /* on 1121 maybe 2 */ + limit = DLWORDSPER_PAGE; + } + else + { + num_pages = 1; + limit = MDSINCREMENT; + } + + for(i=0; i< num_pages; i++) + { + used=0; + while((used += size)<= limit) + { + *base = prev; /* write prev MDS address to the top of MDS page */ + prev =LADDR_from_68k( base ); /* exchanging pointers */ + base = (LispPTR *)((DLword *)base + size); + } /* while end */ + + base = (LispPTR *)((DLword *)base + remain_size ); + + } /* for end */ + + return (prev); +} /* initmdspage end */ + + + +/**********************************************************************/ +/* + Func name : alloc_mdspage + + This version works only for KATANA-SUN + + Date : January 13, 1987 + Edited by : Takeshi Shimizu + Changed : 3-Apr-87 (take) + 20-Aug-87(take) ifdef + 08-Oct-87(take) checkfull + 22-Dec-87(Take) + +*/ +/**********************************************************************/ + + +LispPTR * +alloc_mdspage(register short int type) +{ + + extern LispPTR *MDS_free_page_word; /* Free MDS page number */ + + extern DLword *Next_MDSpage; /* next vacant(new) MDS page */ + extern LispPTR *Next_MDSpage_word; + extern LispPTR *Next_Array_word; + + LispPTR newpage(LispPTR base); + + register LispPTR *ptr; /* points Top 32 bit of the MDS page */ + LispPTR next_page; + + /* Next_Array=(DLword *)Addr68k_from_LADDR(((*Next_Array_word)& 0xffff ) << 8); */ + + + if(LOLOC(*MDS_free_page_word )!=NIL) + { + ptr= (LispPTR *)Addr68k_from_LPAGE(LOLOC(*MDS_free_page_word )); + + if( ((next_page= LOLOC(*ptr))!=0 ) + && (GetTypeNumber((*ptr))!= TYPE_SMALLP)) + error("alloc_mdspage: Bad Free Page Link"); + else { + *MDS_free_page_word = S_POSITIVE | next_page; + } + } + else + { + /* I guess Next_MDSpage is redundant */ + checkfor_storagefull(NIL); +#ifdef BIGVM + Next_MDSpage= (DLword *)Addr68k_from_LADDR(((*Next_MDSpage_word) ) << 8); +#else + Next_MDSpage= (DLword *)Addr68k_from_LADDR(((*Next_MDSpage_word)& 0xffff ) << 8); +#endif + ptr = (LispPTR *)Next_MDSpage; /* Get Pointer to First Page */ + Next_MDSpage -= DLWORDSPER_PAGE * 2; /* decrement MDS count */ +#ifdef BIGVM + *Next_MDSpage_word= LPAGE_from_68k(Next_MDSpage); +#else + *Next_MDSpage_word=S_POSITIVE| LPAGE_from_68k(Next_MDSpage); +#endif + newpage(newpage(LADDR_from_68k(ptr)) + DLWORDSPER_PAGE); + } + + Make_MDSentry(LPAGE_from_68k(ptr),type); + return (ptr); +} /* alloc_mdspage end */ + + + + + + diff --git a/src/arith2.c b/src/arith2.c new file mode 100755 index 0000000..d7f35c9 --- /dev/null +++ b/src/arith2.c @@ -0,0 +1,312 @@ +/* $Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "medleyfp.h" +#include "arith.h" + +DLword *createcell68k(unsigned int type); +LispPTR N_OP_flpus2(); +LispPTR N_OP_fdifference(LispPTR parg1, LispPTR parg2); +LispPTR N_OP_fgreaterp(LispPTR parg1, LispPTR parg2); + +/************************************************************ +N_OP_plus2 + entry PLUS2 OPCODE[0324] + entry IPLUS2 OPCODE[0330] + return(tos + b) +************************************************************/ + +LispPTR N_OP_plus2(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + N_GETNUMBER( tos, arg1, doufn ); + N_GETNUMBER( tosm1, arg2, doufn ); + +#ifdef USE_INLINE_ARITH + + result = plus32(arg1, arg2); + N_ARITH_SWITCH(result); + +doufn2: plus_err_label(); + ERROR_EXIT(tos); + +#else + result = arg1 + arg2; + if ( ((arg1>=0) == (arg2>=0)) && ((result>=0) != (arg1>=0)) ) + {ERROR_EXIT(tos);} + N_ARITH_SWITCH(result); + +#endif /* USE_INLINE_ARITH */ + +doufn: return(N_OP_fplus2(tosm1, tos)); + +} + + + +/************************************************************************/ +/* */ +/* N _ O P _ i p l u s 2 */ +/* */ +/* Implements the IPLUS2 opcode--add the two arguments, which */ +/* must be SMALLP or FIXP */ +/* */ +/************************************************************************/ + +LispPTR N_OP_iplus2(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + N_IGETNUMBER( tos, arg1, doufn ); + N_IGETNUMBER( tosm1, arg2, doufn ); + +#ifdef USE_INLINE_ARITH + + result = iplus32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: iplus_err_label(); + +#else + + result = arg1 + arg2; + if ( ((arg1>=0) == (arg2>=0)) && ((result>=0) != (arg1>=0)) ) + {ERROR_EXIT(tos);} + N_ARITH_SWITCH(result); + +#endif /* USE_INLINE_ARITH */ + +doufn: ERROR_EXIT(tos); + +} + + +/************************************************************ +N_OP_difference + entry DIFFERENCE OPCODE[0325] + entry IDIFFERENCE OPCODE[0331] + return(a - tos) +************************************************************/ + +LispPTR N_OP_difference(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + N_GETNUMBER( tosm1, arg1, doufn ); + N_GETNUMBER( tos, arg2, doufn ); + +#ifdef USE_INLINE_ARITH + + result = sub32(arg1, arg2); + N_ARITH_SWITCH(result); + +doufn2: diff_err_label(); + ERROR_EXIT(tos); + +#else + + result = arg1 - arg2; + if ( ((arg1>=0) == (arg2<0)) && ((result>=0) != (arg1>=0)) ) + {ERROR_EXIT(tos);} + N_ARITH_SWITCH(result); + +#endif + +doufn: return(N_OP_fdifference(tosm1, tos)); + +} + + +LispPTR N_OP_idifference(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + N_IGETNUMBER( tosm1, arg1, doufn ); + N_IGETNUMBER( tos, arg2, doufn ); + +#ifdef USE_INLINE_ARITH + + result = isub32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: idiff_err_label(); + +#else + + result = arg1 - arg2; + if ( ((arg1>=0) == (arg2<0)) && ((result>=0) != (arg1>=0)) ) + {ERROR_EXIT(tos);} + N_ARITH_SWITCH(result); + +#endif +doufn: ERROR_EXIT(tos); + +} + + + +/************************************************************ +N_OP_logxor + entry LOGXOR2 OPCODE[0346] + return(tosm1 ^ tos) +************************************************************/ + +LispPTR N_OP_logxor(int tosm1, int tos) +{ + N_IARITH_BODY_2(tosm1, tos, ^); +} + + + +/************************************************************ +N_OP_logand + entry LOGAND2 OPCODE[0345] + return(tosm1 & tos) +************************************************************/ +LispPTR N_OP_logand(int tosm1, int tos) +{ + N_IARITH_BODY_2(tosm1, tos, &); +} + + + +/************************************************************ +N_OP_logor + entry LOGOR2 OPCODE[0344] + return(tosm1 | tos) +************************************************************/ +LispPTR N_OP_logor(int tosm1, int tos) +{ + N_IARITH_BODY_2(tosm1, tos, |); +} + +/************************************************************ +N_OP_greaterp + entry GREATERP OPCODE[0363] + entry IGREATERP OPCODE[0361] + return(tosm1 > tos) + +************************************************************/ +LispPTR N_OP_greaterp(int tosm1, int tos) +{ +register int arg1,arg2; + + N_GETNUMBER( tosm1, arg1, do_ufn); + N_GETNUMBER( tos, arg2, do_ufn); + + if(arg1 > arg2) + return(ATOM_T); + else + return(NIL_PTR); + +do_ufn: return(N_OP_fgreaterp(tosm1, tos)); +} + + +LispPTR N_OP_igreaterp(int tosm1, int tos) +{ +register int arg1,arg2; + + N_IGETNUMBER( tosm1, arg1, do_ufn); + N_IGETNUMBER( tos, arg2, do_ufn); + + if(arg1 > arg2) + return(ATOM_T); + else + return(NIL_PTR); + +do_ufn: ERROR_EXIT(tos); +} + + + +/************************************************************ +N_OP_iplusn + entry IPLUS.N OPCODE[0335] + return(tos + n) +************************************************************/ +LispPTR N_OP_iplusn(int tos, int n) +{ + +register int arg1; +register int result; + + N_IGETNUMBER( tos, arg1, do_ufn ); + +#ifdef USE_INLINE_ARITH + + result = iplus32n(arg1, n); + N_ARITH_SWITCH(result); +dummy: iplusn_err_label(); + +#else + + result = arg1 + n; + if ((result < 0) && (arg1 >= 0)) {ERROR_EXIT(tos);} + N_ARITH_SWITCH(result); + +#endif + +do_ufn: ERROR_EXIT(tos); + +} + + + +/************************************************************ +N_OP_idifferencen + entry IDIFFERENCE.N OPCODE[0336] + return(tos - n) +************************************************************/ +LispPTR N_OP_idifferencen(int tos, int n) +{ +register int arg1; +register int result; + + N_IGETNUMBER( tos, arg1, do_ufn ); + +#ifdef USE_INLINE_ARITH + + result = sub32n(arg1, n); + N_ARITH_SWITCH(result); +dummy: idiffn_err_label(); + +#else + + result = arg1 - n; + if ((result >= 0) && (arg1 < 0)) {ERROR_EXIT(tos);} + N_ARITH_SWITCH(result); + +#endif + +do_ufn: ERROR_EXIT(tos); + +} + + diff --git a/src/arith3.c b/src/arith3.c new file mode 100755 index 0000000..2f8d33e --- /dev/null +++ b/src/arith3.c @@ -0,0 +1,119 @@ +/* $Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* A R I T H 3 . C */ +/* */ +/* Including : OP_makenumber */ +/* OP_boxiplus */ +/* OP_boxidiff */ +/* */ +/* */ +/************************************************************************/ + + +#include "lispemul.h" +#include "lispmap.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "cell.h" +#include "arith.h" + + + + +/************************************************************************/ +/* */ +/* N _ O P _ m a k e n u m b e r */ +/* */ +/* Given the 2 halves of a FIXP as SMALLP's, create a number */ +/* box for the number, and fill it in. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_makenumber(int tosm1, int tos) +{ + register int result; + + if(((tosm1 & 0xFFFF0000) != S_POSITIVE) || ((tos & 0xFFFF0000) != S_POSITIVE)) + ERROR_EXIT(tos); + result = ((tosm1 & 0xffff) << 16) | (tos & 0xffff); + N_ARITH_SWITCH(result); +} /* end OP_makenumber */ + + + +/************************************************************************/ +/* */ +/* N _ O P _ b o x i p l u s */ +/* */ +/* Given a FIXP box and a number to add to it, add the number, */ +/* leaving the result in the box given. Used to avoid garbaging. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_boxiplus(register int a, int tos) +{ + register int arg2; + + if( GetTypeNumber(a) == TYPE_FIXP ) + { + N_GETNUMBER(tos, arg2, bad); + *((LispPTR *)Addr68k_from_LADDR(a)) += arg2; + return(a); + } +bad: ERROR_EXIT(tos); + +} /* OP_boxiplus */ + + + +/************************************************************************/ +/* */ +/* O P _ b o x i d i f f */ +/* */ +/* Given a FIXP box and a number to subtract from it, do the */ +/* subtraction, and leave the result in the box given. */ +/* Used to avoid allocating storage in low-level routines. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_boxidiff(register int a, int tos) +{ + register int arg2; + + if( GetTypeNumber(a) == TYPE_FIXP ) + { + N_GETNUMBER(tos, arg2, bad); + *((LispPTR *)Addr68k_from_LADDR(a)) -= arg2; + return(a); + } + bad: ERROR_EXIT(tos); + +} /* end OP_boxidiff */ + + diff --git a/src/arith4.c b/src/arith4.c new file mode 100755 index 0000000..7dff7c4 --- /dev/null +++ b/src/arith4.c @@ -0,0 +1,210 @@ +/* $Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + + +/***********************************************************************/ +/* + File Name : arith4.c + + Including : OP_times2 326Q(OP_itimes2 332Q) + + OP_quot 327Q(OP_iquot 333Q) + OP_reminder 334Q + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "lispmap.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "cell.h" +#include "medleyfp.h" +#include "arith.h" + + + +/**********************************************************************/ +/* + + Func name : N_OP_times2(itimes2) + +*/ +/**********************************************************************/ +int N_OP_times2(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + + + N_GETNUMBER( tosm1, arg1, doufn ); + N_GETNUMBER( tos, arg2, doufn ); + +#ifdef SUN3_OS3_OR_OS4_IL + + result = mpy32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: mpy_err_label(); + +#else + + result = arg1 * arg2; + if ((arg2 !=0) &&((result / arg2) != arg1) ) goto doufn2; + N_ARITH_SWITCH(result); + +#endif + +doufn2: ERROR_EXIT(tos); +doufn: return(N_OP_ftimes2(tosm1, tos)); + + +} /* end N_OP_times2 */ + +int N_OP_itimes2(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + + N_IGETNUMBER( tosm1, arg1, doufn ); + N_IGETNUMBER( tos, arg2, doufn ); + +#ifdef SUN3_OS3_OR_OS4_IL + + result = impy32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: impy_err_label(); + +#else + + result = arg1 * arg2; + if ((arg2 !=0) &&( (result / arg2) != arg1) ) {goto doufn;} + N_ARITH_SWITCH(result); + +#endif + +doufn: ERROR_EXIT(tos); + + +} /* end N_OP_itimes2 */ + + + +/**********************************************************************/ +/* + + Func name : N_OP_quot(iquot) + +*/ +/**********************************************************************/ +int N_OP_quot(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + + N_GETNUMBER( tosm1, arg1, doufn ); + N_GETNUMBER( tos, arg2, doufn ); + if (arg2 == 0) goto doufn2; + +#ifdef SUN3_OS3_OR_OS4_IL + + result = quot32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: quot_err_label(); + +#else + + result = arg1/arg2; /* lmm: note: no error case!! */ + N_ARITH_SWITCH(result); +#endif +doufn2: ERROR_EXIT(tos); +doufn: return(N_OP_fquotient(tosm1, tos)); + +} /* end N_OP_quot */ + +int N_OP_iquot(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + + N_IGETNUMBER( tosm1, arg1, doufn ); + N_IGETNUMBER( tos, arg2, doufn ); + if (arg2 == 0) goto doufn; + +#ifdef SUN3_OS3_OR_OS4_IL + + result = iquot32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: iquot_err_label(); + +#else + + result = arg1/arg2; + N_ARITH_SWITCH(result); + +#endif + +doufn: ERROR_EXIT(tos); + +} /* end N_OP_quot */ + + +/**********************************************************************/ +/* + + Func name : N_OP_iremainder + +*/ +/**********************************************************************/ + +int N_OP_iremainder(int tosm1, int tos) +{ +register int arg1,arg2; +register int result; + + + N_IGETNUMBER( tosm1, arg1, doufn ); + N_IGETNUMBER( tos, arg2, doufn ); + if (arg2 == 0) goto doufn; + +#ifdef SUN3_OS3_OR_OS4_IL + + result = irem32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: irem_err_label(); + +#else + + result = arg1 % arg2; + N_ARITH_SWITCH(result); + +#endif + +doufn: ERROR_EXIT(tos); + +} /* end N_OP_iremainder */ + diff --git a/src/array.c b/src/array.c new file mode 100755 index 0000000..20a34ce --- /dev/null +++ b/src/array.c @@ -0,0 +1,75 @@ +/* @(#) array.c Version 2.8 (12/23/88). copyright envos & Fuji Xerox */ +static char *id = "@(#) array.c 2.8 12/23/88 (envos & Fuji Xerox)"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "arith.h" +#include "my.h" + +/************************************************************ + OP_claref -- op 372/9 (base typenumber index) + +type size typenumber + 0 0 0 unsigned : 1 bit + 0 3 3 unsigned : 8 bits + 0 4 4 unsigned : 16 bits + 1 4 20 signed : 16 bits + 1 6 22 signed : 32 bits + 2 6 38 pointer : 32 bits + 3 6 54 float : 32 bits + 4 3 67 character : 8 bits + 4 4 68 character : 16 bits + 5 6 86 Xpointer : 32 bits + + +***********************************************************/ + +/*** N_OP_misc3 -- op 372/9 (base typenumber index) ***/ +N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha) +{ + register int result; + register int index, type; + register DLword *wordp; + + /* for CREATECELL */ + DLword *createcell68k(unsigned int type); + + if (alpha != 9) ERROR_EXIT(inx); + /* test and setup index */ + N_GetPos(inx, index, inx); + + /* test and setup typenumber */ + N_GetPos(typenumber, type, inx); + + /* disp on type */ +#ifdef OS4 + aref_switch(type, inx, baseL, index); +#else + return ( aref_switch(type, inx, baseL, index) ); +#endif + + } /* end N_OP_misc3() */ diff --git a/src/array2.c b/src/array2.c new file mode 100755 index 0000000..5acda03 --- /dev/null +++ b/src/array2.c @@ -0,0 +1,71 @@ +/* This is G-file @(#) array2.c Version 2.9 (10/12/88). copyright Xerox & Fuji Xerox */ +static char *id = "@(#) array2.c 2.9 10/12/88"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* A R R A Y 2 . C */ +/* */ +/* Contains N_OP_misc4, the ASET opcode. */ +/* */ +/************************************************************************/ + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "gc.h" +#include "arith.h" +#include "my.h" + + + +/************************************************************************/ +/* */ +/* N _ O P _ m i s c 4 */ +/* */ +/* CL:ASET opcode op 373/7 (data, base typenumber, index) */ +/* */ +/************************************************************************/ + +N_OP_misc4(register LispPTR data, register LispPTR base, register LispPTR typenumber, register LispPTR inx, int alpha) +{ + register int new; + register int index; + int type; + + if (alpha != 7) ERROR_EXIT(inx); + + /* test and setup index */ + N_GetPos(inx, index, inx); + + /* test and setup typenumber */ + N_GetPos(typenumber, type, inx); + + aset_switch(type, inx); + +doufn: ERROR_EXIT(inx); + + } /* end N_OP_misc4() */ + diff --git a/src/array3.c b/src/array3.c new file mode 100755 index 0000000..505c82a --- /dev/null +++ b/src/array3.c @@ -0,0 +1,79 @@ +/* This is G-file @(#) array3.c Version 2.9 (10/12/88). copyright Xerox & Fuji Xerox */ +static char *id = "@(#) array3.c 2.9 10/12/88"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* A R R A Y 3 . C */ +/* */ +/* Contains: N_OP_aref1 */ +/* */ +/************************************************************************/ + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "arith.h" +#include "my.h" + +/*** N_OP_aref1 -- op 266 (array index) ***/ +N_OP_aref1(register LispPTR arrayarg, register LispPTR inx) +{ + + register LispPTR baseL; + register int type, index; + register OneDArray *arrayblk; + LispPTR temp; + register int result; + + /* for CREATECELL */ + register DLword *wordp; + DLword *createcell68k(unsigned int type); + + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) ERROR_EXIT(inx); + arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); + + /* test and setup index */ + N_GetPos(inx, index, inx); + if (index >= arrayblk->totalsize) ERROR_EXIT(inx); + index += arrayblk->offset; + + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; + + /* setup base */ + baseL = arrayblk->base; + + /* disp on type */ +#ifdef OS4 + aref_switch(type, inx, baseL, index); +#else + return ( aref_switch(type, inx, baseL, index) ); +#endif + +} /* end N_OP_aref1() */ + + diff --git a/src/array4.c b/src/array4.c new file mode 100755 index 0000000..1cc107c --- /dev/null +++ b/src/array4.c @@ -0,0 +1,84 @@ +/* This is G-file @(#) array4.c Version 2.7 (10/12/88). copyright Xerox & Fuji Xerox */ +static char *id = "@(#) array4.c 2.7 10/12/88"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +/************************************************************************/ +/* */ +/* A R R A Y 4 . C */ +/* */ +/* Contains: N_OP_aset1 */ +/* */ +/************************************************************************/ + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "arith.h" +#include "gc.h" +#include "my.h" + +/*** N_OP_aset1 -- op 267 (new-value array index) ***/ + + +/************************************************************************/ +/* */ +/* N _ O P _ a s e t 1 */ +/* */ +/* 1-dimensional array setter. */ +/* */ +/************************************************************************/ + +N_OP_aset1(register LispPTR data, LispPTR arrayarg, register int inx) +{ + register int type; + register OneDArray *arrayblk; + register LispPTR base; + register int new; + register int index; + + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) ERROR_EXIT(inx); + arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); + + /* test and setup index */ + N_GetPos(inx, index, inx); + if (index >= arrayblk->totalsize) ERROR_EXIT(inx); + index += arrayblk->offset; + + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; + + /* setup base */ + base = arrayblk->base; + + + /* disp on type */ + aset_switch(type, inx); + +doufn: ERROR_EXIT(inx); + + } /* end N_OP_aset1() */ + diff --git a/src/array5.c b/src/array5.c new file mode 100755 index 0000000..bd30fc0 --- /dev/null +++ b/src/array5.c @@ -0,0 +1,89 @@ +/* This is G-file @(#) array5.c Version 2.7 (10/12/88). copyright Xerox & Fuji Xerox */ +static char *id = "@(#) array5.c 2.7 10/12/88"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +/************************************************************************/ +/* */ +/* A R R A Y 5 . C */ +/* */ +/* Contains: N_OP_aref2 2-d AREF opcode */ +/* */ +/************************************************************************/ + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "arith.h" +#include "my.h" + + + +/************************************************************************/ +/* */ +/* N _ O P _ a r e f 2 */ +/* */ +/* 2-d AREF op 356 (array index0 index1) */ +/* */ +/************************************************************************/ + +N_OP_aref2(LispPTR arrayarg, LispPTR inx0, LispPTR inx1) +{ +#define REG + LispPTR baseL; + int type; + int arindex, temp; + LispArray *arrayblk; + int j; + /* for CREATECELL */ + DLword *createcell68k(unsigned int type); + + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_TWOD_ARRAY) ERROR_EXIT(inx1); + arrayblk = (LispArray *)Addr68k_from_LADDR(arrayarg); + baseL = arrayblk->base; + + /* test and setup index */ + N_GetPos(inx1, temp, inx1); + if (temp >= (j = arrayblk->Dim1)) ERROR_EXIT(inx1); + N_GetPos(inx0, arindex, inx1); + if (arindex >= arrayblk->Dim0) ERROR_EXIT(inx1); + arindex *= j; + arindex += temp; + + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; + + /* disp on type */ +#ifdef OS4 + aref_switch(type, inx1, baseL, arindex); +#else + return ( aref_switch(type, inx1, baseL, arindex) ); +#endif + +} /* end N_OP_aref2() */ + + diff --git a/src/array6.c b/src/array6.c new file mode 100755 index 0000000..bd6bb33 --- /dev/null +++ b/src/array6.c @@ -0,0 +1,68 @@ +/* This is G-file @(#) array6.c Version 2.10 (4/21/92). copyright Xerox & Fuji Xerox */ +static char *id = "@(#) array6.c 2.10 4/21/92"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "gc.h" +#include "arith.h" +#include "my.h" + +/*** N_OP_aset2 -- op 357 (new-value array index0 index1) ***/ +N_OP_aset2(register LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1) +{ + +register int type; +register LispArray *arrayblk; +register LispPTR base; +register int new; +register int index, temp; +int j; + + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_TWOD_ARRAY) ERROR_EXIT(inx1); + arrayblk = (LispArray *)Addr68k_from_LADDR(arrayarg); + base = arrayblk->base; + + /* test and setup index */ + N_GetPos(inx1, temp, inx1); + if (temp >= (j = arrayblk->Dim1)) ERROR_EXIT(inx1); + N_GetPos(inx0, index, inx1); + if (index >= arrayblk->Dim0) ERROR_EXIT(inx1); + index *= j; + index += temp; + + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; + + /* disp on type */ + aset_switch(type, inx1); + +doufn: ERROR_EXIT(inx1); + +} /* end N_OP_aset2() */ + diff --git a/src/asmbbt.c b/src/asmbbt.c new file mode 100755 index 0000000..837e612 --- /dev/null +++ b/src/asmbbt.c @@ -0,0 +1,59 @@ +/* $Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* File: asmbbt.c */ +/* */ +/* Dummy C-function "bitblt", used to compile the bitblt code */ +/* for hand-optimization. */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "adr68k.h" +#include "address.h" +#include "arith.h" +#include "stack.h" +#include "cell.h" +#include "gc.h" + + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" + + +void bitblt(DLword *srcbase, DLword dstbase, int sx, int dx, int w, int h, int srcbpl, int dstbpl, int backwardflg, int src_comp, int op, int gray, int num_gray, int curr_gray_line) +{ + new_bitblt_code; + } + diff --git a/src/asmbitblt.c b/src/asmbitblt.c new file mode 100755 index 0000000..b39f46c --- /dev/null +++ b/src/asmbitblt.c @@ -0,0 +1,66 @@ +/* $Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* File: asmbitblt.c */ +/* */ +/* Dummy C-function "bitblt", used to compile the bitblt code */ +/* for hand-optimization. */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include "lispemul.h" +#include "lispglobal.h" +#include "lispmap.h" +#include "lisptypes.h" +#include "emulglobal.h" +#include "address68k.h" +#include "address.h" +#include "arith.h" +#include "stack.h" +#include "cell.h" +#include "gc.h" + + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" + + +void +bitblt(DLword *srcbase, DLword *dstbase, int sx, int dx, int w, int h, + int srcbpl, int dstbpl, int backwardflg, int src_comp, + int op, int gray, int num_gray, int curr_gray_line) + + DLword * srcbase, dstbase; + int sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, op, gray, num_gray, curr_gray_line; + + { + new_bitblt_code; + } + diff --git a/src/atom.c b/src/atom.c new file mode 100755 index 0000000..5702729 --- /dev/null +++ b/src/atom.c @@ -0,0 +1,91 @@ +/* $Id: atom.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: atom.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +/**********************************************************************/ +/* + File Name : atom.c + + Desc : implement opcode ATOMCELL.N + + Date : Apr 13, 1987 + Edited by : Naoyuki Mitani + + Including : OP_atomcellN + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" + + +#ifndef BIGATOMS +N_OP_atomcellN(tos, n) + register int tos; + int n; + { + + if ((tos & 0xffff0000) != 0) ERROR_EXIT(tos); + + tos = (tos << 1); + + switch(n) + { + case D_DEFSHI : return(DEFS_OFFSET + tos); + case D_VALSHI : return(VALS_OFFSET + tos); + case D_PLISHI : return(PLIS_OFFSET + tos); + case D_PNHI : return(PNP_OFFSET + tos); + default : ERROR_EXIT(tos); + } +} + +#else +N_OP_atomcellN(register int tos, int n) +{ + + if ((tos & 0xffff0000) == 0){ /* XeroxLisp traditional symbol */ + tos = (tos << 1); + switch(n) + { + case D_DEFSHI : return(DEFS_OFFSET + tos); + case D_VALSHI : return(VALS_OFFSET + tos); + case D_PLISHI : return(PLIS_OFFSET + tos); + case D_PNHI : return(PNP_OFFSET + tos); + default : ERROR_EXIT(tos); + } + } + else{ /* New Symbol */ + switch(n) + { + case D_DEFSHI : return(NEWATOM_DEFN_OFFSET + tos); + case D_VALSHI : return(NEWATOM_VALUE_OFFSET + tos); + case D_PLISHI : return(NEWATOM_PLIST_OFFSET + tos); + case D_PNHI : return(NEWATOM_PNAME_OFFSET + tos); + default : ERROR_EXIT(tos); + } + } + } + +#endif diff --git a/src/bbt68k.s b/src/bbt68k.s new file mode 100755 index 0000000..93f616d --- /dev/null +++ b/src/bbt68k.s @@ -0,0 +1,1683 @@ +# @(#) bbt68k.s Version 1.1 (4/21/92). copyright Venue & Fuji Xerox # + ######################################################################## + # # + # b i t b l t 6 8 K # + # # + # Hand-optimized bitblt for the MC68020. This was created # + # by taking Don Charnley's C version & creating an assembler # + # intermediate file, then hand tuning. # + # # + # bitblt68K(srcbase, dstbase, sx, dx, width, height, # + # srcbpl, dstbpl, backwardflg, src_comp, op, # + # gray, num_gray, curr_gray_line) # + # # + # # + # # + # # + ######################################################################## + .data + .text +LL0: + .proc + LF101 = 128 + LS101 = 15608 + LFF101 = 92 + LSS101 = 0 + LV101 = 92 +| +| Argument offsets on the stack +| +#define srcbase a6@(8) +#define dstbase a6@(12) +#define sx a6@(16) +#define dx a6@(20) +#define width a6@(24) +#define height a6@(28) +#define srcbpl a6@(32) +#define dstbpl a6@(36) +#define backwardflg a6@(40) +#define src_comp a6@(44) +#define op a6@(48) +#define gray a6@(52) +#define num_gray a6@(56) +#define curr_gray_line a6@(60) +| +| Local variable offsets on the stack +| +| -4 num_lines_remaining +| -8 PRECOMPUTED FOR GRAY CASE: (num_gray-1)<<1 +| -12 dstnumL +| -16 src32lbit +| -20 srcLshift +| -24 dst32lbit +| -28 srcRmask +| -32 dstold +| -36 PRECOMPUTED dstbpl << 3 +| -40 mask +| -44 preloop_mask +| -48 postloop_mask +| -52 sdw_mask +| -56 +| -60 dst32rbit +| -64 src32rbit +| -68 +| -72 +| -76 +| -80 bb_fast +| -84 +| -88 +| -92 +#define num_lines_remaining a6@(-4) +|#define temp a6@(-8) /* NEVER loaded, only stored into */ +#define gray_line_length a6@(-8) +#define dstnumL a6@(-12) +#define src32lbit a6@(-16) +#define srcLshift a6@(-20) +#define dst32lbit a6@(-24) +#define srcRmask a6@(-28) +#define dstold a6@(-32) +|#define dstdata a6@(-36) /* no longer used */ +#define dstbpl3 a6@(-36) +#define mask a6@(-40) +|#define x32byta a6@(-44) /* no longer used */ +|#define x32nbyt a6@(-48) /* no longer used */ +|#define x32ia a6@(-52) /* no longer used */ +|#define abc a6@(-56) /* no longer used */ +#define dst32rbit a6@(-60) +#define src32rbit a6@(-64) +|#define fwd a6@(-68) /* No longer used 10/30/89 JDS */ +|#define OrigSrcAddr a6@(-72) +|#define OrigDstAddr a6@(-76) +#define OrigSrcAddr a3 +#define OrigDstAddr a2 +|#define bb_fast a6@(-80) +|#define preloop_mask a6@(-84) +|#define postloop_mask a6@(-88) +|#define sdw_mask a6@(-92) +#define bb_fast a6@(-80) +#define preloop_mask a6@(-44) +#define postloop_mask a6@(-48) +#define sdw_mask a6@(-52) +| +| Register usage remaining from the compiler +| +| a5 srcbase [used 7 times in code] +| a4 dstbase +| a3 OrigSrcAddr (via #define) +| a2 OrigDstAddr (via #define) +| a0 srcaddr +| a1 dstaddr +| +| d7 ShS +| d6 SavedS +| d5 NewS +| d4 srcRshift +| d3 cnt (Loop counter in very inner loops) +| d2 dst32lbit, part-time. +| d1 [working temp] +| d0 [working temp] +| + + .data + .text + .globl _bitblt +_bitblt: +|#PROLOGUE# 0 + link a6,#-128 + moveml #0x3cfc,sp@ +|#PROLOGUE# 1 + movl srcbase,a5 + movl dstbase,a4 + # num_lines_remaining = h; + movl height,num_lines_remaining + # fwd = !backwardflg; /* Removed as redundant */ + # bb_fast = !(31 & (srcbpl | dstbpl)); + movl srcbpl,d0 + orl dstbpl,d0 + moveq #31,d7 + andl d7,d0 + notl d0 + movl d0,bb_fast + + movl dstbpl,d0 + asrl #3,d0 + movl d0,dstbpl3 + + tstl gray + jeq L103 + + ######################################################### + # Precompute the texture -backup amount for loop bottom # + ######################################################### + movl num_gray,d0 + subql #1,d0 + asll #1,d0 + movl d0,gray_line_length + + tstl dx + jge L104 + movl a4,d0 + moveq #7,d1 + subl dx,d1 + asrl #3,d1 + subl d1,d0 + jra LY00000 +L104: + movl a4,d0 + movl dx,d1 + asrl #3,d1 + addl d1,d0 +| +| d0 = x32byta +| d1 = x32nbyt +| a1 = x32ia = dst32addr +LY00000: + movl d0,d1 +| movb a6@(-41),d0 + moveq #3,d7 + andl d7,d1 +| movl d0,x32nbyt + movl d0,a1 + subl d1,a1 +| movl a1,x32ia + lsll d7,d1 + movb a6@(23),d0 | dx + moveq #7,d7 + andl d7,d0 + addl d0,d1 + movl d1,dst32lbit + movl d1,d2 | d2 = dst32lbit starts here + addl width,d1 + subql #1,d1 + moveq #31,d7 + andl d7,d1 + movl d1,dst32rbit + movl a1,OrigDstAddr +| tstl dst32lbit + tstl d2 + jeq L2000004 + moveq #32,d0 +| subl dst32lbit,d0 + subl d2,d0 + moveq #-1,d1 + asll d0,d1 + notl d1 + jra L2000005 +L2000004: + moveq #-1,d1 +L2000005: + movl d1,preloop_mask + moveq #31,d0 + subl dst32rbit,d0 + moveq #-1,d1 + asll d0,d1 + movl d1,postloop_mask + movl preloop_mask,d0 + andl d1,d0 + movl d0,sdw_mask +| movl dst32lbit,d0 + movl d2,d0 + addl width,d0 + asrl #5,d0 + subql #1,d0 + movl d0,dstnumL + movb a6@(39),d0 |dstbpl + moveq #31,d7 + andl d7,d0 + notl d0 + movl d0,bb_fast + movb a6@(19),d0 |sx + moveq #15,d7 + andl d7,d0 + movl d0,src32lbit + jra LY00009 + # else if (fwd) +L103: + tstl backwardflg + jne L107 + # {if (dx < 0) + tstl dx + jge L108 + # { x32byta = (int)dstbase - ((7 - dx) >> 3); } + # else { x32byta = (int)dstbase + (dx >> 3); } + # x32nbyt = x32byta & 3; + # x32ia = x32byta - x32nbyt; + # dst32addr = (int *)x32ia; + movl a4,d0 + moveq #7,d1 + subl dx,d1 + asrl #3,d1 + subl d1,d0 + jra LY00001 +L108: + movl a4,d0 + movl dx,d1 + asrl #3,d1 + addl d1,d0 +LY00001: +| movl d0,x32byta + movl d0,d1 +| movb a6@(-41),d1 + moveq #3,d7 + andl d7,d1 +| movl d1,x32nbyt +| movl x32byta,a1 + movl d0,a1 + subl d1,a1 +| movl a1,x32ia + asll d7,d1 + movb a6@(23),d0 | dx + moveq #7,d7 + andl d7,d0 + addl d0,d1 + movl d1,dst32lbit + movl d1,d2 | d2 = dst32lbit starting here + addl width,d1 + subql #1,d1 + moveq #31,d7 + andl d7,d1 + movl d1,dst32rbit + # OrigDstAddr = dst32addr; + # preloop_mask = ((dst32lbit) ? (~(0xFFFFFFFF << (32 - dst32lbit))) : 0xFFFFFFFF); + # postloop_mask = 0xFFFFFFFF << (31 - dst32rbit); + # sdw_mask = preloop_mask & postloop_mask; + # dstnumL = ((dst32lbit + w) >> 5) - 1; + movl a1,OrigDstAddr +| tstl dst32lbit + tstl d2 + jeq L2000008 + moveq #32,d0 +| subl dst32lbit,d0 + subl d2, d0 + moveq #-1,d1 + asll d0,d1 + notl d1 + jra L2000009 +L2000008: + moveq #-1,d1 +L2000009: + movl d1,preloop_mask + moveq #31,d0 + subl dst32rbit,d0 + moveq #-1,d1 + asll d0,d1 + movl d1,postloop_mask + movl preloop_mask,d0 + andl d1,d0 + movl d0,sdw_mask +| movl dst32lbit,d0 + movl d2,d0 + addl width,d0 + asrl #5,d0 + subql #1,d0 + movl d0,dstnumL + # if (sx < 0) + # { x32byta = (int)srcbase - ((7 - sx) >> 3); } + # else { x32byta = (int)srcbase + (sx >> 3); } + tstl sx + jge L110 + movl a5,d0 + moveq #7,d1 + subl sx,d1 + asrl #3,d1 + subl d1,d0 + jra LY00002 +L110: + movl a5,d0 + movl sx,d1 + asrl #3,d1 + addl d1,d0 +LY00002: +| movl d0,x32byta + # x32nbyt = x32byta & 3; + # x32ia = x32byta - x32nbyt; + # src32addr = (int *)x32ia; +| movb a6@(-41),d1 + movl d0,d1 + moveq #3,d7 + andl d7,d1 +| movl d1,x32nbyt +| movl x32byta,a0 + movl d0,a0 + subl d1,a0 +| movl a1,x32ia + asll d7,d1 + movb a6@(19),d0 | sx + moveq #7,d7 + andl d7,d0 + addl d1,d0 | d0 = src32lbit starts here + movl d0,src32lbit + movl d0,d1 + addl width,d1 + subql #1,d1 + moveq #31,d7 + andl d7,d1 + movl d1,src32rbit +| movl dst32lbit,d4 + movl d2,d4 +| subl src32lbit,d4 + subl d0,d4 + andl d7,d4 +| movl src32lbit,d0 | d0 = src32lbit stops here +| subl dst32lbit,d0 + subl d2,d0 + andl d7,d0 + movl d0,srcLshift + jeq L2000010 +LY00006: | srcLshift is in d0 every way you get here. + moveq #-1,d1 +| movw a6@(-18),d1 | srcLshift + asll d0,d1 + notl d1 + jra L2000051 +L2000010: + moveq #-1,d1 + jra L2000051 +L107: + movl dx,d2 | d2 = abc starts here + addl width,d2 + subql #1,d2 +| movl d2,abc + jge L113 + movl a4,d0 + moveq #7,d1 +| subl abc,d1 + subl d2,d1 + asrl #3,d1 + subl d1,d0 + jra LY00003 +L113: + movl a4,d0 +| movl abc,d1 + movl d2,d1 + asrl #3,d1 + addl d1,d0 +LY00003: +| movl d0,x32byta +| movb a6@(-41),d1 + movl d0,d1 + moveq #3,d7 + andl d7,d1 +| movl d1,x32nbyt +| movl x32byta,a1 + movl d0,a1 + subl d1,a1 +| movl a1,x32ia + asll d7,d1 +| movb a6@(-53),d0 | abc + movl d2,d0 | d2 = abc ends here + moveq #7,d7 + andl d7,d0 + addl d0,d1 + movl d1,dst32rbit | d1 = dst32rbit starts here + movl d1,d2 + subl width,d2 | d2 = dst32lbit starts here + addql #1,d2 + moveq #31,d7 + andl d7,d2 + movl d2,dst32lbit + movl a1,OrigDstAddr + moveq #31,d0 +| subl dst32rbit,d0 + subl d1,d0 | d1 = dst32rbit stops here + moveq #-1,d1 + asll d0,d1 + movl d1,preloop_mask + moveq #32,d0 + moveq #-1,d1 + tstl d2 + jeq JDS2 +| subl dst32lbit,d0 + subl d2,d0 | d2 = dst32lbit stops here +| moveq #-1,d1 + asll d0,d1 + notl d1 +JDS2: movl d1,postloop_mask + movl preloop_mask,d0 + andl d1,d0 + movl d0,sdw_mask + movl width,d0 + subl dst32rbit,d0 + subql #1,d0 + tstl d0 + jle L2000012 + movl width,d0 + subl dst32rbit,d0 + subql #1,d0 + asrl #5,d0 + jra L2000013 +L2000012: + moveq #0,d0 +L2000013: + movl d0,dstnumL + movl sx,d2 | d2 = abc starts here + addl width,d2 + subql #1,d2 +| movl d2,abc + jge L115 + movl a5,d0 + moveq #7,d1 +| subl abc,d1 + subl d2,d1 + asrl #3,d1 + subl d1,d0 + jra LY00004 +L115: + movl a5,d0 +| movl abc,d1 + movl d2,d1 + asrl #3,d1 + addl d1,d0 +LY00004: +| movl d0,x32byta +| movb a6@(-41),d1 + movl d0,d1 + moveq #3,d7 + andl d7,d1 +| movl d1,x32nbyt +| movl x32byta,a0 + movl d0,a0 + subl d1,a0 +| movl a0,x32ia + asll d7,d1 +| movb a6@(-53),d0 |abc + movl d2,d0 | d2 = abc ends here + moveq #7,d7 + andl d7,d0 + addl d0,d1 + movl d1,src32rbit + jra LY00016 +LY00010: + tstl gray + jeq L119 + movl src32lbit,d0 + subl dst32lbit,d0 + moveq #15,d7 + andl d7,d0 | d0 = srcLshift + movl d0,srcLshift + moveq #0,d7 + movw a5@,d7 + movl d7,d1 +| moveq #16,d1 +| lsll d1,d0 + swap d1 + orl d1,d7 +| movw a6@(-18),d0 +| lsll d0,d7 +| movl d7,d0 +| moveq #16,d1 +| lsrl d1,d0 +| andl #65535,d0 +| orl d0,d7 + roll d0,d7 + tstl src_comp + jeq L120 + notl d7 | end oof d0 = srcLshift +L120: + movl dst32lbit,d0 + addl width,d0 + moveq #32,d5 + cmpl d5,d0 + jle LY00008 + movl preloop_mask,mask + movl a1@,d5 | d5 = dstdata thru here... + movl mask,d1 | d1 = dstold thru here + notl d1 + andl d5,d1 +| movl d1,dstold + movl op,d0 +| moveq #3,d5 +| cmpl d5,d0 +| jhi L123 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000017: + .word L125-L2000017 + .word L126-L2000017 + .word L127-L2000017 + .word L128-L2000017 +L125: + movl d7,d5 + jra L123 +L126: + andl d7,d5 + jra L123 +L127: + orl d7,d5 + jra L123 +L128: + eorl d7,d5 +L123: + movl mask,d0 + andl d0,d5 + orl d1,d5 | wass dstold +| orl d0,dstdata + movl d5,a1@+ + movl op,d0 + movl dstnumL,d3 | from all loop headers below. +| moveq #3,d5 +| cmpl d5,d0 +| jhi L129 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000019: + .word L131-L2000019 + .word L135-L2000019 + .word L139-L2000019 + .word L143-L2000019 +L131: +| movl dstnumL,d3 +L134: + subql #1,d3 + jmi L129 + movl d7,a1@+ + jra L134 +L135: +| movl dstnumL,d3 +L138: + subql #1,d3 + jmi L129 + andl d7,a1@+ + jra L138 +L139: +| movl dstnumL,d3 +L142: + subql #1,d3 + jmi L129 + orl d7,a1@+ + jra L142 +|L143: +| movl dstnumL,d3 +| jra LY00013 +LY00014: + eorl d7,a1@+ +L143: +LY00013: + subql #1,d3 + jpl LY00014 +L129: + cmpl #31,dst32rbit + jeq L148 + jra L337 +L119: + tstl backwardflg + jne L149 + movw a6@(-18),d1 | srcLshift in d1 down thru L151 + movl src32lbit,d0 + cmpl dst32lbit,d0 + jle L150 + addl width,d0 + moveq #32,d7 + cmpl d7,d0 + jle L150 + movl a0@+,d6 +| movw a6@(-18),d1 | srcLshift + lsll d1,d6 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + andl srcRmask,d7 + orl d6,d7 + lsll d1,d0 + movl srcRmask,d1 + notl d1 + andl d1,d0 + movl d0,d6 + jra L151 +L150: + movl src32lbit,d0 + cmpl dst32lbit,d0 + jgt L152 + movl a0@+,d6 + movl d6,d7 + lsrl d4,d7 + andl srcRmask,d7 +| movw a6@(-18),d1 |srcLshift + lsll d1,d6 + movl srcRmask,d1 + notl d1 + andl d1,d6 + jra L151 +L152: + movl a0@+,d7 +| movw a6@(-18),d1 | srcLshift + lsll d1,d7 +L151: + tstl src_comp + jeq L154 + notl d7 +L154: + movl dst32lbit,d0 + addl width,d0 + moveq #32,d5 + cmpl d5,d0 + jle LY00008 + movl preloop_mask,mask + movl a1@,d5 | d5 = dstdata thru here + movl mask,d1 | d1 = dstold thru here. + notl d1 + andl d5,d1 +| movl d1,dstold + movl op,d0 +| moveq #3,d5 +| cmpl d5,d0 +| jhi L156 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000021: + .word L158-L2000021 + .word L159-L2000021 + .word L160-L2000021 + .word L161-L2000021 +L158: + movl d7,d5 + jra L156 +L159: + andl d7,d5 + jra L156 +L160: + orl d7,d5 + jra L156 +L161: + eorl d7,d5 +L156: + movl mask,d0 + andl d0,d5 +| movl dstold,d1 + orl d1,d5 + movl d5,a1@+ + movl src32lbit,d0 + cmpl dst32lbit,d0 + jne L162 + tstl src_comp + jeq L184 + movl op,d0 + movl dstnumL,d3 | from loop headers below +| moveq #3,d7 +| cmpl d7,d0 +| jhi L201 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000023: + .word L166-L2000023 + .word L170-L2000023 + .word L174-L2000023 + .word L178-L2000023 +L166: +| movl dstnumL,d3 +L169: + subql #1,d3 + jmi L201 + movl a0@+,d0 + notl d0 + movl d0,a1@+ + jra L169 +L170: +| movl dstnumL,d3 +L173: + subql #1,d3 + jmi L201 + movl a0@+,d0 + notl d0 + andl d0,a1@+ + jra L173 +L174: +| movl dstnumL,d3 +L177: + subql #1,d3 + jmi L201 + movl a0@+,d0 + notl d0 + orl d0,a1@+ + jra L177 +L178: +| movl dstnumL,d3 +L181: + subql #1,d3 + jmi L201 + movl a0@+,d0 + notl d0 + eorl d0,a1@+ + jra L181 +L185: +| movl dstnumL,d3 +L188: + subql #1,d3 + jmi L201 + movl a0@+,a1@+ + jra L188 +L189: +| movl dstnumL,d3 +L192: + subql #1,d3 + jmi L201 + movl a0@+,d0 + andl d0,a1@+ + jra L192 +L193: +| movl dstnumL,d3 +L196: + subql #1,d3 + jmi L201 + movl a0@+,d0 + orl d0,a1@+ + jra L196 +L197: +| movl dstnumL,d3 +L200: + subql #1,d3 + jmi L201 + movl a0@+,d0 + eorl d0,a1@+ + jra L200 +L184: + movl op,d0 + movl dstnumL,d3 |from loop headers +| moveq #3,d7 +| cmpl d7,d0 +| jhi L201 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000025: + .word L185-L2000025 + .word L189-L2000025 + .word L193-L2000025 + .word L197-L2000025 + jra L201 +L162: + tstl src_comp + jeq L223 + movl op,d0 +| moveq #3,d7 +| cmpl d7,d0 +| jhi L201 + movw a6@(-18),d1 | from within the loops below, srcLshift + movl dstnumL,d3 | from loop headers + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000027: + .word L205-L2000027 + .word L209-L2000027 + .word L213-L2000027 + .word L217-L2000027 +L205: +| movl dstnumL,d3 +L208: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 + notl d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + movl d7,a1@+ + jra L208 +L209: +| movl dstnumL,d3 +L212: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 + notl d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + andl d7,a1@+ + jra L212 +L213: +| movl dstnumL,d3 +L216: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 + notl d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + orl d7,a1@+ + jra L216 +L217: +| movl dstnumL,d3 +L220: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 + notl d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + eorl d7,a1@+ + jra L220 +L224: +| movl dstnumL,d3 +L227: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + movl d7,a1@+ + jra L227 +L228: +| movl dstnumL,d3 +L231: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + andl d7,a1@+ + jra L231 +L232: +| movl dstnumL,d3 +L235: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + orl d7,a1@+ + jra L235 +L236: +| movl dstnumL,d3 +L239: + subql #1,d3 + jmi L201 + movl a0@+,d0 + movl d0,d7 + lsrl d4,d7 + orl d6,d7 +| movw a6@(-18),d1 + lsll d1,d0 + movl d0,d6 + eorl d7,a1@+ + jra L239 +L223: + movl op,d0 +| moveq #3,d7 +| cmpl d7,d0 +| jhi L201 + movw a6@(-18),d1 | from loops after dispatch, srcLshift + movl dstnumL,d3 | from loop headers + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000029: + .word L224-L2000029 + .word L228-L2000029 + .word L232-L2000029 + .word L236-L2000029 +L201: + cmpl #31,dst32rbit + jeq L148 + movl src32rbit,d0 + cmpl dst32rbit,d0 + jgt L335 + movl a0@,d0 + lsrl d4,d0 + andl srcRmask,d0 + jra LY00011 +L149: + movl src32rbit,d0 + cmpl dst32rbit,d0 + jge L244 + movl src32lbit,d0 + addl width,d0 + movl dst32lbit,d1 + addql #1,d1 + cmpl d1,d0 + jle L244 + movl a0@,d6 + lsrl d4,d6 + andl srcRmask,d6 + movl a0@-,d0 + subqw #4,a0 + movl d0,d7 + movw a6@(-18),d1 | srcLshift + lsll d1,d7 + orl d6,d7 + lsrl d4,d0 + andl srcRmask,d0 + movl d0,d6 + jra L245 +L244: + movl src32rbit,d0 + cmpl dst32rbit,d0 + jlt L246 + movl a0@,d6 + subqw #4,a0 + movl d6,d7 + movw a6@(-18),d1 | srcLshift + lsll d1,d7 + lsrl d4,d6 + andl srcRmask,d6 + jra L245 +L246: + movl a0@,d7 + subqw #4,a0 + lsrl d4,d7 + andl srcRmask,d7 +L245: + tstl src_comp + jeq L248 + notl d7 +L248: + movl dst32lbit,d0 + addl width,d0 + moveq #32,d5 + cmpl d5,d0 + jgt L249 +LY00008: + movl sdw_mask,mask + jra L122 +L249: + movl preloop_mask,mask + movl a1@,d5 | d5 = dstdata thru here + movl mask,d1 | d1 = dstold thru here. + notl d1 + andl d5,d1 +| movl d1,dstold + movl op,d0 +| moveq #3,d5 +| cmpl d5,d0 +| jhi L250 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000031: + .word L252-L2000031 + .word L253-L2000031 + .word L254-L2000031 + .word L255-L2000031 +L252: + movl d7,d5 + jra L250 +L253: + andl d7,d5 + jra L250 +L254: + orl d7,d5 + jra L250 +L255: + eorl d7,d5 +L250: +| movl mask,d0 +| andl d0,d5 + andl mask,d5 +| movl dstold,d0 +| orl d0,d5 + orl d1,d5 | end of d1/dstold range + movl d5,a1@ + subqw #4,a1 + movl src32lbit,d0 + cmpl dst32lbit,d0 + jne L256 + tstl src_comp + jeq L278 + movl op,d0 + movl dstnumL,d3 | from loop headers below +| moveq #3,d7 +| cmpl d7,d0 +| jhi L295 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000033: + .word L260-L2000033 + .word L264-L2000033 + .word L268-L2000033 + .word L272-L2000033 +L260: +| movl dstnumL,d3 +L263: + subql #1,d3 + jmi L295 + movl a0@,d0 + notl d0 + movl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L263 +L264: +| movl dstnumL,d3 +L267: + subql #1,d3 + jmi L295 + movl a0@,d0 + notl d0 + andl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L267 +L268: +| movl dstnumL,d3 +L271: + subql #1,d3 + jmi L295 + movl a0@,d0 + notl d0 + orl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L271 +L272: +| movl dstnumL,d3 +L275: + subql #1,d3 + jmi L295 + movl a0@,d0 + notl d0 + eorl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L275 +L279: +| movl dstnumL,d3 +L282: + subql #1,d3 + jmi L295 + movl a0@,a1@ + subqw #4,a0 + subqw #4,a1 + jra L282 +L283: +| movl dstnumL,d3 +L286: + subql #1,d3 + jmi L295 + movl a0@,d0 + andl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L286 +L287: +| movl dstnumL,d3 +L290: + subql #1,d3 + jmi L295 + movl a0@,d0 + orl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L290 +L291: +| movl dstnumL,d3 +L294: + subql #1,d3 + jmi L295 + movl a0@,d0 + eorl d0,a1@ + subqw #4,a0 + subqw #4,a1 + jra L294 +L278: + movl op,d0 + movl dstnumL,d3 | from loop headers above +| moveq #3,d7 +| cmpl d7,d0 +| jhi L295 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000035: + .word L279-L2000035 + .word L283-L2000035 + .word L287-L2000035 + .word L291-L2000035 + jra L295 +L256: + tstl src_comp + jeq L317 + movw a6@(-18),d1 | from loops after dispatch, below, srcLshift + movl dstnumL,d3 | from loop headers + movl op,d0 +| moveq #3,d7 +| cmpl d7,d0 +| jhi L295 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000037: + .word L299-L2000037 + .word L303-L2000037 + .word L307-L2000037 + .word L311-L2000037 +L299: +| movl dstnumL,d3 +L302: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + notl d7 + lsrl d4,d0 + movl d0,d6 + movl d7,a1@ + subqw #4,a1 + jra L302 +L303: +| movl dstnumL,d3 +L306: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + notl d7 + lsrl d4,d0 + movl d0,d6 + andl d7,a1@ + subqw #4,a1 + jra L306 +L307: +| movl dstnumL,d3 +L310: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + notl d7 + lsrl d4,d0 + movl d0,d6 + orl d7,a1@ + subqw #4,a1 + jra L310 +L311: +| movl dstnumL,d3 +L314: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + notl d7 + lsrl d4,d0 + movl d0,d6 + eorl d7,a1@ + subqw #4,a1 + jra L314 +L318: +| movl dstnumL,d3 +L321: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + lsrl d4,d0 + movl d0,d6 + movl d7,a1@ + subqw #4,a1 + jra L321 +L322: +| movl dstnumL,d3 +L325: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + lsrl d4,d0 + movl d0,d6 + andl d7,a1@ + subqw #4,a1 + jra L325 +L326: +| movl dstnumL,d3 +L329: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + lsrl d4,d0 + movl d0,d6 + orl d7,a1@ + subqw #4,a1 + jra L329 +L330: +| movl dstnumL,d3 +L333: + subql #1,d3 + jmi L295 + movl a0@,d0 + subqw #4,a0 + movl d0,d7 +| movw a6@(-18),d1 + lsll d1,d7 + orl d6,d7 + lsrl d4,d0 + movl d0,d6 + eorl d7,a1@ + subqw #4,a1 + jra L333 +L317: + movl op,d0 + movw a6@(-18),d1 | from loops after dispatch (above), srcLshift + movl dstnumL,d3 | from loop headers +| moveq #3,d7 +| cmpl d7,d0 +| jhi L295 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000039: + .word L318-L2000039 + .word L322-L2000039 + .word L326-L2000039 + .word L330-L2000039 +L295: + tstl dst32lbit + jeq L148 + movl src32lbit,d0 + cmpl dst32lbit,d0 + jlt L335 + movl a0@,d0 + movw a6@(-18),d1 | srcLshift + lsll d1,d0 +LY00011: + orl d6,d0 + movl d0,d7 + jra L336 +L335: + movl d6,d7 +L336: + tstl src_comp + jeq L337 + notl d7 +L337: + movl postloop_mask,mask +L122: + movl a1@,d5 | d5 = dstdata thru here.... + movl mask,d1 | d1 = dstold thru here. + notl d1 + andl d5,d1 +| movl d1,dstold + movl op,d0 +| moveq #3,d5 +| cmpl d5,d0 +| jhi L338 + movw pc@(6,d0:l:2),d0 + jmp pc@(2,d0:w) +L2000041: + .word L340-L2000041 + .word L341-L2000041 + .word L342-L2000041 + .word L343-L2000041 +L340: + movl d7,d5 + jra L338 +L341: + andl d7,d5 + jra L338 +L342: + orl d7,d5 + jra L338 +L343: + eorl d7,d5 +L338: + movl mask,d0 + andl d0,d5 +| movl dstold,d5 | transcription error??, replaced with: + orl d1, d5 + movl d5,a1@ +L148: + tstl gray + jeq L344 + tstl bb_fast + jeq L345 +| movl dstbpl,d0 +| asrl #3,d0 +| addl d0,OrigDstAddr + addl dstbpl3,OrigDstAddr + movl OrigDstAddr,a1 + jra L346 +L345: + movl OrigDstAddr,a1 | d2 = dst32lbit starts here + movl dst32lbit,d2 +| movl dstbpl,d0 +| addl d0,dst32lbit + addl dstbpl,d2 +| movl dst32lbit,d0 + movl d2,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + addl d0,a1 + moveq #31,d7 +| andl d7,dst32lbit + andl d7,d2 +| movl dst32lbit,d0 + movl d2,d0 + addl width,d0 + subql #1,d0 + andl d7,d0 + movl d0,dst32rbit + movl a1,OrigDstAddr +| tstl dst32lbit + tstl d2 + jeq L2000042 + moveq #32,d0 +| subl dst32lbit,d0 + subl d2,d0 + moveq #-1,d1 + lsll d0,d1 + notl d1 + jra L2000043 +L2000042: + moveq #-1,d1 +L2000043: + movl d1,preloop_mask + moveq #31,d0 + subl dst32rbit,d0 + moveq #-1,d1 + asll d0,d1 + movl d1,postloop_mask + movl preloop_mask,d0 + andl d1,d0 + movl d0,sdw_mask +| movl dst32lbit,d0 + movl d2,d0 + addl width,d0 + asrl #5,d0 + subql #1,d0 + movl d2,dst32lbit | d2 = dst32lbit ends here + movl d0,dstnumL + #################################### + # Bottom of the texture-blt loop # + # +L346: + addql #1,curr_gray_line + movl curr_gray_line,d0 + cmpl num_gray,d0 + jlt L347 + clrl curr_gray_line +| movl num_gray,d0 +| subql #1,d0 +| asll #1,d0 +| subl d0,a5 + subl gray_line_length,a5 + jra LY00009 +L347: + addqw #2,a5 + jra LY00009 +L344: + tstl backwardflg + jne L349 + tstl bb_fast + jeq L350 +| movl dstbpl,d0 +| asrl #3,d0 +| addl d0,OrigDstAddr + addl dstbpl3,OrigDstAddr + movl OrigDstAddr,a1 + jra L351 +L350: + movl OrigDstAddr,a1 | d2 = dst32lbit starts here + movl dst32lbit,d2 +| movl dstbpl,d0 + addl dstbpl,d2 +| addl d0,dst32lbit +| movl dst32lbit,d0 + movl d2,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + addl d0,a1 + moveq #31,d7 +| andl d7,dst32lbit +| movl dst32lbit,d0 + andl d7,d2 + movl d2,d0 + addl width,d0 + subql #1,d0 + andl d7,d0 + movl d0,dst32rbit + movl a1,OrigDstAddr +| tstl dst32lbit + tstl d2 + jeq L2000044 + moveq #32,d0 +| subl dst32lbit,d0 + subl d2,d0 + moveq #-1,d1 + asll d0,d1 + notl d1 + jra L2000045 +L2000044: + moveq #-1,d1 +L2000045: + movl d1,preloop_mask + moveq #31,d0 + subl dst32rbit,d0 + moveq #-1,d1 + asll d0,d1 + movl d1,postloop_mask + movl preloop_mask,d0 + andl d1,d0 + movl d0,sdw_mask +| movl dst32lbit,d0 + movl d2,d0 + addl width,d0 + asrl #5,d0 + subql #1,d0 + movl d0,dstnumL + movl d2,dst32lbit | end of d2 = dst32lbit +L351: + tstl bb_fast + jne LY00007 + movl OrigSrcAddr,a0 + movl src32lbit,d2 | d2 = src32lbit starts here +| movl srcbpl,d0 +| addl d0,src32lbit +| movl src32lbit,d0 + addl srcbpl,d2 + movl d2,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + addl d0,a0 + moveq #31,d7 +| andl d7,src32lbit + andl d7,d2 +| movl src32lbit,d0 + movl d2,d0 + addl width,d0 + subql #1,d0 + andl d7,d0 + movl d0,src32rbit + movl a0,OrigSrcAddr + movl dst32lbit,d4 +| subl src32lbit,d4 + subl d2,d4 + andl d7,d4 +| movl src32lbit,d0 + movl d2,d1 + subl dst32lbit,d1 + andl d7,d1 + movl d1,srcLshift + jeq L2000046 + moveq #-1,d0 +| movw a6@(-18),d1 | srcLshift + asll d1,d0 + notl d0 + jra L2000047 +L2000046: + moveq #-1,d0 +L2000047: + movl d0,srcRmask + movl d2,src32lbit | end of d2 = src32lbit + jra LY00009 +L349: + tstl bb_fast + jeq L354 +| movl dstbpl,d0 +| asrl #3,d0 +| addl d0,OrigDstAddr + addl dstbpl3,OrigDstAddr + movl OrigDstAddr,a1 + jra L355 +L354: + movl OrigDstAddr,a1 + movl dstbpl,d0 + addl d0,dst32rbit + jpl L356 + moveq #31,d0 + subl dst32rbit,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + subl d0,a1 + jra L357 +L356: + movl dst32lbit,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + addl d0,a1 +L357: + moveq #31,d7 + andl d7,dst32rbit + movl dst32rbit,d0 + subl width,d0 + addql #1,d0 + andl d7,d0 + movl d0,dst32lbit + movl a1,OrigDstAddr + moveq #31,d0 + subl dst32rbit,d0 + moveq #-1,d1 + asll d0,d1 + movl d1,preloop_mask + moveq #-1,d1 + tstl dst32lbit + jeq JDS1 + moveq #32,d0 + subl dst32lbit,d0 + asll d0,d1 + notl d1 +JDS1: movl d1,postloop_mask + movl preloop_mask,d0 + andl d1,d0 + movl d0,sdw_mask + movl width,d0 + subl dst32rbit,d0 + subql #1,d0 + tstl d0 + jle L2000048 + movl width,d0 + subl dst32rbit,d0 + subql #1,d0 + asrl #5,d0 + jra L2000049 +L2000048: + moveq #0,d0 +L2000049: + movl d0,dstnumL +L355: + tstl bb_fast + jeq L358 +LY00007: + movl srcbpl,d0 + asrl #3,d0 + addl d0,OrigSrcAddr + movl OrigSrcAddr,a0 + jra LY00009 +L358: + movl OrigSrcAddr,a0 + movl srcbpl,d0 + addl d0,src32rbit + jpl L360 + moveq #31,d0 + subl src32rbit,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + subl d0,a0 + jra L361 +L360: + movl src32rbit,d0 + asrl #5,d0 +| movl d0,temp + asll #2,d0 +| movl d0,temp + addl d0,a0 +L361: + moveq #31,d7 + andl d7,src32rbit +LY00016: + movl src32rbit,d0 + subl width,d0 + addql #1,d0 + moveq #31,d7 + andl d7,d0 + movl d0,src32lbit + movl dst32lbit,d4 + subl d0,d4 + andl d7,d4 + subl dst32lbit,d0 + andl d7,d0 + movl d0,srcLshift + jne LY00006 + moveq #0,d1 +L2000051: + movl d1,srcRmask + movl a0,OrigSrcAddr +LY00009: + movl num_lines_remaining,d0 + subql #1,num_lines_remaining + tstl d0 + jgt LY00010 + moveq #0,d0 +|#PROLOGUE# 2 + moveml a6@(-128),#0x3cfc + unlk a6 +|#PROLOGUE# 3 + rts diff --git a/src/bbtSPARC.s b/src/bbtSPARC.s new file mode 100755 index 0000000..32bf96f --- /dev/null +++ b/src/bbtSPARC.s @@ -0,0 +1,1941 @@ +! @(#) bbtSPARC.s Version 1.2 (4/22/92). copyright Venue & Fuji Xerox # +! +!************************************************************************/ +!* */ +!* (C) Copyright 1989-92 Venue. All Rights Reserved. */ +!* Manufactured in the United States of America. */ +!* */ +!* The contents of this file are proprietary information */ +!* belonging to Venue, and are provided to you under license. */ +!* They may not be further distributed or disclosed to third */ +!* parties without the specific permission of Venue. */ +!* */ +!************************************************************************/ +! Argument stack offsets, for rational naming. +! +#define srcbase [%fp+68] +#define dstbase [%fp+72] +#define sx [%fp+76] +#define dx [%fp+80] +#define w [%fp+84] +#define height [%fp+88] +#define srcbpl [%fp+92] +#define dstbpl [%fp+96] +#define backwardflg [%fp+100] +#define src_comp [%fp+104] +#define op [%fp+108] +#define gray [%fp+112] +#define num_gray [%fp+116] +#define curr_gray_line [%fp+120] +! +! +! +#define num_lines_remaining [%fp-4] +#define fwd [%fp-8] +#define bb_fast [%fp-12] +#define temp +#define dstnumL +#define src32lbit +#define srcLshift +#define dst32lbit +#define srcRmask +#define dstold +#define dstdata +#define mask +#define x32byta +#define x32nbyt +#define x32ia +#define abc +#define dst32rbit +#define src32rbit [%fp-32] +#define OrigSrcAddr [%fp-36] +#define OrigDstAddr [%fp-20] +#define preloop_mask +#define postloop_mask +#define sdw_mask [%fp-24] +#define dst32addr [%fp-16] +#define src32addr [%fp-28] +#define shS +#define savedS +#define newS +#define srcRshift +! +! Computed intermediate values +! +! srcbpl_rshift_3 saved value of (srcbpl>>3) +! dstbpl_rshift_3 saved value of (dstbpl>>3) +! num_gray_1 saved value of (num_gray-1) +! ffff saved value of 0xFFFF +#define srcbpl_rshift_3 [%fp-52] +#define num_gray_1 [%fp-48] +#define dstbpl_rshift_3 [%fp-56] +#define ffff [%fp-44] +! +! Register Usage +! +! %i0 (arg srcbase) +! %i1 srcLshift (arg dstbase) +! %i2 srcRshift (arg sx) +! %i3 dx, newS (arg dx) +! %i4 (arg width) +! %i5 bb_fast (arg height) +! %i6 +! %i7 +! +! %o0 +! %o1 +! %o2 +! %o3 +! %04 +! %o5 +! %o6 +! %o7 +! +! %g0 [always zero] +! %g1 +! %g2 +! %g3 +! %g4 +! %g5 +! %g6 +! %g7 +! +! %l0 srcRmask +! %l1 op (left shifted 2 by JDS as of 11/7/89) +! %l2 postloop_mask +! %l3 preloop_mask +! %l4 dst32rbit +! %l5 src32lbit +! %l6 dst32lbit +! %l7 +! +! Definitions for register assignments, to make code clear. +! All are of the form R, to indicate the R +! version of the variable, in case there is also a storage place +! for it. +! +#define RsrcRmask %l0 +#define Rop %l1 +#define Rpostloop_mask %l2 +#define Rpreloop_mask %l3 +#define Rdst32rbit %l4 +#define Rsrc32lbit %l5 +#define Rdst32lbit %l6 +#define RsrcRshift %i2 +! + .seg "text" ! [internal] + .proc 4 + .global _bitblt +_bitblt: +!#PROLOGUE# 0 +!#PROLOGUE# 1 + save %sp,-120,%sp + ld backwardflg,%o0 + st %i5,num_lines_remaining + tst %o0 + st %i4,w + bne L77003 + st %i0,srcbase + mov 1,%o1 + b L77004 + st %o1,fwd +L77003: + st %g0,fwd +L77004: + ld dstbpl,%o3 + ld srcbpl,%o2 + or %o2,%o3,%o2 + andcc %o2,31,%g0 + bne,a L77007 + mov 0,%i5 ! bb_fast = %i5 + mov 1,%i5 +L77007: + ld gray,%o5 + st %i5,bb_fast + tst %o5 ! are we doing the gray case? + be,a LY53 ! no => LY53 + ld fwd,%o5 + tst %i3 ! dx + bge,a LY52 + sra %i3,3,%o4 + mov 7,%o7 + sub %o7,%i3,%o7 + sra %o7,3,%o7 + b LY12 + sub %i1,%o7,%i1 +LY52: ! [internal] + add %i1,%o4,%i1 +LY12: ! [internal] + and %i1,3,Rdst32lbit + sub %i1,Rdst32lbit,%i1 + st %i1,dst32addr + ld w,%i1 + ld dst32addr,%o2 + sll Rdst32lbit,3,Rdst32lbit + and %i3,7,%i3 + add Rdst32lbit,%i3,Rdst32lbit !dst32lbit + add Rdst32lbit,%i1,%i1 + sub %i1,1,Rdst32rbit + tst Rdst32lbit + st %o2,OrigDstAddr ! OrigDstAddr? + be L77013 + and Rdst32rbit,31,Rdst32rbit ! dst32rbit + mov 32,%o3 + sub %o3,Rdst32lbit,%o3 + mov -1,%i3 + sll %i3,%o3,%i3 + b L77014 + xor %i3,-1,%i3 ! preloop_mask +L77013: + mov -1,%i3 +L77014: + ld dstbpl,%o3 + mov 31,%o2 + sub %o2,Rdst32rbit,%o2 + mov -1,Rpostloop_mask + sll Rpostloop_mask,%o2,Rpostloop_mask ! postloop_mask + mov %i3,Rpreloop_mask + and Rpreloop_mask,Rpostloop_mask,%o0 + andcc %o3,31,%g0 + sra %i1,5,%l7 + st %o0,sdw_mask ! sdw_mask? + bne L77016 + dec %l7 ! dstnumL seems to be in %l7. + b L77017 + mov 1,%i3 +L77016: + mov 0,%i3 ! bb_fast +L77017: + st %i3,bb_fast + b L77396 + and %i2,15,Rsrc32lbit !srclbit +! +! Loop-advance, for either the forward or backward case +! +LY53: ! [internal] + tst %o5 ! going forward? + be,a LY51 ! No. => LY51 + ld w,%o3 + tst %i3 + bge,a LY50 + sra %i3,3,%o4 + mov 7,%o7 + sub %o7,%i3,%o7 + sra %o7,3,%o7 + b LY13 + sub %i1,%o7,%i1 +LY50: ! [internal] + add %i1,%o4,%i1 +LY13: ! [internal] + and %i1,3,Rdst32lbit + sub %i1,Rdst32lbit,%i1 + st %i1,dst32addr + ld w,%i1 + ld dst32addr,%o2 + sll Rdst32lbit,3,Rdst32lbit + and %i3,7,%i3 + add Rdst32lbit,%i3,Rdst32lbit + add Rdst32lbit,%i1,%i1 + sub %i1,1,Rdst32rbit + tst Rdst32lbit + st %o2,OrigDstAddr + be L77024 + and Rdst32rbit,31,Rdst32rbit + mov 32,%o3 + sub %o3,Rdst32lbit,%o3 + mov -1,%i3 + sll %i3,%o3,%i3 + b L77025 + xor %i3,-1,%i3 +L77024: + mov -1,%i3 +L77025: + mov 31,%o2 + sub %o2,Rdst32rbit,%o2 + mov -1,Rpostloop_mask + sll Rpostloop_mask,%o2,Rpostloop_mask + mov %i3,Rpreloop_mask + and Rpreloop_mask,Rpostloop_mask,%o0 + tst %i2 + sra %i1,5,%l7 + st %o0,sdw_mask + bge L77027 + dec %l7 + ld srcbase,%i3 + mov 7,%o3 + sub %o3,%i2,%o3 + sra %o3,3,%o3 + b LY14 + sub %i3,%o3,%i3 +L77027: + ld srcbase,%i3 + sra %i2,3,%o2 + add %i3,%o2,%i3 +LY14: ! [internal] + ld w,%o4 + and %i3,3,Rsrc32lbit + sub %i3,Rsrc32lbit,%i3 + sll Rsrc32lbit,3,Rsrc32lbit + and %i2,7,%i2 + add Rsrc32lbit,%i2,Rsrc32lbit + add Rsrc32lbit,%o4,%o4 + sub Rsrc32lbit,Rdst32lbit,%i1 + and %i1,31,%i1 + dec %o4 + and %o4,31,%o4 + tst %i1 + sub Rdst32lbit,Rsrc32lbit,RsrcRshift + st %i3,src32addr + st %o4,src32rbit + be L77030 + and RsrcRshift,31,RsrcRshift + mov -1,%i3 + sll %i3,%i1,%i3 + b L77031 + xor %i3,-1,%i3 +L77030: + mov -1,%i3 +L77031: + ld src32addr,%o2 + mov %i3,RsrcRmask + b L77396 + st %o2,OrigSrcAddr +! +! +! Loop advance for the blt-backward case. +! +LY51: ! [internal] + add %i3,%o3,%i3 + deccc %i3 + bpos,a LY49 + sra %i3,3,%o4 + mov 7,%o7 + sub %o7,%i3,%o7 + sra %o7,3,%o7 + b LY15 + sub %i1,%o7,%i1 +LY49: ! [internal] + add %i1,%o4,%i1 +LY15: ! [internal] + and %i1,3,Rdst32rbit + sub %i1,Rdst32rbit,%i1 + sll Rdst32rbit,3,Rdst32rbit + and %i3,7,%i3 + add Rdst32rbit,%i3,Rdst32rbit + sub Rdst32rbit,%o3,Rdst32lbit + inc Rdst32lbit + and Rdst32lbit,31,Rdst32lbit + tst Rdst32lbit ! replaced by andCC + st %i1,OrigDstAddr + mov -1,Rpostloop_mask + be Ldstl0 + st %i1,dst32addr + mov 32,%o1 + sub %o1,Rdst32lbit,%o1 + sll Rpostloop_mask,%o1,Rpostloop_mask + xor Rpostloop_mask,-1,Rpostloop_mask +Ldstl0: ld w,%o1 + mov 31,%o3 + sub %o3,Rdst32rbit,%o3 + sub %o1,Rdst32rbit,%i3 + mov -1,Rpreloop_mask + sll Rpreloop_mask,%o3,Rpreloop_mask + dec %i3 + tst %i3 + and Rpreloop_mask,Rpostloop_mask,%o0 + ble L77037 + st %o0,sdw_mask + b L77038 + sra %i3,5,%i3 +L77037: + mov 0,%i3 +L77038: + mov %i3,%l7 + add %i2,%o1,%i3 + deccc %i3 + bpos LY48 + ld srcbase,%i1 + mov 7,%o1 + sub %o1,%i3,%o1 + sra %o1,3,%o1 + b LY16 + sub %i1,%o1,%i1 +LY48: ! [internal] + sra %i3,3,%o0 + add %i1,%o0,%i1 +LY16: ! [internal] + ld w,Rsrc32lbit + and %i1,3,%i2 + sub %i1,%i2,%i1 + sll %i2,3,%i2 + and %i3,7,%i3 + add %i2,%i3,%i2 !src32rbit + st %i2,src32rbit ! moved from below for clarity + sub %i2,Rsrc32lbit,Rsrc32lbit + inc Rsrc32lbit + and Rsrc32lbit,31,Rsrc32lbit + st %i1,src32addr + sub Rsrc32lbit,Rdst32lbit,%i1 + and %i1,31,%i1 +! st %i2,src32rbit + sub Rdst32lbit,Rsrc32lbit,RsrcRshift + tst %i1 + be L77043 + and RsrcRshift,31,RsrcRshift + mov -1,%i3 + sll %i3,%i1,%i3 + b L77044 + xor %i3,-1,%i3 +L77043: + mov 0,%i3 +L77044: + ld src32addr,%o1 + mov %i3,RsrcRmask ! srcRmask + st %o1,OrigSrcAddr +L77396: + ld srcbpl,%o3 + ld num_lines_remaining,%i5 + ld num_gray,%o0 + ld dstbpl,%o5 + ld op,Rop + sll Rop,2,Rop ! op << 2, for jump dispatch + sra %o3,3,%o3 + st %o3,srcbpl_rshift_3 ! srcbpl >> 3, for later use. + ld num_lines_remaining,%o3 + dec %o0 + sethi %hi(0xffff),%o2 + or %o2,%lo(0xffff),%o2 ! [internal] + sll %o0,1,%o0 + dec %o3 + sra %o5,3,%o5 + tst %i5 + st %o2,ffff + st %o0,num_gray_1 + st %o3,num_lines_remaining + ble LY1 + st %o5,dstbpl_rshift_3 +LY8: ! [internal] + ld gray,%o4 + tst %o4 + be,a LY47 + ld fwd,%o3 + ld srcbase,%i5 + ld ffff,%o0 + lduh [%i5],%i5 + sub Rsrc32lbit,Rdst32lbit,%i1 + sll %i5,16,%o3 + or %i5,%o3,%i5 + ld src_comp,%o3 + and %i1,15,%i1 + sll %i5,%i1,%i5 + srl %i5,16,%o7 + and %o7,%o0,%o7 + tst %o3 + be L77051 + or %i5,%o7,%i5 + xor %i5,-1,%i5 +L77051: + ld w,%o5 + add Rdst32lbit,%o5,%o5 + cmp %o5,32 + bg,a LY46 + ld dst32addr,%i4 + b L77305 + ld sdw_mask,%i0 +LY46: ! [internal] +! cmp Rop,3 + ld [%i4],%i4 +! sll Rop,2,%o0 +! bgu L77060 + andn %i4,Rpreloop_mask,%i0 + sethi %hi(L2000000),%o1 + or %o1,%lo(L2000000),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + b L77060 +L2000000: + .word L77054 + .word L77055 + .word L77056 + .word L77057 +L77054: + mov %i5,%i4 +L77055: + and %i4,%i5,%i4 +L77056: + or %i4,%i5,%i4 +L77057: + xor %i4,%i5,%i4 +L77060: + ld dst32addr,%o7 ! o7 = dst32addr down to ~ LY45 + and %i4,Rpreloop_mask,%i4 + or %i4,%i0,%i4 + st %i4,[%o7] +! ld dst32addr,%o7 +! cmp Rop,3 + inc 4,%o7 +! sll Rop,2,%o0 +! bgu L77079 +! st %o7,dst32addr + sethi %hi(L2000001),%o1 + or %o1,%lo(L2000001),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i4 +L2000001: + .word L77061 + .word L77065 + .word L77069 + .word L77073 +L77061: +! mov %l7,%i4 +L77062: + deccc %i4 + bneg,a LY45 + cmp Rdst32rbit,31 +! ld dst32addr,%o0 + st %i5,[%o7] +! ld dst32addr,%o1 +! inc 4,%o1 + b L77062 + inc 4,%o7 +! st %o1,dst32addr +L77065: +! mov %l7,%i4 +L77066: + deccc %i4 + bneg,a LY45 + cmp Rdst32rbit,31 + ld [%o7],%o3 + and %o3,%i5,%o3 + st %o3,[%o7] +! ld dst32addr,%o7 +! inc 4,%o7 + b L77066 + inc 4,%o7 +! st %o7,dst32addr +L77069: +! mov %l7,%i4 +L77070: + deccc %i4 + bneg,a LY45 + cmp Rdst32rbit,31 +! ld dst32addr,%o0 + ld [%o7],%o1 + or %o1,%i5,%o1 + st %o1,[%o7] +! ld dst32addr,%o4 +! inc 4,%o4 + b L77070 + inc 4,%o7 +! st %o4,dst32addr +L77073: +! sub %l7,1,%i4 +! tst %i4 + deccc %i4 + bl,a LY45 + cmp Rdst32rbit,31 +!LY9: ! [internal] +! ld dst32addr,%o5 +LY9a: deccc %i4 + ld [%o7],%o1 + xor %o1,%i5,%o1 + st %o1,[%o7] +! ld dst32addr,%o2 +! inc 4,%o2 + bpos LY9a + inc 4,%o7 +! st %o5,dst32addr +L77079: + cmp Rdst32rbit,31 +LY45: ! [internal] +! be,a LY31 + be LY31 + st %o7,dst32addr ! end of dst32addr in o7 + ld gray,%o2 + b L77305 + mov Rpostloop_mask,%i0 +LY47: ! [internal] + tst %o3 !fwd + be,a LY44 + ld src32rbit,%o7 + cmp Rsrc32lbit,Rdst32lbit + ble,a LY43 + cmp Rsrc32lbit,Rdst32lbit + ld w,%o4 + add Rsrc32lbit,%o4,%o4 + cmp %o4,32 + ble,a LY43 + cmp Rsrc32lbit,Rdst32lbit + ld src32addr,%o1 + ld [%o1],%i3 + inc 4,%o1 +! st %o1,src32addr + ld [%o1],%o3 + sll %i3,%i1,%i3 + srl %o3,RsrcRshift,%i5 + and %i5,RsrcRmask,%i5 + or %i3,%i5,%i5 + sll %o3,%i1,%i3 + inc 4,%o1 + andn %i3,RsrcRmask,%i3 + b LY19 + st %o1,src32addr +LY43: ! [internal] + bg LY42 + ld src32addr,%o7 + ld [%o7],%i3 + inc 4,%o7 + srl %i3,RsrcRshift,%i5 + sll %i3,%i1,%i3 + st %o7,src32addr + and %i5,RsrcRmask,%i5 + b LY19 + andn %i3,RsrcRmask,%i3 +LY42: ! [internal] + ld [%o7],%i5 + inc 4,%o7 + st %o7,src32addr + sll %i5,%i1,%i5 +LY19: ! [internal] + ld src_comp,%o1 + tst %o1 + be,a LY41 + ld w,%o3 + xor %i5,-1,%i5 + ld w,%o3 +LY41: ! [internal] + add Rdst32lbit,%o3,%o3 + cmp %o3,32 + bg,a LY40 + ld dst32addr,%i4 + b L77305 + ld sdw_mask,%i0 +LY40: ! [internal] +! cmp Rop,3 + ld [%i4],%i4 +! sll Rop,2,%o0 +! bgu L77101 + andn %i4,Rpreloop_mask,%i0 + sethi %hi(L2000002),%o1 + or %o1,%lo(L2000002),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + b L77101 +L2000002: + .word L77095 + .word L77096 + .word L77097 + .word L77098 +L77095: +! b L77101 + mov %i5,%i4 +L77096: +! b L77101 + and %i4,%i5,%i4 +L77097: +! b L77101 + or %i4,%i5,%i4 +L77098: + xor %i4,%i5,%i4 +L77101: + ld dst32addr,%o4 ! o4 = dst32addr + and %i4,Rpreloop_mask,%i4 + or %i4,%i0,%i4 + st %i4,[%o4] +! ld dst32addr,%o4 + cmp Rsrc32lbit,Rdst32lbit + inc 4,%o4 + bne L77144 + st %o4,dst32addr + ld src_comp,%o5 + tst %o5 + bne LY39 +! cmp Rop,3 +! bgu L77186 +! sll Rop,2,%o0 + ld src32addr,%o5 ! o5 = src32addr + sethi %hi(L2000004),%o1 + or %o1,%lo(L2000004),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i5 +L2000004: + .word L77124 + .word L77128 + .word L77132 + .word L77136 +L77104: +! mov %l7,%i5 +L77105: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o7 +! ld dst32addr,%o4 + ld [%o5],%o7 + xor %o7,-1,%o7 + st %o7,[%o4] +! ld src32addr,%o3 +! ld dst32addr,%o4 + inc 4,%o4 +! inc 4,%o5 +! st %o3,src32addr + b L77105 + inc 4,%o5 +! st %o4,dst32addr +L77108: +! mov %l7,%i5 +L77109: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o5 +! ld dst32addr,%o0 + ld [%o5],%o7 + ld [%o4],%o1 + andn %o1,%o7,%o1 + st %o1,[%o4] +! ld src32addr,%o4 +! ld dst32addr,%o5 + inc 4,%o4 +! inc 4,%o5 +! st %o4,src32addr + b L77109 + inc 4,%o5 +! st %o5,dst32addr +L77112: +! mov %l7,%i5 +L77113: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o7 +! ld dst32addr,%o1 + ld [%o5],%o7 + ld [%o4],%o2 + orn %o2,%o7,%o2 + st %o2,[%o4] +! ld src32addr,%o5 +! ld dst32addr,%o7 + inc 4,%o5 +! inc 4,%o4 +! st %o5,src32addr + b L77113 + inc 4,%o4 +! st %o7,dst32addr +L77116: +! mov %l7,%i5 +L77117: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o0 +! ld dst32addr,%o2 + ld [%o5],%o0 + ld [%o4],%o3 + xnor %o3,%o0,%o3 + st %o3,[%o4] +! ld src32addr,%o7 +! ld dst32addr,%o0 + inc 4,%o5 +! inc 4,%o4 +! st %o7,src32addr + b L77117 + inc 4,%o4 +! st %o0,dst32addr +LY39: ! [internal] o4 = dst32addr getting here +! bgu L77186 +! sll Rop,2,%o0 +! ld src32addr,%o5 ! o5 = src32addr when getting to LY39 + sethi %hi(L2000003),%o1 + or %o1,%lo(L2000003),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i5 +L2000003: + .word L77104 + .word L77108 + .word L77112 + .word L77116 +L77124: +! mov %l7,%i5 +L77125: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o2 +! ld dst32addr,%o1 + ld [%o5],%o2 + st %o2,[%o4] +! ld src32addr,%o4 +! ld dst32addr,%o5 + inc 4,%o4 +! inc 4,%o5 +! st %o4,src32addr + b L77125 + inc 4,%o5 +! st %o5,dst32addr +L77128: +! mov %l7,%i5 +L77129: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o7 +! ld dst32addr,%o1 + ld [%o5],%o7 + ld [%o4],%o2 + and %o2,%o7,%o2 + st %o2,[%o4] +! ld src32addr,%o5 +! ld dst32addr,%o7 + inc 4,%o5 +! inc 4,%o4 +! st %o5,src32addr + b L77129 + inc 4,%o4 +! st %o7,dst32addr +L77132: +! mov %l7,%i5 +L77133: + deccc %i5 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o0 +! ld dst32addr,%o2 + ld [%o5],%o0 + ld [%o4],%o3 + or %o3,%o0,%o3 + st %o3,[%o4] +! ld src32addr,%o7 +! ld dst32addr,%o0 + inc 4,%o4 +! inc 4,%o5 +! st %o7,src32addr + b L77133 + inc 4,%o5 +! st %o0,dst32addr +L77136: +! sub %l7,1,%i5 +! tst %i5 + deccc %i5 + bl,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +LY10: ! [internal] +! ld src32addr,%o1 +! ld dst32addr,%o3 + ld [%o5],%o1 + ld [%o4],%o2 + deccc %i5 + xor %o2,%o1,%o2 + st %o2,[%o4] +! ld src32addr,%o0 +! ld dst32addr,%o1 + inc 4,%o4 +! inc 4,%o5 +! st %o0,src32addr + bpos LY10 + inc 4,%o5 +! st %o1,dst32addr +L77186: +! cmp Rdst32rbit,31 + st %o4,dst32addr +LY37: ! [internal] + st %o5,src32addr + cmp Rdst32rbit,31 + be,a LY31 + ld gray,%o2 + ld src32rbit,%o5 + cmp %o5,Rdst32rbit + bg,a L77190 + mov %i3,%i5 + ld src32addr,%i5 + ld [%i5],%i5 + srl %i5,RsrcRshift,%i5 + and %i5,RsrcRmask,%i5 + b L77190 + or %i3,%i5,%i5 +L77144: ! o4 = dst32addr when getting here. + ld src_comp,%o2 + tst %o2 + bne LY38 +! cmp Rop,3 +! bgu L77186 +! sll Rop,2,%o0 + ld src32addr,%o5 ! o5 = src322addr + sethi %hi(L2000006),%o1 + or %o1,%lo(L2000006),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i4 +L2000006: + .word L77166 + .word L77170 + .word L77174 + .word L77178 +L77146: +! mov %l7,%i4 +L77147: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o5 +! ld dst32addr,%o3 + ld [%o5],%o1 + inc 4,%o5 + srl %o1,RsrcRshift,%o7 + or %i3,%o7,%o7 + xor %o7,-1,%o7 +! st %o5,src32addr + st %o7,[%o4] + sll %o1,%i1,%i3 +! ld dst32addr,%o4 +! inc 4,%o4 + b L77147 + inc 4,%o4 +! st %o4,dst32addr +L77150: +! mov %l7,%i4 +L77151: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o0 +! ld dst32addr,%o5 + ld [%o5],%o7 + inc 4,%o5 + srl %o7,RsrcRshift,%o1 + or %i3,%o1,%o1 + sll %o7,%i1,%i3 +! st %o0,src32addr + ld [%o4],%o7 + xor %o1,-1,%o1 + and %o7,%o1,%o7 + st %o7,[%o4] +! ld dst32addr,%o2 +! inc 4,%o2 + b L77151 + inc 4,%o4 +! st %o2,dst32addr +L77154: +! mov %l7,%i4 +L77155: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o5 +! ld dst32addr,%o3 + ld [%o5],%o1 + inc 4,%o5 + srl %o1,RsrcRshift,%o7 + or %i3,%o7,%o7 + sll %o1,%i1,%i3 +! st %o5,src32addr + ld [%o4],%o1 + xor %o7,-1,%o7 + or %o1,%o7,%o1 + st %o1,[%o4] +! ld dst32addr,%o0 +! inc 4,%o4 + b L77155 + inc 4,%o4 +! st %o0,dst32addr +L77158: +! mov %l7,%i4 +L77159: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o3 +! ld dst32addr,%o1 + ld [%o5],%o2 + inc 4,%o5 + srl %o2,RsrcRshift,%o1 + or %i3,%o1,%o1 + sll %o2,%i1,%i3 +! st %o3,src32addr + ld [%o4],%o2 + xor %o1,-1,%o1 + xor %o2,%o1,%o2 + st %o2,[%o4] +! ld dst32addr,%o5 +! inc 4,%o4 + b L77159 + inc 4,%o4 +! st %o5,dst32addr +LY38: ! [internal] +! bgu L77186 +! sll Rop,2,%o0 + ld src32addr,%o5 + sethi %hi(L2000005),%o1 + or %o1,%lo(L2000005),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i4 +L2000005: + .word L77146 + .word L77150 + .word L77154 + .word L77158 +! b LY37 +! st %o4,dst32addr +! cmp Rdst32rbit,31 +L77166: +! mov %l7,%i4 +L77167: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o1 +! ld dst32addr,%o5 + ld [%o5],%o0 + inc 4,%o5 + srl %o0,RsrcRshift,%o2 + or %i3,%o2,%o2 +! st %o1,src32addr + st %o2,[%o4] +! ld dst32addr,%o7 + sll %o0,%i1,%i3 +! inc 4,%o4 + b L77167 + inc 4,%o4 +! st %o7,dst32addr +L77170: +! mov %l7,%i4 +L77171: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o2 +! ld dst32addr,%o7 + ld [%o5],%o1 + inc 4,%o5 + srl %o1,RsrcRshift,%o3 + or %i3,%o3,%o3 +! st %o2,src32addr + ld [%o4],%o0 + sll %o1,%i1,%i3 + and %o0,%o3,%o0 + st %o0,[%o4] +! ld dst32addr,%o3 +! inc 4,%o4 + b L77171 + inc 4,%o4 +! st %o3,dst32addr +L77174: +! mov %l7,%i4 +L77175: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o7 +! ld dst32addr,%o3 + ld [%o5],%o7 + inc 4,%o5 + srl %o7,RsrcRshift,%o0 + or %i3,%o0,%o0 +! st %o7,src32addr + ld [%o4],%o1 + sll %o7,%i1,%i3 + or %o1,%o0,%o1 + st %o1,[%o4] +! ld dst32addr,%o0 +! inc 4,%o4 + b L77175 + inc 4,%o4 +! st %o0,dst32addr +L77178: +! mov %l7,%i4 +L77179: + deccc %i4 + bneg,a LY37 + st %o4,dst32addr +! cmp Rdst32rbit,31 +! ld src32addr,%o3 +! ld dst32addr,%o0 + ld [%o5],%o2 + inc 4,%o5 + srl %o2,RsrcRshift,%o3 + or %i3,%o3,%o3 +! st %o3,src32addr + ld [%o4],%o1 + sll %o2,%i1,%i3 + xor %o1,%o3,%o1 + st %o1,[%o4] +! ld dst32addr,%o4 +! inc 4,%o4 + b L77179 + inc 4,%o4 +! st %o4,dst32addr +L77190: + ld src_comp,%o4 + b LY17 + tst %o4 +LY44: ! [internal] + cmp %o7,Rdst32rbit + bge,a LY36 + cmp %o7,Rdst32rbit + ld w,%o1 + add Rdst32lbit,1,%o0 + add Rsrc32lbit,%o1,%o1 + cmp %o1,%o0 + ble,a LY36 + cmp %o7,Rdst32rbit + ld src32addr,%o3 + ld [%o3],%i3 + dec 4,%o3 + st %o3,src32addr + ld [%o3],%o2 + srl %i3,RsrcRshift,%i3 + and %i3,RsrcRmask,%i3 + sll %o2,%i1,%i5 + or %i3,%i5,%i5 + srl %o2,RsrcRshift,%i3 + dec 4,%o3 + and %i3,RsrcRmask,%i3 + b LY21 + st %o3,src32addr +LY36: ! [internal] + bl,a LY35 + ld src32addr,%o3 + ld src32addr,%o4 + ld [%o4],%i3 + dec 4,%o4 + sll %i3,%i1,%i5 + srl %i3,RsrcRshift,%i3 + st %o4,src32addr + b LY21 + and %i3,RsrcRmask,%i3 +LY35: ! [internal] + ld [%o3],%i5 + dec 4,%o3 + srl %i5,RsrcRshift,%i5 + and %i5,RsrcRmask,%i5 + st %o3,src32addr +LY21: ! [internal] + ld src_comp,%o7 + tst %o7 + be,a LY34 + ld w,%o1 + xor %i5,-1,%i5 + ld w,%o1 +LY34: ! [internal] + add Rdst32lbit,%o1,%o1 + cmp %o1,32 + bg,a LY33 + ld dst32addr,%i4 + b L77305 + ld sdw_mask,%i0 +LY33: ! [internal] +! cmp Rop,3 + ld [%i4],%i4 +! sll Rop,2,%o0 +! bgu L77212 + andn %i4,Rpreloop_mask,%i0 + sethi %hi(L2000007),%o1 + or %o1,%lo(L2000007),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + b L77212 +L2000007: + .word L77206 + .word L77207 + .word L77208 + .word L77209 +L77206: +! b L77212 + mov %i5,%i4 +L77207: +! b L77212 + and %i4,%i5,%i4 +L77208: +! b L77212 + or %i4,%i5,%i4 +L77209: + xor %i4,%i5,%i4 +L77212: + ld dst32addr,%o4 ! o4 = dst32addr + ld src32addr,%o5 ! o5 = src32addr + and %i4,Rpreloop_mask,%i4 + or %i4,%i0,%i4 + st %i4,[%o4] +! ld dst32addr,%o4 + cmp Rsrc32lbit,Rdst32lbit + dec 4,%o4 + bne L77255 + st %o4,dst32addr + ld src_comp,%o3 + tst %o3 + bne LY32 +! cmp Rop,3 +! bgu L77297 +! sll Rop,2,%o0 + sethi %hi(L2000009),%o1 + or %o1,%lo(L2000009),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i5 +L2000009: + .word L77235 + .word L77239 + .word L77243 + .word L77247 +L77215: +! mov %l7,%i5 +L77216: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o4 +! ld dst32addr,%o0 + ld [%o5],%o1 + xor %o1,-1,%o1 + st %o1,[%o4] +! ld src32addr,%o1 +! ld dst32addr,%o2 + dec 4,%o5 +! st %o1,src32addr + b L77216 + dec 4,%o4 +! st %o2,dst32addr +L77219: +! mov %l7,%i5 +L77220: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o3 +! ld dst32addr,%o5 + ld [%o5],%o3 + ld [%o4],%o7 + andn %o7,%o3,%o7 + st %o7,[%o4] +! ld src32addr,%o2 +! ld dst32addr,%o3 + dec 4,%o4 +! st %o2,src32addr + b L77220 + dec 4,%o5 +! st %o3,dst32addr +L77223: +! mov %l7,%i5 +L77224: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o4 +! ld dst32addr,%o7 + ld [%o5],%o1 + ld [%o4],%o0 + orn %o0,%o1,%o0 + st %o0,[%o4] +! ld src32addr,%o3 +! ld dst32addr,%o4 + dec 4,%o5 +! st %o3,src32addr + b L77224 + dec 4,%o4 +! st %o4,dst32addr +L77227: +! mov %l7,%i5 +L77228: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o5 +! ld dst32addr,%o0 + ld [%o5],%o0 + ld [%o4],%o1 + xnor %o1,%o0,%o1 + st %o1,[%o4] +! ld src32addr,%o4 +! ld dst32addr,%o5 + dec 4,%o4 +! st %o4,src32addr + b L77228 + dec 4,%o5 +! st %o5,dst32addr +LY32: ! [internal] +! bgu L77297 +! sll Rop,2,%o0 + ld dst32addr,%o4 + ld src32addr,%o5 + sethi %hi(L2000008),%o1 + or %o1,%lo(L2000008),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i5 +L2000008: + .word L77215 + .word L77219 + .word L77223 + .word L77227 +L77235: +! mov %l7,%i5 +L77236: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o0 +! ld dst32addr,%o7 + ld [%o5],%o0 + st %o0,[%o4] +! ld src32addr,%o2 +! ld dst32addr,%o3 + dec 4,%o4 +! dec 4,%o5 +! st %o2,src32addr + b L77236 + dec 4,%o5 +! st %o3,dst32addr +L77239: +! mov %l7,%i5 +L77240: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o4 +! ld dst32addr,%o7 + ld [%o5],%o2 + ld [%o4],%o0 + and %o0,%o2,%o0 + st %o0,[%o4] +! ld src32addr,%o3 +! ld dst32addr,%o4 + dec 4,%o5 +! dec 4,%o4 +! st %o3,src32addr + b L77240 + dec 4,%o4 +! st %o4,dst32addr +L77243: +! mov %l7,%i5 +L77244: + deccc %i5 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o5 +! ld dst32addr,%o0 + ld [%o5],%o2 + ld [%o4],%o1 + or %o1,%o2,%o1 + st %o1,[%o4] +! ld src32addr,%o4 +! ld dst32addr,%o5 + dec 4,%o4 +! dec 4,%o5 +! st %o4,src32addr + b L77244 + dec 4,%o5 +! st %o5,dst32addr +L77247: +! sub %l7,1,%i5 +! tst %i5 + deccc %i5 + bl,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +LY11: ! [internal] +! ld src32addr,%o7 +! ld dst32addr,%o1 + ld [%o5],%o7 + ld [%o4],%o2 + deccc %i5 + xor %o2,%o7,%o2 + st %o2,[%o4] +! ld src32addr,%o5 +! ld dst32addr,%o7 + dec 4,%o5 +! dec 4,%o4 +! st %o5,src32addr + bpos LY11 + dec 4,%o4 +! st %o7,dst32addr +!L77297: +! tst Rdst32lbit + st %o4,dst32addr +LY29: ! [internal] + st %o5,src32addr + tst Rdst32lbit + be,a LY31 + ld gray,%o2 + cmp Rsrc32lbit,Rdst32lbit + bl,a L77301 + mov %i3,%i5 + ld src32addr,%i5 + ld [%i5],%i5 + sll %i5,%i1,%i5 + b L77301 + or %i3,%i5,%i5 +L77255: + ld src_comp,%o0 + tst %o0 + bne LY30 +! cmp Rop,3 +! bgu L77297 +! sll Rop,2,%o0 + ld dst32addr,%o4 + ld src32addr,%o5 + sethi %hi(L2000011),%o1 + or %o1,%lo(L2000011),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i4 +L2000011: + .word L77277 + .word L77281 + .word L77285 + .word L77289 +L77257: +! mov %l7,%i4 +L77258: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o3 +! ld dst32addr,%o1 + ld [%o5],%o2 + dec 4,%o5 + sll %o2,%i1,%o3 + or %i3,%o3,%o3 + xor %o3,-1,%o3 +! st %o3,src32addr + st %o3,[%o1] + srl %o2,RsrcRshift,%i3 +! ld dst32addr,%o2 + b L77258 + dec 4,%o4 +! st %o2,dst32addr +L77261: +! mov %l7,%i4 +L77262: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o5 +! ld dst32addr,%o3 + ld [%o5],%o3 + dec 4,%o5 + sll %o4,%i1,%o7 + or %i3,%o7,%o7 + srl %o3,RsrcRshift,%i3 +! st %o5,src32addr + ld [%o4],%o3 + xor %o7,-1,%o7 + and %o3,%o7,%o3 + st %o3,[%o4] +! ld dst32addr,%o0 + b L77262 + dec 4,%o4 +! st %o0,dst32addr +L77265: +! mov %l7,%i4 +L77266: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o3 +! ld dst32addr,%o1 + ld [%o5],%o2 + dec 4,%o5 + sll %o2,%i1,%o3 + or %i3,%o4,%o3 + srl %o2,RsrcRshift,%i3 +! st %o3,src32addr + ld [%o4],%o2 + xor %o3,-1,%o3 + or %o2,%o3,%o2 + st %o2,[%o4] +! ld dst32addr,%o5 + b L77266 + dec 4,%o4 +! st %o5,dst32addr +L77269: +! mov %l7,%i4 +L77270: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o1 +! ld dst32addr,%o7 + ld [%o5],%o0 + dec 4,%o5 + sll %o0,%i1,%o2 + or %i3,%o2,%o2 + srl %o0,RsrcRshift,%i3 +! st %o1,src32addr + ld [%o4],%o0 + xor %o2,-1,%o2 + xor %o0,%o2,%o0 + st %o0,[%o4] +! ld dst32addr,%o3 + b L77270 + dec 4,%o4 +! st %o3,dst32addr +LY30: ! [internal] +! bgu L77297 +! sll Rop,2,%o0 + ld dst32addr,%o4 + ld src32addr,%o5 + sethi %hi(L2000010),%o1 + or %o1,%lo(L2000010),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + mov %l7,%i4 +L2000010: + .word L77257 + .word L77261 + .word L77265 + .word L77269 +! b LY29 +! tst Rdst32lbit +L77277: +! mov %l7,%i4 +L77278: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o7 +! ld dst32addr,%o3 + ld [%o5],%o7 + dec 4,%o5 + sll %o7,%i1,%o0 + or %i3,%o0,%o0 +! st %o7,src32addr + st %o0,[%o4] +! ld dst32addr,%o4 + srl %o7,RsrcRshift,%i3 + b L77278 + dec 4,%o4 +! st %o4,dst32addr +L77281: +! mov %l7,%i4 +L77282: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o0 +! ld dst32addr,%o4 + ld [%o5],%o7 + dec 4,%o5 + sll %o7,%i1,%o1 + or %i3,%o1,%o1 + !st %o0,src32addr + ld [%o4],%o2 + srl %o7,RsrcRshift,%i3 + and %o2,%o1,%o2 + st %o2,[%o4] +! ld dst32addr,%o1 + b L77282 + dec 4,%o4 +! st %o1,dst32addr +L77285: +! mov %l7,%i4 +L77286: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o4 +! ld dst32addr,%o1 + ld [%o5],%o3 + dec 4,%o5 + sll %o3,%i1,%o1 + or %i3,%o1,%o1 +! st %o4,src32addr + ld [%o4],%o2 + srl %o3,RsrcRshift,%i3 + or %o2,%o1,%o2 + st %o2,[%o4] +! ld dst32addr,%o1 + b L77286 + dec 4,%o4 +! st %o5,dst32addr +L77289: +! mov %l7,%i4 +L77290: + deccc %i4 + bneg,a LY29 + st %o4,dst32addr +! tst Rdst32lbit +! ld src32addr,%o1 +! ld dst32addr,%o5 + ld [%o5],%o0 + dec 4,%o5 + sll %o0,%i1,%o2 + or %i3,%o2,%o2 +! st %o1,src32addr + ld [%o4],%o7 + srl %o0,RsrcRshift,%i3 + xor %o7,%o2,%o7 + st %o7,[%o4] +! ld dst32addr,%o2 + b L77290 + dec 4,%o4 +! st %o2,dst32addr +L77301: + ld src_comp,%o0 + tst %o0 +LY17: ! [internal] + be,a L77305 + mov Rpostloop_mask,%i0 + xor %i5,-1,%i5 + mov Rpostloop_mask,%i0 +L77305: + ld dst32addr,%i4 +! cmp Rop,3 + ld [%i4],%i4 +! sll Rop,2,%o0 + andn %i4,%i0,%o4 +! bgu L77312 +! st %o4,[%fp-40] + sethi %hi(L2000012),%o1 + or %o1,%lo(L2000012),%o1 ! [internal] + ld [Rop+%o1],%o0 + jmp %o0 +! nop + b L77312 +L2000012: + .word L77306 + .word L77307 + .word L77308 + .word L77309 +L77306: +! b L77312 + mov %i5,%i4 +L77307: +! b L77312 + and %i4,%i5,%i4 +L77308: +! b L77312 + or %i4,%i5,%i4 +L77309: + xor %i4,%i5,%i4 +L77312: +! ld [%fp-40],%o7 + ld dst32addr,%o1 + and %i4,%i0,%i4 +! or %i4,%o7,%i4 + or %i4,%o4,%i4 + st %i4,[%o1] + ld gray,%o2 +LY31: ! [internal] + tst %o2 + be,a LY28 + ld fwd,%o7 + ld bb_fast,%o3 + tst %o3 + be,a LY27 + ld dstbpl,%o2 + ld dstbpl_rshift_3,%o5 + ld OrigDstAddr,%o4 + add %o4,%o5,%o4 + st %o4,dst32addr + b L77320 + st %o4,OrigDstAddr +LY27: ! [internal] + ld OrigDstAddr,%o1 + ld w,%l7 + add Rdst32lbit,%o2,Rdst32lbit + sra Rdst32lbit,5,%o7 + and Rdst32lbit,31,Rdst32lbit + sll %o7,2,%o7 + add %o1,%o7,%o7 + add Rdst32lbit,%l7,%l7 + sub %l7,1,Rdst32rbit + tst Rdst32lbit + st %o1,dst32addr + st %o7,OrigDstAddr + and Rdst32rbit,31,Rdst32rbit + be L77318 + st %o7,dst32addr + mov 32,%o0 + sub %o0,Rdst32lbit,%o0 + mov -1,%i5 + sll %i5,%o0,%i5 + b L77319 + xor %i5,-1,%i5 +L77318: + mov -1,%i5 +L77319: + mov 31,%o7 + sub %o7,Rdst32rbit,%o7 + mov -1,Rpostloop_mask + sll Rpostloop_mask,%o7,Rpostloop_mask + mov %i5,Rpreloop_mask + and Rpreloop_mask,Rpostloop_mask,%o4 + sra %l7,5,%l7 + dec %l7 + st %o4,sdw_mask +L77320: + ld curr_gray_line,%o0 + ld num_gray,%o2 + inc %o0 + cmp %o0,%o2 + bl L77322 + st %o0,curr_gray_line + ld srcbase,%o4 + ld num_gray_1,%o3 + st %g0,curr_gray_line + sub %o4,%o3,%o4 + b L77047 + st %o4,srcbase +L77322: + ld srcbase,%o5 + inc 2,%o5 + b L77047 + st %o5,srcbase +LY28: ! [internal] + tst %o7 + be,a LY26 + ld bb_fast,%o2 + ld bb_fast,%o0 + tst %o0 + be,a LY25 + ld dstbpl,%o7 + ld dstbpl_rshift_3,%o2 + ld OrigDstAddr,%o1 + add %o1,%o2,%o1 + st %o1,dst32addr + b L77331 + st %o1,OrigDstAddr +LY25: ! [internal] + ld OrigDstAddr,%o5 + ld w,%l7 + add Rdst32lbit,%o7,Rdst32lbit + sra Rdst32lbit,5,%o3 + and Rdst32lbit,31,Rdst32lbit + sll %o3,2,%o3 + add %o5,%o3,%o3 + add Rdst32lbit,%l7,%l7 + sub %l7,1,Rdst32rbit + tst Rdst32lbit + st %o5,dst32addr + st %o3,OrigDstAddr + and Rdst32rbit,31,Rdst32rbit + be L77329 + st %o3,dst32addr + mov 32,%o4 + sub %o4,Rdst32lbit,%o4 + mov -1,%i5 + sll %i5,%o4,%i5 + b L77330 + xor %i5,-1,%i5 +L77329: + mov -1,%i5 +L77330: + mov 31,%o3 + sub %o3,Rdst32rbit,%o3 + mov -1,Rpostloop_mask + sll Rpostloop_mask,%o3,Rpostloop_mask + mov %i5,Rpreloop_mask + and Rpreloop_mask,Rpostloop_mask,%o1 + sra %l7,5,%l7 + dec %l7 + st %o1,sdw_mask +L77331: + tst %o0 + be,a LY24 + ld srcbpl,%o3 + ld srcbpl_rshift_3,%o7 + ld OrigSrcAddr,%o5 + add %o5,%o7,%o5 + st %o5,src32addr + b L77047 + st %o5,OrigSrcAddr +LY24: ! [internal] + ld OrigSrcAddr,%o2 + add Rsrc32lbit,%o3,Rsrc32lbit + ld w,%o3 + sra Rsrc32lbit,5,%o0 + and Rsrc32lbit,31,Rsrc32lbit + add Rsrc32lbit,%o3,%o3 + sub Rsrc32lbit,Rdst32lbit,%i1 + sll %o0,2,%o0 + add %o2,%o0,%o0 + and %i1,31,%i1 + dec %o3 + and %o3,31,%o3 + tst %i1 + sub Rdst32lbit,Rsrc32lbit,RsrcRshift + st %o2,src32addr + st %o0,OrigSrcAddr + st %o3,src32rbit + and RsrcRshift,31,RsrcRshift + be L77335 + st %o0,src32addr + mov -1,%i5 + sll %i5,%i1,%i5 + b L77336 + xor %i5,-1,%i5 +L77335: + mov -1,%i5 +L77336: + b L77047 + mov %i5,RsrcRmask +LY26: ! [internal] + tst %o2 + be,a LY23 + ld dstbpl,%i5 + ld dstbpl_rshift_3,%o4 + ld OrigDstAddr,%o3 + add %o3,%o4,%o3 + st %o3,dst32addr + b L77347 + st %o3,OrigDstAddr +LY23: ! [internal] + ld OrigDstAddr,%o0 + add Rdst32rbit,%i5,%i5 + tst %i5 + bge L77342 + st %o0,dst32addr + mov 31,%l7 + sub %l7,%i5,%l7 + sra %l7,5,%l7 + sll %l7,2,%l7 + sub %o0,%l7,%o0 + b L77343 + st %o0,dst32addr +L77342: + sra Rdst32lbit,5,Rdst32lbit + sll Rdst32lbit,2,Rdst32lbit + add %o0,Rdst32lbit,Rdst32lbit + st Rdst32lbit,dst32addr +L77343: + ld w,Rdst32lbit + ld dst32addr,%o4 + and %i5,31,Rdst32rbit + ld w,%i5 + sub Rdst32rbit,Rdst32lbit,Rdst32lbit + inc Rdst32lbit +! and Rdst32lbit,31,Rdst32lbit + andcc Rdst32lbit,31,Rdst32lbit + be Ldst0b + mov -1,Rpostloop_mask + mov 32,%o3 + sub %o3,Rdst32lbit,%o3 + mov 31,%o5 + sub %o5,Rdst32rbit,%o5 + sll Rpostloop_mask,%o3,Rpostloop_mask + xor Rpostloop_mask,-1,Rpostloop_mask ! from below +Ldst0b: sub %i5,Rdst32rbit,%i5 + mov -1,Rpreloop_mask + sll Rpreloop_mask,%o5,Rpreloop_mask + dec %i5 +! xor Rpostloop_mask,-1,Rpostloop_mask + and Rpreloop_mask,Rpostloop_mask,%o2 + tst %i5 + st %o4,OrigDstAddr + ble L77345 + st %o2,sdw_mask + b L77346 + sra %i5,5,%i5 +L77345: + mov 0,%i5 +L77346: + mov %i5,%l7 +L77347: + ld bb_fast,%o0 + tst %o0 + be,a LY22 + ld srcbpl,%i1 + ld srcbpl_rshift_3,%o2 + ld OrigSrcAddr,%o1 + add %o1,%o2,%o1 + st %o1,src32addr + b L77047 + st %o1,OrigSrcAddr +LY22: ! [internal] + ld src32rbit,%o7 ! src32rbit loaded + ld OrigSrcAddr,%o5 + add %o7,%i1,%i1 + tst %i1 + bge L77351 + st %o5,src32addr + mov 31,%i2 + sub %i2,%i1,%i2 + sra %i2,5,%i2 + sll %i2,2,%i2 + sub %o5,%i2,%o5 + b L77352 + st %o5,src32addr +L77351: + sra %i1,5,%o3 + sll %o3,2,%o3 + add %o5,%o3,%o3 + st %o3,src32addr +L77352: + ld w,Rsrc32lbit + and %i1,31,%i1 + sub %i1,Rsrc32lbit,Rsrc32lbit + inc Rsrc32lbit + and Rsrc32lbit,31,Rsrc32lbit + st %i1,src32rbit + sub Rsrc32lbit,Rdst32lbit,%i1 + and %i1,31,%i1 + tst %i1 + sub Rdst32lbit,Rsrc32lbit,RsrcRshift + be L77354 + and RsrcRshift,31,RsrcRshift + mov -1,%i5 + sll %i5,%i1,%i5 + b L77355 + xor %i5,-1,%i5 +L77354: + mov 0,%i5 +L77355: + ld src32addr,%o5 + mov %i5,RsrcRmask + st %o5,OrigSrcAddr +L77047: + ld num_lines_remaining,%i5 + ld num_lines_remaining,%o3 + tst %i5 + dec %o3 + bg LY8 + st %o3,num_lines_remaining +LY1: ! [internal] + ret + restore %g0,0,%o0 + .seg "data" ! [internal] diff --git a/src/bbtsub.c b/src/bbtsub.c new file mode 100755 index 0000000..6d27ac9 --- /dev/null +++ b/src/bbtsub.c @@ -0,0 +1,2428 @@ +/* $Id: bbtsub.c,v 1.3 2001/12/24 01:08:59 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: bbtsub.c,v 1.3 2001/12/24 01:08:59 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* File: bbtsub.c */ +/* */ +/* Subroutines to support BITBLT, \BLTCHAR, and \TEDIT.BLTCHAR */ +/* lisp functions, providing performance improvement. */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include + +#ifdef XWINDOW +#ifndef DOS +#include +#endif /* DOS */ +#include +#include +#include +#include "xdefs.h" +#endif /* XWINDOW */ + +/* from pixrect's rect.h: */ +#ifdef LINUX +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#endif /* LINUX */ + +#ifndef XWINDOW +#ifndef NOPIXRECT +#ifndef DOS +#include +#include +#endif /* DOS */ +#endif /* NOPIXRECT */ + +#endif /* XWINDOW */ + +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "adr68k.h" +#include "address.h" +#include "arith.h" +#include "stack.h" +#include "cell.h" +#include "gc.h" +#include "iopage.h" +extern IOPAGE *IOPage68K; + +#ifdef AIX +#include +#ifndef LINUX /* LINUX has no macros.h */ +#include +#endif /* LINUX */ +#endif /* AIX */ + + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" +#include "dspdata.h" +#include "display.h" +#include "dbprint.h" + +#if (defined(DOS) || defined(XWINDOW)) +#include "devif.h" +extern DspInterface currentdsp; +#endif /* DOS || WXINDOW */ + +#ifdef COLOR +extern int MonoOrColor; +#endif /* COLOR */ + + + /*******************************************/ + /* REALCURSOR is defined iff we need to */ + /* take care of cursor movement & hiding */ + /* (during bitblts to screen) ourselves. */ + /*******************************************/ +#if defined(SUNDISPLAY) || defined(DOS) +#define REALCURSOR +#else +#undef REALCURSOR +#endif + +/* same definition is in my.h */ +#ifdef BIGVM +#define IsNumber(address) ((GETWORD(MDStypetbl +(((address) & 0x0fffff00)>>9))) & 0x1000) +#else +#define IsNumber(address) ((GETWORD(MDStypetbl +(((address) & 0x0ffff00)>>9))) & 0x1000) +#endif + +#define BITSPERWORD (16) /* temp definition */ + + + /***** Don't use PixRect code on 386i for now *****/ + /***** -or on any machine that doesn't support it (HP, e.g.) *****/ + + /********************************************************/ + /* */ + /* prropstyle is DEFINED when we want to use */ + /* pixrect versions of the operations in this */ + /* file, and UNDEFINED, when we want to use */ + /* Don Charnley's bitblt code to do them. */ + /* */ + /********************************************************/ + +#if ( !(defined(NOPIXRECT)) && !(defined(NEWBITBLT)) && !(defined(I386)) ) +#define prropstyle 1 +#endif /* NOPIXRECT */ + + +extern int LispWindowFd; +extern int ScreenLocked; /* for mouse tracking */ +/***************************************************************** +(PUTPROPS \SETPBTFUNCTION MACRO + (OPENLAMBDA (BBT SourceType Operation) + (PROGN (replace (PILOTBBT PBTOPERATION) of BBT with + (SELECTQ Operation + (ERASE 1) + (PAINT 2) + (INVERT 3) + 0)) + (replace (PILOTBBT PBTSOURCETYPE) of BBT with + (COND ((EQ (EQ SourceType (QUOTE INVERT)) + (EQ Operation (QUOTE ERASE))) 0) + (T 1)))))) +*****************************************************************/ +#define PixOperationLisp( SRCTYPE, OPERATION ) \ + ( SRCTYPE == INVERT_atom ? \ + (OPERATION == REPLACE_atom ? PIX_NOT(PIX_SRC) : \ + (OPERATION == PAINT_atom ? PIX_NOT(PIX_SRC) | PIX_DST : \ + (OPERATION == ERASE_atom ? PIX_SRC & PIX_DST : \ + (OPERATION == INVERT_atom ? PIX_NOT(PIX_SRC) ^ PIX_DST : ERROR)))) : \ + /* SRCTYPE == INPUT, TEXTURE */ \ + (OPERATION == REPLACE_atom ? PIX_SRC : \ + (OPERATION == PAINT_atom ? PIX_SRC | PIX_DST : \ + (OPERATION == ERASE_atom ? PIX_NOT(PIX_SRC) & PIX_DST : \ + (OPERATION == INVERT_atom ? PIX_SRC ^ PIX_DST : ERROR))))) + +#define bbop( SRCTYPE, OPERATION ) \ + (OPERATION == PAINT_atom ? op_fn_or : \ + (OPERATION == ERASE_atom ? op_fn_and : \ + (OPERATION == INVERT_atom ? op_fn_xor : op_repl_src))) + + + /********************************************************/ + /* */ + /* b b s r c _ t y p e */ + /* */ + /* Returns 1 if the source bits must be inverted */ + /* as part of the BITBLT. This is true if the */ + /* OPERATION argument to BITBLT is 'ERASE, or */ + /* if the SOURCETYPE argument is 'INVERT. */ + /* */ + /********************************************************/ + +#define bbsrc_type( SRCTYPE, OPERATION ) \ + ( SRCTYPE == INVERT_atom ? \ + (OPERATION == ERASE_atom ? 0 : 1 ) \ + /* SRCTYPE == INPUT, TEXTURE */ \ + : (OPERATION == ERASE_atom ? 1 : 0)) + +#define init_kbd_startup \ + if (!kbd_for_makeinit){ \ + init_keyboard(0); \ + kbd_for_makeinit = 1; \ + }; + + + +extern struct pixrect *SrcePixRect, *DestPixRect, *TexturePixRect; +extern struct pixrect *BlackTexturePixRect, *WhiteTexturePixRect; +extern DLword TEXTURE_atom; +extern DLword MERGE_atom; +extern DLword INPUT_atom; +extern DLword INVERT_atom; +extern DLword ERASE_atom; +extern DLword PAINT_atom; +extern DLword REPLACE_atom; + +extern int kbd_for_makeinit; /*** FOR INIT ***/ + + +/************************************************************************/ +/* */ +/* b i t b l t s u b */ +/* */ +/* Implements the lisp function \BITBLTSUB, which is where */ +/* all BITBLT & BLTSHADE calls bottom out. This is distinct */ +/* from the PILOTBITBLT opcode, which is implemented in bitblt.c. */ +/* */ +/* */ +/* args[0] : PILOTBBT */ +/* args[1] : SOURCEBITMAP */ +/* args[2] : SLX (SourceLeftX) sx */ +/* args[3] : STY (SourceTopY) sty */ +/* args[4] : DESTINATIONBITMAP */ +/* args[5] : DLX (DestinationLeftX) dx */ +/* args[6] : DTY (DestinationTopY) dty */ +/* args[7] : HEIGHT */ +/* args[8] : SourceType */ +/* args[9] : Operation */ +/* args[10] : Texture */ +/* args[11] : WindowXOffset */ +/* args[12] : WindowYOffset */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR +bitbltsub( LispPTR *argv ) + { + int sourcetype, operation; + int sty, dty, texture, wxoffset, wyoffset; + int h, w; + int displayflg = 0, desthi; + int backwardflg = 0, sx, dx, srcbpl, dstbpl, src_comp, op; + register DLword *srcbase, *dstbase; + int gray = 0, num_gray = 0, curr_gray_line = 0; + DLword grayword[4]; + + { /* Initialization code, in a block so it optimizes independently */ + register LispPTR *args = argv; + register PILOTBBT *pbt; + register BITMAP *srcebm, *destbm; + BITMAP *texture68k; + register DLword *base; + +#ifdef INIT + init_kbd_startup; +#endif + + pbt = (PILOTBBT *)Addr68k_from_LADDR( args[0] ); + srcebm = (BITMAP *)Addr68k_from_LADDR( args[1] ); + sx = (args[2] & 0xFFFF); + sty = (args[3] & 0xFFFF); + destbm = (BITMAP *)Addr68k_from_LADDR( args[4] ); + dx = (args[5] & 0xFFFF); + dty = (args[6] & 0xFFFF); + sourcetype = ( args[8] == NIL_PTR ? INPUT_atom : args[8] ); + operation = ( args[9] == NIL_PTR ? REPLACE_atom : args[9] ); + + w = pbt->pbtwidth; + h = pbt->pbtheight; + if ((h <= 0) || (w <= 0)) return(0); + src_comp = bbsrc_type(sourcetype, operation); + op = bbop(sourcetype, operation); + + dstbpl = destbm->bmrasterwidth << 4; + + if( sourcetype == TEXTURE_atom ) + { + texture = args[10]; + wxoffset = ( args[11] == NIL_PTR ? 0 : args[11] & 0xFFFF ); + wyoffset = ( args[12] == NIL_PTR ? 0 : args[12] & 0xFFFF ); + sx = ((wxoffset) ? (dx - wxoffset) : dx) % BITSPERWORD; + dstbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( destbm->bmbase, + destbm->bmrasterwidth * dty)); + gray = 1; + if (texture == NIL_PTR) + { /* White Shade */ + grayword[0] = 0; + srcbase = &grayword[0]; + num_gray = 1; + curr_gray_line = 0; + goto do_it_now; + } + else if(IsNumber(texture)) + { + if( (texture &= 0xffff) == 0) + { /* White Shade */ + grayword[0] = 0; + srcbase = &grayword[0]; + num_gray = 1; + curr_gray_line = 0; + goto do_it_now; + } + else if(texture == 0xffff) + { /* Black Shade */ + grayword[0] = 0xFFFF; + srcbase = &grayword[0]; + num_gray = 1; + curr_gray_line = 0; + goto do_it_now; + } + else + { /* 4x4 */ + srcbase = base = (DLword *)(&grayword[0]); + GETWORD(base++) = Expand4Bit(((texture >> 12) & 0xf)); + GETWORD(base++) = Expand4Bit(((texture >> 8) & 0xf)); + GETWORD(base++) = Expand4Bit(((texture >> 4) & 0xf)); + GETWORD(base++) = Expand4Bit((texture & 0xf)); + num_gray = 4; + curr_gray_line = (dty + wyoffset) & 3; + srcbase += curr_gray_line; + goto do_it_now; + } + } + else + { /* A bitmap that is 16 bits wide. */ + texture68k = (BITMAP *)Addr68k_from_LADDR(texture); + srcbase = (DLword *)Addr68k_from_LADDR(texture68k->bmbase); + num_gray = min( texture68k->bmheight, 16); + curr_gray_line = (dty + wyoffset) % num_gray; + srcbase += curr_gray_line; + goto do_it_now; + } + } + /* ; INPUT or INVERT */ + srcbpl = srcebm->bmrasterwidth << 4; + + /* compute flags */ + /* out for now + if(srcebm == destbm) + if(sty <= dty) + if(dty <= (sty + h)) + if((sty != dty) || ((sx < dx) && (dx < (sx + w)))) + backwardflg = T; + out for now */ + /* compute flags */ + if(srcebm != destbm); + else if(sty > dty); + else if(dty > (sty + h)); + else if((sty != dty) || + ((sx < dx) && (dx < (sx + w)))) + backwardflg = T; + + if (backwardflg) + { + srcbase = ( DLword *) + Addr68k_from_LADDR( ADDBASE( srcebm->bmbase, + srcebm->bmrasterwidth * (sty + h - 1))); + dstbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( destbm->bmbase, + destbm->bmrasterwidth * (dty + h - 1))); + srcbpl = 0 - srcbpl; + dstbpl = 0 - dstbpl; + } + else + { + srcbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( srcebm->bmbase, + srcebm->bmrasterwidth * sty)); + dstbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( destbm->bmbase, + destbm->bmrasterwidth * dty)); + } +#ifdef REALCURSOR + displayflg=n_new_cursorin(srcbase,sx,sty,w,h); +#endif /* REALCURSOR */ + + } + +do_it_now: +#ifdef DOS + currentdsp->device.locked++; +#else + ScreenLocked=T; +#endif /* DOS */ + +#ifdef REALCURSOR + displayflg |= n_new_cursorin(dstbase,dx,dty,w,h); + if( displayflg ) HideCursor; +#endif /* REALCURSOR */ + + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, + backwardflg, src_comp, op, gray, num_gray, curr_gray_line); +#else + new_bitblt_code; +#endif + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + /* Copy the changed section of display bank to the frame buffer */ + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltsub: x %d, y %d, w %d, h %d.\n",dx, dty, w,h)); */ + flush_display_region(dx, dty, w, h); + } +#endif + + +#ifdef XWINDOW + XLOCK; + if (in_display_segment(dstbase)) + flush_display_region(dx, dty, w, h); + XFlush(currentdsp->display_id); + XUNLOCK; +#endif /* XWINDOW */ + +#ifdef DOS + /* Copy the changed section of display bank to the frame buffer */ + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltsub: x %d, y %d, w %d, h %d.\n",dx, dty, w,h)); */ + flush_display_region(dx, dty, w, h); + } +#endif /* DOS */ + +#ifdef REALCURSOR + if( displayflg) ShowCursor; +#endif /* REALCURSOR */ + +#ifdef DOS + currentdsp->device.locked--; +#else + ScreenLocked=NIL; +#endif /* DOS */ + +} /* end of bitbltsub */ + + + + + +/************************************************************************/ +/* */ +/* n _ n e w _ c u r s o r i n */ +/* */ +/* Is the cursor over the spot we're about to change on the */ +/* screen? */ +/* */ +/* This version takes a native address for the bitmap base, */ +/* plus x, y, width, and height for the intended change area. */ +/* Returns T if the cursor overlaps the intended change, NIL */ +/* otherwise. */ +/* */ +/************************************************************************/ + + +#ifndef COLOR + + /********************************************************/ + /* */ + /* Monochrome-only version */ + /* */ + /********************************************************/ + +LispPTR +n_new_cursorin(DLword *baseaddr, int dx, int dy, int w, int h) +{ + extern DLword *DisplayRegion68k; + +#ifdef INIT + init_kbd_startup; /* MUST START KBD FOR INIT BEFORE FIRST BITBLT */ +#endif + + if((DisplayRegion68k <= baseaddr) && (baseaddr <=DISP_MAX_Address)) + { + if((dx < MOUSEXR)&&(dx + w > MOUSEXL) && + (dy < MOUSEYH)&&(dy + h > MOUSEYL) ) return(T); + else return(NIL); + } + else return(NIL); +} +#else + /********************************************************/ + /* */ + /* Mono / color version */ + /* */ + /********************************************************/ +extern DLword *DisplayRegion68k,*ColorDisplayRegion68k; +extern int MonoOrColor; + +LispPTR +n_new_cursorin(DLword *baseaddr, int dx, int dy, int w, int h) +{ +#ifdef INIT + init_kbd_startup; /* MUST START KBD FOR INIT BEFORE FIRST BITBLT */ +#endif + +if(MonoOrColor == MONO_SCREEN){ /* in MONO screen */ + if((DisplayRegion68k <= baseaddr) && (baseaddr <=DISP_MAX_Address)){ + if((dx < MOUSEXR)&&(dx + w > MOUSEXL) && + (dy < MOUSEYH)&&(dy + h > MOUSEYL) ) + { return(T);} + else + { return(NIL);} + } + else + return(NIL); + } /* if for MONO end */ +else {/* in COLOR screen */ + if((ColorDisplayRegion68k <= baseaddr) && (baseaddr <=COLOR_MAX_Address)){ + dx = dx >> 3; + /*printf("new_c in COLOR mx=%d my=%d x=%d y=%d\n" + ,*EmMouseX68K,*EmMouseY68K,dx,dy);*/ + if((dx < MOUSEXR)&&(dx + w > MOUSEXL)&&(dy < MOUSEYH) + &&(dy + h > MOUSEYL)) + { /* printf("new_c T\n");*/ return(T);} + else + { return(NIL);} + } + else + return(NIL); + + + } +} +#endif /* COLOR */ + + + +#define BITBLTBITMAP_argnum 14 +#define PUNT_TO_BITBLTBITMAP {\ + if(BITBLTBITMAP_index==0xffffffff){ \ + BITBLTBITMAP_index=get_package_atom("\\PUNT.BITBLT.BITMAP", \ + 19,"INTERLISP",9, NIL); \ + if(BITBLTBITMAP_index==0xffffffff) \ + {error("BITBLTBITMAP install failed"); \ + return;} } \ + CurrentStackPTR +=(BITBLTBITMAP_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(BITBLTBITMAP_index,BITBLTBITMAP_argnum,3);return;} + + + LispPTR BITBLTBITMAP_index; +/************************************************************************/ +/* */ +/* b i t b l t _ b i t m a p */ +/* */ +/* C implementation of the Lisp function \BITBLT.BITMAP, */ +/* which does bitmap-to-bitmap cases of BITBLT, after BITBLT */ +/* does some setup and massaging first. */ +/* */ +/* args[xx]: SourceBitmap */ +/* args[xx]: SourceLeft Must be a SMALLPOSP */ +/* args[xx]: SourceBottom Must be a SMALLPOSP */ +/* args[xx]: DestBitmap */ +/* args[xx]: DestLeft Must be a SMALLPOSP */ +/* args[xx]: DestBottom Must be a SMALLPOSP */ +/* args[xx]: Width Must be a SMALLPOSP */ +/* args[xx]: height Must be a SMALLPOSP */ +/* args[xx]: SourceType */ +/* args[xx]: Operation */ +/* args[xx]: Texture */ +/* args[xx]: ClippingRegion */ +/* args[xx]: ClippedSrcLeft Must be a SMALLPOSP */ +/* args[xx]: ClippedSrcBottom Must be a SMALLPOSP */ +/* */ +/* */ +/* SourceType must not be MERGE, which should be handled by */ +/* the lisp code in \BITBLT.BITMAP. */ +/* This func. can't handle COLOR & souecetype == MERGE case. */ +/* It causes punting to \\PUNT.BITBLT.BITMAP. */ +/* Therefore SYSOUT must contain \\PUNT.BITBLT.BITMAP. */ +/* */ +/************************************************************************/ + +LispPTR +bitblt_bitmap(LispPTR *args) +{ + BITMAP *SourceBitmap, *DestBitmap; + int sleft, sbottom, dleft, dbottom, width, height, clipleft, clipbottom; + LispPTR clipreg, clipvalue; + int stodx, stody, right, top, destbits, sourcebits, left, bottom; + LispPTR sourcetype, operation, texture; + DLword *srcbase, *dstbase; + int dlx, dty, slx, sty, srcbpl, dstbpl, op, src_comp, backwardflg = 0, + displayflg = 0; + + extern DLword MERGE_atom; + +#ifdef INIT + init_kbd_startup; +#endif + +/* Get arguments and check the possibilities of PUNT */ + SourceBitmap = (BITMAP *) Addr68k_from_LADDR(args[0]); + DestBitmap = (BITMAP *) Addr68k_from_LADDR(args[3]); +/* It does not handle COLOR ..... maybe later */ + if(((destbits = DestBitmap->bmbitperpixel) != 1) || + ((sourcebits = SourceBitmap->bmbitperpixel) != 1)) + { PUNT_TO_BITBLTBITMAP; } + sourcetype = args[8]; + /* sourcetype == MERGE_atom case must be handled in + Lisp func \\BITMAP.BITBLT */ + if( sourcetype == MERGE_atom) + { PUNT_TO_BITBLTBITMAP; } + + N_GETNUMBER(args[1], sleft, bad_arg); + N_GETNUMBER(args[2], sbottom, bad_arg); + N_GETNUMBER(args[4], dleft, bad_arg); + N_GETNUMBER(args[5], dbottom, bad_arg); + operation = args[9]; + texture = args[10]; + clipreg = args[11]; + N_GETNUMBER(args[12], clipleft, bad_arg); + N_GETNUMBER(args[13], clipbottom, bad_arg); + + top = DestBitmap->bmheight; + left = bottom = 0; + right = DestBitmap->bmwidth; + + if (clipreg != NIL_PTR) + { /* clip the BITBLT using the clipping region supplied */ + register LispPTR clipvalue; + register int temp, cr_left, cr_bot; + + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, cr_left, bad_arg); + left = max(left, cr_left); + + clipreg = cdr(clipreg); + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, cr_bot, bad_arg); + bottom = max(bottom, cr_bot); + + clipreg = cdr(clipreg); + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, temp, bad_arg); + right = min(right, cr_left+temp); + + clipreg = cdr(clipreg); + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, temp, bad_arg); + top = min(top, cr_bot+temp); + } + + left = max(left, dleft); + bottom = max(bottom, dbottom); + if (args[6] != NIL_PTR) + { + N_GETNUMBER(args[6], width, bad_arg); + right = min(right, dleft+width); + } + if (args[7] != NIL_PTR) + { + N_GETNUMBER(args[7], height, bad_arg); + top = min(top, dbottom+height); + } + stodx = dleft - sleft; + stody = dbottom - sbottom; + + { + register int temp; + left = max(clipleft, max(0, left - stodx)); + bottom = max(clipbottom, max(0, bottom - stody)); + temp = SourceBitmap->bmwidth; + right = min(temp, min(right-stodx, clipleft+width)); + temp = SourceBitmap->bmheight; + top = min(temp, min(top-stody, clipbottom+height)); + } + + if ( (right <= left) || (top <= bottom) ) return(NIL); + + /*** PUT SOURCETYPE MERGE special code HERE ***/ + /**** See avobe, earler in this code check + souecetype and punting. *****/ + + if (sourcebits == destbits) + { /* not 1-bit-per-pixel, so adjust limits by pixel size */ + switch (sourcebits) + { + case 4: left = left*4; + right = right*4; + stodx = stodx*4; + /* Put color texture merge case here */ + break; + + case 8: left = left*8; + right = right*8; + stodx = stodx*8; + /* Put color texture merge case here */ + break; + + case 24: left = left*24; + right = right*24; + stodx = stodx*24; + /* Put color texture merge case here */ + break; + + } + } + else + { +/* DBPRINT(("BITBLT between bitmaps of different sizes, unimplemented.")); */ + return(NIL); + } + + height = top - bottom; + width = right - left; + dty = DestBitmap->bmheight - (top + stody); + dlx = left + stodx; + sty = SourceBitmap->bmheight - top; + slx = left; + + /*** Stolen from bitbltsub, to avoid the call overhead: ***/ + src_comp = bbsrc_type(sourcetype, operation); + op = bbop(sourcetype, operation); + + dstbpl = DestBitmap->bmrasterwidth << 4; + + + /* Sourcetype guaragneed not to be TEXTURE by BITBLT fn */ + srcbpl = SourceBitmap->bmrasterwidth << 4; + + /* compute flags */ + if(SourceBitmap != DestBitmap); + else if(sty > dty); + else if(dty > (sty + height)); + else if((sty != dty) || ((slx < dlx) && (dlx < (slx + width)))) + backwardflg = T; + + if (backwardflg) + { + srcbase = ( DLword *) + Addr68k_from_LADDR( ADDBASE( SourceBitmap->bmbase, + SourceBitmap->bmrasterwidth * (sty + height - 1))); + dstbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( DestBitmap->bmbase, + DestBitmap->bmrasterwidth * (dty + height - 1))); + srcbpl = 0 - srcbpl; + dstbpl = 0 - dstbpl; + } + else + { + srcbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( SourceBitmap->bmbase, + SourceBitmap->bmrasterwidth * sty)); + dstbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( DestBitmap->bmbase, + DestBitmap->bmrasterwidth * dty)); + } + + displayflg=n_new_cursorin(srcbase,slx,sty,width,height); + +do_it_now: + LOCKSCREEN; + +#ifdef REALCURSOR + displayflg |= n_new_cursorin(dstbase,dlx,dty,width,height); + if( displayflg ) HideCursor; +#endif /* REALCURSOR */ + + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, slx, dlx, width, height, srcbpl, dstbpl, + backwardflg, src_comp, op, 0, 0, 0); +#else +#define gray 0 +#define dx dlx +#define sx slx +#define w width +#define h height +#define curr_gray_line dx +#define num_gray 0 + new_bitblt_code; +#undef gray +#undef dx +#undef sx +#undef w +#undef h +#undef curr_gray_line +#undef num_gray +#endif + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + /* Copy the changed section of display bank to the frame buffer */ + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltsub: x %d, y %d, w %d, h %d.\n",dlx, dty, width,height));*/ + flush_display_region(dlx, dty, width, height); + } +#endif + + + +#ifdef XWINDOW + XLOCK; + if (in_display_segment(dstbase)) + flush_display_region(dlx, dty, width, height); + XFlush(currentdsp->display_id); + XUNLOCK; +#endif /* XWINDOW */ + +#ifdef DOS + /* Copy the changed section of display bank to the frame buffer */ + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltsub: x %d, y %d, w %d, h %d.\n",dx, dty, w,h)); */ + flush_display_region(dlx, dty, width, height); + } +#endif /* DOS */ + +#ifdef REALCURSOR + if( displayflg) ShowCursor; +#endif /* REALCURSOR */ + + UNLOCKSCREEN; + + return(ATOM_T); + + bad_arg: return(NIL); +} /* end of bitblt_bitmap */ + + +#define BLTSHADEBITMAP_argnum 8 +#define PUNT_TO_BLTSHADEBITMAP {\ + if(BLTSHADEBITMAP_index==0xffffffff){ \ + BLTSHADEBITMAP_index=get_package_atom("\\PUNT.BLTSHADE.BITMAP"\ + ,21,"INTERLISP",9, NIL); \ + if(BLTSHADEBITMAP_index==0xffffffff) \ + {error("BLTSHADEBITMAP install failed"); \ + return;} } \ + CurrentStackPTR +=(BLTSHADEBITMAP_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(BLTSHADEBITMAP_index,BLTSHADEBITMAP_argnum,3);return;} + + + LispPTR BLTSHADEBITMAP_index; + +/************************************************************************/ +/* */ +/* b i t s h a d e _ b i t m a p */ +/* */ +/* C implementation of the Lisp function \BITSHADE.BITMAP, */ +/* which does bitmap-to-bitmap cases of BITSHADE, after BITSHADE */ +/* does some setup and massaging first. */ +/* This func. can't handle TEXTURE == LISTP or LITATOM case. */ +/* It causes punting to \\PUNT.BLTSHADE.BITMAP. */ +/* Therefore SYSOUT must contain \\PUNT.BLTSHADE.BITMAP. */ +/* */ +/* args[0]: Texture */ +/* args[1]: DestBitmap */ +/* args[2]: DestLeft Must be a SMALLPOSP */ +/* args[3]: DestBottom Must be a SMALLPOSP */ +/* args[4]: Width Must be a SMALLPOSP */ +/* args[5]: height Must be a SMALLPOSP */ +/* args[6]: Operation */ +/* args[7]: ClippingRegion */ +/* */ +/* The numeric arguments are assumed to be SMALLPOSPs; */ +/* the result with anything else isn't guaranteed correct. */ +/* This Func should punt if TEXTURE==LITATOM(NOT NIL) or LISTP */ +/* or DestBitmap's BPP !=1 */ +/* */ +/* */ +/************************************************************************/ + +LispPTR +bitshade_bitmap(LispPTR *args) +{ + BITMAP *DestBitmap, *texture68k; + int dleft, dbottom, width, height, clipleft, clipbottom; + LispPTR clipreg; + int right, top, destbits, left, bottom, textureword; + LispPTR sourcetype, operation, texture; + DLword *srcbase, *dstbase, *base; + int dlx, dty, slx, sty, dstbpl, op, src_comp, + displayflg = 0; + int rasterwidth; + int num_gray, curr_gray_line; + DLword grayword[4]; + + texture = args[0]; + {register temp; + temp = GetTypeNumber(texture); + if (((temp== TYPE_LITATOM)&&(texture != NIL_PTR))|| + (temp == TYPE_LISTP)) + { PUNT_TO_BLTSHADEBITMAP;} + } + + DestBitmap = (BITMAP *) Addr68k_from_LADDR(args[1]); + if((destbits = DestBitmap->bmbitperpixel) != 1) + { PUNT_TO_BLTSHADEBITMAP;} + + N_GETNUMBER(args[2], dleft, bad_arg); + N_GETNUMBER(args[3], dbottom, bad_arg); + operation = args[6]; + clipreg = args[7]; + + rasterwidth = DestBitmap->bmrasterwidth; + top = DestBitmap->bmheight; + left = bottom = 0; + right = DestBitmap->bmwidth; + if (clipreg != NIL_PTR) + { /* clip the BITBLT using the clipping region supplied */ + register LispPTR clipvalue; + register int temp, cr_left, cr_bot; + + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, cr_left, bad_arg); + left = max(left, cr_left); + + clipreg = cdr(clipreg); + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, cr_bot, bad_arg); + bottom = max(bottom, cr_bot); + + clipreg = cdr(clipreg); + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, temp, bad_arg); + right = min(right, cr_left+temp); + + clipreg = cdr(clipreg); + clipvalue = car(clipreg); + N_GETNUMBER(clipvalue, temp, bad_arg); + top = min(top, cr_bot+temp); + } + + left = max(left, dleft); + bottom = max(bottom, dbottom); + if (args[4] != NIL_PTR) + { + N_GETNUMBER(args[4], width, bad_arg); + right = min(right, dleft+width); + } + if (args[5] != NIL_PTR) + { + N_GETNUMBER(args[5], height, bad_arg); + top = min(top, dbottom+height); + } + + if ( (right <= left) || (top <= bottom) ) return(NIL); + + + + height = top - bottom; + width = right - left; + dty = DestBitmap->bmheight - top; + + if ( (dty < 0) || ((dty+height) > DestBitmap->bmheight)) error("dty bad."); + if ( (bottom < 0) ) error("bottom bad."); + if ((bottom > 2048)) error ("bottom suspicious"); + + + /*** Stolen from bitbltsub, to avoid the call overhead: ***/ + src_comp = bbsrc_type(0, operation); + op = bbop(0, operation); + + dstbpl = rasterwidth << 4; + + if ( (left < 0) || (right > dstbpl) ) error ("left/right bad."); + + slx = left % BITSPERWORD; + + + dstbase = (DLword *) + Addr68k_from_LADDR( ADDBASE( DestBitmap->bmbase, + (rasterwidth * dty))); + + if (GetTypeNumber(texture) == TYPE_LITATOM){ + if(texture == NIL_PTR) + { /* White Shade */ + grayword[0] = 0; + srcbase = &grayword[0]; + num_gray = 1; + curr_gray_line = 0; + goto do_it_now; + } + /* temp DEBUFG stuff */ + else { print(texture); error("Should not!");} + } + else if(IsNumber(texture)) + { + if( (texture &= 0xffff) == 0) + { /* White Shade */ + grayword[0] = 0; + srcbase = &grayword[0]; + num_gray = 1; + curr_gray_line = 0; + } + else if(texture == 0xffff) + { /* Black Shade */ + grayword[0] = 0xFFFF; + srcbase = &grayword[0]; + num_gray = 1; + curr_gray_line = 0; + } + else + { /* 4x4 */ + srcbase = base = (DLword *)(&grayword[0]); + GETWORD(base++) = Expand4Bit(((texture >> 12) & 0xf)); + GETWORD(base++) = Expand4Bit(((texture >> 8) & 0xf)); + GETWORD(base++) = Expand4Bit(((texture >> 4) & 0xf)); + GETWORD(base++) = Expand4Bit((texture & 0xf)); + num_gray = 4; + curr_gray_line = (dty) & 3; + srcbase += curr_gray_line; + } + } + else /**** Need to handle texture = listp case, too ***/ + /* Listp case alway punt to LISP */ + { /* A bitmap that is 16 bits wide. */ + texture68k = (BITMAP *)Addr68k_from_LADDR(texture); + srcbase = (DLword *)Addr68k_from_LADDR(texture68k->bmbase); + num_gray = min( texture68k->bmheight, 16); + curr_gray_line = (dty) % num_gray; + srcbase += curr_gray_line; + } + + +do_it_now: + LOCKSCREEN; + +#ifdef REALCURSOR + displayflg |= n_new_cursorin(dstbase,left,dty,width,height); + if( displayflg ) HideCursor; +#endif /* REALCURSOR */ + + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, slx, left, width, height, 0, dstbpl, + 0, src_comp, op, 1, num_gray, curr_gray_line); +#else +#define gray 1 +#define backwardflg 0 +#define srcbpl 0 +#define w width +#define h height +#define dx left +#define sx slx + new_bitblt_code; +#undef gray +#undef backwardflg +#undef srcbpl +#undef w +#undef h +#undef dx +#undef sx +#endif + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + /* Copy the changed section of display bank to the frame buffer */ + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltsub: x %d, y %d, w %d, h %d.\n",left, dty, width,height));*/ + flush_display_region(left, dty, width, height); + } +#endif + + +#ifdef XWINDOW + XLOCK; + if (in_display_segment(dstbase)) + flush_display_region(left, dty, width, height); + XFlush(currentdsp->display_id); + XUNLOCK; +#endif /* XWINDOW */ + +#ifdef DOS + /* Copy the changed section of display bank to the frame buffer */ + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltsub: x %d, y %d, w %d, h %d.\n",dx, dty, w,h)); */ + flush_display_region(left, dty, width, height); + } +#endif /* DOS */ + +#ifdef REALCURSOR + if( displayflg) ShowCursor; +#endif /* REALCURSOR */ + + UNLOCKSCREEN; + + return(ATOM_T); + + bad_arg: return(NIL); +} /* end of bitshade_bitmap */ + + +/* + * + * + ******** BLTCHAR BLTCHAR BLTCHAR BLTCHAR ********* + * + */ + +/** \BLTCHAR **** +(freplace (PILOTBBT PBTDESTBIT) of LOCAL1 with LEFT) +(freplace (PILOTBBT PBTWIDTH) of LOCAL1 with (IDIFFERENCE RIGHT LEFT)) +(freplace (PILOTBBT PBTSOURCEBIT) of LOCAL1 with + (IDIFFERENCE + (IPLUS (\GETBASE + (ffetch (\DISPLAYDATA DDOFFSETSCACHE) of DISPLAYDATA) + CHAR8CODE) + LEFT) + CURX)) +(\PILOTBITBLT LOCAL1 0) +*********/ + + +#ifndef BYTESWAP +#ifdef BIGVM +typedef struct + { + unsigned nil1 : 4; + unsigned pilotbbt : 28; + unsigned nil2 : 4; + unsigned displaydata : 28; + unsigned nil3 : 16; + unsigned char8code : 16; + unsigned nil4 : 16; + unsigned curx : 16; + unsigned nil5 : 16; + unsigned left : 16; + unsigned nil6 : 16; + unsigned right : 16; + } BLTC; +#else +typedef struct + { + unsigned nil1 : 8; + unsigned pilotbbt : 24; + unsigned nil2 : 8; + unsigned displaydata : 24; + unsigned nil3 : 16; + unsigned char8code : 16; + unsigned nil4 : 16; + unsigned curx : 16; + unsigned nil5 : 16; + unsigned left : 16; + unsigned nil6 : 16; + unsigned right : 16; + } BLTC; +#endif /* BIGVM */ +#else +#ifdef BIGVM +typedef struct + { + unsigned pilotbbt : 28; + unsigned nil1 : 4; + unsigned displaydata : 28; + unsigned nil2 : 4; + unsigned char8code : 16; + unsigned nil3 : 16; + unsigned curx : 16; + unsigned nil4 : 16; + unsigned left : 16; + unsigned nil5 : 16; + unsigned right : 16; + unsigned nil6 : 16; + } BLTC; +#else +typedef struct + { + unsigned pilotbbt : 24; + unsigned nil1 : 8; + unsigned displaydata : 24; + unsigned nil2 : 8; + unsigned char8code : 16; + unsigned nil3 : 16; + unsigned curx : 16; + unsigned nil4 : 16; + unsigned left : 16; + unsigned nil5 : 16; + unsigned right : 16; + unsigned nil6 : 16; + } BLTC; +#endif /* BIGVM */ +#endif /* BYTESWAP */ + + + +/************************************************************************/ +/* */ +/* b l t c h a r */ +/* */ +/* BITBLT character images onto a display stream. */ +/* */ +/* */ +/************************************************************************/ + + + +#ifndef prropstyle + /********************************************************/ + /* Non-PIXRECT version of the code */ + /********************************************************/ + +LispPTR +bltchar( register BLTC *args ) + /* args[0] : PILOTBBT + * args[1] : DISPLAYDATA + * args[2] : CHAR8CODE + * args[3] : CURX + * args[4] : LEFT + * args[5] : RIGHT + */ +{ + register PILOTBBT *pbt; + register DISPLAYDATA *dspdata; + int base; + register int displayflg; + + int w, h; + int backwardflg = 0, sx, dx, srcbpl, dstbpl, src_comp, op; + DLword *srcbase, *dstbase; + int gray = 0, num_gray = 0, curr_gray_line = 0; + + + pbt = (PILOTBBT *) Addr68k_from_LADDR( args->pilotbbt ); + dspdata = (DISPLAYDATA *)Addr68k_from_LADDR( args->displaydata ); + + srcbase =(DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtsourcehi, + pbt->pbtsourcelo)); + + dstbase =(DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtdesthi, + pbt->pbtdestlo )); + + srcbpl = abs( pbt->pbtsourcebpl ); + dstbpl = abs( pbt->pbtdestbpl ); + h = pbt->pbtheight; + w = args->right - args->left; + if ((h <= 0) || (w <= 0)) return(0); + + base = GETWORD( Addr68k_from_LADDR + (dspdata->ddoffsetscache + args->char8code)); + sx = base + args->left - args->curx; + dx = args->left; + +#ifdef REALCURSOR + /* if displayflg != 0 then source or destination is DisplayBitMap + * Now we consider about only destination + */ + displayflg = cursorin(pbt->pbtdesthi, + (pbt->pbtdestlo + (args->left >> 4)), + (args->right - args->left), + pbt->pbtheight, + pbt->pbtbackward); +#endif /* REALCURSOR */ + + + op = pbt->pbtoperation; + src_comp = pbt->pbtsourcetype; + + LOCKSCREEN; + +#ifdef REALCURSOR + if( displayflg ) + HideCursor; +#endif /* REALCURSOR */ + + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, + backwardflg, src_comp, op, gray, num_gray, curr_gray_line); +#else + new_char_bitblt_code +#endif + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + if (in_display_segment(dstbase)) + { + flush_display_lineregion(dx, + dstbase, + w, h); + } +#endif + + +#ifdef XWINDOW + XLOCK; + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); + XUNLOCK; +#endif /* XWINDOW */ + +#ifdef DOS + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); +#endif /* DOS */ + +#ifdef REALCURSOR + if( displayflg ) + ShowCursor; +#endif /* REALCURSOR */ + + UNLOCKSCREEN; +} + +#else +/* prropstyle */ + +LispPTR +bltchar( register BLTC *args ) + /* args[0] : PILOTBBT + * args[1] : DISPLAYDATA + * args[2] : CHAR8CODE + * args[3] : CURX + * args[4] : LEFT + * args[5] : RIGHT + */ +{ + register PILOTBBT *pbt; + register DISPLAYDATA *dspdata; + int x, y, destbpl, srcebpl, srcebit, distance; + int base; + register int displayflg; + unsigned int pix_op; + DLword *dstbase; + + pbt = (PILOTBBT *) Addr68k_from_LADDR( args->pilotbbt ); + dspdata = (DISPLAYDATA *)Addr68k_from_LADDR( args->displaydata ); + + (mpr_d(SrcePixRect))->md_image = + (short *)Addr68k_from_LADDR(VAG2( pbt->pbtsourcehi, pbt->pbtsourcelo)); + + dstbase = (mpr_d(DestPixRect))->md_image = + (short *)Addr68k_from_LADDR(VAG2( pbt->pbtdesthi, pbt->pbtdestlo )); + + SrcePixRect->pr_width = srcebpl = abs( pbt->pbtsourcebpl ); + DestPixRect->pr_width = destbpl = abs( pbt->pbtdestbpl ); + SrcePixRect->pr_height = DestPixRect->pr_height = pbt->pbtheight; + +#ifdef I386 + /* Need to take care of byte order, because display bank */ + /* on the 386 is NOT bit reversed.... */ + if (IN_DISPLAY_BANK(pbt->pbtsourcehi)) + mpr_d(SrcePixRect)->md_flags |= MP_I386; + else mpr_d(SrcePixRect)->md_flags &= (~MP_I386); + if (IN_DISPLAY_BANK(pbt->pbtdesthi)) + mpr_d(DestPixRect)->md_flags |= MP_I386; + else mpr_d(DestPixRect)->md_flags &= (~MP_I386); +#endif /* I386 */ + + + mpr_mdlinebytes(DestPixRect) = (destbpl + 7) >> 3; + mpr_mdlinebytes(SrcePixRect) = (srcebpl + 7) >> 3; + + base = GETWORD( Addr68k_from_LADDR + (dspdata->ddoffsetscache + args->char8code)); + srcebit = base + args->left - args->curx; + +#ifdef REALCURSOR + /* if displayflg != 0 then source or destination is DisplayBitMap + * Now we consider about only destination + */ + displayflg = old_cursorin(pbt->pbtdesthi, pbt->pbtdestlo, + args->left, + (args->right - args->left), + pbt->pbtheight, y, pbt->pbtbackward); +#endif /* REALCURSOR */ + + +/**** for DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG *****/ +/* displayflg = T; */ +/**** for DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG *****/ + + pix_op = PixOperation( pbt->pbtsourcetype, pbt->pbtoperation ); + + LOCKSCREEN; + +#ifdef REALCURSOR + if( displayflg ) + HideCursor; +#endif /* REALCURSOR */ + + + if(pr_rop( DestPixRect, args->left, 0, + (args->right - args->left),pbt->pbtheight, pix_op, + SrcePixRect, srcebit, 0) != 0) + error("pilotbitblt: pr_rop failed\n"); + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + if (in_display_segment(dstbase)) + { +/* DBPRINT(("bltchar pix: x %x, y %d, w %d, h %d.\n", args->left, dstbase, (args->right - args->left),pbt->pbtheight)); +*/ + flush_display_lineregion(args->left, dstbase, (args->right - args->left),pbt->pbtheight); + } +#endif + + + +#ifdef XWINDOW + XLOCK; + if (in_display_segment(dstbase)) + flush_display_lineregion(args->left, dstbase, (args->right - args->left),pbt->pbtheight); + XUNLOCK; +#endif /* XWINDOW */ + +#ifdef DOS + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); +#endif /* DOS */ + +#ifdef REALCURSOR + if( displayflg ) + ShowCursor; +#endif /* REALCURSOR */ + + ScreenLocked=NIL; +} +#endif + + + +/************************************************************************/ +/* */ +/* n e w b l t c h a r */ +/* */ +/* BITBLT character images onto a display stream. This version */ +/* handles clipping in the C code, and checks for changes of */ +/* character set and hitting the right margin. In either of */ +/* those cases, it punts to the old LISP code for BLTCHAR. It */ +/* also punts if the display stream we're writing to isn't for */ +/* the top window on the screen's window stack. */ +/* */ +/************************************************************************/ + + +#define BLTCHAR_argnum 3 +#ifndef INIT +#define PUNT_TO_BLTCHAR \ + { \ + if ((BLTCHAR_index==0)) \ + { \ + BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR",18, \ + "INTERLISP",9, NIL); \ + if (BLTCHAR_index == 0xffffffff) \ + { \ + error("\\MAIKO.PUNTBLTCHAR install failed"); \ + return; \ + } \ + } \ + CurrentStackPTR +=(BLTCHAR_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(BLTCHAR_index,BLTCHAR_argnum,3); \ + return; \ + } +#else +#define PUNT_TO_BLTCHAR \ + { /* Version that is silent instead of erroring for init */ \ + if ((BLTCHAR_index==0)) \ + { \ + BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR",18, \ + "INTERLISP",9, NIL); \ + if (BLTCHAR_index == 0xffffffff) \ + { \ + /* error("\\MAIKO.PUNTBLTCHAR install failed"); */ \ + return; \ + } \ + } \ + CurrentStackPTR +=(BLTCHAR_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(BLTCHAR_index,BLTCHAR_argnum,3); \ + return; \ + } +#endif /* INIT */ + + +#define TEDIT_BLTCHAR_argnum 6 +#define PUNT_TO_TEDIT_BLTCHAR {\ + if(TEDIT_BLTCHAR_index==0xffffffff){ \ + TEDIT_BLTCHAR_index=get_package_atom("\\TEDIT.BLTCHAR",14,"INTERLISP",9, NIL); \ + if(TEDIT_BLTCHAR_index==0xffffffff) \ + {error("TEDIT install failed"); \ + return;} } \ + CurrentStackPTR +=(TEDIT_BLTCHAR_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(TEDIT_BLTCHAR_index,TEDIT_BLTCHAR_argnum,3);return;} + + +#define FGetNum(ptr, place) { \ + if(((ptr) & SEGMASK)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ + else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ + else {PUNT_TO_BLTCHAR;}} +#define FGetNum2(ptr, place) { \ + if(((ptr) & SEGMASK)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ + else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ + else {return(-1);}} + +LispPTR *TOPWDS68k; /* Top of window stack's DS */ +LispPTR BLTCHAR_index; /* Atom # for \PUNTBLTCHAR punt fn */ +LispPTR TEDIT_BLTCHAR_index; /* if NIL ,TEDIT is not yet loaded */ + + + /****************************************/ + /* */ + /* Arguments to NEWBLTCHAR */ + /* */ + /****************************************/ +#ifndef BYTESWAP +typedef struct { + DLword nil; /* Unused word */ + unsigned charset : 8; /* High 8 bits of character code */ + unsigned char8code : 8; /* Low 8 bits of character code */ + LispPTR displaystream; /* The display stream to print on */ + LispPTR displaydata; /* The image data (margins, etc) */ +} BLTARG; +#else +typedef struct { + unsigned char8code : 8; /* Low 8 bits of character code */ + unsigned charset : 8; /* High 8 bits of character code */ + DLword nil; /* Unused word */ + LispPTR displaystream; /* The display stream to print on */ + LispPTR displaydata; /* The image data (margins, etc) */ +} BLTARG; +#endif /* BYTESWAP */ + + +#ifndef prropstyle + + +/************************************************************************/ +/* */ +/* n e w b l t c h a r */ +/* (non-PIXRECT version) */ +/* */ +/************************************************************************/ + +newbltchar(register BLTARG *args) +{ + register DISPLAYDATA *displaydata68k; + int right, left, curx; + PILOTBBT *pbt; + int lmargin, rmargin, xoff; + int base; + int h, w; + int displayflg; + int backwardflg = 0, sx, dx, srcbpl, dstbpl, src_comp, op; + DLword *srcbase, *dstbase; + int gray = 0, num_gray = 0, curr_gray_line = 0; + + + displaydata68k=(DISPLAYDATA*)Addr68k_from_LADDR(args->displaydata); + + if((displaydata68k->ddcharset & 0xFFFF) != args->charset) + { + /*if(changecharset_display(displaydata68k, args->charset) ==-1)*/ + PUNT_TO_BLTCHAR; + } + + + if(displaydata68k->ddslowprintingcase) + { + PUNT_TO_BLTCHAR; /** \SLOWBLTCHAR--return;**/ + } + + FGetNum(displaydata68k->ddxposition,curx); + FGetNum(displaydata68k->ddrightmargin,rmargin); + FGetNum(displaydata68k->ddleftmargin,lmargin); + FGetNum(displaydata68k->ddxoffset,xoff); + + right = curx + GETWORD((DLword*)Addr68k_from_LADDR + (displaydata68k->ddcharimagewidths + args->char8code)); + + if((right> rmargin )&&(curx >lmargin)) PUNT_TO_BLTCHAR; + if(args->displaystream != *TOPWDS68k) PUNT_TO_BLTCHAR; + + { + register int newpos; + newpos = curx + GETWORD((DLword*)Addr68k_from_LADDR + (displaydata68k->ddwidthscache + args->char8code )); + + if ((0 <= newpos) && (newpos < 65536)) + (displaydata68k->ddxposition) = (LispPTR)(S_POSITIVE | newpos); + else if(-65537 < newpos) + (displaydata68k->ddxposition) = (LispPTR)(S_NEGATIVE | (0xffff & newpos)); + else {PUNT_TO_BLTCHAR;} + } + + curx += xoff; + right += xoff; + if(right > (int)(displaydata68k->ddclippingright)) + right = displaydata68k->ddclippingright; + + if(curx > (int)(displaydata68k->ddclippingleft)) + left = curx; + else left = displaydata68k->ddclippingleft; + + pbt= (PILOTBBT*)Addr68k_from_LADDR(displaydata68k->ddpilotbbt); + h = pbt->pbtheight; + w = right - left; + if ((h <= 0) || (w <= 0)) return(0); + + srcbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtsourcehi, + pbt->pbtsourcelo)); + + dstbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtdesthi, + pbt->pbtdestlo )); + + op = pbt->pbtoperation; + src_comp = pbt->pbtsourcetype; + + srcbpl = abs( pbt->pbtsourcebpl ); + dstbpl = abs( pbt->pbtdestbpl ); + base = GETWORD( Addr68k_from_LADDR + (displaydata68k->ddoffsetscache + args->char8code)); + sx = base + left - curx; + dx = left; + + LOCKSCREEN; + +#ifdef REALCURSOR + displayflg = ( cursorin(pbt->pbtdesthi, (pbt->pbtdestlo + (left >> 4)), + (right - left), pbt->pbtheight, pbt->pbtbackward) ); + if (displayflg) HideCursor; +#endif /* REALCURSOR */ + + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, + backwardflg, src_comp, op, gray, num_gray, curr_gray_line); +#else + new_char_bitblt_code +#endif + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + if (in_display_segment(dstbase)) + { +/* DBPRINT(("newbltchar: x %d, y 0x%x, w %d, h %d.\n", dx, dstbase, w, h));*/ + flush_display_lineregion(dx, dstbase, w, h); + } +#endif + + + +#ifdef XWINDOW + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); +#endif /* XWINDOW */ +#ifdef DOS + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); +#endif /* DOS */ + +#ifdef REALCURSOR + if (displayflg) ShowCursor; +#endif /* REALCURSOR */ + + UNLOCKSCREEN; + +} /* end of newbltchar */ + +#else /* prropstyle */ + +/************************************************************************/ +/* */ +/* n e w b l t c h a r */ +/* (PIXRECT version) */ +/* */ +/************************************************************************/ + +LispPTR +newbltchar(register BLTARG *args) +{ + register DISPLAYDATA *displaydata68k; + + register int right,left,curx; + register PILOTBBT *pbt; + register int lmargin,rmargin,xoff; + int displayflg; /* T if cursor needs to be taken down */ + displaydata68k=(DISPLAYDATA*)Addr68k_from_LADDR(args->displaydata); + + if((displaydata68k->ddcharset & 0xFFFF) != args->charset) + { + /* Currently, this has BUG, so I can't call it */ + /*if(changecharset_display(displaydata68k,args->charset) ==-1)*/ + {PUNT_TO_BLTCHAR;} + } + + if(displaydata68k->ddslowprintingcase) + { + PUNT_TO_BLTCHAR; /** \SLOWBLTCHAR--return;**/ + } + + FGetNum(displaydata68k->ddxposition, curx); + FGetNum(displaydata68k->ddrightmargin, rmargin); + FGetNum(displaydata68k->ddleftmargin, lmargin); + FGetNum(displaydata68k->ddxoffset, xoff); + + right = curx + GETWORD((DLword*)Addr68k_from_LADDR + (displaydata68k->ddcharimagewidths+ args->char8code)); + + if((right> rmargin )&&(curx >lmargin)) PUNT_TO_BLTCHAR; + if(args->displaystream != *TOPWDS68k) PUNT_TO_BLTCHAR; + { + register int newpos; + newpos = curx + GETWORD((DLword*)Addr68k_from_LADDR + (displaydata68k->ddwidthscache + args->char8code )); + + if ((0 <= newpos) && (newpos < 65536)) + (displaydata68k->ddxposition) = (LispPTR)(S_POSITIVE | newpos); + else if(-65537 < newpos) + (displaydata68k->ddxposition) = (LispPTR)(S_NEGATIVE | (0xffff & newpos)); + else {PUNT_TO_BLTCHAR;} + } + + curx += xoff; + right += xoff; + if(right > (int)(displaydata68k->ddclippingright)) + right = displaydata68k->ddclippingright; + + if(curx > (int)(displaydata68k->ddclippingleft)) + left = curx; + else left = displaydata68k->ddclippingleft; + + + if(left ddpilotbbt); + if(pbt->pbtheight !=0) + { + /****** OLD bltchar *****/ + register int destbpl, srcebpl, sourcebit; + DLword * dstbase; + int base,y; + + (mpr_d(SrcePixRect))->md_image =(short *)Addr68k_from_LADDR( VAG2( pbt->pbtsourcehi, + pbt->pbtsourcelo)); + + dstbase = (mpr_d(DestPixRect))->md_image = (short *)Addr68k_from_LADDR( VAG2( pbt->pbtdesthi, + pbt->pbtdestlo )); + + SrcePixRect->pr_width = srcebpl = abs( pbt->pbtsourcebpl ); + DestPixRect->pr_width = destbpl = abs( pbt->pbtdestbpl ); + SrcePixRect->pr_height = DestPixRect->pr_height = pbt->pbtheight; + + + + + mpr_mdlinebytes(DestPixRect) = (destbpl + 7) >> 3; + mpr_mdlinebytes(SrcePixRect) = (srcebpl + 7) >> 3; + + base = GETBASE(Addr68k_from_LADDR(displaydata68k->ddoffsetscache), args->char8code); + sourcebit = base + left - curx; + + LOCKSCREEN; + +#ifdef SUNDISPLAY + if ( displayflg = old_cursorin(pbt->pbtdesthi, pbt->pbtdestlo, + left, (right - left), pbt->pbtheight, y, pbt->pbtbackward) ) + { + HideCursor; + if(pr_rop( DestPixRect, left, 0, + (right - left),pbt->pbtheight, + PixOperation( pbt->pbtsourcetype, pbt->pbtoperation ), + SrcePixRect, sourcebit, 0) != 0) + error("pilotbitblt: pr_rop failed\n"); + /* Save SHOWCURSOR 'til after paint to screen */ +#ifndef DISPLAYBUFFER + ShowCursor; +#endif + } /* display case */ + else + { + if(pr_rop( DestPixRect, left, 0, + (right - left),pbt->pbtheight, + PixOperation( pbt->pbtsourcetype, pbt->pbtoperation ), + SrcePixRect, sourcebit, 0) != 0) + error("pilotbitblt: pr_rop failed\n"); + + } /* else */ + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + if (in_display_segment(dstbase)) + { +/* DBPRINT(("newbltchar: x %d, y 0x%x, w %d, h %d.\n", left, dstbase, (right - left), pbt->pbtheight)); */ + + flush_display_lineregion(left, dstbase, (right - left), pbt->pbtheight); + if (displayflg) ShowCursor; /* because hide is done earlier */ + } +#endif +#endif /* SUNDISPLAY */ + + +#ifdef XWINDOW + if(pr_rop( DestPixRect, left, 0, + (right - left),pbt->pbtheight, + PixOperation( pbt->pbtsourcetype, pbt->pbtoperation ), + SrcePixRect, sourcebit, 0) != 0) + error("pilotbitblt: pr_rop failed\n"); + + if (in_display_segment(dstbase)) + flush_display_lineregion(left, dstbase, (right - left), pbt->pbtheight); +#endif /* XWINDOW */ + +#ifdef DOS + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); + if (displayflg) ShowCursor; +#endif /* DOS */ + + ScreenLocked=NIL; + + /****** OLD bltchar *****/ + + } + + } +} /* newbltchar */ +#endif + + + +/******************************************************************/ +#ifndef BYTESWAP +#ifdef BIGVM +typedef struct { + LispPTR FONTDEVICE; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + DLword SFAscent; + DLword SFDescent; + DLword SFHeight; + DLword ROTATION; + short FBBOX; + short FBBOY; + short FBBDX; + short FBBDY; + LispPTR SFLKerns; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + unsigned SFFACECODE : 8; + unsigned nil :8; + DLword FONTAVGCHARWIDTH; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; +#else +typedef struct { + LispPTR FONTDEVICE; + LispPTR SFObsolete1; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + LispPTR SFObsolete2; + LispPTR SFObsolete3; + LispPTR SFObsolete4; + DLword SFObsolete5; + DLword SFObsolete6; + DLword SFAscent; + DLword SFDescent; + DLword SFHeight; + DLword ROTATION; + short FBBOX; + short FBBOY; + short FBBDX; + short FBBDY; + unsigned SFFACECODE : 8; + unsigned SFLKerns :24; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + DLword FONTAVGCHARWIDTH; + DLword dum; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; +#endif /* BIGVM */ + +typedef struct { + LispPTR WIDTHS +; + LispPTR OFFSETS; + LispPTR IMAGEWIDTHS; + LispPTR CHARSETBITMAP; + LispPTR YWIDTHS; + DLword CHARSETASCENT; + DLword CHARSETDESCENT; + LispPTR LEFTKERN; + } CHARSETINFO; +#else +typedef struct { + LispPTR FONTDEVICE; + LispPTR SFObsolete1; + LispPTR FONTFAMILY; + LispPTR FONTSIZE; + LispPTR FONTFACE; + LispPTR SFObsolete2; + LispPTR SFObsolete3; + LispPTR SFObsolete4; + DLword SFObsolete6; + DLword SFObsolete5; + DLword SFDescent; + DLword SFAscent; + DLword ROTATION; + DLword SFHeight; + short FBBOY; + short FBBOX; + short FBBDY; + short FBBDX; + unsigned SFLKerns :24; + unsigned SFFACECODE : 8; + LispPTR SFRWidths; + LispPTR FONTDEVICESPEC; + LispPTR OTHERDEVICEFONTPROPS; + LispPTR FONTSCALE; + DLword dum; + DLword FONTAVGCHARWIDTH; + LispPTR FONTIMAGEWIDTHS; + LispPTR FONTCHARSETVECTOR; + LispPTR FONTEXTRAFIELD2; +} FONTDESC; + +typedef struct { + LispPTR WIDTHS; + LispPTR OFFSETS; + LispPTR IMAGEWIDTHS; + LispPTR CHARSETBITMAP; + LispPTR YWIDTHS; + DLword CHARSETDESCENT; + DLword CHARSETASCENT; + LispPTR LEFTKERN; + } CHARSETINFO; +#endif /* BYTESWAP */ + + +#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) +#define IMAX(x,y) (((x) > (y)) ? (x) : (y)) + +/** changecharset_display,sfffixy are not tested *****I don't use TAKE **/ + +LispPTR +changecharset_display(register DISPLAYDATA *displaydata68k, + DLword charset) +{ + register PILOTBBT *pbt68k; + register FONTDESC *fontd68k; + LispPTR csinfo; + register CHARSETINFO *csinfo68k; + BITMAP *bm68k; + LispPTR *base68k; + + pbt68k =(PILOTBBT*)Addr68k_from_LADDR(displaydata68k->ddpilotbbt); + fontd68k=(FONTDESC*)Addr68k_from_LADDR(displaydata68k->ddfont); + base68k = (LispPTR*)Addr68k_from_LADDR(fontd68k->FONTCHARSETVECTOR); + + if((csinfo= *(base68k + charset)) == NIL ){ + return(-1); /* punt case */ + } + csinfo68k = (CHARSETINFO*)Addr68k_from_LADDR(csinfo); +/* REF CNT */ + +FRPLPTR(displaydata68k->ddwidthscache, csinfo68k->WIDTHS); +FRPLPTR(displaydata68k->ddoffsetscache, csinfo68k->OFFSETS); +FRPLPTR(displaydata68k->ddcharimagewidths, csinfo68k->IMAGEWIDTHS); + displaydata68k->ddcharset = charset; + + bm68k =(BITMAP*)Addr68k_from_LADDR( csinfo68k->CHARSETBITMAP); + + pbt68k->pbtsourcebpl = (bm68k->bmrasterwidth) << 4; + + if((displaydata68k->ddcharsetascent != csinfo68k->CHARSETASCENT) || + (displaydata68k->ddcharsetdescent != csinfo68k->CHARSETDESCENT)) + { printf("CCD1\n"); + return(sfffixy(displaydata68k, csinfo68k,pbt68k )); + } + else + { + register LispPTR addr; + register int num; + FGetNum2(displaydata68k->ddcharheightdelta,num);/* if not number, return -1 */ + addr = bm68k->bmbase + (bm68k->bmrasterwidth * num); + printf("CCD2 num=%d\n",num); + pbt68k->pbtsourcehi= addr >> 16; + pbt68k->pbtsourcelo = addr; /* don't care REFCNT */ + return(T); + } +} /* changecharset_display */ + +sfffixy(displaydata68k,csinfo68k,pbt68k) + DISPLAYDATA *displaydata68k; + CHARSETINFO *csinfo68k; + PILOTBBT *pbt68k; + + { + int y; + int chartop,top; + BITMAP *bm68k; + register LispPTR base,ypos,yoff; + + FGetNum2(displaydata68k->ddyoffset, yoff); + FGetNum2(displaydata68k->ddyposition, ypos); + + y = ypos + yoff; + + displaydata68k->ddcharsetascent=csinfo68k->CHARSETASCENT; + chartop = y + displaydata68k->ddcharsetascent; + + bm68k=(BITMAP*)Addr68k_from_LADDR(displaydata68k->dddestination); + base = bm68k->bmbase; + top = IMAX( IMIN(displaydata68k->ddclippingtop, chartop), 0 ); + base= base + (bm68k->bmrasterwidth * (bm68k->bmheight - top)); + pbt68k->pbtdesthi= base >> 16; + pbt68k->pbtdestlo= base; + + bm68k=(BITMAP*)Addr68k_from_LADDR(csinfo68k->CHARSETBITMAP); + base = bm68k->bmbase; + displaydata68k->ddcharheightdelta= + IMIN( IMAX(chartop - top, 0), 65535 );/* always positive */ + base = base + bm68k->bmrasterwidth * displaydata68k->ddcharheightdelta; + pbt68k->pbtsourcehi = base >> 16; + pbt68k->pbtsourcelo = base; + + displaydata68k->ddcharsetdescent= csinfo68k->CHARSETDESCENT; + + pbt68k->pbtheight = IMAX(0, + top-(IMAX( y- displaydata68k->ddcharsetdescent,displaydata68k->ddclippingbottom))); + return(T); + + } /* sfffixy */ + + +/******************************************************************/ + +ccfuncall(atom_index,argnum,bytenum) + register unsigned int atom_index; /* Atomindex for Function you want to invoke */ + register int argnum; /* Number of ARGS on TOS and STK */ + register int bytenum; /* Number of bytes of Caller's + OPCODE(including multi-byte) */ +{ + register struct definition_cell *defcell68k; /* Definition Cell PTR */ + register short pv_num; /* scratch for pv */ + register struct fnhead *tmp_fn; + int rest; /* use for arignments */ + int closurep=NIL; + register CClosure *closure68k; + + /* Get Next Block offset from argnum */ + CURRENTFX->nextblock = (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) + - (argnum<<1)+4 /* +3 */; + + /* Setup IVar */ + IVar = Addr68k_from_LADDR((((LispPTR)(CURRENTFX->nextblock)) | STK_OFFSET)); + + /* Set PC to the Next Instruction and save into FX */ + CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) + bytenum; + + PushCStack; /* save TOS */ + + /* Get DEFCELL 68k address */ + defcell68k =(struct definition_cell *) GetDEFCELL68k(atom_index); + + tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ); + +if((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) >= (UNSIGNED)EndSTKP ) + { + LispPTR test; + test= *((LispPTR*)CurrentStackPTR); + DOSTACKOVERFLOW(argnum,bytenum-1); + S_CHECK(test == *((LispPTR*)CurrentStackPTR), + "stack overflow in ccfuncall"); + } + FuncObj = tmp_fn; + + if( FuncObj->na >= 0 ) + { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = argnum - FuncObj->na; + + while(rest <0) { + PushStack(NIL_PTR); + rest++; + } + CurrentStackPTR -= (rest<<1); + } /* if end */ + + /* Set up BF */ +CurrentStackPTR+=2; + GETWORD(CurrentStackPTR) = BF_MARK; + GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock; +CurrentStackPTR+=2; + + /* Set up FX */ + GETWORD(CurrentStackPTR) = FX_MARK; + + /* Now SET new FX */ + ((struct frameex1 *)CurrentStackPTR)->alink = LADDR_from_68k(PVar); + PVar = (DLword *)CurrentStackPTR + FRAMESIZE; +#ifdef BIGVM + ((struct frameex1 *)CurrentStackPTR)->fnheader = + (defcell68k->defpointer); +#else + ((struct frameex1 *)CurrentStackPTR)->lofnheader = + (defcell68k->defpointer) & 0x0ffff; + ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = + ((defcell68k->defpointer) & SEGMASK) >> 16; +#endif /* BIGVM */ + CurrentStackPTR = PVar; + + /* Set up PVar area */ + pv_num = FuncObj->pv+1; /* Changed Apr.27 */ + + while(pv_num > 0) { + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; + CurrentStackPTR += DLWORDSPER_CELL; + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; + CurrentStackPTR += DLWORDSPER_CELL; + pv_num--; + } + + /* Set PC points New Function's first OPCODE */ + PC = (ByteCode *)FuncObj + FuncObj->startpc; + /* It assume that ccfuncall is called for PUNTing from SUBRCALL */ + PC -= 3 ; /* Ajust PC */ + +} /* end ccfuncall */ + +/****************************************************************/ +/* */ +/* tedit_bltchar */ +/* */ +/* C-coded version of TEdit's character-painting function */ +/* \\TEDIT.BLTCHAR */ +/* */ +/****************************************************************/ +#ifndef BYTESWAP +typedef + struct tbta + { + DLword nil; + unsigned charset : 8; + unsigned char8code : 8; + LispPTR displaystream; + unsigned int nil2 : 16; + unsigned int current_x : 16; /* this is allways positive */ + LispPTR displaydata; + LispPTR ddpilotbitblt; + unsigned int nil3 : 16; + unsigned int clipright : 16;/* this is allways positive */ + } TBLTARG; +#else +typedef + struct tbta + { + unsigned char8code : 8; + unsigned charset : 8; + DLword nil; + LispPTR displaystream; + unsigned int current_x : 16; /* this is allways positive */ + unsigned int nil2 : 16; + LispPTR displaydata; + LispPTR ddpilotbitblt; + unsigned int clipright : 16;/* this is allways positive */ + unsigned int nil3 : 16; + } TBLTARG; +#endif /* BYTESWAP */ + + + +#ifndef prropstyle + /***************************/ + /* Non-PIXRECT version */ + /***************************/ +tedit_bltchar(args) + register TBLTARG *args; + { +#define backwardflg 0 +#define displayflg 0 + register DISPLAYDATA *displaydata68k; + int right; + register PILOTBBT *pbt; + int imagewidth, newx; + /* for new_char_bitblt_code */ + int h, w; + int sx, dx, srcbpl, dstbpl, src_comp, op; + DLword *srcbase, *dstbase; + int gray = 0, num_gray = 0, curr_gray_line = 0; + + displaydata68k=(DISPLAYDATA*)Addr68k_from_LADDR(args->displaydata); + if(displaydata68k->ddcharset != args->charset) + { + /**if(changecharset_display(displaydata68k, args->charset)== -1)**/ + { + PUNT_TO_TEDIT_BLTCHAR; + } + } + imagewidth = *((DLword*)Addr68k_from_LADDR + (displaydata68k->ddcharimagewidths+ args->char8code)); + newx = args->current_x + imagewidth; + dx = args->current_x; + right = IMIN(newx, args->clipright); + + if(dx < right) + { + pbt= (PILOTBBT*)Addr68k_from_LADDR(displaydata68k->ddpilotbbt); + h = pbt->pbtheight; + srcbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtsourcehi, + pbt->pbtsourcelo)); + + dstbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtdesthi, + pbt->pbtdestlo )); + srcbpl = abs( pbt->pbtsourcebpl ); + dstbpl = abs( pbt->pbtdestbpl ); + + op = pbt->pbtoperation; + src_comp = pbt->pbtsourcetype; + + /*dx=left; I'll optimize later*/ + sx = GETBASE(Addr68k_from_LADDR(displaydata68k->ddoffsetscache), + args->char8code); + w= IMIN(imagewidth, (right-dx)); +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, + backwardflg, src_comp, op, gray, num_gray, curr_gray_line); +#else + + new_char_bitblt_code; +#endif + + } +#undef displayflg +#undef backwardflg + + } /* end tedit_bltchar */ +#else + +/* pr_op style */ + /**********************/ + /* PIXRECT version */ + /**********************/ + +tedit_bltchar(args) + register TBLTARG *args; + { + register DISPLAYDATA *displaydata68k; + register int left,right; + register PILOTBBT *pbt; + register int imagewidth, newx; + register displayflg; + + displaydata68k=(DISPLAYDATA*)Addr68k_from_LADDR(args->displaydata); + if(displaydata68k->ddcharset != args->charset) + { + /**if(changecharset_display(displaydata68k, args->charset)== -1)**/ + { + PUNT_TO_TEDIT_BLTCHAR; + } + } + imagewidth = *((DLword*)Addr68k_from_LADDR + (displaydata68k->ddcharimagewidths+ args->char8code)); + newx = args->current_x + imagewidth; + left = IMAX(0,args->current_x ); + right = IMIN(newx, args->clipright); + LOCKSCREEN; + + if(left < right) + { + pbt= (PILOTBBT*)Addr68k_from_LADDR(displaydata68k->ddpilotbbt); + if( pbt->pbtheight) + { + (mpr_d(SrcePixRect))->md_image = + (short *)Addr68k_from_LADDR(VAG2(pbt->pbtsourcehi, + pbt->pbtsourcelo)); + + (mpr_d(DestPixRect))->md_image = + (short *)Addr68k_from_LADDR(VAG2(pbt->pbtdesthi, + pbt->pbtdestlo )); + { + register int srcebpl,destbpl; + SrcePixRect->pr_width = srcebpl = abs( pbt->pbtsourcebpl ); + DestPixRect->pr_width = destbpl = abs( pbt->pbtdestbpl ); + SrcePixRect->pr_height = DestPixRect->pr_height = pbt->pbtheight; + +#ifdef I386 + /* Need to take care of byte order, because display bank */ + /* on the 386 is NOT bit reversed.... */ + if (IN_DISPLAY_BANK(pbt->pbtsourcehi)) + mpr_d(SrcePixRect)->md_flags |= MP_I386; + else mpr_d(SrcePixRect)->md_flags &= (~MP_I386); + if (IN_DISPLAY_BANK(pbt->pbtdesthi)) + mpr_d(DestPixRect)->md_flags |= MP_I386; + else mpr_d(DestPixRect)->md_flags &= (~MP_I386); +#endif /* I386 */ + + + + mpr_mdlinebytes(DestPixRect) = (destbpl + 7) >> 3; + mpr_mdlinebytes(SrcePixRect) = (srcebpl + 7) >> 3; + } + + pbt->pbtwidth= IMIN(imagewidth, (right-left)); + pbt->pbtsourcebit=GETBASE(Addr68k_from_LADDR + (displaydata68k->ddoffsetscache), args->char8code); + + if(pr_rop( DestPixRect, left, 0, + pbt->pbtwidth,pbt->pbtheight, + PixOperation( pbt->pbtsourcetype, pbt->pbtoperation ), + SrcePixRect, pbt->pbtsourcebit, 0) != 0) + error("pilotbitblt: pr_rop failed\n"); + + + } /* if pbt->pbtheight */ + } /* if left MOUSEXL)&& + (y < MOUSEYH)&&(y + h > MOUSEYL) ) + return( T ); + else + return( NIL ); + } + +#else +/* For MONO and COLOR */ +old_cursorin ( addrhi, addrlo, x, w, h, y, backward) + DLword addrhi; /* Lisp addr hi-word */ + DLword addrlo; /* Lisp addr lo-word */ + register int x, w, h, y; + { + register DLword *base68k; + extern int MonoOrColor; + extern int displaywidth; +#ifdef INIT + init_kbd_startup; +#endif + + if(MonoOrColor == MONO_SCREEN) { + if (addrhi == DISPLAY_HI) y = addrlo / DisplayRasterWidth; + else if (addrhi == DISPLAY_HI+1) + y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; + else return( NIL ); + + if(backward) y -= h; + + if((x < MOUSEXR)&&(x + w > MOUSEXL)&& + (y < MOUSEYH)&&(y + h > MOUSEYL) ) + return( T ); + else + return( NIL ); + } /* MONO case end */ + else { + base68k=(DLword*)Addr68k_from_LADDR(addrhi << 16 | addrlo); + if ((ColorDisplayRegion68k<=base68k) && + (base68k <= COLOR_MAX_Address)){ + y =(base68k - ColorDisplayRegion68k) /displaywidth ; + } + else return( NIL ); + + if(backward) y -= h; + /* printf("old_c:x=%d,y=%d,w=%d,h=%d\n",x,y,w,h);*/ + if((x < MOUSEXR)&&((x + (w >>3)) > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) + { /* printf("old_c T\n");*/ return( T );} + else + return( NIL ); + } /* COLOR case end */ + } + +#endif /* COLOR */ + + diff --git a/src/bin.c b/src/bin.c new file mode 100755 index 0000000..a6e19be --- /dev/null +++ b/src/bin.c @@ -0,0 +1,71 @@ +/* $Id: bin.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: bin.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/***********************************************************************/ +/* + File Name : bin.c + + Desc : + + Date : Jul. 22, 1987 + Edited by : Takeshi Shimizu + Changed : + + Including : OP_bin + + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "cell.h" +#include "stream.h" + +N_OP_bin(register int tos) +{ + register Stream *stream68k; /* stream instance on TOS */ + register char *buff68k; /* pointer to BUFF */ + + if(GetTypeNumber(tos) == TYPE_STREAM) + { + stream68k=(Stream *) Addr68k_from_LADDR(tos); + + if(!stream68k->BINABLE) ERROR_EXIT(tos); + + if(stream68k->COFFSET >= stream68k->CBUFSIZE) ERROR_EXIT(tos); + + /* get BUFFER instance */ + buff68k =(char *)Addr68k_from_LADDR(stream68k->CBUFPTR); + + /* get BYTE data and set it to TOS */ + return(S_POSITIVE | (Get_BYTE(buff68k + (stream68k->COFFSET)++)) ); + } + else ERROR_EXIT(tos); + +} diff --git a/src/binds.c b/src/binds.c new file mode 100755 index 0000000..50fbb7f --- /dev/null +++ b/src/binds.c @@ -0,0 +1,167 @@ +/* $Id: binds.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: binds.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "emlglob.h" + +/************************************************** +N_OP_bind(stack_pointer, tos, n1, n2) + + Entry: BIND opcode[021] + + 1. bind PVAR slot to NIL. (n1 times) + 2. bind PVAR slot to value of slot in Evaluation stack. (n2 times) + or push TopOfStack to Evaluation stack. + 3. Push [upper word] 1's complement of bind slots + [lower word] 2word offset from PVar + +***************************************************/ + +LispPTR *N_OP_bind(register LispPTR *stack_pointer, register LispPTR tos, int byte1, int byte2) +{ + register int n1; /* # slots to bind to NIL (0, 0) */ + register int n2; /* # slots to bind to value in stack */ + register LispPTR *ppvar; /* pointer to argued slot in Pvar area */ + register int i; /* temporary for control */ + +#ifdef TRACE + printPC(); + printf("TRACE: N_OP_bind()\n"); +#endif + + n1 = byte1 >> 4; + n2 = byte1 & 0xf; + ppvar = (LispPTR *) PVar + 1 + byte2; + + for(i=0; i> 16); + ppvar = (LispPTR *) (PVar + 2 + GetLoWord(value)); + value = 0xffffffff; + for(i=0; i + +#ifndef NOPIXRECT +#ifndef DOS +#include +#include + +#include +#include +#include +#include +#endif /* DOS */ +#include +#endif + +#ifdef XWINDOW +#define DISPLAYBUFFER +#endif /* XWINDOW */ + + +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "adr68k.h" +#include "address.h" + +#include "pilotbbt.h" +#include "display.h" +#include "bitblt.h" +#include "bb.h" + +#ifdef DOS +#include "devif.h" +#include "iopage.h" +extern DspInterface currentdsp; +extern IOPAGE *IOPage68K; +#endif + +extern int LispWindowFd; +extern int ScreenLocked; +extern int kbd_for_makeinit; + +#ifdef COLOR +extern int MonoOrColor; +#endif /* COLOR */ + + +/*****************************************************************************/ +/** **/ +/** N_OP_pilotbitblt **/ +/** **/ +/** The Native-code compatible version of the opcode for bitblt. **/ +/** **/ +/** **/ +/*****************************************************************************/ + + +LispPTR N_OP_pilotbitblt(pilot_bt_tbl, tos) + LispPTR pilot_bt_tbl; + int tos; + { + PILOTBBT *pbt; + DLword *srcbase, *dstbase; + int displayflg; + int sx, dx, w, h, srcbpl, dstbpl, backwardflg; + int src_comp, op, gray, num_gray, curr_gray_line; + +#ifdef INIT + + /* for init, we have to initialize the pointers at the + first call to pilotbitblt or we die. If we do it + earlier we die also. We set a new flag so we don't + do it more than once which is a lose also. + + I put this in an ifdef so there won't be any extra + code when making a regular LDE. */ + + if (!kbd_for_makeinit) + { + init_keyboard(0); + kbd_for_makeinit = 1; + }; + + +#endif + + pbt = (PILOTBBT *)Addr68k_from_LADDR(pilot_bt_tbl); + + w = pbt->pbtwidth; + h = pbt->pbtheight; + if ((h <= 0) || (w <= 0)) return(pilot_bt_tbl); + dx = pbt->pbtdestbit; + sx = pbt->pbtsourcebit; + backwardflg = pbt->pbtbackward; + /* if displayflg != 0 then source or destination is DisplayBitMap */ +#ifdef DOS + currentdsp->device.locked++; +#else + ScreenLocked = T; +#endif /* DOS */ + +#if SUNDISPLAY || DOS + displayflg = cursorin(pbt->pbtdesthi, (pbt->pbtdestlo + (dx >> 4)), + w, h, backwardflg) || + cursorin(pbt->pbtsourcehi, (pbt->pbtsourcelo + (sx >> 4)), + w, h, backwardflg); +#endif /* SUNDISPLAY */ + + + srcbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtsourcehi, + pbt->pbtsourcelo)); + dstbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtdesthi, + pbt->pbtdestlo )); + + srcbpl = pbt->pbtsourcebpl; + dstbpl = pbt->pbtdestbpl; + src_comp = pbt->pbtsourcetype; + op = pbt->pbtoperation; + gray = pbt->pbtusegray; + num_gray = ((TEXTUREBBT *)pbt)->pbtgrayheightlessone + 1; + curr_gray_line = ((TEXTUREBBT *)pbt)->pbtgrayoffset; + +#ifdef SUNDISPLAY + if( displayflg ) HideCursor; +#elif DOS + if( displayflg ) (currentdsp->mouse_invissible)( currentdsp, IOPage68K );; +#endif /* SUNDISPLAY / DOS */ + + + new_bitblt_code + +#ifdef SUNDISPLAY +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + if (in_display_segment(dstbase)) + flush_display_lineregion(dx, dstbase, w, h); +#endif + if( displayflg) ShowCursor; +#elif DOS + flush_display_lineregion(dx, dstbase, w, h); + if( displayflg) (currentdsp->mouse_vissible)( IOPage68K->dlmousex, + IOPage68K->dlmousey ); +#endif /* SUNDISPLAY / DOS */ + + +#ifdef XWINDOW + flush_display_lineregion(dx, dstbase, w, h); +#endif /* XWINDOW */ + + +#ifdef DOS + currentdsp->device.locked--; +#else + ScreenLocked = NIL; +#endif /* DOS */ + + return(pilot_bt_tbl); + + } /* end of N_OP_pilotbitblt */ + + + +/************************************************************************/ +/* */ +/* c u r s o r i n */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifndef COLOR +/* for MONO only */ +int cursorin (addrhi, addrlo, w, h, backward) + DLword addrhi; /* Lisp addr hi-word */ + DLword addrlo; /* Lisp addr lo-word */ + register int w, h; + { + register int x, y; + if (addrhi == DISPLAY_HI) + { + y = addrlo / DisplayRasterWidth; + x = (addrlo - y * DisplayRasterWidth) << 4; + } + else if (addrhi == DISPLAY_HI+1) + { + y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; + x = ((addrlo + DLWORDSPER_SEGMENT) - y * DisplayRasterWidth) << 4; + } + else return( NIL ); + + if(backward) y -= h; + + if((x < MOUSEXR)&&(x + w > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) + return( T ); + else return( NIL ); + } +#else + +/* for COLOR & MONO */ +int cursorin (addrhi, addrlo, w, h, backward) + DLword addrhi; /* Lisp addr hi-word */ + DLword addrlo; /* Lisp addr lo-word */ + register int w, h; + { + register int x, y; + register DLword *base68k; + extern int MonoOrColor; + extern int displaywidth; + extern DLword *ColorDisplayRegion68k; + + if(MonoOrColor == MONO_SCREEN) { /* On MONO screen */ + if (addrhi == DISPLAY_HI) + { + y = addrlo / DisplayRasterWidth; + x = (addrlo - y * DisplayRasterWidth) << 4; + } + else if (addrhi == DISPLAY_HI+1) + { + y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; + x = ((addrlo + DLWORDSPER_SEGMENT) - y * DisplayRasterWidth) << 4; + } + else return( NIL ); + + if(backward) y -= h; + + if((x < MOUSEXR)&&(x + w > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) + return( T ); + else + return( NIL ); + } + else { + base68k=(DLword*)Addr68k_from_LADDR(addrhi << 16 | addrlo); + if ((ColorDisplayRegion68k<=base68k) && + (base68k <= COLOR_MAX_Address)){ + y =(base68k - ColorDisplayRegion68k) /displaywidth ; + x = (UNSIGNED)(base68k - ColorDisplayRegion68k) -(y * displaywidth ); + /* printf("cursorin: IN COLOR mx=%d my=%d x=%d y%d w=%d h=%d\n" + ,*EmMouseX68K,*EmMouseY68K,x,y,w,h); */ + } + else return( NIL ); + + if(backward) y -= h; + + if((x < MOUSEXR)&&((x + (w >> 3)) > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) + { /* printf("cursorin T\n"); */ return( T );} + else + return( NIL ); + + } /* on COLOR screen */ + } +#endif /* COLOR */ diff --git a/src/blt.c b/src/blt.c new file mode 100755 index 0000000..1a808c3 --- /dev/null +++ b/src/blt.c @@ -0,0 +1,75 @@ +/* $Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/* + * + * Author : Takeshi Shimizu + * + */ +/******************************************************************/ +/* + File Name : blt.c + Including : OP_blt + + Created : jul 9, 1987 by T.Shimizu +*/ +/******************************************************************/ + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "stack.h" +#include "emlglob.h" +#include "lspglob.h" +#include "cell.h" + +/* + N_OP_blt takes 3 arguments. + STK-1 has destination's pointer. + STK has source's pointer. + TOS has number of words to be translated. +*/ + + +LispPTR N_OP_blt(LispPTR destptr, LispPTR sourceptr, register LispPTR wordcount) +{ + register DLword *source68k; + register DLword *dest68k ; + register int nw; + + if((wordcount & SEGMASK) != S_POSITIVE) ERROR_EXIT(wordcount); + nw = wordcount & 0xffff ; + + source68k = Addr68k_from_LADDR(sourceptr) + nw; + dest68k = Addr68k_from_LADDR(destptr) + nw; + + while(nw) { (GETWORD(--dest68k))= GETWORD(--source68k) ; nw--; } + + return(wordcount); + } /* end N_OP_blt */ + + + + diff --git a/src/box b/src/box new file mode 100755 index 0000000..183c002 --- /dev/null +++ b/src/box @@ -0,0 +1,6 @@ + + +/************************************************************************/ +/* */ +/* */ +/************************************************************************/ diff --git a/src/byteswap.c b/src/byteswap.c new file mode 100755 index 0000000..a76d67f --- /dev/null +++ b/src/byteswap.c @@ -0,0 +1,236 @@ +/* $Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/***************************************************************************/ +/* */ +/* byteswap.c */ +/* */ +/* Support functions for byte-swapped architecture machines */ +/* (e.g., 80386's) */ +/* */ +/***************************************************************************/ + + +#include "hdw_conf.h" +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "stack.h" + +#ifdef ISC +#include "inlnPS2.h" +#else + + + +/****************************************************************/ +/* */ +/* Byte-swap a single 2-byte word */ +/* (Name used for general-purpose byte swaps, rather */ +/* than for fixing up byte-swapped machines) */ +/* */ +/****************************************************************/ +unsigned int swapx(unsigned int word) +{ + return( ((word>>16)&0xffff)+((word&0xffff)<<16) ); + } + + +/****************************************************************/ +/* */ +/* Byte-swap a single 2-byte word */ +/* */ +/****************************************************************/ +unsigned short byte_swap_word(short unsigned int word) +{ + return( ((word>>8)&0xff)+((word&0xff)<<8) ); + } + + +/****************************************************************/ +/* */ +/* Word-swap a 2-word integer */ +/* Does NOT byte-swap the words themselves. */ +/* */ +/****************************************************************/ +/*** +unsigned int word_swap_longword(word) + unsigned int word; + { + return( ((word>>16)&0xffff)+((word&0xffff)<<16) ); + } ***/ +#ifndef I386 +#define word_swap_longword(word) ( ((word>>16)&0xffff)+((word&0xffff)<<16) ) +#endif +#endif /* AIXPS2 */ + + +/****************************************************************/ +/* */ +/* Byte-swap a region wordcount words long */ +/* This does NOT swap words in a long-word! */ +/* */ +/****************************************************************/ +byte_swap_page(short unsigned int *page, int wordcount) +{ + int i; + for (i = 0; i < wordcount; i++) + { + *(page+i) = byte_swap_word(*(page+i)); + } + } + +#ifndef GCC386 +/****************************************************************/ +/* */ +/* Byte- & word-swap a region wordcount long-words long */ +/* */ +/****************************************************************/ +void word_swap_page(short unsigned int *page, int longwordcount) +{ + register int i; + register unsigned int *longpage; + longpage = (unsigned int *) page; + for (i = 0; i < (longwordcount+longwordcount); i++) + { + *(page+i) = byte_swap_word(*(page+i)); + } + for (i = 0; i < longwordcount; i++) + { + *(longpage+i) = word_swap_longword(*(longpage+i)); + } + } +#endif /* GCC386 */ + + +/****************************************************************/ +/* */ +/* Bit-reverse all the words in a region */ +/* */ +/****************************************************************/ + + unsigned char reversedbits[256] = + { /* table of bytes with their bits reversed */ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, + }; + +/*unsigned short reverse_bits(word) + unsigned short word; + { + return ((reversedbits[(word>>8) & 0xFF] <<8) | reversedbits[word & 0xff]); + } +******/ +#define reverse_bits(word) ((reversedbits[((word)>>8) & 0xFF] <<8) | reversedbits[(word) & 0xff]) + +bit_reverse_region(register short unsigned int *top, int width, int height, int rasterwidth) +{ + register int i, j, wordwid = ((width+31)>>5)<<1; + register unsigned short *word; + + for (i = 0; i < height; i++) + { + word = top; + for (j = 0; j < wordwid; j++) + { + GETWORD(word+j) = reverse_bits(GETWORD(word+j)); + } + word_swap_page((unsigned short *)((UNSIGNED)word&0xFFFFFFFE), (wordwid+1)>>1); + top += rasterwidth; + } + + } + + + + +/************************************************************************/ +/* */ +/* b y t e _ s w a p _ c o d e _ b l o c k */ +/* */ +/* Byte-swap the opcodes in a piece of compiled code. This */ +/* can be used to make the compiled bytes be in machine-natural */ +/* order, so we can avoid pointer arithmetic on the PC in the */ +/* inner loop. The performance effect isn't yet known (2/92) */ +/* */ +/************************************************************************/ + +#ifdef RESWAPPEDDCODESTREAM +unsigned int byte_swap_code_block (unsigned int *base) +{ + UNSIGNED startpc, len; + + startpc = ((UNSIGNED)base) + ((struct fnhead *)base)->startpc; + len = code_block_size(base); + + word_swap_page((unsigned short *)startpc, (len+3)>>2); + + return (UNSIGNED)base; + + } /* end of byte_swap_code_block */ +#endif /* RESWAPPEDCODESTREAM */ diff --git a/src/call-c.c b/src/call-c.c new file mode 100755 index 0000000..f48e727 --- /dev/null +++ b/src/call-c.c @@ -0,0 +1,39 @@ +/* $Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* F O R E I G N - F U N C T I O N C A L L I N T E R F A C E */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#include "lispemul.h" + + +lispPTR call_c_fn(args); + { + void() *fn = args[0]; + (*fn)(); + return(NIL); + } diff --git a/src/car-cdr.c b/src/car-cdr.c new file mode 100755 index 0000000..4c4c120 --- /dev/null +++ b/src/car-cdr.c @@ -0,0 +1,738 @@ +/* $Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/***********************************************************************/ +/* + File Name : car-cdr.c + + Desc : car-cdr management + + Date : Apr 24, 1987 + Edited by : Naoyuki Mitani + + Including : car + cdr + rplaca + rplacd + OP_car + OP_cdr + OP_rplaca + OP_rplacd +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "emlglob.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "gc.h" +#include "cell.h" + + + +/************************************************************************/ +/* */ +/* c a r */ +/* */ +/* Returns CAR of its argument. Meant to be called from C. */ +/* */ +/************************************************************************/ + +LispPTR car(register LispPTR datum) + /* datum must be LISP pointer(word offset) */ + { + register ConsCell *datum68k; + register ConsCell *temp; + + datum68k = (ConsCell *)(Addr68k_from_LADDR(datum)); + if (Listp(datum)) + { + if (datum68k->cdr_code == CDR_INDIRECT) + { + temp = (ConsCell *)Addr68k_from_LADDR(datum68k->car_field); + return((LispPTR)temp->car_field); + } + else return((LispPTR)datum68k->car_field); + } + + else if (datum==NIL_PTR) return((LispPTR)NIL_PTR); + + else + { + if(datum == ATOM_T) return(ATOM_T); + + /** We assume CAR/CDRERR is CDR ***/ + else if ((datum & SEGMASK)==0) /* LITATOM */ + return(NIL); + else error("car : ARG not list"); + } + } /* end of car */ + + + + +/************************************************************************/ +/* */ +/* c d r */ +/* */ +/* Returns CDR of its argument. Meant to be called from C. */ +/* */ +/************************************************************************/ + +LispPTR cdr(register LispPTR datum) + /* datum must be LISP pointer(word offset) */ + { + register ConsCell *datum68k; + register DLword cdr_code; + register ConsCell *temp; + + datum68k = (ConsCell *)(Addr68k_from_LADDR(datum)); + cdr_code = datum68k->cdr_code; + + if (Listp(datum)) + { + if (cdr_code == CDR_NIL) return(NIL_PTR); /* cdr is nil */ + + else if ((cdr_code & CDR_ONPAGE) != 0) /* cdr-samepage */ +#ifdef NEWCDRCODING + return(datum + ((cdr_code & 7) << 1)); +#else + return(POINTER_PAGEBASE(datum) + ((cdr_code & 127) << 1)); +#endif /* NEWCDRCODING */ + else if (cdr_code == CDR_INDIRECT) /* cdr_code > CDR_ONPAGE */ + /* cdr-indirect */ + return(cdr ((LispPTR)(datum68k->car_field))); + + else + { + /* cdr isn't a CONS, but is stored on this page. */ +#ifdef NEWCDRCODING + temp = (ConsCell *)(Addr68k_from_LADDR + (datum + (cdr_code << 1))); +#else + temp = (ConsCell *)(Addr68k_from_LADDR + (POINTER_PAGEBASE(datum) + (cdr_code << 1))); +#endif /* NEWCDRCODING */ + return((LispPTR)temp->car_field); + } + } + else if (datum==NIL_PTR) return(NIL_PTR); + + /**** We assume CAR/CDRERR is CDR ****************/ + else error("cdr : ARG not list"); + + } /* end of cdr */ + + + +/**********************************************************************/ +/* + Func name : rplaca + + Called from C program. + + Date : Apr 15, 1987 + Edited by : Naoyuki Mitani +*/ +/**********************************************************************/ + +LispPTR rplaca(register LispPTR x, register LispPTR y) + /* car of x will be smashed */ + /* y is a newly car object */ + { + register ConsCell *x_68k; + register ConsCell *temp; + +#ifdef TRACE2 + printf("TRACE: rplaca()\n"); +#endif + + if (Listp(x) == NIL) + { /* arg isn't a CONS cell, might be NIL */ + if (x == NIL_PTR) + { + if (y != NIL_PTR) error("Attempt to RPLACA NIL"); + else return(NIL_PTR); + } + else error("ARG not List"); + } + + else + { + x_68k = (ConsCell *)Addr68k_from_LADDR(x); + + GCLOOKUP(car(x), DELREF); /* set up reference count */ + GCLOOKUP(y, ADDREF); + + if (x_68k->cdr_code == CDR_INDIRECT) + { + temp = (ConsCell *)Addr68k_from_LADDR((LispPTR)x_68k->car_field); + temp->car_field = y; + } + else x_68k->car_field = y; + + return(x); + } + } /* end of rplaca */ + + + + +/**********************************************************************/ +/* + Func name : rplacd + + Called from C program. + + Date : Apr 16, 1987 + Edited by : Naoyuki Mitani +*/ +/**********************************************************************/ +#ifdef NEWCDRCODING +ConsCell *find_cdrable_pair(LispPTR carpart, LispPTR cdrpart); /* below... */ +#endif +extern struct conspage *next_conspage(void); /* conspage.c */ + +LispPTR rplacd(LispPTR x, register LispPTR y) + /* cdr of x will be smashed */ + /* y is a newly cdr object */ + { + register ConsCell *x_68k; + register ConsCell *temp68k; + register ConsCell *cdr_cell68k; + LispPTR cdr_cell; + LispPTR rp_page; + DLword cdr_code; + register struct conspage *cons68k; + ConsCell * find_close_cell(struct conspage *page, LispPTR oldcell); + + if (Listp(x) == NIL) + { + if (x == NIL_PTR) + { + if (y != NIL_PTR) error("Attempt to RPLACD NIL"); + else return(NIL_PTR); + } + else error("ARG not List"); + } + + else + { + x_68k = (ConsCell *)Addr68k_from_LADDR(x); + + GCLOOKUP(cdr(x), DELREF); /* set up reference count */ + GCLOOKUP(y, ADDREF); + + cdr_code = x_68k->cdr_code; + + if (cdr_code == CDR_INDIRECT) + { + /* cdr-indirect */ + + rp_page = (LispPTR)x_68k->car_field; + temp68k = (ConsCell *)Addr68k_from_LADDR(rp_page); +#ifdef NEWCDRCODING + cdr_cell = (rp_page) + (temp68k->cdr_code << 1); +#else + cdr_cell = POINTER_PAGEBASE(rp_page) + + (temp68k->cdr_code << 1); +#endif /* NEWCDRCODING */ + + cdr_cell68k = (ConsCell *)Addr68k_from_LADDR(cdr_cell); + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code is set to 0 */ + } + else if (cdr_code <= CDR_MAXINDIRECT) + { + /* cdr-differentpage */ +#ifdef NEWCDRCODING + cdr_cell = x + (cdr_code << 1); +#else + cdr_cell = POINTER_PAGEBASE(x) + (cdr_code << 1); +#endif /* NEWCDRCODING */ + cdr_cell68k = (ConsCell *)Addr68k_from_LADDR(cdr_cell); + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code is set to 0 */ + + } + else if (y == NIL_PTR) + /* cdr-samepage & y is nil */ + x_68k->cdr_code = CDR_NIL; +#ifdef NEWCDRCODING + else if (((rp_page = POINTER_PAGEBASE(x)) == POINTER_PAGEBASE(y)) + && (y > x) && (y <= (x+14))) + /* cdr-samepage & x and y are on same page */ + x_68k->cdr_code = CDR_ONPAGE + ((y-x) >> 1); +#else + else if ((rp_page = POINTER_PAGEBASE(x)) == POINTER_PAGEBASE(y)) + /* cdr-samepage & x and y are on same page */ + x_68k->cdr_code = CDR_ONPAGE + ((y & 0xff) >> 1); +#endif /* NEWCDRCODING */ + else + { + /* cdr-samepage & x and y are on different page */ + + cons68k = (struct conspage *)(Addr68k_from_LADDR(rp_page)); +#ifdef NEWCDRCODING + if ((cons68k->count > 0) + && (cdr_cell68k = find_close_cell(cons68k, x))) + { + /* at least one free-cell on x's conspage */ + /* AND it's within CDR-code range of x. */ + + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ + + x_68k->cdr_code = (LADDR_from_68k(cdr_cell68k) - x) >> 1; + } +#else + if (cons68k->count > 0) + { + /* at least one free-cell on x's conspage */ + cdr_cell68k = GetNewCell_68k(cons68k); + cons68k->count--; + cons68k->next_cell = ((freecons *)cdr_cell68k)->next_free; + + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ + + x_68k->cdr_code = (LADDR_from_68k(cdr_cell68k) - + rp_page) >> 1; + } +#endif /* NEWCDRCODING */ + else + { + /* no more free-cell on x's conspage */ +#ifdef NEWCDRCODING + temp68k = (ConsCell *)find_cdrable_pair(x, y); + temp68k->car_field = x_68k->car_field; + x_68k->car_field = LADDR_from_68k(temp68k); + x_68k->cdr_code = CDR_INDIRECT; +#else + cons68k = next_conspage(); + + cdr_cell68k = GetNewCell_68k(cons68k); + cons68k->next_cell = ((freecons *)cdr_cell68k)->next_free; + temp68k = GetNewCell_68k(cons68k); + cons68k->next_cell = ((freecons *)temp68k)->next_free; + + cons68k->count -= 2; + + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ + + temp68k->car_field = x_68k->car_field; + x_68k->car_field = LADDR_from_68k(temp68k); + + temp68k->cdr_code = (LADDR_from_68k(cdr_cell68k) & 0xff) >> 1; + + x_68k->cdr_code = CDR_INDIRECT; +#endif /* NEWCDRCODING */ + } + } + } + return(x); + + }/* end of rplacd */ + + + + +/**********************************************************************/ +/* + Func name : N_OP_car + + car management + + Date : March 21, 1988 + Edited by : Robert Krivacic + +*/ +/**********************************************************************/ + +LispPTR N_OP_car(register LispPTR tos) +{ + register ConsCell *datum68k; + register ConsCell *temp; + + datum68k = (ConsCell *)(Addr68k_from_LADDR(tos)); + if (Listp(tos)) + { + if (datum68k->cdr_code == CDR_INDIRECT) + { + temp = (ConsCell *)Addr68k_from_LADDR(datum68k->car_field); + return((LispPTR) temp->car_field); + } + else return((LispPTR) datum68k->car_field); + } + else if (tos == NIL_PTR) return(tos); + else if ( tos == ATOM_T) return(tos); + else + { + ERROR_EXIT(tos); + } + } /* end of N_OP_car */ + + + + +/**********************************************************************/ +/* + Func name : N_OP_cdr + + cdr management + + Date : March 21, 1988 + Edited by : Robert Krivacic +*/ +/**********************************************************************/ + +LispPTR N_OP_cdr(register LispPTR tos) +{ + register ConsCell *datum68k; + register DLword cdr_code; + register ConsCell *temp; + + datum68k = (ConsCell *)(Addr68k_from_LADDR(tos)); + cdr_code = datum68k->cdr_code; + + if (Listp(tos)) + { + if (cdr_code == CDR_NIL) return(NIL_PTR); /* cdr-nil */ + + else if (cdr_code > CDR_ONPAGE) /* cdr-samepage */ +#ifdef NEWCDRCODING + return(tos + ((cdr_code & 7) << 1)); +#else + return(POINTER_PAGEBASE(tos) + ((cdr_code & 127) << 1)); +#endif /*NEWCDRCODING */ + else if (cdr_code == CDR_INDIRECT) /* cdr_code < CDR_ONPAGE */ + /* cdr-indirect */ + return(cdr ((LispPTR)(datum68k->car_field))); + + else + { + /* cdr-differentpage */ + +#ifdef NEWCDRCODING + return((LispPTR) + ((ConsCell *) + (Addr68k_from_LADDR + (tos+(cdr_code << 1))))->car_field); +#else + return((LispPTR) + ((ConsCell *) + (Addr68k_from_LADDR + (POINTER_PAGEBASE(tos)+(cdr_code << 1))))->car_field); +#endif /*NEWCDRCODING */ + } + } + else if (tos == NIL_PTR) return(tos); + else + { + ERROR_EXIT(tos); + } + + + } /* end of N_OP_cdr */ + + + + +/**********************************************************************/ +/* + + Func name : N_OP_rplaca + + rplaca management + + Date : March 21, 1988 + Edited by : Robert Krivacic +*/ +/**********************************************************************/ + +LispPTR N_OP_rplaca(register LispPTR tosm1, register LispPTR tos) +{ + register ConsCell *x_68k; + register ConsCell *temp; + + if (Listp(tosm1) == NIL) + { + if (tosm1 == NIL_PTR) + { + if (tos != NIL_PTR) ERROR_EXIT(tos) + else return(tosm1); + } + else ERROR_EXIT(tos); + } + + else + { + x_68k = (ConsCell *)Addr68k_from_LADDR(tosm1); + + GCLOOKUP(car(tosm1), DELREF); /* set up reference count */ + GCLOOKUP(tos, ADDREF); + + if (x_68k->cdr_code == CDR_INDIRECT) + { + temp = (ConsCell *)Addr68k_from_LADDR + ((LispPTR)x_68k->car_field); + temp->car_field = tos; + } + else x_68k->car_field = tos ; + + return(tosm1); + } + } /* end of N_OP_rplaca */ + + + + +/**********************************************************************/ +/* + Func name : N_OP_rplacd + + rplacd management + + Date : March 21, 1988 + Edited by : Robert Krivacic + + +*/ +/**********************************************************************/ + +LispPTR N_OP_rplacd(register LispPTR tosm1, register LispPTR tos) +{ + + if (Listp(tosm1) == NIL) + { + if (tosm1 == NIL_PTR) + { + if (tos != NIL_PTR) ERROR_EXIT(tos) + else return(tosm1); + } + else ERROR_EXIT(tos); + } + + else rplacd(tosm1, tos); + + return(tosm1); + + }/* end of N_OP_rplacd */ + + + +/************************************************************************/ +/* */ +/* f i n d _ c l o s e _ c e l l */ +/* */ +/* Given the real address of a CONS page and an existing cell */ +/* on that page, return another cell that is close enough to */ +/* be used as the CDR of the existing cell (i.e., within 7 */ +/* cells. If no such cell exists, return 0. */ +/* */ +/* If a cell is found, it is taken off the free chain before */ +/* being returned. */ +/* */ +/************************************************************************/ + +ConsCell * find_close_cell(struct conspage *page, LispPTR oldcell) +{ + unsigned oldoffset = oldcell & 0xFF; + unsigned offset = page->next_cell; + unsigned prior = 0; + + while (offset) + { + if ((offset > oldoffset) && (offset <= (oldoffset+14))) + { + if (prior) + ((freecons *) ((DLword *)page + prior))->next_free + = ((freecons *) ((DLword *)page + offset))->next_free; + else page->next_cell + = ((freecons *) ((DLword *)page + offset))->next_free; + page->count -= 1; + return(ConsCell *)((DLword *)page + offset); + } + + prior = offset; + offset = ((freecons *) ((DLword *)page + offset))->next_free; + } + return((ConsCell *)0); /* No cell close enough */ + } + + + +/************************************************************************/ +/* */ +/* f i n d _ c l o s e _ p r i o r _ c e l l */ +/* */ +/* Given the real address of a CONS page and an existing cell */ +/* on that page, return another cell that is close enough to */ +/* that the existing cell can be its CDR (i.e. up to 7 cells */ +/* earlier. If no such cell exists, return 0. */ +/* */ +/* If a cell is found, it is taken off the free chain before */ +/* being returned. */ +/* */ +/************************************************************************/ + +ConsCell * find_close_prior_cell(struct conspage *page, LispPTR oldcell) +{ + unsigned oldoffset = oldcell & 0xFF; + unsigned offset = page->next_cell; + unsigned prior = 0; + unsigned noffset, poffset; + unsigned nprior = 0; + ConsCell *cell; + + while (offset) + { + if ((offset < oldoffset) && (offset >= (oldoffset-14))) + { + poffset = offset; + noffset = FREECONS(page, offset)->next_free; + while ((noffset>offset) && (noffset < oldoffset)) + { + prior = offset; + offset = noffset; + noffset = FREECONS(page, offset)->next_free; + } + cell = (ConsCell *)((DLword *)page + offset); + if (prior) + FREECONS(page, prior)->next_free = + FREECONS(page,offset)->next_free; + else page->next_cell + = FREECONS(page,offset)->next_free; + page->count -= 1; + cell->cdr_code = CDR_ONPAGE | ((oldoffset - offset)>>1); + if (254 < (offset + ((cell->cdr_code&7)<<1))) error("in fcpc, page overflow."); + return(cell); + } + + prior = offset; + offset = ((freecons *) ((DLword *)page + offset))->next_free; + } + return((ConsCell *)0); /* No cell close enough */ + } + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +ConsCell *find_cdrpair_in_page(struct conspage *pg, LispPTR carpart, LispPTR cdrpart) +{ + ConsCell *cell; + unsigned offset, prior, priorprior, nprior, poffset, noffset; + + prior = priorprior = nprior = 0; + + if (pg->count < 2) return (ConsCell * ) 0; + + offset = pg->next_cell; + + while (offset) + { + if (prior && (offset < prior) && (prior <= offset+14)) + { + ConsCell *carcell, *cdrcell; + + poffset = offset; + noffset = FREECONS(pg, offset)->next_free; + while ((noffset>offset) && (noffset < prior)) + { + nprior = offset; + poffset = prior; + offset = noffset; + noffset = FREECONS(pg, offset)->next_free; + } + + carcell = (ConsCell *) (((DLword *)pg) + offset); + cdrcell = (ConsCell *) (((DLword *)pg) + prior); + if (priorprior) + FREECONS(pg, priorprior)->next_free = FREECONS(pg,poffset)->next_free; + else pg->next_cell = FREECONS(pg,poffset)->next_free; + + if (nprior) FREECONS(pg,nprior)->next_free = + FREECONS(pg,offset)->next_free; + + pg->count -= 2; + + *(LispPTR *)carcell = carpart; + *(LispPTR *)cdrcell = cdrpart; + + carcell->cdr_code = (cdrcell-carcell); + return(carcell); + } + else if (prior && (offset > prior) && (offset <= prior+14)) + { + ConsCell *carcell, *cdrcell; + + carcell = (ConsCell *) (((DLword *)pg) + prior); + cdrcell = (ConsCell *) (((DLword *)pg) + offset); + if (priorprior) + FREECONS(pg, priorprior)->next_free = ((freecons *)cdrcell)->next_free; + else pg->next_cell = ((freecons *)cdrcell)->next_free; + + pg->count -= 2; + + *(LispPTR *)carcell = carpart; + *(LispPTR *)cdrcell = cdrpart; + + carcell->cdr_code = (cdrcell-carcell); + return(carcell); + } + priorprior = prior; + prior = offset; + offset = FREECONS(pg, offset)->next_free; + } + + return(0); /* found no entries in this page, so return failure code */ + } + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +ConsCell *find_cdrable_pair(LispPTR carpart, LispPTR cdrpart) +{ + unsigned offset, prior, priorprior, pgno; + struct conspage *pg; + ConsCell *cell; + + for ( pg = (struct conspage *)Addr68k_from_LPAGE(pgno = ListpDTD->dtd_nextpage); + pgno; pg = (struct conspage *)Addr68k_from_LPAGE(pgno = pg->next_page)) + { + if (cell = find_cdrpair_in_page(pg, carpart, cdrpart)) return (cell); + } + + return (find_cdrpair_in_page(next_conspage(), carpart, cdrpart)); + } diff --git a/src/cdaudio.c b/src/cdaudio.c new file mode 100755 index 0000000..caf211b --- /dev/null +++ b/src/cdaudio.c @@ -0,0 +1,381 @@ +/* $Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/*********************************** + + file: cdaudio.c + +***********************************/ + +#include +#include +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "arith.h" +#include "cdrom.h" + + +int cdaudio(LispPTR *args) +{ + int request; + int res; + + + N_GETNUMBER(args[0], request, BAD_ARG); + +#ifdef DEBUG + printf("CD-ROM function called. function = %d\n",request); +#endif + + switch(request){ + case CD_OPEN: + res = cd_open(args); + break; + case CD_CLOSE: + res = cd_close(args); + break; + case CD_READ: + res = cd_read(args); + break; + case CD_DISK_INFO: + res = cd_disk_info(args); + break; + case CD_TRACK_INFO: + res = cd_track_info(args); + break; + case CD_START: + res = cd_start(args); + break; + case CD_STOP: + res = cd_stop(args); + break; + case CD_PLAY: + res = cd_play(args); + break; + case CD_Q_READ: + res = cd_q_read(args); + break; + case CD_PAUSE: + res = cd_pause(args); + break; + case CD_RESUME: + res = cd_resume(args); + break; + case CD_VOLUME: + res = cd_volume(args); + break; + case CD_EJECT: + res = cd_eject(args); + break; + default: + return(NIL); + break; + } +#ifdef DEBUG + printf( "Result = %d\n",res ); +#endif + if ( res == 0 ) { + return(ATOM_T); + } else { + return( GetSmallp(res) ); + } + + BAD_ARG: + return(NIL); +} + +int cd_open(LispPTR *args) + +/* + args[0] function number + args[1] CD-ROM drive path name string +*/ +{ + char drive[80]; + + LispStringToCString(args[1], drive, 80); +#ifdef DEBUG + printf( "cd_open called. drive = %s\n", drive ); +#endif + return( CDopen(drive) ); +} + +int cd_close(LispPTR *args) + +/* + args[0] function number +*/ +{ +#ifdef DEBUG + printf("cd_close is called\n"); +#endif + return( CDclose() ); +} + +int cd_read(LispPTR *args) + +/* + args[0] function number + args[1] Logical block number + args[2] number of blocks to read + args[3] data buffer +*/ +{ + DWORD blk; + int num; + BYTE *buf; + LispPTR *naddress; + char *base; + int offset; + + switch( GetTypeNumber(args[1]) ) { + case TYPE_SMALLP: + N_GETNUMBER( args[1], blk, BAD_ARG ); + break; + case TYPE_FIXP: + blk = *(DWORD *)(Addr68k_from_LADDR(args[1])); + break; + default: + return(1); + break; + } + switch( GetTypeNumber(args[2]) ) { + case TYPE_SMALLP: + N_GETNUMBER( args[2], num, BAD_ARG ); + break; + case TYPE_FIXP: + num = *(DWORD *)(Addr68k_from_LADDR(args[2])); + break; + default: + return(1); + break; + } + if (GetTypeNumber(args[3]) == TYPE_ONED_ARRAY ){ + naddress = (LispPTR *)(Addr68k_from_LADDR(args[3])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buf = base + offset; + } else + return(1); +#ifdef DEBUG + printf("call CDread()\n"); + printf("blk = %d, num = %d buff = %d\n",blk,num,buf); +#endif + return( CDread(blk, num, buf) ); + BAD_ARG: + return(1); +} + +int cd_disk_info(LispPTR *args) + +/* + args[0] function number + args[1] min tune number + args[2] max tune number +*/ +{ + BYTE min_no, max_no; + int res; + + res = CDdisk_info(&min_no, &max_no); +#ifdef DEBUG + printf( "min = %d, max = %d",min_no,max_no); +#endif + *(int *)(Addr68k_from_LADDR(args[1])) = (int)min_no; + *(int *)(Addr68k_from_LADDR(args[2])) = (int)max_no; + return(res); +} + +int cd_track_info(LispPTR *args) + +/* + args[0] function number (in: smallp) + args[1] tune number (in: fixp) + args[2] start address(LBN) (out: fixp) + args[3] control data (out: fixp) +*/ +{ + int tno; + DWORD blk; + BYTE cntl; + int res; + + switch( GetTypeNumber(args[1]) ) { + case TYPE_SMALLP: + N_GETNUMBER( args[1], tno, BAD_ARG ); + break; + case TYPE_FIXP: + tno = *(DWORD *)(Addr68k_from_LADDR(args[1])); + break; + } + res = CDtrack_info(tno, &blk, &cntl); + *(int *)(Addr68k_from_LADDR(args[2])) = (int)blk; + *(int *)(Addr68k_from_LADDR(args[3])) = (int)cntl; + return(res); + + BAD_ARG: + return( -1 ); +} + +int cd_start(LispPTR *args) + +/* + args[0] function number +*/ +{ + return( CDstart() ); +} + +int cd_stop(LispPTR *args) + +/* + args[0] function number +*/ +{ + return( CDstop() ); +} + +int cd_play(LispPTR *args) + +/* + args[0] function number + args[1] play start address(LBN) + args[2] play end address(LBN) +*/ +{ + DWORD sblk, eblk; + + switch( GetTypeNumber(args[1])) { + case TYPE_SMALLP: + N_GETNUMBER(args[1], sblk, BAD_ARG); + break; + case TYPE_FIXP: + sblk = *(DWORD *)(Addr68k_from_LADDR(args[1])); + break; + } + switch( GetTypeNumber(args[2])) { + case TYPE_SMALLP: + N_GETNUMBER(args[2], eblk, BAD_ARG); + break; + case TYPE_FIXP: + eblk = *(DWORD *)(Addr68k_from_LADDR(args[2])); + break; + } + return( CDplay(sblk, eblk) ); + + BAD_ARG: + return(1); +} + +int cd_q_read(LispPTR *args) + +/* + args[0] function number + args[1] audio status + args[2] tune number + args[3] current position min + args[4] current position sec + args[5] current position frame +*/ +{ + BYTE ast, tno, mm, ss, ff; + int res; + + res = CDqread(&ast, &tno, &mm, &ss, &ff); + if ( !res ) { + *(int *)(Addr68k_from_LADDR(args[1])) = (int)ast; + *(int *)(Addr68k_from_LADDR(args[2])) = (int)tno; + *(int *)(Addr68k_from_LADDR(args[3])) = (int)mm; + *(int *)(Addr68k_from_LADDR(args[4])) = (int)ss; + *(int *)(Addr68k_from_LADDR(args[5])) = (int)ff; + } + return(res); + + +} + +int cd_pause(LispPTR *args) + +/* + args[0] function number +*/ +{ + return( CDpause() ); +} + +int cd_resume(LispPTR *args) + +/* + args[0] function number +*/ +{ + return( CDresume() ); +} + +int cd_volume(LispPTR *args) + +/* + args[0] function number + args[1] right volume + args[2] left volume +*/ +{ + int right, left; + + switch( GetTypeNumber(args[1])) { + case TYPE_SMALLP: + N_GETNUMBER(args[1], right, BAD_ARG); + break; + case TYPE_FIXP: + right = *(DWORD *)(Addr68k_from_LADDR(args[1])); + break; + } + switch( GetTypeNumber(args[2])) { + case TYPE_SMALLP: + N_GETNUMBER(args[2], left, BAD_ARG); + break; + case TYPE_FIXP: + left = *(DWORD *)(Addr68k_from_LADDR(args[2])); + break; + } + return( CDvolume(right, left) ); + + BAD_ARG: + return(1); +} + +int cd_eject(LispPTR *args) + +/* + args[0] function number +*/ +{ +#ifdef DEBUG + printf( "cd_eject called.\n"); +#endif + return( CDeject() ); +} + + diff --git a/src/cdrom.c b/src/cdrom.c new file mode 100755 index 0000000..7b5349c --- /dev/null +++ b/src/cdrom.c @@ -0,0 +1,250 @@ +/* $Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/*********************************** + + file: cdrom.c + +***********************************/ + +#include +#include +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "arith.h" +#include "cdrom.h" + + +int cdrom(LispPTR *args) +{ + int request; + int res; + + + N_GETNUMBER(args[0], request, BAD_ARG); + +#ifdef DEBUG + printf("CD-ROM function called. function = %d\n",request); +#endif + + switch(request){ + case CDROM_INIT_DRV: + res = cdrom_init_drv(args); + break; + case CDROM_KEN_INT: + res = cdrom_ken_int(args); + break; + case CDROM_CHOSAKU: + res = cdrom_chosaku(args); + break; + case CDROM_MIKANA: + res = cdrom_mikana(args); + break; + case CDROM_MIKANAT: + res = cdrom_mikanat(args); + break; + case CDROM_SYURYO: + res = cdrom_syuryo(args); + break; + default: + return(NIL); + break; + } +#ifdef DEBUG + printf( "Result = %d\n",res ); +#endif + if ( res == 0 ) { + return(ATOM_T); + } else { + return( GetSmallp(res) ); + } + + BAD_ARG: + return(NIL); +} + +static int cdrom_init_drv(LispPTR *args) + +/* + args[0] function number + args[1] pointer to buffer + args[2] device name +*/ +{ + int res; + char *buff; + char drive[80]; + LispPTR *naddress; + char *base; + int offset; + + if (GetTypeNumber(args[1]) == TYPE_ONED_ARRAY ){ + naddress = (LispPTR *)(Addr68k_from_LADDR(args[1])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return(1); + LispStringToCString(args[2], drive, 80); + + return( init_drv(buff, drive) ); +} + + +static int cdrom_ken_int(LispPTR *args) + +/* + args[0] function number + args[1] shoseki number + args[2] flag for index and sort +*/ +{ + int bunno; + int flg; + + N_GETNUMBER(args[1], bunno, BAD_ARG); + N_GETNUMBER(args[2], flg, BAD_ARG); +#ifdef DEBUG + printf( "bunno = %x\n",bunno ); + printf( "flg = %d\n",flg ); +#endif + return( ken_int(bunno, flg) ); + + BAD_ARG: + return(1); +} + + +static int cdrom_chosaku(LispPTR *args) + +/* + args[0] function number + args[1] buffer for copy right data + args[2] real data size +*/ +{ + char *buff; + int size; + int *data_size; + LispPTR *naddress; + char *base; + int offset; + + if (GetTypeNumber(args[1]) == TYPE_ONED_ARRAY ){ + naddress = (LispPTR *)(Addr68k_from_LADDR(args[1])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return(1); + size = (int)(((OneDArray *)naddress)->totalsize); +#ifdef DEBUG + printf( "size = %d\n",size ); +#endif + data_size = (int *)(Addr68k_from_LADDR(args[2])); + return( chosaku(buff, size, data_size) ); +} + + +static int cdrom_mikana(LispPTR *args) + +/* + args[0] function number + args[1] relative id number + args[2] pointer to retrieve data + args[3] size of retrieve data +*/ +{ + int hyono; + char *buff; + int buff_size; + int *data_size; + LispPTR *naddress; + char *base; + int offset; + + + N_GETNUMBER(args[1], hyono, BAD_ARG); + if (GetTypeNumber(args[2]) == TYPE_ONED_ARRAY ){ + naddress = (LispPTR *)(Addr68k_from_LADDR(args[2])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return(1); + buff_size = (int)(((OneDArray *)naddress)->totalsize); + data_size = (int *)(Addr68k_from_LADDR(args[3])); + return( mikana(hyono, buff, buff_size, data_size) ); + + BAD_ARG: + return(1); +} + + +static int cdrom_mikanat(LispPTR *args) + +/* + args[0] function number + args[1] pointer to a search key + args[2] pointer to buffer + args[3] size of searched data + args[4] nuber of items matched to the search key +*/ +{ + char key[65]; + char *buff; + int buff_size; + int *data_size; + int *hitn; + LispPTR *naddress; + char *base; + int offset; + + + LispStringToCString2(args[1], key, 65); + if (GetTypeNumber(args[2]) == TYPE_ONED_ARRAY ){ + naddress = (LispPTR *)(Addr68k_from_LADDR(args[2])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return(1); + buff_size = (((OneDArray *)naddress)->totalsize); + data_size = (int *)(Addr68k_from_LADDR(args[3])); + hitn = (int *)(Addr68k_from_LADDR(args[4])); + + return( mikanat(key, buff, buff_size, data_size, hitn) ); +} + + +static int cdrom_syuryo(LispPTR *args) + +/* + args[0] function number +*/ +{ + return( syuryo() ); +} + diff --git a/src/chardev.c b/src/chardev.c new file mode 100755 index 0000000..37bc288 --- /dev/null +++ b/src/chardev.c @@ -0,0 +1,454 @@ +/* $Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/************************************************************************/ +/* */ +/* C H A R A C T E R - D E V I C E S U P P O R T */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifndef DOS +#include +#include +#include +#include +#include +#include +#ifndef OS5 +#include +#endif /* OS5 */ +#ifndef HPUX +#ifndef OS5 +#include +#endif /* OS5 */ +#endif /* HPUX */ +#include +#else /* DOS */ +#include +#endif /* DOS */ + +#include +#include +#include +#include + +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "timeout.h" +#include "locfile.h" +#include "osmsg.h" +#include "dbprint.h" + + +#ifdef ISC +#include +#endif + +extern int* Lisp_errno; +extern int Dummy_errno; + + + +/************************************************************************/ +/* */ +/* C H A R _ o p e n f i l e */ +/* */ +/* Given the arg vector */ +/* args[0] Lisp string full Unix file-name to open */ +/* args[1] Access to open it for (INPUT, OUTPUT, BOTH) */ +/* args[2] a FIXP cell to hold any Unix error number */ +/* */ +/* Open the file named, and return the SMALLP descriptor. If */ +/* the open fails, return NIL, and put the Unix error number */ +/* into the FIXP cell provided, for Lisp to look at. */ +/* */ +/************************************************************************/ + +CHAR_openfile(args) + register LispPTR *args; + /* args[0] fullname */ + /* args[1] access */ + /* args[2] errno */ + { +#ifndef DOS + register int id; /* return value of open system call. */ + register int flags; /* open system call's argument */ + register int rval; + register int linkflag =0; + register int *bufp; + struct stat statbuf; + char pathname[MAXPATHLEN]; + +#if (defined(RS6000) || defined(HPUX)) + static int one=1; /* Used in charopenfile, etc. */ +#endif + + + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + + LispStringToCString(args[0], pathname, MAXPATHLEN); + flags = O_NDELAY; + ERRSETJMP(NIL); +/* TIMEOUT( rval=stat(pathname, &statbuf) ); + if(rval == 0){ } */ + switch(args[1]) + { + case ACCESS_INPUT: + flags |= O_RDONLY; + break; + case ACCESS_OUTPUT: + flags |= (O_WRONLY | O_CREAT); + break; + case ACCESS_APPEND: + flags |= (O_APPEND | O_RDWR | O_CREAT); + break; + case ACCESS_BOTH: + flags |= (O_RDWR | O_CREAT); + break; + default: + return(NIL); + } + TIMEOUT( id=open(pathname, flags) ); + if(id == -1) + { + err_mess("open", errno); + *Lisp_errno = errno; + return(NIL); + } + /* Prevent I/O requests from blocking -- make them error */ + /* if no char is available, or there's no room in pipe. */ +#ifdef RS6000 + ioctl(id, FIONBIO, &one); + fcntl(id, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(id, FIOSNBIO, &one); +#else + rval = fcntl(id, F_GETFL, 0); + rval |= FNDELAY; + rval = fcntl(id, F_SETFL, rval); +#endif /* HPUX */ + +#endif /* RS6000 */ + + return(GetSmallp(id)); +#endif /* DOS */ + + } + + + +/************************************************************************/ +/* */ +/* C H A R _ c l o s e f i l e */ +/* */ +/* Given the arg vector: */ +/* args[0] The SMALLP file descriptor as returned by OPEN */ +/* args[1] a FIXP cell to hold any Unix error number */ +/* */ +/* Close the file identified by the descriptor. If the */ +/* close succeeds, return T. Otherwise, return NIL, and put */ +/* the Unix error number in the FIXP cell, for Lisp to see. */ +/* */ +/************************************************************************/ + +CHAR_closefile(args) + register LispPTR *args; + /* args[0] id */ + /* args[1] errno */ + { +#ifndef DOS + register int id; /* FileID */ + register int rval; + char pathname[MAXPATHLEN]; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); + id = LispNumToCInt(args[0]); + ERRSETJMP(NIL); + TIMEOUT( rval=close(id) ); + if( rval == -1) + { + /** This if is a patch for an apparent problem **/ + /** in SunOS 4 that causes a close on /dev/ttya **/ + /** to error with 'not owner' **/ + if (errno == 1) + { + DBPRINT(("Got errno 1 on a CLOSE!")); + return(ATOM_T); + } + DBPRINT(("Closing char device descriptor #%d.\n", id)); + err_mess("close", errno); + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); +#endif /* DOS */ + + } + + + +/************************************************************************/ +/* */ +/* C H A R _ i o c t l */ +/* */ +/* Given the arg vector: */ +/* args[0] the file descriptor to be acted on. */ +/* args[1] the IOCTL request code. */ +/* args[2] auxiliary data structure passed to IOCTL */ +/* args[3] a FIXP cell to contain any Unix error number */ +/* */ +/* Perform the IOCTL system call on the given file descriptor, */ +/* passing in the request code and auxiliary structure given. */ +/* If the IOCTL succeeds, return T (and the aux structure may */ +/* be side-effected). Otherwise, return NIL, and put the Unix */ +/* error number in the FIXP cell for Lisp to look at. */ +/* */ +/************************************************************************/ + +CHAR_ioctl(args) + LispPTR *args; + { +#ifndef DOS + int id, request, data; + register int rval; + char *base; + struct stat sbuf; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + id = LispNumToCInt(args[0]); + request = LispNumToCInt(args[1]); + data = (int)(Addr68k_from_LADDR(args[2])); + ERRSETJMP(NIL); + TIMEOUT(rval=ioctl(id, request, data)); + if(rval != 0) + { + err_mess("ioctl", errno); + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); +#endif /* DOS */ + +} + + + +/************************************************************************/ +/* */ +/* C H A R _ b i n */ +/* */ +/* Reads one character from the character file descriptor */ +/* id, and returns the value. If no character is available, */ +/* or an error happens, returns NIL and sets the errno FIXP */ +/* cell to the Unix error number. */ +/* */ +/************************************************************************/ + +CHAR_bin(id, errn) + register int id; + register LispPTR errn; + { +#ifndef DOS + register int rval, size; + unsigned char ch[4]; + Lisp_errno = (int *)(Addr68k_from_LADDR(errn)); + ERRSETJMP(NIL); + id = LispNumToCInt(id); + /* Read PAGE_SIZE bytes file contents from filepointer. */ + TIMEOUT( rval=read(id, ch, 1) ); + if ( rval == 0 ) + { + *Lisp_errno = EWOULDBLOCK; + return(NIL); + } + if ( rval == -1 ) + { + *Lisp_errno = errno; + return(NIL); + } + return(GetSmallp(ch[0])); +#endif /* DOS */ + + } + + + +/************************************************************************/ +/* */ +/* C H A R _ b o u t */ +/* */ +/* Write character ch to the character file descriptor id. If */ +/* the write works, return T; else return NIL and sets the FIXP */ +/* cell at errno to contain the Unix error number. */ +/* */ +/************************************************************************/ + +CHAR_bout(id, ch, errn) + register int id; + register LispPTR ch, errn; + { +#ifndef DOS + register int rval; + char buf[4]; + Lisp_errno = (int *)(Addr68k_from_LADDR(errn)); + ERRSETJMP(NIL); + id = LispNumToCInt(id); + buf[0] = LispNumToCInt(ch); + /* Write PAGE_SIZE bytes file contents from filepointer. */ + + TIMEOUT( rval=write(id, buf, 1) ); + + if (rval == -1) + { + *Lisp_errno = errno; + return(NIL); + } + if (rval == 0) + { + *Lisp_errno = EWOULDBLOCK; + return(NIL); + } + return(ATOM_T); +#endif /* DOS */ + + } + + +/************************************************************************/ +/* */ +/* C H A R _ b i n s */ +/* */ +/* Given the argument vector: */ +/* args[0] the file id to read bytes from */ +/* args[1] the base address of the buffer to read into */ +/* args[2] starting offset within the buffer to put bytes at */ +/* args[3] the number of bytes desired to read, maximum */ +/* args[4] a FIXP cell to hold the errno, if an error occurs */ +/* */ +/* Read up to the specified number of bytes into the buffer, */ +/* starting at the offset given. Return the number of bytes */ +/* actually read; will return if fewer bytes than desired are */ +/* read. If an error occurs in reading, return NIL, and put */ +/* the Unix errno into the FIXP cell given. EWOULDBLOCK is an */ +/* error that can occur--and bins returns NIL, so Lisp code has */ +/* to handle that case itself. */ +/* */ +/************************************************************************/ + +CHAR_bins(args) + register LispPTR *args; + { +#ifndef DOS + register int id, rval; + char *buffer; + int offset, nbytes; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); + ERRSETJMP(NIL); + id = LispNumToCInt(args[0]); + buffer = ((char *) (Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]); + nbytes = LispNumToCInt(args[3]); + /* Read PAGE_SIZE bytes file contents from filepointer. */ + TIMEOUT( rval=read(id, buffer, nbytes) ); + if ( rval == 0 ) + { + *Lisp_errno = EWOULDBLOCK; + return(NIL); + } + if ( rval == -1 ) + { + *Lisp_errno = errno; + return(NIL); + } + +#ifdef BYTESWAP + word_swap_page(buffer, (nbytes+3)>>2); +#endif /* BYTESWAP */ + + + return(GetSmallp(rval)); +#endif /* DOS */ + + } + + + +/************************************************************************/ +/* */ +/* C H A R _ b o u t s */ +/* */ +/* Given the argument vector: */ +/* args[0] the file id to write bytes to */ +/* args[1] the base address of the buffer to write from */ +/* args[2] starting offset within the buffer to gt bytes from */ +/* args[3] the number of bytes desired to write, maximum */ +/* args[4] a FIXP cell to hold the errno, if an error occurs */ +/* */ +/* write up to the specified number of bytes from the buffer, */ +/* starting at the offset given. Return the number of bytes */ +/* actually written; will return if fewer bytes than desired are */ +/* written. If an error occurs in writing, return NIL, and put */ +/* the Unix errno into the FIXP cell given. EWOULDBLOCK is an */ +/* error that can occur--and bins returns NIL, so Lisp code has */ +/* to handle that case itself. */ +/* */ +/************************************************************************/ + +CHAR_bouts(args) + register LispPTR *args; + { +#ifndef DOS + register int id, rval; + char *buffer; + int nbytes, offset; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); + ERRSETJMP(NIL); + id = LispNumToCInt(args[0]); + buffer = ((char *)(Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]); + nbytes = LispNumToCInt(args[3]); + /* Write PAGE_SIZE bytes file contents from filepointer. */ +#ifdef BYTESWAP + word_swap_page(buffer, (nbytes+3)>>2); +#endif /* BYTESWAP */ + + TIMEOUT( rval=write(id, buffer, nbytes) ); +#ifdef BYTESWAP + word_swap_page(buffer, (nbytes+3)>>2); +#endif /* BYTESWAP */ + + if (rval == -1) + { + *Lisp_errno = errno; + return(NIL); + } + if (rval == 0) + { + *Lisp_errno = EWOULDBLOCK; + return(NIL); + } + return(GetSmallp(rval)); +#endif /* DOS */ + + } diff --git a/src/chatter.c b/src/chatter.c new file mode 100755 index 0000000..971d27a --- /dev/null +++ b/src/chatter.c @@ -0,0 +1,249 @@ +/* $Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include +#include +#include +#include + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "arith.h" +#include "locfile.h" + +#define CHAR_MAXLEN 512 +#define BYTESIZE 256 + +int chatter_fd; + +#define LStringToCString(Lisp, C, MaxLen ,Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int i; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((UNSIGNED)Lisp)); \ + Len = min(MaxLen, arrayp->totalsize); \ + \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0;ibase))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(i=0;itypenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(id=0;idfillpointer = Len; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *) \ + (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(id=0;idfillpointer = Len; \ + break; \ + \ + default: \ + error("CStringToLString can not handle\n"); \ + } \ + } + +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + \ + base = (int *) Addr68k_from_LADDR((UNSIGNED)Lisp); \ + *base = C; \ + } + +chatter(args) + int args[]; +{ + int result; + int length; + int number; + unsigned char data[(CHAR_MAXLEN+1)*2]; + unsigned char tmp[(CHAR_MAXLEN+1)*2]; + + int i; + + N_GETNUMBER(args[0], number, ERROR); + switch (number) { + case 1: + LStringToCString(args[1], data, CHAR_MAXLEN,length); + result = chatter_open(data); + break; + + case 2: + result = chatter_close(); + break; + + case 3: + LStringToCString(args[1], data, CHAR_MAXLEN, length); + result = chatter_write_string(data , length); + break; + + case 4: + result = chatter_read(data,1); + number = data[0]; + IntToFixp(number, args[1]); + break; + + + case 5: + N_GETNUMBER(args[1], number, ERROR); + data[0] = number & 0xff; + result = chatter_write_code(data[0]); + break; + +ERROR: + result = 9999; + break; + } + + if (result == 0) + return (ATOM_T); + else + return(NIL); + +} + +chatter_open(dev) + char dev[]; +{ + struct termios termdata; + + if ((chatter_fd = open(dev, O_RDWR)) < 0) { + perror("CHATTER OPEN ERROR"); + return (-1); + } + if (ioctl(chatter_fd, TCGETS, &termdata) < 0) { + perror("CHATTER GET PARAMS ERROR"); + return (-1); + } + termdata.c_iflag &= ~IXON; + termdata.c_iflag &= ~IXANY; + termdata.c_iflag &= ~IXOFF; + + termdata.c_cflag &= ~CBAUD; + termdata.c_cflag |= B4800; + termdata.c_cflag &= ~CSIZE; + termdata.c_cflag |= CS8; + termdata.c_cflag &= ~CSTOPB; + termdata.c_cflag &= ~PARODD; + termdata.c_cflag &= ~CIBAUD; + + termdata.c_lflag = 0; + + termdata.c_cc[VMIN] = 256; + termdata.c_cc[VTIME] = 1; + + if (ioctl(chatter_fd, TCSETS, &termdata) < 0) { + perror("CHATTER SET PARAMS ERROR:"); + return (-1); + } + return (0); +} + +chatter_close() +{ + if (close(chatter_fd) < 0) { + perror("CHATTER CLOSE ERROR"); + return (-1); + } + return (0); +} + +chatter_write_string(data, len) + char data[]; + int len; +{ + if (write(chatter_fd, data, len) < 0) { + perror("WRITE ERROR"); + return (-1); + } + return (0); +} + +chatter_write_code(code) + unsigned char code; +{ + if (write(chatter_fd, &code, 1) < 0) { + perror("WRITE ERROR"); + return (-1); + } + return (0); +} + +chatter_read(data, len) + unsigned char *data; + int len; +{ + if (read(chatter_fd, data, len) < 0) { + perror("READ ERROR"); + return (-1); + } + return (0); +} diff --git a/src/codeconv.c b/src/codeconv.c new file mode 100755 index 0000000..049a65b --- /dev/null +++ b/src/codeconv.c @@ -0,0 +1,210 @@ +/* $Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/*************************************************/ +/* NSFatchar string <-> EUC character string */ +/* conversion program */ +/* file name : char_codes.c */ +/* 26,Jun,'89 */ +/* 5,Aug,'89 */ +/* by Shinichi Miyamoto */ +/* 10,Jan,'91 */ +/* 27,Feb,'91 */ +/* by Sumie Kurihara (FXIS) */ +/*************************************************/ + +#include + +#define EUCMASK 0x80 +#define EUCUNMASK 0x7F +#define MASK8BIT 0x00FF +#define TABLESIZE 256 + +int +FatcharNStoEUC(unsigned char *ns_ptr, int ns_len, unsigned char *euc_ptr) +{ + int i; + int euc_len; + unsigned short ns, euc; + unsigned short ns_euc(short unsigned int ns); + +#ifdef DEBUG + unsigned char *ptr; + ptr = euc_ptr; + printf("FatcharNStoEUC start\n"); + printf("ns_len = %d\n", ns_len); + for (i = 0; i < ns_len*2; i++) + printf("%x ", ns_ptr[i]); + printf("\n"); +#endif + + /* ns_len convert to byte count */ + ns_len *= 2; + + for (i = euc_len = 0; i < ns_len; i += 2) { + ns = *ns_ptr++ * TABLESIZE; + ns += *ns_ptr++; + euc = ns_euc(ns); + if (euc / TABLESIZE) { + /* 16 bit charactor */ + *euc_ptr++ = euc / TABLESIZE; + *euc_ptr++ = euc % TABLESIZE; + euc_len += 2; + } else { + /* ASCII charactor */ + *euc_ptr++ = euc % TABLESIZE; + ++euc_len; + } + } + + *euc_ptr++ = '\0'; + +#ifdef DEBUG + printf("FatcharNStoEUC end\n"); + printf("euc_len = %d\n", euc_len); + for (i = 0; i < euc_len; i++) + printf("%x ", ptr[i]); + printf("\n"); +#endif + + return (euc_len); +} + +int +ThincharNStoEUC(unsigned char *ns_ptr, int ns_len, unsigned char *euc_ptr) +{ + int i; + int euc_len = 0; + unsigned short ns, euc; + unsigned short ns_euc(short unsigned int ns); + +#ifdef DEBUG + unsigned char *ptr; + ptr = euc_ptr; + printf("ThincharNStoEUC start\n"); + printf("ns_len = %d\n", ns_len); + for (i = 0; i < ns_len; i++) + printf("%x ", ns_ptr[i]); + printf("\n"); +#endif + + /* ns_len convert to byte count */ + for (i = euc_len = 0; i < ns_len; i++) { + ns = *ns_ptr++; + euc = ns_euc(ns); + if (euc / TABLESIZE) { + /* 16 bit charactor */ + *euc_ptr++ = euc / TABLESIZE; + *euc_ptr++ = euc % TABLESIZE; + euc_len += 2; + } else { + /* ASCII charactor */ + *euc_ptr++ = euc % TABLESIZE; + ++euc_len; + } + } + + *euc_ptr++ = '\0'; + +#ifdef DEBUG + printf("ThincharNStoEUC end\n"); + printf("euc_len = %d\n", euc_len); + for (i = 0; i < euc_len; i++) + printf("%x ", ptr[i]); + printf("\n"); +#endif + + return (euc_len); +} + +int +EUCtoFatcharNS(unsigned char *euc_ptr, unsigned char *ns_ptr) +{ + int i; + int ns_len; + unsigned short euc, ns; + unsigned short euc_ns(short unsigned int euc); + +#ifdef DEBUG + printf("EUCtoFatcharNS start\n"); + for (i = 0; i < strlen(euc_ptr); i++) + printf("%x ", euc_ptr[i]); + printf("\n"); +#endif + + i = 0; + while (euc = *euc_ptr++) { + if (euc & EUCMASK) { + /* 16 bit charactor */ + euc *= TABLESIZE; + euc += *euc_ptr++; + } + + ns = euc_ns(euc); + + ns_ptr[i++] = ns / TABLESIZE; + ns_ptr[i++] = ns % TABLESIZE; + } + ns_len = i / 2; + +#ifdef DEBUG + printf("EUCtoFatcharNS end\n"); + printf("ns_len = %d\n", ns_len); + for (i = 0; i < ns_len*2; i++) + printf("%x ", ns_ptr[i]); + printf("\n"); +#endif + + return (ns_len); +} + +int +EUCstrlen(char *euc_ptr) +{ + int len = 0; + +#ifdef DEBUG + int i; + + printf("EUCstrlen start\n"); + for (i = 0; i < strlen(euc_ptr); i++) + printf("%x ", euc_ptr[i]); + printf("\n"); +#endif + + while (*euc_ptr) + if (*euc_ptr & EUCMASK) { + /* 16 bit charactor */ + len += 2; + *euc_ptr++; + *euc_ptr++; + } else { + /* ASCII charactor */ + len++; + *euc_ptr++; + } + +#ifdef DEBUG + printf("EUCstrlen end\n"); + printf("len = %d\n", len); +#endif + + return (len); +} diff --git a/src/codetbl.c b/src/codetbl.c new file mode 100755 index 0000000..3a62dae --- /dev/null +++ b/src/codetbl.c @@ -0,0 +1,582 @@ +/* $Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/***************************************************/ +/* NS <-> EUC character code converstion program */ +/* file name : nstables.c */ +/* function : ns_euc --- NS to EUC conversion */ +/* : euc_ns --- EUC to NS */ +/* 5, Aug '89 */ +/* by Shinichi Miyamoto */ +/* */ +/* 11,May '90 : table data update by Miyamoto */ +/* 15,May '90 : table data update by Miyamoto */ +/***************************************************/ + +#define TABLESIZE 256 +#define EUCBITS 0x8080 +#define NSBITS 0x7F7F + +static unsigned short eucA1[TABLESIZE] = { + 41216, 41217, 41218, 41219, 41220, 41221, 41222, 41223, + 41224, 41225, 41226, 41227, 41228, 41229, 41230, 41231, + 41232, 41233, 41234, 41235, 41236, 41237, 41238, 41239, + 41240, 41241, 41242, 41243, 41244, 41245, 41246, 41247, + 41248, 41249, 41250, 41251, 41252, 41253, 41254, 41255, + 41256, 41257, 41258, 41259, 41260, 41261, 41262, 41263, + 41264, 41265, 41266, 41267, 41268, 41269, 41270, 41271, + 41272, 41273, 41274, 41275, 41276, 41277, 41278, 41279, + 41280, 41281, 41282, 41283, 41284, 41285, 41286, 41287, + 41288, 41289, 41290, 41291, 41292, 41293, 41294, 41295, + 41296, 41297, 41298, 41299, 41300, 41301, 41302, 41303, + 41304, 41305, 41306, 41307, 41308, 41309, 41310, 41311, + 41312, 41313, 41314, 41315, 41316, 41317, 41318, 41319, + 41320, 41321, 41322, 41323, 41324, 41325, 41326, 41327, + 41328, 41329, 41330, 41331, 41332, 41333, 41334, 41335, + 41336, 41337, 41338, 41339, 41340, 41341, 41342, 41343, + 41344, 41345, 41346, 41347, 41348, 41349, 41350, 41351, + 41352, 41353, 41354, 41355, 41356, 41357, 41358, 41359, + 41360, 41361, 41362, 41363, 41364, 41365, 41366, 41367, + 41368, 41369, 41370, 41371, 41372, 41373, 41374, 41375, + 41376, 8481, 8482, 8483, 44, 46, 183, 58, + 59, 63, 33, 8491, 8492, 194, 193, 200, + 195, 9155, 204, 8499, 8500, 8501, 8502, 8503, + 8504, 8505, 8506, 8507, 8508, 61220, 8510, 47, + 92, 126, 8514, 124, 8516, 8517, 169, 39, + 170, 186, 40, 41, 8524, 8525, 91, 93, + 123, 125, 61234, 61235, 171, 187, 8534, 8535, + 8536, 8537, 8538, 8539, 43, 45, 177, 180, + 184, 61, 8546, 60, 62, 8549, 8550, 8551, + 8552, 8553, 8554, 176, 8556, 8557, 8558, 165, + 164, 162, 163, 37, 35, 38, 42, 64, + 167, 8569, 8570, 8571, 8572, 8573, 8574, 41471 +}; + +static unsigned short eucA2[TABLESIZE] = { + 41472, 41473, 41474, 41475, 41476, 41477, 41478, 41479, + 41480, 41481, 41482, 41483, 41484, 41485, 41486, 41487, + 41488, 41489, 41490, 41491, 41492, 41493, 41494, 41495, + 41496, 41497, 41498, 41499, 41500, 41501, 41502, 41503, + 41504, 41505, 41506, 41507, 41508, 41509, 41510, 41511, + 41512, 41513, 41514, 41515, 41516, 41517, 41518, 41519, + 41520, 41521, 41522, 41523, 41524, 41525, 41526, 41527, + 41528, 41529, 41530, 41531, 41532, 41533, 41534, 41535, + 41536, 41537, 41538, 41539, 41540, 41541, 41542, 41543, + 41544, 41545, 41546, 41547, 41548, 41549, 41550, 41551, + 41552, 41553, 41554, 41555, 41556, 41557, 41558, 41559, + 41560, 41561, 41562, 41563, 41564, 41565, 41566, 41567, + 41568, 41569, 41570, 41571, 41572, 41573, 41574, 41575, + 41576, 41577, 41578, 41579, 41580, 41581, 41582, 41583, + 41584, 41585, 41586, 41587, 41588, 41589, 41590, 41591, + 41592, 41593, 41594, 41595, 41596, 41597, 41598, 41599, + 41600, 41601, 41602, 41603, 41604, 41605, 41606, 41607, + 41608, 41609, 41610, 41611, 41612, 41613, 41614, 41615, + 41616, 41617, 41618, 41619, 41620, 41621, 41622, 41623, + 41624, 41625, 41626, 41627, 41628, 41629, 41630, 41631, + 41632, 8737, 8738, 8739, 8740, 8741, 8742, 8743, + 8744, 8745, 174, 172, 173, 175, 8750, 8751, + 8752, 8753, 8754, 8755, 8756, 8757, 8758, 8759, + 8760, 8761, 61258, 61260, 61273, 61272, 61275, 61274, + 61271, 61270, 8770, 8771, 8772, 8773, 8774, 8775, + 8776, 8777, 61366, 61367, 61290, 61263, 61262, 61365, + 61364, 8785, 8786, 8787, 8788, 8789, 8790, 8791, + 8792, 8793, 8794, 8795, 61292, 61296, 61376, 61370, + 61369, 61298, 8802, 61250, 61251, 61308, 64894, 61297, + 61295, 61301, 8810, 8811, 8812, 8813, 8814, 8815, + 8816, 8817, 61736, 61249, 9148, 9132, 213, 61232, + 61233, 182, 8826, 8827, 8828, 8829, 8830, 41727 +}; + +static unsigned short eucA3[TABLESIZE] = { + 41728, 41729, 41730, 41731, 41732, 41733, 41734, 41735, + 41736, 41737, 41738, 41739, 41740, 41741, 41742, 41743, + 41744, 41745, 41746, 41747, 41748, 41749, 41750, 41751, + 41752, 41753, 41754, 41755, 41756, 41757, 41758, 41759, + 41760, 41761, 41762, 41763, 41764, 41765, 41766, 41767, + 41768, 41769, 41770, 41771, 41772, 41773, 41774, 41775, + 41776, 41777, 41778, 41779, 41780, 41781, 41782, 41783, + 41784, 41785, 41786, 41787, 41788, 41789, 41790, 41791, + 41792, 41793, 41794, 41795, 41796, 41797, 41798, 41799, + 41800, 41801, 41802, 41803, 41804, 41805, 41806, 41807, + 41808, 41809, 41810, 41811, 41812, 41813, 41814, 41815, + 41816, 41817, 41818, 41819, 41820, 41821, 41822, 41823, + 41824, 41825, 41826, 41827, 41828, 41829, 41830, 41831, + 41832, 41833, 41834, 41835, 41836, 41837, 41838, 41839, + 41840, 41841, 41842, 41843, 41844, 41845, 41846, 41847, + 41848, 41849, 41850, 41851, 41852, 41853, 41854, 41855, + 41856, 41857, 41858, 41859, 41860, 41861, 41862, 41863, + 41864, 41865, 41866, 41867, 41868, 41869, 41870, 41871, + 41872, 41873, 41874, 41875, 41876, 41877, 41878, 41879, + 41880, 41881, 41882, 41883, 41884, 41885, 41886, 41887, + 41888, 8993, 8994, 8995, 8996, 8997, 8998, 8999, + 9000, 9001, 9002, 9003, 9004, 9005, 9006, 9007, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 9018, 9019, 9020, 9021, 9022, 9023, + 9024, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 9051, 9052, 9053, 9054, 9055, + 9056, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 9083, 9084, 9085, 9086, 41983 +}; + +static unsigned short eucA6[TABLESIZE] = { + 42496, 42497, 42498, 42499, 42500, 42501, 42502, 42503, + 42504, 42505, 42506, 42507, 42508, 42509, 42510, 42511, + 42512, 42513, 42514, 42515, 42516, 42517, 42518, 42519, + 42520, 42521, 42522, 42523, 42524, 42525, 42526, 42527, + 42528, 42529, 42530, 42531, 42532, 42533, 42534, 42535, + 42536, 42537, 42538, 42539, 42540, 42541, 42542, 42543, + 42544, 42545, 42546, 42547, 42548, 42549, 42550, 42551, + 42552, 42553, 42554, 42555, 42556, 42557, 42558, 42559, + 42560, 42561, 42562, 42563, 42564, 42565, 42566, 42567, + 42568, 42569, 42570, 42571, 42572, 42573, 42574, 42575, + 42576, 42577, 42578, 42579, 42580, 42581, 42582, 42583, + 42584, 42585, 42586, 42587, 42588, 42589, 42590, 42591, + 42592, 42593, 42594, 42595, 42596, 42597, 42598, 42599, + 42600, 42601, 42602, 42603, 42604, 42605, 42606, 42607, + 42608, 42609, 42610, 42611, 42612, 42613, 42614, 42615, + 42616, 42617, 42618, 42619, 42620, 42621, 42622, 42623, + 42624, 42625, 42626, 42627, 42628, 42629, 42630, 42631, + 42632, 42633, 42634, 42635, 42636, 42637, 42638, 42639, + 42640, 42641, 42642, 42643, 42644, 42645, 42646, 42647, + 42648, 42649, 42650, 42651, 42652, 42653, 42654, 42655, + 42656, 9793, 9794, 9796, 9797, 9798, 9801, 9802, + 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, + 9811, 9813, 9814, 9816, 9817, 9818, 9819, 9820, + 9821, 9785, 9786, 9787, 9788, 9789, 9790, 9791, + 9792, 9825, 9826, 9828, 9829, 9830, 9833, 9834, + 9835, 9836, 9837, 9838, 9839, 9840, 9841, 9842, + 9843, 9845, 9846, 9848, 9849, 9850, 9851, 9852, + 9853, 42713, 42714, 42715, 42716, 42717, 42718, 42719, + 42720, 42721, 42722, 42723, 42724, 42725, 42726, 42727, + 42728, 42729, 42730, 42731, 42732, 42733, 42734, 42735, + 42736, 42737, 42738, 42739, 42740, 42741, 42742, 42743, + 42744, 42745, 42746, 42747, 42748, 42749, 42750, 42751 +}; + +static unsigned short eucA8[TABLESIZE] = { + 43008, 43009, 43010, 43011, 43012, 43013, 43014, 43015, + 43016, 43017, 43018, 43019, 43020, 43021, 43022, 43023, + 43024, 43025, 43026, 43027, 43028, 43029, 43030, 43031, + 43032, 43033, 43034, 43035, 43036, 43037, 43038, 43039, + 43040, 43041, 43042, 43043, 43044, 43045, 43046, 43047, + 43048, 43049, 43050, 43051, 43052, 43053, 43054, 43055, + 43056, 43057, 43058, 43059, 43060, 43061, 43062, 43063, + 43064, 43065, 43066, 43067, 43068, 43069, 43070, 43071, + 43072, 43073, 43074, 43075, 43076, 43077, 43078, 43079, + 43080, 43081, 43082, 43083, 43084, 43085, 43086, 43087, + 43088, 43089, 43090, 43091, 43092, 43093, 43094, 43095, + 43096, 43097, 43098, 43099, 43100, 43101, 43102, 43103, + 43104, 43105, 43106, 43107, 43108, 43109, 43110, 43111, + 43112, 43113, 43114, 43115, 43116, 43117, 43118, 43119, + 43120, 43121, 43122, 43123, 43124, 43125, 43126, 43127, + 43128, 43129, 43130, 43131, 43132, 43133, 43134, 43135, + 43136, 43137, 43138, 43139, 43140, 43141, 43142, 43143, + 43144, 43145, 43146, 43147, 43148, 43149, 43150, 43151, + 43152, 43153, 43154, 43155, 43156, 43157, 43158, 43159, + 43160, 43161, 43162, 43163, 43164, 43165, 43166, 43167, + 43168, 61413, 61412, 10275, 10276, 10277, 10278, 10279, + 10280, 10281, 10282, 61414, 61410, 61409, 10286, 10287, + 10288, 10289, 10290, 10291, 10292, 10293, 61411, 10295, + 10296, 10297, 10298, 10299, 10300, 10301, 10302, 10303, + 10304, 43201, 43202, 43203, 43204, 43205, 43206, 43207, + 43208, 43209, 43210, 43211, 43212, 43213, 43214, 43215, + 43216, 43217, 43218, 43219, 43220, 43221, 43222, 43223, + 43224, 43225, 43226, 43227, 43228, 43229, 43230, 43231, + 43232, 43233, 43234, 43235, 43236, 43237, 43238, 43239, + 43240, 43241, 43242, 43243, 43244, 43245, 43246, 43247, + 43248, 43249, 43250, 43251, 43252, 43253, 43254, 43255, + 43256, 43257, 43258, 43259, 43260, 43261, 43262, 43263 +}; + + +static unsigned short eucF4[TABLESIZE] = { + 62464, 62465, 62466, 62467, 62468, 62469, 62470, 62471, + 62472, 62473, 62474, 62475, 62476, 62477, 62478, 62479, + 62480, 62481, 62482, 62483, 62484, 62485, 62486, 62487, + 62488, 62489, 62490, 62491, 62492, 62493, 62494, 62495, + 62496, 62497, 62498, 62499, 62500, 62501, 62502, 62503, + 62504, 62505, 62506, 62507, 62508, 62509, 62510, 62511, + 62512, 62513, 62514, 62515, 62516, 62517, 62518, 62519, + 62520, 62521, 62522, 62523, 62524, 62525, 62526, 62527, + 62528, 62529, 62530, 62531, 62532, 62533, 62534, 62535, + 62536, 62537, 62538, 62539, 62540, 62541, 62542, 62543, + 62544, 62545, 62546, 62547, 62548, 62549, 62550, 62551, + 62552, 62553, 62554, 62555, 62556, 62557, 62558, 62559, + 62560, 62561, 62562, 62563, 62564, 62565, 62566, 62567, + 62568, 62569, 62570, 62571, 62572, 62573, 62574, 62575, + 62576, 62577, 62578, 62579, 62580, 62581, 62582, 62583, + 62584, 62585, 62586, 62587, 62588, 62589, 62590, 62591, + 62592, 62593, 62594, 62595, 62596, 62597, 62598, 62599, + 62600, 62601, 62602, 62603, 62604, 62605, 62606, 62607, + 62608, 62609, 62610, 62611, 62612, 62613, 62614, 62615, + 62616, 62617, 62618, 62619, 62620, 62621, 62622, 62623, + 62624, 29985, 29986, 29987, 29988, 62629, 62630, 62631, + 62632, 62633, 62634, 62635, 62636, 62637, 62638, 62639, + 62640, 62641, 62642, 62643, 62644, 62645, 62646, 62647, + 62648, 62649, 62650, 62651, 62652, 62653, 62654, 62655, + 62656, 62657, 62658, 62659, 62660, 62661, 62662, 62663, + 62664, 62665, 62666, 62667, 62668, 62669, 62670, 62671, + 62672, 62673, 62674, 62675, 62676, 62677, 62678, 62679, + 62680, 62681, 62682, 62683, 62684, 62685, 62686, 62687, + 62688, 62689, 62690, 62691, 62692, 62693, 62694, 62695, + 62696, 62697, 62698, 62699, 62700, 62701, 62702, 62703, + 62704, 62705, 62706, 62707, 62708, 62709, 62710, 62711, + 62712, 62713, 62714, 62715, 62716, 62717, 62718, 62719 +}; + + + +/* initializeNSToeucConversionTables */ + +static unsigned short ns00[TABLESIZE] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 41904, 41905, 41906, 41907, 41908, 41909, 41910, 41911, + 41912, 41913, 58, 59, 60, 61, 62, 63, + 64, 41921, 41922, 41923, 41924, 41925, 41926, 41927, + 41928, 41929, 41930, 41931, 41932, 41933, 41934, 41935, + 41936, 41937, 41938, 41939, 41940, 41941, 41942, 41943, + 41944, 41945, 41946, 91, 92, 93, 94, 95, + 96, 41953, 41954, 41955, 41956, 41957, 41958, 41959, + 41960, 41961, 41962, 41963, 41964, 41965, 41966, 41967, + 41968, 41969, 41970, 41971, 41972, 41973, 41974, 41975, + 41976, 41977, 41978, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, + 144, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 41457, 41458, 41456, 41455, 166, 41464, + 168, 41414, 41416, 41428, 41643, 41644, 41642, 41645, + 41451, 41438, 178, 179, 41439, 181, 41721, 41382, + 41440, 41415, 41417, 41429, 188, 189, 190, 191, + 192, 41390, 41389, 41392, 196, 197, 198, 199, + 41391, 201, 202, 203, 41394, 205, 206, 207, + 208, 209, 210, 211, 212, 41718, 214, 215, + 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, 230, 231, + 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, + 248, 249, 250, 251, 252, 253, 254, 255 +}; + +static unsigned short ns23[TABLESIZE] = { + 8960, 8961, 8962, 8963, 8964, 8965, 8966, 8967, + 8968, 8969, 8970, 8971, 8972, 8973, 8974, 8975, + 8976, 8977, 8978, 8979, 8980, 8981, 8982, 8983, + 8984, 8985, 8986, 8987, 8988, 8989, 8990, 8991, + 8992, 8993, 8994, 8995, 8996, 8997, 8998, 8999, + 9000, 9001, 9002, 9003, 9004, 9005, 9006, 9007, + 9008, 9009, 9010, 9011, 9012, 9013, 9014, 9015, + 9016, 9017, 9018, 9019, 9020, 9021, 9022, 9023, + 9024, 9025, 9026, 9027, 9028, 9029, 9030, 9031, + 9032, 9033, 9034, 9035, 9036, 9037, 9038, 9039, + 9040, 9041, 9042, 9043, 9044, 9045, 9046, 9047, + 9048, 9049, 9050, 9051, 9052, 9053, 9054, 9055, + 9056, 9057, 9058, 9059, 9060, 9061, 9062, 9063, + 9064, 9065, 9066, 9067, 9068, 9069, 9070, 9071, + 9072, 9073, 9074, 9075, 9076, 9077, 9078, 9079, + 9080, 9081, 9082, 9083, 9084, 9085, 9086, 9087, + 9088, 9089, 9090, 9091, 9092, 9093, 9094, 9095, + 9096, 9097, 9098, 9099, 9100, 9101, 9102, 9103, + 9104, 9105, 9106, 9107, 9108, 9109, 9110, 9111, + 9112, 9113, 9114, 9115, 9116, 9117, 9118, 9119, + 9120, 9121, 9122, 9123, 9124, 9125, 9126, 9127, + 9128, 9129, 9130, 9131, 41717, 9133, 9134, 9135, + 9136, 9137, 9138, 9139, 9140, 9141, 9142, 9143, + 9144, 9145, 9146, 9147, 41716, 9149, 9150, 9151, + 9152, 9153, 9154, 41393, 9156, 9157, 9158, 9159, + 9160, 9161, 9162, 9163, 9164, 9165, 9166, 9167, + 9168, 9169, 9170, 9171, 9172, 9173, 9174, 9175, + 9176, 9177, 9178, 9179, 9180, 9181, 9182, 9183, + 9184, 9185, 9186, 9187, 9188, 9189, 9190, 9191, + 9192, 9193, 9194, 9195, 9196, 9197, 9198, 9199, + 9200, 9201, 9202, 9203, 9204, 9205, 9206, 9207, + 9208, 9209, 9210, 9211, 9212, 9213, 9214, 9215 +}; + +static unsigned short ns26[TABLESIZE] = { + 9728, 9729, 9730, 9731, 9732, 9733, 9734, 9735, + 9736, 9737, 9738, 9739, 9740, 9741, 9742, 9743, + 9744, 9745, 9746, 9747, 9748, 9749, 9750, 9751, + 9752, 9753, 9754, 9755, 9756, 9757, 9758, 9759, + 9760, 9761, 9762, 9763, 9764, 9765, 9766, 9767, + 9768, 9769, 9770, 9771, 9772, 9773, 9774, 9775, + 9776, 9777, 9778, 9779, 9780, 9781, 9782, 9783, + 9784, 42681, 42682, 42683, 42684, 42685, 42686, 42687, + 42688, 42657, 42658, 9795, 42659, 42660, 42661, 9799, + 9800, 42662, 42663, 42664, 42665, 42666, 42667, 42668, + 42669, 42670, 42671, 42672, 9812, 42673, 42674, 9815, + 42675, 42676, 42677, 42678, 42679, 42680, 9822, 9823, + 9824, 42689, 42690, 9827, 42691, 42692, 42693, 9831, + 9832, 42694, 42695, 42696, 42697, 42698, 42699, 42700, + 42701, 42702, 42703, 42704, 9844, 42705, 42706, 9847, + 42707, 42708, 42709, 42710, 42711, 42712, 9854, 9855, + 9856, 9857, 9858, 9859, 9860, 9861, 9862, 9863, + 9864, 9865, 9866, 9867, 9868, 9869, 9870, 9871, + 9872, 9873, 9874, 9875, 9876, 9877, 9878, 9879, + 9880, 9881, 9882, 9883, 9884, 9885, 9886, 9887, + 9888, 9889, 9890, 9891, 9892, 9893, 9894, 9895, + 9896, 9897, 9898, 9899, 9900, 9901, 9902, 9903, + 9904, 9905, 9906, 9907, 9908, 9909, 9910, 9911, + 9912, 9913, 9914, 9915, 9916, 9917, 9918, 9919, + 9920, 9921, 9922, 9923, 9924, 9925, 9926, 9927, + 9928, 9929, 9930, 9931, 9932, 9933, 9934, 9935, + 9936, 9937, 9938, 9939, 9940, 9941, 9942, 9943, + 9944, 9945, 9946, 9947, 9948, 9949, 9950, 9951, + 9952, 9953, 9954, 9955, 9956, 9957, 9958, 9959, + 9960, 9961, 9962, 9963, 9964, 9965, 9966, 9967, + 9968, 9969, 9970, 9971, 9972, 9973, 9974, 9975, + 9976, 9977, 9978, 9979, 9980, 9981, 9982, 9983 +}; + +static unsigned short ns75[TABLESIZE] = { + 29952, 29953, 29954, 29955, 29956, 29957, 29958, 29959, + 29960, 29961, 29962, 29963, 29964, 29965, 29966, 29967, + 29968, 29969, 29970, 29971, 29972, 29973, 29974, 29975, + 29976, 29977, 29978, 29979, 29980, 29981, 29982, 29983, + 29984, 62625, 62626, 62627, 62628, 62885, 62886, 62887, + 62888, 62889, 62890, 62891, 62892, 62893, 62894, 62895, + 62896, 62897, 62898, 62899, 62900, 62901, 62902, 62903, + 62904, 62905, 62906, 62907, 62908, 62909, 62910, 62911, + 62912, 62913, 62914, 62915, 62916, 62917, 62918, 62919, + 62920, 62921, 62922, 62923, 62924, 62925, 62926, 62927, + 62928, 62929, 62930, 62931, 62932, 62933, 62934, 62935, + 62936, 62937, 62938, 62939, 62940, 62941, 62942, 62943, + 62944, 62945, 62946, 62947, 62948, 62949, 62950, 62951, + 62952, 62953, 62954, 62955, 62956, 62957, 62958, 62959, + 62960, 62961, 62962, 62963, 62964, 62965, 62966, 62967, + 62968, 62969, 62970, 62971, 62972, 62973, 62974, 30079, + 30080, 30081, 30082, 30083, 30084, 30085, 30086, 30087, + 30088, 30089, 30090, 30091, 30092, 30093, 30094, 30095, + 30096, 30097, 30098, 30099, 30100, 30101, 30102, 30103, + 30104, 30105, 30106, 30107, 30108, 30109, 30110, 30111, + 30112, 30113, 30114, 30115, 30116, 30117, 30118, 30119, + 30120, 30121, 30122, 30123, 30124, 30125, 30126, 30127, + 30128, 30129, 30130, 30131, 30132, 30133, 30134, 30135, + 30136, 30137, 30138, 30139, 30140, 30141, 30142, 30143, + 30144, 30145, 30146, 30147, 30148, 30149, 30150, 30151, + 30152, 30153, 30154, 30155, 30156, 30157, 30158, 30159, + 30160, 30161, 30162, 30163, 30164, 30165, 30166, 30167, + 30168, 30169, 30170, 30171, 30172, 30173, 30174, 30175, + 30176, 30177, 30178, 30179, 30180, 30181, 30182, 30183, + 30184, 30185, 30186, 30187, 30188, 30189, 30190, 30191, + 30192, 30193, 30194, 30195, 30196, 30197, 30198, 30199, + 30200, 30201, 30202, 30203, 30204, 30205, 30206, 30207 +}; + +static unsigned short nsEE[TABLESIZE] = { + 60928, 60929, 60930, 60931, 60932, 60933, 60934, 60935, + 60936, 60937, 60938, 60939, 60940, 60941, 60942, 60943, + 60944, 60945, 60946, 60947, 60948, 60949, 60950, 60951, + 60952, 60953, 60954, 60955, 60956, 60957, 60958, 60959, + 60960, 60961, 60962, 60963, 60964, 60965, 60966, 60967, + 60968, 60969, 60970, 60971, 60972, 60973, 60974, 60975, + 60976, 60977, 60978, 60979, 60980, 60981, 60982, 60983, + 60984, 60985, 60986, 60987, 60988, 60989, 60990, 60991, + 60992, 60993, 60994, 60995, 60996, 60997, 60998, 60999, + 61000, 61001, 61002, 61003, 61004, 61005, 61006, 61007, + 61008, 61009, 61010, 61011, 61012, 61013, 61014, 61015, + 61016, 61017, 61018, 61019, 61020, 61021, 61022, 61023, + 61024, 61025, 61026, 61027, 61028, 61029, 61030, 61031, + 61032, 61033, 61034, 61035, 61036, 61037, 61038, 61039, + 61040, 61041, 61042, 61043, 61044, 61045, 61046, 61047, + 61048, 61049, 61050, 61051, 61052, 61053, 41409, 61055, + 61056, 61057, 61058, 61059, 61060, 61061, 61062, 61063, + 61064, 61065, 61066, 61067, 61068, 61069, 61070, 61071, + 61072, 61073, 61074, 61075, 61076, 61077, 61078, 61079, + 61080, 61081, 61082, 61083, 61084, 61085, 61086, 61087, + 61088, 61089, 61090, 61091, 61092, 61093, 61094, 61095, + 61096, 61097, 61098, 61099, 61100, 61101, 61102, 61103, + 61104, 61105, 61106, 61107, 61108, 61109, 61110, 61111, + 61112, 61113, 61114, 61115, 61116, 61117, 61118, 61119, + 61120, 61121, 61122, 61123, 61124, 61125, 61126, 61127, + 61128, 61129, 61130, 61131, 61132, 61133, 61134, 61135, + 61136, 61137, 61138, 61139, 61140, 61141, 61142, 61143, + 61144, 61145, 61146, 61147, 61148, 61149, 61150, 61151, + 61152, 61153, 61154, 61155, 61156, 61157, 61158, 61159, + 61160, 61161, 61162, 61163, 61164, 61165, 61166, 61167, + 61168, 61169, 61170, 61171, 61172, 61173, 61174, 61175, + 61176, 61177, 61178, 61179, 61180, 61181, 61182, 61183 +}; + +static unsigned short nsEF[TABLESIZE] = { + 61184, 61185, 61186, 61187, 61188, 61189, 61190, 61191, + 61192, 61193, 61194, 61195, 61196, 61197, 61198, 61199, + 61200, 61201, 61202, 61203, 61204, 61205, 61206, 61207, + 61208, 61209, 61210, 61211, 61212, 61213, 61214, 61215, + 61216, 61217, 61218, 61219, 41405, 41405, 61222, 61223, + 61224, 61225, 41426, 41427, 61228, 61229, 61230, 61231, + 41719, 41720, 41426, 41427, 61236, 61237, 61238, 61239, + 61240, 61241, 61242, 61243, 61244, 61245, 61246, 61247, + 61248, 41715, 41699, 41700, 61252, 61253, 61254, 61255, + 61256, 61257, 41658, 61259, 41659, 61261, 41678, 41677, + 61264, 61265, 61266, 61267, 61268, 61269, 41665, 41664, + 41661, 41660, 41663, 41662, 61276, 61277, 61278, 61279, + 61280, 61281, 61282, 61283, 61284, 61285, 61286, 61287, + 61288, 61289, 41676, 61291, 41692, 61293, 61294, 41704, + 41693, 41703, 41697, 61299, 61300, 41705, 61302, 61303, + 61304, 61305, 61306, 61307, 41701, 61309, 61310, 61311, + 61312, 61313, 61314, 61315, 61316, 61317, 61318, 61319, + 61320, 61321, 61322, 61323, 61324, 61325, 61326, 61327, + 61328, 61329, 61330, 61331, 61332, 61333, 61334, 61335, + 61336, 61337, 61338, 61339, 61340, 61341, 61342, 61343, + 61344, 61345, 61346, 61347, 61348, 61349, 61350, 61351, + 61352, 61353, 61354, 61355, 61356, 61357, 61358, 61359, + 61360, 61361, 61362, 61363, 41680, 41679, 41674, 41675, + 61368, 41696, 41695, 61371, 61372, 61373, 61374, 61375, + 41694, 61377, 61378, 61379, 61380, 61381, 61382, 61383, + 61384, 61385, 61386, 61387, 61388, 61389, 61390, 61391, + 61392, 61393, 61394, 61395, 61396, 61397, 61398, 61399, + 61400, 61401, 61402, 61403, 61404, 61405, 61406, 61407, + 61408, 43181, 43180, 43190, 43170, 43169, 43179, 61415, + 61416, 61417, 61418, 61419, 61420, 61421, 61422, 61423, + 61424, 61425, 61426, 61427, 61428, 61429, 61430, 61431, + 61432, 61433, 61434, 61435, 61436, 61437, 61438, 61439 +}; + +static unsigned short nsF1[TABLESIZE] = { + 61696, 61697, 61698, 61699, 61700, 61701, 61702, 61703, + 61704, 61705, 61706, 61707, 61708, 61709, 61710, 61711, + 61712, 61713, 61714, 61715, 61716, 61717, 61718, 61719, + 61720, 61721, 61722, 61723, 61724, 61725, 61726, 61727, + 61728, 61729, 61730, 61731, 61732, 61733, 61734, 61735, + 41714, 61737, 61738, 61739, 61740, 61741, 61742, 61743, + 61744, 61745, 61746, 61747, 61748, 61749, 61750, 61751, + 61752, 61753, 61754, 61755, 61756, 61757, 61758, 61759, + 61760, 61761, 61762, 61763, 61764, 61765, 61766, 61767, + 61768, 61769, 61770, 61771, 61772, 61773, 61774, 61775, + 61776, 61777, 61778, 61779, 61780, 61781, 61782, 61783, + 61784, 61785, 61786, 61787, 61788, 61789, 61790, 61791, + 61792, 61793, 61794, 61795, 61796, 61797, 61798, 61799, + 61800, 61801, 61802, 61803, 61804, 61805, 61806, 61807, + 61808, 61809, 61810, 61811, 61812, 61813, 61814, 61815, + 61816, 61817, 61818, 61819, 61820, 61821, 61822, 61823, + 61824, 61825, 61826, 61827, 61828, 61829, 61830, 61831, + 61832, 61833, 61834, 61835, 61836, 61837, 61838, 61839, + 61840, 61841, 61842, 61843, 61844, 61845, 61846, 61847, + 61848, 61849, 61850, 61851, 61852, 61853, 61854, 61855, + 61856, 61857, 61858, 61859, 61860, 61861, 61862, 61863, + 61864, 61865, 61866, 61867, 61868, 61869, 61870, 61871, + 61872, 61873, 61874, 61875, 61876, 61877, 61878, 61879, + 61880, 61881, 61882, 61883, 61884, 61885, 61886, 61887, + 61888, 61889, 61890, 61891, 61892, 61893, 61894, 61895, + 61896, 61897, 61898, 61899, 61900, 61901, 61902, 61903, + 61904, 61905, 61906, 61907, 61908, 61909, 61910, 61911, + 61912, 61913, 61914, 61915, 61916, 61917, 61918, 61919, + 61920, 61921, 61922, 61923, 61924, 61925, 61926, 61927, + 61928, 61929, 61930, 61931, 61932, 61933, 61934, 61935, + 61936, 61937, 61938, 61939, 61940, 61941, 61942, 61943, + 61944, 61945, 61946, 61947, 61948, 61949, 61950, 61951 +}; + +static unsigned short nsFD[TABLESIZE] = { + 64768, 64769, 64770, 64771, 64772, 64773, 64774, 64775, + 64776, 64777, 64778, 64779, 64780, 64781, 64782, 64783, + 64784, 64785, 64786, 64787, 64788, 64789, 64790, 64791, + 64792, 64793, 64794, 64795, 64796, 64797, 64798, 64799, + 64800, 64801, 64802, 64803, 64804, 64805, 64806, 64807, + 64808, 64809, 64810, 64811, 64812, 64813, 64814, 64815, + 64816, 64817, 64818, 64819, 64820, 64821, 64822, 64823, + 64824, 64825, 64826, 64827, 64828, 64829, 64830, 64831, + 64832, 64833, 64834, 64835, 64836, 64837, 64838, 64839, + 64840, 64841, 64842, 64843, 64844, 64845, 64846, 64847, + 64848, 64849, 64850, 64851, 64852, 64853, 64854, 64855, + 64856, 64857, 64858, 64859, 64860, 64861, 64862, 64863, + 64864, 64865, 64866, 64867, 64868, 64869, 64870, 64871, + 64872, 64873, 64874, 64875, 64876, 64877, 64878, 64879, + 64880, 64881, 64882, 64883, 64884, 64885, 64886, 64887, + 64888, 64889, 64890, 64891, 41701, 64893, 41702, 64895, + 64896, 64897, 64898, 64899, 64900, 64901, 64902, 64903, + 64904, 64905, 64906, 64907, 64908, 64909, 64910, 64911, + 64912, 64913, 64914, 64915, 64916, 64917, 64918, 64919, + 64920, 64921, 64922, 64923, 64924, 64925, 64926, 64927, + 64928, 64929, 64930, 64931, 64932, 64933, 64934, 64935, + 64936, 64937, 64938, 64939, 64940, 64941, 64942, 64943, + 64944, 64945, 64946, 64947, 64948, 64949, 64950, 64951, + 64952, 64953, 64954, 64955, 64956, 64957, 64958, 64959, + 64960, 64961, 64962, 64963, 64964, 64965, 64966, 64967, + 64968, 64969, 64970, 64971, 64972, 64973, 64974, 64975, + 64976, 64977, 64978, 64979, 64980, 64981, 64982, 64983, + 64984, 64985, 64986, 64987, 64988, 64989, 64990, 64991, + 64992, 64993, 64994, 64995, 64996, 64997, 64998, 64999, + 65000, 65001, 65002, 65003, 65004, 65005, 65006, 65007, + 65008, 65009, 65010, 65011, 65012, 65013, 65014, 65015, + 65016, 65017, 65018, 65019, 65020, 65021, 65022, 65023 +}; + +unsigned short euc_ns(short unsigned int euc) +{ + unsigned short table; + + table = euc / TABLESIZE; + switch ( table ) { + case 0xA1: + return( eucA1[ euc % TABLESIZE ] ); + case 0xA2: + return( eucA2[ euc % TABLESIZE ] ); + case 0xA3: + return( eucA3[ euc % TABLESIZE ] ); + case 0xA6: + return( eucA6[ euc % TABLESIZE ] ); + case 0xA8: + return( eucA8[ euc % TABLESIZE ] ); + case 0xF4: + return( eucF4[ euc % TABLESIZE ] ); + default: + return( euc & NSBITS ); + } +} + +unsigned short ns_euc(short unsigned int ns) +{ + unsigned short table; + + table = ns / TABLESIZE; + switch ( table ) { + case 0x00: + return( ns00[ ns % TABLESIZE ] ); + case 0x23: + return( ns23[ ns % TABLESIZE ] ); + case 0x26: + return( ns26[ ns % TABLESIZE ] ); + case 0x75: + return( ns75[ ns % TABLESIZE ] ); + case 0xEE: + return( nsEE[ ns % TABLESIZE ] ); + case 0xEF: + return( nsEF[ ns % TABLESIZE ] ); + case 0xF1: + return( nsF1[ ns % TABLESIZE ] ); + case 0xFD: + return( nsFD[ ns % TABLESIZE ] ); + default: + return( ns | EUCBITS ); + } +} + + diff --git a/src/colorbltfns.c b/src/colorbltfns.c new file mode 100755 index 0000000..00cb054 --- /dev/null +++ b/src/colorbltfns.c @@ -0,0 +1,787 @@ +/* $Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* C O L O R B I T B L T / G R A P H I C S S U P P O R T */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lispemul.h" +#include "lispglobal.h" +#include "lispmap.h" +#include "lisptypes.h" +#include "address68k.h" +#include "address.h" +#include "stream.h" +#include "displaydata.h" +#include "pilotbbt.h" +#include "debug.h" +#include "arith.h" +#include "bitblt.h" +#include "lldisplay.h" + +#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) +#define IMAX(x,y) (((x) > (y)) ? (x) : (y)) + + /*******************************/ + /* A LISP Big-bitmap structure */ + /*******************************/ +typedef struct + { + LispPTR bigbmwidth; + LispPTR bigbmheight; + LispPTR bigbmlist; + } BIGBM; + + + +#define GetNewFragment(list,frag,type) \ + frag = (type)Addr68k_from_LADDR( car(list) ); \ + list = cdr( list ); + +LispPTR SLOWBLTCHAR_index; +#define SLOWBLTCHAR_argnum 2 +#define PUNT_TO_SLOWBLTCHAR {\ + if(SLOWBLTCHAR_index==0xffffffff)\ + SLOWBLTCHAR_index= get_package_atom("\\PUNT.SLOWBLTCHAR", \ + 17, "INTERLISP", 9, NIL);\ + if(SLOWBLTCHAR_index==0xffffffff)\ + {error("SLOWBLTCHAR install fail"); return;} \ + CurrentStackPTR +=(SLOWBLTCHAR_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(SLOWBLTCHAR_index,SLOWBLTCHAR_argnum,3);return;} + +/***********************************************************/ +/* + C_slowbltchar + + by Takeshi + June 6, 1989 +*/ +/***********************************************************/ + +/* I'll merge this macro with FGetNum later */ +#define SFGetNum(ptr, place) { \ + if(((ptr) & 0xff0000)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ + else if(((ptr) & 0xff0000)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ + else {PUNT_TO_SLOWBLTCHAR;}} + + +/* place: native pointer + val: native value(should be smallp) + puntcase: punt descriptions */ +#define FReplaceSmallp(place,val,puntcase) {\ + if ((0 <= (val)) && ((val) <= MAX_SMALL)) \ + (LispPTR)(place) = (LispPTR)(S_POSITIVE | (val));\ + else if(MIN_SMALL <= val)\ + (LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val)));\ + else {puntcase;}} + +/* charcode should be pos. smallp */ +#define charcode (args[0] & 0xffff) +#define displaystream args[1] +#define Char8Code(x) ((u_char)((x) & 0xff)) +#define CharSet(x) ((x) >> 8) + +#define PSEUDO_BLACK 255 +#define PSEUDO_WHITE 0 + +LispPTR *SCREENBITMAPS68k; /* Initialized in initsysout.c */ +LispPTR *COLORSCREEN68k; /* Initialized in initsysout.c */ +LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */ + + + + +/************************************************************************/ +/* */ +/* C _ s l o w b l t c h a r */ +/* */ +/* args[0] charcode */ +/* args[1] displaystream */ +/* */ +/* */ +/************************************************************************/ + +C_slowbltchar(args) + register LispPTR *args; + { + Stream *n_dstream; + DISPLAYDATA *n_dd; + FONTDESC *n_fontd; + CHARSETINFO *n_csinfo; + BITMAP *n_destbitmap; + int dest_bpp; + LispPTR csinfo; + int curx,cury,newx,rmargin,lmargin,xoff,yoff; + DLword cl_left, cl_right, cl_bottom, cl_top; + DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h; + + + u_char forecolor,backcolor; + register int displayflg; + + + extern LispPTR *TOPWDS68k; + + n_dstream=(Stream*)Addr68k_from_LADDR(displaystream); + n_dd=(DISPLAYDATA*)Addr68k_from_LADDR(n_dstream->IMAGEDATA); + n_fontd=(FONTDESC*)Addr68k_from_LADDR(n_dd->ddfont); + n_destbitmap=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); + + if((n_fontd->ROTATION & 0xffff) == 0) + { + + if((csinfo= + *(((LispPTR*)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) + + CharSet(charcode) )) == NIL ) + PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */ + + n_csinfo =(CHARSETINFO*)Addr68k_from_LADDR(csinfo); + + SFGetNum(n_dd->ddxposition, curx); + SFGetNum(n_dd->ddyposition, cury); + SFGetNum(n_dd->ddrightmargin, rmargin); + SFGetNum(n_dd->ddleftmargin, lmargin); + SFGetNum(n_dd->ddxoffset, xoff); + SFGetNum(n_dd->ddyoffset, yoff); + cl_left = n_dd->ddclippingleft; + cl_right = n_dd->ddclippingright; + cl_bottom = n_dd->ddclippingbottom; + cl_top = n_dd->ddclippingtop; + + newx = curx + *(DLword*)Addr68k_from_LADDR(n_dd->ddwidthscache + + Char8Code(charcode)); + + if(newx > rmargin) + PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */ + + /* If we care about TOPW then it's too slow to create Menu etc. + But,if we don't,it causes some error **/ + { + WINDOW *window; + SCREEN *ColorScreenData; + if(COLORSCREEN_index==0xffffffff) + { /* Make sure COLOR lives? */ + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = (LispPTR *)Addr68k_from_LADDR(VALS_OFFSET + + (COLORSCREEN_index << 1)); + } + ColorScreenData=(SCREEN*)Addr68k_from_LADDR(*COLORSCREEN68k); + window = (WINDOW*)Addr68k_from_LADDR(ColorScreenData->SCTOPW); + if((displaystream != ColorScreenData->SCTOPW) && + (displaystream != window->DSP) && + (displaystream != *TOPWDS68k) && + ((fmemb(n_dd->dddestination,*SCREENBITMAPS68k)) != NIL)) + PUNT_TO_SLOWBLTCHAR; + } + + FReplaceSmallp( n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR); + + /* make curx abs coord */ + curx += xoff; + cury += yoff; + + { register PILOTBBT *pbt; + register BITMAP *n_destBM,*n_srcBM; + register BIGBM *n_destBIGBM; + register int destYOffset; + register int width,sourceBitOffset; + extern int ScreenLocked; + extern int displayheight; + + n_srcBM=(BITMAP*)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP); + src_h = n_srcBM->bmheight; + src_w = n_srcBM->bmwidth; + + src_x = *((DLword*)Addr68k_from_LADDR( n_dd->ddoffsetscache + + Char8Code(charcode))); + src_y = 0; + w = *(DLword*)Addr68k_from_LADDR(n_dd->ddcharimagewidths + + Char8Code(charcode)); + h = src_h; + + (short)dst_x = (short)curx; + (short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT; + + { /* clipping */ + short left,right,bottom,top; + short stodx,stody; + + left = (short)IMAX( (short)dst_x, (short)cl_left ); + right = (short)IMIN( (short)dst_x+w, (short)cl_right ); + bottom = (short)IMAX( (short)dst_y, (short)cl_bottom ); + top = (short)IMIN( (short)dst_y+h, (short)cl_top ); + stodx = (short)dst_x - (short)src_x; + stody = (short)dst_y - (short)src_y; + left = IMAX( (short)src_x, IMAX( left-stodx, 0 ) ); + bottom = IMAX( (short)src_y, IMAX( bottom-stody , 0 ) ); + right = IMIN( (short)src_w, IMIN( (short)(src_x+w), right-stodx ) ); + top = IMIN( (short)src_h, IMIN( (short)(src_y+h), top-stody ) ); + if ( (right<=left) || (top<=bottom) ) return; + w = (DLword)(right - left); + h = (DLword)(top - bottom); + dst_x = (DLword)(left + stodx); + dst_y = (DLword)(bottom + stody); + src_x = (DLword)left; + src_y = (DLword)bottom; + } + + /* forground and bacground color */ + + if(n_dd->ddcolor ==NIL_PTR) + { + forecolor = PSEUDO_BLACK; + backcolor = PSEUDO_WHITE; + } + else + { + backcolor = 0xff & cdr(n_dd->ddcolor); + forecolor = 0xff & car(n_dd->ddcolor); + } + + if(GetTypeNumber( n_dd->dddestination ) == TYPE_BITMAP) + { /* Bitap */ + n_destBM=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); + ScreenLocked=T; + /* xposition is shifted 3 Kludge for cursorin + in color(8bpp) ** x's meaning is different from + bitbltsub's. For now,I use this func with Kludge */ + displayflg=n_new_cursorin( + Addr68k_from_LADDR(n_destBM->bmbase),dst_x<<3, + /* Kludge:YCoordination upside down*/ + displayheight-cury,w,h); + if(displayflg) HideCursor; + + ColorizeFont8(n_srcBM, src_x, src_y + , n_destBM, dst_x, dst_y + , w, h + , backcolor,forecolor + , n_dd->ddsourcetype,n_dd->ddoperation); + + + if(displayflg) ShowCursor; + ScreenLocked=NIL; + + } + else + { /* BIGBM */ + ScreenLocked=T; + n_destBIGBM = (BIGBM*)n_destbitmap; + ColorizeFont8_BIGBM(n_srcBM, src_x, src_y + , n_destBIGBM, dst_x, dst_y + , w, h + , backcolor,forecolor + , n_dd->ddsourcetype,n_dd->ddoperation); + ScreenLocked=NIL; + } /* end if( TYPE_BITMAP ) */ + + + } + } + else + { + /* ROTATE case ,do-PUNT */ + PUNT_TO_SLOWBLTCHAR; + } + + } /* end C_slowbltchar */ + + + +/************************************************************************/ +/* */ +/* C o l o r i z e d F o n t 8 */ +/* */ +/* Expand a 1bpp font to 8bpp colorized font bitmap, using */ +/* col1 and col0 as the colors for 1 bits & 0 bits, respectively. */ +/* */ +/* dbm must be the output bitmap (not a bigbm), whose bpp is 8. */ +/* */ +/************************************************************************/ + +#define MAXFONTHEIGHT 48 +#define MAXFONTWIDTH 48 +#define BITSPERNIBBLE 4 +#define BITSPERDLWORD 16 +#define BPP 8 + +u_int ColorizedFont8CACHE[MAXFONTHEIGHT/BITSPERNIBBLE * + MAXFONTWIDTH/BITSPERNIBBLE]; + + +ColorizeFont8(sBM,sXOffset,sYOffset,dBM,dXOffset, + dYOffset,width,height,col0,col1,sourcetype,operation) + register BITMAP *sBM; + register DLword sXOffset,sYOffset, width, height; + register BITMAP *dBM; + DLword dYOffset,dXOffset; + u_char col0,col1; + LispPTR sourcetype; + LispPTR operation; + +{ + register DLword *nbase; + register u_char *dbase; + register int i; + + sYOffset = sBM->bmheight - (sYOffset+height); + dYOffset = dBM->bmheight - (dYOffset+height); + + nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) + + (sBM->bmrasterwidth * sYOffset); + (DLword*)dbase= (DLword*)Addr68k_from_LADDR(dBM->bmbase) + + (dBM->bmrasterwidth * dYOffset); + for(i=0, dbase += dXOffset;/* 8bpp */ + i < height; + i++,nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dBM->bmrasterwidth) + { + lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); + } /* for end */ + +} /* ColorizeFont8 end */ + + + + + +/************************************************************************/ +/* */ +/* C o l o r i z e d F o n t 8 _ B I G B M */ +/* */ +/* Expand a 1bpp font to 8bpp colorized font bitmap, using */ +/* col1 and col0 as the colors for 1 bits & 0 bits, respectively. */ +/* */ +/* dbm must be the output BIGBM (not a bitmap), whose bpp is 8. */ +/* */ +/************************************************************************/ + +ColorizeFont8_BIGBM(sBM,sXOffset,sYOffset,dBM,dXOffset,dYOffset,width,height,col0,col1,sourcetype,operation) +register BITMAP *sBM; +register DLword sXOffset,sYOffset,width,height; +register BIGBM *dBM; +DLword dXOffset, dYOffset; +u_char col0,col1; +LispPTR sourcetype; +LispPTR operation; + + +{ + register DLword *nbase; + register u_char *dbase; + register int i; + int dest_bottom + , dest_bigbmheight + , dest_fragtop + , dest_fragbottom + , dest_yoffset + , dest_h; + + LispPTR dest_bmlist; + BITMAP *dest_frag; + + SFGetNum( dBM->bigbmheight, dest_bigbmheight ); + + sYOffset = sBM->bmheight - ( sYOffset+height ); + dYOffset = dest_bigbmheight - ( dYOffset+height ); + + dest_bottom = dYOffset + height; + dest_bmlist = (LispPTR)dBM->bigbmlist; + GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); + dest_fragtop = 0; + dest_fragbottom = dest_frag->bmheight; + +/* search fragment of bitmaps including the desitnation top. */ + while( dest_fragbottom <= dYOffset ) { + GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); + if( dest_frag == (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) return; + dest_fragtop = dest_fragbottom; + dest_fragbottom += dest_frag->bmheight; + } /* end while */ + +/* y offset form bitmap top. */ + dest_yoffset = dYOffset - dest_fragtop; + +loop: +/* height of lineBlt8 */ + if( dest_fragbottom > dest_bottom ) { + /* this fragment inludes dest bottom. */ + dest_h = dest_bottom - (dest_fragtop + dest_yoffset); + } else { + /* remaining fragments include dest bottom. */ + dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset); + } /* end if */ + + dbase= (DLword*)Addr68k_from_LADDR(dest_frag->bmbase) + + (dest_frag->bmrasterwidth * dest_yoffset); + nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) + + (sBM->bmrasterwidth * sYOffset); + + sYOffset += (DLword)dest_h; /* next src yoffset */ + + for(i=0, dbase += dXOffset; + i < dest_h; + i++, nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dest_frag->bmrasterwidth) + { + lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); + } + +/* remaining height */ + height -= dest_h; + if( height > 0 ) { + GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); + if( dest_frag != (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) { + dest_fragtop = dest_fragbottom; + dest_fragbottom = dest_fragtop + dest_frag->bmheight; + dest_yoffset = 0; /* y offset must be zero. */ + nbase += sBM->bmrasterwidth; + goto loop; + } /* end if(dest_frag) */ + } /* end if(height) */ + +} /* end ColorizeFont8_BIGBM() */ + + + +/************************************************************************/ +/* */ +/* n e w C o l o r i z e F o n t 8 */ +/* */ +/* */ +/* */ +/************************************************************************/ + +newColorizeFont8(pbt,backcolor,forecolor,srctype,ope) + PILOTBBT *pbt; + u_char backcolor,forecolor; + LispPTR srctype,ope; +{ + register DLword *nbase; + register u_char *dbase; + register int i; + + nbase=(DLword*)Addr68k_from_LADDR + ((pbt->pbtsourcehi << 16 ) | (pbt->pbtsourcelo)) ; + (DLword*)dbase= (DLword*)Addr68k_from_LADDR( + (pbt->pbtdesthi << 16 ) | (pbt->pbtdestlo)) ; + dbase += pbt->pbtdestbit; + for(i=0; i < pbt->pbtheight; + i++,nbase += pbt->pbtsourcebpl/16 + , dbase += pbt->pbtdestbpl/8) + { + lineBlt8(nbase,pbt->pbtsourcebit,dbase,pbt->pbtwidth,backcolor,forecolor,srctype,ope); + } /* for end */ + + +} + + + +/************************************************************************/ +/* */ +/* U n c o l o r i z e _ B i t m a p */ +/* */ +/* Uncolorize bitmap from 8bpp to 1bpp. */ +/* */ +/************************************************************************/ + +Uncolorize_Bitmap( args ) +LispPTR args[]; +{ + BITMAP *s_bitmap + , *d_bitmap; + register DLword* OnOff; + + register u_char *s_base; + register DLword *d_base; + register int y; + int s_height + , s_width + , s_bitsperpixel + , s_rasterwidth + , d_rasterwidth; + + s_bitmap = (BITMAP*)Addr68k_from_LADDR( args[0] ); + d_bitmap = (BITMAP*)Addr68k_from_LADDR( args[1] ); + OnOff = (DLword*)Addr68k_from_LADDR( args[2] ); + + s_height = s_bitmap->bmheight; + s_width = s_bitmap->bmwidth; + s_bitsperpixel = s_bitmap->bmbitperpixel; + + if( s_bitsperpixel != 8 ) return; + + s_base = (u_char*)Addr68k_from_LADDR(s_bitmap->bmbase); + d_base = (DLword*)Addr68k_from_LADDR(d_bitmap->bmbase); + s_rasterwidth = s_bitmap->bmrasterwidth; + d_rasterwidth = d_bitmap->bmrasterwidth; + + for( y=0; ybmbase ) + + s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height)); + (DLword*)d_base = (DLword*)Addr68k_from_LADDR( d_bitmap->bmbase ) + + d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height)); + + for( i=0, d_base += d_left; ibmrasterwidth + , (DLword*)d_base += d_bitmap->bmrasterwidth ) { + + lineBlt8( s_base, s_left, d_base, width + , (u_char)color0, (u_char)color1 + , INPUT_atom, REPLACE_atom ); + + } /* end for(i) */ + + bad_arg: return( NIL ); + +} /* end Colorize_Bitmap() */ + + + +/************************************************************************/ +/* */ +/* D r a w _ 8 B p p C o l o r L i n e */ +/* */ +/* Draw a line in the 8-bpp display bitmap. */ +/* */ +/************************************************************************/ + +#define op_replace +#define op_erase & +#define op_invert ^ +#define op_paint | + +#define draw8bpplinex(op) \ + while( (x0 <= xlimit) && ( y0 <= ylimit ) ) { \ + *(base++) op= color; ++x0; cdl += dy; \ + if( dx <= cdl ) { \ + cdl -= dx; \ + base += yinc; ++y0; \ + } \ + } + +#define draw8bppliney(op) \ + while( (x0 <= xlimit) && (y0 <= ylimit ) ) { \ + *base op= color; base += yinc; ++y0; cdl += dx; \ + if( dy <= cdl ) { \ + cdl -= dy; \ + ++ base; ++x0; \ + } \ + } + +Draw_8BppColorLine( args ) + register LispPTR *args; + { + extern DLword REPLACE_atom + , INVERT_atom + , PAINT_atom + , ERASE_atom; + + register u_char color; + register u_char *base; + register short x0 + , y0 + , xlimit + , ylimit + , dx + , dy + , cdl + , yinc + , raster_width; + int mode + , displayflg; + u_char *n_bmbase; + + x0 = (short)( args[0] &0xffff ); + y0 = (short)( args[1] &0xffff ); + xlimit = (short)( args[2] &0xffff ); + ylimit = (short)( args[3] &0xffff ); + dx = (short)( args[4] &0xffff ); + dy = (short)( args[5] &0xffff ); + cdl = (short)( args[6] &0xffff ); + yinc = (short)( args[7] &0xffff ); yinc *= 2; /* for byte addressing */ + + if ( args[8] == PAINT_atom ) mode = 3; + else if( args[8] == INVERT_atom ) mode = 2; + else if( args[8] == ERASE_atom ) mode = 1; + else mode = 0; /* REPLACE_atom */ + + n_bmbase = (u_char*)Addr68k_from_LADDR( args[9] ); + raster_width = (short) ( args[10] &0xffff ); + color = (u_char)( args[11] & 0xff ); + + if( yinc >= 0 ) + { + displayflg = n_new_cursorin( (DLword*)n_bmbase + , (int)(x0<<3), (int)y0, (int)(xlimit<<3), (int)ylimit ); + } + else + { + displayflg = + n_new_cursorin( (DLword*)n_bmbase, + (int)(x0<<3), (int)(y0-ylimit), + (int)(xlimit<<3), (int)ylimit ); + } + + base = n_bmbase + y0 * (raster_width << 1) + x0; + x0 = y0 = 0; + + if( displayflg ) + { + ScreenLocked = T; + HideCursor; + } + + if( dx >= dy ) + { /* .draw8bpplinex */ + switch( mode ) + { + case 0: draw8bpplinex( op_replace ); + break; + case 1: draw8bpplinex( op_erase ); + break; + case 2: draw8bpplinex( op_invert ); + break; + case 3: draw8bpplinex( op_paint ); + break; + } /* end switch */ + + } + else + { /* .draw8bppliney */ + switch( mode ) + { + case 0: draw8bppliney( op_replace ); + break; + case 1: draw8bppliney( op_erase ); + break; + case 2: draw8bppliney( op_invert ); + break; + case 3: draw8bppliney( op_paint ); + break; + } /* end switch */ + + } /* end if( dx >= dy ) */ + + if( displayflg ) + { + ShowCursor; + ScreenLocked = NIL; + } + + } /* end Draw_8BppColorLine */ diff --git a/src/common.c b/src/common.c new file mode 100755 index 0000000..851638b --- /dev/null +++ b/src/common.c @@ -0,0 +1,203 @@ +/* $Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lspglob.h" +#include "emlglob.h" +#include "stack.h" +#include "dbprint.h" + +#ifndef NOPIXRECT +#include +#endif + +stab() + { + DBPRINT(("Now in stab\n")); + } + + + + +/*************************************************************** +error + common sub-routine. + + Printout error message. + Enter URAID. + And exit.(takeshi) + +******************************************************************/ +#define URMAXFXNUM 100 + +extern unsigned int LispReadFds,LispWindowFd,LispKbdFd; +extern struct screen LispScreen; +extern int displaywidth,displayheight; +extern DLword *DisplayRegion68k; +extern int FrameBufferFd; + extern char URaid_inputstring[]; + extern char URaid_comm; + extern char URaid_arg1[256]; + extern char URaid_arg2[10]; + extern int URaid_argnum; + extern char *URaid_errmess; + extern int URaid_currentFX; + extern FX *URaid_FXarray[]; + extern jmp_buf BT_jumpbuf; + extern jmp_buf SD_jumpbuf; + extern int BT_temp; /* holds the continue-character the user typed */ + + LispPTR Uraid_mess=NIL; + +/* Currentry Don't care Ether re-initial */ +/* Medley only */ + + + +/************************************************************************/ +/* */ +/* e r r o r */ +/* */ +/* Last-ditch error handling; enters URAID, low-level debug. */ +/* */ +/************************************************************************/ + +#define URMAXCOMM 512 +error(cp) + char *cp; + { + char *ptr; + if(device_before_raid()<0) + { + printf("Can't Enter URAID.\n"); + exit(-1); + } + /* comm read */ + URaid_errmess=cp; + printf("\n*Error* %s\n",cp); + fflush(stdin); + printf("Enter the URaid\n"); + print(Uraid_mess); putchar('\n'); + URaid_currentFX=URMAXFXNUM +1; + memset(URaid_FXarray, 0, URMAXFXNUM *4); +#ifndef DOS + { + int stat = fcntl(fileno(stdin), F_GETFL, 0); + if (stat != O_RDONLY && stat != O_RDWR) + if (freopen("/dev/tty", "r", stdin) == NULL) + { + perror("Reopen of stdin failed."); + exit(0); + } + } +#endif /* DOS */ +uraidloop: + if(setjmp(BT_jumpbuf) == 1) goto uraidloop; + if(setjmp(SD_jumpbuf) == 1) goto uraidloop; + for(;;) + { /* URAID LOOP */ + + uraid_commclear(); + BT_temp = 0; /* So we get the "more" option on screen-full */ + printf("\n< "); + for( ptr=URaid_inputstring;( *ptr= getchar() ) != '\n' ; ptr++) {} + URaid_argnum = sscanf(URaid_inputstring, + "%1s%s%s",&URaid_comm, URaid_arg1, URaid_arg2); + + if(uraid_commands()==NIL) break; + } /* for end */ + + /**TopOfStack = NIL;if error is called from subr TOS will be set NIL**/ + if(device_after_raid() <0) + { + printf("Can't return to Lisp. Return to UNIX?"); + { int c; + c= getchar(); + if((c=='Y')||(c=='y')) exit(-1); + } + fflush(stdin); + goto uraidloop; + } + return(0); + } + + + +/************************************************************************/ +/* */ +/* w a r n */ +/* */ +/* Print a warning message, but don't stop running. */ +/* */ +/************************************************************************/ + +warn(s) + char *s; + { printf("\nWARN: %s \n",s); } + + + + +/***************************************************************** +stackcheck + + common sub-routine. + + Not Implemented. + + 1.check Stack overflow. + (check CurrentStackPTR) + 2.if overflow, return T (not 0). + Otherwise, return F (0). +******************************************************************/ +stackcheck() + { +#ifdef TRACE2 + printf("TRACE:stackcheck()\n"); +#endif + return(0); + } + + + + +/***************************************************************** +stackoverflow + + common sub-routine. + + Not Implemented. + + 1.error handling of stack overflow. +******************************************************************/ + +stackoverflow() + { +#ifdef TRACE2 + printf("TRACE:stackoverflow()\n"); +#endif + printf("stackoverflow \n"); + } + diff --git a/src/conspage.c b/src/conspage.c new file mode 100755 index 0000000..67d51e7 --- /dev/null +++ b/src/conspage.c @@ -0,0 +1,496 @@ +/* $Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/***********************************************************************/ +/* + File Name :conspage.c +*/ +/************************************************************************/ +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "cell.h" +#include "lispmap.h" +#include "lspglob.h" +#include "gc.h" + +/**********************************************************************/ +/* + Func name : next_conspage + + GET NEXT CONS PAGE . + + Date : January 13, 1987 + Edited by : Takeshi Shimizu + Changed : January 20, 1987 (take) + Changed : Feb-12-87 take + Changed : Feb-13-87 take + +*/ +/**********************************************************************/ + +struct conspage *next_conspage(void) +{ + extern struct dtd *ListpDTD ; + + register struct conspage *page1 ; /* Allocated 1st MDS page */ + register struct conspage *page2 ; /* Allocated 2nd MDS page */ + struct conspage *pg, *priorpg; + register int next, prior; + +#ifdef NEWCDRCODING + /* Alloc 2 Conspages and get 1st page base */ + page1 = (struct conspage *)alloc_mdspage(TYPE_LISTP) ; + /* Culc. next Conspage's Base address */ + page2 = (struct conspage *)((DLword *)page1 + DLWORDSPER_PAGE) ; + + init_conspage(page2 , 0); /* Doesn't exst next page */ + init_conspage(page1 , LPAGE_from_68k(page2) ) ; + + prior = 0; + for (pg = (struct conspage *)Addr68k_from_LPAGE(next=ListpDTD->dtd_nextpage); + next && (next != CONSPAGE_LAST); + pg = (struct conspage *)Addr68k_from_LPAGE(next = pg->next_page)) + { priorpg = pg; prior = next; } + + if (prior) priorpg->next_page = LPAGE_from_68k(page1); + else ListpDTD->dtd_nextpage = LPAGE_from_68k(page1) ; + + if (page2->next_page) error("page2 has a next page??"); + if (page2 == priorpg) error("loop in conspage next_pages"); +#else + for(next =(int) ListpDTD->dtd_nextpage ; /* getnext free conspage */ + ; ListpDTD -> dtd_nextpage = next = page1 -> next_page , + page1->next_page = 0xffff ) + { + if(next ==0) + { + /* Alloc 2 Conspages and get 1st page base */ + page1 = (struct conspage *)alloc_mdspage(TYPE_LISTP) ; + + /* Culc. next Conspage's Base address */ + page2 = (struct conspage *)((DLword *)page1 + DLWORDSPER_PAGE) ; + + init_conspage(page2 , ListpDTD->dtd_nextpage); /* Doesn't exst next page */ + init_conspage(page1 , LPAGE_from_68k(page2) ) ; + + ListpDTD->dtd_nextpage = LPAGE_from_68k(page1) ; + goto ex ; /* replaced break */ + } + else + { + page1 =(struct conspage *) Addr68k_from_LPAGE(next) ; /*Jan-21*/ + } + + if (page1->count > 1) break ; + + } /* for loop end */ +#endif /* NEWCDRCODING */ +ex : + return(page1) ; + } /* next_conspage end */ + + + + +/************************************************************************/ +/* */ +/* i n i t _ c o n s p a g e */ +/* */ +/* Initialize a fresh page of CONS cells. Sets the count field */ +/* and chains the cells together for ease of searching. */ +/* */ +/* A fresh CONS page looks like this: */ +/* */ +/* +--------+--------+----------------+ */ +/* 0 | count | nxtcell| (padding) | nxtcell = 254. */ +/* +--------+--------+----------------+ */ +/* 2 | next_page | */ +/* +--------+-------------------------+ */ +/* 4 | 0 | N I L | */ +/* +--------+-------------------------+ */ +/* 6 | 4 | N I L | */ +/* +--------+-------------------------+ */ +/* ... | ... | N I L | */ +/* +--------+-------------------------+ */ +/* 254 | 252 | N I L | */ +/* +--------+-------------------------+ */ +/* */ +/* The cells are chained together thru their high 8 bits, */ +/* using the word offset within page as the chain. Cells */ +/* are chained from the top of the page down. */ +/* */ +/* Experimental version goes nxtcell = 248 */ +/* count/nxtcell in cell 4, next_page in cell 6 */ +/* Chain up 4 down 8 ( ^ 6 into word count) */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +init_conspage(register struct conspage *base, unsigned int link) + /* Page Base */ + /* Prev Link page number DL->int*/ + { + register ConsCell *cell ; + register int j ; /* DL-> int */ + +#ifdef TRACE2 + printf("TRACE: init_conspage()\n"); +#endif + + +#ifdef NEWCDRCODING + base -> next_cell= 6^(j = 254) ; + while (j > 8) + { + cell = (ConsCell *)((DLword *)base + (6 ^ j) ); + cell->car_field = NIL_PTR ; + j -= 2; + ((freecons *)cell)->next_free = (6^j) ; + } + base -> count = 124; +#else + base -> next_cell= j = 254 ; + while(j != 0) + { + cell = (ConsCell *)((DLword *)base + (j) ); + cell->car_field = NIL_PTR ; + j -= 2; + ((freecons *)cell)->next_free = (j) ; + } + base -> count = 127 ; +#endif /* NEWCDRCODING */ + base -> next_page = link ; + + } /* init_conspage end */ + + + +/************************************************************************/ +/* */ +/* f i n d _ c d r c o d a b l e _ p a i r */ +/* */ +/* Find a pair of CONS cells that are close enough (within 7) */ +/* that the second can be cdr-coded as the cdr of the first. */ +/* Set up the cdr code in the first cell, and return it. */ +/* */ +/* First searches the CONS page given, then the free-page chain */ +/* finally, calls conspage to get a fresh (and guaranteed useful) page. */ +/* */ +/************************************************************************/ + +ConsCell * find_pair_in_page(struct conspage *pg, LispPTR cdrval) +{ + ConsCell *carcell, *cdrcell; + unsigned int offset, prior, priorprior, ppriorprior, noffset, nprior, poffset; + + if (pg->count < 2) return((ConsCell *)0); + + ppriorprior = priorprior = prior = nprior = 0; + + for (offset = pg->next_cell; offset; offset = FREECONS(pg, offset)->next_free) + { + if (prior) + { + /* if ((6^prior) <= (6^offset)) error("free list in CONS page corrupt."); */ + if ((prior>offset) && (prior <= offset+14)) + { + poffset = offset; + noffset = FREECONS(pg,offset)->next_free; + while ((noffset>offset) && (noffset < prior)) + { + nprior = offset; + poffset = prior; + offset = noffset; + noffset = FREECONS(pg,offset)->next_free; + } + carcell = (ConsCell *) ((DLword *)pg + offset); + cdrcell = (ConsCell *) ((DLword *)pg + prior); + if (priorprior) + FREECONS(pg,priorprior)->next_free = + FREECONS(pg,poffset) ->next_free; + else pg->next_cell = FREECONS(pg,poffset) ->next_free; + if (nprior) FREECONS(pg,nprior)->next_free = FREECONS(pg,offset)->next_free; + carcell -> cdr_code = cdrcell - carcell; +#ifdef NEWCDRCODING + if ((cdrcell-carcell) > 7) error("in find_pair_in_page, cdr code too big."); + if (254 < (offset + (carcell->cdr_code << 1))) error ("in fpip, page overflow."); +#endif /* NEWCDRCODING */ + pg->count -= 2; + *((LispPTR *)cdrcell) = cdrval; + return(carcell); + } + else if ((offset>prior) && (offset <= prior+14)) + { + + carcell = (ConsCell *) ((DLword *)pg + prior); + cdrcell = (ConsCell *) ((DLword *)pg + offset); + if (priorprior) + FREECONS(pg,priorprior)->next_free = + ((freecons *)cdrcell) ->next_free; + else pg->next_cell = ((freecons *)cdrcell) ->next_free; + carcell -> cdr_code = cdrcell - carcell; +#ifdef NEWCDRCODING + if ((cdrcell-carcell) > 7) error("in find_pair_in_page, cdr code too big."); + if (254 < (prior + (carcell->cdr_code << 1))) error ("in fpip, page overflow."); +#endif /* NEWCDRCODING */ + pg->count -= 2; + *((LispPTR *)cdrcell) = cdrval; + return(carcell); + } + } + ppriorprior = priorprior; + priorprior = prior; + prior = offset; + + } + return((ConsCell *)0); + } + + + +ConsCell * find_cdrcodable_pair(LispPTR cdrval) +{ + ConsCell * cell; + struct conspage *pg; + unsigned pgno = ListpDTD->dtd_nextpage; + + for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno); pgno; + pg = (struct conspage *)Addr68k_from_LPAGE(pgno = pg->next_page)) + if (cell = find_pair_in_page(pg, cdrval)) return(cell); + + pg = next_conspage(); + cell = find_pair_in_page(pg,cdrval); + return(cell); + } /* end of find_cdrcodable_pair */ + + + + +ConsCell * find_free_cons_cell(void) +{ + ConsCell * cell; + struct conspage *pg, *priorpg; + unsigned pgno = ListpDTD->dtd_nextpage; + + + for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno); pgno; + pg = (struct conspage *)Addr68k_from_LPAGE(pgno)) + if (pg->count) + { + pg->count--; + cell =(ConsCell *) (((DLword *)pg)+(pg->next_cell)); + pg->next_cell = ((freecons *)cell)->next_free; + return(cell); + } + else + { /* remove the empty page from the free chain */ + pgno = ListpDTD->dtd_nextpage = pg->next_page; + pg->next_page = CONSPAGE_LAST; + } + + return((ConsCell *)0); + } /* end of find_free_cons_cell */ + + + +/**********************************************************************/ +/* function cons same as N_OP_cons */ +/**********************************************************************/ + +cons(LispPTR cons_car, LispPTR cons_cdr) +{ + return(N_OP_cons(cons_car, cons_cdr)); + } + + + +/**********************************************************************/ +/* + Func name :N_OP_cons + Execute CONS OPCODE + + Date : March 29 1988 + Edited by : Bob Krivacic + +*/ +/**********************************************************************/ + +N_OP_cons(register int cons_car, register int cons_cdr) +{ + extern struct dtd *ListpDTD ; + + register struct conspage *new_conspage ; + register ConsCell *new_cell ; + register ConsCell *temp_cell ; + register int new_page ; /* hold the return val of nextconspage ,DL->int */ + + extern ConsCell * find_close_prior_cell(struct conspage *page, LispPTR oldcell); + + GCLOOKUP(cons_cdr &= POINTERMASK, ADDREF); + GCLOOKUP(cons_car, ADDREF); + + + if(cons_cdr == NIL_PTR) + { +#ifdef NEWCDRCODING + if (new_cell = find_free_cons_cell()) + { /* next page has 1 or more free cells */ +#else + if ((ListpDTD->dtd_nextpage != 0) + && (GetCONSCount(ListpDTD->dtd_nextpage) > 0)) + { /* next page has 1 or more free cells */ + new_page = ListpDTD->dtd_nextpage; + new_conspage = (struct conspage *)Addr68k_from_LPAGE(new_page); + if (new_conspage->next_cell == 0) error("count ne 0, but nothing on free chain."); + new_cell = GetNewCell_68k(new_conspage); /* get new cell */ + + new_conspage->count --; /* decrement free cnt. */ + new_conspage->next_cell + = ((freecons *)new_cell)->next_free ; /* update free cell chain */ +#endif /* NEWCDRCODING */ + + /* filling new cell with the data */ + new_cell->car_field = cons_car ; + new_cell->cdr_code = CDR_NIL ; + + ListpDTD->dtd_cnt0++; + + } /* if (ListpDTD.. end */ + else + { /* Need to get a new CONS page */ + new_conspage=next_conspage(); + + new_cell = GetNewCell_68k( new_conspage ) ; + + new_conspage->count --; /* decrement free cnt. */ + new_conspage->next_cell + = ((freecons *)new_cell)->next_free ; /* update free cell chain */ + + /* filling new cell with the data */ + new_cell->car_field = cons_car ; + new_cell->cdr_code = CDR_NIL ; + + ListpDTD->dtd_oldcnt++; + + } /* else 1 end */ + } /* if(cons_cdr.. end */ + else /* cons_cdr != NIL */ + { + new_page = POINTER_PAGE(cons_cdr); /* Y's page num */ + new_conspage= (struct conspage *)Addr68k_from_LPAGE(new_page); +#ifdef NEWCDRCODING + if (Listp(cons_cdr) && (new_conspage->count > 0 ) + && (new_cell = find_close_prior_cell(new_conspage, cons_cdr))) +#else + if(Listp(cons_cdr) && (new_conspage->count > 0 )) +#endif /* NEWCDRCODING */ + { /* The cdr is itself a CONS cell, and can be */ + /* represented using CDR_ONPAGE representation */ + +#ifndef NEWCDRCODING + new_cell = GetNewCell_68k( new_conspage ) ; +#ifdef DEBUG + if(new_cell->car_field != NIL) + { + printf("CELL 0x%x has non-NIL car = 0x%x \n", + LADDR_from_68k(new_cell), new_cell->car_field); + error("QUIT from N_OP_cons"); + } +#endif + + new_conspage->count --; /* decrement free cnt. */ + new_conspage->next_cell + = ((freecons *)new_cell)->next_free ; /* update free cell chain */ +#endif /*NEWCDRCODING */ + + new_cell->car_field = cons_car ; + /* cdr_onpage + cell offset in this conspage */ +#ifdef NEWCDRCODING +#else + new_cell->cdr_code = CDR_ONPAGE | ((cons_cdr&0xff)>>1) ; +#endif /* NEWCDRCODING */ + ListpDTD->dtd_cnt0++; + + + } /* if (listp.. end */ + else + { + /* UFN case : CDR_INDIRECT */ +#ifdef NEWCDRCODING + new_cell = find_cdrcodable_pair(cons_cdr); +#else + new_conspage = next_conspage(); + + /* get 2 cells from conspage */ + temp_cell = GetNewCell_68k( new_conspage ) ; +#ifdef DEBUG + if(temp_cell->car_field != NIL) { + printf("CDR indirect CELL 0x%x has non-NIL car 0x%x \n", + LADDR_from_68k(new_cell), temp_cell->car_field); + error("QUIT from N_OP_cons"); + } +#endif + + new_conspage->next_cell + = ((freecons *)temp_cell)->next_free ; /* update free cell chain */ + new_cell = GetNewCell_68k( new_conspage ) ; +#ifdef DEBUG + if(new_cell->car_field != NIL) { + printf("CDR ind-2 CELL 0x%x has non-NIL car = 0x%x \n", + LADDR_from_68k(new_cell), new_cell->car_field); + error("QUIT from N_OP_cons"); + } +#endif + + new_conspage->next_cell + = ((freecons *)new_cell)->next_free ; /* update free cell chain */ + new_conspage->count -= 2; /* decrement free cnt. */ + + /* filling cell */ + *((LispPTR *)temp_cell) = cons_cdr ; /* Indirect CDR ptr */ +#endif /* NEWCDRCODING */ + new_cell->car_field = cons_car ; + +#ifndef NEWCDRCODING + /* culc. cdr code */ + new_cell->cdr_code = (((LispPTR)LADDR_from_68k(temp_cell)) & 0xff) >> 1; +#endif /* NEWCDRCODING */ + + ListpDTD->dtd_oldcnt++ ; /* added feb-12 take */ + + + } /* else end */ + + } /* else (cons_cdr==NIL end) */ + + + new_page = LADDR_from_68k(new_cell) ; + GCLOOKUP(new_page, DELREF); +#ifdef NEWCDRCODING + if (254 < ((new_page & 0xff) + ((new_cell->cdr_code & 7)<<1))) error("in CONS, cdr code too big."); +#endif /* NEWCDROCDING */ + return(new_page); + + } /* N_OP_cons() end */ diff --git a/src/cr b/src/cr new file mode 100755 index 0000000..9c4c7f1 --- /dev/null +++ b/src/cr @@ -0,0 +1,13 @@ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ diff --git a/src/dbgtool.c b/src/dbgtool.c new file mode 100755 index 0000000..ae553ab --- /dev/null +++ b/src/dbgtool.c @@ -0,0 +1,865 @@ +/* $Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/***************************************************************/ +/* + file name : Kdbgtool.c + + For Debugging Aids + + Including : + get_ivar_name(fx_addr68k , offset) + + date : 25 Aug 1987 NMitani + changed: 09 Sep 1987 NMitani + +*/ +/***************************************************************/ +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "emlglob.h" +#include "cell.h" +#include "stack.h" + +#define LOCAL_PVAR 0xFFFF +#ifdef BIGATOMS +#define VTY_IVAR 0x00000000 +#define VTY_PVAR 0x80000000 +#define VTY_FVAR 0xC0000000 +#define NT_OFFSET_MASK 0xFFFFFFF +#define GetNTEntry(X) GetLongWord(X) +#define NAMETABLE LispPTR +#else +#define VTY_IVAR 0x0000 +#define VTY_PVAR 0x8000 +#define VTY_FVAR 0xC000 +#define NT_OFFSET_MASK 0xFF +#define GetNTEntry(X) GETWORD(X) +#define NAMETABLE DLword +#endif + +#define URMAXFXNUM 2000 +#define URSCAN_ALINK 0 +#define URSCAN_CLINK 1 +extern int URaid_scanlink; +extern int URaid_currentFX; +extern FX *URaid_FXarray[]; +extern int URaid_ArrMAXIndex; +int BT_lines; +int BT_temp; +jmp_buf BT_jumpbuf; +#ifdef DOS +#define BTMAXLINE 24 + /* DOS has a 25-line screen, and getchar discards ESC for some reason */ +#define BT_morep if((BT_temp != '!') && (++BT_lines>BTMAXLINE)){\ + printf("Press Return(Esc & Ret to quit, ! don't stop):");\ + BT_temp=getch();\ + fflush(stdin);\ + BT_lines=0; \ + if(BT_temp==27)longjmp(BT_jumpbuf,1) ; \ + } +#else /* DOS */ +#define BTMAXLINE 30 +#define BT_morep if(++BT_lines>BTMAXLINE){\ + printf("Press Return(to quit Esc and Ret):");\ + BT_temp=getchar();\ + fflush(stdin);\ + BT_lines=0; \ + if(BT_temp==27)longjmp(BT_jumpbuf,1) ; \ + } +#endif /* DOS */ + + +/***************************************************************/ +/* + Func Name : get_ivar_name + + Desc : returns atom index of ivar on the given + FX. + If ivar is localvars then set *localivar + 1 otherwize 0. + + Changed 25 Aug 1987 NMitani + +*/ +/***************************************************************/ + +LispPTR get_ivar_name(struct frameex1 *fx_addr68k, DLword offset, int *localivar) +{ + NAMETABLE *first_table; + NAMETABLE *second_table; + struct fnhead *fnobj; + int i; +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR( + ((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader); +#endif /* BIGVM */ + if (fnobj->ntsize > 0) + { + /* name table exists */ + first_table = (NAMETABLE *)(fnobj + 1); + second_table =(NAMETABLE *)((DLword *)first_table + fnobj->ntsize); + + for(i = 0; (i < fnobj->ntsize) && (GetNTEntry(second_table) != offset) ; + first_table++ , second_table++ , i++) ; + if ((i < fnobj->ntsize) && (GetNTEntry(first_table) != 0)) + { + /* target ivar was in name table */ + *localivar = 0 ; + return((LispPTR)(GetNTEntry(first_table))); + } + else + { + /* Target ivar is in locar vars table */ +#ifdef BIGATOMS + first_table = (NAMETABLE *)(fnobj + 1) + (fnobj->ntsize ); + second_table = first_table + (((DLword *)fnobj + + (fnobj->startpc >> 1) + - (DLword *)first_table) >> 2); +#else + first_table = (NAMETABLE *)(fnobj + 1) + (fnobj->ntsize << 1); + second_table = first_table + (((DLword *)fnobj + + (fnobj->startpc >> 1) - first_table) >> 1); +#endif + } + } + else + { + /* name table doesn't exist, so all ivars are in locar vars table */ +#ifdef BIGATOMS + int delta; + first_table = (NAMETABLE *)(fnobj + 1) + (4>>1); + delta = (DLword *)(((DLword *)fnobj) + + (fnobj->startpc >> 1)) + - (DLword *)first_table; + second_table = first_table + (delta >> 2); +#else + first_table = (NAMETABLE *)(fnobj + 1) + 4; + second_table = first_table + + (((DLword *)fnobj + (fnobj->startpc >> 1) - first_table) >> 1); +#endif + } +#ifdef BIGATOMS + while (*(second_table) != (VTY_IVAR |offset)) +#else + while (GETWORD(second_table) != (VTY_IVAR |offset)) +#endif /* BIGATOMS */ + + { + first_table++ ; + second_table++ ; + } + *localivar = 1 ; + +#ifdef BIGATOMS + return((LispPTR)( *(first_table))); +#else + return((LispPTR)(GETWORD(first_table))); +#endif /* BIGATOMS */ + + + }/* end get_ivar_name */ + + + +/***************************************************************/ +/* + Func Name : get_pvar_name + + Desc : returns atom index of pvar on the given + FX or LOCAL_PVAR if that pvar is localvars. + + Changed 26 Aug 1987 NMitani + +*/ +/***************************************************************/ + +LispPTR get_pvar_name(struct frameex1 *fx_addr68k, DLword offset) +{ + NAMETABLE *first_table; + NAMETABLE *second_table; + struct fnhead *fnobj; + int i; + +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR( + ((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader); +#endif /* BIGVM */ + + first_table = (NAMETABLE *)(fnobj + 1); + second_table =(NAMETABLE *)((DLword *)first_table + fnobj->ntsize); + if (first_table == second_table) return(LOCAL_PVAR); /* no name table */ + + for(i = 0; +#ifdef BIGATOMS + i < (fnobj->ntsize >> 1) && *(second_table) != (VTY_PVAR | offset); +#else + i < fnobj->ntsize && GETWORD(second_table) != (VTY_PVAR | offset); +#endif + first_table++ , second_table++ , i++) /* Do nothing */; + +#ifdef BIGATOMS + if (i < (fnobj->ntsize >> 1)) return((LispPTR) *(first_table)); +#else + if (i < fnobj->ntsize) return((LispPTR)GETWORD(first_table)); +#endif + else return(LOCAL_PVAR); /* Pvar was local */ + }/* end get_pvar_name */ + + + + +/************************************************************************/ +/* */ +/* g e t _ f n _ f v a r _ n a m e */ +/* */ +/* Given (LISP) codeblock addr and an offset return fvar's name */ +/* */ +/************************************************************************/ + +LispPTR get_fn_fvar_name(struct fnhead *fnobj, DLword offset) +{ + NAMETABLE *first_table; + NAMETABLE *second_table; + + first_table = (NAMETABLE *)((DLword *)fnobj + fnobj->fvaroffset); + second_table =(NAMETABLE *)((DLword *)first_table + fnobj->ntsize); +#ifdef BIGATOMS + while (*(second_table) != (VTY_FVAR | offset)) +#else + while (GETWORD(second_table) != (VTY_FVAR | offset)) +#endif /* BIGATOMS */ + + { + first_table++ ; + second_table++; + } +#ifdef BIGATOMS + return((LispPTR) *(first_table)); +#else + return((LispPTR)GETWORD(first_table)); +#endif /* BIGATOMS */ + + + }/* end get_fvar_name */ + + + + +/************************************************************************/ +/* */ +/* g e t _ f v a r _ n a m e */ +/* */ +/* Given an FX and fvar offset, return the atom# for the fvar. */ +/* */ +/************************************************************************/ + +LispPTR get_fvar_name(struct frameex1 *fx_addr68k, DLword offset) +{ +#ifdef BIGVM + get_fn_fvar_name((struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader), offset); +#else + get_fn_fvar_name( + (struct fnhead *)Addr68k_from_LADDR(((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader), offset); +#endif /* BIGVM */ + }/* end get_fvar_name */ + + + +/************************************************************************/ +/* */ +/* s f */ +/* */ +/* Dump the contents of a single frame, given the address of */ +/* the frame as a NATIVE address. */ +/* */ +/* */ +/* */ +/************************************************************************/ + +sf(struct frameex1 *fx_addr68k) +{ + Bframe *bf; + DLword *next68k ; + DLword *ptr ; + DLword *ptrhi ; + DLword *ptrlo ; + LispPTR atomindex ; + int i; + DLword npvar; + DLword max_npvar; + LispPTR pvarindex ; + DLword nfvar; + struct fnhead *fnobj; + int localivar; + LispPTR ivarindex ; + + BT_lines=0; + + if((UNSIGNED)fx_addr68k == 0) return(-1); + if((fx_addr68k)->flags != STK_FX) + { + printf("Invalid FX 0x%x, flags = 0x%x.\n", + LADDR_from_68k(fx_addr68k), + (fx_addr68k)->flags); + return(-1); + } + + if(((fx_addr68k)->alink & 1)==0) + { /* FAST */ + bf = (Bframe *)(((DLword *)fx_addr68k) - 2 ); + } + else + { /* SLOW */ + bf =(Bframe *) Addr68k_from_LADDR(((fx_addr68k)->blink+ STK_OFFSET)) ; + } + + /* Print IVARs */ + printf("IVAR -------\n");BT_morep; + + ptr = Addr68k_from_LADDR( STK_OFFSET + bf->ivar); + i=0; + while(ptr!=(DLword *)bf) + { + ptrhi = ptr; + ptrlo = ptr + 1 ; + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr), + GETWORD(ptr) , GETWORD(ptrlo)); + ivarindex = get_ivar_name(fx_addr68k , i++ , &localivar); + if (localivar == 1) printf("*local* "); + print_atomname(ivarindex); + printf(" "); + print(*(LispPTR *)ptr); + putchar('\n');BT_morep; + ptr += 2 ; + } + putchar('\n');BT_morep; + printf("## STACK BF at 0x%x ##\n",(LispPTR)LADDR_from_68k(bf));BT_morep; + + /* print BF */ + if(bf->flags != 4) {printf("Invalid frame, NOT a BX\n");return(-1);} + putchar('['); + if (bf->residual) printf("Res, "); + if (bf->padding) printf("Pad, "); + printf("cnt=%d ]\n",bf->usecnt);BT_morep; + printf("ivar : 0x%x\n",bf->ivar);BT_morep; + + printf(">> Bf's ivar says 0x%x vs. IVar says 0x%x\n", + bf->ivar+STK_OFFSET,LADDR_from_68k(IVar));BT_morep; + + + atomindex = get_framename(fx_addr68k); + printf("Fname is "); + print(atomindex); + printf("\n");BT_morep; + + /***** printout FX ****/ + printf("## STACK FX at 0x%x ##\n",LADDR_from_68k(fx_addr68k));BT_morep; + + if((fx_addr68k)->flags != 6) + { printf("Invalid frame, NOT FX\n");return(-1);} + + putchar('['); + if((fx_addr68k)->fast) printf("F, "); + if((fx_addr68k)->incall) printf("incall, "); + if(fx_addr68k->validnametable) printf("V, "); + printf("cnt = %d ]\n",fx_addr68k->usecount);BT_morep; + + printf(" #alink 0x%x ",fx_addr68k->alink); + + if(fx_addr68k->alink & 1) printf("[SLOWP]\n"); + else printf("\n"); + + BT_morep; + +#ifdef BIGVM + printf(" fnhead 0x%x \n", fx_addr68k->fnheader);BT_morep; +#else + printf(" fnheadlo 0x%x \n",fx_addr68k->lofnheader);BT_morep; + printf(" hi1,hi2 fnhead 0x%x , 0x%x \n", + fx_addr68k->hi1fnheader,fx_addr68k->hi2fnheader);BT_morep; +#endif /* BIGVM */ + printf(" nextblock 0x%x \n",fx_addr68k->nextblock);BT_morep; + printf(" pc 0x%x \n",fx_addr68k->pc);BT_morep; +#ifdef BIGVM + printf(" nametbl 0x%x \n", fx_addr68k->nametable);BT_morep; +#else + printf(" lonametbl 0x%x \n",fx_addr68k->lonametable);BT_morep; + printf(" hi1,hi2 nametbl 0x%x , 0x%x \n", + fx_addr68k->hi1nametable,fx_addr68k->hi2nametable);BT_morep; +#endif /* BIGVM */ + printf(" #blink 0x%x \n",fx_addr68k->blink);BT_morep; + printf(" #clink 0x%x \n",fx_addr68k->clink);BT_morep; + + /* added by NMitani 26 Aug 87 */ + +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR(fx_addr68k->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR( + ((int)fx_addr68k->hi2fnheader << 16) | fx_addr68k->lofnheader); +#endif /* BIGVM */ + max_npvar = npvar = fnobj->nlocals; /* npvar is number of Pvars */ + if (fnobj->fvaroffset) +#ifdef BIGATOMS + nfvar = *((NAMETABLE *) + ((DLword *)fnobj + fnobj->fvaroffset + fnobj->ntsize)) & NT_OFFSET_MASK; +#else + nfvar = GETWORD((NAMETABLE *) + ((DLword *)fnobj + fnobj->fvaroffset + fnobj->ntsize)) & NT_OFFSET_MASK; +#endif /* BIGATOMS */ + + else nfvar = 0; + + if (fx_addr68k == CURRENTFX) + { + ptr=PVar; + i = 0; + while(npvar-- > 0) + { + ptrhi = ptr; + ptrlo = ptr + 1 ; + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , + GETWORD(ptrlo)); + if ((pvarindex = get_pvar_name(fx_addr68k , i++)) == LOCAL_PVAR) + printf("*local* [pvar%d] " , (i - 1)); + else + print_atomname(pvarindex); + if (GETWORD(ptr) == 0xFFFF) + { + printf(" [variable not bound]\n");BT_morep; + } + else + { + printf(" "); + print(*(LispPTR *)ptr); + putchar('\n'); BT_morep; + } + ptr += 2 ; + } + i = max_npvar; + while(nfvar && nfvar-- >= max_npvar) + { + ptrhi = ptr; + ptrlo = ptr + 1 ; + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , + GETWORD(ptrlo)); + if (0xFFFF == GETWORD(ptrhi)) + { + printf("[not looked up] "); + print_atomname(get_fvar_name(fx_addr68k , i)); + putchar('\n');BT_morep; + } + else if ((0xFFFF & GETWORD(ptrlo)) == 1) + { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k , i)); + printf(" on stack] "); + print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n');BT_morep; + } + else + { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k , i)); + printf(" top value ] "); + print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0xFFF & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n');BT_morep; + } + ptr += 2 ; + i++; + } + if (fx_addr68k->alink == 11) /* for contextsw */ + next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock+STK_OFFSET)) ; + + else next68k = CurrentStackPTR; + while(ptr < next68k) + { + ptrhi = ptr; + ptrlo = ptr + 1 ; + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , + GETWORD(ptrlo)); + print(*(LispPTR *)ptr); + ptr += 2 ; + putchar('\n');BT_morep; + } + printf("this frame is last !!\n");BT_morep; + return(-1); + } + + next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock+STK_OFFSET)) ; + ptr =(DLword *)(fx_addr68k+1) ; + + i = 0; + while(npvar-- > 0) + { + ptrhi = ptr; + ptrlo = ptr + 1 ; + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , + GETWORD(ptrlo)); + if ((pvarindex = get_pvar_name(fx_addr68k , i++)) == LOCAL_PVAR) + printf("*local* [pvar%d] " , (i - 1)); + else + print_atomname(pvarindex); + if (GETWORD(ptr) == 0xFFFF){ + printf(" [variable not bound]\n");BT_morep; + } + else{ + printf(" "); + print(*(LispPTR *)ptr); + putchar('\n'); BT_morep; + } + ptr += 2 ; + } + i = max_npvar; + + while(nfvar && nfvar-- >= max_npvar) + { + ptrhi = ptr; + ptrlo = ptr + 1 ; + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , + GETWORD(ptrlo)); + if (0xFFFF == GETWORD(ptrhi)) + { + printf("[not looked up] "); + print_atomname(get_fvar_name(fx_addr68k , i)); + putchar('\n');BT_morep; + } + else if ((0xFFFF & GETWORD(ptrlo)) == 1) + { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k , i)); + printf(" on stack] "); + print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n');BT_morep; + } + else + { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k , i)); + printf(" top value ] "); + print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n');BT_morep; + } + ptr += 2 ; + i++; + } + + while(next68k > ptr) + { + printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptr++) , + GETWORD(ptr++)); + putchar('\n');BT_morep; + } + return (0); + + } + + + +/************************************************************************/ +/* */ +/* b t */ +/* */ +/* Print the names of the frames on the stack. Equivalent to */ +/* the Lisp DEBUGGER's BT! command. */ +/* */ +/* Changed 26 Aug 1987 NMitani */ +/* Changed May 4, 1988 Take(for URaid) */ +/* */ +/************************************************************************/ + +bt(void) +{ + bt1(CURRENTFX); + } + + +bt1(FX *startFX) +{ + FX *fx ; + struct fnhead *fnobj; + FX *get_nextFX(FX *fx); + int fnum=0; + BT_lines=0; + fx = startFX ; + URaid_FXarray[fnum]=fx; + printf("%3d : ",fnum++); +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR(fx->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR( + ((int)fx->hi2fnheader << 16) | fx->lofnheader); +#endif /* BIGVM */ + printf(" 0x%x : " , LADDR_from_68k(fx)); + print(fnobj->framename); + putchar('\n');BT_morep; + while((fnobj->framename != ATOM_T) && (fx->alink != 11)) + { + if(fnum >URMAXFXNUM-1) + { + /* Internal buf overflow,more than 100 stacks */ + printf("***There are more than 100 stack frames.\n"); + printf("If you want to continue, Uraid will smash its internal table for FX pointer. Do you accept?(Y or N)\n"); + { + int c; + c= getchar();fflush(stdin); + if((c=='Y')||(c=='y')) + { + fnum=0; + memset(URaid_FXarray, 0, URMAXFXNUM *4); + } + else goto bt1_exit; + + } + } + + fx= get_nextFX(fx); +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR(fx->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR( + ((int)fx->hi2fnheader << 16) | fx->lofnheader); +#endif /* BIGVM */ + URaid_FXarray[fnum]=fx; + printf("%3d : ",fnum++); + printf(" 0x%x : " , LADDR_from_68k(fx)); + print(fnobj->framename); + putchar('\n');BT_morep; + } + if (fnobj->framename != ATOM_T) + { + printf(">>root frame for contextsw<<\n"); + putchar('\n');BT_morep; + } + +bt1_exit: URaid_ArrMAXIndex=fnum-1; + URaid_currentFX=0; + }/* end bt */ + + + + +/***************************************************************/ +/* + Func Name : btvv + + Desc : dumps the all stack frame name. + + Changed 4 Sep 1987 NMitani + +*/ +/***************************************************************/ + + + +/************************************************************************/ +/* */ +/* b t v v */ +/* */ +/* Print all stack frames, with variables. Equivalent to the */ +/* Lisp DEBUGGER's BTV! command. */ +/* */ +/* */ +/* */ +/************************************************************************/ + +btvv(void) +{ + struct frameex1 *fx_addr68k; + LispPTR atomindex ; + FX *get_nextFX(FX *fx); + + fx_addr68k = CURRENTFX ; + + atomindex = get_framename(fx_addr68k); + + while((atomindex != ATOM_T) && (fx_addr68k->alink != 11)) + { + sf(fx_addr68k); + fx_addr68k= get_nextFX(fx_addr68k); + atomindex = get_framename(fx_addr68k); + + } + + sf(fx_addr68k); + + printf("\n BTV! end ********\n"); + + +} /*end btvv*/ + + + + +/************************************************************************/ +/* */ +/* s f f */ +/* */ +/* Given the address of a lisp stack frame-extension (FX) */ +/* as a LISP (not native!) address, print the stack frame. */ +/* */ +/* */ +/* NMitani */ +/************************************************************************/ + +sff(LispPTR laddr) +{ + sf((FX *)Addr68k_from_LADDR(laddr)); + } + +#ifdef BIGATOMS +/*****************************************************************/ +/* Nametable debugging aid */ +/* */ +/* nt(index): print function header and name table */ +/* in defcell of Atom index 'index' */ +/*****************************************************************/ +#define DUMPSIZE 40 +#define FNOVERHEADWORDS (8) +nt(LispPTR index) + /* atom index */ + { + struct fnhead *fnobj; + DefCell *defcell68k; + LispPTR cell; + DLbyte *scratch; + int i; + LispPTR *localnt1; + int localntsize; + DLword fnobj_lisp; + + defcell68k = (DefCell *)GetDEFCELL68k(index); + fnobj = (struct fnhead *)Addr68k_from_LADDR(defcell68k->defpointer); + + /* check if it's the same index ??*/ + if (index != (fnobj->framename)) + { + printf("DEFCELL says it is "); + print_atomname(index); + printf("\n But Func OBJ says "); + print_atomname(fnobj->framename); + putchar('\n'); + return; + } + + printf("***DUMP Func Header << "); + printf("start at 0x%x lisp address(0x%x 68k)\n", + LADDR_from_68k(fnobj),fnobj); + print(index); + putchar('\n'); + + ntheader(fnobj); +} + +ntheader(struct fnhead *fnobj) +{ + LispPTR *localnt1; + int localntsize; + LispPTR *fnobj_lisp; + + fnobj_lisp = (LispPTR *)LADDR_from_68k((DLword *)fnobj); + printf("0x%06x: 0x%08x stkmin\n",fnobj_lisp,fnobj->stkmin); + printf("0x%06x: 0x%08x na\n",fnobj_lisp+1, fnobj->na); + printf("0x%06x: 0x%08x pv\n",fnobj_lisp+2, fnobj->pv); + printf("0x%06x: 0x%08x startpc\n",fnobj_lisp+3,fnobj->startpc); + printf("0x%06x: 0x%08x argtype\n",fnobj_lisp+4,fnobj->argtype); + printf("0x%06x: 0x%08x framename ",fnobj_lisp+5,fnobj->framename); + print(fnobj->framename); + putchar('\n'); + printf("0x%06x: 0x%08x ntsize\n",fnobj_lisp+6,fnobj->ntsize); + printf("0x%06x: 0x%08x nlocals",fnobj_lisp+7,fnobj->nlocals); + printf(" 0x%08x fvaroffset\n",fnobj->fvaroffset); + + nt1((LispPTR *)((DLword *)fnobj + FNOVERHEADWORDS), fnobj->ntsize, "Name Table" ); + localnt1= (LispPTR *)((DLword *)fnobj + FNOVERHEADWORDS + (fnobj->ntsize ? (2 * fnobj->ntsize) : 4)); + localntsize = ((DLword *)fnobj + (fnobj->startpc >> 1) - (DLword *)localnt1) >> 1; + nt1(localnt1,localntsize,"Local args"); + + } + +nts(struct frameex1 *fxp) +{ + struct fnhead *nt; + +#ifdef BIGVM + if(fxp->validnametable) + nt = (struct fnhead *) (Addr68k_from_LADDR(fxp->nametable )); + else + nt = (struct fnhead *) (Addr68k_from_LADDR(fxp->fnheader )); +#else + if(fxp->validnametable) + nt = (struct fnhead *) + (Addr68k_from_LADDR(((fxp->hi2nametable)<<16 | + fxp->lonametable ))); + else + nt = (struct fnhead *) + (Addr68k_from_LADDR(((fxp->hi2fnheader)<<16 | + fxp->lofnheader ))); +#endif /* BIGVM */ + ntheader(nt); +} + +#define VARTYPE_FVAR (3) +#define VARTYPE_PVAR (2) +#define VARTYPE_IVAR (0) + +#define VAROFFSET(X) (X & 0xFFFFFFF) + +nt1(LispPTR *start, int size, char *str) +{ + LispPTR *endp, *entry2p; + + printf("\n---- %s ----\n", str); + size = size >> 1; /* originally size is # of word. now size is # of int */ + endp = start + size; + while( start < endp ){ + entry2p = start+size; + printf("0x%06x: 0x%08x", + LADDR_from_68k((DLword *)start), *start); + printf(" 0x%06x: 0x%08x", + LADDR_from_68k((DLword *)entry2p), *entry2p); + if(*start != 0){ + if((*entry2p >> 30)== VARTYPE_FVAR) + printf(" FVAR"); + else if((*entry2p >> 30)== VARTYPE_PVAR) + printf(" PVAR"); + else if((*entry2p >> 30)== VARTYPE_IVAR) + printf(" IVAR"); + else + printf(" ????"); + printf("%2d ", VAROFFSET(*entry2p)); + print_atomname(*start); + } + putchar('\n'); + start++; + } +} + +#endif diff --git a/src/dir.c b/src/dir.c new file mode 100755 index 0000000..1fbf8a8 --- /dev/null +++ b/src/dir.c @@ -0,0 +1,2420 @@ +/* $Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +#include +#include +#ifndef DOS +#include +#ifndef OS5 +#include +#endif /* OS5 */ +#include +#include +#include + +#ifndef SYSVONLY +#include +/* #else */ +/* #include */ +#endif /* SYSVONLY */ + +#ifdef LINUX +#include +#endif /* LINUX */ + +#ifdef INDIGO +#include +#endif + +#ifdef RISCOS +#include +#define direct dirent +#endif /* RISCOS */ + +#ifdef ISC +#include +#include +#include +#define direct dirent +#endif /* ISC */ + +#else /* DOS, now */ +#include +#include +#include +#include +#include +#include +#define index strchr +#define rindex strrchr +#define MAXPATHLEN _MAX_PATH +#define MAXNAMLEN _MAX_PATH +#define alarm(x) 1 +#endif /* DOS */ + + +#ifdef SYSVONLY +#include +#endif /* SYSVONLY */ + +#ifdef OS5 +#include +#define direct dirent +#endif + + +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "lspglob.h" +#include "timeout.h" +#include "locfile.h" + +extern int* Lisp_errno; +extern int Dummy_errno; + +#define DIRCHAR '>' + +/************************************************************************ + SUBROUTINES + For pattern matching check +************************************************************************/ + +/* + * Name: SetupMatch + * + * Argument: char *tname Target name including name ,extension and version. + * char *pname Pattern including name and extenstion. + * char *text The place where separated target extension will be + * stored. + * char *pext The place where separated pattern extension will be + * stored. + * char *tver The place where separated target version will be + * stored. + * + * Value: N/A + * + * Side Effect: The string tname and pname points are destructivly modified. + * + * Description: + * + * Split target and pattern to each component for the convinience of match_pattern + * routine. + */ + +#define SetupMatch(tname, pname, text, pext, tver) { \ + register char *pp; \ + \ + separate_version(tname, tver, 0); \ + \ + if ((pp = (char *)rindex(tname, '.')) == NULL) { \ + *text = '\0'; \ + } else { \ + *pp = '\0'; \ + strcpy(text, pp + 1); \ + } \ + \ + if ((pp = (char *)rindex(pname, '.')) == NULL) { \ + *pext = '\0'; \ + } else { \ + *pp = '\0'; \ + strcpy(pext, pp + 1); \ + } \ + } + +#define MatchP(target, name, ver, matchtag, unmatchtag) { \ + \ + char tname[MAXNAMLEN], text[MAXNAMLEN], tver[VERSIONLEN]; \ + char pname[MAXNAMLEN], pext[MAXNAMLEN]; \ + \ + strcpy(tname, target); \ + DOWNCASE(tname); \ + strcpy(pname, name); \ + DOWNCASE(pname); \ + \ + SetupMatch(tname, pname, text, pext, tver); \ + \ + if (match_pattern(tname, pname) && \ + match_pattern(text, pext) && \ + match_pattern(tver, ver)) \ + goto matchtag; \ + else \ + goto unmatchtag; \ +} + +#define MatchP_Case(target, name, ver, matchtag, unmatchtag) { \ + \ + char tname[MAXNAMLEN], text[MAXNAMLEN], tver[VERSIONLEN]; \ + char pname[MAXNAMLEN], pext[MAXNAMLEN]; \ + \ + strcpy(tname, target); \ + strcpy(pname, name); \ + \ + SetupMatch(tname, pname, text, pext, tver); \ + \ + if (match_pattern(tname, pname) && \ + match_pattern(text, pext) && \ + match_pattern(tver, ver)) \ + goto matchtag; \ + else \ + goto unmatchtag; \ +} + +/* + * Name: match_pattern + * + * Argument: char *tp String which is matched against pattern. + * char *pp String represents a pattern. + * + * Value: If target is regarded to match with pattern, returns 1, otherwise 0. + * + * Side Effect: None. + * + * Description: + * + * Matches string against pattern. Wild character is '*', it matches to arbitrary + * number of characters. + */ + +match_pattern(tp, pp) + register char *tp; + register char *pp; +{ + register char *tsp, *psp; + register int inastr; + +#ifdef DOS + /* % is not allowed in DOS names for Medley. */ + if (strchr(tp, '%')) return 0; + +#endif /* DOS */ + + for (tsp = tp, psp = pp, inastr = 0;;tp++, pp++) { + switch (*pp) { + + case '\0': + return ((*tp == '\0') ? 1 : 0); + + case '*': + while (*pp == '*') pp++; /* Skip successive '*'s. */ + if (*pp == '\0') return(1); + + psp = pp; + while (*tp != *pp && *tp != '\0') tp++; + + if (*tp == '\0') return(0); + + tsp = tp; + inastr = 1; + + continue; + + default: + if (*tp == *pp) continue; + + if (inastr) { + /* + * Try to find a character which match to + * a character psp points from a charcter + * next to tsp. If found retry from there. + */ + for (tp = tsp + 1; + *tp != '\0' && *tp != *psp; + tp++) {} + if (*tp == '\0') return(0); + pp = psp; + tsp = tp; + continue; + } else { + return(0); + } + } + } +} + + + +#ifdef DOS + +int make_old_version(old, file) + char *old, *file; + { + int len = (int)strlen(file)-1; + if(file[len] == DIRCHAR) return 0; + /* look up old versions of files for version # 0's */ + strcpy(old, file); + + if (old[len] == '.') strcat(old, "%"); + else if ( (len > 0) && old[len-1] == '.') strcat(old, "%"); + else if ( (len > 1) && old[len-2] == '.') strcat(old, "%"); + else if ( (len > 2) && old[len-3] == '.') old[len] = '%'; + else strcat(old, ".%"); + return 1; + } +#endif /* DOS */ + + + +/************************************************************************/ +/******** E N D O F P A T T E R N - M A T C H I N G C O D E *******/ +/************************************************************************/ + +/************************************************************************/ +/************ B E G I N O F F I L E - I N F O C O D E **************/ +/************************************************************************/ + +/* + * FINFO and FPROP are used to store the information of the enumerated files + * and directories. They are arranged in a form of linked list. Each list is + * corresponding to the each directory enumeratreion. All of the informations + * Lisp needs are stored in the list. This list is in the emulator's address space + * and can be specified by "ID" which is the interface between the emulator and Lisp + * code. In this implementation, ID is represeted as an integer and is actually + * an index of the array of the lists. + * + * To avoid the overhead of the FINFO and FPROP structure dynamic allocation and + * deallocation, some number of their instances are pre-allocated when the emulator + * starts and managed in a free list. If all of the pre-allocated instances are in + * use, new instances are allocated. The new instances are linked to the free list + * when it is freed. + * + * As described above, the linked list result of the enumeration is stored in a + * array for the subsequent request from Lisp. Lisp code requests the emulator to + * release the list when it enumerated all of the entries in the list or the + * enumerating operation is aborted. + */ + +typedef struct fprop { + unsigned length; /* Byte length of this file. */ + unsigned wdate; /* Written (Creation) date in Lisp sense. */ + unsigned rdate; /* Read date in Lisp sense. */ + unsigned protect; /* Protect mode of this file. */ + char author[256]; /* Author in Lisp sense. */ + u_short au_len; /* Byte length of author. */ + unsigned long nil; /* padding to 8-byte multiple */ +} FPROP; + + /* This structure has a pointer at each end to force alignment to + be correct when a pointer is 8 bytes long. */ +typedef struct finfo { + FPROP *prop; /* File properties Lisp needs. */ + char lname[MAXNAMLEN]; /* Name in Lisp Format. */ + u_short lname_len; /* Byte length of lname. */ + char no_ver_name[MAXNAMLEN]; + /* + * Name in UNIX Format. Does not + * include Version field. + * All lower case. + */ + ino_t ino; /* I-node number of this file. */ + unsigned version; /* Version in Lisp sense. */ + u_short dirp; /* If 1, this file is a directory. */ + struct finfo *next; /* + * Link to a next entry. Last entry is + * indicated by NULL pointer. + */ +} FINFO; + +typedef struct dfinfo { + FINFO *head; /* Head of the linked FINFO structures. */ + FINFO *next; /* FINFO structure generated next time. */ +} DFINFO; + +FINFO *FreeFinfoList; +#define INITFINFONUM 1024 + +DFINFO *FinfoArray; +#define INITFINFOARRAY 32 + +unsigned MAXFINFO; + +#define FINFOARRAYRSIZE 16 + +#define AllocFinfo(fp) { \ + if (FreeFinfoList != (FINFO *)NULL) { \ + fp = FreeFinfoList; \ + FreeFinfoList = fp->next; \ + } else if ((fp = (FINFO *)calloc(1, sizeof(FINFO))) == NULL) { \ + fp = (FINFO *)NULL; \ + } else if ((fp->prop = (FPROP *)calloc(1, sizeof(FPROP))) == NULL) { \ + free(fp); \ + fp = (FINFO *)NULL; \ + } \ +} + +#define FreeFinfo(fp) { \ + register FINFO *lastp; \ + for (lastp = fp; lastp->next != (FINFO *)NULL; lastp = lastp->next) {} \ + lastp->next = FreeFinfoList; \ + FreeFinfoList = fp; \ +} + +/* + * For debug aid. + */ + +#ifdef FSDEBUG +print_finfo(fp) + FINFO *fp; +{ + FINFO *sp; + sp = fp; + + if (fp != (FINFO *)NULL) { + do { + printf("%s -> ", fp->lname); + printf("%d\n", fp->version); + fp = fp->next; + } while (fp != (FINFO *)NULL && fp != sp); + + if (fp = sp) printf("Circular detected!\n"); + } +} +#endif /* FSDEBUG */ + + +/* + * Name: init_finfo + * + * Argument: None. + * + * Value: If suceed, returns 1, otherwise 0. + * + * Side Effect: FreeFinfoList will point to the alloced area. MAXFINFO will hold + * the total number of allocated instances of FINFO structure. + * + * Description: + * + * Allocates the storage for the instances of FINFO and FPROP structure and arrange + * them to build a linked list. + * This routine is invoked at very first stage of emulator start up. + */ + +init_finfo() +{ + register FINFO *cp; + register int n; + + if ((FreeFinfoList = + (FINFO *)calloc(sizeof(FINFO) + sizeof(FPROP), INITFINFONUM)) + == (FINFO *)NULL) { + *Lisp_errno = errno; + return(0); + } + for (cp = FreeFinfoList, n = INITFINFONUM; n > 1; n--) { + cp->prop = (FPROP *)(cp + 1); + cp->next = (FINFO *)((char *)cp + sizeof(FINFO) + sizeof(FPROP)); + cp = cp->next; + } + cp->prop = (FPROP *)(cp + 1); + cp->next = (FINFO *)NULL; + + if ((FinfoArray = (DFINFO *)calloc(sizeof(DFINFO), INITFINFOARRAY)) + == (DFINFO *)NULL) { + *Lisp_errno = errno; + return(0); + } + MAXFINFO = INITFINFOARRAY; + + return(1); +} + +/* + * Name: get_finfo_id + * + * Argument: None. + * + * Value: If suceed, returns the id of linked list of FINFO structures, + * otherwise -1. + * + * Side Effect: If needed, FinfoArray will be extened according to the value of + * FINFOARRAYRSIZE. + * + * Description: + * + * Get an ID which can be used to name a linked list of FINFO structure. ID is + * represeted as an integer, and it is actualy an index of an array FinfoArray. + * + * If all entries of FinfoArray is occupied by linked lists of FINFO structures, + * extended storage is allocated and old contents of the array are copied to the + * new area. The size of the extended part is decided by the value of + * FINFOARRAYRSIZE. + */ + +get_finfo_id() +{ + register int i; + DFINFO *dfap; + + for (i = 0; i < MAXFINFO; i++) if (FinfoArray[i].head == (FINFO *)0) + return (i); + + if ((dfap = (DFINFO *)calloc(sizeof(DFINFO), MAXFINFO + FINFOARRAYRSIZE)) + == (DFINFO *)NULL) { + *Lisp_errno = errno; + return(-1); + } + for (i = 0; i < MAXFINFO; i++) { + dfap[i].head = FinfoArray[i].head; + dfap[i].next = FinfoArray[i].next; + } + free(FinfoArray); + MAXFINFO += FINFOARRAYRSIZE; + FinfoArray = dfap; + return(i); +} + +/* + * Name: enum_dsk_prop + * + * Argument: char *dir Absolute path of directory in UNIX format. + * char *name Pattern specify the files to be enumerated. + * char *ver String representation of version should be + * enumerated. + * FINFO **finfo_buf + * The place where linked list of FINFO structures + * reslt of the enumeration will be stored. + * + * Value: If suceed, returns the number of enumerated files, otherwise -1. + * + * Side Effect: None. + * + * Description: + * + * Enumerates files and directories matching to the pattern on the specified + * directory. The pattern matching is done in case insensitive manner. + * File properties Lisp will need later are also stored in the result linked list + * of FINFO structures. + */ + +#ifdef DOS +enum_dsk_prop(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval, res, isslash = 0, drive = 0; + struct find_t dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; + char old[MAXNAMLEN]; + + + + /* The null directory has to be special cased */ + /* because adjacent \'s in the pathname don't match anything */ + if (dir[1] == DRIVESEP) drive = dir[0]; + + if (strcmp(dir, "\\")==0) isslash = 1; + else if (drive && (strcmp(dir+2, "\\")==0)) isslash = 1; + + if (!isslash) strcpy(namebuf, dir); /* Only add the dir if it's real */ + else if (drive) + { + namebuf[0] = drive; + namebuf[1] = DRIVESEP; + namebuf[2] = '\0'; + } + else *namebuf = '\0'; + + strcat(namebuf,DIRSEPSTR); + strcat(namebuf, name); + + + TIMEOUT(res = _dos_findfirst(namebuf, _A_NORMAL|_A_SUBDIR, &dirp)); + if (res < 0) { + *Lisp_errno = errno; + return(-1); + } + + for (nextp = prevp = (FINFO *)NULL, n = 0; + res == 0; + S_TOUT(res = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; + MatchP(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + if (isslash) + { + if (drive) sprintf(namebuf,"%c:\\%s", drive, dirp.name); + else sprintf(namebuf, "\\%s", dirp.name); + } + else sprintf(namebuf, "%s\\%s", dir, dirp.name); + + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dirp.name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + strcat(namebuf,".~1~"); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); + len = strlen(namebuf); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + nextp->version = 1; + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; + /* TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } */ + n++; + } + + + /***********************/ + /* Now go looking for version-0 entries */ + /***********************/ + + for (nextp = prevp; nextp; nextp = nextp -> next) + { + FINFO *newp; + + if (!make_old_version(old, nextp->no_ver_name)) continue; + + if (isslash) + { + if (drive) sprintf(namebuf,"%c:\\%s", drive, old); + else sprintf(namebuf, "\\%s", old); + } + else sprintf(namebuf, "%s\\%s", dir, old); + TIMEOUT(rval = stat(namebuf, &sbuf)); + + if (rval == -1 ) continue; + + AllocFinfo(newp); + newp->next = prevp; + /* All other types than directory. */ + newp->dirp = 0; + sprintf(namebuf, "%s.~00~", nextp->no_ver_name); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(newp->lname, namebuf); + *(newp->lname + len) = '\0'; + newp->lname_len = len; + + strcpy(newp->no_ver_name, old); + newp->version = 0; + newp->ino = sbuf.st_ino; + newp->prop->length = (unsigned)sbuf.st_size; + newp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + newp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + newp->prop->protect = (unsigned)sbuf.st_mode; + n++; + prevp = newp; + } + if (n > 0) *finfo_buf = prevp; + return(n); +} +#else /* DOS */ +enum_dsk_prop(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; + + errno=0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return(-1); + } + + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno=0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) + { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || + dp->d_ino == 0) continue; + MatchP((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + separate_version(namebuf, fver, 1); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + if (*fver == '\0') + nextp->version = 0; + else + nextp->version = atoi(fver); + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return(n); +} +#endif /* DOS */ + +/* + * Name: enum_dsk + * + * Argument: char *dir Absolute path of directory in UNIX format. + * char *name Pattern specify the files to be enumerated. + * char *ver String representation of version should be + * enumerated. + * FINFO **finfo_buf + * The place where linked list of FINFO structures + * reslt of the enumeration will be stored. + * + * Value: If suceed, returns the number of enumerated files, otherwise -1. + * + * Side Effect: None. + * + * Description: + * + * Similar to enum_dsk_prop, but file properties are not stored. + */ +#ifdef DOS +enum_dsk(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval, isslash = 0, drive = 0; + struct find_t dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; + char old[MAXPATHLEN]; + + + /* The null directory has to be special cased */ + /* because adjacent \'s in the pathname don't match anything */ + if (dir[1] == DRIVESEP) drive = dir[0]; + + if (strcmp(dir, "\\")==0) isslash = 1; + else if (drive && (strcmp(dir+2, "\\")==0)) isslash = 1; + + if (!isslash) strcpy(namebuf, dir); /* Only add the dir if it's real */ + else if (drive) + { + namebuf[0] = drive; + namebuf[1] = DRIVESEP; + namebuf[2] = '\0'; + } + else *namebuf = '\0'; + + strcat(namebuf,DIRSEPSTR); + strcat(namebuf, name); + + + TIMEOUT(rval = _dos_findfirst(namebuf, _A_NORMAL|_A_SUBDIR, &dirp)); + if (rval != 0) + { + *Lisp_errno = errno; + return(-1); + } + + for (nextp = prevp = (FINFO *)NULL, n = 0; + rval == 0; + S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) + { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; + MatchP(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + if (isslash) + { + if (drive) sprintf(namebuf,"%c:\\%s", drive, dirp.name); + else sprintf(namebuf, "\\%s", dirp.name); + } + else sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dirp.name); /* moved from below 2/26/93 */ + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + strcat(namebuf,".~1~"); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); /* to get real versionless name */ + len = strlen(namebuf); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + nextp->version = 1; + nextp->ino = sbuf.st_ino; + n++; + } + + /***********************/ + /* Now go looking for version-0 entries */ + /***********************/ + + for (nextp = prevp; nextp; nextp = nextp -> next) + { + FINFO *newp; + + if (!make_old_version(old, nextp->no_ver_name)) continue; + + if (isslash) + { + if (drive) sprintf(namebuf,"%c:\\%s", drive, old); + else sprintf(namebuf, "\\%s", old); + } + else sprintf(namebuf, "%s\\%s", dir, old); + TIMEOUT(rval = stat(namebuf, &sbuf)); + + if (rval == -1 ) continue; + + AllocFinfo(newp); + newp->next = prevp; + /* All other types than directory. */ + newp->dirp = 0; + sprintf(namebuf, "%s.~00~", nextp->no_ver_name); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(newp->lname, namebuf); + *(newp->lname + len) = '\0'; + newp->lname_len = len; + + strcpy(newp->no_ver_name, old); + newp->version = 0; + newp->ino = sbuf.st_ino; + n++; + prevp = newp; + } + + if (n > 0) *finfo_buf = prevp; + return(n); + } + +#else /* DOS */ + +enum_dsk(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; + + errno=0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return(-1); + } + + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno=0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) + { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || + dp->d_ino == 0) continue; + MatchP((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + separate_version(namebuf, fver, 1); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + if (*fver == '\0') + nextp->version = 0; + else + nextp->version = atoi(fver); + nextp->ino = sbuf.st_ino; + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return(n); +} +#endif /* DOS */ + +/* + * Name: enum_ufs_prop + * + * Argument: char *dir Absolute path of directory in UNIX format. + * char *name Pattern specify the files to be enumerated. + * char *ver String representation of version should be + * enumerated. + * FINFO **finfo_buf + * The place where linked list of FINFO structures + * reslt of the enumeration will be stored. + * + * Value: If suceed, returns the number of enumerated files, otherwise -1. + * + * Side Effect: None. + * + * Description: + * + * Enumerates files and directories matching to the pattern on the specified + * directory. The pattern matching is done in case sensitive manner. + * File properties Lisp will need later are also stored in the result linked list + * of FINFO structures. + */ +#ifdef DOS +enum_ufs_prop(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + struct find_t dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + + TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); + if (rval != 0) { + *Lisp_errno = errno; + return(-1); + } + + for (nextp = prevp = (FINFO *)NULL, n = 0; + rval == 0; + S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; + MatchP_Case(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dirp.name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; +/* + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } +*/ + n++; + } + if (n > 0) *finfo_buf = prevp; + return(n); +} +#else /* DOS */ +enum_ufs_prop(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + + errno = 0; + TIMEOUT(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return(-1); + } + + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) + { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || + dp->d_ino == 0) continue; + MatchP_Case((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; +/* + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } +*/ + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return(n); +} +#endif /* DOS */ + +/* + * Name: enum_ufs + * + * Argument: char *dir Absolute path of directory in UNIX format. + * char *name Pattern specify the files to be enumerated. + * char *ver String representation of version should be + * enumerated. + * FINFO **finfo_buf + * The place where linked list of FINFO structures + * reslt of the enumeration will be stored. + * + * Value: If suceed, returns the number of enumerated files, otherwise -1. + * + * Side Effect: None. + * + * Description: + * + * Similar to enum_ufs_prop, but file properties are not stored. + */ +#ifdef DOS +enum_ufs(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + struct find_t dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + + TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); + if (rval != 0) { + *Lisp_errno = errno; + return(-1); + } + + for (nextp = prevp = (FINFO *)NULL, n = 0; + rval == 0; + S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; + MatchP_Case(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dirp.name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + n++; + } + if (n > 0) *finfo_buf = prevp; + return(n); +} +#else /* DOS */ +enum_ufs(dir, name, ver, finfo_buf) + char *dir; + char *name; + char *ver; + FINFO **finfo_buf; +{ + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + + errno = 0; + TIMEOUT(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return(-1); + } + + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) + { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || + dp->d_ino == 0) continue; + MatchP_Case((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return(-1); + } + + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return(n); +} +#endif /* DOS*/ + + + +/* + * Name: trim_finfo + * + * Argument: FINFO **fp Linked list of the numerated FINFO structures. + * + * Value: Returns the total number of files still remaining in **fp. + * + * Side Effect: None. + * + * Description: + * + * Giving the linked list of FINFO, take care of versionless files. If the + * versionless file is not linked any higher versioned file, it is given a highest + * version. If versionless file is linked to one of versioned file, it is got + * rid of. + * This routine is only used by DSK codes. + */ + +trim_finfo(fp) + FINFO **fp; +{ +#ifndef DOS + register FINFO *tp, *sp, *mp, *cp, *pp; + register int num, pnum; + int linkp; + char ver[VERSIONLEN]; + + sp = mp = cp = *fp; + pp = (FINFO *)NULL; + num = pnum = 0; + + do { + if (cp->dirp) { + pp = cp; + sp = cp = cp->next; + pnum++; + num++; + continue; + } + + if (cp->next != (FINFO *)NULL && + strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + mp = cp = cp->next; + num++; + while (cp->next != (FINFO *)NULL && + strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + cp = cp->next; + num++; + } + } else { + mp = cp; + } + + if (sp->version == 0) { + if (cp != sp) { + /* + * Both versionless and versioned files exists. + */ + linkp = 0; + tp = sp; + do { + tp = tp->next; + if (tp->ino == sp->ino) { + linkp = 1; + break; + } + } while (cp != tp); + + if (!linkp) { + /* + * Versionless is not linked to any versioned + * file. + */ + sprintf(ver, ";%d", mp->version + 1); + strcat(sp->lname, ver); + sp->lname_len = strlen(sp->lname); + pnum = ++num; + pp = cp; + sp = cp = cp->next; + } else { + /* + * Versionless is linked to one of versionless + * files. We can remove it. + */ + sp->next = (FINFO *)NULL; + FreeFinfo(sp); + pnum = num; + if (pp != (FINFO *)NULL) + pp->next = mp; + else + *fp = mp; + pp = cp; + sp = cp = cp->next; + } + } else { + /* + * Only versionless file exists. It is regarded as + * version 1. + */ + strcat(cp->lname, ";1"); + cp->lname_len += 2; + pp = cp; + sp = cp = cp->next; + num = ++pnum; + } + } else { + if (cp != sp) { + /* + * All files are versioned. + */ + pnum = ++num; + } else { + /* + * A versioned file only exists. + */ + num = ++pnum; + } + pp = cp; + sp = cp = cp->next; + } + } while (sp != (FINFO *)NULL) ; + +#else /* DOS version */ + int num = 0; + FINFO *tp; + tp = *fp; + while (tp) { num++; tp = tp->next; } +#endif /* DOS */ + + return(num); +} + +/* + * Name: trim_finfo_highest + * + * Argument: FINFO **fp Linked list of the numerated FINFO structures. + * + * Value: Returns the total number of files still remaining in **fp. + * + * Side Effect: None. + * + * Description: + * + * Similar to true_finfo, but the files but the highest versioned file are got rid + * of. + */ + +trim_finfo_highest(fp, highestp) + FINFO **fp; + int highestp; +{ + register FINFO *tp, *sp, *mp, *cp, *pp; + register int num, pnum; + int linkp; + char ver[VERSIONLEN]; + + sp = mp = cp = *fp; + pp = (FINFO *)NULL; + num = pnum = 0; + + do { + if (cp->dirp) { + pp = cp; + sp = cp = cp->next; + pnum++; + num++; + continue; + } + + if (cp->next != (FINFO *)NULL && + strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + mp = cp = cp->next; + num++; + while (cp->next != (FINFO *)NULL && + strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + cp = cp->next; + num++; + } + } else { + mp = cp; + } + + if (sp->version == 0) { + if (cp != sp) { + /* + * Both versionless and versioned files exists. + */ + linkp = 0; + tp = sp; + do { + tp = tp->next; + if (tp->ino == sp->ino) { + linkp = 1; + break; + } + } while (cp != tp); + + if (!linkp) { + /* + * Versionless is not linked to any versioned + * file. + */ + sprintf(ver, ";%d", mp->version + 1); + strcat(sp->lname, ver); + sp->lname_len = strlen(sp->lname); + /* + * Lower versioned files, mp to cp + * inclusive, should be removed. + */ + sp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(mp); + num = ++pnum; + pp = sp; + sp = cp = pp->next; + } else { + /* + * Versionless is linked to one of versionless + * files. We can remove it. + */ + + if (mp != cp) { + sp->next = mp->next; + mp->next = cp->next; + cp->next = (FINFO *)NULL; + } else { + sp->next = (FINFO *)NULL; + } + FreeFinfo(sp); + num = ++pnum; + if (pp != (FINFO *)NULL) + pp->next = mp; + else + *fp = mp; + pp = mp; + sp = cp = mp->next; + } + } else { + /* + * Only versionless file exists. It is regared as + * version 1. + */ + strcat(cp->lname, ";1"); + cp->lname_len += 2; + pp = cp; + sp = cp = cp->next; + num = ++pnum; + } + } else { + if (cp != sp) { + /* + * All files are versioned. + * Lower versioned files can be removed. + */ + tp = sp->next; + sp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(tp); + num = ++pnum; + } else { + /* + * A versioned file only exists. + */ + num = ++pnum; + } + pp = sp; + sp = cp = sp->next; + } + } while (sp != (FINFO *)NULL) ; + + return(num); +} + +/* + * Name: trim_finfo_version + * + * Argument: FINFO **fp Linked list of the numerated FINFO structures. + * int rver Requested version number. + * + * Value: Returns the total number of files still remaining in **fp. + * + * Side Effect: None. + * + * Description: + * + * Similar to true_finfo, but the files but the versioned file with specified version + * are got rid of. + */ + +trim_finfo_version(fp, rver) + FINFO **fp; + int rver; +{ + register FINFO *tp, *sp, *mp, *cp, *pp, *vp; + register int num, pnum; + int linkp; + char ver[VERSIONLEN]; + + sp = mp = cp = *fp; + pp = (FINFO *)NULL; + num = pnum = 0; + + do { + if (cp->dirp) { + /* + * Directory has no version, thus they should be remvoed. + */ + sp = cp = cp->next; + continue; + } + + if (cp->next != (FINFO *)NULL && + strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + mp = cp = cp->next; + num++; + while (cp->next != (FINFO *)NULL && + strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + cp = cp->next; + num++; + } + } else { + mp = cp; + } + + for (tp = sp, vp = (FINFO *)NULL; tp != cp->next; tp = tp->next) { + if (tp->version == rver) { + vp = tp; + break; + } + } + + if (vp != (FINFO *)NULL) { + /* + * Specified version file exists. Other files should be + * removed. + */ + if (vp == sp) { + if (cp != sp) { + vp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(mp); + } + } else { + for (tp = sp; tp->next != vp; tp = tp->next) {} + if (vp != cp) { + tp->next = vp->next; + vp->next = cp->next; + cp->next = (FINFO *)NULL; + } else { + tp->next = (FINFO *)NULL; + } + if (pp != (FINFO *)NULL) + pp->next = vp; + else + *fp = vp; + FreeFinfo(sp); + } + pp = vp; + sp = cp = vp->next; + num = ++pnum; + continue; + + } + + /* + * Although there is no file with specified version, versionless + * file might be interpreted the specified version. + */ + if (sp->version == 0) { + if (cp != sp) { + /* + * Both versionless and versioned files exists. + */ + linkp = 0; + tp = sp; + do { + tp = tp->next; + if (tp->ino == sp->ino) { + linkp = 1; + break; + } + } while (cp != tp); + + if (!linkp) { + /* + * Versionless is not linked to any versioned + * file. + */ + if (mp->version + 1 == rver) { + sprintf(ver, ";%d", rver); + strcat(sp->lname, ver); + sp->lname_len = strlen(sp->lname); + /* + * Lower versioned files, mp to cp + * inclusive, should be removed. + */ + sp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(mp); + num = ++pnum; + pp = sp; + sp = cp = pp->next; + } else { + /* + * sp to cp inclusive, all files, + * should be removed. + */ + tp = cp->next; + if (pp != (FINFO *)NULL) + pp->next = tp; + else + *fp = tp; + cp->next = (FINFO *)NULL; + FreeFinfo(sp); + sp = cp = tp; + } + } else { + /* + * Versionless is linked to one of versionless + * files. We can remove all files, because + * no versioned file match with rver. + */ + tp = cp->next; + if (pp != (FINFO *)NULL) + pp->next = tp; + else + *fp = tp; + cp->next = (FINFO *)NULL; + FreeFinfo(sp); + sp = cp = tp; + } + } else { + /* + * Only versionless file exists. It is regared as + * version 1. Unless rver is 1, we can remove it. + */ + if (rver != 1) { + cp = sp->next; + if (pp != (FINFO *)NULL) + pp->next = cp; + else + *fp = cp; + sp->next = (FINFO *)NULL; + FreeFinfo(sp); + sp = cp; + } else { + strcat(cp->lname, ";1"); + cp->lname_len += 2; + pp = cp; + sp = cp = cp->next; + num = ++pnum; + } + } + } + } while (sp != (FINFO *)NULL) ; + + return(num); +} + +/************************************************************************/ +/************ E N D O F F I L E - I N F O C O D E *****************/ +/************************************************************************/ + +/************************************************************************/ +/********* B E G I N O F F I L E - S O R T I N G C O D E ***********/ +/************************************************************************/ + +/* + * Name: prepare_sort_buf + * + * Argument: FINFO *fp Linked list of FINFO structures being sorted. + * int n Total number of structures in the above list. + * + * Value: If succeed, returns the pointer to the buffer, otherwise NULL + * pointer. + * + * Side Effect: (sizeof(FINFO *) * n) bytes storage are allocated as a sort buffer. + * + * Description: + * + * Prepare an area to be used as a sort buffer by qsort routine, and arrange the + * contents of the buffer to be convinience to qsort routine. + * Caller have to free the area after sorting done. + */ + +FINFO ** +prepare_sort_buf(fp, n) + register FINFO *fp; + register int n; +{ + register FINFO **bp; + register FINFO **bufp; + + if ((bufp = (FINFO **)malloc(sizeof(FINFO *) * n)) == NULL) { + *Lisp_errno = errno; + return((FINFO **)NULL); + } + for (bp = bufp; fp != (FINFO *)NULL; fp = fp->next, bp++) *bp = fp; + + return(bufp); +} + +/* + * Name: dsk_filecmp + * + * Argument: FINFO *fp1 A FINFO structure, a file name in it is being compared. + * FINFO *fp2 A FINFO structure, a file name in it is being compared. + * + * Value: Returns -1, 0, or 1, according as s1 is lexically but with case + * insensitive mode greater than, equal to, or less than c2. + * + * Side Effect: None. + * + * Description: + * + * Compares two file names lexically but with case insensitive mode. Two file names + * should be processed by UnixVersionToLispVersion to make sure that they have a + * valid version fields. The version fields comparison is done in numerical manner. + * Note that the result is in the reversed order. + */ + +dsk_filecmp(fp1, fp2) + FINFO **fp1; + FINFO **fp2; +{ + register int res, v1, v2; + + if ((res = strcmp((*fp1)->no_ver_name, (*fp2)->no_ver_name)) != 0) + return(res); + + if ((*fp1)->version == (*fp2)->version) return(0); +#ifndef DOS + if ((v1 = (*fp1)->version) == 0) return(-1); + if ((v2 = (*fp2)->version) == 0) return(1); +#endif /* DOS */ + return((v1 < v2) ? 1 : -1); +} + +/* + * Name: unix_filecmp + * + * Argument: FINFO *f1 A FINFO structure, a file name in it is being compared. + * FINFO *f2 A FINFO structure, a file name in it is being compared. + * + * Value: Returns -1, 0, or 1, according as s1 is lexically greater than, + * equal to, or less than c2. + * + * Side Effect: None. + * + * Description: + * + * Compares two file names lexically mode. + * Note that the result is in the reversed order. + */ + +unix_filecmp(f1, f2) + register FINFO **f1; + register FINFO **f2; +{ + return(strcmp((*f1)->lname, (*f2)->lname)); +} + +/* + * Name: file_sort + * + * Argument: FINFO **fpp A pointer to a pointer adressing the linked FINFO + * being sorted. + * int n A number of FINFO structure linked. + * int (*sortfn)() + * A pointer to a function to be used to sort the FINFOs. + * + * Value: If succeed, returns 1, otherwise, 0. + * + * Side Effect: None. + * + * Description: + * + * Sorts the files to be appropriate for Lisp. dsk_filecmp and unix_filecmp are + * used for {DSK} and {UNIX} device respectively as a sort function. + */ + +file_sort(fpp, n, sortfn) + register FINFO **fpp; + register int n; + register int (*sortfn)(); +{ + register FINFO **fp; + register FINFO **sort_bufp; + + if ((sort_bufp = prepare_sort_buf(*fpp, n)) == (FINFO **)NULL) return(0); + + qsort(sort_bufp, n, sizeof(FINFO *), sortfn); + + /* + * Relink FINFO structures in a buffer. + */ + for (fp = sort_bufp; n > 1; fp++, n--) (*fp)->next = *(fp + 1); + (*fp)->next = (FINFO *)NULL; + + *fpp = *sort_bufp; + + free((char *)sort_bufp); + + return(1); +} + +/************************************************************************/ +/************ E N D O F F I L E - S O R T I N G C O D E ***********/ +/************************************************************************/ + +#ifndef BYTESWAP +#ifdef BIGVM +typedef struct ufsgfs { + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned propp : 1; + unsigned padding : 3; + unsigned dev :28; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; +} UFSGFS; +#else +typedef struct ufsgfs { + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned propp : 1; + unsigned padding : 7; + unsigned dev :24; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; +} UFSGFS; +#endif /* BIGVM */ + +#else /* BYTESWAP */ + +#ifdef BIGVM +typedef struct ufsgfs { + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned dev :28; + unsigned padding : 3; + unsigned propp : 1; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; +} UFSGFS; +#else +typedef struct ufsgfs { + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned dev :24; + unsigned padding : 7; + unsigned propp : 1; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; +} UFSGFS; +#endif /* BIGVM */ +#endif /* BYTESWAP */ + + +/* + * Name: COM_gen_files + * + * Argument: LispPTR *args args[0] + * The pattern of file name to be enumerated in Lisp + * format. Includes the host field. + * args[1] + * Flag indicating whether Lisp needs property or not. + * args[2] + * The place where the file info ID should be placed. + * args[3] + * The place where the error number should be stored. + * + * Value: If succeed, returns the Lisp positive integer which represents the + * total number of enumerated files, otherwise Lisp -1. + * + * Side Effect: None. + * + * Description: + * + * The implementation of GENERATEFILES FDEV method for DSK and UNIX device. + * Enumerates files matching pattern. + */ + +COM_gen_files(args) + register LispPTR *args; +{ + char fbuf[MAXPATHLEN + 5], dir[MAXPATHLEN], pattern[MAXPATHLEN]; + char host[MAXNAMLEN], name[MAXNAMLEN], ver[VERSIONLEN], drive[1]; + int dskp, count, highestp, propp, id, version; + register char *cp; + FINFO *fp; + int dsk_filecmp(), unix_filecmp(); + + ERRSETJMP(GetSmallp(-1)); + + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], count, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + count = dskp ? count + 4 + 1 : count + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (count > MAXPATHLEN + 5) FileNameTooLong((GetSmallp(-1))); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); +#ifdef DOS + separate_host(fbuf, host, drive); +#else + separate_host(fbuf, host); +#endif /* DOS */ + + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + + if (args[1] == NIL) + propp = 0; + else + propp = 1; + + /* + * The way to deal with the version field in file enumeration is a little + * bit tricky because of the bad specification of original {UNIX} device. + * + * According to the Medley 1.1 release note, in the representation + * "{UNIX}name.ext;3", ';' and '3' are regarded as a part of the + * file name, not its version. On the other hand, in 1.1 implementation, + * in the pattern "{UNIX}*.*;*", the ';' and the last '*' are regarded + * as a version field, not part of the file name. Actually the pattern + * "{UNIX}*.*;*" enumerates all of the files on /tmp directory + * even if they never include ';' character in its name, as well as '.'. + * + * Thus I beleive, the specification should be clean upped as like, + * "UNIX device always ignores the version field in it file name representation + * even if a user specifies it expricitly". + * But to keep a compatibility to an already released version, we have + * to do some trick here. + */ + +#ifdef DOS + if (!unixpathname(fbuf, pattern, 1, 1, drive, 0, 0)) { +#else + if (!unixpathname(fbuf, pattern, 1, 1)) { +#endif /* DOS */ + /* Yes, always dskp is on */ + return(GetSmallp(-1)); + } + + if (!unpack_filename(pattern, dir, name, ver, 0)) return(GetSmallp(-1)); + + if (dskp) { + /* + * On {DSK}, we have to make sure dir is case insensitively exisiting + * directory. + */ + if (true_name(dir) != -1) return(GetSmallp(-1)); + + if (*ver != '\0') { + highestp = 0; + version = atoi(ver); + if (version > 0) strcpy(ver, "*"); + } else { + version = 0; + for (cp = fbuf; *cp; cp++) {} + if (*(cp - 1) == ';' && *(cp - 2) != '\'') { + /* + * An empty version is interpreted as wanting the + * highest version. In this case, at first enumerate + * all version. trim_finfo_highest will get rid of + * lower versions. + */ + strcpy(ver, "*"); + highestp = 1; + } else { + highestp = 0; + } + } + if (propp) + count = enum_dsk_prop(dir, name, ver, &fp); + else + count = enum_dsk(dir, name, ver, &fp); + } else { + /* Makes UNIX device matchts any version. */ + strcpy(ver, "*"); + + if (propp) + count = enum_ufs_prop(dir, name, ver, &fp); + else + count = enum_ufs(dir, name, ver, &fp); + } + + switch (count) { + + case -1: + return(GetSmallp(-1)); + + case 0: + return(GetSmallp(0)); + + default: + if (!file_sort(&fp, count, dskp ? dsk_filecmp : unix_filecmp)) + return(GetSmallp(-1)); + if (dskp) { + if (highestp) + count = trim_finfo_highest(&fp); + else if (version > 0 && count > 0) + count = trim_finfo_version(&fp, version); + else + count = trim_finfo(&fp); + } + + if ((id = get_finfo_id()) < 0) return(GetSmallp(-1)); + *(int *)(Addr68k_from_LADDR(args[2])) = id; + FinfoArray[id].head = fp; + FinfoArray[id].next = fp; + return(GetSmallp(count)); + } +} + +/* + * Name: COM_next_file + * + * Argument: LispPTR *args args[0] + * Lisp pointer to UFSGFS structure. + * + * Value: If succeed, returns the length of the file name as a Lisp positive + * integer, otherwise -1. + * + * Side Effect: None. + * + * Description: + * + * The implementation of NEXTFILEFN File Generator Component for DSK and UNIX device. + * Because of the efficiency reason, if propp, stores properties as well as file + * name. + */ + +COM_next_file(args) + register LispPTR *args; +{ + register LispPTR laddr; + register FPROP *pp; + register FINFO *fp; + register char *base; + register DFINFO *dfp; + register UFSGFS *gfsp; + int finfoid, propp; + + ERRSETJMP(-1); + Lisp_errno = &Dummy_errno; + + gfsp = (UFSGFS *)(Addr68k_from_LADDR(args[0])); + + finfoid = (int)gfsp->finfoid; + + if (finfoid < 0 || MAXFINFO - 1 < finfoid) return(GetSmallp(-1)); + + propp = gfsp->propp; + + dfp = &FinfoArray[finfoid]; + if (dfp->head == (FINFO *)0 || (fp = dfp->next) == (FINFO *)0) + return(GetSmallp(-1)); + dfp->next = fp->next; + + laddr = gfsp->name; + STRING_BASE(laddr, base); +#ifndef BYTESWAP + strncpy(base, fp->lname, fp->lname_len); +#else + StrNCpyFromCToLisp(base, fp->lname, fp->lname_len); +#endif /* BYTESWAP */ + + + if (!propp) return(GetSmallp(fp->lname_len)); + + pp = fp->prop; + gfsp->length = pp->length; + gfsp->wdate = pp->wdate; + gfsp->rdate = pp->rdate; + gfsp->protection = pp->protect; + + laddr = gfsp->author; + STRING_BASE(laddr, base); +#ifndef BYTESWAP + strncpy(base, pp->author, pp->au_len); +#else + StrNCpyFromCToLisp(base, pp->author, pp->au_len); +#endif /* BYTESWAP */ + + + gfsp->aulen = pp->au_len; + + return(GetSmallp(fp->lname_len)); +} + +/* + * Name: COM_finish_finfo + * + * Argument: LispPTR *args args[0] + * Finfo ID. + * + * Value: If succeed, returns ATOM_T, otherwise Lisp NIL. + * + * Side Effect: None. + * + * Description: + * + * When Lisp directory enumerateion file generator is exhausted or the enumerating + * operation is aborted, this routine is called. + * Abandon all cached information corresponding to the generator. + */ + +COM_finish_finfo(args) + register LispPTR *args; +{ + register DFINFO *dfp; + register FINFO *fp; + register finfoid; + + ERRSETJMP(NIL); + + Lisp_errno = &Dummy_errno; + + finfoid = LispNumToCInt(args[0]); + + if (finfoid < 0 || MAXFINFO - 1 < finfoid) return(NIL); + + dfp = &FinfoArray[finfoid]; + if ((fp = dfp->head) == (FINFO *)0) { + dfp->next = (FINFO *)0; + return(NIL); + } + + dfp->head = (FINFO *)0; + dfp->next = (FINFO *)0; + FreeFinfo(fp); + + return(ATOM_T); +} diff --git a/src/dlpi.c b/src/dlpi.c new file mode 100755 index 0000000..ed7d751 --- /dev/null +++ b/src/dlpi.c @@ -0,0 +1,720 @@ +/* $Id: dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $ Copyright (C) Venue"; +#ifndef lint +static char *RCSid = "$Header: /disk/disk3/cvsroot/medley/src/dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $"; +#endif + +#include "os.h" + +#ifdef USE_DLPI +/* + * dpli.c - routines for messing with the Data Link Provider Interface. + * + * The code in this module is based in large part (especially the dl* + * routines) on the example code provided with the document "How to Use + * DLPI", by Neal Nuckolls of Sun Internet Engineering. Gotta give credit + * where credit is due. If it weren't for Neal's excellent document, + * this module just plain wouldn't exist. + * + * David A. Curry + * Purdue University + * Engineering Computer Network + * 1285 Electrical Engineering Building + * West Lafayette, IN 47907-1285 + * davy@ecn.purdue.edu + * + * $Log: dlpi.c,v $ + * Revision 1.3 2001/12/24 01:09:00 sybalsky + * past changes + * + * Revision 1.2 1999/01/03 02:06:54 sybalsky + * Add ID comments / static to files for CVS use + * + * Revision 1.1.1.1 1998/12/17 05:03:20 sybalsky + * Import of Medley 3.5 emulator + * + * Revision 4.1 1993/09/15 20:50:44 davy + * GCC fixes from Guy Harris. + * + * Revision 4.1 1993/09/15 20:50:44 davy + * GCC fixes from Guy Harris. + * + * Revision 4.0 1993/03/01 19:59:00 davy + * NFSWATCH Version 4.0. + * + * Revision 1.5 1993/02/19 19:54:36 davy + * Another change in hopes of making things work on SVR4. + * + * Revision 1.4 1993/01/26 13:19:05 davy + * Fixed a goof in passing buffer size. + * + * Revision 1.3 1993/01/26 13:18:39 davy + * Added ifdef's to make it work on DLPI 1.3. + * + * Revision 1.2 1993/01/15 19:33:39 davy + * Miscellaneous cleanups. + * + * Revision 1.1 1993/01/15 15:42:32 davy + * Initial revision + * + */ +#include +#include +#include +#include +#ifdef OS5 +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nfswatch.h" +#include "externs.h" + +static void dlbindreq(); +static void dlinforeq(); +static void dlattachreq(); +static void dlpromisconreq(); +static void sigalrm(); +static int dlokack(); +static int dlinfoack(); +static int dlbindack(); +static int expecting(); +static int strgetmsg(); +static char *pname; + +extern unsigned char ether_host[6]; + +int truncation = 1500; +/* + * setup_dlpi_dev - set up the data link provider interface. + */ +int +setup_dlpi_dev(device) +char *device; +{ + char *p; + u_int chunksz; + char cbuf[BUFSIZ]; + struct ifconf ifc; + struct ifreq *ifrp; + struct strioctl si; + char devname[BUFSIZ]; + int n, s, fd, devppa; + struct timeval timeout; + long buf[DLPI_MAXDLBUF]; + + /* + * If the interface device was not specified, + * get the default one. + */ + if ((device == NULL) || *device == NULL) { + /* + * Grab a socket. + */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("socket"); + return(-1); + } + + ifc.ifc_buf = cbuf; + ifc.ifc_len = sizeof(cbuf); + + /* + * See what devices we've got. + */ + if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) { + perror("ioctl: SIOCGIFCONF"); + return(-1); + } + + /* + * Take the first device we encounter. + */ + ifrp = ifc.ifc_req; + for (n = ifc.ifc_len/sizeof(struct ifreq); n > 0; n--,ifrp++) { + /* + * Skip the loopback interface. + */ + if (strcmp(ifrp->ifr_name, "lo0") == 0) + continue; + + device = savestr(ifrp->ifr_name); + break; + } + + (void) close(s); + } + + /* + * Split the device name into type and unit number. + */ + if ((p = strpbrk(device, "0123456789")) == NULL) + return(-1); + + strcpy(devname, DLPI_DEVDIR); + strncat(devname, device, p - device); + devppa = atoi(p); + + /* + * Open the device. + */ + if ((fd = open(devname, O_RDWR)) < 0) { + if (errno == ENOENT || errno == ENXIO) + return(-1); + + /*perror(devname);*/ + return(-1); + } + + /* + * Attach to the device. If this fails, the device + * does not exist. + */ + dlattachreq(fd, devppa); + + if (dlokack(fd, buf) < 0) { + close(fd); + return(-1); + } + + + /* + * Bind to the specific unit. + */ + dlbindreq(fd, 0x0600 , 0, DL_CLDLS, 0, 0); + + if (dlbindack(fd, buf) < 0) { + fprintf(stderr, "%s: dlbindack failed.\n", pname); + return(-1); + } + +#ifdef OS5 + /* + * We really want all types of packets. However, the SVR4 DLPI does + * not let you have the packet frame header, so we won't be able to + * distinguish protocol types. But SunOS5 gives you the DLIOCRAW + * ioctl to get the frame headers, so we can do this on SunOS5. + */ + dlpromisconreq(fd, DL_PROMISC_SAP); + + if (dlokack(fd, buf) < 0) { + fprintf(stderr, "%s: DL_PROMISC_SAP failed.\n", pname); + return(-1); + } + + dlpromisconreq(fd, DL_PROMISC_MULTI); + + if (dlokack(fd, buf) < 0) { + fprintf(stderr, "%s: DL_PROMISC_MULTI failed.\n", pname); + return(-1); + } + + /* + * We want raw packets with the packet frame header. But we can + * only get this in SunOS5 with the DLIOCRAW ioctl; it's not in + * standard SVR4. + */ + si.ic_cmd = DLIOCRAW; + si.ic_timout = -1; + si.ic_len = 0; + si.ic_dp = 0; + + if (ioctl(fd, I_STR, &si) < 0) { + perror("ioctl: I_STR DLIOCRAW"); + return(-1); + } +#endif /* OS5 */ + + /* + * Arrange to get discrete messages. + */ + if (ioctl(fd, I_SRDOPT, (char *) RMSGD) < 0) { + perror("ioctl: I_SRDOPT RMSGD"); + return(-1); + } + +#ifdef OS5 + /* + * Push and configure the streams buffering module. This is once + * again SunOS-specific. + */ +#ifdef NEVER + if (ioctl(fd, I_PUSH, DLPI_BUFMOD) < 0) { + perror("ioctl: I_PUSH BUFMOD"); + return(-1); + } + /* + * Set the read timeout. + */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + si.ic_cmd = SBIOCSTIME; + si.ic_timout = INFTIM; + si.ic_len = sizeof(timeout); + si.ic_dp = (char *) &timeout; + + if (ioctl(fd, I_STR, (char *) &si) < 0) { + perror("ioctl: I_STR SBIOCSTIME"); + return(-1); + } + + /* + * Set the chunk size. + */ + chunksz = DLPI_CHUNKSIZE; + + si.ic_cmd = SBIOCSCHUNK; + si.ic_len = sizeof(chunksz); + si.ic_dp = (char *) &chunksz; + + if (ioctl(fd, I_STR, (char *) &si) < 0) { + perror("ioctl: I_STR SBIOCSCHUNK"); + return(-1); + } + + /* + * Set snapshot mode. + */ + si.ic_cmd = SBIOCSSNAP; + si.ic_len = sizeof(truncation); + si.ic_dp = (char *) &truncation; + + if (ioctl(fd, I_STR, (char *) &si) < 0) { + perror("ioctl: I_STR SBIOCSSNAP"); + return(-1); + } +#endif /* NEVER */ + +#endif /* OS5 */ + + return(fd); +} + +/* + * flush_dlpi - flush data from the dlpi. + */ +void +flush_dlpi(fd) +int fd; +{ + if (ioctl(fd, I_FLUSH, (char *) FLUSHR) < 0) { + perror("ioctl: I_FLUSH"); + return; + } +} + +/* + * dlpi_devtype - determine the type of device we're looking at. + */ +int +dlpi_devtype(fd) +int fd; +{ + long buf[DLPI_MAXDLBUF]; + union DL_primitives *dlp; + + dlp = (union DL_primitives *) buf; + + dlinforeq(fd); + + if (dlinfoack(fd, buf) < 0) + return(DLT_EN10MB); + + bcopy((char *)dlp+dlp->info_ack.dl_addr_offset, ether_host, 6); + + switch (dlp->info_ack.dl_mac_type) { + case DL_CSMACD: + case DL_ETHER: + return(DLT_EN10MB); +#ifdef DL_FDDI + case DL_FDDI: + return(DLT_FDDI); +#endif + default: + fprintf(stderr, "%s: DLPI MACtype %d unknown, ", pname, + dlp->info_ack.dl_mac_type); + fprintf(stderr, "assuming ethernet.\n"); + return(DLT_EN10MB); + } +} + +/* + * dlinforeq - request information about the data link provider. + */ +static void +dlinforeq(fd) +int fd; +{ + dl_info_req_t info_req; + struct strbuf ctl; + int flags; + + info_req.dl_primitive = DL_INFO_REQ; + + ctl.maxlen = 0; + ctl.len = sizeof (info_req); + ctl.buf = (char *) &info_req; + + flags = RS_HIPRI; + + if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) { + perror("putmsg"); + return; + } +} + +/* + * dlattachreq - send a request to attach. + */ +static void +dlattachreq(fd, ppa) +u_long ppa; +int fd; +{ + dl_attach_req_t attach_req; + struct strbuf ctl; + int flags; + + attach_req.dl_primitive = DL_ATTACH_REQ; + attach_req.dl_ppa = ppa; + + ctl.maxlen = 0; + ctl.len = sizeof (attach_req); + ctl.buf = (char *) &attach_req; + + flags = 0; + + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0) { + perror("putmsg"); + return; + } +} + +#ifdef DL_PROMISCON_REQ +/* + * dlpromisconreq - send a request to turn promiscuous mode on. + */ +static void +dlpromisconreq(fd, level) +u_long level; +int fd; +{ + dl_promiscon_req_t promiscon_req; + struct strbuf ctl; + int flags; + + promiscon_req.dl_primitive = DL_PROMISCON_REQ; + promiscon_req.dl_level = level; + + ctl.maxlen = 0; + ctl.len = sizeof (promiscon_req); + ctl.buf = (char *) &promiscon_req; + + flags = 0; + + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0) { + perror("putmsg"); + return; + } +} +#endif /* DL_PROMISCON_REQ */ + +/* + * dlbindreq - send a request to bind. + */ +static void +dlbindreq(fd, sap, max_conind, service_mode, conn_mgmt, xidtest) +u_long sap, max_conind, service_mode, conn_mgmt, xidtest; +int fd; +{ + dl_bind_req_t bind_req; + struct strbuf ctl; + int flags; + + bind_req.dl_primitive = DL_BIND_REQ; + bind_req.dl_sap = sap; + bind_req.dl_max_conind = max_conind; + bind_req.dl_service_mode = service_mode; + bind_req.dl_conn_mgmt = conn_mgmt; +#ifdef DL_PROMISC_PHYS + /* + * DLPI 2.0 only? + */ + bind_req.dl_xidtest_flg = xidtest; +#endif + + ctl.maxlen = 0; + ctl.len = sizeof (bind_req); + ctl.buf = (char *) &bind_req; + + flags = 0; + + if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0) { + perror("putmsg"); + return; + } +} + +/* + * dlokack - general acknowledgement reception. + */ +static int +dlokack(fd, bufp) +char *bufp; +int fd; +{ + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack") < 0) + return(-1); + + dlp = (union DL_primitives *) ctl.buf; + + if (expecting(DL_OK_ACK, dlp) < 0) + return(-1); + + if (ctl.len < sizeof (dl_ok_ack_t)) + return(-1); + + if (flags != RS_HIPRI) + return(-1); + + if (ctl.len < sizeof (dl_ok_ack_t)) + return(-1); + + return(0); +} + +/* + * dlinfoack - receive an ack to a dlinforeq. + */ +static int +dlinfoack(fd, bufp) +char *bufp; +int fd; +{ + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg(fd, &ctl, (struct strbuf *)NULL, &flags, "dlinfoack") < 0) + return(-1); + + dlp = (union DL_primitives *) ctl.buf; + + if (expecting(DL_INFO_ACK, dlp) < 0) + return(-1); + + if (ctl.len < sizeof (dl_info_ack_t)) + return(-1); + + if (flags != RS_HIPRI) + return(-1); + + if (ctl.len < sizeof (dl_info_ack_t)) + return(-1); + + return(0); +} + +/* + * dlbindack - receive an ack to a dlbindreq. + */ +static int +dlbindack(fd, bufp) +char *bufp; +int fd; +{ + union DL_primitives *dlp; + struct strbuf ctl; + int flags; + + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; + + if (strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack") < 0) + return(-1); + + dlp = (union DL_primitives *) ctl.buf; + + if (expecting(DL_BIND_ACK, dlp) < 0) + return(-1); + + if (flags != RS_HIPRI) + return(-1); + + if (ctl.len < sizeof (dl_bind_ack_t)) + return(-1); + + return(0); +} + +/* + * expecting - see if we got what we wanted. + */ +static int +expecting(prim, dlp) +union DL_primitives *dlp; +int prim; +{ + if (dlp->dl_primitive != (u_long)prim) + return(-1); + + return(0); +} + +/* + * strgetmsg - get a message from a stream, with timeout. + */ +static int +strgetmsg(fd, ctlp, datap, flagsp, caller) +struct strbuf *ctlp, *datap; +char *caller; +int *flagsp; +int fd; +{ + int rc; + void sigalrm(); + + /* + * Start timer. + */ + (void) sigset(SIGALRM, sigalrm); + + if (alarm(DLPI_MAXWAIT) < 0) { + perror("alarm"); + return(-1); + } + + /* + * Set flags argument and issue getmsg(). + */ + *flagsp = 0; + if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) { + perror("getmsg"); + return(-1); + } + + /* + * Stop timer. + */ + if (alarm(0) < 0) { + perror("alarm"); + return(-1); + } + + /* + * Check for MOREDATA and/or MORECTL. + */ + if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) + return(-1); + if (rc & MORECTL) + return(-1); + if (rc & MOREDATA) + return(-1); + + /* + * Check for at least sizeof (long) control data portion. + */ + if (ctlp->len < sizeof (long)) + return(-1); + + return(0); +} + +/* + * sigalrm - handle alarms. + */ +static void +sigalrm() +{ + (void) fprintf(stderr, "dlpi: timeout\n"); +} + + + + +/* + * savestr - save string in dynamic memory. + */ +char * +savestr(s) +char *s; +{ + char *t; + char *malloc(); + + if ((t = malloc(strlen(s) + 1)) == NULL) { + (void) fprintf(stderr, "%s: out of memory.\n", pname); + (void) exit(1); + } + + (void) strcpy(t, s); + + return(t); +} + + + + +dlunitdatareq(fd, addrp, addrlen, minpri, maxpri, datap, datalen) +int fd; +u_char *addrp; +int addrlen; +u_long minpri, maxpri; +u_char *datap; +int datalen; +{ + long buf[DLPI_MAXDLBUF]; + union DL_primitives *dlp; + struct strbuf data, ctl; + + dlp = (union DL_primitives*) buf; + + dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ; + dlp->unitdata_req.dl_dest_addr_length = addrlen+2; + dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t); + dlp->unitdata_req.dl_priority.dl_min = minpri; + dlp->unitdata_req.dl_priority.dl_max = maxpri; + + (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen); + (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)+addrlen), (char *)addrp + 12, 2); + + ctl.maxlen = 0; + ctl.len = sizeof (dl_unitdata_req_t) + addrlen +2; + ctl.buf = (char *) buf; + + data.maxlen = 0; + data.len = datalen; + data.buf = (char *) datap; + +#ifdef NEVER + if (putmsg(fd, &ctl, &data, 0) < 0) +#else + if (putmsg(fd, (char *) NULL, &data, 0) < 0) +#endif /* NEVER tst on 9/30/96 jds to see if raw out works */ + return -1; else return 0; +} +#endif /* USE_DLPI */ + diff --git a/src/doscomm.c b/src/doscomm.c new file mode 100755 index 0000000..ae25af4 --- /dev/null +++ b/src/doscomm.c @@ -0,0 +1,26 @@ +/* $Id: doscomm.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: doscomm.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +DOS_handlecomm(int args) +{ +} diff --git a/src/doskbd.c b/src/doskbd.c new file mode 100755 index 0000000..12124fb --- /dev/null +++ b/src/doskbd.c @@ -0,0 +1,345 @@ +/* $Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ Copyright (C) Venue"; +/************************************************************************/ +/* */ +/* D O S K E Y B O A R D H A N D L E R */ +/* */ +/* */ +/************************************************************************/ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +#include "version.h" + + +#include /* defines REGS & other structs */ +#include /* "#pragma interrupt" & '_chain_intr'*/ +#include +#include + +#include "lispemul.h" +#include "keyboard.h" +#include "keysym.h" +#include "devif.h" + +int nokbdflag = FALSE; +extern int eurokbd; +extern KbdInterface currentkbd; +extern MouseInterface currentmouse; +extern IOPAGE *IOPage68K; +extern IFPAGE *InterfacePage; +extern int KBDEventFlg; + +extern keybuffer *CTopKeyevent; + +extern LispPTR *LASTUSERACTION68k; +extern LispPTR *KEYBUFFERING68k; + + /************************************************/ + /* Keyboard-Interface Registers, Status Codes */ + /************************************************/ +#define KBD_COMMAND_PORT 0x64 /* I/O port commands go out on */ +#define KBD_ENABLE 0xAE +#define KBD_DISABLE 0xAD +#define KBD_RESET 0xF6 + +#define PORT_8042 0x60 /* Port scan codes come in on */ +#define KBD_SCAN_CODE_PORT 0x60 +#define KBD_resend 0xFE /* KBD asked for resend */ +#define KBD_ack 0xFA /* KBD ack's our command */ +#define KBD_echo_response 0xEE /* KBD responds to echo req */ +#define KBD_failure 0xFD /* Failure code */ +#define KBD_prefix 0xE0 /* Prefix for extended chars */ +#define KBD_pause_prefix 0xE1 /* Pause prefix?? */ +#define KBD_overflow 0x00 /* Overflow of some kind */ +#define KBD_overrun 0xFF /* KBD buffer overrun */ + + +#define KBD_STATUS_PORT 0x64 /* Port KBD status comes in on */ +#define KBD_INP_FULL 0x02 /* input buffer full */ + + +#define INTA00 0x20 /* The 8259 port, to reset irq */ +#define ENDOFINTERRUPT 0x20 + +#define PRTSC_KEY 0x37 /* Keyboard codes for extended chars */ +#define HOME_KEY 0x47 +#define UPARROW_KEY 0x48 +#define PGUP_KEY 0x49 +#define LEFTARROW_KEY 0x4b +#define RIGHTARROW_KEY 0x4d +#define END_KEY 0x4f +#define DOWNARROW_KEY 0x50 +#define PGDOWN_KEY 0x51 +#define INS_KEY 0x52 +#define DEL_KEY 0x53 + + /******************************************************/ + /* Tell the Interrupt-dispatch IC we're done, and */ + /* Tell the keyboard itself that we're ready again. */ + /* */ + /* (This process is critical to the proper function */ + /* of the handler, so let's do it once, correctly.) */ + /******************************************************/ +#define ENABLE_KBD \ + { \ + outp(INTA00, ENDOFINTERRUPT); \ + outp( KBD_COMMAND_PORT, KBD_ENABLE); /* Turn kbd on again. */ \ + } + + + +/************************************************************************/ +/* */ +/* K B D _ E V E N T */ +/* */ +/* Keyboard interrupt handler routine */ +/************************************************************************/ +extern DLword *DisplayRegion68k; + +#pragma interrupt(Kbd_event) + +void Kbd_event() + { + + _XSTACK *ebp; /* Real-mode handler stack frame */ + DLword w,r; + KBEVENT *kbevent; + unsigned char keycode, tmpkey; + + ebp = (_XSTACK *) _get_stk_frame(); /* Get stack frame address */ + ebp->opts |= _STK_NOINT; /* Bypass real-mode handler */ + + /*************************************************/ + /* First, get the scan code from the keyboard. */ + /* Handle exceptional conditions & errors, and */ + /* the extended-character prefix, 0xE0 */ + /* generated for, e.g., the INSERT key. */ + /*************************************************/ + + _disable(); /* prevent further interrupts from killing us */ + outp( KBD_COMMAND_PORT, KBD_DISABLE); /* Turn the kbd off. */ + do { tmpkey = inp( KBD_STATUS_PORT); } while (tmpkey & KBD_INP_FULL); + + /* Finite state machine that either returns or goes to label handle: */ + switch ( tmpkey = inp( KBD_SCAN_CODE_PORT ) ) + { + case KBD_overflow: /* Ignore these. */ + case KBD_pause_prefix: + case KBD_echo_response: + case KBD_ack: + case KBD_failure: + case KBD_resend: + case KBD_overrun: ENABLE_KBD; + return; + break; + + case KBD_prefix: /* It's a prefix, so really use next char. */ + /* Remember that we saw the prefix: */ + currentkbd->lastbyte = tmpkey; + ENABLE_KBD; + return; + break; + + default: tmpkey = inp( KBD_SCAN_CODE_PORT ); + if (currentkbd->lastbyte == KBD_prefix) + switch (tmpkey) /* deal with prefixed characters */ + { + case 0x2A: /* by ignoring some (what are they??) */ + case 0xAA: + case 0xB6: + case 0x36: ENABLE_KBD; + return; + break; + + default: /* and passing the rest thru as-is */ + currentkbd->lastbyte = tmpkey; /* Set the state. */ + goto handle; + break; + } + else + { + currentkbd->lastbyte = tmpkey; /* Set the state. */ + goto handle; + } + } + + return; /* Don't have anything to handle yet, so just return */ + + /*****************************************************/ + /* Second, translate the scan code into a LISP key */ + /* transition, add it to the ring buffer, and set */ + /* the interrupt-request flags so lisp sees it. */ + /*****************************************************/ + handle: + /* The upflag is the eight bit in the char ie. upflag = currentkbd->lastbyte >> 7 */ + /* The event is the lower seven bits of the byte */ + + keycode=currentkbd->KeyMap[currentkbd->lastbyte & 0x7f]; + + if(keycode !=0xff) + { + if( keycode < 64 ) + { + PUTBASEBIT68K( &(IOPage68K->dlkbdad0), keycode, + (currentkbd->lastbyte >> 7)&1 ); + } + else if( keycode >= 80 ) + { + PUTBASEBIT68K( &(IOPage68K->dlkbdad0), keycode-16, + (currentkbd->lastbyte >> 7)&1); + } + else + { + PUTBASEBIT68K( &(IOPage68K->dlutilin), (keycode & 0xf), + (currentkbd->lastbyte >> 7)&1 ); + PUTBASEBIT68K( &(InterfacePage->fakemousebits), (keycode & 0xf), + (currentkbd->lastbyte >> 7)&1 ); + } + } + + /* In DOS we can't enter uraid inside an exception handler. */ + /* Uraid may touch a swapped out address and that dumps Medley */ + if(((IOPage68K->dlkbdad2 & 2113) == 0) || /* Ctrl-shift-NEXT */ + ((IOPage68K->dlkbdad2 & 2114) == 0)) + { /* Ctrl-shift-DEL */ + currentkbd->URaid = TRUE; /* Tell the dispatch loop about it. */ + return; + } + + r=CTopKeyevent->ring.vectorindex.read; + w=CTopKeyevent->ring.vectorindex.write; + + if(r!=w) + { + kbevent=(KBEVENT*)((DLword *)CTopKeyevent + w); + /* Copy the Hardware bits. */ + kbevent->W0= IOPage68K->dlkbdad0; + kbevent->W1= IOPage68K->dlkbdad1; + kbevent->W2= IOPage68K->dlkbdad2; + kbevent->W3= IOPage68K->dlkbdad3; + kbevent->W4= IOPage68K->dlkbdad4; + kbevent->W5= IOPage68K->dlkbdad5; + kbevent->WU= IOPage68K->dlutilin; + + /* If queue was empty, update the read pointer */ + if(r==0) CTopKeyevent->ring.vectorindex.read=w; + + /* Update the write pointer */ + if(w >= currentkbd->maxkeyevent) CTopKeyevent->ring.vectorindex.write = MINKEYEVENT; + else CTopKeyevent->ring.vectorindex.write += currentkbd->keyeventsize; + } + if(*KEYBUFFERING68k ==NIL) *KEYBUFFERING68k=ATOM_T; + + KBDEventFlg++; + Irq_Stk_End=0; + Irq_Stk_Check=0; + + ENABLE_KBD; + return; +} + +extern u_char DOSLispKeyMap_101[]; + + +/************************************************************************/ +/* */ +/* E X I T D O S K B D */ +/* */ +/* Turn off the DOS keyboard handler, and reinstall the */ +/* normal DOS handler. */ +/************************************************************************/ + +ExitDosKbd(kbd) + KbdInterface kbd; + { + if (kbd->device.active == TRUE) + { + kbd->device.active = FALSE; + + _dpmi_unlockregion((void *)¤tkbd, sizeof(currentkbd)); + _dpmi_unlockregion((void *)kbd, sizeof(*kbd)); + _dpmi_unlockregion((void *)&InterfacePage, sizeof(InterfacePage)); + _dpmi_unlockregion((void *)InterfacePage, sizeof(IFPAGE)); + _dpmi_unlockregion((void *)&IOPage68K, sizeof(IOPage68K)); + _dpmi_unlockregion((void *)IOPage68K, sizeof(IOPAGE)); + + _dpmi_unlockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); + _dpmi_unlockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); + + _dpmi_unlockregion((void *)&MachineState, sizeof(MachineState)); + _dpmi_unlockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); + _dpmi_unlockregion((void *)&ExitDosKbd, 4096); + _dpmi_unlockregion((void *)&Kbd_event, 4096); + + _dos_setvect(0x09, kbd->prev_handler); /* unhook our handlr, install previous*/ + } + } + + +/************************************************************************/ +/* */ +/* E N T E R D O S K B D */ +/* */ +/* Turn on the DOS keyboard device. */ +/* */ +/************************************************************************/ + +EnterDosKbd(kbd) + KbdInterface kbd; + { + int i; + + if (kbd->device.active == FALSE) + { + kbd->device.active = TRUE; + for(i =0 ; i < 0x80; i++) + kbd->KeyMap[i] = DOSLispKeyMap_101[i]; + + if (eurokbd) kbd->keyeventsize = EUROKEYEVENTSIZE; + else kbd->keyeventsize = NOEUROKEYEVENTSIZE; + kbd->eurokbd = eurokbd; + + /* Offset of the end of the ring buffer */ + kbd->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * kbd->keyeventsize)); + + _dpmi_lockregion((void *)¤tkbd, sizeof(currentkbd)); + _dpmi_lockregion((void *)kbd, sizeof(*kbd)); + _dpmi_lockregion((void *)&InterfacePage, sizeof(InterfacePage)); + _dpmi_lockregion((void *)InterfacePage, sizeof(IFPAGE)); + _dpmi_lockregion((void *)&IOPage68K, sizeof(IOPage68K)); + _dpmi_lockregion((void *)IOPage68K, sizeof(IOPAGE)); + _dpmi_lockregion((void *)&MachineState, sizeof(MachineState)); + + _dpmi_lockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); + _dpmi_lockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); + + _dpmi_lockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); + _dpmi_lockregion((void *)&ExitDosKbd , 4096); + _dpmi_lockregion((void *)&Kbd_event, 4096); + + /* Don't hook in our handler if the user flagged he wants to run */ + /* without a kbd. */ + if (!nokbdflag) + { + kbd->prev_handler = _dos_getvect(0x09); /* get addr of currnt 09 hndlr */ + _dos_setvect(0x09, kbd->device_event); /* hook our int handler to interrupt */ + } + } + } diff --git a/src/dosmouse.c b/src/dosmouse.c new file mode 100755 index 0000000..07bc340 --- /dev/null +++ b/src/dosmouse.c @@ -0,0 +1,701 @@ +/* $Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + + +#include /* Defines "#pragma interrupt" */ +#include /* _XSTACK struct definition */ +#include /* Defines REGS & other structs */ + +#include "lispemul.h" +#include "display.h" +#include "bb.h" + +#include "dbprint.h" +#include "devif.h" +#include "keyboard.h" +#include "ifpage.h" + +extern int eurokbd; +extern IOPAGE *IOPage68K; +extern MISCSTATS *MiscStats; +extern IFPAGE *InterfacePage; +extern int KBDEventFlg; +extern DspInterface currentdsp; +extern MouseInterface currentmouse; +extern KbdInterface currentkbd; + +extern keybuffer *CTopKeyevent; +extern DLword *DisplayRegion68k; +extern DLword *Lisp_world ; + +extern LispPTR *KEYBOARDEVENTQUEUE68k; +extern LispPTR *KEYBUFFERING68k; +extern LispPTR *LASTUSERACTION68k; + +#define MOUSE_MV 0x01 /* Mouse movement occurred */ +#define LB_PRESS 0x02 /* Left button pressed */ +#define LB_OFF 0x04 /* Left button released */ +#define RB_PRESS 0x08 /* Right button pressed */ +#define RB_OFF 0x10 /* Right button released */ +#define CB_PRESS 0x20 /* Center button released */ +#define CB_OFF 0x40 /* Center button pressed */ + + +#pragma interrupt(TwoButtonHandler) +#pragma interrupt(ThreeButtonHandler) +#pragma interrupt(ButtonTimer) +void ButtonTimer(); +void MouseButtonSignal(); + + + + + +void EnterDosMouse(mouse, dsp) + MouseInterface mouse; + DspInterface dsp; +{ + union REGS regs; + + probemouse(); + _dpmi_lockregion((void *)&MouseButtonSignal, 4096); + /* Set up the ringbuffer */ + if (eurokbd) mouse->keyeventsize = EUROKEYEVENTSIZE; + else mouse->keyeventsize = NOEUROKEYEVENTSIZE; + + mouse->eurokbd = eurokbd; + + /* Offset of the end of the ring buffer */ + mouse->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * mouse->keyeventsize)); + + /* Lock myself */ + _dpmi_lockregion((void *)mouse, sizeof(*mouse)); + _dpmi_lockregion((void *)¤tmouse, sizeof(currentmouse)); + + /* Lock the handler routines */ + _dpmi_lockregion((void *)mouse->Handler, 4096); + + if(mouse->Button.TwoButtonP) { + _dpmi_lockregion((void *)&ButtonTimer, 4096); + } + + /* Lock the structures used, both pointers to 'em & the whole structure. */ + _dpmi_lockregion((void *)&IOPage68K, sizeof(IOPage68K)); + _dpmi_lockregion((void *)IOPage68K, sizeof(IOPAGE)); + _dpmi_lockregion((void *)&InterfacePage, sizeof(InterfacePage)); + _dpmi_lockregion((void *)InterfacePage, sizeof(IFPAGE)); + _dpmi_lockregion((void *)&MiscStats, sizeof(MiscStats)); + _dpmi_lockregion((void *)MiscStats, sizeof(MISCSTATS)); + + /* Lock the flags */ + _dpmi_lockregion((void *)&KBDEventFlg, sizeof(KBDEventFlg)); + _dpmi_lockregion((void *)&MachineState, sizeof(MachineState)); + + /* Lock the pointers into the sysout */ + _dpmi_lockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); + + /* Lock the regions of the sysout that the pointers points to */ + /* KEYBUFFERINF68k points to the value cell for a symbol */ + _dpmi_lockregion((void *)KEYBUFFERING68k, sizeof(LispPTR)); + + /* CTopKeyevent points to the ring-buffer of keyboard events */ + _dpmi_lockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); + _dpmi_lockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); + + /* Now Lock the lastuseraction machine. */ +/* _dpmi_lockregion(mouse->timestamp, sizeof(LispPTR)); */ /* Lisp_world itself */ + + regs.w.eax = 0x0001; /* Function 1 = turn on mouse cursor */ + int86(0x33, ®s, ®s); + regs.w.eax = 0x0002; /* Function 2 = hide mouse cursor */ + int86(0x33, ®s, ®s); + + regs.w.eax = 0x0C; /* Function 0C = set user-defined mouse handler */ + regs.w.ecx = LB_PRESS | LB_OFF | CB_PRESS | CB_OFF | RB_PRESS | RB_OFF | MOUSE_MV ; + regs.w.edx = FP_OFF(*(mouse->Handler)); /* Address of our mouse handler routine */ + int86(0x33, ®s, ®s); /* Install our handler to process events */ + + if (regs.w.eax == 'MERR') + VESA_errorexit("Unable to install mouse handler - not enough low memory.\n", -1); + + regs.x.ax = 0x7; /* Set mouse horizontal range */ + regs.x.cx = 0x0; + regs.x.dx = (short)( dsp->Display.width - 1); + int86(0x33, ®s, ®s); + + regs.x.ax = 0x8; /* Set mouse vertical range */ + regs.x.cx = 0x0; + regs.x.dx = (short)( dsp->Display.height - 1 ); + int86(0x33, ®s, ®s); + + /* See if turning this off fixes the "mouse granularity" problem */ + /* Nope. It didn't. */ + regs.x.ax = 0xf; /* Set mickey per pixel range */ + regs.x.cx = 0x8; + regs.x.dx = 0x8; + int86(0x33, ®s, ®s); + + mouse->Button.NextHandler = _dos_getvect(0x1c); + _dos_setvect(0x1c, ButtonTimer); + + mouse->device.active = TRUE; +} + +void ExitDosMouse(mouse) + MouseInterface mouse; +{ + + if( mouse->device.active ){ + /* Unlock myself */ + _dpmi_unlockregion((void *)mouse, sizeof(*mouse)); + _dpmi_unlockregion((void *)¤tmouse, sizeof(currentmouse)); + + /* Unlock the handler routines */ + _dpmi_unlockregion((void *)mouse->Handler, 4096); + _dpmi_unlockregion((void *)&ButtonTimer, 4096); + _dpmi_unlockregion((void *)&MouseButtonSignal, 4096); + + + /* Unlock the structures used. */ + _dpmi_unlockregion((void *)&IOPage68K, sizeof(IOPage68K)); + _dpmi_unlockregion((void *)&InterfacePage, sizeof(InterfacePage)); + _dpmi_unlockregion((void *)&MiscStats, sizeof(MiscStats)); + + /* Unlock the flags */ + _dpmi_unlockregion((void *)&KBDEventFlg, sizeof(KBDEventFlg)); + _dpmi_unlockregion((void *)&MachineState, sizeof(MachineState)); + + /* Unlock the pointers into the sysout */ + _dpmi_unlockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); + /* _dpmi_unlockregion((void *)&KEYBOARDEVENTQUEUE68k, sizeof(KEYBOARDEVENTQUEUE68k)); */ + + /* Unlock the regions of the sysout that the pointers points to */ + _dpmi_unlockregion((void *)KEYBUFFERING68k, sizeof(LispPTR)); + + _dpmi_unlockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); + _dpmi_unlockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); + +/* _dpmi_unlockregion(mouse->timestamp, sizeof(LispPTR)); */ + + _dos_setvect(0x1c, mouse->Button.NextHandler); + mouse->device.active = FALSE; + } +} + +void DosMouseAfterRaid(mouse, dsp) + MouseInterface mouse; + DspInterface dsp; +{ + union REGS regs; + + /* Screen mode changed. We have to reinit the ranges. */ + regs.x.ax = 0x7; /* Set mouse horizontal range */ + regs.x.cx = 0x0; + regs.x.dx = (short)( dsp->Display.width - 1); + int86(0x33, ®s, ®s); + + regs.x.ax = 0x8; /* Set mouse vertical range */ + regs.x.cx = 0x0; + regs.x.dx = (short)( dsp->Display.height - 1 ); + int86(0x33, ®s, ®s); + + mouse->device.active = TRUE; +} + +void DosMouseBeforeRaid(mouse, dsp) + MouseInterface mouse; + DspInterface dsp; +{ + mouse->device.active = FALSE; +} + + + +/***************************************************************/ +/* d o s _ c u r s o r _ i n v i s s i b l e */ +/* Since we only blit the cursor to the VESA/VGA displaybuffer */ +/* and not to the emulator displaybuffer we can make the cursor*/ +/* invissible just by updateing the area under the cursor! */ +/***************************************************************/ +void dos_cursor_invissible(dsp, iop) + DspInterface dsp; + IOPAGE *iop; + +{ + (dsp->bitblt_to_screen) (dsp, + DisplayRegion68k, + iop->dlcursorx, + iop->dlcursory, + 16, 16); +} + +/***************************************************************/ +/* d o s _ c u r s o r _ v i s s i b l e */ +/* blit the mouse to the display ... */ +/* The cursor should be blitted according to the following: */ +/* ((backgroundbm AND maskbm) OR ((NOT mask) OR cursorbm)) */ +/* ie. bltAND the mask to the background then bltOR the rest */ +/* */ +/* Hah!! this crappy machine doesn't have a mask!! /jarl */ +/* ie. use the inverted bitmap as a mask!!!! */ +/* */ +/* More to the point. The mask is the image inverted. (sigh..) */ +/* */ +/***************************************************************/ + + +set_DOSmouseposition(dsp, x, y) + DspInterface dsp; + int x, y; + +{ + union REGS regs; + + dsp->device.locked++; + currentmouse->device.active++; + +#ifdef NEVER + /* int 33h, case 0004, cx=col, dx = row */ + regs.w.eax = 4; /* Function 4 = move cursor */ + regs.w.ecx = x; + regs.w.edx = y; + int86(0x33, ®s, ®s); +#endif /* NEVER */ + + /* Actually move the cursor image */ + IOPage68K->dlmousex = x; + IOPage68K->dlmousey = y; + +/* *(currentmouse->timestamp) = MiscStats->secondstmp; */ + + (currentdsp->mouse_invissible)( currentdsp, IOPage68K ); + currentmouse->Cursor.New.x = IOPage68K->dlcursorx = x; + currentmouse->Cursor.New.y = IOPage68K->dlcursory = y; + (currentdsp->mouse_vissible)( x, y ); + + dsp->device.locked--; + currentmouse->device.active--; +} + +void docopy(newx, newy) + int newx, newy; +{ + register DLword *srcbase, *dstbase; + static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + + srcbase = IOPage68K->dlcursorbitmap; + dstbase= DisplayRegion68k + ( newy * currentdsp->Display.width/16) ; + sx = 0; + dx = newx; + w = currentmouse->Cursor.Last.width; + h = currentmouse->Cursor.Last.height; + srcbpl = 16; + dstbpl = currentdsp->Display.width; + op = 2; /* OR-in */ + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, + src_comp, 2, 0, 0, 0); +#else + new_bitblt_code; +#endif /* NEWBITBLT */ +} + + +dostaking_mouse_up(newx, newy) + int newx, newy; +{ + /* save hidden bitmap */ + + register DLword *srcbase, *dstbase; + static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + + /* newx and newy are hotspot coordinates. */ + /* newx -= currentmouse->Cursor.Hotspot.x; */ + /* newy -= ( 15 - currentmouse->Cursor.Hotspot.y); */ + + + /* save image */ + srcbase = DisplayRegion68k + ( newy * currentdsp->Display.width/16); + dstbase = currentmouse->Cursor.Savebitmap; + sx = newx; + dx = 0; + + if( currentdsp->Display.width < (newx + 16)) + { currentmouse->Cursor.Last.width = w = currentdsp->Display.width-newx; } + else { currentmouse->Cursor.Last.width = w = 16; }; + + if(currentdsp->Display.height < (newy + 16)) + { currentmouse->Cursor.Last.height = h = currentdsp->Display.height - newy;} + else + { currentmouse->Cursor.Last.height = h = 16;}; + + srcbpl = currentdsp->Display.width; + dstbpl = 16; + op= 0; /* replace */ + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, + src_comp, 0, gray, num_gray, curr_gray_line); +#else + new_bitblt_code; +#endif /* NEWBITBLT */ + + /* Copy Cursor Image */ + docopy(newx, newy); + + currentmouse->Cursor.Last.x = newx; + currentmouse->Cursor.Last.y = newy; + + (currentdsp->bitblt_to_screen) + (currentdsp, DisplayRegion68k, + currentmouse->Cursor.Last.x, + currentmouse->Cursor.Last.y, w, h); +} + +dostaking_mouse_down(dsp, iop) + DspInterface dsp; + IOPAGE *iop; +{ + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + + /* restore saved image */ + srcbase = currentmouse->Cursor.Savebitmap; + dstbase = DisplayRegion68k + ( (currentmouse->Cursor.Last.y) * (dsp->Display.width/16)); /* old y */ + sx = 0; + dx = currentmouse->Cursor.Last.x; /* old x */ + w = currentmouse->Cursor.Last.width; + h = currentmouse->Cursor.Last.height; + srcbpl = 16; + dstbpl = dsp->Display.width; + op=0; + +#ifdef NEWBITBLT + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, + src_comp, 0, 0, 0, 0); +#else + new_bitblt_code; +#endif /* NEWBITBLT */ + + (dsp->bitblt_to_screen) + (dsp, DisplayRegion68k, + currentmouse->Cursor.Last.x, + currentmouse->Cursor.Last.y, w, h); +} + + + +/************************************************************************/ +/* */ +/* M o u s e B u t t o n S i g n a l */ +/* */ +/* Tell LISP about a mouse event by putting an entry on the ring buf- */ +/* fer of mouse/kbd events, with the new mouse-button state in it. */ +/* */ +/* */ +/************************************************************************/ + +void MouseButtonSignal(mouse) + MouseInterface mouse; + { + DLword w,r; + KBEVENT *kbevent; + + /* In the mouse device TRUE means button pressed */ + /* In the IOPage 0 means button pressed */ + /* Hence the ! in the lines below. */ + PUTBASEBIT68K( &(IOPage68K->dlutilin), MOUSE_LEFT, !mouse->Button.Left); + PUTBASEBIT68K( &(IOPage68K->dlutilin), MOUSE_MIDDLE, !mouse->Button.Middle); + PUTBASEBIT68K( &(IOPage68K->dlutilin), MOUSE_RIGHT, !mouse->Button.Right); + + r=CTopKeyevent->ring.vectorindex.read; + w=CTopKeyevent->ring.vectorindex.write; + + if(r!=w) + { + kbevent=(KBEVENT*)((DLword *)CTopKeyevent+ w); + + /* Copy the Hardware bits. */ + kbevent->W0= IOPage68K->dlkbdad0; + kbevent->W1= IOPage68K->dlkbdad1; + kbevent->W2= IOPage68K->dlkbdad2; + kbevent->W3= IOPage68K->dlkbdad3; + kbevent->W4= IOPage68K->dlkbdad4; + kbevent->W5= IOPage68K->dlkbdad5; + kbevent->WU= IOPage68K->dlutilin; + + /* If queue was empty, update the read pointer */ + if(r==0) CTopKeyevent->ring.vectorindex.read=w; + + /* Update the write pointer */ + if(w >= mouse->maxkeyevent) CTopKeyevent->ring.vectorindex.write = MINKEYEVENT; + else CTopKeyevent->ring.vectorindex.write += mouse->keyeventsize; + } + + if(*KEYBUFFERING68k ==NIL) *KEYBUFFERING68k=ATOM_T; + + KBDEventFlg++; /* Signal the emulator to tell Lisp */ + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + } + + + +/***************************************************************/ +/* B u t t o n T i m e r */ +/* This function is used with the mouse chording machinery. */ +/* This function is the timer interrupt handler. When a button */ +/* event happens we will wait to report it until the next */ +/* timeout happens. We will thus obtain the ``rubbery feeling''*/ +/* that proponents of chording so desire. */ +/***************************************************************/ +void ButtonTimer() + { + if(currentmouse->Button.RunTimer) + if(currentmouse->Button.tick-- <= 0) + { + currentmouse->Button.RunTimer = FALSE; /* Turn the timer off. */ + currentmouse->Button.Left |= currentmouse->Button.StateLeft; + currentmouse->Button.Right |= currentmouse->Button.StateRight; + + /* Mouse chording code. If at the end of the timeout + the left and right buttons are down we signal middle + button and bring the others up. */ + /* Are L & R down? */ + + if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) + { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = TRUE; + } + + currentmouse->Button.StateLeft = FALSE; + currentmouse->Button.StateRight = FALSE; + + /* Did L & R go up after a simulated M */ +/* if((currentmouse->Button.Middle && + !(currentmouse->Button.StateLeft || + currentmouse->Button.StateRight))) + { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = FALSE; + } +*/ + MouseButtonSignal(currentmouse); + } + _chain_intr(currentmouse->Button.NextHandler); + } + + + +/***************************************************************/ +/* T w o B u t t o n H a n d l e r */ +/* This function is ther interrupt handler for the mouse. */ +/* This function sets the state of the mouse structure and */ +/* signals the dispatch loop to care of the matter. This */ +/* akward solution is due to the severe braindamage in DOS. */ +/***************************************************************/ +void TwoButtonHandler(void) + { + _XSTACK *stk_ptr; + + /* First save the stack frame. */ + stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */ + stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */ + + if(!currentmouse->device.active) return; + + if (stk_ptr->eax & LB_PRESS) + if (currentmouse->Button.RunTimer) /* Prior right-down seen... */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.FakeMiddle = TRUE; + currentmouse->Button.Middle = TRUE; + currentmouse->Button.StateLeft = TRUE; + MouseButtonSignal(currentmouse); + } + else if (currentmouse->Button.Right) + { + currentmouse->Button.Left = TRUE; + currentmouse->Button.StateLeft = TRUE; + MouseButtonSignal(currentmouse); + } + else /* No other button down... */ + { + currentmouse->Button.StateLeft = TRUE; + currentmouse->Button.tick = currentmouse->Button.StartTime; + currentmouse->Button.RunTimer = TRUE; + } + if (stk_ptr->eax & LB_OFF) /* Left button released, and */ + if (currentmouse->Button.RunTimer) /* Timer had been running */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.Left = TRUE; + MouseButtonSignal(currentmouse); + currentmouse->Button.StateLeft = FALSE; + /* currentmouse->Button.Left = FALSE; + MouseButtonSignal(currentmouse); */ + } + else /* timer wasn't running */ + { + currentmouse->Button.StateLeft = FALSE; + currentmouse->Button.Left = FALSE; + currentmouse->Button.FakeMiddle = FALSE; + currentmouse->Button.Middle = currentmouse->Button.StateMiddle; + MouseButtonSignal(currentmouse); + } + + if((stk_ptr->eax & CB_PRESS) || (stk_ptr->eax & CB_OFF)) + { + currentmouse->Button.Middle = ((stk_ptr->eax & CB_PRESS) && TRUE) + || currentmouse->Button.FakeMiddle; + currentmouse->Button.StateMiddle = (stk_ptr->eax & CB_PRESS) && TRUE; + currentmouse->Button.RunTimer = FALSE; + MouseButtonSignal(currentmouse); + } + + if(stk_ptr->eax & RB_PRESS) /* Right button pressed, and */ + if (currentmouse->Button.RunTimer) /* Timer was running... */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.FakeMiddle = TRUE; + currentmouse->Button.Middle = TRUE; + currentmouse->Button.StateRight = TRUE; + MouseButtonSignal(currentmouse); + } + else if (currentmouse->Button.Left) + { + currentmouse->Button.Right = TRUE; + currentmouse->Button.StateRight = TRUE; + MouseButtonSignal(currentmouse); + } + else + { + currentmouse->Button.StateRight = TRUE; + currentmouse->Button.tick = currentmouse->Button.StartTime; + currentmouse->Button.RunTimer = TRUE; + } + if (stk_ptr->eax & RB_OFF) /* Right button released */ + if (currentmouse->Button.RunTimer) /* Timer had been running */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.Right = TRUE; + MouseButtonSignal(currentmouse); + currentmouse->Button.StateRight = FALSE; + /* currentmouse->Button.Right = FALSE; + MouseButtonSignal(currentmouse); */ + } + else + { + currentmouse->Button.StateRight = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.FakeMiddle = FALSE; + currentmouse->Button.Middle = currentmouse->Button.StateMiddle; + MouseButtonSignal(currentmouse); + } + + + + /* The dude moved the mouse. Set the chordstate NOW. */ + /* And turn the timer off. */ + if ((stk_ptr->eax & MOUSE_MV)&&(!currentdsp->device.locked)) + { + currentmouse->Button.RunTimer = FALSE; + + /* Are L & R down? */ +/* if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) + { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = TRUE; + } +*/ + /* currentmouse->Cursor.New.x = (DLword)stk_ptr->ecx & 0xFFFF; + currentmouse->Cursor.New.y = (DLword)stk_ptr->edx & 0xFFFF; */ + currentmouse->Cursor.Moved = TRUE; + + if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) + { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = TRUE; + } + else + { + currentmouse->Button.Left |= currentmouse->Button.StateLeft; + currentmouse->Button.Right |= currentmouse->Button.StateRight; + } + + currentmouse->Button.StateLeft = currentmouse->Button.StateRight = FALSE; + MouseButtonSignal(currentmouse); + } + +} + +/***************************************************************/ +/* T h r e e B u t t o n H a n d l e r */ +/* This function is ther interrupt handler for the mouse. */ +/* This function sets the state of the mouse structure and */ +/* signals the dispatch loop to care of the matter. This */ +/* akward solution is due to the severe braindamage in DOS. */ +/***************************************************************/ +void ThreeButtonHandler() + +{ + _XSTACK *stk_ptr; + unsigned long mouse_flags; + + /* First save the stack frame. */ + stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */ + stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */ + + if(currentmouse->device.active){ + mouse_flags = stk_ptr->eax; /* Save event flags from mouse driver */ + + /* Decode the transition bits. */ + if (mouse_flags & LB_PRESS) currentmouse->Button.Left = TRUE; + if (mouse_flags & LB_OFF) currentmouse->Button.Left = FALSE; + + if (mouse_flags & CB_PRESS) currentmouse->Button.Middle = TRUE; + if (mouse_flags & CB_OFF) currentmouse->Button.Middle = FALSE; + + if (mouse_flags & RB_PRESS) currentmouse->Button.Right = TRUE; + if (mouse_flags & RB_OFF) currentmouse->Button.Right = FALSE; + + if ((!currentdsp->device.locked) && (mouse_flags & MOUSE_MV)) + { + currentmouse->Cursor.Moved = TRUE; + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + } + + if (mouse_flags & (LB_PRESS|LB_OFF|CB_PRESS|CB_OFF|RB_PRESS|RB_OFF)) + MouseButtonSignal(currentmouse); + } +} diff --git a/src/draw.c b/src/draw.c new file mode 100755 index 0000000..70eab6f --- /dev/null +++ b/src/draw.c @@ -0,0 +1,391 @@ +/* $Id: draw.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: draw.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* D R A W . C */ +/* */ +/* Line-drawing code, N_OP_drawline. */ +/* */ +/************************************************************************/ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +#include + +#ifndef NOPIXRECT +#include +#include +#include +#endif + +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "adr68k.h" +#include "bitblt.h" +#include "display.h" + +#include "my.h" + +#ifdef DISPLAYBUFFER +extern struct pixrect *ColorDisplayPixrect, *DisplayRegionPixrect; +#endif + +extern int displaywidth, displayheight; +extern int DisplayRasterWidth; +extern DLword *DisplayRegion68k_end_addr; + +extern int LispWindowFd; +extern int ScreenLocked; + +#ifdef COLOR +extern int MonoOrColor; +#endif /* COLOR */ + + +#ifdef DISPLAYBUFFER +n_new_cursorin_CG6( dx, dy, w, h ) +register int dx, dy, w, h; + { + if((dx < MOUSEXR)&&(dx + w > MOUSEXL)&&(dy < MOUSEYH)&&(dy + h > MOUSEYL)) + return(T); + else + return(NIL); + } +#endif + +/************************************************************ + # name len-1 stk level effect UFN table entry + 73 DRAWLINE 0 -8 \DRAWLINE.UFN + +takes 9 (!) args from top of stack, does line draw inner loop + Entry format: + TOS --> Maximum number of Y steps allowed {uYCount} + SP-0 --> Maximum number of X steps allowed {uXCount} + SP-2 --> Initial Delta {Delta} + SP-4 --> Function number: {L2} + 0: Set pixel + 1: Reset Pixel + 2: Invert Pixel + SP-6 --> Relative Y coordinate of end of line (for the bucket) {uYT} + SP-8 --> Width of bitmap (in words), signed to indicate Y direction {uYIncHi , uYIncLo} + SP-10 -> Relative X coordinate of end of line (for the bucket) {uXT} + SP-12 -> bit index [0..15] of bit to start at {CurBit} + SP-14 -> Pointer to first word in bitmap {uPAdrHi , uPAdrLo} + + +***********************************************************/ +/* curbit = bit position for next bit */ +/* delta = current value of delta */ +/* op = draw operation: 0/paint, 1/erase, 2/invert */ +/***** +plot: + if x = xmax or y = ymax then exit + data = data op curbit; + if (ymax > xmax) then {movex(-), if delta neg, then movey(+), goto plot} + else {movey(-), if delta neg, then movex(+), goto plot} + + movex = { + xmax-- + delta = delta +/- ysize + curbit >>= 1 + if curbit = 0 then {curbit = 0x8000, incx} + } + movey = { + ymax-- + delta = delta +/- xsize + incy + } +*****/ + +/* + ptr pointer to "first word of bitmap" + curbit bit index to start with, and tracks therefrom. + xsize Rel X coord + width width of bitmap, in words + ysize Rel Y coord of end of line + op operation + delta initial delta + numx step count for X steps + numy step count for Y steps +*/ + +#ifdef XWINDOW +#define DISPLAYBUFFER +#endif /* XWINDOW */ + + +int N_OP_drawline(ptr, curbit, xsize, width, ysize, op, delta, numx, numy) + register int curbit, xsize; + int width; + register int ysize; + int op; + register int delta, numx, numy; + LispPTR ptr; + { + register DLword *dataptr; + ScreenLocked=T; + +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + +#ifdef SUNDISPLAY +#ifndef DISPLAYBUFFER + HideCursor; /** Figure out how to be smart later **/ +#else /* DISPLAYBUFFER */ +#ifndef OLD_CURSOR + HideCursor; +#endif /* OLD_CURSOR */ + +#endif /* DISPLAYBUFFER */ + +#endif /* SUNDISPLAY */ + + + delta &= 0xFFFF; + op &= 3; + + if ((SEGMASK & width) == S_POSITIVE) width &= 0xFFFF; + else if ((SEGMASK & width) == S_NEGATIVE) width |= 0xFFFF0000; + else ERROR_EXIT(numy); + + curbit = 0x8000 >> (curbit & 0xFFFF); + dataptr = Addr68k_from_LADDR(ptr); + numy &= 0xFFFF; + numx &= 0xFFFF; + ysize &= 0xFFFF; + xsize &= 0xFFFF; + if (xsize > ysize) + { + delta = xsize - delta - 1; + switch (op) + { + case 0: + while (numx && numy) + { + if (!curbit) + { + curbit = 0x8000; + dataptr++; + } /* end if curbit */ + GETWORD(dataptr) |= curbit; + numx--; + delta -= ysize; + curbit >>= 1; + if (delta < 0) + { + numy--; + delta += xsize; + dataptr += width; + } /* end if delta */ + }/* end while */ + break; + case 1: + while (numx && numy) + { + if (!curbit) { + curbit = 0x8000; + dataptr++; + } /* end if curbit */ + GETWORD(dataptr) &= ~curbit; + numx--; + delta -= ysize; + curbit >>= 1; + if (delta < 0) + { + numy--; + delta += xsize; + dataptr += width; + } /* end if delta */ + }/* end while */ + break; + case 2: + while (numx && numy) + { + if (!curbit) { curbit = 0x8000; dataptr++; } + GETWORD(dataptr) ^= curbit; + numx--; + delta -= ysize; + curbit >>= 1; + if (delta < 0) + { + numy--; + delta += xsize; + dataptr += width; + } /* end if delta */ + }/* end while */ + break; + } /* end switch */ + }/* end if */ + else + { /* yfirst */ + delta = ysize - delta - 1; + switch (op) + { + case 0: + while (numx && numy) + { + GETWORD(dataptr) |= curbit; + numy--; + delta -= xsize; + dataptr += width; + if (delta < 0) + { + numx--; + delta += ysize; + curbit >>= 1; + if (!curbit) { curbit = 0x8000; dataptr++; } + } /* end if delta */ + }/* end while */ + break; + case 1: + while (numx && numy) + { + GETWORD(dataptr) &= ~curbit; + numy--; + delta -= xsize; + dataptr += width; + if (delta < 0) + { + numx--; + delta += ysize; + curbit >>= 1; + if (!curbit) { curbit = 0x8000; dataptr++; } + } /* end if delta */ + }/* end while */ + break; + case 2: + while (numx && numy) + { + GETWORD(dataptr) ^= curbit; + numy--; + delta -= xsize; + dataptr += width; + if (delta < 0) + { + numx--; + delta += ysize; + curbit >>= 1; + if (!curbit) { curbit = 0x8000; dataptr++; } + } /* end if delta */ + }/* end while */ + break; + } /* end switch */ + } /* end else */ +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + +#ifdef SUNDISPLAY +#ifndef DISPLAYBUFFER + ShowCursor; /** figure how to be smart later **/ +#else +#ifndef OLD_CURSOR + ShowCursor; +#endif /* OLD_CURSOR */ + +#endif /* DISPLAYBUFFER */ + +#endif /* SUNDISPLAY */ + + +#ifdef DISPLAYBUFFER +#ifdef COLOR + if( MonoOrColor == MONO_SCREEN ) +#endif /* COLOR */ + + { + DLword *start_addr + , *temp_s + , *temp_e; + + start_addr = (DLword*)Addr68k_from_LADDR(ptr); + + if( ((int)(temp_s = (DLword*)(start_addr - DisplayRegion68k)) >= 0 ) + && (start_addr < DisplayRegion68k_end_addr) + && ((int)(temp_e = (DLword*)(dataptr - DisplayRegion68k)) >= 0 ) + && ((DLword*)dataptr < DisplayRegion68k_end_addr) ) + { + + int start_x + , start_y + , end_x + , end_y + , w + , h + , displayflg; + + start_y = (int)temp_s / DisplayRasterWidth; + start_x = ((int)temp_s % DisplayRasterWidth) * BITSPER_DLWORD; + + end_y = (int)temp_e / DisplayRasterWidth ; + end_x = ((int)temp_e % DisplayRasterWidth) * BITSPER_DLWORD + + (BITSPER_DLWORD - 1); + + w = abs(start_x - end_x) + 1; + h = abs(start_y - end_y) + 1; + + if(start_x > end_x) start_x = end_x; + if(start_y > end_y) start_y = end_y; + +#if defined(SUNDISPLAY) && !defined(BYTESWAP) +#ifdef OLD_CURSOR + if( (displayflg = n_new_cursorin_CG6( start_x, start_y, w, h )) ) + HideCursor; +#endif /* OLD_CURSOR */ + + pr_rop(ColorDisplayPixrect, start_x, start_y, w, h, + PIX_SRC,DisplayRegionPixrect, start_x, start_y ); +#ifdef OLD_CURSOR + if( displayflg ) ShowCursor; +#endif /* OLD_CURSOR */ + +#endif /* SUNDISPLAY */ + + +#if defined(XWINDOW) || defined(BYTESWAP) + flush_display_region( start_x, start_y, w, h); + +#endif /* XWINDOW */ + + + } + } +#endif /* DISPLAYBUFFER */ + + + ScreenLocked=NIL; + + return(0); /* return a value for the error test to check. */ + + } /* end N_OP_drawline() */ + +#ifdef XWINDOW +#undef DISPLAYBUFFER +#endif /* XWINDOW */ + + +/* end module */ diff --git a/src/dsk.c b/src/dsk.c new file mode 100755 index 0000000..f8705a9 --- /dev/null +++ b/src/dsk.c @@ -0,0 +1,4767 @@ +/* $Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +#include +#ifndef DOS +#include +#include +#ifndef OS5 +#include +#endif /* OS5 Solaris doesn't need strings.h */ +#ifndef SYSVONLY +#include +#endif /* SYSVONLY */ + +#include +#include +#ifdef sun +#include +#endif /* sun */ +#ifdef HPUX +#include +#endif /* HPUX */ + +#else /* DOS */ + +#include +#include +#include +#include /* get R_OK, F_OK symbols */ +#include +#include +#include +#include +#define index strchr +#define rindex strrchr +#define MAXPATHLEN _MAX_PATH +#define MAXNAMLEM _MAX_PATH +#define L_SET SEEK_SET +#define alarm(x) 0 +#endif /* DOS */ + + +#ifdef RISCOS +#include +#include +#define direct dirent +#define d_namlen d_reclen +#endif /* RISCOS */ + + +#ifdef OS5 +#define index strchr +#define rindex strrchr +#define L_SET SEEK_SET +#endif /* OS5 */ + + +#ifdef ISC +#include +#include +#define direct dirent +#define d_namlen d_reclen +#define L_SET SEEK_SET +#endif /* ISC */ + + +#ifdef SYSVONLY +#include +#include +#define direct dirent +#define d_namlen d_reclen +#ifndef LINUX +#define L_SET SEEK_SET +#endif +#endif /* SYSVONLY */ + +#ifndef DOS +#include +#endif /* DOS */ +#include +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "arith.h" +#include "stream.h" +#include "timeout.h" +#include "locfile.h" +#include "osmsg.h" +#include "dbprint.h" + +#ifdef ULTRIX +#include +#elif OSF1 +#include +#else +#ifdef AIX +#if (!defined(AIXPS2) && !defined(HPUX)) +#ifdef LINUX +#include +#else +#include +#endif +#endif /* AIXPS2 | HPUX */ + +#define d_fileno d_ino +#endif /* AIX */ + +#endif /* ULTRIX */ + + +#ifdef APOLLO +#include +#define d_fileno d_ino +#define f_bavail f_bfree +#endif /* APOLLO */ + + +#ifdef GCC386 +#include "inlnPS2.h" +#endif /* GCC386 */ + + +extern int* Lisp_errno; +extern int Dummy_errno; + +typedef struct filename_entry + { + char name[MAXPATHLEN]; /* With version, foo.~3~ or foo */ + int version_no; + } FileName; + +typedef struct current_varray + { + char path[MAXPATHLEN]; /* pathname of directory */ + char file[MAXPATHLEN]; /* file name (down cased name) */ + time_t mtime; + } CurrentVArray; + +FileName VersionArray[VERSIONARRAYLENGTH]; +CurrentVArray VArrayInfo; + +FileName *GetHighestVersion(); +FileName *GetNextHighestVersion(); +FileName *GetLowestVersion(); +FileName *VersionlessP(); + + + +/* + * Name: COM_openfile + * + * Argument: LispPTR *args args[0] + * Full file name which is following the Xerox + * Lisp file naming convention. + * args[1] Recoginition mode. See IRM. + * args[2] Access mode. See IRM. + * args[3] The place where the creation date of the + * opened file should be stored. + * args[4] The place where the size of the opened file + * should be stored. + * args[5] The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp smallp which represents the open + * file descriptor, otherwise Lisp NIL. + * + * Side Effect: If succeed, cdate(args[3]) and size(args[4]) will hold the + * creation date and file size respectively. + * + * Description: + * + * The implementation of OPENFILE FDEV method for DSK and UNIX device. Try to + * open a specified file. + */ + +COM_openfile(args) + register LispPTR *args; +{ + char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + register int fatp, dskp, rval, fd, link_check_flg, flags, *bufp; + struct stat sbuf; +#ifdef DOS + char drive[1]; /* Drive designator */ + int extlen; /* length of the raw file extension */ + char rawname[MAXNAMLEN]; +#endif /* DOS */ + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[5])); + + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + /* Add five for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + +#ifdef DOS + separate_host(lfname, host, drive); +#else + separate_host(lfname, host); +#endif /* DOS */ + UPCASE(host); + + if (strcmp(host, "DSK") == 0) dskp = 1; + else if (strcmp(host, "UNIX") == 0) dskp = 0; + else return(NIL); + + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ +#ifdef DOS + unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); +#else + unixpathname(lfname, file, dskp, 0); +#endif + + /* + * Set up the flags argument for open system call. + * And we have to handle the non existing directory case if the device is + * DSK. + * link_check_flg is used to determine wheter we have to check a hard-link + * based version control after opening a file. + */ + link_check_flg = 0; + switch (args[1]) { + + case RECOG_OLD: + case RECOG_OLDEST: + switch (args[2]) { + + case ACCESS_INPUT: + flags = O_RDONLY; + break; + + case ACCESS_OUTPUT: + /* + * The current implementation of Lisp page mapped device requires + * that the output stream being "readable"! + */ + flags = O_RDWR | O_TRUNC; + break; + + case ACCESS_BOTH: + flags = O_RDWR; + break; + + case ACCESS_APPEND: + /* + * Should be O_WRONLY | O_APPEND. But Lisp needs it. + */ + flags = O_RDWR; + break; + } + break; + case RECOG_NEW: + case RECOG_OLD_NEW: + /* + * In DSK device, the not exsting yet file can be recognized. In this + * case, if there is a chance to create a new file, we have to make + * sure that all directory to reach the recognized file exists. + * Also we have to check the versionless file is collectly maintained + * or not when we have a chance to create a new file. + */ + switch (args[2]) { + + case ACCESS_INPUT: + if (args[1] == RECOG_NEW) { + /* + * Opening a input stream to a new, not yet + * existing, file does not make sense. + */ + return(NIL); + } else { + /* + * Even if OLD/NEW recoginition, opening a input + * stream never try to create a new file. Thus, + * without O_CREAT. + */ + flags = O_RDONLY; + } + break; + + case ACCESS_OUTPUT: + flags = O_RDWR | O_TRUNC | O_CREAT; + if (dskp) { + unpack_filename(file, dir, name, ver, 1); + if (make_directory(dir) == 0) return(NIL); + link_check_flg = 1; + } + break; + + case ACCESS_BOTH: + flags = O_RDWR | O_CREAT; + if (dskp) { + unpack_filename(file, dir, name, ver, 1); + if (make_directory(dir) == 0) return(NIL); + link_check_flg = 1; + } + break; + + case ACCESS_APPEND: + flags = O_RDWR | O_CREAT; + if (dskp) { + unpack_filename(file, dir, name, ver, 1); + if (make_directory(dir) == 0) return(NIL); + link_check_flg = 1; + } + break; + } + break; + + default: + return(NIL); + } + + /* + * The file name which has been passed from Lisp is sometimes different + * from the actual file name on DSK, even after the Lisp name is converted + * to UNIX form with unixpathname. Lisp always recognize a file on DSK + * with version. If the versionless file exists and it is not correctly + * maintained, that is it is not hard linked to the exisiting highest + * versioned file, Lisp regards such link missing versionless file as + * the highest versioned file, but the actual name on the file system + * is still versionless. + * get_old, get_oldest, get_new, get_old_new routines handle all of the + * complicated cases correctly and let us know the "Lisp recognizing" + * name and "Real" name. Both of them are UNIX format. + * At this point, we will use one of the four routines and get the + * real name. We can use it to open a file which is requeste from Lisp + * with the "Lisp recognizing" name. + */ + + if (dskp) { + if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); + if (true_name(dir) != -1) return(0); + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) + return(NIL); + ConcNameAndVersion(name, ver, file); + + switch (args[1]) { + + case RECOG_OLD: + if (get_old(dir, VersionArray, file, name) == 0) + return(NIL); + break; + + case RECOG_OLDEST: + if (get_oldest(dir, VersionArray, file, name) == 0) + return(NIL); + break; + + case RECOG_NEW: + if (get_new(dir, VersionArray, file, name) == 0) + return(NIL); + break; + + case RECOG_OLD_NEW: + if (get_old_new(dir, VersionArray, file, name) == 0) + return(NIL); + break; + + default: + return(NIL); + } + } + + /* + * DSK device only allow to open a regular file. + */ + if (dskp) { + TIMEOUT(rval = stat(file, &sbuf)); + if (rval == 0) { + if ((sbuf.st_mode & S_IFMT) != S_IFREG) { + /* + * The Lisp code handles this case as same as "file table + * overflow" error. Final error message is "File won't + * open". + */ + *Lisp_errno = ENFILE; + return(NIL); + } + } else { + /* + * When stat failed, only if the reason is "file does not + * exist" and we are trying to open a file with a mode we can + * create a new file, we can proceed. + */ + if (errno != ENOENT || !link_check_flg) { + *Lisp_errno = errno; + return(NIL); + } + } + } + if (dskp && link_check_flg) { + /* + * When we are opening a file with a mode we might create a new file, + * we have to make sure that versionless file is maintaied + * correctly before we actually creating a new file, because a + * created new file will change the status and the recognition on + * the same file with the same recognition mode will return the + * different result. + * At this point, the third argument for maintain_version, forcep is + * 1, because a lonly versionless file should be linked to version 1. + * If we are opening a file recognized with new mode, version 2, + * without pre-linking a versionless to version 1, the final + * clean up maintain_version will link the versionless to version 3. + */ + TIMEOUT(rval = access(file, F_OK)); + if (rval == -1) { + if (errno == ENOENT) { + /* + * Actually we are creating a new file. We have to + * maintain a version status. + */ + if (maintain_version(file, (FileName *)NULL, 1) == 0) { + TIMEOUT(rval = close(fd)); + *Lisp_errno = errno; + return(NIL); + } + } else { + /* + * Because of other reason, access call failed. + */ + *Lisp_errno = errno; + return(NIL); + } + } else { + /* + * The subjective file has already existed. We don't need + * to maintain a version. + */ +#ifdef DOS + if (args[1] == RECOG_NEW) + { + char old[MAXPATHLEN]; + make_old_version(old, file); + unlink(old); + rename(file, old); /* make old version */ + } +#endif /* DOS */ + + } + } + + /* + * If a new file is created, its actual mode is computed from the + * third argument for open and the process's umask. I'm pretty sure + * 0666 would be most appropriate mode to specify here. + */ + TIMEOUT(fd = open(file, flags, 0666)); + if (fd == -1) { + *Lisp_errno = errno; + return(NIL); + } + + if (dskp && link_check_flg) { + /* + * Again we have to maintain version to clean up the directory. + * This time we invoke maintain_version with forcep off, because + * the entirely newly created file, versionless file, should not + * be linked to any file. + */ + if (maintain_version(file, (FileName *)NULL, 0) == 0) { + TIMEOUT(close(fd)); + *Lisp_errno = errno; + return(NIL); + } + } + + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + TIMEOUT(close(fd)); + *Lisp_errno = errno; + return(NIL); + } + + bufp = (int *)(Addr68k_from_LADDR(args[3])); + *bufp = ToLispTime(sbuf.st_mtime); + + bufp = (int *)(Addr68k_from_LADDR(args[4])); + if (!dskp && ((sbuf.st_mode & S_IFMT) != S_IFREG) && + ((sbuf.st_mode & S_IFMT) != S_IFDIR)) { + /* + * Not a regular file or directory file. Put on a marker. + */ + *bufp = SPECIALFILEMARK; + } else { + *bufp = sbuf.st_size; + } + + return(GetSmallp(fd)); +} + +/* + * Name: COM_closefile + * + * Argument: LispPTR *args args[0] + * Full file name which is following the Xerox + * Lisp file naming convention. Including a host + * field. + * args[1] + * The Lisp integer representing a file descriptor + * of the file being closed. + * args[2] + * The creation date of the file. + * args[3] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp T otherwise, Lisp NIL. + * + * Side Effect: None. + * + * Description: + * + * The implementation of CLOSEFILE FDEV method for DSK and UNIX device. Try to + * close a specified file. + * The creation date file attribute in Lisp sense is kept in st_mdate field of + * UNIX structure. To keep the creation date of the file, it is maintained by + * Lisp and it is passed to COM_closefile. + */ + +COM_closefile(args) + register LispPTR *args; +{ + +#ifdef DOS + + register int fd, dskp, rval; + time_t cdate; + char lfname[MAXPATHLEN + 5], host[MAXNAMLEN]; + char file[MAXPATHLEN], dir[MAXPATHLEN], name[MAXNAMLEN + 1]; + char ver[VERSIONLEN], drive[1]; + struct find_t dirp; + int dp; + struct stat sbuf; + ino_t ino; + int extlen; + char rawname[MAXNAMLEN]; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], rval, dskp); + + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add five for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + + separate_host(lfname, host, drive); + + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ + dskp ? unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) : unixpathname(lfname, file, 0, 0, drive, &extlen, rawname); + fd = LispNumToCInt(args[1]); + cdate = (time_t)LispNumToCInt(args[2]); + if (!dskp) { + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + } + + if (cdate == 0) { + /* Just close. */ + TIMEOUT(rval = close(fd)); + if (rval == -1) { + if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) { + /* + * On {UNIX} device, closing a special file we are not + * the owner of it. Although I don't think close fails + * because of EPERM, in honor of Medley 1.1 code, I put + * this segment here. + */ + return(ATOM_T); + } else { + *Lisp_errno = errno; + return(NIL); + } + } else { + return(ATOM_T); + } + } + + if (!unpack_filename(file, dir, name, ver, 1)) return(NIL); + + if (dskp) { + /* + * On {DSK}, we have to make sure dir is case sensitively exisiting + * directory. + */ + if (true_name(dir) != -1) return(NIL); + + /* + * There is a very troublesom problem here. The file name Lisp + * recognizes is not always the same as the name which COM_openfile + * used to open the file. Sometimes COM_openfile uses the versionless + * file name to open a file, although Lisp always recognizes with + * *versioned* file name. + * Thus, we compare i-node number of the requested file with ones of all + * of files on the directory. This is time spending implementation. + * More clean up work is needed. + */ + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + ino = sbuf.st_ino; + TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); + if (rval < 0) { + *Lisp_errno = errno; + return(NIL); + } + + for (; rval == 0; + S_TOUT(rval = _dos_findnext(&dirp))) { + sprintf(file, "%s\\%s", dir, dirp.name); + } + } +#ifndef DOS /* effectively NEVER, since we're in an ifdef DOS */ + time[0].tv_sec = (long)sbuf.st_atime; + time[0].tv_usec = 0L; + time[1].tv_sec = (long)ToUnixTime(cdate); + time[1].tv_usec = 0L; +#endif /* DOS */ + TIMEOUT(rval = close(fd)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } +#ifndef DOS + TIMEOUT(rval = utimes(file, time)); + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } +#endif /* DOS, internal */ +#else /* UNIX version of CLOSEFILE */ + register int fd, fatp, dskp, rval; + time_t cdate; + char lfname[MAXPATHLEN + 5], host[MAXNAMLEN]; + char file[MAXPATHLEN], dir[MAXPATHLEN], name[MAXNAMLEN + 1]; + char ver[VERSIONLEN]; + register DIR *dirp; + register struct direct *dp; + struct stat sbuf; + struct timeval time[2]; + ino_t ino; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + /* Add five for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + + separate_host(lfname, host); + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ + dskp ? unixpathname(lfname, file, 1, 0) : unixpathname(lfname, file, 0, 0); + + fd = LispNumToCInt(args[1]); + cdate = (time_t)LispNumToCInt(args[2]); + + if (!dskp) { + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + } + + if (cdate == 0) { + /* Just close. */ + TIMEOUT(rval = close(fd)); + if (rval == -1) { + if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) { + /* + * On {UNIX} device, closing a special file we are not + * the owner of it. Although I don't think close fails + * because of EPERM, in honor of Medley 1.1 code, I put + * this segment here. + */ + return(ATOM_T); + } else { + *Lisp_errno = errno; + return(NIL); + } + } else { + return(ATOM_T); + } + } + + if (!unpack_filename(file, dir, name, ver, 1)) return(NIL); + + if (dskp) { + /* + * On {DSK}, we have to make sure dir is case sensitively exisiting + * directory. + */ + if (true_name(dir) != -1) return(NIL); + + /* + * There is a very troublesom problem here. The file name Lisp + * recognizes is not always the same as the name which COM_openfile + * used to open the file. Sometimes COM_openfile uses the versionless + * file name to open a file, although Lisp always recognizes with + * *versioned* file name. + * Thus, we compare i-node number of the requested file with ones of all + * of files on the directory. This is time spending implementation. + * More clean up work is needed. + */ + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + ino = sbuf.st_ino; + + errno=0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == (DIR *)NULL) { + *Lisp_errno = errno; + return(NIL); + } + + for (S_TOUT(dp = readdir(dirp)); dp != (struct direct*)NULL || errno == EINTR; + errno=0, S_TOUT(dp = readdir(dirp))) + if (dp) + { + if (ino == (ino_t)dp->d_fileno) + sprintf(file, "%s/%s", dir, dp->d_name); + } + TIMEOUT(closedir(dirp)); + } + + time[0].tv_sec = (long)sbuf.st_atime; + time[0].tv_usec = 0L; + time[1].tv_sec = (long)ToUnixTime(cdate); + time[1].tv_usec = 0L; + + TIMEOUT(rval = close(fd)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + +#ifdef USE_UTIME + TIMEOUT(rval = utime(file, time)); +#else + TIMEOUT(rval = utimes(file, time)); +#endif + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + +#endif /* DOS */ + + return(ATOM_T); + +} + +/* + * Name: DSK_getfilename + * + * Argument: LispPTR *args args[0] Full file name in Lisp format. + * args[1] Rcoginition mode. See IRM. + * args[2] Name area where the recognized full file name + * will be stored. + * args[3] The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp smallp which represents the length + * of the recognized full file name, otherwise Lisp NIL. + * + * Side Effect: If succeed, name area (args[2]) will be replaced with the + * recognized full file name. + * + * Description: + * + * The implementation of GETFILENAME FDEV method for DSK device. Performs the + * recognition on the specified name. Does not check if OPENFILE actually + * can open the file with the specified mode or not. + */ + +DSK_getfilename(args) + register LispPTR *args; +{ + register char *base; + register int len, dirp, rval; + int fatp; + char lfname[MAXPATHLEN]; + char aname[MAXNAMLEN]; + char vname[MAXPATHLEN]; + char file[MAXPATHLEN]; + char dir[MAXPATHLEN]; + char name[MAXNAMLEN]; + char ver[VERSIONLEN]; +#ifdef DOS + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ + + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], len, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + len = fatp ? len + 4 + 1 : len + 2 + 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + +#ifdef DOS + separate_drive(lfname, drive); +#endif + + /* + * Convert a Lisp file name to UNIX one. This is a DSK device method. + * Thus we have to convert a version field too. Third argument for + * unixpathname specifies it. + */ +#ifdef DOS + if (unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) == 0) + return(NIL); +#else + if (unixpathname(lfname, file, 1, 0) == 0) return(NIL); +#endif + + if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); + + switch (args[1]) { + + case RECOG_OLD: + /* + * "Old" file means the "newest existing" file. Thus, we have to + * check dir is an existing directory or not. The serach have to + * be done in case insensitive manner. true_name does this work. + */ + + if (true_name(dir) != -1) + { + /* No such directory. */ + return(NIL); + } + /* + * At this point, true_name has converted dir to the "true" name + * of the directory. + */ + if (strcmp(name, "") == 0) { + /* + * The file name is specified with a trail directory delimitor. + * We should recognize it as a directory. + */ + strcpy(aname, dir); + strcpy(vname, dir); + dirp = 1; + } else { + /* + * Recognizing a file on DSK device needs the version information. + * We gather version information in a version array first. + */ + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) + return(NIL); + + ConcNameAndVersion(name, ver, aname); + if (get_old(dir, VersionArray, aname, vname) == 0) return(NIL); + + if ((rval = true_name(aname)) == 0) return(NIL); + if (rval == -1) { + /* + * The specified file is a directory file. + */ + strcpy(vname, aname); + dirp = 1; + } else { +#ifdef DOS + strcpy(vname, aname); +#endif + dirp = 0; + } + } + + break; + + case RECOG_OLDEST: + /* + * "Oldest" file means the "oldest existing" file. Thus, we have to + * check dir is an existing directory or not. + */ + if (true_name(dir) != -1) { + /* No such directory. */ + return(NIL); + } + if (strcmp(name, "") == 0) { + /* + * The file name is specified with a trail directory delimitor. + * We should recognize it as a directory. + */ + strcpy(aname, dir); + strcpy(vname, dir); + dirp = 1; + } else { + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) + return(NIL); + + ConcNameAndVersion(name, ver, aname); + if (get_oldest(dir, VersionArray, aname, vname) == 0) return(NIL); + + if ((rval = true_name(aname)) == 0) return(NIL); + if (rval == -1) { + /* + * The specified file is a directory file. + */ + strcpy(vname, aname); + dirp = 1; + } else { +#ifdef DOS + strcpy(vname, aname); +#endif + dirp = 0; + } + } + break; + + case RECOG_NEW: + /* + * "New" file means the "not existing" file. Thus it is not + * necessary that dir is an existing directory. If dir is not + * an exisiting directory, we returns the specified file name + * as if, the subsequent OPENFILE will find the truth. + */ + if (true_name(dir) != -1) { + strcpy(vname, file); + dirp = 0; + } else if (strcmp(name, "") == 0) { + /* + * The file name is specified with a trail directory delimitor. + * We should recognize it as a directory. + */ + strcpy(aname, dir); + strcpy(vname, dir); + dirp = 1; + } else { + ConcDirAndName(dir, name, aname); + if ((rval = true_name(aname)) == -1) { + strcpy(vname, aname); + dirp = 1; + } else { + /* + * Here, dir is an existing directory. We have to perform + * "new" recognition with the version information. + */ + if (get_version_array(dir, name, VersionArray, + &VArrayInfo) == 0) + return(NIL); + + ConcNameAndVersion(name, ver, aname); + if (get_new(dir, VersionArray, aname, vname) == 0) + return(NIL); + dirp = 0; + } + } + break; + + case RECOG_OLD_NEW: + /* + * "Old/new" file means the "newest existing" or "not existing" file. + * Thus, if dir is not an existing directory, we can return the + * specified file name. If it is an existing one, we have to + * try "old" recognition on the directory first. If the recognition + * fails, we try "new" recognition. + */ + if (true_name(dir) != -1) { + strcpy(vname, file); + dirp = 0; + } else { + ConcDirAndName(dir, name, aname); + if ((rval = true_name(aname)) == -1) { + strcpy(vname, aname); + dirp = 1; + } else { + if (get_version_array(dir, name, VersionArray, + &VArrayInfo) == 0) + return(NIL); + + ConcNameAndVersion(name, ver, aname); + if (get_old_new(dir, VersionArray, aname, vname) == 0) + return(NIL); + dirp = 0; + } + } + break; + + case RECOG_NON: + /* + * "Non" recognition is used to recognize a sysout file. The sysout + * file is dealt with specially, it does not have any version, even + * if it is on {DSK} device. Only we have to do here is to make + * sure the path to reach to the specified file is an existing + * directories. The file name itself is recognized as if. + */ + if (true_name(dir) != -1) return(NIL); + ConcDirAndName(dir, name, vname); + strcpy(aname, vname); + if (true_name(aname) == -1) { + strcpy(vname, aname); + dirp = 1; + } else { + dirp = 0; + } + if (lisppathname(vname, lfname, dirp, 0) == 0) return(NIL); + STRING_BASE(args[2], base); + len = strlen(lfname); + +#ifndef BYTESWAP + strncpy(base, lfname, len + 1); +#else + StrNCpyFromCToLisp(base, lfname, len + 1); +#endif /* BYTESWAP */ + + return(GetSmallp(len)); + } + + /* + * DSK device does not recognize a directory file as a file. Thus we should + * return NIL when the recognized file is a directory. + */ + if (dirp) return(NIL); + + /* + * Now, vname holds the "versioned" full name of the recognized file in UNIX + * format. We have to convert it back to Lisp format. The version field + * have to be converted. The fourth argument for lisppathname specifies it. + */ +#ifdef DOS + /* For DOS, have to assure we use the name asked for, not the */ + /* faked-up oversion-0 name, so reported names match. */ + { + char dver[VERSIONLEN]; + separate_version(vname, dver, 0); + ConcDirAndName(dir, name, aname); + ConcNameAndVersion(aname, dver, vname); + } +#endif /* DOS */ + + if (lisppathname(vname, lfname, dirp, (dirp ? 0 : 1)) == 0) return(NIL); + + STRING_BASE(args[2], base); + len = strlen(lfname); + +#ifndef BYTESWAP + strncpy(base, lfname, len + 1); +#else + StrNCpyFromCToLisp(base, lfname, len + 1); +#endif /* BYTESWAP */ + + + return(GetSmallp(len)); +} + + + + +/* + * Name: DSK_deletefile + * + * Argument: LispPTR *args args[0] + * Full file name in Lisp format. + * args[1] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp symbol T, otherwise Lisp NIL. + * + * Side Effect: If succeed, the specified file is unlinked. + * + * Description: + * + * The implementation of DELETEFILE FDEV method for DSK device. Try to delete + * a specified file. + */ + +DSK_deletefile(args) + register LispPTR *args; +{ + char file[MAXPATHLEN], fbuf[MAXPATHLEN], vless[MAXPATHLEN]; + char dir[MAXPATHLEN], ver[VERSIONLEN]; + int rval, fatp; + register FileName *varray; +#ifdef DOS + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); + + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + if (rval > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); +#ifdef DOS + separate_drive(fbuf, drive); + unixpathname(fbuf, file, 1, 0, drive, &extlen, rawname); +#else + unixpathname(fbuf, file, 1, 0); +#endif + + + if (unpack_filename(file, dir, fbuf, ver, 1) == 0) return(NIL); + if (get_version_array(dir, fbuf, VersionArray, &VArrayInfo) == 0) return(NIL); + varray = VersionArray; + + if (NoFileP(varray)) return(NIL); /* + * If the specified file is deleted from + * outside of Lisp during the last time + * Lisp recognize it and now, this case + * will occure. + */ + + /* + * Although the file should have been recognized with "oldest" mode in Lisp + * code, we have to recognize it again to know the "real" accessible name + * of it. + */ + + ConcNameAndVersion(fbuf, ver, file); + if (get_oldest(dir, varray, file, fbuf) == 0) return(NIL); + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file. All we have to do is to simply + * try to unlink the specified file. + */ + TIMEOUT(rval = unlink(file)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); + } + + /* + * If a versionless file exists, we have to check the link status of it, + * because deleting a versionless file or a file to which a versionless + * file is linked will destroy the concistency of the version status. + */ + + if (check_vless_link(vless, varray, fbuf, &rval) == 0) return(NIL); + + if (strcmp(file, vless) == 0 || strcmp(file, fbuf) == 0) { + if (*fbuf != '\0') { + /* + * Both of the versionless file and the file to which the + * versionless file is linked have to be unlinked. + */ + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + TIMEOUT(rval = unlink(fbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + /* + * Finally, we have to maintain the version status. + */ + if (maintain_version(vless, (FileName *)NULL, 0) == 0) + return(NIL); + return(ATOM_T); + } else { + /* + * Although the versionfile is specified, it is not linked + * to any file in varray. We should not maintain the version + * status after deleting the versionless file, because + * we cannot say wheter the versionless file is actually under + * control of the Medley DSK file system or not. + */ + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); + } + } else { + /* + * Just unlink the specified file. + */ + TIMEOUT(rval = unlink(file)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); + } +} + + + + +/* + * Name: DSK_renamefile + * + * Argument: LispPTR *args args[0] + * Full file name in Lisp format. The file which + * is being renamed. + * args[1] + * Full file name in Lisp format. The file to which + * args[0] is being renamed. + * args[2] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp symbol T, otherwise Lisp NIL. + * + * Side Effect: If succeed, the specified file is unlinked. + * + * Description: + * + * The implementation of RENAMEFILE FDEV method for DSK device. Try to rename + * a specified file. + */ + +DSK_renamefile(args) + register LispPTR *args; +{ + char src[MAXPATHLEN], dst[MAXPATHLEN]; + char fbuf[MAXPATHLEN], vless[MAXPATHLEN], svless[MAXPATHLEN]; + char dir[MAXPATHLEN], ver[VERSIONLEN]; + int rval, fatp; + register int need_maintain_flg; + register FileName *varray; +#ifdef DOS + char drive1[1], drive2[1]; + int extlen1, extlen2; /* len of extension */ + char rawname1[MAXNAMLEN], rawname2[MAXNAMLEN]; +#endif /* DOS */ + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + if (rval > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringLength(args[1], rval, fatp); + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + if (rval > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); +#ifdef DOS + separate_drive(fbuf, drive1); + unixpathname(fbuf, src, 1, 0, drive1, &extlen1, rawname1); +#else /* DOS */ + unixpathname(fbuf, src, 1, 0); +#endif /* DOS */ + + LispStringToCString(args[1], fbuf, MAXPATHLEN); +#ifdef DOS + separate_drive(fbuf, drive2); + unixpathname(fbuf, dst, 1, 0, drive2, &extlen2, rawname2); +#else /* DOS */ + unixpathname(fbuf, dst, 1, 0); +#endif /* DOS */ + + + + if (unpack_filename(dst, dir, fbuf, ver, 1) == 0) return(NIL); + /* + * The destination file has been recognized as new file. Thus we have + * to make sure that the directory exisits. + */ + if (make_directory(dir) == 0) return(NIL); + + /* + * We maintain the destination to handle the link damaged case correctly. + */ + ConcDirAndName(dir, fbuf, dst); + if (maintain_version(dst, (FileName *)NULL, 0) == 0) return(NIL); + + if (get_version_array(dir, fbuf, VersionArray, &VArrayInfo) == 0) return(NIL); + varray = VersionArray; + + /* + * Although the file should have been recognized with "new" mode in Lisp + * code, we have to recognize it again to know the "real" accessible name + * of it. + */ + + ConcNameAndVersion(fbuf, ver, dst); + if (get_new(dir, varray, dst, fbuf) == 0) return(NIL); + + /* + * At this point, there are three cases for the destination. If there is + * no member of the destination family, there is nothing to do. If there + * is only a versionless file and, if the "real" destination is not the + * versionless, we have to rename it to version 1. And last case, if the + * "real" destination file is the file to which the versinless file is linked, + * we have to unlink the versionless file. + */ + if (!NoFileP(varray)) { + if (OnlyVersionlessP(varray)) { + get_versionless(varray, vless, dir); + if (strcmp(dst, vless) != 0) { + ConcNameAndVersion(vless, "1", fbuf); + TIMEOUT(rval = rename(vless, fbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + } + } else { + /* + * We are sure that the versionless file is linked to one of + * the higher versioned file here. + */ + get_versionless(varray, vless, dir); + if (check_vless_link(vless, varray, fbuf, &rval) == 0) { + return(NIL); + } + if (strcmp(dst, fbuf) == 0) { + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + } + } + } + + if (unpack_filename(src, dir, fbuf, ver, 1) == 0) return(NIL); + if (get_version_array(dir, fbuf, varray, &VArrayInfo) == 0) return(NIL); + + if (NoFileP(varray)) return(NIL); /* + * If the specified file is deleted from + * outside of Lisp during the last time + * Lisp recognize it and now, this case + * will occure. + */ + + /* + * Although the file should have been recognized with "old" mode in Lisp + * code, we have to recognize it again to know the "real" accessible name + * of it. + */ + ConcNameAndVersion(fbuf, ver, src); + if (get_old(dir, varray, src, fbuf) == 0) return(NIL); + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file. All we have to do is to simply + * try to rename the specified file. + */ + need_maintain_flg = 0; + } else { + /* + * If a versionless file exists, we have to check the link status + * of it, because renaming a versionless file or a file to which a + * versionless file is linked will destroy the concistency of the + * version status. + */ + if (check_vless_link(vless, varray, fbuf, &rval) == 0) return(NIL); + + if (strcmp(src, vless) == 0 && *fbuf != '\0') { + /* + * At this point, we only unlink the file to which the + * versionless is linked. The versionless fill will be + * renamed later. + */ + TIMEOUT(rval = unlink(fbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + need_maintain_flg = 1; + } else if (strcmp(src, fbuf) == 0) { + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + need_maintain_flg = 1; + } else { + need_maintain_flg = 0; + } + strcpy(svless, vless); + } + + /* + * At this point, src holds the full file name to be renamed, and dst holds + * the full file name to which src will be renamed. + */ + + TIMEOUT(rval = rename(src, dst)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + + /* + * The destination directory always have to be maintained, because it is + * now under control of DSK device. + * The source directory have to be maintained only if need_maintain_flg + * is on. + */ + + if (maintain_version(dst, (FileName *)NULL, 0) == 0) return(NIL); + if (need_maintain_flg) { + if (maintain_version(src, (FileName *)NULL, 0) == 0) return(NIL); + } + + return(ATOM_T); +} + + + + +/* + * Name: DSK_directorynamep + * + * Argument: LispPTR *args args[0] + * Directory name in Lispformat. Both of the initial + * and trail directory delimiter are stripped by Lisp + * code. Only one exception is a "root directory". + * "Root directory is represented as ">". + * args[1] + * The place where the "true" name of the directory + * in Lisp format will be stored. + * args[2] + * The place where the error number should be stored. + * Not used in the current Lisp code implementation. + * + * Value: If succeed, returns the Lisp smallp which represents the length + * of the "true" name of the directory, otherwise Lisp NIL. + * + * Side Effect: If the directory is recognized as a valid directory representation, + * args[1] is replaced with the "true" directory name. + * + * Description: + * + * The implementation of the DIRECTORYNAMEP FDEV method for DSK device. + * Performs the recoginition as well. Accepts the directory representation which + * obeys the Xerox Lisp file naming convention. The "true" name which is stored + * on the area specified with the second argument also follows the Xerox Lisp + * file naming convention, and it includes the initial and trail directory + * delimiter. Thus the Lisp code does not have to worry about the conversion of + * the directory name representation. + */ + +DSK_directorynamep(args) + register LispPTR *args; +{ + char dirname[MAXPATHLEN]; + char fullname[MAXPATHLEN]; + register int len, fatp; + register char *base; +#ifdef DOS + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + + LispStringLength(args[0], len, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + len = fatp ? len + 4 + 1 : len + 2 + 1; + /* -2 for the initial and trail directory delimitor. */ + if (len > MAXPATHLEN - 2) FileNameTooLong(NIL); + + LispStringToCString(args[0], dirname, MAXPATHLEN); + + /* Convert Xerox Lisp file naming convention to Unix one. */ +#ifdef DOS + separate_drive(dirname, drive); + if (unixpathname(dirname, fullname, 1, 0, drive, 0, 0) == 0) return(NIL); +#else /* DOS*/ + if (unixpathname(dirname, fullname, 1, 0) == 0) return(NIL); +#endif /* DOS */ + + if (true_name(fullname) != -1) return(NIL); + + /* Convert Unix file naming convention to Xerox Lisp one. */ + if (lisppathname(fullname, dirname, 1, 0) == 0) return(NIL); + + len = strlen(dirname); + STRING_BASE(args[1], base); + +#ifndef BYTESWAP + strncpy(base, dirname, len + 1); +#else + StrNCpyFromCToLisp(base, dirname, len + 1); +#endif /* BYTESWAP */ + + + return(GetSmallp(len)); +} + + + + +/* + * Name: COM_getfileinfo + * + * Argument: LispPTR *args args[0] + * Full file name which is following the Xerox + * Lisp file naming convention. Including a host + * field. + * args[1] + * The Lisp pointer which represents the requested + * file attribute. + * args[2] + * The place where the requested value will be stored. + * args[3] + * The place where the errno will be stored. + * + * Value: If failed, returns Lisp NIL. If succeed, returned value is + * different according to the attribute requested. + * In the case of LENGTH, WDATE, RDATE, and PROTECTION, returns Lisp T. + * In the case of AUTHOR and ALL, returns the length of the author name + * copied into the specified buffer. + * + * Side Effect: The specified buffer will be replaced with the value of the requested + * attribute. + * + * Description: + * + * The implementation of GETFILEINFO FDEV method for DSK and UNIX device. Try to + * fetch a value of a specified file attribute. + * The creation date file attribute in Lisp sense is kept in st_mdate field of + * UNIX structure, and it is treated as same as the write date file attribute in + * Lisp sense. + */ + +COM_getfileinfo(args) + register LispPTR *args; +{ + register int dskp, rval; + register unsigned *bufp; +#ifndef DOS + register struct passwd *pwd; +#endif + register char *base; + char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + struct stat sbuf; + LispPTR laddr; +#ifdef DOS + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], rval, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); +#ifdef DOS + separate_host(lfname, host, drive); +#else + separate_host(lfname, host); +#endif + + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ +#ifdef DOS + unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname) ; +#else /* DOS */ + unixpathname(lfname, file, dskp, 0); +#endif /* DOS */ + + /* + * The file name which has been passed from Lisp is sometimes different + * from the actual file name on DSK, even after the Lisp name is converted + * to UNIX form with unixpathname. The Lisp code for GETFILEINFO always + * recognizes a file with old mode. Thus, we recognize it again using + * get_old routine. It will let us know the "real accessible" name of + * the file. + */ + if (dskp) { + if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); + if (true_name(dir) != -1) return(0); + if (strcmp(name, "") == 0) { + /* + * The directory is specified. + */ + strcpy(file, dir); + } else { + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) + return(NIL); + ConcNameAndVersion(name, ver, file); + if (get_old(dir, VersionArray, file, name) == 0) + return(NIL); + } + } + + TIMEOUT(rval = stat(file, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + + switch (args[1]) { + + case LENGTH: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = (unsigned)sbuf.st_size; + return(ATOM_T); + + case WDATE: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = (unsigned)ToLispTime(sbuf.st_mtime); + return(ATOM_T); + + case RDATE: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = (unsigned)ToLispTime(sbuf.st_atime); + return(ATOM_T); + + case PROTECTION: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = sbuf.st_mode; + return(ATOM_T); + + case AUTHOR: +#ifndef DOS + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + /* + * Returns Lisp 0. Lisp code handles this case as author + * unknown. The returned value from Lisp GETFILEINFO + * function would be "". + */ + return(GetSmallp(0)); + } + STRING_BASE(args[2], base); + rval = strlen(pwd->pw_name); +#ifndef BYTESWAP + strncpy(base, pwd->pw_name, rval); +#else + StrNCpyFromCToLisp(base, pwd->pw_name, rval); +#endif /* BYTESWAP */ +#endif /* DOS */ + return(GetSmallp(rval)); + + case ALL: + /* + * The format of the buffer which has been allocated by Lisp + * is as follows. + * ((LENGTH . fixp) + * (WDATE . fixp) + * (RDATE . fixp) + * (PROTECTION . fixp) + * (AUTHOR . string)) + */ + laddr = cdr(car(args[2])); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp= sbuf.st_size; + + laddr = cdr(car(cdr(args[2]))); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp = ToLispTime(sbuf.st_mtime); + + laddr = cdr(car(cdr(cdr(args[2])))); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp= ToLispTime(sbuf.st_atime); + + laddr = cdr(car(cdr(cdr(cdr(args[2]))))); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp= sbuf.st_mode; +#ifndef DOS + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if(pwd == (struct passwd *)NULL) { + return(GetSmallp(0)); + } + laddr = cdr(car(cdr(cdr(cdr(cdr(args[2])))))); + STRING_BASE(laddr, base); + rval = strlen(pwd->pw_name); +#ifndef BYTESWAP + strncpy(base, pwd->pw_name, rval); +#else + StrNCpyFromCToLisp(base, pwd->pw_name, rval); +#endif /* BYTESWAP */ +#endif /* DOS */ + return(GetSmallp(rval)); + + default: + return(NIL); + } +} + + + + +/* + * Name: COM_setfileinfo + * + * Argument: LispPTR *args args[0] + * Full file name which is following the Xerox + * Lisp file naming convention. Including a host + * field. + * args[1] + * The Lisp pointer which represents the requested + * file attribute. + * args[2] + * The value to be stored on the request attribute. + * args[3] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns Lisp T, otherwise Lisp NIL. + * + * Side Effect: The specified attribute of a file will be replaced with the specified + * value. + * + * Description: + * + * The implementation of SETFILEINFO FDEV method for DSK and UNIX device. Try to + * replace a value of a specified file attribute. + * In this implementation, only WDATE(as well as Createion Date) and PROTECTION + * make sense. + */ + +COM_setfileinfo(args) + register LispPTR *args; +{ + register int dskp, rval, date; + char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + struct stat sbuf; +#ifndef DOS + struct timeval time[2]; +#else + char drive[1], rawname[MAXNAMLEN]; + int extlen; +#endif /* DOS */ + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], rval, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + +#ifdef DOS + separate_host(lfname, host, drive); +#else + separate_host(lfname, host); +#endif /* DOS */ + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ +#ifdef DOS + unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); +#else /* DOS */ + unixpathname(lfname, file, dskp, 0); +#endif /* DOS */ + + /* + * The file name which has been passed from Lisp is sometimes different + * from the actual file name on DSK, even after the Lisp name is converted + * to UNIX form with unixpathname. The Lisp code for SETFILEINFO always + * recognizes a file with old mode. Thus, we recognize it again using + * get_old routine. It will let us know the "real accessible" name of + * the file. + */ + if (dskp) { + if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); + if (true_name(dir) != -1) return(0); + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) + return(NIL); + ConcNameAndVersion(name, ver, file); + if (get_old(dir, VersionArray, file, name) == 0) + return(NIL); + } + + + switch (args[1]) { + + case WDATE: + TIMEOUT(rval = stat(file, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } +#ifndef DOS + date = LispNumToCInt(args[2]); + time[0].tv_sec = (long)sbuf.st_atime; + time[0].tv_usec = 0L; + time[1].tv_sec = (long)ToUnixTime(date); + time[1].tv_usec = 0L; +#ifdef USE_UTIME + TIMEOUT(rval = utime(file, time)); +#else + TIMEOUT(rval = utimes(file, time)); +#endif /* HPUX */ +#endif /* DOS */ + if(rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); + + case PROTECTION: + rval = LispNumToCInt(args[2]); + TIMEOUT(rval = chmod(file, rval)); + if(rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + return(ATOM_T); + + default: + return(NIL); + } +} + + + + +/* + * Name: COM_readpage + * + * Argument: LispPTR *args args[0] + * The Lisp integer representing a file descriptor + * of the file being read. + * args[1] + * The Lisp integer representing a page number of the + * file being read. + * args[2] + * The place where the contents of the file will be + * stored. + * args[3] + * The place where the error number should be stored. + * + * Value: If succeed, returns a Lisp integer representing a total number of + * bytes read, otherwise Lisp NIL. + * + * Side Effect: The specified buffer will be filled with the specified region of the + * contents of the file. + * + * Description: + * + * The implementation of READPAGES FDEV method for DSK and UNIX device. Try to + * read a page into a buffer. + * If a page being read is a last page in a file, and it is not a full page, the + * remaining region of a buffer will be zero outed. The size of a page is 512 bytes. + */ + +COM_readpage(args) + register LispPTR *args; +{ + register char *bufp; + register char *bp; + register int count, fd, npage, rval; + struct stat sbuf; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + fd = LispNumToCInt(args[0]); + npage = LispNumToCInt(args[1]); + bufp = (char*)(Addr68k_from_LADDR(args[2])); + + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + + if((sbuf.st_mode & S_IFREG) != 0){ + /* + * The request file is a regular file. We have to make sure that + * next byte read is at the beggning of the requested page of the + * file. If the request file is special file, lseek is not needed. + */ +sklp: TIMEOUT(rval = lseek(fd, (npage * PAGE_SIZE), L_SET)); + if(rval == -1) { + if (errno == EINTR) goto sklp; /* interrupted, retry */ + *Lisp_errno = errno; + return(NIL); + } + } + +rdlp: TIMEOUT(count = read(fd, bufp, PAGE_SIZE)); + if(count == -1) { + if (errno == EINTR) goto rdlp; /* interrupted; retry */ + *Lisp_errno = errno; + return(NIL); + } + + /* O out the remaining part of the buffer. */ + for(bp = &bufp[count], rval = count; rval < PAGE_SIZE; ++rval) *bp++ = 0; + +#ifdef BYTESWAP + word_swap_page(bufp, PAGE_SIZE / 4); +#endif /* BYTESWAP */ + + + return(GetSmallp(count)); +} + + + + +/* + * Name: COM_writepage + * + * Argument: LispPTR *args args[0] + * The Lisp integer representing a file descriptor + * of the file being read. + * args[1] + * The Lisp integer representing a page number of the + * file being written. + * args[2] + * The place in where the next date to be written is + * hold. + * args[3] + * The Lisp integer representing a number of bytes + * of data to be written. + * args[4] + * The place where the error number should be stored. + * + * Value: If succeed, returns a Lisp T, otherwise Lisp NIL. + * + * Side Effect: The specified page of the file will be replaced with the contents of + * the buffer. + * + * Description: + * + * The implementation of WRITEPAGES FDEV method for DSK and UNIX device. Try to + * write a page into a buffer. + * The actual size of data written is specified with args[3]. + */ + +COM_writepage(args) + register LispPTR *args; +{ + register int fd; + register int npage; + register char *bufp; + register int rval, count; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); + + fd = LispNumToCInt(args[0]); + npage = LispNumToCInt(args[1]); + bufp = (char*)(Addr68k_from_LADDR(args[2])); + count = LispNumToCInt(args[3]); + +sklp2: TIMEOUT(rval = lseek(fd, (npage*PAGE_SIZE), L_SET)); + if (rval == -1) { + if (errno == EINTR) goto sklp2; /* interrupted; retry */ + *Lisp_errno = errno; + return(NIL); + } + +#ifdef DEMO + /* Do nothing if this is a demo emulator--not allowed to write files. */ +#else + + /* OK to write the page. */ + +#ifdef BYTESWAP + word_swap_page(bufp, (count + 3) >> 2); +#endif /* BYTESWAP */ + + +wlp: TIMEOUT(rval = write(fd, bufp, count)); + if ( rval == -1) { + if (errno == EINTR) goto wlp; /* interrupted; retry */ + *Lisp_errno = errno; +#ifdef BYTESWAP + word_swap_page(bufp, (count + 3) >> 2); +#endif /* BYTESWAP */ + return(NIL); + } + +#ifdef BYTESWAP + word_swap_page(bufp, (count + 3) >> 2); +#endif /* BYTESWAP */ + +#endif /* DEMO */ + + return(ATOM_T); +} + + + + +/* + * Name: COM_truncatefile + * + * Argument: LispPTR *args args[0] + * The Lisp integer representing a file descriptor + * of the file being truncated. + * args[1] + * The Lisp integer representing a requested length to be + * truncated. + * args[2] + * The place where the error number should be stored. + * + * Value: If succeed, returns a Lisp T, otherwise Lisp NIL. + * + * Side Effect: The length of the specified file will be the specified length. + * + * Description: + * + * The implementation of TRUNCATEFILE FDEV method for DSK and UNIX device. Try to + * truncate a file. + */ + +COM_truncatefile(args) + register LispPTR *args; +{ + register int fd; + register int length; + register int rval; + struct stat sbuf; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + + fd = LispNumToCInt(args[0]); + length = LispNumToCInt(args[1]); + + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + + if((sbuf.st_mode & S_IFREG) == 0){ + /* + * The request file is not a regular file. We don't need to + * truncate such file. + */ + return(ATOM_T); + } + if ((off_t)length != sbuf.st_size) + { +#ifndef ISC /* ISC has no ftruncate; sigh */ +#ifdef DOS + TIMEOUT(rval = chsize(fd, (off_t)length)); +#else + TIMEOUT(rval = ftruncate(fd, (off_t)length)); +#endif /* DOS */ + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } +#endif /* ISC */ + + /* + * TRUNCATEFILE FDEV method is invoked from FORCEOUTPUT Lisp function. + * Thus we have to sync the file state here. + */ +#ifdef INDIGO + TIMEOUT(rval = fsync(fd)); +#elif OS5 + TIMEOUT(rval = fsync(fd)); +#elif DOS +#elif SYSVONLY + TIMEOUT(rval = fsync(fd)); +#else + TIMEOUT(rval = fsync(fd)); +#endif /* INDIGO */ + + if (rval != 0) { + *Lisp_errno = errno; + return(NIL); + } + } + return(ATOM_T); +} + + + + +/* + * Name: COM_changedir + * + * Argument: LispPTR *args args[0] + * Full file directory name which is following the Xerox + * Lisp file naming convention. Including a host + * field. + * + * Value: If succeed, returns a Lisp T, otherwise Lisp NIL. + * + * Side Effect: If succeed, the current directory of this Lisp proecess will be changed. + * + * Description: + * + * Change the current directory of the process to the specified directory. + */ + +COM_changedir(args) + register LispPTR *args; +{ + register int dskp, rval; + char lfname[MAXPATHLEN + 5], dir[MAXPATHLEN], host[MAXNAMLEN]; +#ifdef DOS + char drive[1], rawname[MAXNAMLEN]; + int extlen; +#endif /* DOS */ + + + ERRSETJMP(NIL); + Lisp_errno = &Dummy_errno; + + LispStringLength(args[0], rval, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); +#ifdef DOS + separate_host(lfname, host, drive); +#else + separate_host(lfname, host); +#endif /* DOS */ + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + +#ifdef DOS + if (!unixpathname(lfname, dir, 0, 0, drive, 0, 0)) return(NIL); +#else /* DOS */ + if (!unixpathname(lfname, dir, 0, 0)) return(NIL); +#endif /* DOS */ + + if (dskp) { + /* + * If {DSK} device, the directory name can be specified in a case + * insensitive manner. We have to convert it into a right case. + */ + if (true_name(dir) != -1) return(NIL); + } + + TIMEOUT(rval = chdir(dir)); + if (rval != 0) return(NIL); +#ifdef DOS + if (*drive) + { + + if (*drive <= 'Z') rval = _chdrive(*drive - ('A'-1)); + else rval = _chdrive(*drive-('a'-1)); + if (rval != 0) return(NIL); + } +#endif /* DOS */ + return(ATOM_T); +} + + + +/************************************************************************/ +/* */ +/* C O M _ g e t f r e e b l o c k */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/* + * Name: COM_getfreeblock + * + * Argument: LispPTR *args args[0] + * Full sysout in Lisp format. Including a host field. + * args[1] + * The place where the available free block size will + * be stored. + * + * Value: If succeed, returns a Lisp T, otherwise Lisp NIL. + * + * Side Effect: None. + * + * Description: + * + * Examines the statistics of the file system on which the specified sysout file + * resides, and returns the number of available free blocks thorugh the specified + * buffer. + * This routine is invoked just before the Lisp flushes its image on a sysout file so + * as to make sure the Lisp image is gracefully written on a sysout file. See + * \MAIKO.CHECKFREESPACE in MOD44IO. + * The version controll based on a file naming convention is not applicable to a + * sysout file, even if the sysout file is specified on {DSK} device. The Lisp code + * strips the version field by invoking DSK_getfilename with NON recognition mode. + */ + +COM_getfreeblock(args) + register LispPTR *args; +{ + register int dskp, rval, *buf; + char lfname[MAXPATHLEN + 5], dir[MAXPATHLEN], host[MAXNAMLEN]; + char name[MAXNAMLEN + 1], file[MAXPATHLEN], ver[VERSIONLEN]; + char drive[2]; +#ifdef ULTRIX + struct fs_data sfsbuf; +#else +#ifndef AIXPS2 +#ifndef DOS + struct statfs sfsbuf; +#endif /* DOS */ +#endif /* AIXPS2 */ + +#endif /* ULTRIX */ +#ifdef DOS + struct diskfree_t sfsbuf; +#endif /* DOS */ + + + + ERRSETJMP(NIL); + Lisp_errno = &Dummy_errno; + + LispStringLength(args[0], rval, dskp); + /* + * Add 1 byte for NULL terminating character. + */ + rval += 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + buf = (int *)(Addr68k_from_LADDR(args[1])); +#ifdef DOS + separate_host(lfname, host, drive); +#else + separate_host(lfname, host); +#endif /* DOS */ + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return(NIL); + +#ifdef DOS + if (!unixpathname(lfname, file, 0, 0, drive, 0, 0)) return(NIL); +#else /* DOS */ + if (!unixpathname(lfname, file, 0, 0)) return(NIL); +#endif /* DOS */ + + if (!unpack_filename(file, dir, name, ver, 0)) return(NIL); + + if (dskp) { + /* + * Although Lisp code gurantees the directory is an existing one, + * by calling DSK_getfilename, we check it again for safety. + */ + if (true_name(dir) != -1) return(NIL); + } + + /* + * The specified file itself might be a file being created newly. Thus, + * we check the available block size, using the directory on which the file + * will be exist. + */ +#ifdef DOS + /* For DOS, we have to use either the disk drive the file + will be on, or the default drive. */ + + if (drive[0]) + { + drive[1] = 0; + UPCASE(drive); + if (_dos_getdiskfree((unsigned)drive[0] - (int)'@', &sfsbuf)) + return(NIL); /* call failed, so name is invalid */ + + *buf = sfsbuf.avail_clusters * sfsbuf.sectors_per_cluster + * sfsbuf.bytes_per_sector; + } + else + { + if (_dos_getdiskfree(0, &sfsbuf)) + return(NIL); /* call failed, so name is invalid */ + + *buf = sfsbuf.avail_clusters * sfsbuf.sectors_per_cluster + * sfsbuf.bytes_per_sector; + + } +#else +#ifdef ULTRIX + TIMEOUT(rval = getmnt(0, &sfsbuf, 0, STAT_ONE, dir)); + if (rval <= 0) { +#elif OSF1 + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs))); + if (rval <= 0) { +#elif defined(ISC) + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { +#elif APOLLO + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { +#elif defined(LINUX) + TIMEOUT(rval = statfs(dir, &sfsbuf)); + if (rval != 0) { +#elif HPUX + TIMEOUT(rval = statfs(dir, &sfsbuf)); + if (rval != 0) { +#elif INDIGO + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { +#elif SYSVONLY + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { +#else +#ifndef AIXPS2 + TIMEOUT(rval = statfs(dir, &sfsbuf)); +#endif /* AIXPS2 */ + + if (rval != 0) { +#endif /* ULTRIX */ + *Lisp_errno = errno; + return(NIL); + } +#ifdef ULTRIX + *buf = sfsbuf.fd_req.bfree; +#elif defined(RS6000) + *buf = (sfsbuf.f_bavail) * 4; /* AIX 3.1 returns no. of 4K blocks */ +#elif defined(ISC) + *buf = (sfsbuf.f_bfree)/2; /* ISC claims 1K blocks, but it's really 512b */ +#elif defined(SYSVONLY) + *buf = sfsbuf.f_bfree; +#elif (!defined(AIXPS2)) + *buf = sfsbuf.f_bavail; +#else + *buf = 200000; /* FAKE - pretend we have 200,000 blocks free! */ +#endif /* ULTRIX */ +#endif /* DOS */ + return(ATOM_T); +} + + + +/******************************************** + Subroutines +********************************************/ + +/* + * Name: unpack_filename + * + * Argument: char *file UNIX file name in the UNIX format. It must be an + * absolute path. + * char *dir The place where unpacked directory will be stored. + * char *name The place where unpacked "root file name" will be + * stored. "Root file name" contains the file name + * and the extension. + * char *ver The place where unpacked version will be stored. + * int checkp If 1, whether the version field contains only the + * numeric characters or not will be checked. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: dir, name, and ver will be replaced with the unpacked corresponding + * fields. + * + * Description: + * + * Unpack the specified UNIX full pathname to three components. If the file does + * not include a version field, NULL string will be stored as a version. + * unpack_filename assumes the pathname passed is a file, not a directory. + * + */ + +unpack_filename(file, dir, name, ver, checkp) + register char *file; + register char *dir; + register char *name; + register char *ver; + register int checkp; +{ + register char *cp; + +#ifdef DOS + if ((cp =(char *) max((UNSIGNED) rindex(file, DIRSEP), + (UNSIGNED) rindex(file,UNIXDIRSEP))) == 0) + return(0); + + if (file[1] == DRIVESEP) + { /* There's a drive spec; copy it and ignore it from here on. */ + *dir++ = *file++; + *dir++ = *file++; + } +#else /* DOS */ + if ((cp = (char *) rindex(file,UNIXDIRSEP)) == NULL) return(0); +#endif /* DOS */ + + if (cp == file) { + /* File is on a root directory. */ + *dir = '/'; + *(dir + 1) = '\0'; + } else { + while (file != cp) *dir++ = *file++; + *dir = '\0'; + } + + strcpy(name, cp + 1); + separate_version(name, ver, checkp); + return(1); +} + +/* + * Name: separate_version + * + * Argument: char *name UNIX file name. It is recommended to pass only + * "root file name" (i.e. without directory) as + * name argument, but full file name is also + * acceptable. + * char *ver The place where extracted version will be stored. + * init checkp If 1, whether the version field contains only + * numbers or not is checked. If 0, anything in the + * version field is stored in ver. If GENERATEFILE + * want to contain a wild card character in a version + * field, checkp should be 0. + * + * Value: void + * + * Side Effect: If name contains a valid version field, name and version will + * be set to name and version respectively. + * + * Description: + * + * Check if name contains the valid version field and if so, separate version + * field from name field. After this operation, name contains only name and + * version contains its version. If name does not contain a valid version + * field, version will be NULL string. + * If checkp is 1, the version field which contains only numeric characters are + * regarded valid. + * + */ + +separate_version(name, ver, checkp) + register char *name; + register char *ver; + register int checkp; +{ + register char *start, *end, *cp; + register int len, ver_no; + char ver_buf[VERSIONLEN]; + + if ((end = (char *)strchr(name, '~')) != (char *)NULL) { + start = end; + cp = end + 1; + while (*cp) { + if (*cp == '~') { + start = end; + end = cp; + } + cp++; + } + + if (start != end && *(start - 1) == '.' && end == (cp - 1)) { + /* + * name ends in the form ".~###~". But we have to check + * ### are all numbers or not, if checkp is 1. + */ + len = (int)end - (int)start - 1; + strncpy(ver_buf, start + 1, len); + ver_buf[len] = '\0'; + if (checkp) { + NumericStringP(ver_buf, YES, NO); + YES: + /* + * name contains a valid version field. + */ + *(start - 1) = '\0'; + *end = '\0'; + /* + * Use atoi to eliminate leading 0s. + */ + ver_no = atoi(start + 1); + sprintf(ver_buf, "%d", ver_no); + strcpy(ver, ver_buf); + return; + } else { + *(start - 1) = '\0'; + strcpy(ver, ver_buf); + return; + } + } + } + else if (strchr(name,'%')) { strcpy(ver,"0"); return;} + NO: + /* name does not contain a valid version field. */ + *ver = '\0'; +} + + + +/* + * Name: separate_host + * + * Argument: char *lfname Lisp full file name including host field. + * char *host The place where host field will be stored. + * + * Value: void + * + * Side Effect: lfname will be replaced with the file name except host field, + * and host will be replaced with the host field. + * + * Description: + * + * Accepts a Lisp full file name from Lisp code, and separate the host field + * from other components. The result will be appropriate form to pass to + * unixpathname. For convinience to unixpathname, the initial directory + * delimiter will be removed from lfname except the case lfname specifies the + * very root directory. And if the lfname is regarded as other directory, + * the trail directory delimiter is also removed. + * + */ + +#ifdef DOS +separate_host(lfname, host, drive) + char *drive; +#else +separate_host(lfname, host) +#endif /* DOS */ + register char *lfname; + register char *host; +{ + register char *cp; + register int diff; + + cp = lfname + 1; /* Skip the initial "{". */ + + while (*cp != '}') *host++ = *cp++; + *host = '\0'; + + cp++; /* Now, *cp == '<' or drive letter. */ +#ifdef DOS + /* Check if there's a drive specified. */ + + if (*(cp+1) == DRIVESEP) + { + *drive = *cp; /* copy the drive letter, if there is one */ + cp++; cp++; /* Move to the real `<`/ */ + } + else *drive = '\0'; /* no drive */ +#endif /* DOS */ + + if (*(cp + 1) == '\0') { + /* Root directory is specified. */ + *lfname = '<'; + *(lfname + 1) = '\0'; + } else { + diff = (int)cp - (int)lfname; + if (*cp == '<' || *cp == DIRSEP +#ifdef DOS + || *cp == UNIXDIRSEP +#endif /* DOS */ + ) { + /* + * Skip the initial directory delimiter. + */ + cp++; + diff++; + } + while (*cp) { + *(cp - diff) = *cp; + cp++; + } + if (*(cp - 1) == '>' && *(cp - 2) != '\'') { + /* + * The last character is a not quoted directory + * delimiter. We have to remove it from the result + * lfname for the convenience of unixpathname. + */ + *(cp - diff - 1) = '\0'; + } else { + *(cp - diff) = '\0'; + } + } +} + + + + +#ifdef DOS +separate_drive(lfname, drive) + register char *lfname; + char *drive; +{ + register char *cp; + + cp = lfname ; + + /* Check if there's a drive specified. */ + + if (*(cp+1) == DRIVESEP) + { + *drive = *cp; /* copy the drive letter, if there is one */ + cp++; cp++; /* Move to the real `<`/ */ + while (*cp) /* Move the rest to the left to cover. */ + { + *(cp - 2) = *cp; + cp++; + } + *(cp-2) = '\0'; + } + else *drive = '\0'; /* no drive */ + + +} +#endif /* DOS */ + + +/* + * Name: true_name + * + * Argument: char *path The pathname which follows the UNIX file naming + * convention and does not include any meta character. + * Whether a tail directory delimiter is included + * in path or not is not a matter. true_name handles + * both case correctly. + * + * Value: If the pathname is recognized as an existing directory, returns + * -1, recognized as an existing file, returns 1, otherwise 0. + * + * Side Effect: If succeed, the contents of path is replaced with the true name. + * + * Description: + * + * Try to find the file or directory specified with path. The search is case + * insensitive. + * + */ + +true_name(path) + register char *path; +{ + char dir[MAXPATHLEN]; + char name[MAXNAMLEN], drive[1]; + register char *sp, *cp; + register int type, c; + + if (strcmp(path, "/") == 0) return(-1); + +#ifdef DOS + if (*(path+1) == DRIVESEP) + { + drive[0] = *path; + dir[0] = drive[0]; /* but copy it to the working dir string */ + dir[1] = DRIVESEP; + dir[2] = '\0'; + cp = path + 3; /* skip the drive spec & 1st dir delimiter */ + } + else + { +#endif /* DOS */ + *dir = '\0'; /* + * locate_file does not accept the directory with + * the trail delimiter. Thus, for the root + * directory, we have to set the null character + * as directory. + */ + cp = path + 1; +#ifdef DOS + } +#endif /* DOS */ + /* If all there was was the root /, succeed easily */ + if (strcmp((cp-1), DIRSEPSTR) == 0) return (-1); + + while (*cp) { + /* + * Copy the next subdirectory to name. + * And examine if it is an existing subdirectory or the file on the + * dir. + * At this point dir has been guaranteed to be exist. + */ + sp = name; + for (c= *cp++, *sp++ = c; c != '/' && c != '\0' && c != DIRSEP ;c= *cp++, *sp++ = c) {} + if (c == '/') { + /* Remove the trail delimiter */ + *(sp - 1) = '\0'; + } else { + /* Move back cp to '\0' character to finish the loop. */ + cp--; + } + + /* Try to locate name on dir*/ + if ((type = locate_file(dir, name)) == 0) { + /* + * No directory or file named name has been found on + * dir. + */ + return(0); + } + /* + * Now, the true name including the name has been set + * to dir by locate_file. + */ + } + strcpy(path, dir); + return(type); + +} + + + + +/* + * Name: locate_file + * + * Argument: char *dir The existing directory name. Does not include + * the trail delimiter. + * + * char *name The name which is searched on dir. + * + * Value: If name is recognized as an existing diretory, returns -1, + * recognized as an existing file, returns 1, otherwise 0. + * + * Side Effect: If succeed, the contents of dir is replaced with the true name + * including name. + * + * Description: + * + * Try to find the file or directory specified with name on the directory + * specified with dir. The search is case insensitve. + * + */ + +locate_file(dir, name) + register char *dir; + register char *name; +{ +#ifdef DOS + char path[MAXPATHLEN]; + char nb1[MAXNAMLEN], nb2[MAXNAMLEN]; + register int type, len; + struct find_t dirp; + struct direct *dp; + + /* First of all, recognize as if. */ + sprintf(path, "%s\\%s", dir, name); + DIR_OR_FILE_P(path, type); + if (type != 0) + { + strcpy(dir, path); + return(type); + } + + return(0); + +#else /* UNIX code follows */ + + char path[MAXPATHLEN]; + char nb1[MAXNAMLEN], nb2[MAXNAMLEN]; + register int type, len; + DIR *dirp; + struct direct *dp; + + /* First of all, recognize as if. */ + sprintf(path, "%s/%s", dir, name); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return(type); + } + + /* Next try with all lower case name. */ + strcpy(nb1, name); + DOWNCASE(nb1); + sprintf(path, "%s/%s", dir, nb1); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return(type); + } + + /* Next try with all upper case name. */ + UPCASE(nb1); + sprintf(path, "%s/%s", dir, nb1); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return(type); + } + + /* No way. Read dir and compare with name. */ + len = strlen(name); + errno=0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return(0); + } + for(S_TOUT(dp = readdir(dirp)); dp != NULL || errno == EINTR; errno=0, S_TOUT(dp = readdir(dirp))) + if (dp) + { + if (dp->d_namlen == len) { + strcpy(nb2, dp->d_name); + UPCASE(nb2); + if (strcmp(nb1, nb2) == 0) { + sprintf(path, "%s/%s", dir, dp->d_name); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + TIMEOUT(closedir(dirp)); + return(type); + } + } + } + } + TIMEOUT(closedir(dirp)); + return(0); +#endif /* DOS */ +} + + + +/* + * Name: make_directory + * + * Argument: char *dir The full directory name in UNIX format. It does + * not include a tail delimiter. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: The directory specified as dir will be created in the file system. + * If succeed, dir will be replaced with the true name of the directory. + * + * Description: + * + * Try to create a specified directory. + * + */ + +make_directory(dir) + register char *dir; +{ + register char *cp, *dp; + register int maked, rval; + char dir_buf[MAXPATHLEN]; + + maked = 0; + + dp = dir_buf; + cp = dir; + +#ifdef DOS + if (DRIVESEP == *(cp+1)) + { + *dp++ - *cp++; /* copy the drive letter and colon */ + *dp++ = *cp++; + } +#endif /* DOS */ + + + *dp++ = DIRSEP; /* For a root directory. */ + cp++; /* Skip a root directory in dir. */ + + for (;;) { + switch (*cp) { +#ifdef DOS + case DIRSEP: +#endif + case '/': + case '\0': + *dp = '\0'; + /* + * Now, dir_buf contains the absolute path to the next + * subdirectory or file. If one of the parent directories + * are created, we have to create a new subdirectory + * anyway. If all of the parent directories are exisiting + * directories, we have to check this subdirectory is an + * exisiting or not. + */ + if (maked) { +#ifdef DOS + TIMEOUT(rval = mkdir(dir_buf)); +#else + TIMEOUT(rval = mkdir(dir_buf, 0777)); +#endif /* DOS */ + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } + if (*cp == '\0') { + strcpy(dir, dir_buf); + return(1); + } + *dp++ = DIRSEP; + cp++; + } else { + switch (true_name(dir_buf)) { + + case -1: /* Directory */ + if (*cp == '\0') { + /* Every subdirectories are examined. */ + strcpy(dir, dir_buf); + return(1); + } else { + dp = dir_buf; + while (*dp) dp++; + *dp++ = DIRSEP; + cp++; + } + break; + + case 1: /* Regular File */ + /* + * UNIX does not allow to make a directory + * and a file in the same name on a directory. + */ + return(0); + + default: + /* + * Should handle other cases. (special file). + */ +#ifdef DOS + TIMEOUT(rval = mkdir(dir_buf)); +#else + TIMEOUT(rval = mkdir(dir_buf, 0777)); +#endif /* DOS */ + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } + if (*cp == '\0') return(1); + *dp++ = DIRSEP; + cp++; + maked = 1; + break; + } + } + break; + + default: + *dp++ = *cp++; + break; + } + } +} + +/* + * Name: FindHighestVersion + * + * Argument: FileName *varray + * The version array. It has to include at + * least one versioned file. + * FileName *mentry + * The place where an entry in varray corresponding + * to the highest versioned file will be stored. + * int max_no The place where the version number of the highest + * versioned file will be stored. + * + * Value: N/A + * + * Side Effect: mentry and max_no will be replaced with the highset versioned entry + * and highest version number respectively. + * + * Description: + * + * Find the highest versioned entry in varray. Varray has to include at least + * one versioned file, that is varray has to satisfy (!NoFileP(varray) && + * !OnlyVersionlessP(varray)). + * + */ +#ifdef DOS +#define FindHighestVersion(varray, mentry, max_no){ \ + \ + register FileName *centry; \ + for (centry = varray, max_no = -1; centry->version_no != LASTVERSIONARRAY; \ + centry++) { \ + if (centry->version_no > max_no) { \ + max_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ +} +#else +#define FindHighestVersion(varray, mentry, max_no){ \ + \ + register FileName *centry; \ + for (centry = varray, max_no = 0; centry->version_no != LASTVERSIONARRAY; \ + centry++) { \ + if (centry->version_no > max_no) { \ + max_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ +} +#endif /* DOS */ + + + +/* + * Name: FindLowestVersion + * + * Argument: FileName *varray + * The version array. It has to include at + * least one versioned file. + * FileName *mentry + * The place where an entry in varray corresponding + * to the lowest versioned file will be stored. + * int min_no The place where the version number of the highest + * versioned file will be stored. + * + * Value: N/A + * + * Side Effect: mentry and min_no will be replaced with the lowest versioned entry + * and lowest version number respectively. + * + * Description: + * + * Find the lowest versioned entry in varray. Varray has to include at least + * one versioned file, that is varray has to satisfy (!NoFileP(varray) && + * !OnlyVersionlessP(varray)). + * + */ +#ifdef DOS +#define FindLowestVersion(varray, mentry, min_no){ \ + \ + register FileName *centry; \ + for (centry = varray, min_no = MAXVERSION; \ + centry->version_no != LASTVERSIONARRAY; centry++) { \ + if (centry->version_no < min_no ) { \ + min_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ +} +#else +#define FindLowestVersion(varray, mentry, min_no){ \ + \ + register FileName *centry; \ + for (centry = varray, min_no = MAXVERSION; \ + centry->version_no != LASTVERSIONARRAY; centry++) { \ + if (centry->version_no < min_no && centry->version_no != 0) { \ + min_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ +} +#endif /* DOS */ + + + +/* + * Name: FindSpecifiedVersion + * + * Argument: FileName *varray + * The version array. It has to include at + * least one versioned file. + * FileName *sentry + * The place where an entry in varray corresponding + * to the file which has the specified version will + * be stored. + * int ver_no The version number to be found. + * + * Value: N/A + * + * Side Effect: sentry will be replaced with the specified versioned entry. + * + * Description: + * + * Find the specified versioned entry in varray. Varray has to include at least + * one versioned file, that is varray has to satisfy (!NoFileP(varray) && + * !OnlyVersionlessP(varray)). + * + */ + +#define FindSpecifiedVersion(varray, sentry, ver_no){ \ + \ + register FileName *centry; \ + \ + sentry = (FileName *)NULL; \ + for (centry = varray; centry->version_no != LASTVERSIONARRAY; centry++) \ + if (centry->version_no == ver_no) { \ + sentry = centry; \ + break; \ + } \ +} + + + + + + +/************************************************************************/ +/* */ +/* g e t _ v e r s i o n _ a r r a y */ +/* */ +/* Given a file, create an array of file/version# pairs for all */ +/* versions of that file. Returns 1 on success, 0 on failure. */ +/* */ +/* dir UNIX directory specified absolutely. Caller must */ +/* guarantee that the directory exists. */ +/* file File name, optionally including a (unix) version */ +/* varray Place to put the version array entries. */ +/* cache Place to hold info about the new version array */ +/* */ +/* Read thru DIR and gather all files that match FILE into */ +/* VARRAY. DIR's case must match existing directory's, but */ +/* FILE name matching is case-insensitive. For UNIX, the */ +/* versionless file is marked with a version# of 0; for DOS, */ +/* version 0 is the back-up copy of the file. */ +/* */ +/************************************************************************/ + +get_version_array(dir, file, varray, cache) + register char *dir; + register char *file; + register FileName *varray; + register CurrentVArray *cache; + { +#ifdef DOS + + char lcased_file[MAXPATHLEN]; + char old_file[MAXPATHLEN]; + char name[MAXNAMLEN]; + char ver[VERSIONLEN]; + register FileName *svarray; + struct find_t dirp; + register struct direct *dp; + register int rval, drive = 0, isslash = 0; + struct stat sbuf; + int res; + + + /* + * First of all, prepare a lower cased file name for the case insensitve + * serch. Also we have to separate file name from its version field. + */ + if (dir[1] == DRIVESEP) drive = dir[0]; + + if (strcmp(dir, "\\")==0) isslash = 1; + else if (drive && (strcmp(dir+2, "\\")==0)) isslash = 1; + + if (!isslash) strcpy(lcased_file, dir); /* Only add the dir if it's real */ + else if (drive) + { + lcased_file[0] = drive; + lcased_file[1] = DRIVESEP; + lcased_file[2] = '\0'; + } + else *lcased_file = '\0'; + + /* strcpy(lcased_file, dir); removed when above code added 3/4/93 */ + strcat(lcased_file, DIRSEPSTR); + strcat(lcased_file, file); + separate_version(lcased_file, ver, 1); + DOWNCASE(lcased_file); + + /*************************************************/ + /* First, look up the backup version of the file */ + /*************************************************/ + + /* First, make the "backup-file-name" for this file */ + + make_old_version(old_file, lcased_file); + + svarray = varray; + + TIMEOUT(res = _dos_findfirst(old_file,_A_NORMAL|_A_SUBDIR,&dirp)); + if (res == 0) + { + strcpy(name, dirp.name); + strcpy(svarray->name, name); + svarray -> version_no = 0; + svarray++; + } + + /*******************************/ + /* Now look up the file itself */ + /*******************************/ + + TIMEOUT(res = _dos_findfirst(lcased_file,_A_NORMAL|_A_SUBDIR,&dirp)); +/* if (res != 0) + { + *Lisp_errno = errno; + return(0); + } +*/ + for ( ; res == 0 ; S_TOUT(res = _dos_findnext(&dirp))) + { + strcpy(name, dirp.name); + separate_version(name, ver, 1); + DOWNCASE(name); + + strcpy(svarray->name, dirp.name); + if (*ver == '\0') + { + /* Versionless file */ + svarray->version_no = 1; + } + else + { + /* + * separater_version guranteeds ver is a numeric + * string. + */ + svarray->version_no = atoi(ver); + } + svarray++; + } + + /* + * The last entry of varray is indicated by setting LASTVERSIONARRAY into + * version_no field. + */ + svarray->version_no = LASTVERSIONARRAY; + + /* + * If more than one files have been stored in varray, we store the name + * without version in the last marker entry. + */ + if (!NoFileP(varray)) + { + strcpy(name, varray->name); + separate_version(name, ver, 1); + strcpy(svarray->name, name); + } + + return(1); + +#else + /* UNIX version-array builder */ + char lcased_file[MAXNAMLEN]; + char name[MAXNAMLEN]; + char ver[VERSIONLEN]; + register FileName *svarray; + register DIR *dirp; + register struct direct *dp; + register int rval; + struct stat sbuf; + + /* + * First of all, prepare a lower cased file name for the case insensitve + * serch. Also we have to separate file name from its version field. + */ + strcpy(lcased_file, file); + separate_version(lcased_file, ver, 1); + DOWNCASE(lcased_file); + +/* + TIMEOUT(rval = stat(dir, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } +*/ + + /* + * If the cached version array is still valid, we can return immediately. + */ + + /* + * Cache machaisme is not used now, because of the bug of Sun OS. + * Sometimes just after unlinking a file on a directory, the st_mtime + * of the directory does not change. This will make Maiko beleive + * cached version array is still valid, although it is already invalid. + * sync(2) has no effect on such case. + */ + +/* + if ((sbuf.st_mtime == cache->mtime) && strcmp(dir, cache->path) == 0 + && strcmp(lcased_file, cache->file) == 0) return(1); +*/ + errno=0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return(0); + } + + for (S_TOUT(dp = readdir(dirp)), svarray = varray; dp != NULL || errno == EINTR; + errno=0, S_TOUT(dp = readdir(dirp))) + if(dp) + { + strcpy(name, dp->d_name); + separate_version(name, ver, 1); + DOWNCASE(name); + if (strcmp(name, lcased_file) == 0) { + /* + * This file can be regarded as a same file in Lisp sense. + */ + strcpy(svarray->name, dp->d_name); + if (*ver == '\0') { + /* Versionless file */ + svarray->version_no = 0; + } else { + /* + * separater_version guranteeds ver is a numeric + * string. + */ + svarray->version_no = atoi(ver); + } + svarray++; + } + } + /* + * The last entry of varray is indicated by setting LASTVERSIONARRAY into + * version_no field. + */ + svarray->version_no = LASTVERSIONARRAY; + + /* + * If more than one files have been stored in varray, we store the name + * without version in the last marker entry. + */ + if (!NoFileP(varray)) { + strcpy(name, varray->name); + separate_version(name, ver, 1); + strcpy(svarray->name, name); + } + + /* + * Update cache information. + */ +/* + strcpy(cache->path, dir); + strcpy(cache->file, lcased_file); + cache->mtime = sbuf.st_mtime; +*/ + TIMEOUT(closedir(dirp)); + return(1); +#endif /* DOS */ +} + + + + +/* + * Name: maintain_version + * + * Argument: char *file The full file name in UNIX format. + * FileName *varray + * The version array. + * int forcep If 1, a versionless file will be linked to version + * 1 file when there is no other files having the same + * name. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: None. + * + * Description: + * + * Try to make sure that the version control based on the name convention + * is well maintained. The versionless file corresponding to file will be + * maintained. The second argument varray is an optional. If it is not + * NULL pointer, maintain_version maintains the version control using the + * version array. If varray is NULL pointer, a version array is re collected + * by this routine. + * Currently, forcep is 1 only if maintain_version is called from COM_openfile + * to maintain the directory on which a file is being created. + */ + +maintain_version(file, varray, forcep) + register char *file; + register FileName *varray; + register int forcep; +{ + char dir[MAXPATHLEN], fname[MAXNAMLEN], ver[VERSIONLEN]; + char old_file[MAXPATHLEN], vless[MAXPATHLEN]; + int highest_p; + register int rval, max_no; + register FileName *entry; + + if (varray == (FileName *)NULL) { + if (unpack_filename(file, dir, fname, ver, 1) == 0) return(0); + /* + * We have to make sure that dir is the existing directory. + */ + if (true_name(dir) != -1) return(0); + if (get_version_array(dir, fname, VersionArray, &VArrayInfo) == 0) + return(0); + varray = VersionArray; + } + + if (NoFileP(varray)) { + /* + * We don't need to care about such case that there is no such file + * or an only versionless file exists. + */ + return(1); + } + + if (OnlyVersionlessP(varray)) { + if (forcep) { + /* + * If forcep, we link the versionless file to the version + * 1 file. + */ +#ifndef DOS + get_versionless(varray, vless, dir); + ConcNameAndVersion(vless, "1", fname); + TIMEOUT(rval = link(vless, fname)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } +#endif /* DOS */ + } + return(1); + } + + /* + * At this point, we are sure that at least one file with version number + * exists. Thus, FindHighestVersion works fine from now on. + */ + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is not a versionless file, but at least one versioned file. + * Thus, the thing we have to do is to link a versionless file + * to the existing highest versioned file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, old_file); + /* + * The versionless file should have the same case name as the old + * file. + */ +#ifndef DOS + strcpy(fname, entry->name); + separate_version(fname, ver, 1); + ConcDirAndName(dir, fname, vless); + TIMEOUT(rval = link(old_file, vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } +#endif /* DOS */ + return(1); + } + + if (check_vless_link(vless, varray, old_file, &highest_p) == 0) return(0); + + if (*old_file == '\0') { + /* + * The versionless file is not linked to any file in varray. + * Thus, we have to link the versionless file to the file which + * is versioned one higher than the exisiting highest version. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(ver, "%d", max_no + 1); + /* + * The old file should have the same case name as the versionless + * file. + */ +#ifndef DOS + ConcNameAndVersion(vless, ver, old_file); + TIMEOUT(rval = link(vless, old_file)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } +#endif /* DOS */ + return(1); + } + + if (highest_p) { + /* + * The versionless file has been already linked to the highest + * versioned file. Thus, there is nothing to do. + */ + return(1); + } else { + /* + * Although the versionless file is linked to a file in varray, + * the file is not the highest versioned file. We have to unlink + * the wrongly linked versionless file, and link the highest versioned + * file to a versionless file. + */ + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, old_file); + /* + * The versionless file should have the same case name as the old + * file. + */ +#ifndef DOS + strcpy(fname, entry->name); + separate_version(fname, ver, 1); + ConcDirAndName(dir, fname, vless); + TIMEOUT(rval = link(old_file, vless)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } +#endif /* DOS */ + return(1); + } +} + + + + +/* + * Name: get_versionless + * + * Argument: FileName *varray + * The version array already filled by + * get_version_array routin. + * char *file The place where the full file name of the found + * versionless file will be stored. + * char *dir Directory absolute path following the UNIX + * file naming convention on which varray + * has been gathered. + * + * Value: If a versionless file found, returns 1, otherwise 0. + * + * Side Effect: file will be replaced with the full name of the found versionless + * file when it is found. + * + * Description: + * + * Accepts a version array and try to find a versionless file within it. + * + */ + +get_versionless(varray, file, dir) + register FileName *varray; + register char *file; + register char *dir; +{ +#ifdef DOS +return(0); +#endif /* DOS */ + if (NoFileP(varray)) return (0); + + while (varray->version_no != LASTVERSIONARRAY) { + if (varray->version_no == 0) { + ConcDirAndName(dir, varray->name, file); + return(1); + } else + varray++; + } + return(0); +} + + +/* + * Name: check_vless_link + * + * Argument: char *vless The full file name of the versionless file in + * UNIX format. + * FileName *varray + * The version array already filled by get_version_array. + * char *to_file + * The place where the full file name of the file + * to which the versionless file is hard linked will + * be stored. + * int *highest_p + * If to_file is the highest versioned file in varrray, + * highest_p will point to 1, otherwise, 0. + * + * Value: If succeed, returns 1, otherwise, 0. + * + * Side Effect: to_file will be replaced with the full file name to which the + * versionless file is hard linked. highest_p will be replaced with + * 1 or 0. + * + * Description: + * + * Examines the link status of a specified versionless file. If there is a file + * to which the versionless file is hard linked in a version array, it will be + * stored in to_file. If there is no such file, to_file will be NULL string. + * When hard linked file is found, if highest_p is 1, the file is the highest + * versioned file in the version array. This is the such case that a versionless + * file is well maintained by DSK code. + * Notice that even if to_file is NULL, it does not mean that the versionless file + * is not hard linked to any file. It only means that there is no file to which the + * versionless file is hard linked in the version array. The versionless file + * might be hard linked to the other file entirely differently named. + * + */ + +check_vless_link(vless, varray, to_file, highest_p) + register char *vless; + register FileName *varray; + register char *to_file; + register int *highest_p; +{ + register int rval, max_no, found; + ino_t vless_ino; + struct stat sbuf; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + register FileName *max_entry, *linked_entry; + + TIMEOUT(rval = stat(vless, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(0); + } + + if (sbuf.st_nlink == 1) { + /* There is no file to which vless is hard linked. */ + *to_file = '\0'; + return(1); + } + vless_ino = sbuf.st_ino; + + if (unpack_filename(vless, dir, name, ver, 1) == 0) return(0); + + max_no = 0; + found = 0; + max_entry = NULL; + linked_entry = NULL; + + while (varray->version_no != LASTVERSIONARRAY) { + if (varray->version_no > max_no) { + max_no = varray->version_no; + max_entry = varray; + } + if (!found && varray->version_no != 0) { + ConcDirAndName(dir, varray->name, name); + TIMEOUT(rval = stat(name, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return(0); + } + if (sbuf.st_ino == vless_ino) { + found = 1; + linked_entry = varray; + } + } + varray++; + } + + if (linked_entry != NULL) { + if (linked_entry == max_entry) { + *highest_p = 1; + } else { + *highest_p = 0; + } + strcpy(to_file, name); + } else { + *to_file = '\0'; + } + return(1); +} + + +/* + * Name: get_old + * + * Argument: char *dir Directory absolute path following the UNIX + * file naming convention on which varray + * has been gathered. + * FileName *varray + * The version array already filled by + * get_version_array routin. + * char *afile File name. It might include a version field. + * The version field have to be following the + * UNIX convention, that is "name.~##~", not + * Xerox Lisp one. The versionless file is + * also acceptable. + * afile is also used as a place where the true + * name of the recognized file will be stored. + * char *vfile The place where the versioned name of the + * recognized file will be stored. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: afile will be replaced with the full name of the recognized file + * when the recognition succeed. vfile will be replaced with the + * versioned full name of the recognized file when the recognition + * succeed. + * + * Description: + * + * Accepts a version array and file name, and recognize a file in the version + * array with the old mode. + * "Old" file means the "newest existing" file. + * Notice that, afile and vfile are not necessary same name, because the versionless + * file is recognized as an old file, afile will hold the true versionless file name, + * although vfile will hold the versioned file name anyway. + * afile could be used as the real UNIX pathname to access the recognized file, on + * the other hand, vfile could be used as file name from which the file name + * which should be returned to Lisp could be produced. + * + */ + +get_old(dir, varray, afile, vfile) + register char *dir; + register FileName *varray; + register char *afile; + register char *vfile; +{ + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, max_no; + int highest_p; + register FileName *entry; + + + /* "Old" file have to be existing, thus varray should not be empty. */ + if (NoFileP(varray)) return(0); + + strcpy(name, afile); + separate_version(name, ver, 1); + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else return(0); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. + */ + ConcNameAndVersion(vless, "1", vfile); + strcpy(afile, vless); + return(1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * Other versions than 1 are not recognized as an old + * file. + */ + return(0); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) + return(0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The one higher than an + * exisiting maximum version is dealt with as the + * old version, and it should be a version of the + * link missing versionless file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return(1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, max_no); + if (ver_no == max_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else return(0); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * in varray is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else return(0); + } + } + } +} + +/* + * Name: get_oldeset + * + * Argument: char *dir Directory absolute path following the UNIX + * file naming convention on which varray + * has been gathered. + * FileName *varray + * The version array already filled by + * get_version_array routin. + * char *afile File name. It might include a version field. + * The version field have to be following the + * UNIX convention, that is "name.~##~", not + * Xerox Lisp one. The versionless file is + * also acceptable. + * afile is also used as a place where the true + * name of the recognized file will be stored. + * char *vfile The place where the versioned name of the + * recognized file will be stored. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: afile will be replaced with the full name of the recognized file + * when the recognition succeed. vfile will be replaced with the + * versioned full name of the recognized file when the recognition + * succeed. + * + * Description: + * + * Accepts a version array and filename, and recognize a file in the version + * array with oldest mode. + * "Oldest" file means the "oldest existing" file. + * Notice that, afile and vfile are not necessary same name, because the versionless + * file is recognized as an old file, afile will hold the true versionless file name, + * although vfile will hold the versioned file name anyway. + * afile could be used as the real UNIX pathname to access the recognized file, on + * the other hand, vfile could be used as file name from which the file name + * which should be returned to Lisp could be produced. + * + */ + +get_oldest(dir, varray, afile, vfile) + register char *dir; + register FileName *varray; + register char *afile; + register char *vfile; +{ + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, min_no; + int highest_p; + register FileName *entry; + + + /* "Oldest" file have to be existing, thus varray should not be empty. */ + if (NoFileP(varray)) return(0); + + strcpy(name, afile); + separate_version(name, ver, 1); + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The lowest versioned file + * is an oldest file. + */ + FindLowestVersion(varray, entry, min_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else return(0); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. + */ + ConcNameAndVersion(vless, "1", vfile); + strcpy(afile, vless); + return(1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * Other versions than 1 are not recognized as an + * oldest file. + */ + return(0); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) + return(0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The lowest version is + * dealt with as the oldest version. + */ + FindLowestVersion(varray, entry, min_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, min_no); + if (ver_no == min_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else return(0); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The lowest versioned file + * in varray is an old file. + */ + FindLowestVersion(varray, entry, min_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else return(0); + } + } + } +} + + +/* + * Name: get_new + * + * Argument: char *dir Directory absolute path following the UNIX + * file naming convention on which varray + * has been gathered. + * FileName *varray + * The version array already filled by + * get_version_array routin. + * char *afile File name. It might include a version field. + * The version field have to be following the + * UNIX convention, that is "name.~##~", not + * Xerox Lisp one. The versionless file is + * also acceptable. + * afile is also used as a place where the true + * name of the recognized file will be stored. + * char *vfile The place where the versioned name of the + * recognized file will be stored. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: afile will be replaced with the full name of the recognized file + * when the recognition succeed. vfile will be replaced with the + * versioned full name of the recognized file when the recognition + * succeed. + * + * Description: + * + * Accepts a version array and filename, and recognize a file in the version + * array with new mode. + * "New" file means the "not yet existing" file with the version which is one + * higher than the current highest version. + * Notice that, afile and vfile are not necessary same name, because the versionless + * file is recognized as an old file, afile will hold the true versionless file name, + * although vfile will hold the versioned file name anyway. + * afile could be used as the real UNIX pathname to access the recognized file, on + * the other hand, vfile could be used as file name from which the file name + * which should be returned to Lisp could be produced. + * + */ + +get_new(dir, varray, afile, vfile) + register char *dir; + register FileName *varray; + register char *afile; + register char *vfile; +{ + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, max_no; + int highest_p; + register FileName *entry; + + strcpy(name, afile); + separate_version(name, ver, 1); + +#ifndef DOS + if (NoFileP(varray)) { + /* + * If there is no file with such name, "new" file is always + * recognized. + */ + if (*ver == '\0' || strcmp(ver, "1") == 0) +#endif /* DOS */ + { + /* + * If version is not specified or 1 is specified, + * we can return versionless file as afile. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + ConcDirAndName(dir, name, afile); + return(1); + } +#ifndef DOS + else { + /* + * A version other than 1 is specified. "New" file + * is recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The new file is one higher than + * the existing highest version. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + /* + * We weill use the file name of the exisiting highest + * versioned file as the name of the new file, so that + * new file is as the same case as old. + */ + strcpy(name, entry->name); + separate_version(name, ver, 1); + ConcDirAndName(dir, name, afile); + ConcNameAndVersion(afile, vbuf, vfile); + strcpy(afile, vfile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } + /* + * There is not a file with the specified version in varray. + * The specified file can be recognized as if. + * Most user will hope to create a new file in same case as + * old. One of case sensitive names in the files are stored + * in the trail marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all of the gathered + * files has the name in same case. + */ + while (varray->version_no != LASTVERSIONARRAY) varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. Thus new version is 2. + */ + ConcNameAndVersion(vless, "2", vfile); + strcpy(afile, vfile); + return(1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * Other versions than 1 are recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) + return(0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The two higher than an + * exisiting maximum version is dealt with as the + * new version, because the one higher version is + * dealt with as the actual version of the link + * missing versionless file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 2); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vfile); + return(1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, max_no); + if (ver_no == max_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. One of case sensitive + * names in the files are stored in the trail + * marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all + * of the gathered files has the name in same + * case. + */ + while (varray->version_no != LASTVERSIONARRAY) + varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The one higher than the + * exisiting highest versioned file in varray is a + * new file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + /* + * We will use the name of the highest versioned file + * as the name of the new file. + */ + strcpy(vless, entry->name); + separate_version(vless, ver, 1); + ConcDirAndName(dir, vless, afile); + ConcNameAndVersion(afile, vbuf, vfile); + strcpy(afile, vfile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. We will use the name of + * the highest versioned file as the name of the + * new file. + */ + FindHighestVersion(varray, entry, max_no); + strcpy(vless, entry->name); + separate_version(vless, vbuf, 1); + ConcDirAndName(dir, vless, afile); + ConcNameAndVersion(afile, ver, vfile); + strcpy(afile, vfile); + return(1); + } + } + } +#endif /* DOS */ +} + +/* + * Name: get_old_new + * + * Argument: char *dir Directory absolute path following the UNIX + * file naming convention on which varray + * has been gathered. + * FileName *varray + * The version array already filled by + * get_version_array routin. + * char *afile File name. It might include a version field. + * The version field have to be following the + * UNIX convention, that is "name.~##~", not + * Xerox Lisp one. The versionless file is + * also acceptable. + * afile is also used as a place where the true + * name of the recognized file will be stored. + * char *vfile The place where the versioned name of the + * recognized file will be stored. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: afile will be replaced with the full name of the recognized file + * when the recognition succeed. vfile will be replaced with the + * versioned full name of the recognized file when the recognition + * succeed. + * + * Description: + * + * Accepts a version array and filename, and recognize a file in the version + * array with old/new mode. + * "Old/new" file means the "newest existing" or "not yet existing" file with the + * version which is one higher than the current highest version. + * Notice that, afile and vfile are not necessary same name, because the versionless + * file is recognized as an old file, afile will hold the true versionless file name, + * although vfile will hold the versioned file name anyway. + * afile could be used as the real UNIX pathname to access the recognized file, on + * the other hand, vfile could be used as file name from which the file name + * which should be returned to Lisp could be produced. + * + */ + +get_old_new(dir, varray, afile, vfile) + register char *dir; + register FileName *varray; + register char *afile; + register char *vfile; +{ + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, max_no; + int highest_p; + register FileName *entry; + + strcpy(name, afile); + separate_version(name, ver, 1); + + if (NoFileP(varray)) { + /* + * If there is no file with such name, "old/new" file is always + * recognized. + */ + if (*ver == '\0' || strcmp(ver, "1") == 0) { + /* + * If version is not specified or 1 is specified, + * we can return versionless file as afile. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + ConcDirAndName(dir, name, afile); + return(1); + } else { + /* + * A version other than 1 is specified. "New" file + * is recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } + /* + * There is not a file with the specified version in varray. + * The specified file can be recognized as if. + * Most user will hope to create a new file in same case as + * old. One of case sensitive names in the files are stored + * in the trail marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all of the gathered + * files has the name in same case. + */ + while (varray->version_no != LASTVERSIONARRAY) varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. + */ + ConcNameAndVersion(vless, "1", vfile); + strcpy(afile, vless); + return(1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * Other versions than 1 are recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) + return(0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The one higher than an + * exisiting maximum version is dealt with as the + * old version, and it should be a version of the + * link missing versionless file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return(1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, max_no); + if (ver_no == max_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return(1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. One of case sensitive + * names in the files are stored in the trail + * marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all + * of the gathered files has the name in same + * case. + */ + while (varray->version_no != LASTVERSIONARRAY) + varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return(1); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * in varray is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return(1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. We will use the name of + * the highest versioned file as the name of the + * new file. + */ + FindHighestVersion(varray, entry, max_no); + strcpy(vless, entry->name); + separate_version(vless, vbuf, 1); + ConcDirAndName(dir, vless, afile); + ConcNameAndVersion(afile, ver, vfile); + strcpy(afile, vfile); + return(1); + } + } + } +} diff --git a/src/dsp386.il b/src/dsp386.il new file mode 100755 index 0000000..8fe4be6 --- /dev/null +++ b/src/dsp386.il @@ -0,0 +1,1791 @@ +/* @(#) dsp386.il Version 1.1 (4/21/92). copyright Venue & Fuji Xerox */ +/* @(#) disp386i.il Version 1.14 (5/3/90). copyright Venue & Fuji Xerox */ +////////////////////////////////////////////////////////////////////////// +// // +// d i s p 3 8 6 i . i l // +// // +// INLINE-code definitions specific to the Sun 386i // +// // +// Conventions (empirically discovered): // +// // +// Caller pushes args on stack // +// 0(%esp) = arg 1 // +// 4(%esp) = arg 2 // +// etc. // +// // +// Leave the result in %eax // +// // +// YOU CAN'T USE LOCAL LABELS // +// // +// jmp over code makes the code dead for -O??? // +// // +// // +// // +////////////////////////////////////////////////////////////////////////// + + +/************************************************************************/ +/* */ +/* Copyright 1990 Venue, Fuji Xerox Co., Ltd, Xerox Corp. */ +/* */ +/* This file is work-product resulting from the Xerox/Venue */ +/* Agreement dated 18-August-1989 for support of Medley. */ +/* */ +/************************************************************************/ + + + +/ swap the words in a long-word. +.inline swapx,1 + movl 0(%esp),%eax + rol $16,%eax +.end + + +/ swap the words in a long-word +.inline word_swap_longword,1 + movl 0(%esp),%eax + rol $16,%eax +.end + +/swap the bytes in a 16-bit word +.inline byte_swap_word,1 + movl 0(%esp),%eax + rolw $8,%ax +.end + + +.inline word_swap_page,8 + movl 4(%esp),%ecx / word count into the loop counter + movl 0(%esp),%edx / address of the block to swap + movl 0(%edx),%eax + rolw $8,%ax + roll $16,%eax + rolw $8,%ax + movl %eax,0(%edx) + add $4,%edx + loop .-20 +.end + +.inline bit_reverse_region,16 +/args: (top width height rasterwidth) + .noopt + pushl %edi + pushl %esi + pushl %ebx + movl 12(%esp),%edx /top + movl %edx,%eax + andl $-2,%edx + movl %edx,12(%esp) + andl $1,%eax + shll $4,%eax + addl 16(%esp),%eax /width + movl 20(%esp),%edx /height +/ 24(%esp) /rasterwidth, in words + leal 31(%eax),%eax + sarl $5,%eax + leal (%eax,%eax),%eax + movl %eax,16(%esp) / word wid now in width. + cld / so we move up thru memory + leal reversedbits,%ebx / for xlateb + movl 12(%esp),%edi / starting init of word ptr + sub $0,%edx + jle .+63 +/ ..4: + movl %edi,%esi /so both edi & esi are at start of line to swap + + movl 16(%esp),%ecx / byte count to ecx + leal (%ecx,%ecx),%ecx +/ ..3: + lodsb + xlat + stosb + loop .-3 / ..3 + + movl 16(%esp),%ecx + incl %ecx + sarl $1,%ecx + movl 12(%esp),%esi / must be into esi, then edi, to +/ andl $-2,%edi / defeat the peephole optimizer. + movl %esi,%edi +/ ..5: + lodsl + rolw $8,%ax + roll $16,%eax + rolw $8,%ax + stosl + loop .-13 / ..5 + movl 12(%esp),%edi / word = word + rasterwidth + addl 24(%esp),%edi + addl 24(%esp),%edi + movl %edi,12(%esp) + decl %edx +/ .L60: / at this point, starting word addr is in %edi + jg .-59 / ..4 + popl %ebx + popl %esi + popl %edi + .optim +.end + +///////////////////////////// +// +// Dispatch loop speedup functions for the 386i +// +// Register assumptions: +// +// pccache %edi +// TOS %ebx +// stk ptr %esi +// +// +///////////////////////////// + + + /////////////////// + // Get_BYTE_PCMAC1 -- fetch one byte at PCMAC+1 // + // (= pccache) + /////////////////// + +.inline Get_BYTE_PCMAC0fn,0 + leal -1(%edi),%eax + xorl $3,%eax + movzbl (%eax),%eax +.end + +.inline Get_BYTE_PCMAC1fn,0 + movl %edi,%eax + xorl $3,%eax + movzbl (%eax),%eax +.end + +.inline Get_BYTE_PCMAC2fn,0 + leal 1(%edi),%eax + xorl $3,%eax + movzbl (%eax),%eax +.end + +.inline Get_BYTE_PCMAC3fn,0 + leal 2(%edi),%eax + xorl $3,%eax + movzbl (%eax),%eax +.end + + +.inline Get_DLword_PCMAC0fn,0 +/ .byte 0x33,0xdb / xorl %ebx,%ebx + leal 0(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal -1(%edi),%edx + xorl $3,%edx + movb (%edx),%ah +.end + +.inline Get_DLword_PCMAC1fn,0 +/ .byte 0x33,0xdb / xorl %ebx,%ebx + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah +.end + +.inline Get_DLword_PCMAC2fn,0 +/ .byte 0x33,0xdb / xorl %ebx,%ebx + leal 2(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 1(%edi),%edx + xorl $3,%edx + movb (%edx),%ah +.end + +.inline Get_DLword_PCMAC3fn,0 + .byte 0x33,0xdb / xorl %ebx,%ebx + leal 3(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 2(%edi),%edx + xorl $3,%edx + movb (%edx),%ah +.end + + +.inline fast0_dispatcher,0 + leal -1(%edi),%eax + xorb $3,%al + movzbl (%eax),%eax + jmp *optable(,%eax,4) +.end + +.inline fast1_dispatcher,0 + movl %edi,%eax + xorb $3,%al + movzbl (%eax),%eax + incl %edi + jmp *optable(,%eax,4) +.end + +.inline fast2_dispatcher,0 + leal 1(%edi),%eax + xorb $3,%al + addl $2,%edi + movzbl (%eax),%eax + jmp *optable(,%eax,4) +.end + + + ///////////////////////////// + // + // Arithmetic code speedups + // + // Assume edi & esi are arguments + // + // ebx is result. + // + //////////////////////////////// + +.inline Xiplus32,0 + addl %edi,%esi + jo iplus_err + movl %esi,%eax +.end + +.inline Xiplus32n,0 + leal (%edi),%eax + addl %esi,%eax + jo iplusn_err +.end + + +.inline Xplus32,0 + leal (%edi),%eax + addl %esi,%eax + jo plus_err +.end + +.inline Xsub32,0 + leal (%edi),%eax + subl %esi,%eax + jo diff_err +.end + +.inline Xisub32,0 + leal (%edi),%eax + subl %esi,%eax + jo idiff_err +.end + +.inline Xisub32n,0 + leal (%edi),%eax + subl %esi,%eax + jo idiffn_err +.end + +.inline plus_err_label,0 +plus_err: +.end + +.inline iplus_err_label,0 +iplus_err: +.end + +.inline diff_err_label,0 +diff_err: +.end + +.inline idiff_err_label,0 +idiff_err: +.end + +.inline iplusn_err_label,0 +iplusn_err: +.end + +.inline idiffn_err_label,0 +idiffn_err: +.end + +.inline fast_op_difference,4 + + movl 0(%esp),%eax + roll $15,%ebx + subb $7,%bl + jne diff_err + roll $15,%eax + subb $7,%al + jne diff_err + subl %ebx,%eax + jo diff_err + rorl $15,%eax + orl $917504,%eax + movl %eax,%ebx +.end + +.inline fast_op_idifference,4 + + movl 0(%esp),%eax + roll $15,%ebx + subb $7,%bl + jne idiff_err + roll $15,%eax + subb $7,%al + jne idiff_err + subl %ebx,%eax + jo idiff_err + rorl $15,%eax + orl $917504,%eax + movl %eax,%ebx +.end + + +.inline fast_op_idifferencen,4 + + movl 0(%esp),%eax + roll $15,%eax + roll $15,%ebx + subb $7,%bl + jne idiffn_err + subl %eax,%ebx + jo idiffn_err + rorl $15,%ebx + orl $917504,%ebx +.end + + +/* + *************************************************************** + PLUS VERSIONS sp@ + sp@(4) i.e. (tos-1) + (tos) + *************************************************************** +*/ + + +.inline fast_op_plus,4 + movl 0(%esp),%eax + roll $15,%ebx + subb $7,%bl + jne plus_err + roll $15,%eax + subb $7,%al + jne plus_err + addl %ebx,%eax + jo plus_err + rorl $15,%eax + orl $917504,%eax + movl %eax,%ebx +.end + +.inline fast_op_iplus,4 + movl 0(%esp),%eax + roll $15,%ebx + subb $7,%bl + jne iplus_err + roll $15,%eax + subb $7,%al + jne iplus_err + addl %ebx,%eax + jo iplus_err + rorl $15,%eax + orl $917504,%eax + movl %eax,%ebx +.end + +.inline fast_op_iplusn,4 + + movl 0(%esp),%eax + roll $15,%eax + roll $15,%ebx + subb $7,%bl + jne iplusn_err + addl %ebx,%eax + jo iplusn_err + rorl $15,%eax + orl $917504,%eax + movl %eax,%ebx +.end + + + +.inline fast_op_logor,4 + movl 0(%esp),%eax + roll $15,%ebx + cmpb $7,%bl + jne logor_err + roll $15,%eax + cmpb $7,%al + jne logor_err + orl %eax,%ebx + rorl $15,%ebx +.end + + +.inline fast_op_logand,4 + movl 0(%esp),%eax + roll $15,%ebx + cmpb $7,%bl + jne logand_err + roll $15,%eax + cmpb $7,%al + jne logand_err + andl %eax,%ebx + rorl $15,%ebx +.end + + +.inline fast_op_logxor,4 + movl 0(%esp),%eax + roll $15,%ebx + cmpb $7,%bl + jne logxor_err + roll $15,%eax + subb $7,%al + jne logxor_err + xorl %eax,%ebx + rorl $15,%ebx +.end + +.inline fast_op_lrsh8,0 + movl %ebx,%eax + roll $16,%eax + cmpw $0xe,%ax + jne lrsh8_err + shrw $8,%bx +.end + + +.inline fast_op_lrsh1,0 + movl %ebx,%eax + roll $16,%eax + cmpw $0xe,%ax + jne lrsh1_err + shrw $1,%bx +.end + + +.inline fast_op_llsh8,0 + cmpw $0x0FF,%bx + jg llsh8_err + movl %ebx,%eax + roll $16,%eax + cmpw $0xe,%eax + jne llsh8_err + shlw $8,%bx +.end + + +.inline fast_op_llsh1,0 + cmpw $0x07FFF,%bx + jg llsh1_err + movl %ebx,%eax + roll $16,%eax + cmpw $0xe,%ax + jne llsh1_err + shlw $1,%bx +.end + + +.inline fast_op_greaterp,4 + + movl 0(%esp),%eax + movl %ebx,%edx + roll $15,%edx + subb $7,%dl + jne greaterp_err + roll $15,%eax + subb $7,%al + jne greaterp_err + xorl %ebx,%ebx + cmpl %edx,%eax + jle .+7 + movl $76,%ebx +.end + + +.inline fast_op_igreaterp,4 + + movl 0(%esp),%eax + movl %ebx,%edx + roll $15,%edx + subb $7,%dl + jne igreaterp_err + roll $15,%eax + subb $7,%al + jne igreaterp_err + xorl %ebx,%ebx + cmpl %edx,%eax + jle .+7 + movl $76,%ebx +.end + + +.inline fast_op_addbase,4 + movl 0(%esp),%eax + roll $15,%ebx + subb $7,%bl + jne addbase_err + sarl $15,%ebx + andl $0xFFFFFF,%eax + addl %eax,%ebx +.end + + +.inline fast_op_loloc,0 + andl $0x0000FFFF,%ebx + orl $0x000E0000,%ebx +.end + + + +.inline fast_op_hiloc,0 + shrl $16,%ebx + andl $0x0000FFFF,%ebx + orl $0x000E0000,%ebx +.end + + +/// Unused, because 386i as peephole optimizer removes the shll. +.inline fast_op_vag2,4 + movl 0(%esp),%eax + shll $16,%ebx + movw %ax,%bx + rorl $16,%ebx +.end + + + +.inline _fast_op_listp,0 + movl d7,d1 + lsrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + movw a0@(0,d1:l:1),d1 + andw #0x7FF,d1 + cmpw #5,d1 + jeq 110$ + clrl d7 +110$: +.end + + +.inline _fast_op_ntypex,0 + lsrl #8,d7 + andl #0xFFFE,d7 + movl _MDStypetbl,a0 + movw a0@(0,d7:l:1),d7 + andw #0x7FF,d0 + orl #0x000E0000,d7 +.end + + +.inline _fast_op_typep,0 + movl d7,d0 + lsrl #8,d0 + andl #0xFFFE,d0 + movl _MDStypetbl,a0 + movw a0@(0,d0:l:1),d0 + andw #0x7FF,d0 + moveq #0,d1 + movb a5@,d1 + cmpw d1,d0 + beq 115$ + moveq #0,d7 +115$: +.end + +///////////////////////////////////////////////////////////////// +/// +/// F U N C T I O N C A L L S P E E D - U P S +/// +///////////////////////////////////////////////////////////////// + + +.inline fast_FN0,0 + cld // so we can use string instructions + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .LFN0ccode + movl %eax,-12(%ebp) + movl $0,-24(%ebp) + movl $3,-20(%ebp) + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.LFN0ccode: + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + leal 4(%edi),%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) +/ movl %ecx,%eax + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN0noarg1 + xorl %eax,%eax +/ movl %ecx,%edx + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax // for storing NILs. + jmp .FN0argls1 +.FN0arglp1: +/ movl $0,(%edi) +/ addl $4,%edi + stosl + incl -48(%ebp) +.FN0argls1: + cmpl $0,-48(%ebp) + jl .FN0arglp1 + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN0noarg1: +/ movl %edi,%eax + movl -44(%ebp),%eax +/ addl $4,%edi + orl $-2147483648,%eax +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) +/ pushl -40(%ebp) + movl -40(%ebp),%eax + rol $16,%eax +/ popl %ecx + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 +/ movl %ecx,%eax + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN0disp +/ movl $-1,-52(%ebp) +/ movl %edi,%eax + movl $-1,%eax +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN0disp +.FNxxalp: +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + decl -48(%ebp) +.FN0xalp: + decl -48(%ebp) + jl .FN0disp +/ movl %edi,%eax +/ movl -52(%ebp),%edx +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + jmp .FN0xalp +.FN0disp: + movzwl 4(%ecx),%eax + movl %ecx,%edx + addl $4,%edi + addl %eax,%edx + incl %edx + movl %edx,%esi + movl %ecx,MachineState+20 + leal -1(%esi),%eax + xorb $3,%al + xchg %edi,%esi / done using edit to store fast with. + movzbl (%eax),%eax + jmp *optable(,%eax,4) +.end + +.inline fast_FN1,0 + cld // for string instruction use + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN1ccode + movl %eax,-12(%ebp) + movl $1,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN1ccode: +/ movl -40(%ebp),%eax + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx +/ movl %eax,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) +/ movl %ecx,%eax + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi +/ movl %edi,%eax + movl %edi,MachineState + movl %edi,-48(%ebp) + movl MachineState+4,%eax + movl %edi,%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) +/ movl %ecx,%eax + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN1noarg + movl $1,%eax +/ movl %ecx,%edx + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN1lps +.FN1lp1: +/ movl $0,(%edi) +/ addl $4,%edi + stosl + incl -48(%ebp) +.FN1lps: + cmpl $0,-48(%ebp) + jl .FN1lp1 + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN1noarg: +/ movl %edi,%eax + movl -44(%ebp),%edx +/ addl $4,%edi + orl $-2147483648,%edx + movl %edx,(%edi) + addl $4,%edi + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp +/ movl $-1,-52(%ebp) +/ movl %edi,%eax +/ movl -52(%ebp),%edx + movl $-1,%eax +/ movl %eax,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + decl -48(%ebp) +.FN1xlp: + decl -48(%ebp) + jl .FN1disp +/ movl %edi,%eax +/ movl -52(%ebp),%edx +/ movl %edx,(%eax) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + jmp .FN1xlp + + // can be pointed to FN0disp when we do the ecx change here. +.FN1disp: + movzwl 4(%ecx),%eax + movl %ecx,%esi + addl $4,%edi + addl %eax,%esi + incl %esi +/ movl %edx,%esi + movl %ecx,MachineState+20 + leal -1(%esi),%eax + xchg %edi,%esi / done using edi to store fast with. + xorb $3,%al + movzbl (%eax),%eax + jmp *optable(,%eax,4) + +.end + +.inline fast_FN2,0 + cld // for string ops, so they push upward. + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN2ccode + movl %eax,-12(%ebp) + movl $2,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN2ccode: +/ movl -40(%ebp),%eax + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx +/ movl %eax,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) +/ movl %ecx,%eax + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $4,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) +/ movl %ecx,%eax + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN2noarg + movl $2,%eax +/ movl %ecx,%edx + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN2lps +.FN2lp: +/ movl $0,(%edi) +/ addl $4,%edi + stosl + incl -48(%ebp) +.FN2lps: + cmpl $0,-48(%ebp) + jl .FN2lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN2noarg: +/ movl %edi,%eax + movl -44(%ebp),%eax +/ addl $4,%edi + orl $-2147483648,%eax +/ movl %edx,(%eax) + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp +/ movl $-1,-52(%ebp) +/ movl %edi,%eax + movl $-1,%eax +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + decl -48(%ebp) +.FN2xlp: + decl -48(%ebp) + jl .FN1disp +/ movl %edi,%eax +/ movl -52(%ebp),%edx +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + jmp .FN2xlp +.end + + +.inline fast_FN3,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN3ccode + movl %eax,-12(%ebp) + movl $3,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN3ccode: + cld // so string ops work upward. +/ movl -40(%ebp),%eax + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx +/ movl %eax,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) +/ movl %ecx,%eax + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $8,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) +/ movl %ecx,%eax + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN3noarg + movl $3,%eax +/ movl %ecx,%edx + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN3lps +.FN3lp: +/ movl $0,(%edi) +/ addl $4,%edi + stosl + incl -48(%ebp) +.FN3lps: + cmpl $0,-48(%ebp) + jl .FN3lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN3noarg: +/ movl %edi,%eax + movl -44(%ebp),%eax +/ addl $4,%edi + orl $-2147483648,%eax +/ movl %edx,(%eax) + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp +/ movl $-1,-52(%ebp) +/ movl %edi,%eax + movl $-1,%eax +/ movl %edx,(%eax) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + decl -48(%ebp) +.FN3xlp: + decl -48(%ebp) + jl .FN1disp +/ movl %edi,%eax +/ movl -52(%ebp),%edx +/ movl %edx,(%edi) +/ addl $4,%edi +/ movl %edx,(%edi) +/ addl $4,%edi + stosl + stosl + jmp .FN3xlp +.end + + +.inline fast_FN4,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN4ccode + movl %eax,-12(%ebp) + movl $4,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN4ccode: + cld // so string ops work upward. + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $12,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN4noarg + movl $4,%eax + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN4lps +.FN4lp: + stosl + incl -48(%ebp) +.FN4lps: + cmpl $0,-48(%ebp) + jl .FN4lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN4noarg: + movl -44(%ebp),%eax + orl $-2147483648,%eax + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp + movl $-1,%eax + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp + stosl + stosl + decl -48(%ebp) +.FN4xlp: + decl -48(%ebp) + jl .FN1disp + stosl + stosl + jmp .FN4xlp +.end + + + +.inline fast_FN5,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN5ccode + movl %eax,-12(%ebp) + movl $5,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN5ccode: + cld // so string ops work upward. + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $16,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN5noarg + movl $5,%eax + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN5lps +.FN5lp: + stosl + incl -48(%ebp) +.FN5lps: + cmpl $0,-48(%ebp) + jl .FN5lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN5noarg: + movl -44(%ebp),%eax + orl $-2147483648,%eax + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp + movl $-1,%eax + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp + stosl + stosl + decl -48(%ebp) +.FN5xlp: + decl -48(%ebp) + jl .FN1disp + stosl + stosl + jmp .FN5xlp +.end + + + +.inline fast_FN6,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN6ccode + movl %eax,-12(%ebp) + movl $6,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN6ccode: + cld // so string ops work upward. + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $20,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN6noarg + movl $6,%eax + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN6lps +.FN6lp: + stosl + incl -48(%ebp) +.FN6lps: + cmpl $0,-48(%ebp) + jl .FN6lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN6noarg: + movl -44(%ebp),%eax + orl $-2147483648,%eax + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp + movl $-1,%eax + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp + stosl + stosl + decl -48(%ebp) +.FN6xlp: + decl -48(%ebp) + jl .FN1disp + stosl + stosl + jmp .FN6xlp +.end + + + +.inline fast_FN7,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN7ccode + movl %eax,-12(%ebp) + movl $7,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN7ccode: + cld // so string ops work upward. + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $24,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN7noarg + movl $7,%eax + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN7lps +.FN7lp: + stosl + incl -48(%ebp) +.FN7lps: + cmpl $0,-48(%ebp) + jl .FN7lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN7noarg: + movl -44(%ebp),%eax + orl $-2147483648,%eax + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp + movl $-1,%eax + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp + stosl + stosl + decl -48(%ebp) +.FN7xlp: + decl -48(%ebp) + jl .FN1disp + stosl + stosl + jmp .FN7xlp +.end + + + +.inline fast_FN8,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN8ccode + movl %eax,-12(%ebp) + movl $8,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN8ccode: + cld // so string ops work upward. + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $28,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN8noarg + movl $8,%eax + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN8lps +.FN8lp: + stosl + incl -48(%ebp) +.FN8lps: + cmpl $0,-48(%ebp) + jl .FN8lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN8noarg: + movl -44(%ebp),%eax + orl $-2147483648,%eax + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp + movl $-1,%eax + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp + stosl + stosl + decl -48(%ebp) +.FN8xlp: + decl -48(%ebp) + jl .FN1disp + stosl + stosl + jmp .FN8xlp +.end + + + +.inline fast_FN9,0 + leal 1(%edi),%edx + xorl $3,%edx + movzbl (%edx),%eax + leal 0(%edi),%edx + xorl $3,%edx + movb (%edx),%ah + movl %eax,%ecx + leal (,%eax,4),%eax + addl Defspace,%eax + movl (%eax),%edx + testl %edx,%edx + jl .FN9ccode + movl %eax,-12(%ebp) + movl $9,-24(%ebp) + movl $3,-20(%ebp) + movl %ecx,-16(%ebp) + movl $0,-28(%ebp) + jmp fn_common +.FN9ccode: + cld // so string ops work upward. + andl $16777215,%edx + movl %edx,-40(%ebp) + leal (%edx,%edx),%ecx + addl Lisp_world,%ecx + movl MachineState+4,%eax + leal -1(%edi),%edx + subl MachineState+20,%edx + leal 3(%edx),%edx + movw %dx,-12(%eax) + movzwl 2(%ecx),%eax + leal (%eax,%eax),%eax + movl MachineState+32,%edx + subl %eax,%edx + movl %edx,MachineState+28 + cmpl %edx,%esi + jg check_interrupt + xchg %edi,%esi + movl %edi,%eax + subl $32,%eax + movl %eax,MachineState + movl %eax,-48(%ebp) + movl MachineState+4,%eax + movl -48(%ebp),%edx + subl Stackspace,%edx + shrl $1,%edx + movl %edx,-44(%ebp) + movw %dx,-10(%eax) + movl %ebx,(%edi) + movw (%ecx),%dx + addl $4,%edi + testw %dx,%dx + jl .FN9noarg + movl $9,%eax + movswl (%ecx),%edx + subl %edx,%eax + movl %eax,-48(%ebp) + xorl %eax,%eax + jmp .FN9lps +.FN9lp: + stosl + incl -48(%ebp) +.FN9lps: + cmpl $0,-48(%ebp) + jl .FN9lp + movl -48(%ebp),%eax + leal (,%eax,4),%eax + subl %eax,%edi +.FN9noarg: + movl -44(%ebp),%eax + orl $-2147483648,%eax + stosl + movl MachineState+4,%eax + subl Stackspace,%eax + shrl $1,%eax + orl $-1073741824,%eax + movl %eax,(%edi) + movl -40(%ebp),%eax + rol $16,%eax + movl %eax,4(%edi) + addl $20,%edi + movl %edi,MachineState+4 + movswl 6(%ecx),%eax + movl %eax,-48(%ebp) + cmpl $0,-48(%ebp) + jl .FN1disp + movl $-1,%eax + stosl + stosl + cmpl $0,-48(%ebp) + jle .FN1disp + stosl + stosl + decl -48(%ebp) +.FN9xlp: + decl -48(%ebp) + jl .FN1disp + stosl + stosl + jmp .FN9xlp +.end + + + + + + +////////////////////////////////////////////////// +/// +/// assembler label definitions +/// +///////////////////////////////////////////////// + +.inline asm_label_check_interrupt,0 +check_interrupt: +.end +.inline asm_label_op_fn_common,0 +op_fn_common: +.end diff --git a/src/dspSPARC.il b/src/dspSPARC.il new file mode 100755 index 0000000..cb68303 --- /dev/null +++ b/src/dspSPARC.il @@ -0,0 +1,723 @@ +/* @(#) dspSPARC.il Version 1.1 (4/21/92). copyright Venue & Fuji Xerox */ +/* @(#) dispSPARC.il Version 2.7 (7/25/90). copyright Xerox & Fuji Xerox */ + + +/* change _name_scan for name table expanding '90/07/13 by osamu */ +/* Name table Expanded version */ +/* _name_scan2(entry, limit, names) inner loop of FVAR + %o0 entry even pointer to name table entry + %o1 limit oct_byte pointer beyond last name + %o2 names 32 bit (actually 24bit) atom number + %o4 low contents of entry +/**/ + +.inline _name_scan2,12 !(entry, limit, names) returns first+4 or 0 +loop: cmp %o0,%o1 !loop: if(entrynative interface */ + +.inline _asmcall,4 + jmp %o0 + nop + +.end + +/* + *************************************************************** + Arithmetic Opcode Helpers + *************************************************************** +*/ + +.inline _sub32,8 + subcc %o0,%o1,%o0 ! result = arg0 - arg1 + bvs diff_err + nop +.end + +.inline _isub32,8 + subcc %o0,%o1,%o0 ! result = arg0 - arg1 + bvs idiff_err + nop +.end + +.inline _sub32n,8 + subcc %o0,%o1,%o0 ! result = arg0 - arg1 + bvs diff_err2 + nop +.end + +.inline _mpy32,8 + ba mpy_err + nop +.end + +.inline _impy32,8 + ba impy_err + nop +.end + +.inline _quot32,8 + ba quot_err + nop +.end + +.inline _iquot32,8 + ba iquot_err + nop +.end + +.inline _rem32,8 + ba rem_err + nop +.end + +.inline _irem32,8 + ba irem_err + nop +.end + + +.inline _plus32,8 + addcc %o0,%o1,%o0 ! result = arg0 + arg1 + bvs plus_err + nop +.end + +.inline _iplus32,8 + addcc %o0,%o1,%o0 ! result = arg0 + arg1 + bvs iplus_err + nop +.end + +.inline _iplus32n,8 + addcc %o0,%o1,%o0 ! result = arg0 + arg1 + bvs iplusn_err + nop +.end + + +/* + *************************************************************** + Inline Assembly help for dispatcher. + *************************************************************** +*/ + + +/* Note: that the error exit of these routines may or may not need to + fix the tos pointer. The C code should decide when tos must + be fixed through the ifdef flats. +*/ + +/* SWAP halves of a register */ + +.inline _swapx,4 + sll %o0,16,%o1 + srl %o0,16,%o0 + or %o0,%o1,%o0 +.end + +/* + *************************************************************** + DIFFERENCE VERSIONS sp@ - sp@(4) i.e. (tos-1) - (tos) + *************************************************************** +*/ + +.inline _op_difference,8 ! working + srl %o1,17,%o2 ! r2 = type(arg1) + cmp %o2,7 ! ==smallp ? + bne diff_err ! else diff_err + srl %o0,17,%o2 ! r2 = type(arg0) + cmp %o2,7 + bne diff_err + sll %o0,15,%o2 ! preserve arg0 + sll %o1,15,%o1 + subcc %o2,%o1,%o0 + bvs diff_err + srl %o0,15,%o0 + sethi %hi(0x000E0000),%o2 + or %o2, %o0,%o0 +.end + +/* + *************************************************************** + PLUS VERSIONS sp@ + sp@(4) i.e. (tos-1) + (tos) + *************************************************************** +*/ + + +.inline _op_plus,8 + srl %o1,17,%o2 ! r2 = type(arg1) + cmp %o2,7 ! ==smallp ? + bne plus_err ! else diff_err + srl %o0,17,%o2 ! r2 = type(arg0) + cmp %o2,7 + bne plus_err + sll %o0,15,%o2 ! preserve arg0 + sll %o1,15,%o1 + addcc %o2,%o1,%o0 + bvs plus_err + srl %o0,15,%o0 + sethi %hi(0x000E0000),%o2 + or %o2, %o0,%o0 +.end + +/* + *************************************************************** + LOGAND VERSIONS sp@ & sp@(4) i.e. (tos-1) & (tos) + *************************************************************** +*/ + + +.inline _op_logand,8 + srl %o1,17,%o2 ! r2 = type(arg1) + cmp %o2,7 ! ==smallp ? + bne logand_err ! else diff_err + srl %o0,17,%o2 ! r2 = type(arg0) + cmp %o2,7 + bne logand_err + and %o0,%o1,%o0 +.end + +/* + *************************************************************** + LOGOR VERSIONS sp@ | sp@(4) i.e. (tos-1) | (tos) + *************************************************************** +*/ + +.inline _op_logor,8 + srl %o1,17,%o2 ! r2 = type(arg1) + cmp %o2,7 ! ==smallp ? + bne logor_err ! else diff_err + srl %o0,17,%o2 ! r2 = type(arg0) + cmp %o2,7 + bne logor_err + or %o0,%o1,%o0 +.end + +/* + *************************************************************** + LOGXOR VERSIONS sp@ | sp@(4) i.e. (tos-1) | (tos) + *************************************************************** +*/ + +.inline _op_logxor,8 + srl %o1,17,%o2 ! r2 = type(arg1) + cmp %o2,7 ! ==smallp ? + bne logxor_err ! else diff_err + srl %o0,17,%o2 ! r2 = type(arg0) + cmp %o2,7 + bne logxor_err + xor %o0,%o1,%o0 + sethi %hi(0x000E0000),%o1 + or %o0,%o1,%o0 +.end + +/* + *************************************************************** + SHIFT OPCODE VERSIONS + *************************************************************** +*/ + + +.inline _op_lrsh8,4 + srl %o0,16,%o2 ! r2 = type(arg0) + cmp %o2,0xE + bne lrsh8_err + sethi %hi(0xE0E0000),%o1 !E0000 xor E000000 + xor %o0,%o1,%o0 + srl %o0,8,%o0 +.end + + +/* inline LRSH1 */ +/* sp@ >> 1 +*/ + +.inline _op_lrsh1,4 + srl %o0,16,%o2 + cmp %o2,0xE + bne lrsh1_err + srl %o0,11,%o0 + sethi %hi(0x00090000),%o1 !E0000 xor 70000 + or %o0,%o1,%o0 +.end + + +.inline _op_llsh8,4 + srl %o0,8,%o2 ! (arg0>>8)==0xE00? + cmp %o2,0xE00 + bne llsh8_err + sll %o0,8,%o0 + sethi %hi(0xE0E0000),%o1 !E0000 xor E000000 + xor %o0,%o1,%o0 +.end + + +.inline _op_llsh1,4 + srl %o0,15,%o2 ! (arg0>>15)==0x1C + cmp %o2,0x1C + bne llsh1_err + sll %o0,1,%o0 + sethi %hi(0x00120000),%o1 !E0000 xor 1C0000 + xor %o0,%o1,%o0 +.end + +/* + *************************************************************** + GREATERP OPCODE VERSIONS + *************************************************************** +*/ + +.inline _op_greaterp,8 + srl %o1,17,%o2 ! \ + cmp %o2,7 ! > smallp(arg1) ? + bne greaterp_err ! / + sll %o0,15,%o2 ! preserve arg0 + srl %o0,17,%o0 ! return NIL + cmp %o2,7 ! > smallp(arg0) ? + bne greaterp_err ! / + cmp %o2,%o1 ! arg0 - arg1 ?? + bg,a 9f ! if greater, return T + or %o0,76,%o0 +9: +.end + +/* + *************************************************************** + POINTER OPCODE VERSIONS + *************************************************************** +*/ + +.inline _addbase,8 + srl %o1,17,%o2 ! \ + cmp %o2,7 ! > smallp(arg1) ? + bne addbase_err ! / + sll %o1,15,%o1 + sra %o1,15,%o1 + add %o1,%o0,%o0 + sethi %hi(0xFFFFFF),%o1 !is this necessary ?? + and %o0,%o1,%o0 +.end + + +.inline _loloc,4 + sll %o0,16,%o0 + srl %o0,16,%o0 + sethi %hi(0xE0000),%o1 + or %o0,%o1,%o0 +.end + + +.inline _hiloc,4 + srl %o0,16,%o0 + sethi %hi(0xE0000),%o1 + or %o0,%o1,%o0 +.end + +/* this really doesn't need to check */ +.inline _vag2,8 + sll %o0,16,%o0 + sll %o1,16,%o1 + srl %o1,16,%o1 + or %o0,%o1,%o0 +.end + +/* + *************************************************************** + TYPE OPCODE VERSIONS + *************************************************************** +*/ +/* TYPE INLINE OPCODES */ + +.inline _listp,4 + movl a7@+,d0 + movl d0,d1 + lsrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + movw a0@(0,d1:l:1),d1 + andw #0x7FF,d1 + cmpw #5,d1 + jeq _xwzq5 + clrl d0 +_xwzq5: +.end + +.inline _fast_op_listp,0 + movl d7,d1 + lsrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + movw a0@(0,d1:l:1),d1 + andw #0x7FF,d1 + cmpw #5,d1 + jeq _xwzq6 + clrl d7 +_xwzq6: +.end + + +.inline _ntypex,4 + movl a7@+,d1 + lsrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + movl #0x000E0000,d0 + movw a0@(0,d1:l:1),d0 + andw #0x7FF,d0 +.end + +.inline _fast_op_ntypex,0 + lsrl #8,d7 + andl #0xFFFE,d7 + movl _MDStypetbl,a0 + movw a0@(0,d7:l:1),d7 + andw #0x7FF,d0 + orl #0x000E0000,d7 +.end + + +.inline _typep,8 + movl a7@+,d1 + movl a7@+,d2 + movl d1,d0 + lsrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + movw a0@(0,d1:l:1),d1 + andw #0x7FF,d1 + cmpl d2,d1 + beq 115$ + moveq #0,d0 +115$: +.end + +.inline _fast_op_typep,0 + movl d7,d0 + lsrl #8,d0 + andl #0xFFFE,d0 + movl _MDStypetbl,a0 + movw a0@(0,d0:l:1),d0 + andw #0x7FF,d0 + moveq #0,d1 + movb a5@(1),d1 + cmpw d1,d0 + beq 115$ + moveq #0,d7 +115$: +.end + + +/* TYPE INLINE FUNCTIONS */ + +.inline _GetTypeNumber,4 + movl a7@+,d1 + asrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + moveq #00,d0 + movw a0@(0,d1:l:1),d0 + andw #0x7FF,d0 +.end + +.inline _GetTypeEntry,4 + movl a7@+,d1 + asrl #8,d1 + andl #0xFFFE,d1 + movl _MDStypetbl,a0 + movw a0@(0,d1:l:1),d0 +.end + + + + +.inline _opreturn,0 + + movl _CurrentFX,a1 |returnFX = a1 + movl #65536,d0 + movw a1@(2),d0 |returnFX->alink + lsrl #1,d0 |low bit to carry + jcs ni |jump if slow return + movl a2,a3 |CSTKPTR = IVAR + movl _Lisp_world,a0 |PVar= + lea a0@(0,d0:l:4),a0 + movl a0,_PVar + moveq #20,d1 + subl d1,a0 |returnFX = a0 + movl a0,_CurrentFX |CURRENTFX = returnFX + movl #65536,d0 + movw a0@(-2),d0 |returnFX -1 + movl _Lisp_world,a1 + lea a1@(0,d0:l:2),a2 |IVAR = a2 + moveq #0,d0 + movb a0@(7),d0 |returnFX->hi2fnheader + swap d0 + movw a0@(4),d0 |returnFX->lofnheader + movl _Lisp_world,a1 + lea a1@(0,d0:l:2),a1 + movl a1,_FuncObj |FuncObj = a1 + subl a5,a5 + movw a0@(10),a5 |returnFX->pc a5 + lea a1@(0,a5:l:1),a5 | a5 + FuncObj + movb a5@,d6 + movl a4@(0,d6:l:4),a0 + jmp a0@ + + +.end + + + +.inline _fn3,0 + + moveq #0,d0 + movw a5@(1),d0 + movl _Defspace,a0 + lea a0@(0,d0:l:4),a1 |defcell = a1 + movl a1,d4 |save defcell in d4 +| movl a1,a6@(-20) + btst #7,a1@ + jeq ni + movl a1@,d0 |defcell->defpointer + andl #16777215,d0 + movl _Lisp_world,a0 + lea a0@(0,d0:l:2),a1 |LOCFNCELL + movl a1,d2 |save LOCFNCELL in a1, d2 +| movl a1,a6@(-12) + moveq #0,d0 + movw a1@,d0 |LOCFNCELL->stkmin + lea a3@(4,d0:l:2),a0 +| addql #4,a0 + cmpl _StkLimO,a0 + jcc ni |stack overflow + lea a3@(-8),a1 |CSTKPTR-(x<<1)+2 + subl _Lisp_world,a1 + movl a1,d3 + lsrl #1,d3 +| movl d3,a1 + andl #65535,d3 |NEXTBLOCK = d3 +| movl d0,d3 + movl _CurrentFX,a1 |a1 = _CurrentFX + movw d3,a1@(8) |CURRENTFX->nextblock = + movl d3,d0 + orl #65536,d0 + movl _Lisp_world,a0 + lea a0@(0,d0:l:2),a2 |IVAR = +| movl _CurrentFX,a0 + movl a5,d0 + subl _FuncObj,d0 + addql #3,d0 + movw d0,a1@(10) |CURRENTFX->pc + movl d7,a3@+ |CPushCStack + movl d2,a1 |get LOCFNCELL = a1 + movw a1@(2),d0 + tstw d0 + jlt fn3noargs |no function arguments +| movw a0@(2),d0 + extl d0 + moveq #2,d1 + subl d0,d1 +| movl d1,d4 + jra fn3ly16 +fn3ly17: + clrl a3@+ + addql #1,d1 +fn3ly16: + tstl d1 + jlt fn3ly17 +| movl d4,d0 + asll #2,d1 + subl d1,a3 +fn3noargs: + movl d3,d0 |CPush(BF_MARK32 | NEXTBLOCK) + orl #-2147483648,d0 + movl d0,a3@+ + movl a3,_CurrentFX |CURRENTFX = + movl _PVar,d0 +| subl _Lisp_world,d0 + subl a0,d0 + lsrl #1,d0 + andl #65535,d0 + orl #-1073741824,d0 + movl d0,a3@ |*CSTKPTR=FX_MARK etc + movl d4,a0 |defcell = a0 + movw a0@(2),a3@(4) |->lofnheader = ->defpointer +| movl a6@(-20),a0 +| movl a0@,d0 +| andl #16777215,d0 +| movw d0,a3@(4) +| movl d4,a0 +| movl a6@(-20),a0 + movb a0@(1),a3@(7) |hi2fnheader = *((defcell)+1) + lea a3@(20),a3 + movl a3,_PVar |PVar = CSTKPTR +| movl d2,a0 + movw a1@(4),d0 ||LOCFNCELL->pv + extl d0 + addql #1,d0 +| movl d0,a6@(-8) + moveq #-1,d1 + jra fn3ly18 +fn3ly19: + movl d1,a3@+ + movl d1,a3@+ + subql #1,d0 +fn3ly18: + tstl d0 + jgt fn3ly19 + addqw #4,a3 | CSTKPTR += 2 +| movl d2,a0 +| moveq #0,d0 + subl a5,a5 + movw a1@(6),a5 |LOCFNCELL->startpc + addl a1,a5 +| movl d0,a5 + movl a1,_FuncObj + + +.end + + +|.inline _min,8 +| cmp %o0,%o1 +| ble,a $10 +| mov %o1,%o0 +|$10 +|.end + +|.inline _max,8 +| cmp %o0,%o1 +| bge,a $10 +| mov %o1,%o0 +|$10 +|.end diff --git a/src/dsphack.lex b/src/dsphack.lex new file mode 100755 index 0000000..2ac3573 --- /dev/null +++ b/src/dsphack.lex @@ -0,0 +1,62 @@ +/* @(#) disphack.lex Version 1.5 (11/2/88). copyright envos & Fuji Xerox */ + +REG "%"[oilg][0-9] +LABEL L[0-9]+ +COMPUTE "\tcall\t_compute_dispatch_table,0\n nop\n\tmov\t%o0," +DISPATCH "\tmov\t"{REG}",%o0\n\tcall\t_fast_dispatcher,2\n\tnop\n" +HEXD 0x[0-3] +ADDX "\tadd\t"{REG}","{HEXD}","{REG} +LDUB "\tldub\t["{REG}"],"{REG} +LDUBm1 "\tldub\t["{REG}"+-0x1],%o1" +MOV "\tmov\t"{REG}",%o1" + +%% + extern char *dispatch_label; + + +{COMPUTE} printf(" set %s,", dispatch_label); + +{ADDX}\n{LDUBm1}\n{DISPATCH} { + if ( memcmp(yytext + 5, yytext + 13, 3) + || memcmp(yytext + 5, yytext + 24, 3)) {REJECT}; + + printf(" ldub [%.3s+%.3s+-0x1],%%o1\n",yytext+5, yytext+9); + printf(" sll %%o1,2,%%o1\n"); + printf(" ld [%%o1+%.3s],%%o1\n",yytext+43); + printf(" jmp %%o1\n"); + printf("%.16s\n", yytext); +} + + + +{DISPATCH} { + printf(" sll %%o1,2,%%o1\n"); + printf(" ld [%%o1+%%%.2s],%%o1\n",yytext + 6); + printf(" jmp %%o1\n"); + printf(" nop\n"); +} + +{ADDX}\n{LDUB} { + if ( !memcmp(yytext + 5, yytext + 13, 3) + && !memcmp(yytext + 5, yytext + 24, 3) + && memcmp(yytext + 5, yytext + 29, 3)) { + printf(" ldub [%.3s+%.3s],%.3s\n%.16s\n", + yytext+5,yytext+9,yytext+29,yytext); + } else + printf("%s", yytext); +} + + +{LDUB}\n\tcmp\t{REG}",255\n\tbgu\t"{LABEL}\n\t\sll\t{REG}",2,"{REG}\n\tset\t{LABEL}"," { + if (memcmp(yytext+yyleng-strlen(dispatch_label)-1, + dispatch_label, + strlen(dispatch_label))) { + fprintf(stderr, "Label in dispatch changed. Edit disphack.lex"); + fprintf(stderr, " and change '%s' to label", dispatch_label); + fprintf(stderr, " in last line of \n\n%s\n\n and retry!\n", yytext); + exit(-1); + } else if (memcmp(yytext + 12, yytext + 21, 3)) { + fprintf(stderr, "Odd sequence %s\n", yytext); + }; + REJECT; +}; diff --git a/src/dspif.c b/src/dspif.c new file mode 100755 index 0000000..1d852a0 --- /dev/null +++ b/src/dspif.c @@ -0,0 +1,165 @@ +/* $Id: dspif.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dspif.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright (C) Venue"; +/* This is the display interface */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, */ +/* 1995, 1999 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +#include +#include "lispemul.h" +#include "dbprint.h" +#include "devif.h" + +DspInterfaceRec _curdsp, _coldsp; + +DspInterface currentdsp = &_curdsp; +DspInterface colordsp = &_coldsp; + +#ifdef XWINDOW +extern int LispDisplayRequestedWidth; +extern int LispDisplayRequestedHeight; + +extern DspInterface X_init( DspInterface dsp, + char *lispbitmap, + int width_hint, + int height_hint, + int depth_hint ); +#endif /* XWINDOW */ + +#ifdef DOS +extern int dosdisplaymode; +#endif /* DOS */ + +make_dsp_instance(DspInterface dsp, char *lispbitmap, int width_hint, int height_hint, int depth_hint) +{ +#ifdef DOS + + TPRINT(("Enter make_dsp_instance, dosdisplaymode is: %d\n", dosdisplaymode)); + + if (depth_hint == 0) depth_hint = 1; + + switch(dosdisplaymode) { + case 1: + VGA_init( dsp ,0, 0, 0, depth_hint ); + break; + case 0x102: + case 0x104: + VESA_init( dsp ,0, 0, 0, depth_hint ); + break; + default: + if (VESA_p()) { + VESA_init( dsp ,0, 0, 0, depth_hint ); + } else if (VGA_p()){ + VGA_init( dsp ,0, 0, 0, depth_hint ); + } else { /* Can't set *ANY* video mode! */ + (void)fprintf(stderr, "No portable graphics mode supported by this host.\n"); + (void)fprintf(stderr, "\n-Expected VESA or VGA.\n"); + exit(1); + } + break; + } + +#elif XWINDOW + /* lispbitmap is 0 when we call X_init the first time. */ + if ( X_init( dsp, 0, LispDisplayRequestedWidth, + LispDisplayRequestedHeight, depth_hint ) == NULL) { + fprintf(stderr, "Can't open display."); + exit(-1); + } +#endif /* DOS | XWINDOW */ +} /* Now we know the Maxi-MooM capabillities of the hardware. */ + +#ifdef DOS +VESA_p() +{ + /* Magic. Do a vesa call to determine the current mode. */ + return(VESA_call( 3 , 0 )); +} + +VGA_p() +{ + return( TRUE ); +} +#endif /* DOS */ + +/*********************************************************************/ +/* */ +/* G e n e r i c R e t u r n T */ +/* */ +/* Utility function that just returns T */ +/* */ +/*********************************************************************/ +unsigned long +GenericReturnT(void) +{ + return(T); +} + +void GenericPanic(DspInterface dsp) +{ + TPRINT(("Enter GenericPanic\n")); + fprintf( stderr, "Panic! Call to uninitialized display slot!" ); + exit(0); +} + + +SwitchDisplay(LispPTR display) +{ + DspInterface tmp; /* Switch-a-roo! */ + + TPRINT(("Enter SwitchDisplay\n")); + tmp = currentdsp; + currentdsp = colordsp; + colordsp = tmp; + TPRINT(("Exit SwitchDisplay\n")); + return( display ); +} + +describedsp(DspInterface dsp) +{ + if ( dsp == 0 ){ + printf("describedsp: Not a dsp!\n"); + return; + } + if ( dsp == &_curdsp ) + printf("dsp is B/W display\n"); + else + printf("dsp is COLOR display\n"); + + printf("\n"); + printf("width= %d\n", dsp->Display.width); + printf("height= %d\n", dsp->Display.height); + printf("bitsperpixel= %d\n", dsp->bitsperpixel); + printf("colors= %d\n", dsp->colors); + printf("graphicsmode= %d\n", dsp->graphicsmode); + printf("numberofbanks= %d\n", dsp->numberofbanks); +#ifdef DOS + printf("BytesPerLine= %d\n", dsp->BytesPerLine); + printf("DisplayStartAddr= %d\n", dsp->DisplayStartAddr); +#endif /* DOS */ + printf("bitblt_to_screen= %d\n", dsp->bitblt_to_screen); + printf("cleardisplay= %d\n", dsp->cleardisplay); +#ifdef DOS + printf("mouse_vissible= %d\n", dsp->mouse_vissible); + printf("mouse_invissible= %d\n", dsp->mouse_invissible); + printf("\n"); +#endif /* DOS */ + fflush(stdout); +} diff --git a/src/dspsubrs.c b/src/dspsubrs.c new file mode 100755 index 0000000..1b8834f --- /dev/null +++ b/src/dspsubrs.c @@ -0,0 +1,328 @@ +/* $Id: dspsubrs.c,v 1.3 2001/12/26 22:17:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: dspsubrs.c,v 1.3 2001/12/26 22:17:02 sybalsky Exp $ Copyright (C) Venue"; +/*** ADOPTED NEW VERSION ***/ + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-2000 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#ifndef NOPIXRECT +#include +#include +#endif /* NOPIXRECT */ + + +#include "lispemul.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "display.h" +#include "arith.h" +extern int DebugDSP; +extern int displaywidth, displayheight; + +#ifdef XWINDOW +extern int Mouse_Included; +#endif /* XWINDOW */ + + +/**************************************************** + * + * DSP_dspbout() entry of SUBRCALL 9 1 + * called from (DSPBOUT X) + * + ****************************************************/ + +DSP_dspbout( args ) +LispPTR *args; /* args[0] : charcode */ + { + putc( (args[0] & 0xFFFF) & 0x7f, BCPLDISPLAY ); + } + + + +/**************************************************** + * + * DSP_showdisplay() entry of SUBRCALL 19 2 + * called from (SHOWDISPLAY BASE RASTERWIDTH) + * + ****************************************************/ + +extern int DisplayInitialized ; + +DSP_showdisplay( args ) +LispPTR *args; +{ + DisplayInitialized = 1; +} + + + +/**************************************************** + * + * DSP_VideoColor() entry of SUBRCALL 66 1 + * called from (VIDEOCLOR BLACKFLG) + * + ****************************************************/ + +DSP_VideoColor( args ) +LispPTR *args; /* args[0] : black flag */ +{ + int invert; +#ifdef SUNDISPLAY + return NIL; +#endif /* SUNDISPLAY */ + + +#ifdef XWINDOW + invert = args[0] & 0xFFFF; + lisp_Xvideocolor( invert ); + if( invert ) + return ATOM_T; + else + return NIL; +#endif /* XWINDOW */ + +} + + + +extern struct cursor CurrentCursor; +extern int LispWindowFd; + +extern int errno; + + +/**************************************************** + * + * DSP_Cursor() entry of SUBRCALL 64 2 + * called from \HARDCURSORUP etc. + * + ****************************************************/ +DSP_Cursor( args , argnum) +LispPTR *args; int argnum; + /* args[0] : hot sopt X + * args[1] : hot spot Y + */ +{ + extern int ScreenLocked; + extern DLword *EmCursorX68K,*EmCursorY68K; + extern int LastCursorX,LastCursorY; + static int Init=T; + +#ifdef SUNDISPLAY + if (argnum == 2) { + CurrentCursor.cur_xhot=args[0] & 0xffff; + CurrentCursor.cur_yhot=args[1] & 0xffff; + }; + +#ifdef OLD_CURSOR + win_setcursor( LispWindowFd, &CurrentCursor ); +#else +#ifndef INIT + ScreenLocked =T; + if(!Init){ + taking_mouse_down(); + taking_mouse_up(*EmCursorX68K,*EmCursorY68K); + } + else{ + Init=NIL; + cursor_hidden_bitmap(0,0); + taking_mouse_up(0,0); + *EmCursorX68K=LastCursorX=0; + *EmCursorY68K=LastCursorY=0; + } + + ScreenLocked=NIL; +#else +/* Init specific lde only */ + ScreenLocked =T; + if(!Init){ + taking_mouse_down(); + taking_mouse_up(0,0); + } + else{ + Init=NIL; + cursor_hidden_bitmap(0,0); + taking_mouse_up(0,0); + } + + ScreenLocked=NIL; +#endif /* INIT */ + +#endif +#endif /* SUNDISPLAY */ + + +#ifdef XWINDOW + /* For X-Windows, set the cursor the the given location. */ + Set_XCursor( (int)(args[0]&0xFFFF), (int)(args[1]&0xFFFF) ); +#endif /* XWINDOW */ + + +} + + + +/**************************************************** + * + * DSP_SetMousePos() entry of SUBRCALL 65 2 + * called from macro \SETMOUSEXY etc. + * + ****************************************************/ + +DSP_SetMousePos( args ) +register LispPTR *args; /* args[0] : X pos + * args[1] : Y pos + */ +{ +#ifdef SUNDISPLAY +#ifdef OLD_CURSOR + register int x ,y; + x=GetSmalldata(args[0]); + y=GetSmalldata(args[1]); /* debug */ + win_setmouseposition(LispWindowFd, GetSmalldata(args[0]), + GetSmalldata(args[1])); +#else + extern int ScreenLocked; + extern DLword *EmCursorX68K,*EmCursorY68K,*EmMouseX68K,*EmMouseY68K; + register int x ,y; + ScreenLocked=T; + x=GetSmalldata(args[0]); + y=GetSmalldata(args[1]); + /* for Suntool's invisible cursor */ + win_setmouseposition(LispWindowFd, x,y); + /* for REAL cursor image */ + taking_mouse_down(); + taking_mouse_up(x,y); + +#ifndef INIT + *EmMouseX68K=x; + *EmMouseY68K=y; +#endif + ScreenLocked=NIL; +#endif +#endif /* SUNDISPLAY */ + + +#ifdef XWINDOW + if( Mouse_Included ) + set_Xmouseposition( (int)(GetSmalldata(args[0])) + , (int)(GetSmalldata(args[1])) ); +#endif /* XWINDOW */ + +} + +/**************************************************** + * + * DSP_ScreenWidth() entry of SUBRCALL 67 0 + * called from \Katana.DisplayWidth. + * + ****************************************************/ +DSP_ScreenWidth( args ) +LispPTR *args; +{ + return( S_POSITIVE | (0xFFFF & displaywidth) ); +} + +/**************************************************** + * + * DSP_ScreenHight() entry of SUBRCALL 68 0 + * called from \Katana.DisplayHeight. + * + ****************************************************/ +DSP_ScreenHight( args ) +LispPTR *args; +{ + return( S_POSITIVE | (0xFFFF & displayheight) ); +} + +/**************************************************** + * + * flip_cursor() + * + ****************************************************/ + +extern DLword *EmCursorBitMap68K; +extern int for_makeinit; + +#ifdef XWINDOW +extern int Current_Hot_X, Current_Hot_Y; +#endif /* XWINDOW */ + +flip_cursor() + { + register DLword *word; + register int cnt; + extern int ScreenLocked; + extern DLword *EmCursorX68K,*EmCursorY68K; + + word = EmCursorBitMap68K; + +#ifdef INIT + + /* since this is called frequently, and you don't want to have + to build a different LDE to run the 2 parts of a Loadup, there is + an ifdef AND a test. This way we don't generate + extra code for anybody elses building an LDE + except those who want to try building loadups. */ + + if (!for_makeinit){ + for (cnt = CURSORHEIGHT;(cnt--);) + { + GETWORD(word++) ^= 0xFFFF; + }; + }; + +#else + + for (cnt = CURSORHEIGHT;(cnt--);) + { + GETWORD(word++) ^= 0xFFFF; + }; + +#endif + +#ifdef SUNDISPLAY +#ifdef OLD_CURSOR + + win_setcursor( LispWindowFd, &CurrentCursor ); +#else + ScreenLocked=T; + taking_mouse_down(); +#ifndef INIT + taking_mouse_up(*EmCursorX68K,*EmCursorY68K); +#else + if(!for_makeinit) + taking_mouse_up(*EmCursorX68K,*EmCursorY68K); + else + taking_mouse_up(0,0); +#endif /* INIT */ + + ScreenLocked=NIL; +#endif +#endif /* SUNDISPLAY */ + + +#ifdef XWINDOW + /* JDS 011213: 15- cur y, as function does same! */ + Set_XCursor( Current_Hot_X, 15-Current_Hot_Y ); +#endif /* XWINDOW */ + +} diff --git a/src/ejlisp.c b/src/ejlisp.c new file mode 100755 index 0000000..ad1b411 --- /dev/null +++ b/src/ejlisp.c @@ -0,0 +1,974 @@ +/* $Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "arith.h" +#include "locfile.h" + +#ifdef FPO +#define WCHAR_T +#endif + +#include "jllib.h" +#include "jslib.h" + +#include "timeout.h" + +#define CHAR_MAXLEN 512 +#define TABLE_MAX 100 +#define CHAR_SIZE CHAR_MAXLEN*(sizeof(char)/sizeof(int)) + +#define LStringToCString(Lisp, C, MaxLen ,Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int i,j; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ + Len = min(MaxLen, arrayp->totalsize); \ + \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0;ibase))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(i=0;itypenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(id=0;idfillpointer = Len; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(id=0;idfillpointer = Len; \ + break; \ + \ + default: \ + error("CStringToLString can not handle\n"); \ + } \ + } + +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + \ + base = (int *) Addr68k_from_LADDR((unsigned int)Lisp); \ + *base = C; \ + } + +#define ZeroFix(C) \ + { \ + int k,j; \ + \ + if (C[0] == 0 && C[1] != 0) { \ + for (k = j = 0 ; C[k] != 0 || C[k+1] != 0;k++) { \ + if (C[k] != 0) C[j++] = C[k]; \ + } \ + C[j] = 0; \ + } \ + } + +#define EJLISP_SETJMP(x) \ + { \ + if (setjmp(jmpbuf) != 0) { \ + ejlisp_buf = NULL; \ + return(x); \ + } \ + } + +typedef struct first_array { + unsigned int orig : 1 ; + unsigned int nil1 : 1 ; + unsigned int rdonly : 1 ; + unsigned int nil2 : 1 ; + unsigned int type : 4 ; + unsigned int base : 24 ; + unsigned short length; + unsigned short offset ; } FirstArray; + +struct wnn_buf *ejlisp_buf = NULL; +struct wnn_jdata *ejlisp_jdp; +int ejlisp_jdp_num; +int ejlisp_kouho_max; +int ejlisp_kouho_num; +int ejlisp_kouho_next; + +#define WNN_OPEN 1 +#define WNN_CLOSE 2 +#define WNN_CONV 3 +#define WNN_RECONV 4 +#define WNN_SELECT_BUNSETSU 5 +#define WNN_GET_KOUHO 6 +#define WNN_SELECT_KOUHO 7 +#define WNN_GET_YOMI 8 +#define WNN_CONV_END 9 +#define WNN_ADD_USERDIC 10 +#define WNN_DEL_USERDIC 11 +#define WNN_SEARCH_USERDIC 12 +#define WNN_GET_USERDIC 13 +#define WNN_GET_USERDIC_NAME 14 +#define WNN_BUNSETSU_KANJI 15 +#define WNN_BUNSETSU_YOMI 16 + +ejlisp(args) + int args[]; +{ + int result; + int i,j,length; + + int c_number1, c_number2, c_number3, c_number4; + int c_number5[TABLE_MAX], c_number6[TABLE_MAX]; + + unsigned char c_char1[(CHAR_MAXLEN+1)*2]; + unsigned char c_char2[(CHAR_MAXLEN+1)*2]; + unsigned char c_char3[TABLE_MAX][(CHAR_MAXLEN+1)*2]; + unsigned char tmp[(CHAR_MAXLEN+1)*2]; + + FirstArray *a_ptr; + unsigned int *base1; + unsigned int *base2; + unsigned int *base3; + + N_GETNUMBER(args[0], c_number1, ERROR); + +#ifdef DEBUG + printf("ejlisp start\n"); + printf("case = %d\n", c_number1); +#endif + + switch (c_number1) { + case WNN_OPEN: + LStringToCString(args[1], c_char1, CHAR_MAXLEN,length); + N_GETNUMBER(args[2], c_number1, ERROR); + LStringToCString(args[3], c_char2, CHAR_MAXLEN,length); + result = ejlisp_open(c_char1, c_number1, c_char2); + break; + + case WNN_CLOSE: + result = ejlisp_close(); + break; + + case WNN_CONV: + LStringToCString(args[1], tmp, CHAR_MAXLEN, length); + if (strlen(tmp) == length) { + for (i = length - 1 ; i >= 0 ; i--) { + tmp[i*2+1] = tmp[i]; + tmp[i*2] = 0; + } + tmp[length*2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char1); + for (i = length; i < (CHAR_MAXLEN+1)*2; i++) + c_char1[i] = NULL; + + result = ejlisp_conv(c_char1, c_char2, &c_number1, &c_number2); + if (result != 0) break; + + ZeroFix(c_char2); + length = EUCtoFatcharNS(c_char2, tmp); + CStringToLString(tmp, args[2], length); + + IntToFixp(c_number1, args[3]); + IntToFixp(c_number2, args[4]); + + break; + + case WNN_RECONV: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); + + result = ejlisp_reconv(c_number1, c_number2, c_char1, &c_number3, &c_number4); + if (result != 0) break; + + ZeroFix(c_char1); + length = EUCtoFatcharNS(c_char1, tmp); + CStringToLString(tmp, args[3], length); + + IntToFixp(c_number3, args[4]); + IntToFixp(c_number4, args[5]); + + break; + + case WNN_SELECT_BUNSETSU: + N_GETNUMBER(args[1], c_number1, ERROR); + + result = ejlisp_select_bunsetsu(c_number1, &c_number2); + if (result != 0) break; + + IntToFixp(c_number2, args[2]); + + break; + + case WNN_GET_KOUHO: + N_GETNUMBER(args[1], c_number1, ERROR); + + result = ejlisp_get_kouho(c_number1, c_char3, &c_number2); + if (result != 0) break; + + a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[2])); + base1 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + + + for(i=0;i= 0 ; i--) { + tmp[i*2+1] = tmp[i]; + tmp[i*2] = 0; + } + tmp[length*2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char1); + for (i = length; i < (CHAR_MAXLEN+1)*2; i++) + c_char1[i] = NULL; + + LStringToCString(args[3], tmp, CHAR_MAXLEN,length); + if (strlen(tmp) == length) { + for (i = length - 1 ; i >= 0 ; i--) { + tmp[i*2+1] = tmp[i]; + tmp[i*2] = 0; + } + tmp[length*2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char2); + for (i = length; i < (CHAR_MAXLEN+1)*2; i++) + c_char2[i] = NULL; + + N_GETNUMBER(args[4], c_number2, ERROR); + + result = ejlisp_add_userdic(c_number1, c_char1, c_char2, c_number2); + if (result != 0) break; + + break; + + case WNN_DEL_USERDIC: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); + + result = ejlisp_del_userdic(c_number1, c_number2); + if (result != 0) break; + + break; + + case WNN_SEARCH_USERDIC: + N_GETNUMBER(args[1], c_number1, ERROR); + + LStringToCString(args[2], tmp, CHAR_MAXLEN,length); + if (strlen(tmp) == length) { + for (i = length - 1 ; i >= 0 ; i--) { + tmp[i*2+1] = tmp[i]; + tmp[i*2] = 0; + } + tmp[length*2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char1); + for (i = length; i < (CHAR_MAXLEN+1)*2; i++) + c_char1[i] = NULL; + + result = ejlisp_search_userdic(c_number1, c_char1); + if (result != 0) break; + + IntToFixp(ejlisp_jdp_num, args[3]); + + break; + + case WNN_GET_USERDIC: + + result = ejlisp_get_userdic(c_char3, c_number5, c_number6); + if (result != 0) break; + + a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[1])); + base1 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + + a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[2])); + base2 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + + a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[3])); + base3 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + + for(i=0;ibase))) + (int)(a_ptr->offset); + + a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[2])); + base2 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + + a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[3])); + base3 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + + for(i=0;c_char3[i][0] != NULL;i++,base1++,base2++,base3++) { + ZeroFix(c_char3[i]); + length = EUCtoFatcharNS(c_char3[i], tmp); + CStringToLString(tmp, *base1, length); + *base2 = c_number5[i]; + *base3 = c_number6[i]; + } + + break; + + case WNN_BUNSETSU_KANJI: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); + + result = ejlisp_bunsetsu_kanji(c_number1, c_number2, &c_number3); + if (result != 0) break; + + IntToFixp(c_number3, args[3]); + break; + + case WNN_BUNSETSU_YOMI: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); + + result = ejlisp_bunsetsu_yomi(c_number1, c_number2, &c_number3); + if (result != 0) break; + + IntToFixp(c_number3, args[3]); + break; + +ERROR: + result = 9999; + break; + + } + +#ifdef DEBUG + printf("ejlisp end\n"); + printf("result = %d\n", result); +#endif + + return (GetSmallp(result)); +} + +ejlisp_add_userdic (dic_no,kanji,yomi,hinshi) +int dic_no; +unsigned short *kanji; +unsigned short *yomi; +int hinshi; +{ + int result; +#ifdef DEBUG + printf("ejlisp_add_userdic start\n"); + printf("dic_no = %d,kanji = %s,yomi = %s,hinshi = %d\n",dic_no,kanji,yomi,hinshi); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(result = jl_word_add(ejlisp_buf,dic_no,yomi,kanji,NULL,hinshi,0)); + if (result == 0) { + TIMEOUT(jl_dic_save (ejlisp_buf,dic_no)); + } + +#ifdef DEBUG + printf("ejlisp_add_userdic end\n"); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_bunsetsu_kanji(bunsetsu_no,bunsetsu_no2,kanji_len) +int bunsetsu_no,bunsetsu_no2; +int *kanji_len; +{ + +#ifdef DEBUG + printf("ejlisp_bunsetsu_kanji start\n"); + printf("bunsetsu_no = %d\n",bunsetsu_no); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(*kanji_len = jl_kanji_len (ejlisp_buf,bunsetsu_no,bunsetsu_no2)) ; + +#ifdef DEBUG + printf("ejlisp_bunsetsu_kanji end\n"); + if (wnn_errorno == 0) + printf("kanji_len = %d\n",*kanji_len); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_bunsetsu_yomi(bunsetsu_no,bunsetsu_no2,yomi_len) +int bunsetsu_no,bunsetsu_no2; +int *yomi_len; +{ + +#ifdef DEBUG + printf("ejlisp_bunsetsu_yomi start\n"); + printf("bunsetsu_no = %d\n",bunsetsu_no); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(*yomi_len = jl_yomi_len (ejlisp_buf,bunsetsu_no,bunsetsu_no2)) ; + +#ifdef DEBUG + printf("ejlisp_bunsetsu_yomi end\n"); + printf("yomi_len = %d\n",*yomi_len); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_close () +{ + +#ifdef DEBUG + printf("ejlisp_close start\n"); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(jl_close (ejlisp_buf)) ; + ejlisp_buf = NULL; + +#ifdef DEBUG + printf("ejlisp_close end\n"); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_conv(yomi,kanji,kanji_len,bunsetsu_suu) +unsigned short *yomi; +unsigned short *kanji; +int *kanji_len,*bunsetsu_suu; +{ + +#ifdef DEBUG + printf("ejlisp_conv start\n"); + printf("yomi = %s\n",yomi); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(*bunsetsu_suu = jl_ren_conv (ejlisp_buf,yomi,0,-1,WNN_USE_MAE)); + if (*bunsetsu_suu != -1) { + TIMEOUT(*kanji_len = jl_get_kanji (ejlisp_buf,0,-1,kanji)) ; + } + +#ifdef DEBUG + printf("ejlisp_conv end\n"); + if (wnn_errorno == 0) + printf("kanji = %s, kanji_len = %d, bunsetsu_suu = %d\n", + kanji,*kanji_len,*bunsetsu_suu); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_conv_end () +{ +#ifdef DEBUG + printf("ejlisp_conv_end start\n"); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(jl_update_hindo (ejlisp_buf,0,99)); + if (wnn_errorno == 0) { + TIMEOUT(jl_dic_save_all (ejlisp_buf)); + } + +#ifdef DEBUG + printf("ejlisp_conv_end end\n"); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_del_userdic (dic_no,entry) +{ +#ifdef DEBUG + printf("ejlisp_del_userdic start\n"); + printf("dic_no = %d,entry = %d\n",dic_no,entry); +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(jl_word_delete (ejlisp_buf,dic_no,entry)); + if (wnn_errorno == 0) { + TIMEOUT(jl_dic_save (ejlisp_buf,dic_no)); + } + +#ifdef DEBUG + printf("ejlisp_del_userdic end\n"); + printf("wnn_errorno = %d\n",wnn_errorno); +#endif + + return (wnn_errorno) ; +} + +ejlisp_get_kouho(pos,kouho_arrey,kouho_num) +unsigned short kouho_arrey[TABLE_MAX][CHAR_MAXLEN+1]; +int pos,*kouho_num; +{ + int i,j; + +#ifdef DEBUG + int num; + + printf("ejlisp_get_kouho start\n"); + printf("pos = %d\n",pos); + num = ejlisp_kouho_next; + +#endif + + if (ejlisp_buf == NULL) return(72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + i = ejlisp_kouho_next; + if (pos < 0) { + if ((i -= ejlisp_kouho_max) < 0) + i = ejlisp_kouho_num - + (ejlisp_kouho_num % ejlisp_kouho_max); + if ((i -= ejlisp_kouho_max) < 0) + i = ejlisp_kouho_num - + (ejlisp_kouho_num % ejlisp_kouho_max); + } + + for(j=0;j= ejlisp_kouho_num) + ejlisp_kouho_next = 0; + else + ejlisp_kouho_next = i; + } + +#ifdef DEBUG + printf("ejlisp_get_kouho end\n"); + if (wnn_errorno == 0) { + for(i=0;ikanji); + kouho_len_arrey[i] = strlen(kouho_arrey[i])/2; + kouho_entry_arrey[i] = ejlisp_jdp->serial; + } + +#ifdef DEBUG + printf("ejlisp_get_userdic end\n"); + for(i=0;ifname[0] == '!') { + strcpy(&dic_name_array[j][0],&(dip->fname[1])); + dic_name_len_array[j] = strlen(&dic_name_array[j][0]); + dic_no_array[j] = dip->dic_no; + j++; + } + } + dic_name_array[j][0] = NULL; + } + +#ifdef DEBUG + printf("ejlisp_get_userdic_name end\n"); + if (wnn_errorno == 0) { + for(i=0;i +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "medleyfp.h" +#include "my.h" +#include "arith.h" + + +/************************************************************ +op 072 N_OP_eqlop EQL +op 0314 N_OP_clequal CL:EQUAL +op 0360 (inline) EQ +op 0364 N_OP_equal IL:EQUAL +op 0377 N_OP_eqq CL:= +***********************************************************/ +/* differences between these operations: + +EQ is a strict pointer comparision, equivalent to C's == + +EQL (common lisp) does no conversions before comparision, but will + compare equal FIXPs or equal FLOATPs. + +CL:= will do a numeric comparison + and will compare floats. If given integers, it will convert + to floating point first. + +IL:EQUAL is a recursive comparison which will compare 1 = 1.0 + it work like code with CL:= for the most part + +CL:EQUAL is a recursive comparision which uses EQL at the leaves + +Interlisp operations IEQP, FEQP have no opcodes, although there +is an unboxed FEQP. + +number types include: + +SMALLP (immediate with S_POSITIVE or S_NEGATIVE) +FIXP (32 bit boxed value, handled in C. Usually canonical, i.e., + will be SMALLP. (IPLUS x 0) will always canonicallize.) +FLOATP (32 bit boxed value, handled in C, usually) +RATIO (a/b. Always canonical, i.e., b doesn't divide a evenly) +COMPLEX (a+bi. Not handled in C) +BIGNUM (integer that can't be represented bigger than 32 bits) + +*/ + +#define IF_IMMEDIATE(arg, doit, doitsmall) \ + switch(SEGMASK & arg) { \ + case ATOM_OFFSET: doit; \ + case S_CHARACTER: doit; \ + case S_POSITIVE: doitsmall; \ + case S_NEGATIVE: doitsmall; \ + } + + + + +/************************************************************************/ +/* */ +/* N _ O P _ c l e q u a l */ +/* */ +/* Common Lisp EQUAL, opcode 0314. */ +/* */ +/************************************************************************/ + +int N_OP_clequal(register int arg1, register int arg2) +{ + register int type; + + if (arg2 == arg1) return(ATOM_T); + IF_IMMEDIATE(arg1, return(NIL), return(NIL)); + IF_IMMEDIATE(arg2, return(NIL), return(NIL)); + + /* CL:EQUAL is true for two strings that have different Interlisp + type numbers; cannot currently handle it here. */ + + /* can return NIL if one is a number and the other isn't */ + + if (IsNumber(arg1)) { if(!IsNumber(arg2)) return(NIL); } + else {if (IsNumber(arg2)) {return(NIL);} + else ERROR_EXIT(arg2)} + + /* now we know both are numbers */ + + if ((type = GetTypeNumber(arg1)) != (GetTypeNumber(arg2))) return(NIL); + + /* now we know both are the same type. Shouldn't see any SMALLPs */ + + switch (type) + { + case TYPE_FIXP: if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) + {return(ATOM_T);} + return(NIL); + + case TYPE_FLOATP: if(FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) + {return(ATOM_T);} + return(NIL); + + default: ERROR_EXIT(arg2); + } + + }/* end N_OP_clequal */ + + + + +/************************************************************************/ +/* */ +/* N _ O P _ e q l o p */ +/* */ +/* Common Lisp EQL. */ +/* */ +/************************************************************************/ + +int N_OP_eqlop(register int arg1, register int arg2) +{ + register int type; + + if (arg2 == arg1) return(ATOM_T); + IF_IMMEDIATE(arg1, return(NIL), return(NIL)); + IF_IMMEDIATE(arg2, return(NIL), return(NIL)); + + /* EQL is true if EQ or both are numbers, the same type, and EQUAL */ + + /* can return NIL if one is a number and the other isn't */ + + if ((type = GetTypeNumber(arg1)) != (GetTypeNumber(arg2))) return(NIL); + + /* now we know both are the same type. Shouldn't see any SMALLPs */ + + switch (type) + { + case TYPE_FIXP: if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) + {return(ATOM_T);} + return(NIL); + + case TYPE_FLOATP: if(FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) + {return(ATOM_T);} + return(NIL); + + default: if(IsNumber(arg1)) {ERROR_EXIT(arg2); } + else return(NIL); + + } + + } /* end N_OP_eqlop */ + + + + +/************************************************************************/ +/* */ +/* N _ O P _ e q u a l */ +/* */ +/* IL:EQUAL, opcode 0364. */ +/* */ +/************************************************************************/ + +N_OP_equal(register int arg1, register int arg2) +{ + register int type, type2; + + if (arg2 == arg1) return(ATOM_T); + + IF_IMMEDIATE(arg1, return(NIL), goto arg1_small); + IF_IMMEDIATE(arg2, return(NIL), goto arg2_small); + goto arg2_small; + +arg1_small: + IF_IMMEDIATE(arg2, return(NIL), return(NIL)); /* arg2 atom or both small */ + +arg2_small: + + if (IsNumber(arg1)) { if(!IsNumber(arg2)) return(NIL) ;} + else {if (IsNumber(arg2)) {return(NIL);} + else ERROR_EXIT(arg2)} + + /* now we know both are numbers */ + + type = GetTypeNumber(arg1); + type2 = GetTypeNumber(arg2); + + if (type == type2) + { + switch (GetTypeNumber(arg1)) + { + case TYPE_SMALLP: return(NIL); + case TYPE_FIXP: if(FIXP_VALUE(arg1)==FIXP_VALUE(arg2)) + {return(ATOM_T);} + return(NIL); + case TYPE_FLOATP: if(FLOATP_VALUE(arg1)==FLOATP_VALUE(arg2)) + {return(ATOM_T);} + return(NIL); + default: ERROR_EXIT(arg2); + + } + } + + if ((type == TYPE_FLOATP) || (type2 == TYPE_FLOATP)) + { + register float f1, f2; + N_MakeFloat(arg1, f1, arg2); + N_MakeFloat(arg2, f2, arg2); + if ((f1 + 0.0) == (f2 + 0.0)) return(ATOM_T); + else return(NIL); + } + else return(NIL); /* neither is float, types are different */ + + } /* end N_OP_equal */ + + + + +/************************************************************************/ +/* */ +/* N _ O P _ e q q */ +/* */ +/* Common Lisp =, opcode 0377. Numeric compare, will convert */ +/* among representations as needed. */ +/* */ +/************************************************************************/ + +N_OP_eqq(register int arg1, register int arg2) /* CL:= opcode 0377 */ + + { + register int type1, type2; + register float f1, f2; + + + if (!((type1 = GetTypeEntry(arg1)) & TT_NUMBERP)) ERROR_EXIT(arg2); + if (arg2 == arg1) return(ATOM_T); + if (!((type2 = GetTypeEntry(arg2)) & TT_NUMBERP)) ERROR_EXIT(arg2); + type1 &= 0x7ff; + type2 &= 0x7ff; + + switch ( type1 ) + { + case TYPE_SMALLP : + switch ( type2 ) + { + case TYPE_SMALLP : return(NIL); + case TYPE_FIXP : return(NIL); + case TYPE_FLOATP : goto checkfloats; + default : ERROR_EXIT(arg2); + } + + case TYPE_FIXP : + switch ( type2 ) + { + case TYPE_SMALLP : return(NIL); + case TYPE_FIXP : + if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) + return(ATOM_T); + else return(NIL); + case TYPE_FLOATP : goto checkfloats; + default : ERROR_EXIT(arg2); + } + + case TYPE_FLOATP : + switch ( type2 ) + { + case TYPE_SMALLP : goto checkfloats; + case TYPE_FIXP : goto checkfloats; + case TYPE_FLOATP : goto checkfloats; + default : ERROR_EXIT(arg2); + } + + default : ERROR_EXIT(arg2); + } + + checkfloats: + + N_MakeFloat(arg1, f1, arg2); + N_MakeFloat(arg2, f2, arg2); + if (f1 == f2) return(ATOM_T); + if ((f1 == -0.0) && (f2 == 0.0)) return(ATOM_T); + if ((f1 == 0.0) && (f2 == -0.0)) return(ATOM_T); + return(NIL); + } /* end N_OP_eqq() */ + + + diff --git a/src/ether.c b/src/ether.c new file mode 100755 index 0000000..075583d --- /dev/null +++ b/src/ether.c @@ -0,0 +1,1190 @@ +/* $Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1996 inclusive Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifdef USE_DLPI +#define PKTFILTER 1 +#define NIOCSFLAGS SBIOCSFLAGS +#endif +#ifdef OS4 +#define PKTFILTER 1 +#endif + + +#include +#include +#ifndef DOS +#include +#include +#include +#include +#include +#ifndef NOETHER +#include +#include +#include +#include +#include +#ifndef USE_DLPI +#include +#endif + +#include +#ifdef PKTFILTER +#include +#include +#ifdef OS4 +#include +#include +/* #include */ +#include +#else +#include +#include +#endif /* OS4 */ +#endif /* PKTFILTER */ + +#ifndef USE_DLPI +#include +#endif +#include +#endif /* DOS */ +#endif /* NOETHER */ + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "adr68k.h" +#include "ether.h" +#include "dbprint.h" + +#ifdef USE_DLPI +#define NIOCSETF PFIOCSETF +#endif + + +u_int EtherReadFds; + +int ether_fd = -1; /* file descriptor for ether socket */ +int ether_intf_type = 0; +u_char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address of this node */ +u_char broadcast[6] = {255, 255, 255, 255, 255, 255}; +int ether_bsize = 0; /* if nonzero then a receive is pending */ +u_char *ether_buf; /* address of receive buffer */ +u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) */ +extern LispPTR *PENDINGINTERRUPT68k; +extern u_int LispReadFds; + +int ETHEREventCount = 0; + +#define PacketTypeIP 0x0800 +#define PacketTypeARP 0x0806 +#define PacketTypeRARP 0x8035 +#define PacketTypeXNS 0x0600 +#define PacketTypePUP 0x0200 +#define PacketType3TO10 0x0201 + +#ifndef NOETHER +#ifdef PKTFILTER +/* the receiving packetfilter structure */ +/* if this is changed, be sure to get the references to it in init_ether + and check the length (the second entry in the structure) */ +struct packetfilt goodpf = {0, 29,{ +ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeIP, /* punt if PacketTypeIP */ +ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeARP, /* or PacketTypeARP */ +ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 8, /* check our addr */ +ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 11, /* which is filled in */ +ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 14, /* in init_ether */ +ENF_AND, ENF_AND, +ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* check broadcast */ +ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* which is all ones */ +ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 0xFFFF, +ENF_AND, ENF_AND, +ENF_OR}}; + +/* struct packetfilt allpf = {0, 1, {ENF_PUSHFFFF}}; */ + +/* a filter that rejects all packets to be used by ether_suspend and the + initial routine to flush out ether_fd */ +struct packetfilt nopf = {0, 1, {ENF_PUSHZERO}}; + +#endif /* PKTFILTER */ + +int ether_in = 0; /* number of packets received */ +int ether_out = 0; /* number of packets sent */ +#ifndef PKTFILTER +static struct nit_ioc nioc; +#endif /* PKTFILTER */ + +#endif /* NOETHER */ + + + + +/************************************************************************/ +/* */ +/* e t h e r _ s u s p e n d */ +/* */ +/* Suspend receiving packets from the NIT socket. */ +/* 175/70/0 */ +/* */ +/************************************************************************/ + +ether_suspend(args) + LispPTR args[]; + { +#ifndef NOETHER +#ifdef PKTFILTER + static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; + struct strioctl si; +#endif /* PKTFILTER */ + + if (ether_fd == -1) return(NIL); +#ifndef PKTFILTER + nioc.nioc_typetomatch = NT_NOTYPES; + if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) + { + printf("ether_suspend: ioctl failed\n"); + return(NIL); + } +#else /* PKTFILTER */ + + /* The trick here is to install a packet filter */ + /* that rejects all packets, I think... */ +#ifdef USE_DLPI + + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(nopf); + si.ic_dp = (char *)𝕟 + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ether_suspend nopf ioctl: I_STR PFIOCSETF"); + return(NIL); + } + +#else + if ( ioctl(ether_fd, NIOCSETF, &nopf) != 0) + { + perror("ether_suspend: NIOCSETF failed\n"); + return(NIL); + } +#endif /* USE_DLPI */ +#endif /* PKTFILTER */ +#endif /* NOETHER */ + + return(ATOM_T); + } /* ether_suspend */ + + + + +/************************************************************************/ +/* */ +/* e t h e r _ r e s u m e */ +/* */ +/* resume nit socket to receive all types of packets 175/71/0 */ +/* */ +/************************************************************************/ + +ether_resume(args) + LispPTR args[]; + { +#ifndef NOETHER + struct strioctl si; + if (ether_fd == -1) return(NIL); +#ifndef PKTFILTER + nioc.nioc_typetomatch = NT_ALLTYPES; + if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) + { + printf("ether_resume: ioctl failed\n"); + return(NIL); + } +#else /* PKTFILTER */ + +/* Install a packet filter that accepts all packets we want */ +#ifdef USE_DLPI + + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(goodpf); + si.ic_dp = (char *)&goodpf; + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ether_resume goodpf ioctl: I_STR PFIOCSETF"); + return(NIL); + } + +#else + if ( ioctl(ether_fd, NIOCSETF, &goodpf) != 0) + { + perror("ether_resume: NIOCSETF failed\n"); + return(NIL); + } +#endif /* USE_DLPI */ +#endif /* PKTFILTER */ + +#endif /* NOETHER */ + + return(ATOM_T); + } /* ether_resume */ + + + +/************************************************************************/ +/* */ +/* e t h e r _ c t r l r */ +/* */ +/* return T if ether controller is available 175/72/0 */ +/* */ +/************************************************************************/ + +ether_ctrlr(args) + LispPTR args[]; + { + if (ether_fd < 0) return(NIL); + return(ATOM_T); + } + + + +/********************************************************************** + * ether_reset(args) 175/73/0 + * reset ether controller and disable receipt of packets + **********************************************************************/ +ether_reset(args) + LispPTR args[]; + { + int i; + char hostnumber[6]; + + if (ether_fd < 0) {return(NIL);} + /* JRB - host number check removed here; if ether_fd is open here, + net is on... */ + ether_bsize = 0; /* deactivate receiver */ + return(ATOM_T); + } /* ether_reset */ + + + +/************************************************************************/ +/* */ +/* e t h e r _ g e t (175/74/2) */ +/* */ +/* Set up the Ethernet driver to receive a packet. The driver */ +/* first tries to read any pending packet from the net, and if */ +/* there is one, ether_get returns T. If there is no pending */ +/* packet, the failing read sets us up to get an interrupt when */ +/* a packet DOES arrive, and ether_get returns NIL. */ +/* */ +/* args[0] Length of the buffer we're passed */ +/* args[1] LISP address of a packet buffer */ +/* */ +/* sets ether_buf to the buffer address, for check_ether's use */ +/* sets ether_bsize to the buffer size. ether_bsize>0 means */ +/* it's OK to read packets from the network on interrupt. */ +/* */ +/************************************************************************/ + +ether_get(args) + LispPTR args[]; + { + LispPTR MaxByteCount; + LispPTR result = NIL; + int interrupt_mask; + +#ifndef NOETHER + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + + DBPRINT(("Ether Get. ")); + +#ifdef SYSVSIGNALS + sighold(SIGIO); +#else + interrupt_mask = sigblock(sigmask(SIGIO)); /* turn off ENET interrupts */ +#endif /* SYSVSIGNALS */ + if (ether_fd > 0 && (MaxByteCount > 0)) + { + ether_buf = (u_char *)Addr68k_from_LADDR(args[1]); + ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ + result = get_packet(); +/* check_ether(); for old behavior, move comment to above line */ + } +#ifdef SYSVSIGNALS + sigrelse(SIGIO); +#else + sigsetmask(interrupt_mask); /* interrupts back on */ +#endif /* SYSVISGNALS */ +#endif /* NOETHER */ + + + return (result); + } /* ether_get */ + + + +/********************************************************************** + * ether_send(args) 175/75/2 max_words,buffer_addr + * send a packet + **********************************************************************/ +#define OFFSET sizeof(sa.sa_data) + +ether_send(args) +LispPTR args[]; +{ +#ifndef NOETHER + /* + * Send a packet. + */ + struct sockaddr sa; + + LispPTR MaxByteCount; + char *BufferAddr; /* buffer address pointer(in native address) */ + + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + BufferAddr = (char *)Addr68k_from_LADDR(args[1]); + + if (ether_fd > 0) { +#ifdef PKTFILTER + struct strbuf ctl,data; + +#endif /* PKTFILTER */ + + sa.sa_family = AF_UNSPEC; /* required for the NIT protocol */ + bcopy(BufferAddr, sa.sa_data, OFFSET); +#ifndef PKTFILTER + if ( sendto(ether_fd, BufferAddr+OFFSET, MaxByteCount-OFFSET, 0, + &sa, sizeof(sa)) == (MaxByteCount-OFFSET) ); + else perror("Lisp Ether: sendto"); + ether_out++; +#elif defined(USE_DLPI) + + if (dlunitdatareq(ether_fd, BufferAddr, 6, 0, 0, BufferAddr, MaxByteCount)) + { + perror("unitdatareq"); + return(NIL); + } + ether_out++; + ioctl(ether_fd, I_FLUSH, FLUSHW); + +#else /* PKTFILTER */ + + ctl.maxlen = ctl.len = sizeof(sa); + ctl.buf = (char *)&sa; + data.maxlen = data.len = MaxByteCount - OFFSET; + data.buf = BufferAddr + OFFSET; + if(putmsg(ether_fd, &ctl, &data, 0)<0) { + perror("Ether_send lost"); + return(NIL); + } + else { + ether_out++; + /* flush the buffers to make sure the packet leaves */ + /* maybe we'll use the buffering module some day... */ + ioctl(ether_fd, I_FLUSH, FLUSHW); + } +#endif /* PKTFILTER */ + + } +#endif /* NOETHER */ + + + return(ATOM_T); +} /* ether_send */ + + + + +/********************************************************************** + * ether_setfilter(args) 175/75/1 filterbits + * check whether a packet has come. if does, notify iocb + **********************************************************************/ + +ether_setfilter(args) + LispPTR args[]; + { + return(NIL); + } /* ether_setfilter */ + + + + +/********************************************************************** + * ether_debug() + * returns the ethernet statistics. + **********************************************************************/ + +int estat[3]; + +int *ether_debug() + { +#ifndef NOETHER + estat[0] = 0; + if (ether_fd < 0) return(NIL); + printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", + ether_fd, ether_bsize, (int)ether_buf, + IOPage->dlethernet[3],ether_in,ether_out); +#endif /* NOETHER */ + + return(estat); + } /* end ether_debug */ + +#ifndef NOETHER +static struct timeval EtherTimeout = { + 0, 0 +}; +#endif /* NOETHER */ + + +/********************************************************************** + * check_ether() + * checks an incoming packet + **********************************************************************/ + +#ifndef PKTFILTER +static int nitpos=0, nitlen=0; /* for NIT read buffer in OS3 */ +#endif + +check_ether() + { + /* + * If receiver active then check if any packets are + * available from the ethernet. If so, read the packet + * and signal the icb and return T. + */ + +#ifndef NOETHER +#ifndef PKTFILTER + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* PKTFILTER */ + + static int rfds; + int result; + int i; + int plen; + struct strbuf ctl, data; + char ctlbuf[2000]; +#endif /* PKTFILTER */ + + + rfds = EtherReadFds; +#ifndef PKTFILTER + i = 2; + if(/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) + { + if( (ether_fd >= 0) && (ether_bsize > 0) ) + { + while ( (select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) + && (i-- > 0) ) + { + if (nitpos>=nitlen) + { /* Used up last NIT buffer full; read another. */ + nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); + nitpos = 0; + } + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) + { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) + { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) + { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); + nitpos += fromlen; + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End=0; + *PENDINGINTERRUPT68k = ATOM_T; + /* return(NIL); */ + return(ATOM_T); + } + nitpos += fromlen; + break; + + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; + } + } + } + } + } +#else /* PKTFILTER */ + + if(ether_fd >= 0 && ether_bsize > 0 +/* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 + * -- [on '90/02/14: getsignsldata() chech this] */ + && (rfds & (1 << ether_fd))) + { + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if(result >= 0 ) + { + if(data.len <= ether_bsize + && data.len > 0) + { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End=0; + *PENDINGINTERRUPT68k = ATOM_T; + return(NIL); /* return(ATOM_T); */ + } + } + else if (errno != EWOULDBLOCK) + { + perror("Check_ether read error:\n"); + } + } +#endif /* PKTFILTER */ + +#endif /* NOETHER */ + + + return(NIL); + } /* end check_ether */ + + +/************************************************************************/ +/* */ +/* g e t _ p a c k e t */ +/* */ +/* Try getting a packet, ala check_ether, returning NIL if none, */ +/* T if one was received. This is used by ether_get only. */ +/* */ +/************************************************************************/ + +get_packet() + { +#ifndef NOETHER +#ifndef PKTFILTER + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* PKTFILTER */ + + static int rfds; + int result; + int i; + int plen; + struct strbuf ctl, data; + char ctlbuf[2000]; +#endif /* PKTFILTER */ + + +#ifndef PKTFILTER + while (1) + { + if (nitpos>=nitlen) + { /* Used up last NIT buffer full; read another. */ + nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); + if (nitlen < 0) return(NIL); /* No more packets to try. */ + nitpos = 0; + } + + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) + { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) + { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) + { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", + fromlen, nitpos, nitlen)); + nitpos += fromlen; + return(ATOM_T); + } + nitpos += fromlen; + break; + + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; + } + } + } + +#else /* PKTFILTER */ + + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if(result >= 0 ) + { + if (ctl.len > 0) + printf("ctl msg rcvd.\n"); + if(data.len <= ether_bsize && data.len > 0) + { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + return(ATOM_T); + } + } + else if (errno != EWOULDBLOCK) perror("Check_ether read error:\n"); +#endif /* PKTFILTER */ + +#endif /* NOETHER */ + + + return(NIL); + } /* end get_packet */ + + + + + +/********************************************************************** + * check_filter(buffer) + * see if this packet passes the current filter setting + * This is believed obsolete with packet filtering enabled + **********************************************************************/ + +check_filter(buffer) + u_char* buffer; + { + /* broadcast packets */ + if (ether_addr_equal(buffer, broadcast)) + switch(((short*)buffer)[6]) + { + case PacketTypeIP: return(0); + case PacketTypeARP: return(0); + default: return(1); + }; + /* my address */ + if (ether_addr_equal(buffer, ether_host)) + switch(((short*)buffer)[6]) + { + case PacketTypeIP: return(0); + case PacketTypeARP: return(0); + default: return(1); + }; + return(0); + } + + + +/********************************************************************** + * ether_addr_equal(add1, add2) + * checks ethernet addresses equality + * Also believed obsolete + **********************************************************************/ + +ether_addr_equal(add1, add2) + +u_char add1[], add2[]; + { + register int i; + for(i=0; i<6; i++) if (add1[i] != add2[i]) return(0); + return(1); + } + + + +/********************************************************************** + * init_uid() + * sets effective user-id to real user-id + **********************************************************************/ +init_uid() + { +#ifndef NOETHER + int rid; + rid = getuid(); + seteuid(rid); +#endif /* NOETHER */ + } + + + +/************************************************************************/ +/* i n i t _ i f p a g e _ e t h e r */ +/* */ +/* sets Lisp's idea of \my.nsaddress. Clears it if ether not */ +/* enabled */ +/* */ +/************************************************************************/ + +init_ifpage_ether() + { + InterfacePage->nshost0 = (DLword)((ether_host[0] << 8) + ether_host[1]); + InterfacePage->nshost1 = (DLword)((ether_host[2] << 8) + ether_host[3]); + InterfacePage->nshost2 = (DLword)((ether_host[4] << 8) + ether_host[5]); + } + + +#ifndef NOETHER + /* this needs to be a global so the name can be set by main() in Ctest */ + /* But NOETHER doesn't support NIT, so dyke it out for NOETHER */ +#ifndef USE_DLPI +struct sockaddr_nit snit; +#endif /* USE_DLPI */ +#endif /* NOETHER */ + + + + + +/************************************************************************/ +/* i n i t _ e t h e r */ +/* */ +/* open nit socket, called from main before starting BCE. */ +/* */ +/************************************************************************/ +init_ether() + { + +#ifndef NOETHER + + /* JRB - This code will have to be a bit different for SUN 4.0; the probable differences are in commented-out code below + (not ifdefed because they're untested...) + */ + int flags; + struct strioctl si; + unsigned long snaplen = 0; + + /* ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 0; + ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->handledmask = 0; +*/ + + if (ether_fd < 0) + { + /* it's not open yet, try and open it; + if it's already open here, it was opened by ldeether and + all the appropriate stuff was done to it there. + */ +#ifdef USE_DLPI + /* Use DLPI to connect to the ethernet. This code is stolen + from NFSWATCH4.3 + */ + + /* if (getuid() != geteuid()) */ + { + if ( (ether_fd = setup_dlpi_dev(NULL)) > 0) { /* Open an ether interface */ + + ether_intf_type = dlpi_devtype(ether_fd); + + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pfmod") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } + + + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(nopf); + si.ic_dp = (char *)𝕟 + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ioctl: I_STR PFIOCSETF"); + return(-1); + } + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | O_NDELAY ); + + } + else + { +I_Give_Up: +/* JDS 991228 remove perror("Can't open network; XNS unavailable.\n"); */ + ether_fd = -1; + + } + seteuid(getuid()); + } +#else + /* N O T D L P I C O D E */ + + + +#ifndef OS4 + if (getuid() != geteuid()) + { + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) + { + /* 4.0: socket -> open("/dev/nit", O_BOTH) */ + /* it's open, now query it and find out its name and address */ + /* JRB - must document that Maiko uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option to + specify which net board (suspect more than one net board on a + Maiko machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + /* 4.0 - before the SIOCGIFCONF, do: + bzero(ifbuf, sizeof(ifbuf)) + */ + if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) + { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ + + if (getuid() != geteuid()) + { + if ((ether_fd = open("/dev/nit", O_RDWR|FASYNC)) >= 0) + { + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option + to specify which net board (suspect more than one net + board on an LDE machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pf") < 0) + { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + perror("No socket for interface name"); + close(s); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; +#ifndef OS4 + return(NIL); +#else /* OS4 */ + + goto I_Give_Up; +#endif /* OS4 */ + + } +#ifndef OS4 + /* got its name, copy it into snit */ + strcpy(snit.snit_ifname, if_data.ifc_req[0].ifr_name); + /* 4.0, before the SIOCGIFADDR, do: + ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) + */ + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) + { + perror("Couldn't GIFADDR socket: Net is off"); +#else /* OS4 */ + + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) + { + perror("Couldn't get interface name from socket"); + close(s); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; +#ifndef OS4 + return(NIL); +#else /* OS4 */ + + goto I_Give_Up; +#endif /* OS4 */ + + } +#ifndef OS4 + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + init_uid(); + } +#else /* OS4 */ + + (void) close(s); +#endif /* OS4 */ + + } +#ifdef OS4 + if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) + { + perror("Couldn't NIOCBIND socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) + { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + DBPRINT(("init_ether: **** Ethernet starts ****\n")); + } + else + { +I_Give_Up: + perror("Can't open network; XNS unavailable.\n"); + ether_fd = -1; + + } + seteuid(getuid()); + } + +#endif /* OS4 */ +#endif /* USE_DLPI */ + +} + + + /******************************/ + /* Have now either opened enet here, or in ldeether */ + /***************************************************/ + +if (ether_fd >= 0) { +#ifndef PKTFILTER + /* bind the socket to an interface */ + snit.snit_family = AF_NIT; + bind(ether_fd, &snit, sizeof(snit)); +#else /* PKTFILTER */ + +/* I think all you really have to do here is set the SNAP length, flags, + and configure the buffering module */ + struct timeval zerotime; +#endif /* PKTFILTER */ + + +#ifndef PKTFILTER + /* establish the operating modes */ + bzero(&nioc, sizeof(nioc)); + nioc.nioc_bufspace = 20000; + nioc.nioc_chunksize = 50; /* small chunks so each packet read */ + nioc.nioc_typetomatch = NT_ALLTYPES; + nioc.nioc_snaplen = 32767; + nioc.nioc_flags = 0; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("init_ether: ioctl failed\n"); + + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#else /* PKTFILTER */ + + EtherReadFds |= (1 << ether_fd); + +/* first and foremost, flush out ether_fd's buffers and filter it */ +/* install packetfilter that rejects everything */ +#ifdef USE_DLPI + + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(nopf); + si.ic_dp = (char *)𝕟 + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("init_ether nopf ioctl: I_STR PFIOCSETF"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } + +#else + if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { + perror("init_ether: nopf NIOCSETF failed:\n"); + + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#endif /* USE_DLPI */ +#endif /* PKTFILTER -- jds 23 sep 96 unmatched if fix */ +#ifndef PKTFILTER + EtherReadFds |= (1 << ether_fd); + if (fcntl(ether_fd, F_SETFL, + fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY)<0) + perror("Ether setup SETFLAGS fcntl"); + if( fcntl(ether_fd, F_SETOWN, getpid()) < 0) + perror("Ether setup SETOWN"); +#else /* PKTFILTER */ + +/* then throw away everything that's currently buffered there; + this descriptor may have been open since ldeether ran, with + no filtering; a busy net will have stuffed it full */ +#ifdef USE_DLPI + if (ioctl(ether_fd, I_FLUSH, (char *)FLUSHR) < 0) + { + perror("init_ether I_FLUSH"); + } +#else + {int rfds = EtherReadFds; + while(select(32, &rfds, NULL, NULL, &EtherTimeout) > 0) + read(ether_fd, nit_buf, sizeof(nit_buf)); + } +#endif /* USE_DLPI */ + + +/* put the address into the packetfilter structure */ +/* DANGER! Vulnerable to byte ordering! DANGER! */ + goodpf.Pf_Filter[8]= (DLword)((ether_host[0] << 8) + ether_host[1]); + goodpf.Pf_Filter[11]= (DLword)((ether_host[2] << 8) + ether_host[3]); + goodpf.Pf_Filter[14]= (DLword)((ether_host[4] << 8) + ether_host[5]); +/* and set up the packetfilter */ +#ifdef USE_DLPI + + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(goodpf); + si.ic_dp = (char *)&goodpf; + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("init_ether goodpf ioctl: I_STR PFIOCSETF"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } + +#else + if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { + perror("init_ether: NIOCSETF failed:\n"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#endif /* USE_DLPI */ +#ifndef USE_DLPI + DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); + if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) + { + perror("init_ether: I_SETSIG failed:\n"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#endif /* USE_DLPI */ +#endif /* PKTFILTER */ + + if (EtherReadFds == 0) + error("EtherReadFds is zero, but enet opened??"); + LispReadFds |= EtherReadFds; + + DBPRINT(("init_ether: **** Ethernet starts ****\n")); + } +#endif /* NOETHER */ + + } + + + + +#define MASKWORD1 0xffff + + +/************************************************************************/ +/* */ +/* c h e c k _ s u m */ +/* */ +/* Implements the CHECKSUM opcode; compute the checksum for an */ +/* ethernet packet. */ +/* */ +/* args[0] LispPTR base; */ +/* args[1] LispPTR nwords; */ +/* args[2] LispPTR initsum; */ +/* */ +/* */ +/************************************************************************/ + +check_sum(args) + register LispPTR *args; + { + register LispPTR checksum; + register DLword *address; + register int nwords; + + address=(DLword*)Addr68k_from_LADDR(*args++); + nwords = *args ++; + + if( *args != NIL) checksum = (*args) & MASKWORD1; + else checksum = 0; + + for(;nwords > (S_POSITIVE); address++,nwords--) + { + checksum= checksum + GETWORD(address); + if(checksum > 0xffff) + checksum = (checksum & 0xffff) +1; /* add carry */ + + if(checksum >0x7fff) /* ROTATE LEFT 1 */ + checksum= ((checksum & 0x7fff)<<1) | 1 ; + else checksum = checksum << 1; + } + + if(checksum == MASKWORD1) return(S_POSITIVE);/* ret 0 */ + else return(S_POSITIVE|checksum); + + } /*check_sum */ diff --git a/src/find-dsp.lex b/src/find-dsp.lex new file mode 100755 index 0000000..dbf71f0 --- /dev/null +++ b/src/find-dsp.lex @@ -0,0 +1,17 @@ +/* @(#) find-dispatch.lex Version 1.2 (4/7/89). copyright envos & Fuji Xerox */ + +REG "%"[oilg][0-9] +REGOFF "%"[oilg][0-9]\+\-0x[0-9] +LABEL L[0-9]+ +LDUB "\tldub\t["{REG}"],"{REG} +LDUB2 "\tldub\t["{REGOFF}"],"{REG} + +%% + +{LDUB2}\n\tcmp\t{REG}",255\n\tbgu\t"{LABEL}\n\t\sll\t{REG}",2,"{REG}\n\tset\t { char x; + printf("char *dispatch_label = \""); + loop: x=input(); + if(x == ','){ printf("\";\n"); return;} + output(x); goto loop;} + +.*\n {} diff --git a/src/findkey.c b/src/findkey.c new file mode 100755 index 0000000..4c830fa --- /dev/null +++ b/src/findkey.c @@ -0,0 +1,84 @@ +/* $Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" +#include "stack.h" +#include "lspglob.h" +#include "adr68k.h" + + +/***********************************************************************/ +/* + File Name : findkey.c + + Desc : + + Date : Mar. 29 88 + Edited by : Bob Krivacic + Including : N_OP_findkey + + +*/ +/**********************************************************************/ + + +LispPTR N_OP_findkey(register LispPTR tos, register int byte) +{ + LispPTR *ptr ; + DLword *find_end ; + DLword arg_nth ; + +#ifdef TRACE + printPC(); + printf("TRACE : N_OP_findkey \n"); +#endif + + if(CURRENTFX->alink & 1) + { /* slow case */ + find_end = (DLword *)Addr68k_from_LADDR(STK_OFFSET | (CURRENTFX->blink-4)) ; + } + else + { /* Fast cae */ + find_end = ((DLword *)CURRENTFX) -2-4; + } + + arg_nth =byte + 1 ; + + for ( ptr =(LispPTR *) (IVar + ((byte * 2) - 2)); + (unsigned)find_end >= (unsigned) ptr ; ptr += 2, arg_nth +=2) + { + if (*ptr == tos) + { /* KEY founded */ + return(S_POSITIVE | arg_nth); + } + } /* for end */ + +/* No matched */ + + return(NIL_PTR); + + }/* end N_OP_findkey() */ + + diff --git a/src/foreign.c b/src/foreign.c new file mode 100755 index 0000000..70da4a6 --- /dev/null +++ b/src/foreign.c @@ -0,0 +1,997 @@ +/* $Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifndef NOFORN +#include +#include "dld.h" +#include "lispemul.h" +#include "lspglob.h" +#include "emlglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "locfile.h" +#include "medleyfp.h" +#include "arith.h" +#include "stack.h" + + + + /***********************************************************/ + /* L S t r i n g T o C S t r i n g */ + /* */ + /* Convert a lisp string to a C string up to MaxLen long. */ + /***********************************************************/ + +#define LStringToCString(Lisp, C, MaxLen ,Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int i; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ + Len = min(MaxLen, arrayp->fillpointer); \ + \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0;ibase))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(i=0;i]: arguments */ +/* */ +/************************************************************************/ +#define Max_Arg 32 + +LispPTR call_c_fn(LispPTR *args) +{ + int intarg[Max_Arg], result, i, j; + int fnaddr, resulttype, *errorflag, *smasher, arglistlength, *descriptorblock; + PFI pickapart1, pickapart2, pickapart3, pickapart4; + float fresult; + + DLword *fword, *createcell68k(unsigned int type); + + FX2 *caller; + struct fnhead *fnhead; + ByteCode *pc; + + /* Initialize the variables from the descriptorblock */ + descriptorblock = (int *)Addr68k_from_LADDR(args[0]); + fnaddr=*descriptorblock++; + resulttype=*descriptorblock++; + errorflag=descriptorblock++; + arglistlength=*descriptorblock++; + smasher=descriptorblock++; + + /* initialize the errorflag */ + *errorflag=0; + + /* Initialize the argvector */ + for(i=0; ifnheader)); + pc = (ByteCode *)fnhead+(caller->pc); + break; + case TYPE_SMALLP: + case TYPE_FIXP: + { int tmp; + tmp = ((PFI)fnaddr) + (intarg[0], intarg[1], intarg[2], intarg[3], + intarg[4], intarg[5], intarg[6], intarg[7], + intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], + intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], + intarg[28], intarg[29], intarg[30], intarg[31] + ); + return(CIntToLispInt(tmp)); + }; + break; + case TYPE_CHARACTERP: + { int tmp; + tmp = ((PFC)fnaddr) + (intarg[0], intarg[1], intarg[2], intarg[3], + intarg[4], intarg[5], intarg[6], intarg[7], + intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], + intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], + intarg[28], intarg[29], intarg[30], intarg[31] + ); + return(S_CHAR | tmp); + }; + break; + case TYPE_FLOATP: + fresult = ((PFF)fnaddr) + (intarg[0], intarg[1], intarg[2], intarg[3], + intarg[4], intarg[5], intarg[6], intarg[7], + intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], + intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], + intarg[28], intarg[29], intarg[30], intarg[31] + ); + fword = createcell68k(TYPE_FLOATP); + *((float *)fword) = fresult; + return(LADDR_from_68k(fword)); + break; + default: + *errorflag=-2; + break; + } + } + + +/************************************************************************/ +/* */ +/* S M A S H I N G _ C _ F N */ +/* */ +/* args[0]: descriptor block for the function */ +/* 0 is the function address if the function is callable */ +/* or 0 if the function is undefined or unresolved */ +/* 1 is the result type */ +/* 2 is the error return flag: 0=no errors. 1 if there's */ +/* some problem */ +/* 3 is the lenght of the arglist passed */ +/* 4-n the arglist types */ +/* args[1]: Smashing place */ +/* args[2 - ]: arguments */ +/* */ +/* This is an aboration. It is only implemented on the speciffic */ +/* request of an influential customer. The things we do for money! */ +/* */ +/* The result of this functioncall will be smashed into what */ +/* arg[0] points to. If it is a cell of the right type we are ok. */ +/* If it is not we are on the road to hell. /jarl nilsson */ +/* */ +/************************************************************************/ +LispPTR smashing_c_fn(LispPTR *args) +{ + int intarg[Max_Arg], result, i, j; + int fnaddr, resulttype, *errorflag, arglistlength, *descriptorblock; + PFI pickapart1, pickapart2, pickapart3, pickapart4; + float fresult; + + int *valueplace; + DLword *fword, *createcell68k(unsigned int type); + + FX2 *caller; + struct fnhead *fnhead; + ByteCode *pc; + + /* Initialize the variables from the descriptorblock */ + descriptorblock = (int *)Addr68k_from_LADDR(args[0]); + fnaddr=*descriptorblock++; + resulttype=*descriptorblock++; + errorflag=descriptorblock++; + arglistlength=*descriptorblock++; + + /* initialize the errorflag */ + *errorflag=0; + + /* Initialize the valueplace */ + valueplace = (int *)Addr68k_from_LADDR(args[1]); + + /* Initialize the argvector */ + for(i=0; ifnheader)); + pc = (ByteCode *)fnhead+(caller->pc); + break; + case TYPE_SMALLP: + case TYPE_FIXP: + { int tmp; + tmp = ((PFI)fnaddr) + (intarg[0], intarg[1], intarg[2], intarg[3], + intarg[4], intarg[5], intarg[6], intarg[7], + intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], + intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], + intarg[28], intarg[29], intarg[30], intarg[31] + ); + *valueplace=tmp; + return(NIL); + }; + break; + case TYPE_CHARACTERP: + return(S_CHAR | (((PFC)fnaddr) + (intarg[0], intarg[1], intarg[2], intarg[3], + intarg[4], intarg[5], intarg[6], intarg[7], + intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], + intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], + intarg[28], intarg[29], intarg[30], intarg[31] + ))); + break; + case TYPE_FLOATP: + fresult = ((PFF)fnaddr) + (intarg[0], intarg[1], intarg[2], intarg[3], + intarg[4], intarg[5], intarg[6], intarg[7], + intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], + intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], + intarg[28], intarg[29], intarg[30], intarg[31] + ); + *valueplace=fresult; + return(NIL); + break; + default: + *errorflag=-2; + break; + } + } + + +/************************************************************************/ +/* */ +/* M d l d _ l i n k */ +/* */ +/* args[0] - The lisp string name of the path to the filename */ +/* Return value: 0 -> ok. */ +/* 1 - 16 -> errorcode */ +/* */ +/************************************************************************/ + +int Mdld_link(LispPTR *args) +{ + char filename[MAXPATHLEN]; + int result, leng; + +#ifdef TRACE + printf( "TRACE: dld_link(" ); +#endif + + LStringToCString( args[0], filename, MAXPATHLEN, leng); + +#ifdef TRACE + printf( "%s)\n", filename ); +#endif + + result = dld_link( filename ); + N_ARITH_SWITCH ( result ); +}; + +/************************************************************************/ +/* */ +/* M d l d _ u n l i n k _ b y _ f i l e */ +/* */ +/* args[0] - The lisp string name of the path to the filename */ +/* args[1] - Force flag. If NonZero, force the unlinking, even */ +/* if there are references to this module. */ +/* Return value: 0 -> ok. */ +/* 1 - 16 -> errorcode */ +/* */ +/************************************************************************/ + +int Mdld_unlink_by_file(LispPTR *args) +{ + char filename[MAXPATHLEN]; + int hard, result, leng; + +#ifdef TRACE + printf( "TRACE: dld_unlink_by_file(" ); +#endif + + LStringToCString( args[0], filename, MAXPATHLEN, leng ); + hard = GetSmalldata( args[1] ); + +#ifdef TRACE + printf( "%s, %d)\n", filename, hard ); +#endif + + result = dld_unlink_by_file( filename, hard ); + N_ARITH_SWITCH ( result ); +}; + +/************************************************************************/ +/* */ +/* M d l d _ u n l i n k _ b y _ s y m b o l */ +/* */ +/* args[0] - The lisp string name of the symbol in some module. */ +/* args[1] - Force flag. If NonZero, force the unlinking, even */ +/* if there are references to this module. */ +/* Return value: 0 -> ok. */ +/* 1 - 16 -> errorcode */ +/* */ +/************************************************************************/ + +int Mdld_unlink_by_symbol(LispPTR *args) +{ + char symbolname[MAXPATHLEN]; + int hard, result, leng; + +#ifdef TRACE + printf( "TRACE: dld_unlink_by_symbol(" ); +#endif + + LStringToCString( args[0], symbolname, MAXPATHLEN, leng ); + hard = GetSmalldata( args[1] ); + +#ifdef TRACE + printf( "%s, %d)\n", symbolname, hard ); +#endif + + result = dld_unlink_by_symbol( symbolname, hard ); + N_ARITH_SWITCH ( result ); +}; + +/************************************************************************/ +/* */ +/* M d l d _ g e t _ s y m b o l */ +/* */ +/* args[0] - The lisp string name of the symbol. */ +/* Return value - a pointer to the symbol or 0 */ +/* */ +/************************************************************************/ + +unsigned long Mdld_get_symbol(LispPTR *args) +{ + char symbolname[MAXPATHLEN]; + int result, leng; + +#ifdef TRACE + printf( "TRACE: dld_get_symbol(" ); +#endif + + LStringToCString( args[0], symbolname, MAXPATHLEN, leng ); + +#ifdef TRACE + printf( "%s, %d)\n", symbolname ); +#endif + + result = dld_get_symbol( symbolname ); + N_ARITH_SWITCH ( result ); +}; + +/************************************************************************/ +/* */ +/* M d l d _ g e t _ f u n c */ +/* */ +/* args[0] - The lisp string name of the function. */ +/* Return value - a pointer to the function or 0. */ +/* */ +/************************************************************************/ +unsigned long Mdld_get_func(LispPTR *args) +{ + char funcname[MAXPATHLEN]; + int result, leng; + +#ifdef TRACE + printf( "TRACE: dld_get_func(" ); +#endif + + LStringToCString( args[0], funcname, MAXPATHLEN, leng ); + +#ifdef TRACE + printf( "%s )\n", funcname ); +#endif + + result = dld_get_func( funcname ); + N_ARITH_SWITCH ( result ); +}; + +/************************************************************************/ +/* */ +/* M d l d _ f u n c t i o n _ e x e c u t a b l e _ p */ +/* */ +/* args[0] - The lisp string name of the function. */ +/* */ +/************************************************************************/ +int Mdld_function_executable_p(LispPTR *args) +{ + char funcname[MAXPATHLEN]; + int result, leng; + +#ifdef TRACE + printf( "TRACE: dld_function_executable_p(" ); +#endif + + LStringToCString( args[0], funcname, MAXPATHLEN, leng ); + +#ifdef TRACE + printf( "%s, %d)\n", funcname ); +#endif + + result = dld_function_executable_p( funcname ); + N_ARITH_SWITCH ( result ); +}; + +/************************************************************************/ +/* */ +/* M d l d _ l i s t _ u n d e f i n e d _ s y m */ +/* */ +/* */ +/************************************************************************/ +int Mdld_list_undefined_sym(void) +{ + char **dld_list_undefined_sym(); + int temp; + extern int dld_undefined_sym_count; + +#ifdef TRACE + printf( "TRACE: dld_list_undefined_sym()\n" ); +#endif + + if (dld_undefined_sym_count == 0) { + return (NIL); + } + + temp = (int)dld_list_undefined_sym( ); + N_ARITH_SWITCH ( temp ); +}; + +/************************************************************************/ +/* */ +/* m a l l o c */ +/* */ +/* */ +/************************************************************************/ +int c_malloc (LispPTR *args) +{ + printf ("malloc!\n"); + return(NIL); +} + +/************************************************************************/ +/* */ +/* f r e e */ +/* */ +/* */ +/************************************************************************/ +int c_free (LispPTR *args) +{ + printf ("free!\n"); + return(NIL); +} + +/************************************************************************/ +/* */ +/* P U T B A S E B Y T E */ +/* */ +/* arg[0] = the base address. */ +/* arg[1] = the offset as calculated by the type */ +/* arg[2] = type of access. */ +/* 0 = set the bit pointed out by address + offset */ +/* 1 = set the byte pointed out by address + offset */ +/* 2 = set the word (16bit) pointed to by address + offset */ +/* 3 = set the integer pointed out by address + offset */ +/* 4 = set the float pointed out by address + offset */ +/* arg[3] = the new value. */ +/* The offset changes depending on the type argument. If type is */ +/* 0 the changed value will be the bit at ADDRESS + OFFSET bits. */ +/* If type is 1 the changedvalue will be the byte at ADDRESS + */ +/* OFFSET bytes. If type is 2 the changed value will be the int */ +/* at ADDRESS + OFFSET. */ +/* */ +/* This makes it easy to set values in arrays. */ +/* */ +/************************************************************************/ +int put_c_basebyte (LispPTR *args) +{ + int addr, offset, newval; + + addr = LispIntToCInt(args[0]); + offset = LispIntToCInt(args[1]); + newval= LispIntToCInt(args[3]); + + switch (LispIntToCInt(args[2])) { + case 0: /* bit */ + if (newval == 0) { + GETBYTE((char *)(addr + (offset >> 3))) &= (~(1 << (0x7 & offset))); + } else { + GETBYTE((char *)(addr + (offset >> 3))) |= (1 << (0x7 & offset)); + }; + break; + case 1: /* byte */ + GETBYTE((char*)(addr + offset)) = 0xFF & newval; + break; + case 2: /* word */ + newval &= 0xFFFF; + (*((short *) ((addr & 0xFFFFFFFE) + (offset << 1)))) = newval; + break; + case 3: /* int */ + (*((int *) ((addr & 0xFFFFFFFE) + (offset << 2)))) = newval; + break; + case 4: /* float */ + (*((float *) ((addr & 0xFFFFFFFE) + (offset << 2)))) = FLOATP_VALUE(args[3]); + break; + } + return(NIL); +} + +/************************************************************************/ +/* */ +/* G E T _ C _ B A S E B Y T E */ +/* */ +/* arg[0] = the base address. */ +/* arg[1] = the offset as calculated by the type */ +/* arg[2] = type of access. */ +/* 0 = get the bit pointed out by address + offset */ +/* 1 = get the byte pointed out by address + offset */ +/* 2 = get the word (16bit) pointed to by address + offset */ +/* 3 = get the integer pointed out by address + offset */ +/* 4 = get the float pointed out by address + offset */ +/* The offset changes depending on the type argument. If type */ +/* is 0 the return value will be the bit at ADDRESS + OFFSET bits. */ +/* If type is 1 the return value will be the byte at ADDRESS + */ +/* OFFSET bytes. If type is 2 the return value will be the integer */ +/* at ADDRESS + OFFSET. */ +/* */ +/* This makes it easy to access arrays. */ +/* */ +/************************************************************************/ +int get_c_basebyte(LispPTR *args) +{ + int addr, offset, type; + DLword *fword, *createcell68k(unsigned int type); + + addr = LispIntToCInt(args[0]); + offset = LispIntToCInt(args[1]); + + switch (LispIntToCInt(args[2])) { + case 0: /* bit */ + if ((GETBYTE((char *)(addr + (offset >> 3)))) & (1 << (0x7 & offset))) { + /* ^get bitmask from offset ^get the byte at the byteaddress */ + return(ATOM_T); + } else { + return(NIL); + }; + break; + case 1: /* byte */ + return((0xFF & (GETBYTE((char *)(addr + offset)))) | S_POSITIVE); + break; + case 2: /* word */ + return( CIntToLispInt (0xFFFF & (*((short *) ((addr & 0xFFFFFFFE) + (offset << 1)))))); + break; + case 3: /* int */ + return( CIntToLispInt (*((int *) ((addr & 0xFFFFFFFE) + (offset << 2))))); + break; + case 4: /* float */ + fword = createcell68k(TYPE_FLOATP); + *((float *)fword) = *(float *)((addr & 0xFFFFFFFE) + (offset << 2)); + return(LADDR_from_68k(fword)); + break; + } +} +#endif /* NOFORN */ diff --git a/src/fp.c b/src/fp.c new file mode 100755 index 0000000..31ca8e4 --- /dev/null +++ b/src/fp.c @@ -0,0 +1,192 @@ +/* $Id: fp.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: fp.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/************************************************************************/ +/* */ +/* F P . C */ +/* */ +/* Floating-point arithmetic code. */ +/* */ +/************************************************************************/ +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "my.h" +#include "medleyfp.h" + +/************************************************************ + N_OP_fplus2 -- op 350 + N_OP_fdifference -- op 351 + N_OP_ftimes2 -- op 352 + N_OP_fquotient -- op 353 + N_OP_fgreaterp -- op 362 +***********************************************************/ + +DLword *createcell68k(unsigned int type); + + + +/************************************************************************/ +/* */ +/* N _ O P _ f p l u s 2 */ +/* */ +/* 2-argument floating point addition opcode */ +/* */ +/************************************************************************/ + +N_OP_fplus2(LispPTR parg1, LispPTR parg2) +{ + REGISTER float arg1; + REGISTER float arg2; + REGISTER float result; + register DLword *wordp; + + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; +#ifdef I386 + I386Round; +#endif + result = arg1 + arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return(LADDR_from_68k(wordp)); + } /* end N_OP_fplus2() */ + + + +/************************************************************************/ +/* */ +/* N _ O P _ f d i f f e r e n c e */ +/* */ +/* 2-arugment floating-point subtraction. */ +/* */ +/************************************************************************/ + +N_OP_fdifference(LispPTR parg1, LispPTR parg2) +{ + REGISTER float arg1, arg2; + REGISTER float result; + register DLword *wordp; + + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; +#ifdef I386 + I386Round; +#endif + result = arg1 - arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return(LADDR_from_68k(wordp)); + } /* end N_OP_fdifference() */ + + + + +/************************************************************************/ +/* */ +/* N _ O P _ f t i m e s 2 */ +/* */ +/* Floating-point multiplication */ +/* */ +/************************************************************************/ + +N_OP_ftimes2(LispPTR parg1, LispPTR parg2) +{ + REGISTER float arg1, arg2; + REGISTER float result; + register DLword *wordp; + + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; +#ifdef I386 + I386Round; +#endif + result = arg1 * arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return(LADDR_from_68k(wordp)); + } /* end N_OP_ftimes2() */ + + + + +/************************************************************************/ +/* */ +/* N _ O P _ f q u o t i e n t */ +/* */ +/* floating-point division */ +/* */ +/************************************************************************/ + +N_OP_fquotient(LispPTR parg1, LispPTR parg2) +{ + REGISTER float arg1, arg2; + REGISTER float result; + register DLword *wordp; + + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; +#ifdef I386 + I386Round; +#endif + result = arg1 / arg2; + + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return(LADDR_from_68k(wordp)); + } /* end N_OP_fquotient() */ + + + +/************************************************************************/ +/* */ +/* N _ O P _ f g r e a t e r p */ +/* */ +/* Floating-point > */ +/* */ +/************************************************************************/ + +N_OP_fgreaterp(LispPTR parg1, LispPTR parg2) +{ + REGISTER float arg1, arg2; + register DLword *wordp; + register LispPTR lptr; + + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + if (arg1 > arg2) return(ATOM_T); + else return(NIL_PTR); + } /* end N_OP_fgreaterp() */ + + diff --git a/src/fvar.c b/src/fvar.c new file mode 100755 index 0000000..fe857a2 --- /dev/null +++ b/src/fvar.c @@ -0,0 +1,610 @@ +/* $Id: fvar.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: fvar.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "stack.h" +#include "emlglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "gc.h" + +#ifdef GCC386 +#include "inlnPS2.h" +#endif + +#define MaskShift(x) (((x) << 16) & SEGMASK) + + +#ifdef BIGATOMS +#define NT_OFFSET_MASK 0xFFFFFFF +#define NT_TYPE_MASK 0xFF000000 +#define GetNTEntry(X) GetLongWord(X) +#define NAMETABLE LispPTR +#else +#define NT_OFFSET_MASK 0xFF +#define NT_TYPE_MASK 0xFF00 +#define GetNTEntry(X) GETWORD(X) +#define NAMETABLE DLword +#endif + +/************************************************************************* + N_OP_fvarn + entry of OPCODE[120b-127b]: FVAR, FVARX + + 1. save TopOfStack to evaluation stack. + 2. set address of searching FVAR slot to chain. + 3. call lookfor. (It sets some content to FVAR slot) + 4. get some address by caluculation of content of FVAR slot. + 5. set the address to TopOfStack. +**************************************************************************/ +LispPTR N_OP_fvarn(register int n) + /* n is word offset */ + + { + register DLword *chain; /* keep FVAR slot2 in CurrentFrameExtension */ + + chain = PVar + n; + + if(WBITSPTR(chain)->LSB) + { + /* check 15bit of FVAR slot1 in CurrentFrameExtension. + 0: bound + 1: unbound */ + nfvlookup(CURRENTFX, chain, FuncObj); + } + + return(GetLongWord(Addr68k_from_LADDR(POINTERMASK & + (((GETBASEWORD(chain,1))<<16) | + GETBASEWORD(chain,0))))); + } + + + + +/************************************************************************** + nfvlookup: + + This routine is used by only OP_fvarn. + ( in addition to N_OP_fvar_() ) + 1. get Atom index number of target fvar slot. + 2. call fvlookfor. + +****************************************************************************/ +nfvlookup(struct frameex1 *apframe1, register DLword *achain, register struct fnhead *apfnhead1) + /* pointer to current frame extension */ + /* pointer to 1st word of the searching + FVAR slot in CurrentFrameExtension */ + /* pointer to current function heaer */ + { + register DLword *pfh; /* pointer to current function header */ + register int paoffset; /* 2word offset in PVAR AREA */ + + pfh = (DLword *)apfnhead1; + paoffset = ((UNSIGNED)achain - (UNSIGNED)PVar)>>2; + /* slot to looked for, 2word offset from PVar */ +#ifdef BIGATOMS + nnewframe(apframe1, achain, + (*((LispPTR *) + ((DLword *)pfh + apfnhead1->fvaroffset) + paoffset + - apfnhead1->nlocals))); +#else + nnewframe(apframe1, achain, + (GETWORD(pfh + (apfnhead1->fvaroffset + paoffset - + apfnhead1->nlocals)))); +#endif + } + + +/****************************************************************************** + +N_OP_stkscan + entry STKSCAN OPCODE[057] + + <> + TopOfStack: Low word - Atom index number of variable to be saned. + <> + TopOfStack: Address of found value. + + 1. call fvlookup. + 2. Set *chain to TopOfStack. + 3. Increment Pc by 1. + +******************************************************************************/ + +LispPTR N_OP_stkscan(LispPTR tos) +{ +#ifdef I386 + int scratchx[3]; + int *scratch = (int *)(0xFFFFFFFC & (3+(UNSIGNED)scratchx)); + *scratch = tos; + nnewframe(CURRENTFX, (DLword *)scratch, POINTERMASK & *scratch ); + return(swapx(*scratch)); +#else + int scratch; + scratch = tos; + nnewframe(CURRENTFX, (DLword *)&scratch, POINTERMASK & scratch ); + return(swapx(scratch)); +#endif /* I386 */ + + } + + + + +/************************************************** +N_OP_fvar_ + + Entry: FVAR_ opcode[0143] + + +***************************************************/ + +LispPTR N_OP_fvar_(register LispPTR tos, register int n) +{ + register DLword *ppvar; /* pointer to argued Fvar slot in pvar area */ + register DLword *pfreeval; /* pointer to argued free value */ + register int l1; /* return value of fvlookup() */ + + ppvar = PVar + n; + + if(WBITSPTR(ppvar)->LSB) /* check unbound ? */ + { /* unbound */ + nfvlookup(CURRENTFX, ppvar, FuncObj); + } + + pfreeval =Addr68k_from_LADDR( MaskShift((GETWORD(ppvar+1))) | + GETWORD(ppvar) ); + + if( ((0xFF & GETWORD(ppvar+1)) != STK_HI)) + { + GCLOOKUP(*((LispPTR *)pfreeval), DELREF); + GCLOOKUP(tos, ADDREF); + } + + *((LispPTR *)pfreeval) = tos; + return(tos); + } + +#define FVSTACK 2 +#define FVGLOBAL 6 + +#ifdef BIGATOMS +#define FVIVARHI 0x0 +#define FVPVARHI (0x80000000) +#define FVFVARHI (0xC0000000) +#else +#define FVIVARHI 0x0 +#define FVPVARHI 0x8000 +#define FVFVARHI 0xC000 +#endif + +#define ENDSTACKMARK 0xb + + + + +/****************************************************************************** +nnewframe + + This routine is used by fvlookup and OP_stkscan. + + 1. scan Name table in new function header. + 2. if found, set address of searching variable to chain address. + 3. return the type of var, on stack, or global. (fs: unused, removed) + +******************************************************************************/ + +nnewframe(register struct frameex1 *newpfra2, register DLword *achain, register int name) + /* pointer to new frame extension */ + /* pointer to 1st word of the searching + FVAR slot in CurrentFrameExtension */ + /* Atom index num. of target FVAR slot. */ + { + + register NAMETABLE *pindex; /* '90/06/06 osamu changed from DLword * + * index to indexs of new name table */ + register UNSIGNED i; /* temp for control */ + register int nametablesize; /* NameTable size of current function header. */ + register int ph; /* alink temp, also phase */ +struct frameex1 *onewpfra2, *oonewpfra2, *ooonewpfra2; + + newframe: +#ifdef SUN3_OS3_OR_OS4_IL + newframe_setup_label(); +#endif + /* assume that apframe1 points to the next frame to be scanned */ + ph = newpfra2->alink; +if (ph==0) error("alink = 0 in nnewframe"); + if(ph == ENDSTACKMARK) + { + /* endStack */ +#ifdef BIGATOMS + if ((name&SEGMASK) != 0) /* New symbol */ + { + register int result = name+NEWATOM_VALUE_OFFSET; + /* printf("NEW-SYMBOL in nnewframe, 0x%x, result = 0x%x\n", name, result); */ + GETBASEWORD(achain,1) = result>>16; + GETBASEWORD(achain,0) = result & 0xFFFF; + } + else +#endif /* BIGATOMS */ + +#ifdef BIGVM + if (name & SEGMASK) + { /* It's a big-atom, so just offset from the base to get value */ + register int result = name + NEWATOM_VALUE_OFFSET; + GETBASEWORD(achain,1) = result>>16; + GETBASEWORD(achain,0) = result & 0xFFFF; + } + else + { /* It's an "old" atom, so offset into the table of atoms */ + register int result = (ATOMS_HI << 16) + (10*name) + NEWATOM_VALUE_OFFSET; + GETBASEWORD(achain,1) = result>>16; + GETBASEWORD(achain,0) = result & 0xFFFF; + } +#else + if(name >= 0x8000) + { + GETBASEWORD(achain,1) = VALS_HI + 1; + GETBASEWORD(achain,0) = name*2; + } + else + { + GETBASEWORD(achain,1) = VALS_HI; + GETBASEWORD(achain,0) = name*2; + } +#endif /* BIGVM */ + return; + } + + ph &= 0xFFFE; /* to mask off SLOW bit */ +ooonewpfra2 = oonewpfra2; +oonewpfra2 = onewpfra2; +onewpfra2 = newpfra2; + newpfra2 = (struct frameex1 *)(-FRAMESIZE + Stackspace + ph); + + { /* open new block to try and conserve address register */ + register struct fnhead *newpfn2; /* ptr to new fn header */ + + if(newpfra2->validnametable) /* check VALIDNAMETABLE */ +#ifdef BIGVM + newpfn2 = (struct fnhead *) + (Addr68k_from_LADDR(newpfra2->nametable)); + else + newpfn2 = (struct fnhead *) + (Addr68k_from_LADDR(newpfra2->fnheader)); +#else + newpfn2 = (struct fnhead *) + (Addr68k_from_LADDR(((newpfra2->hi2nametable)<<16 | + newpfra2->lonametable ))); + else + newpfn2 = (struct fnhead *) + (Addr68k_from_LADDR(((newpfra2->hi2fnheader)<<16 | + newpfra2->lofnheader ))); +#endif /* BIGVM */ + pindex = (NAMETABLE *)((DLword *)newpfn2 + FNHEADSIZE); + /* now pindex points 1st word of Nametable. */ +#ifdef BIGATOMS + nametablesize = (newpfn2->ntsize >> 1); /* ntsize is # of words in NT + not # of element */ +#else + nametablesize = newpfn2->ntsize; +#endif + } +#ifdef SUN3_OS3_OR_OS4_IL + newframe_loop_label(); +#endif + + i = (UNSIGNED) (pindex + nametablesize); + for(; (UNSIGNED)i > (UNSIGNED) pindex;) + { /* searching in NewFuncHeader */ +#ifdef BIGATOMS + /* These used to be GETWORDs, but NAMETABLE is a CELL in 3-byte */ +#if 1 + if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=1; goto foundit;} +cont2: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=0; goto foundit;} +#else + if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=1; goto foundit;} +cont2: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=2; goto foundit;} +cont3: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=3; goto foundit;} +cont4: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=0; goto foundit;} +#endif /* ISC */ + +#else + if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=1; goto foundit;} +cont2: if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=2; goto foundit;} +cont3: if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=3; goto foundit;} +cont4: if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=0; goto foundit;} +#endif + continue; +foundit: + { + register int fvartype; /* probing fvar vartype */ + register int fvaroffset; /* probing fvar varoffset */ + register DLword *ppvar; /* ptr to probing var candidate */ +#ifdef BIGATOMS + fvartype = (int) *(pindex + nametablesize - 1); +#else + fvartype = GETWORD(pindex + nametablesize - 1); +#endif /* BIGATOMS */ + + fvaroffset = NT_OFFSET_MASK & fvartype; + fvaroffset <<= 1; + fvartype &= NT_TYPE_MASK; + switch( fvartype ) + { + case FVPVARHI: /* 0x8000 or 0x80000000(BIGATOMS) */ + ppvar = FRAMESIZE+(DLword *)newpfra2+fvaroffset; + /* ppvar points to argued Pvar */ + if(WBITSPTR(ppvar)->xMSB) + /* check UNBOUND (if *ppvar is negative , unbound) */ + switch ( ph ) + { + case 0 : continue; + case 1 : goto cont2; + /* case 2 : goto cont3; + case 3 : goto cont4; */ + } + GETBASEWORD(achain,1) = STK_HI; + GETBASEWORD(achain,0) = 0xFFFF & LADDR_from_68k(ppvar); + /* save High word of PVAR slot address to FVAR slot */ + /* achain points to target FVAR slot */ + return; + case FVFVARHI: /* 0xC000 or 0xC0000000(BIGATOMS) */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + if( WBITSPTR(ppvar)->LSB ) goto endlookfor; + /* Not Found in new FnHeader, scan next one. */ + *((int *)achain) = *((int *)ppvar); + /* save address of FX to FVAR slot */ + /* achain points to target FVAR slot */ + return; + case FVIVARHI: /* 0x000: */ + ppvar = -1 + (DLword *)newpfra2; + /* ppvar points to IVAR field in Basic frame */ + GETBASEWORD(achain,1) = STK_HI; + GETBASEWORD(achain,0) = GETWORD(ppvar) + fvaroffset; + return; + default:error("Stack corrupted: bad value in name table"); + }/* end switch */ + }/* end if */ + }/* end for */ + +endlookfor: + goto newframe; /* scan the next one */ + + } +#ifndef BIGATOMS +#ifdef SUN3_OS3_OR_OS4_IL + +#define VALS_HI_RET(x) newframe_vals_hi_ret(x) +#define STK_HI_RET(x) newframe_stk_hi_ret(x) + +#else + +#define VALS_HI_RET(x) \ + ((int) x << 17) + VALS_HI + ((unsigned short) x >> 15) + +#define STK_HI_RET(x) \ + ((int) x << 16) | 1 | ((unsigned int) x >> 16) + +#endif /* SUN3_IL */ + +#else + +#ifdef BIGVM +#define VALS_HI_RET(x) ((((int) x & SEGMASK) == 0) ? \ + (swapx((ATOMS_HI<<16) + (10 * (int) (x)) + NEWATOM_VALUE_OFFSET)) : \ + (swapx((int)x + NEWATOM_VALUE_OFFSET))) +#else +#define VALS_HI_RET(x) ((((int) x & SEGMASK) == 0) ? \ + (((int) x << 17) + VALS_HI + ((unsigned short) x >> 15)) : \ + (swapx((int)x + NEWATOM_VALUE_OFFSET))) +#endif /* BIGVM */ + +#define STK_HI_RET(x) ((int) x << 16) | 1 | ((unsigned int) x >> 16) + +#endif /* BIGATOMS */ + + + + + +/****************************************************************************** +native_newframe + + 1. scan Name table in new function header. + 2. if found, set address of searching variable to chain address. + 3. return the pointer + +******************************************************************************/ +native_newframe(int slot) + /* index of FVAR slot. */ + { + register struct frameex2 *newpfra2; /* pointer to new frame extension */ + register DLword *achain; /* pointer to 1st word of the searching + FVAR slot in CurrentFrameExtension */ + register int name; /* Atom# of target FVAR slot. */ +struct frameex2 *onewpfra2, *oonewpfra2, *ooonewpfra2; + + { /* LOCAL temp regs */ + register int rslot = slot; + register struct fnhead *fnobj = FuncObj; + register LispPTR *pvar = (LispPTR *) PVar; + +#ifdef BIGATOMS + name = (int) *((LispPTR *) + ((DLword *)fnobj + fnobj->fvaroffset) + + rslot - fnobj->nlocals); +#else + name = GETWORD((DLword *)fnobj + + (fnobj->fvaroffset + rslot - fnobj->nlocals)); +#endif + + newpfra2 = (struct frameex2 *) ((DLword *) pvar - FRAMESIZE); + achain = (DLword *) (pvar + rslot); + + } + + { + register NAMETABLE *pindex; /* index to indexs of new name table */ + register int i; /* temp for control */ + register int nametablesize; /* NameTable size of current fnhdr */ + register int alink; + +natnewframe: +#ifdef SUN3_OS3_OR_OS4_IL + natnewframe_label(); +#endif + /* assume that apframe1 points to the next frame to be scanned */ + + alink = newpfra2->alink; +if (alink == 0) error("alink is 0 in native_newframe"); + if(alink == ENDSTACKMARK) + { /* End of stack, so return top-level-value */ +/* if (name & SEGMASK) printf("native_newframe returning name 0x%x, result 0x%x.\n", + name, VALS_HI_RET(name)); */ + return(*((LispPTR *)achain) = VALS_HI_RET(name)); + } +ooonewpfra2 = oonewpfra2; +oonewpfra2 = onewpfra2; +onewpfra2 = newpfra2; + newpfra2 = (struct frameex2 *)(-FRAMESIZE + Stackspace + (alink & 0xFFFE)); + + + { /* open new block to try and conserve address register */ + register struct fnhead *newpfn2; /* ptr to new fn header */ + + newpfn2 = GETNAMETABLE(newpfra2); + + pindex = (NAMETABLE *)(((DLword *)newpfn2) + FNHEADSIZE); + /* now pindex points 1st word of Nametable. */ +#ifdef BIGATOMS + nametablesize = (newpfn2->ntsize >> 1); /* ntsize is # of words in NT + nametablesize is # of items in NT */ +#else + nametablesize = newpfn2->ntsize; +#endif /* */ + + } +#ifdef SUN4_OS4_IL + + i = (UNSIGNED) (pindex + nametablesize); +lookup: +#ifdef BIGATOMS + pindex = (LispPTR *) name_scan2((UNSIGNED)pindex, i, name); +#else + pindex = (DLword *) name_scan((UNSIGNED)pindex, i, name | (name<<16)); +#endif + if (!pindex) goto natnewframe; + { + { +#else +#ifdef SUN3_OS3_OR_OS4_IL + + i = nametablesize; + if (--i < 0) goto natnewframe; + + + /* **** assumes: + d7 = name + d6 = i + a3 = pindex + *** */ +#ifdef BIGATOMS +lookup: fvar_lookup_loop2(); +#else +lookup: fvar_lookup_loop(); +#endif +{ +{ +#else + + for(i=nametablesize; --i >= 0;){ + /* searching in NewFuncHeader */ +#ifdef BIGATOMS + if((LispPTR) *((NAMETABLE *)pindex++) == (LispPTR)name){ +#else + if(GETWORD((NAMETABLE *)pindex++) == (DLword)name){ +#endif /* BIGATOMS */ + +#endif +#endif + + register int fvartype; /* probing fvar vartype */ + register int fvaroffset; /* probing fvar varoffset */ + register DLword *ppvar; /* ptr to probing var candidate */ +#ifdef BIGATOMS + fvartype = (int) *(pindex + nametablesize - 1); +#else + fvartype = GETWORD(pindex + nametablesize - 1); +#endif /* BIGATOMS */ + + fvaroffset = (NT_OFFSET_MASK & fvartype) << 1; + fvartype &= NT_TYPE_MASK; + switch( fvartype ){ + case FVPVARHI: /* 0x8000 or 0x80000000(NEWATOM): */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + /* ppvar points to argued Pvar */ + if(WBITSPTR(ppvar)->xMSB) + /* check UNBOUND (if *ppvar is negative , unbound) */ +#ifdef SUN4_OS4_IL + goto lookup; +#else +#ifdef SUN3_OS3_OR_OS4_IL + goto lookup; +#else + { + continue; + } +#endif +#endif + /* save High word of PVAR slot address to FVAR slot */ + /* achain points to target FVAR slot */ + return(*((LispPTR *)achain) = + STK_HI_RET( LADDR_from_68k( ppvar ))); + case FVFVARHI: /* 0xC000 or 0xC0000000(NEWATOM S) */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + if( WBITSPTR(ppvar)->LSB ) + { + goto endlookfor; + } + /* Not Found in new FuncHeader, scan next one. */ + /* save address of frame extension to FVAR slot */ + /* achain points to target FVAR slot */ + return(*((int *)achain) = *((int *)ppvar)); + case FVIVARHI: /* 0x0000000: */ + ppvar = (DLword *)newpfra2 - 1; + /* ppvar points to IVAR field in Basic frame */ + return(*((LispPTR *)achain) = + STK_HI_RET(GETWORD(ppvar)+fvaroffset));; + default:error("Stack corrupted: bad value in name table"); + }/* end switch */ + }/* end if */ + }/* end for */ + +endlookfor: + goto natnewframe; /* scan the next one */ +} +} diff --git a/src/gc.c b/src/gc.c new file mode 100755 index 0000000..c6c10f4 --- /dev/null +++ b/src/gc.c @@ -0,0 +1,52 @@ +/* $Id: gc.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gc.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "gc.h" + +/************************************************************ + + entry OP_gcref OPCODE[025] + + 1. alpha is ADDREF or DELREF, STKREF. + TopOfStack is argued slot address. + 2. call gclookup with alpha and TopOfStack. + 3. if stk=0 and refcnt=0 of entry of HashMainTable, + TopOfStack left alone. + else replace TopOfStack with 0. + 4. increment PC by 2. + +***********************************************************/ + +OP_gcref(void) +{ +#ifdef TRACE + printPC(); + printf("TRACE:OP_gcref()\n"); +#endif + GCLOOKUPV(TopOfStack, Get_code_BYTE(PC+1), TopOfStack); + PC+=2; + return; +} + diff --git a/src/gc2.c b/src/gc2.c new file mode 100755 index 0000000..b4835bd --- /dev/null +++ b/src/gc2.c @@ -0,0 +1,96 @@ +/* $Id: gc2.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gc2.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/**********************************************************************/ +/* + File Name: gc2.c + Desc: implement opcode SCAN1,SCAN2,GCRECLAIMCELL + + + Including : OP_scan1 + OP_scan2 + OP_gcreccell + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "emlglob.h" +#include "address.h" +#include "adr68k.h" + +#ifdef GCC386 +#include "inlnPS2.h" +#endif /* GCC386 */ + + + + + +/**********************************************************************/ +/* + Func Name : OP_gcscan1 +*/ +/**********************************************************************/ + +OP_gcscan1(void) +{ + DLword gcscan1(register int probe); + +#ifdef TRACE + printPC(); + printf("TRACE: OP_gcscan1()\n"); +#endif + if((TopOfStack & SEGMASK)==S_POSITIVE) + { + TopOfStack=gcscan1(LOLOC(TopOfStack)); + } + if(TopOfStack != NIL) TopOfStack |= S_POSITIVE ; + PC++; + } /* OP_gcscan1 end */ + + + + +/**********************************************************************/ +/* + Func Name : OP_gcscan2 +*/ +/**********************************************************************/ + +OP_gcscan2(void) +{ + DLword gcscan2(register int probe); + +#ifdef TRACE + printPC(); + printf("TRACE: OP_gcscan2()\n"); +#endif + if((TopOfStack & SEGMASK)==S_POSITIVE) + { + TopOfStack=gcscan2(LOLOC(TopOfStack)); + } + if(TopOfStack != NIL) TopOfStack |= S_POSITIVE ; + PC++; + } /* OP_gcscan2 end */ + diff --git a/src/gcarray.c b/src/gcarray.c new file mode 100755 index 0000000..60bbf36 --- /dev/null +++ b/src/gcarray.c @@ -0,0 +1,371 @@ +/* $Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/*************************************************************************/ +/* */ +/* File Name : gcarray.c */ +/* */ +/*************************************************************************/ +/* */ +/* Functions : */ +/* LispPTR aref1(array, index); */ +/* DLword find_symbol(char_base,offset, */ +/* length,hashtbl); */ +/* DLword get_package_atom( */ +/* char_base,charlen,packname, */ +/* packlen,externalp); */ +/* */ +/* LispPTR with_symbol(charbase, charlen, */ +/* hashtable, result_fixp); */ +/* */ +/*************************************************************************/ +/* Description : */ +/* */ +/* The function "aref1" is the accessor of oned_array. */ +/* The functions "find_symbol" and "get_package_atom" are implemented */ +/* to access the atom through the package mechanism. */ +/* */ +/* with_symbol is a C subr implementation of LLPACKAGE's */ +/* WITH-SYMBOL macro: It returns as its result the symbol found, */ +/* or NIL if none, and in the result_fixp, -1 if not found. */ +/* */ +/*************************************************************************/ +/* \Tomtom */ +/*************************************************************************/ + + +#include "lispemul.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "stack.h" +#include "cell.h" +#include "ifpage.h" +#include "gc.h" +#include "array.h" +#include "debug.h" +#include "lispmap.h" + +/*** not currently used -FS + #define min(a,b) ((a > b)?b:a) + #define Trailer(ldatum,datum68) (ldatum+2*(datum68->arlen - ARRAYBLOCKTRAILERCELLS)) + #define BucketIndex(n) min(integerlength(n),MAXBUCKETINDEX) + #define FreeBlockChainN(n) ((POINTERMASK & *FreeBlockBuckets_word)+2*BucketIndex(n)) + ***/ + +#define Rehash_factor(hash,tablelen) \ + (((hash) % ((tablelen) - 2)) + 1) +#define Symbol_hash_reprobe(hash,rehashfactor,tablelen) \ + (((hash) + (rehashfactor)) % (tablelen)) +#define Entry_hash(strlen,sxhash) \ + (((((((strlen)^(sxhash))^((sxhash) >> 8)) \ + ^((sxhash) >> 16))^((sxhash) >> 19)) % 254) + 2) + +/************************************************************************/ +/* */ +/* Package hashtable structure */ +/* */ +/* 2 per package, for looking up internal and external symbols. */ +/* */ +/************************************************************************/ + +struct hashtable + { + LispPTR table; + LispPTR hash; + LispPTR size; + LispPTR free; + LispPTR deleted; + }; + + + + +/* The end of macros & structure for medley version */ + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR aref1(LispPTR array, int index) +{ + register LispPTR retval; + register LispPTR base; + register short typenumber; + register struct arrayheader *actarray; + + actarray = (struct arrayheader *)Addr68k_from_LADDR(array); + if (index >= actarray->totalsize) + { + printf("Invalid index in GC's AREF1: 0x%x\n", index); + printf(" Array size limit: 0x%x\n", actarray->totalsize); + printf(" Array ptr: 0x%x\n", (UNSIGNED)array); + printf(" Array 68K ptr: 0x%x\n", (UNSIGNED) actarray); + printf("base: 0x%x\n", actarray->base); + printf("offset: 0x%x\n", actarray->offset); + printf("type #: 0x%x\n", actarray->typenumber); + printf("fill ptr: 0x%x\n", actarray->fillpointer); + error("index out of range in GC's AREF1."); + } + index += actarray->offset; + typenumber = actarray->typenumber; + base = actarray->base; + switch(typenumber) + { + case 3: /* unsigned 8bits */ + /* the following code confuses the Apollo compiler; */ + /* its equivalent doesn't */ +#ifndef APOLLO + retval = (GETBYTE(((char *)Addr68k_from_LADDR(base)) + + index)) & 0x0ff; +#else + { + register char *eightbitbase = + (char *)Addr68k_from_LADDR(base); + retval = GETBYTE(eightbitbase + index) & 0xff; + } +#endif + retval |= S_POSITIVE; + break; + case 4: /* unsigned 16bits */ + retval = (GETWORD(((DLword *)Addr68k_from_LADDR(base)) + + index)) & 0x0ffff; + retval |= S_POSITIVE; + break; + case 38: + retval = (*(((LispPTR *)Addr68k_from_LADDR(base)) + + index)); + break; + default: error("Not Implemented in gc's aref1 (other types)"); + }; + return(retval); + } + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR find_symbol(char *char_base, DLword offset, DLword length, LispPTR hashtbl, DLword fatp, DLword lispp) + + + + + /* T => the "chars" coming in are 16-bit */ + /* T => the incoming chars are in LISP space */ + { + DLword hashval, ehashval, h2, ehash, indexvar; + int arraylen; + struct hashtable *hashtbladdr; +#ifdef BIGATOMS + LispPTR vecs, hashes; +#endif /* BIGATOMS */ + + LispPTR vec,hash; + struct arrayheader *vec68k; + int fatpnamep; + + if (!hashtbl) return(0xffffffff); + + if (lispp) hashval = compute_lisp_hash(char_base, offset, length, fatp); + else hashval = compute_hash(char_base, offset, length); + + ehashval = Entry_hash(length, hashval); + hashtbladdr = (struct hashtable *)Addr68k_from_LADDR(hashtbl); + + /* Move our string ptr up by offset, allowing for fatness */ + if (fatp) char_base += (offset << 1); else char_base += offset; + + +#ifdef BIGATOMS + vecs = hashtbladdr->table; + hashes = hashtbladdr->hash; + +loop_thru_hashtables: + + vec = car(vecs); + vecs = cdr(vecs); + hash = car(hashes); + hashes = cdr(hashes); + vec68k = (struct arrayheader *)Addr68k_from_LADDR(vec); + arraylen = vec68k->totalsize; + if(arraylen==0) return(0xffffffff);/*kludge TAKE*/ + h2 = Rehash_factor(hashval, arraylen); + indexvar = (hashval % arraylen); +#else + vec = hashtbladdr->table; + hash = hashtbladdr->hash; + vec68k = (struct arrayheader *)Addr68k_from_LADDR(vec); + arraylen = vec68k->totalsize; + if(arraylen==0) return(0xffffffff);/*kludge TAKE*/ + h2 = Rehash_factor(hashval, arraylen); + indexvar = (hashval % arraylen); +#endif /* BIGATOMS */ + + +retry: + /* the aref1 returns a smallp, which is always <256, so trim it */ + while (ehashval != (ehash = 0xFF & aref1(hash, indexvar))) + { + if(ehash==NIL) + { /* Ran out of entries in this table; try next or fail */ +#ifdef BIGATOMS + if (hashes == NIL) return(0xffffffff); /* Last table. Fail. */ + goto loop_thru_hashtables; +#else + return(0xffffffff); +#endif /* BIGATOMS */ + + } + indexvar = Symbol_hash_reprobe(indexvar, h2, arraylen); + } + /* if ((indexvar&0xffff) != NIL) */ + { + LispPTR index; + PNCell *pnptr; + char *pname_base; + + index = aref1(vec, indexvar); + if ((index & SEGMASK) == S_POSITIVE) index &= 0xFFFF; + + pnptr = (PNCell *)GetPnameCell(index); + fatpnamep = ((PLCell *)GetPropCell(index))->fatpnamep; + pname_base= (char *)Addr68k_from_LADDR(pnptr->pnamebase); + if((length == GETBYTE(pname_base)) && + (T == ((lispp) ? + compare_lisp_chars((pname_base+1+fatpnamep), char_base, + length, fatpnamep, fatp) : + compare_chars((pname_base+1+fatpnamep), char_base, length))) ) + { + return(index); + } + else + { + indexvar = Symbol_hash_reprobe(indexvar, h2, arraylen); + goto retry; + } + } + /* else return(0xffffffff); */ /* can't find */ + } + + + + +/************************************************************************/ +/* */ +/* g e t _ p a c k a g e _ a t o m */ +/* */ +/* Try to look up the given symbol in the given package. If */ +/* you find it, return the atom number. Otherwise, return -1. */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword packlen, int externalp) +{ + int packindex; + PACKAGE *packaddr; + LispPTR hashtbladdr; + LispPTR index; + extern LispPTR find_package_from_name(char *packname, int len); + + /* For convenience, recognize the common package nicknames: */ + + if (0 == strncmp(packname, "XCL", packlen)) + packindex = find_package_from_name("XEROX-COMMON-LISP",17); + else if (0 == strncmp(packname, "SI", packlen)) + packindex = find_package_from_name("SYSTEM",6); + else if (0 == strncmp(packname, "CL", packlen)) + packindex = find_package_from_name("LISP",4); + else if (0 == strncmp(packname, "XCLC", packlen)) + packindex = find_package_from_name("COMPILER",8); + +/**** else if (0 == strncmp(packname, "KEYWORD", packlen)) + packindex = 7;***/ + + else packindex=find_package_from_name(packname, packlen); + + if (packindex <0) + { + printf("getting package index is failed \n"); + return(0xffffffff); + } + +/* if (packindex != 7) Not necessary (Take)*/ + packaddr = (PACKAGE *)Addr68k_from_LADDR( + aref1(*Package_from_Index_word, packindex)); +/* else packaddr = (PACKAGE *)Addr68k_from_LADDR( + *Keyword_Package_word); */ +/* hashtbladdr = ((externalp == T)?(packaddr->EXTERNAL_SYMBOLS): + (packaddr->INTERNAL_SYMBOLS)); + return( find_symbol(char_base, 0, charlen, hashtbladdr, 0, 0) );*/ + + if ((index=find_symbol(char_base, 0, charlen,packaddr->EXTERNAL_SYMBOLS, 0, 0)) != + 0xffffffff) + return(index); + else + return(find_symbol(char_base, 0, charlen,packaddr->INTERNAL_SYMBOLS, 0, 0)); + +} + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR with_symbol(LispPTR char_base, LispPTR offset, LispPTR charlen, LispPTR fatp, LispPTR hashtbl, LispPTR result) +{ + char * charbase68k = (char *) Addr68k_from_LADDR(char_base); + LispPTR *resultptr = (LispPTR *) Addr68k_from_LADDR(result); + DLword chars = charlen & 0xFFFF; /* charlen must be a SMALLP! */ + DLword offst = offset & 0xFFFF; + int symbol; /* Where the symbol goes pro tem */ + + symbol = find_symbol(charbase68k, offst, chars, hashtbl, (DLword)fatp, (DLword)1); + + if (symbol == -1) + { /* Not found. Signal that with -1 in result fixp */ + *resultptr = -1; + return(NIL); + } + + *resultptr = 3; + return(symbol); + + } /* End of with_symbol */ diff --git a/src/gccode.c b/src/gccode.c new file mode 100755 index 0000000..f8cb0b4 --- /dev/null +++ b/src/gccode.c @@ -0,0 +1,390 @@ +/* $Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +/************************************************************************/ +/* File Name : gccode.c */ +/* */ +/************************************************************************/ +/* */ +/* Creation Date : Sep-25-1987 */ +/* Written by Tomoru Teruuchi */ +/* Edit by Larry Masinter */ +/************************************************************************/ +/* */ +/* Functions : */ +/* reclaimcodeblock(); */ +/* */ +/* */ +/* */ +/************************************************************************/ +/* \Tomtom */ +/************************************************************************/ + +#include "lispemul.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "lispmap.h" +#include "stack.h" +#include "cell.h" +#include "ifpage.h" +#include "gc.h" +#include "array.h" + +#define min(a,b) ((a > b)?b:a) + + +#define ENDOFX 0 +#define GCONST 111 + +#define Reprobefn(bits, index) (((bits^((bits) >> 8)) & min(63, index)) | 1) +#define Fn16bits(a, b) ((a + b) & 0x0ffff) +#define Hashingbits(item) (HILOC(item)^( \ + ((LOLOC(item) & 0x1fff) << 3)^(LOLOC(item) >> 9))) +#define Getikvalue(base, index) \ + (*( LispPTR *)Addr68k_from_LADDR(base + (index << 1))) + +#ifndef BYTESWAP +typedef +struct implicit_key_hash_table { + LispPTR base; + unsigned last_index : 16; + unsigned num_slots : 16; + unsigned num_keys : 16; + unsigned null_slots : 16; + LispPTR key_accessor; +} Ikhashtbl; +#else +typedef +struct implicit_key_hash_table { + LispPTR base; + unsigned num_slots : 16; + unsigned last_index : 16; + unsigned null_slots : 16; + unsigned num_keys : 16; + LispPTR key_accessor; +} Ikhashtbl; +#endif + + +#ifdef BIGVM +/* Table of opcode lengths for 4-byte atom opcode cases */ +#define LONGEST_OPCODE 5 +unsigned int oplength[256] = { +0,0,0,0,0,1,4,2, +4,4,4,4,4,5,0,0, +0,2,0,0,1,1,0,4, +0,0,0,0,0,0,1,0, +0,0,0,1,2,9,0,0, +9,9,9,9,0,0,0,0, +1,1,1,1,0,0,0,0, +1,1,0,0,1,1,0,0, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +4,0,1,1,0,0,0,4, +0,0,0,0,1,1,2,4, +9,0,0,0,0,0,0,0, +1,1,0,0,0,2,0,4, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +1,2,1,1,1,1,0,0, +0,0,0,0,0,0,0,0, +1,1,0,4,0,1,1,0, +1,1,2,9,0,1,1,2, +0,0,0,0,0,0,0,0, +0,0,0,0,0,1,1,0, +0,0,0,0,0,0,0,0, +0,0,0,0,1,1,0,0, +0,0,0,0,0,0,0,0, +1,0,1,1,0,0,0,0 +}; +#elif defined(BIGATOMS) +/* Table of opcode lengths for 3-byte atom opcode cases */ +#define LONGEST_OPCODE 4 +unsigned int oplength[256] = { +0,0,0,0,0,1,3,2, +3,3,3,3,3,4,0,0, +0,2,0,0,1,1,0,3, +0,0,0,0,0,0,1,0, +0,0,0,1,2,9,0,0, +9,9,9,9,0,0,0,0, +1,1,1,1,0,0,0,0, +1,1,0,0,1,1,0,0, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +3,0,1,1,0,0,0,3, +0,0,0,0,1,1,2,3, +9,0,0,0,0,0,0,0, +1,1,0,0,0,2,0,3, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +1,2,1,1,1,1,0,0, +0,0,0,0,0,0,0,0, +1,1,0,3,0,1,1,0, +1,1,2,9,0,1,1,2, +0,0,0,0,0,0,0,0, +0,0,0,0,0,1,1,0, +0,0,0,0,0,0,0,0, +0,0,0,0,1,1,0,0, +0,0,0,0,0,0,0,0, +1,0,1,1,0,0,0,0 +}; +#else +/* Table of opcode lengths for old, 2-byte atom opcodes. */ +#define LONGEST_OPCODE 3 +unsigned int oplength[256] = { +0,0,0,0,0,1,2,2, +2,2,2,2,2,3,0,0, +0,2,0,0,1,1,0,2, +0,0,0,0,0,0,1,0, +0,0,0,1,2,9,0,0, +9,9,9,9,0,0,0,0, +1,1,1,1,0,0,0,0, +1,1,0,0,1,1,0,0, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +0,0,0,0,0,0,0,1, +2,0,1,1,0,0,0,2, +0,0,0,0,1,1,2,3, +9,0,0,0,0,0,0,0, +1,1,0,0,0,2,0,3, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0, +1,2,1,1,1,1,0,0, +0,0,0,0,0,0,0,0, +1,1,0,2,0,1,1,0, +1,1,2,9,0,1,1,2, +0,0,0,0,0,0,0,0, +0,0,0,0,0,1,1,0, +0,0,0,0,0,0,0,0, +0,0,0,0,1,1,0,0, +0,0,0,0,0,0,0,0, +1,0,1,1,0,0,0,0 +}; +#endif /* BIGATOMS */ + + +typedef ByteCode *InstPtr; + + + +/************************************************************************/ +/* */ +/* m a p _ c o d e _ p o i n t e r s */ +/* */ +/* Find all pointers in a block of compiled code (they're the */ +/* the args to the GCONST opcode), and change the reference */ +/* count according to "casep". Complains if it hits an unknown */ +/* opcode. */ +/* */ +/************************************************************************/ + +map_code_pointers(LispPTR codeblock, short int casep) +{ + InstPtr codeptr; + register unsigned int opnum; + register unsigned int len; + struct fnhead *fnbase; + fnbase = (struct fnhead *) Addr68k_from_LADDR(codeblock); + codeptr = ((InstPtr) fnbase) + fnbase->startpc; + +#ifdef RESWAPPEDCODESTREAM + if (!fnbase->byteswapped) byte_swap_code_block(fnbase); +#endif + + while (T) + { + switch (opnum=Get_code_BYTE(codeptr)) + { + case ENDOFX: /* -X- */ + return (NIL); + case GCONST: /* GCONST */ +#ifdef BIGVM + {LispPTR reclaimed = (Get_code_BYTE(codeptr + 1) << 24) | + (Get_code_BYTE(codeptr + 2) << 16) | + (Get_code_BYTE(codeptr + 3) << 8) | + Get_code_BYTE(codeptr + 4); +#else + {LispPTR reclaimed = (Get_code_BYTE(codeptr + 1) << 16) | + (Get_code_BYTE(codeptr + 2) << 8) | + Get_code_BYTE(codeptr + 3); +#endif /* BIGVM */ + if (reclaimed != codeblock) +/* {htfind(reclaimed, casep);} */ + {REC_GCLOOKUP(reclaimed, casep);} + }; + }; + if ((len = oplength[opnum]) > LONGEST_OPCODE) + { /* len > biggest possible marks an unknown opcode */ + char errtext[200]; + sprintf(errtext, + "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use UFN length", opnum, codeptr-(InstPtr)fnbase, (codeblock>>16)&0xFF, codeblock&0xFFFF); + error(errtext); + oplength[opnum] = len =(((UFN *)UFNTable) + (opnum))->byte_num; + } + codeptr += len + 1; + }; +} + + + +/************************************************************************/ +/* */ +/* r e m i m p l i c i t k e y h a s h */ +/* */ +/* Remove a fn defn from the implicit-key hash table of defns */ +/* */ +/************************************************************************/ + +/* JRB - These values are xpointers; their high bytes are not set and + shouldn't be looked at */ +#define getikkey(value) ((*(LispPTR *)Addr68k_from_LADDR(value)) & POINTERMASK) + +LispPTR remimplicitkeyhash(LispPTR item, LispPTR ik_hash_table) +{Ikhashtbl *ik_htable; + LispPTR reprobe, bits, limits, index, + base, value, key_accessor; + ik_htable = (Ikhashtbl *)Addr68k_from_LADDR(ik_hash_table); + bits = Hashingbits(item); + limits = ik_htable->last_index; + index = (bits & limits); + base = ik_htable->base; + value = Getikvalue(base, index); + if (value != *Deleted_Implicit_Hash_Slot_word) + { if (value != NIL) + {if (item == + getikkey(value)) + {goto found;}; + } + else + return(NIL); + }; + reprobe = Reprobefn(bits, limits); + lp: + index = Fn16bits(index, reprobe) & limits; + value = Getikvalue(base, index); + if (value != *Deleted_Implicit_Hash_Slot_word) + { if (value != NIL) + {if (item == + getikkey(value)) + {goto found;}; + } + else + return(NIL); + }; + goto lp; + found: +/* + htfind(*Deleted_Implicit_Hash_Slot_word, ADDREF); + htfind(Getikvalue(base, index), DELREF); +*/ + REC_GCLOOKUP(*Deleted_Implicit_Hash_Slot_word, ADDREF); + REC_GCLOOKUP(Getikvalue(base, index), DELREF); + Getikvalue(base, index) = *Deleted_Implicit_Hash_Slot_word; + (ik_htable->num_keys)--; + return (T); +} + + + + +/************************************************************************/ +/* */ +/* r e c l a i m c o d e b l o c k */ +/* */ +/* Reclaim an array block that contains compiled code. When */ +/* this happens, we need to decrement the reference counts for */ +/* */ +/* * The frame name, which may be a string, list, etc. */ +/* * Any GCONSTs in the code (constants, internal fns, */ +/* etc.), since they're no longer needed. */ +/* */ +/************************************************************************/ + +LispPTR reclaimcodeblock(LispPTR codebase) +{ struct fnhead *fnbase; + if ((*Closure_Cache_Enabled_word != NIL) && + (remimplicitkeyhash(codebase, *Closure_Cache_word) != NIL)) + { return(T); + }; + fnbase = (struct fnhead *)Addr68k_from_LADDR(codebase); + REC_GCLOOKUP((POINTERMASK & fnbase->framename), DELREF); + if (fnbase->startpc != 0) map_code_pointers(codebase,DELREF); + return(NIL); + } + + + + +/************************************************************************/ +/* */ +/* c o d e _ b l o c k _ s i z e */ +/* */ +/* Given a native pointer to a code block, return its size. */ +/* */ +/************************************************************************/ + +code_block_size(long unsigned int codeblock68k) +{ + InstPtr codeptr, initcodeptr; + register unsigned int opnum; + register unsigned int len; + struct fnhead *fnbase; + fnbase = (struct fnhead *) codeblock68k; + initcodeptr = codeptr = ((InstPtr) fnbase) + fnbase->startpc; + while (T) + { + switch (opnum=Get_BYTE(codeptr)) + { + case ENDOFX: /* -X- */ + return (codeptr-initcodeptr); + }; + if ((len = oplength[opnum]) > LONGEST_OPCODE) + { /* len > biggest possible marks an unknown opcode */ + char errtext[200]; + sprintf(errtext, + "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use UFN length", opnum, codeptr-(InstPtr)fnbase, (codeblock68k>>16)&0xFF, codeblock68k&0xFFFF); + error(errtext); + oplength[opnum] = len =(((UFN *)UFNTable) + (opnum))->byte_num; + } + codeptr += len + 1; + }; +} diff --git a/src/gcfinal.c b/src/gcfinal.c new file mode 100755 index 0000000..d488229 --- /dev/null +++ b/src/gcfinal.c @@ -0,0 +1,628 @@ +/* $Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/*************************************************************************/ +/*************************************************************************/ +/* */ +/* File Name : gcfinal.c */ +/* */ +/*************************************************************************/ +/* */ +/* */ +/* Functions : */ +/* reclaimstackp(); */ +/* reclaimarrayblock(ptr); */ +/* reclaimcodeblock() is in another file */ +/* releasingvmempage(); */ +/* deleteblock(); */ +/* linkblock(); */ +/* mergeforward(); */ +/* mergebackward(); */ +/* arrayblockmerger(); */ +/* checkarrayblock(); */ +/* findptrsbuffer(); */ +/* */ +/* */ +/* */ +/*************************************************************************/ +/* Description : */ +/* */ +/* */ +/* */ +/*************************************************************************/ +/* \Tomtom */ +/*************************************************************************/ + +#include "lispemul.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "stack.h" +#include "cell.h" +#include "ifpage.h" +#include "gc.h" +#include "array.h" + +#ifdef NEVER +#define GetSegnuminColl(entry1) ((entry1 & 0x01fe) >> 1) /* segnum field */ +#define GetLinkptr(entry) (entry & 0x0fffe) +#define GetCountinColl(entry1) ((entry1 & 0x0fc00) >> 10) +#define Oddp(num) (((num % 2) != 0)?1:0) +#define Evenp(num) (((num % 2) != 0)?0:1) +#define STK_HI 1 /* This value also */ +#define WORDSPERCELL 2 +#define PADDING 4 +#define Boundp(frame_field) ((frame_field == 0)?1:0) +#endif /* NEVER */ + + +#define min(a,b) ((a > b)?b:a) +#define Trailer(ldatum,datum68) (ldatum+2*(datum68->arlen - \ + ARRAYBLOCKTRAILERCELLS)) +#define BucketIndex(n) min(integerlength(n),MAXBUCKETINDEX) +#define FreeBlockChainN(n) ((POINTERMASK & *FreeBlockBuckets_word)+ \ + 2*BucketIndex(n)) + +#ifndef BYTESWAP +#ifdef BIGVM +struct buf { + LispPTR filepage; + LispPTR vmempage; + LispPTR buffernext; + unsigned noreference :1; + unsigned usermapped :1; + unsigned iodirty :1; + unsigned unused :1; + unsigned sysnext :28; +}; +#else +struct buf { + LispPTR filepage; + LispPTR vmempage; + LispPTR buffernext; + unsigned noreference :1; + unsigned usermapped :1; + unsigned iodirty :1; + unsigned unused :5; + unsigned sysnext :24; +}; +#endif /* BIGVM */ +#else +struct buf { + LispPTR filepage; + LispPTR vmempage; + LispPTR buffernext; + unsigned sysnext :24; + unsigned unused :5; + unsigned iodirty :1; + unsigned usermapped :1; + unsigned noreference :1; +}; +#endif /* BYTESWAP */ + + +/************* The following procedure is common !! **************************/ + +integerlength(unsigned int n) +{int cnt; + if (n <= 2) + return(n); + else + {cnt = 1; + do + {cnt++; + n = (n >> 1); + }while(n != 1); + return(cnt); + }; +} + +/************* The above procedure is common !! **************************/ + + + +/************************************************************************/ +/* */ +/* f i n d p t r s b u f f e r */ +/* */ +/* Given a pointer to a VMEMPAGEP, see if it is pointed to by */ +/* any BUFFER. If so, return the BUFFER's pointer. Otherwise, */ +/* return NIL. */ +/* */ +/************************************************************************/ + +LispPTR findptrsbuffer(LispPTR ptr) +{ struct buf *bptr; + bptr = (struct buf *)Addr68k_from_LADDR(*System_Buffer_List_word); + while(LADDR_from_68k(bptr) != NIL) + {if (ptr == bptr->vmempage) + return(LADDR_from_68k(bptr)); + else bptr = (struct buf *)Addr68k_from_LADDR(bptr->sysnext);}; + return(NIL); +} + + + +/************************************************************************/ +/* */ +/* r e l e a s i n g v m e m p a g e */ +/* */ +/* Called when ptr, a VMEMPAGEP, is about to be reclaimed by the */ +/* GC. Returns T if it is NOT OK TO RECLAIM THE VMEMPAGEP. */ +/* Otherwise, returns NIL. It won't be OK to reclaim when */ +/* the VMEMPAGEP is being used as a buffer. */ +/* */ +/************************************************************************/ + +LispPTR releasingvmempage(LispPTR ptr) +{ + register struct buf *bptr; + register LispPTR bufferptr = findptrsbuffer(ptr); + + if (bufferptr == NIL) return(NIL); /* Not in use, OK to reclaim it */ + + bptr = (struct buf *)Addr68k_from_LADDR(bufferptr); + bptr->noreference = T; /* Mark the buffer free to use ?? */ + return(ATOM_T); + } + + + +/************************************************************************/ +/* */ +/* c h e c k a r r a y b l o c k */ +/* */ +/* Given an array block, do consistency checks on it. */ +/* */ +/************************************************************************/ + +LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist) +{struct arrayblock *bbase, *btrailer; + struct arrayblock *bfwd, *bbwd, *rbase; + LispPTR fbl; + LispPTR *rover, *tmprover; +#ifdef ARRAYCHECK + if (T) +#else + if (*Array_Block_Checking_word != NIL) +#endif + { + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + btrailer=(struct arrayblock *)Addr68k_from_LADDR(Trailer(base,bbase)); + bfwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->fwd); + bbwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->bkwd); + if (bbase->password != ARRAYBLOCKPASSWORD) + { + printarrayblock(base); + error("ARRAYBLOCK password wrong\n"); + } + else if (bbase->inuse == free) + { + printarrayblock(base); + error("ARRAYBLOCK INUSE bit set wrong\n"); + } + else if (btrailer->password != ARRAYBLOCKPASSWORD) + { + printarrayblock(base); + error("ARRAYBLOCK trailer password wrong\n"); + } + else if (bbase->arlen != btrailer->arlen) + { + printarrayblock(base); + error("ARRAYBLOCK Header and Trailer length don't match\n"); + } + else if (btrailer->inuse == free) + /* This is not original source.(in original, + btrailer -> bbase) maybe, this is correction. */ + { + printarrayblock(base); + error("ARRAYBLOCK Trailer INUSE bit set wrong\n"); + } + else if (!onfreelist || (bbase->arlen < MINARRAYBLOCKSIZE)) + /* Remaining tests only for free list. */ + return(NIL); + else if ((bbwd->fwd != base) || (bfwd->bkwd != base)) + { + error("ARRAYBLOCK links fouled\n"); + } + else + {fbl = FreeBlockChainN(bbase->arlen); + rover = tmprover = (LispPTR *)Addr68k_from_LADDR(fbl); + /* GETBASEPTR */ + if ((*rover & POINTERMASK) == NIL) + error("Free Block's bucket empty\n"); + do + {if ((*rover & POINTERMASK) == base) + return(NIL); + checkarrayblock((*rover & POINTERMASK), T, NIL); + rbase = (struct arrayblock *)Addr68k_from_LADDR( + *rover & POINTERMASK); + }while(((*rover = rbase->fwd)& POINTERMASK) != + (*tmprover & POINTERMASK)); + return(NIL); + }; + }; + return(NIL); +} + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR deleteblock(LispPTR base) +{ struct arrayblock *bbase, *fbbase, *bbbase; + LispPTR fwd,bkwd,fbl,freeblocklsp; + LispPTR *freeblock; + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + if ((bbase->arlen >= MINARRAYBLOCKSIZE) && (bbase->fwd != NIL)) + {fwd = bbase->fwd; + fbbase = (struct arrayblock *)Addr68k_from_LADDR(fwd); + bkwd = bbase->bkwd; + bbbase = (struct arrayblock *)Addr68k_from_LADDR(bkwd); + fbl = FreeBlockChainN(bbase->arlen); + freeblock = (LispPTR *)Addr68k_from_LADDR(fbl); + freeblocklsp = POINTERMASK & *freeblock; + if (base == fwd) + {if (base == freeblocklsp) + *freeblock = NIL; + else error("GC error:deleting last list # FREEBLOCKLIST\n"); + return(NIL); + } + else + if (base == freeblocklsp) + *freeblock = fwd; + fbbase->bkwd = bkwd; + bbbase->fwd = fwd; + } + return(NIL); +} + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR linkblock(LispPTR base) +{ struct arrayblock *bbase,*fbbase,*tmpbase; + LispPTR fbl,freeblocklsp; + LispPTR *freeblock; + if (*FreeBlockBuckets_word != NIL) + { bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + if (bbase->arlen < MINARRAYBLOCKSIZE) + checkarrayblock(base, T, NIL); + else + {fbl = FreeBlockChainN(bbase->arlen); + freeblock = (LispPTR *)Addr68k_from_LADDR(POINTERMASK & fbl); + freeblocklsp = POINTERMASK & (*freeblock); + if (freeblocklsp == NIL) + {bbase->fwd = base; + bbase->bkwd = base; + } + else + {fbbase = (struct arrayblock *)Addr68k_from_LADDR(freeblocklsp); + bbase->fwd = freeblocklsp; + bbase->bkwd = fbbase->bkwd; + tmpbase = (struct arrayblock *) + Addr68k_from_LADDR(fbbase->bkwd); + tmpbase->fwd = base; + fbbase->bkwd = base; + }; + *freeblock = base; + checkarrayblock(base, T, T); + }; + }; + return(base); +} + + + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR makefreearrayblock(LispPTR block, DLword length) +{ LispPTR trailer; + struct arrayblock *bbase; + struct abdum *dbase; + bbase = (struct arrayblock *)Addr68k_from_LADDR(block); + dbase = (struct abdum *)WORDPTR(bbase); + dbase->abflags = FREEARRAYFLAGWORD; + bbase->arlen = length; + trailer = Trailer(block,bbase); + bbase = (struct arrayblock *)Addr68k_from_LADDR(trailer); + dbase = (struct abdum *)WORDPTR(bbase); + dbase->abflags = FREEARRAYFLAGWORD; + bbase->arlen = length; + return(block); +} + + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +LispPTR arrayblockmerger(LispPTR base, LispPTR nbase) +{ DLword arlens, narlens, secondbite, minblocksize, shaveback; + struct arrayblock *bbase, *bnbase; + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + bnbase = (struct arrayblock *)Addr68k_from_LADDR(nbase); + arlens = bbase->arlen; + narlens = bnbase->arlen; + secondbite = MAXARRAYBLOCKSIZE - arlens; + if (narlens > secondbite) + {arlens = MAXARRAYBLOCKSIZE; + narlens = narlens - secondbite; + minblocksize = ((*Hunk_word == ATOM_T) ? + (ARRAYBLOCKOVERHEADCELLS+MAXCELLSPERHUNK) : + MINARRAYBLOCKSIZE); + if (narlens < minblocksize) + {shaveback = narlens - minblocksize; + narlens = minblocksize; + arlens += shaveback; + secondbite += shaveback; + }; + linkblock(makefreearrayblock(nbase+2*secondbite, narlens)); + narlens = 0; + }; + return(linkblock(makefreearrayblock(base, arlens+narlens))); +} + + + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR mergebackward(LispPTR base) +{ LispPTR pbase; + struct arrayblock *ptrailer; + + ptrailer = (struct arrayblock *)Addr68k_from_LADDR(base - + ARRAYBLOCKTRAILERWORDS); + if (base == NIL) + return(NIL); + else if ((*ArrayMerging_word == NIL) || ((base == *ArraySpace_word) || + ((base == *ArraySpace2_word) || (ptrailer->inuse == T)))) + return(linkblock(base)); + pbase = base - 2*ptrailer->arlen; + checkarrayblock(pbase, T,NIL); + deleteblock(pbase); + return(arrayblockmerger(pbase, base)); +} + + + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR mergeforward(LispPTR base) +{ LispPTR nbase, nbinuse; + struct arrayblock *bbase, *bnbase; + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + nbase = base + 2*(bbase->arlen); + bnbase = (struct arrayblock *)Addr68k_from_LADDR(nbase); + if ((*ArrayMerging_word == NIL) || ((base == NIL) + || (checkarrayblock(base, T, T) || ((nbase == *ArrayFrLst_word) || + ((nbase == *ArrayFrLst2_word) || + (checkarrayblock(nbase, (! (nbinuse = bnbase->inuse)),NIL) || + nbinuse)))))) + return(NIL); + deleteblock(nbase); + deleteblock(base); + return(arrayblockmerger(base, nbase)); +} + + + + + + +/************************************************************************/ +/* */ +/* r e c l a i m a r r a y b l o c k */ +/* */ +/* Reclaim a block of storage in the array-space heap. */ +/* */ +/************************************************************************/ + +LispPTR reclaimarrayblock(LispPTR ptr) +{ LispPTR tmpptr, btrailer; + struct arrayblock *base; + LispPTR *tmpp; + int reclaim_p; + + reclaim_p = T; +#ifdef ARRAYCHECK + checkarrayblock(ptr-ARRAYBLOCKHEADERWORDS, NIL, NIL); +#endif /* ARRAYCHECK */ + + base = (struct arrayblock *)Addr68k_from_LADDR(ptr-ARRAYBLOCKHEADERWORDS); +#ifdef ARRAYCHECK + if (HILOC(ptr) < FIRSTARRAYSEGMENT) + { + printarrayblock(ptr-ARRAYBLOCKHEADERWORDS); + error("Bad array block reclaimed [not in array space].\nContinue with 'q' but save state ASAP. \n"); + return(T); + } + else if (ARRAYBLOCKPASSWORD != base->password) + { + printarrayblock(ptr-ARRAYBLOCKHEADERWORDS); + error("Bad array block reclaimed [password wrong].\nContinue with 'q' but save state ASAP. \n"); + return(T); + } + else if (base->inuse == NIL) + { + printarrayblock(ptr-ARRAYBLOCKHEADERWORDS); + error("Bad array block reclaimed [block not in use].\nContinue with 'q' but save state ASAP. \n"); + return(T); + } +#else + /* Normal case, just tell the guy something's wrong: */ + if ((HILOC(ptr) < FIRSTARRAYSEGMENT) || + ((ARRAYBLOCKPASSWORD != base->password) || + (base->inuse == NIL))) + { + error("Bad array block reclaimed--continue with 'q' but save state ASAP. \n"); + return(T); + }; +#endif /* ARRAYCHECK */ + + + switch(base->gctype) + { + case PTRBLOCK_GCT: + {btrailer = (ptr-2)+2*(base->arlen - ARRAYBLOCKTRAILERCELLS); + tmpptr = ptr; + do + { + tmpp = (LispPTR *)Addr68k_from_LADDR(tmpptr); + /* GCLOOKUP(0x8000,DELREF, *tmpp);*/ /* added 8-Oct-87 TT */ + REC_GCLOOKUP(*tmpp, DELREF); + *tmpp = NIL; + tmpptr += 2; + } while (tmpptr != btrailer); + break; + }; + case CODEBLOCK_GCT: + reclaim_p = ((reclaimcodeblock(ptr) == NIL)?T:NIL); + + + /* default: No Action */ + }; + if (reclaim_p == T) + mergeforward(mergebackward(makefreearrayblock( + ptr-ARRAYBLOCKHEADERWORDS + ,base->arlen))); + return(T); + } + + + +/************************************************************************/ +/* */ +/* r e c l a i m s t a c k p */ +/* */ +/* Reclaim a STACKP, which contains a stack pointer. */ +/* */ +/************************************************************************/ + +LispPTR reclaimstackp (LispPTR ptr) /* This is the entry function */ + /* in stack reclaiming */ + { + register STACKP *stkp; + register FX *fxp; + stkp = (STACKP*)Addr68k_from_LADDR(ptr); + fxp = (FX*)Addr68k_from_StkOffset( stkp->edfxp ); + decusecount68k(fxp); /* decrement the use-count for the frame it uses */ + return(NIL); /* and let the normal reclaimer reclaim it */ + } + + + +/************************************************************************/ +/* */ +/* p r i n t a r r a y b l o c k */ +/* */ +/* Print an array block's contents, for debugging work. */ +/* */ +/************************************************************************/ + +printarrayblock(LispPTR base) +{ + struct arrayblock *bbase, *btrailer, *ptrailer; + struct arrayblock *bfwd, *bbwd, *rbase; + LispPTR *addr, *tmprover; + + LispPTR pbase, nbase; + + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + btrailer=(struct arrayblock *)Addr68k_from_LADDR(Trailer(base,bbase)); + ptrailer=(struct arrayblock *)Addr68k_from_LADDR(base-ARRAYBLOCKTRAILERWORDS); + bfwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->fwd); + bbwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->bkwd); + + nbase = base + 2*bbase->arlen; + pbase = base - 2*ptrailer->arlen; + + printf("This array block: 0x%x. Previous: 0x%x. Next: 0x%x.\n", + base, pbase, nbase); + printf(" Length: %d cells.\n\n", bbase->arlen); + + addr = ((LispPTR *) bbase) - 20; + for (;addr<(LispPTR *)bbase; addr++) + printf("0x%x %8x\n", addr, *addr); + printf("0x%x %8x <- array header\n", addr, *addr++); + for (; addr < (LispPTR *) bbase + 20; addr++) + printf("0x%x %8x\n", addr, *addr); + printf(". . .\n"); + + addr = ((LispPTR *) btrailer) - 20; + for (;addr<(LispPTR *)btrailer; addr++) + printf("0x%x %8x\n", addr, *addr); + printf("0x%x %8x <- array trailer\n", addr, *addr++); + for (; addr < (LispPTR *) btrailer + 20; addr++) + printf("0x%x %8x\n", addr, *addr); + + } diff --git a/src/gchtfind.c b/src/gchtfind.c new file mode 100755 index 0000000..250b25c --- /dev/null +++ b/src/gchtfind.c @@ -0,0 +1,584 @@ +/* $Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +#include "lispemul.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "gc.h" +#include "lispmap.h" +#include "cell.h" + + + +#define Evenp(num,prim) ((num % prim) == 0) +#ifdef BIGVM + /* HTCOLLMAX should be in half-entries, not in words */ +#define HTCOLLMAX (HTCOLL_SIZE/DLWORDSPER_CELL)-16 +#else +#define HTCOLLMAX HTCOLL_SIZE-16 +#endif /* BIGVM */ + +/* GetLink gets a new entry from the GC collision table */ +#define GetLink(var) \ + { \ + \ + register GCENTRY linkoff; \ + linkoff = GETGC(HTcoll); \ + if (linkoff == 0) \ + { \ + if ((linkoff = GETGC((GCENTRY *)HTcoll + 1)) \ + >= HTCOLLMAX) \ + { \ + disablegc1(NIL); \ + return(NIL); \ + }; \ + GETGC((GCENTRY*)HTcoll + 1) = linkoff + 2; \ + var = (GCENTRY *)(HTcoll + linkoff); \ + } \ + else \ + { \ + GETGC(HTcoll) = GETGC((GCENTRY *)(HTcoll + linkoff+1)); \ + var = (GCENTRY *)(HTcoll + linkoff); \ + } \ +} + +#ifdef BIGVM +#define HTCNTSHIFT 17 /* amount to shift to get hash table count */ +#define HTCNTMASK 0xFFFE0000 /* mask which masks off hash table count */ +#define HTCNTSTKMASK 0XFFFF0000 /* mask for hash table count + stack bit */ +#define HTSTKMASK 0x10000 /* mask for stack bit only */ +#define HTHIMASK 0x1FFE /* mask of bits which contain high part of + pointer in hash table FIXME change this + to 1FFE when pointers really go to + 28 bits. JDS */ +#define HTHISHIFT 1 /* high bits in hash table are shifted left 1 */ +#else +#define HTCNTSHIFT 10 /* amount to shift to get hash table count */ +#define HTCNTMASK 0xFC00 /* mask which masks off hash table count */ +#define HTCNTSTKMASK 0XFE00 /* mask for hash table count + stack bit */ +#define HTSTKMASK 0x0200 /* mask for stack bit only */ +#define HTHIMASK 0x1FE /* mask of bits which contain high part of pointer + in hash table */ +#define HTHISHIFT 1 /* high bits in hash table are shifted left 1 */ +#endif /* BIGVM */ + + +/* NewEntry is a macro for adding a new gc hash table entry; + entry is pointer to hash table entry + hiptr is the high point of the ref-cnted entry, shifted + casep is one of ADDREF, DELREF, etc. +*/ + +/* + * NewEntry is never called in the course of the reclaimation. + * Thus STKREF case is not needed. + */ +#define NewEntry(entry, hiptr, casep, ptr) { \ +switch (casep) { \ + case ADDREF: \ + GETGC(entry) = hiptr | (2 << HTCNTSHIFT); /* set count = 2 */ \ + IncAllocCnt(1);\ + return NIL; /* not new 0 entry */ \ + case DELREF: \ + GETGC(entry) = hiptr; /* set count = 0 */ \ + IncAllocCnt(1);\ + return ptr; /* new 0 entry */ \ + default: \ + error("GC error: new entry touches stack bit"); \ + }} + +/* + * RecNewEntry is called in the course of the reclaimation. + * Does not maintain the allocation count. + */ +#define RecNewEntry(entry, hiptr, casep, ptr) { \ +switch (casep) { \ + case ADDREF: \ + GETGC(entry) = hiptr | (2 << HTCNTSHIFT); /* set count = 2 */ \ + return NIL; /* not new 0 entry */ \ + case DELREF: \ + GETGC(entry) = hiptr; /* set count = 0 */ \ + return ptr; /* new 0 entry */ \ + case STKREF: /* set refcnt to 1, stack bit to 1 */ \ + GETGC(entry) = hiptr | (1<> HTCNTSHIFT) == 0) \ + error("attempt to decrement 0 reference count"); \ + contents -= (1 << HTCNTSHIFT); \ + if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) { \ + DecAllocCnt(1); \ + goto remove; \ + } \ + break;\ + default: error("GC error: mod entry touches stack bit"); \ + }\ + GETGC(entry) = contents;\ + return NIL;\ + } + +/* + * RecModEntry is called in the course of the reclaimation. + * Does not maintain the allocation count. + */ +#define RecModEntry(entry, contents, ptr, casep, remove) { \ + if ((contents & HTCNTMASK) == HTCNTMASK) \ + { /* overflow; return non-zero */ \ + modify_big_reference_count(entry, casep, ptr);\ + return NIL;}\ + switch (casep) {\ + case ADDREF:\ + contents += (1 << HTCNTSHIFT);\ + if ((contents & HTCNTMASK) == HTCNTMASK) \ + {\ + /* overflow */\ + GETGC(entry) = contents; \ + enter_big_reference_count(ptr);\ + return NIL;\ + }\ + break; /* check for possibly deleting entry */\ + case DELREF:\ + if ( (contents >> HTCNTSHIFT) == 0) \ + error("attempt to decrement 0 reference count");\ + contents -= (1 << HTCNTSHIFT); \ + break;\ + case STKREF:\ + GETGC(entry) = contents | HTSTKMASK;\ + return NIL;\ +/*\ + case UNSTKREF:\ + contents = contents & ~ HTSTKMASK;\ + break;\ +*/\ + }\ + if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) goto remove;\ + GETGC(entry) = contents;\ + return NIL;\ +} + +/************************************************************************/ +/* */ +/* e n t e r _ b i g _ r e f e r e n c e _ c o u n t */ +/* */ +/* Add a new overflow entry, for a count that won't fit into */ +/* the field of a main GC table entry. */ +/* */ +/************************************************************************/ + +void enter_big_reference_count(LispPTR ptr) +{ + struct gc_ovfl *oventry; + register LispPTR tmp; + + /* this kludge is apparently necessary. Odd pointers are + illegal, but apparently some are reference counted. If you + get an odd pointer, just ignore the low bit */ + + ptr &= 0xfffffffe; + + oventry = (struct gc_ovfl *)HTbigcount; + while(((tmp = oventry->ovfl_ptr) != ATOM_T) && (tmp != NIL)) + /* free area ? */ + { + if (tmp == ptr) + { + error("ERROR : PTR already in overflow table.\n"); + oventry->ovfl_cnt += 0x10000; /* "Assure it lives forever" */ + return; + } + else ++oventry; + }; + + if (tmp == NIL) + { + if (Evenp(LADDR_from_68k(oventry+1),DLWORDSPER_PAGE)) + { + if ((UNSIGNED)oventry+1 >= (UNSIGNED)HTcoll) + error("GC big reference count table overflow"); + newpage(LADDR_from_68k(oventry+1)); + } + } + + oventry->ovfl_cnt = MAX_GCCOUNT; + oventry->ovfl_ptr = ptr; + return; + } + + + +/************************************************************************/ +/* */ +/* m o d i f y _ b i g _ r e f e r e n c e _ c o u n t */ +/* */ +/* Modify an existing overflow entry. */ +/* */ +/************************************************************************/ + +void modify_big_reference_count(LispPTR *entry, DLword casep, LispPTR ptr) +{ + struct gc_ovfl *oventry; + LispPTR tmp; + int tmpcnt; + + /* ditto comment in entry_big_reference_count */ + if (ptr & 1) ptr &= 0xfffffffe; + oventry = (struct gc_ovfl *) HTbigcount; + while ((tmp = oventry->ovfl_ptr) != ptr) + if (tmp == NIL) + { + error("refcnt previously overflowed, but not found in table.\n"); + return; + } + else ++oventry; /* increment by size of oventry structure */ + + switch (casep) + { + case ADDREF: + ++(oventry->ovfl_cnt); + return; + case DELREF: + if (--(oventry->ovfl_cnt) < MAX_GCCOUNT) + { + /* fallen below threshold */ + ((struct hashentry *) GCPTR(entry))->count = MAX_GCCOUNT - 1; + oventry->ovfl_ptr = ATOM_T; /* mark entry unused */ + } + return; + case STKREF: + ((struct hashentry *) WORDPTR(entry))->stackref = 1; + return; +/* + case UNSTKREF: + ((struct hashentry *) WORDPTR(entry))->stackref = 0; + return; +*/ + } +} + + + +/************************************************************************/ +/* */ +/* h t f i n d */ +/* */ +/* Main entry for Ref-count manipulation: Modify the reference */ +/* count for a lisp pointer. */ +/* */ +/* casep is one of ADDREF, DELREF, STKREF */ +/* */ +/* ADDREF = add 1 */ +/* DELREF = subtract 1 */ +/* STKREF = turn on stack bit */ +/* UNSTKREF = turn off stack bit */ +/* */ +/* returns NIL if DELREF and the entry became */ +/* refcount = 0, stk bit off (only can happen on a *new* DELREF) */ +/* in which case it returns PTR */ +/* */ +/************************************************************************/ + +LispPTR htfind(LispPTR ptr, int casep) +{ + register GCENTRY *entry, *link, *prev; + register GCENTRY entry_contents, hiptr; + register struct htlinkptr *htlptr; + + /* if the NOREF bit is on in the type table entry, do + not reference count this pointer. Used for non-reference + counted types like symbols, and also when the GC is + disabled. */ + + /* + * Following two tests were moved into GCLOOKUP macro + * for efficency. + */ +/* + if (GetTypeEntry(ptr) & TT_NOREF) return NIL; +*/ + /* if *GcDisabled_word is T then do nothing */ + /* FS: this test should not be needed (because type table should + be cleared). Also, this test seems to cause an infinite + ucode loop in remimplicitkeyhash on the 386i */ + +/* if(*GcDisabled_word == ATOM_T) return(NIL); */ + + /* GC hash table entries have the high 8 bits of the + pointer stored in the middle. Set up hiptr to have + the high bits of the pointer ready to store or test + against */ + + hiptr = (((UNSIGNED)ptr) >> (16-HTHISHIFT) ) & HTHIMASK; + + /* entry points at the place in the main hash table + where this pointer is stored. The 'hash' isn't one really; + it just uses the low bits of the pointer. */ + + entry = HTmain + (LOLOC(ptr) >> 1); + + entry_contents = GETGC(entry); + + if (entry_contents == 0) NewEntry(entry, hiptr, casep, ptr); + /* NewEntry returns */ + + if (entry_contents & 1) + { /* low bit means a collision entry */ + /* entry_contents-1 removes low bit */ + link = HTcoll + (entry_contents - 1); + prev = 0; + goto newlink; + } + + if (hiptr == (entry_contents & HTHIMASK)) + { + ModEntry(entry, entry_contents, ptr, casep, delentry); + /* ModEntry returns or will go to delentry */ + } + + /* new collision */ + + GetLink(link); + GetLink(prev); + GETGC((GCENTRY *)prev + 1) = 0; + GETGC((GCENTRY *)prev) = entry_contents; + GETGC((GCENTRY *)link + 1) = prev - HTcoll; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + + NewEntry(link, hiptr, casep, ptr); + /* NewEntry returns */ + + +delentry: GETGC(entry) = 0; + return NIL; + +/* start here when a collision is detected. link is a pointer to + the entry in the collision table, prev is the previous collision + entry or 0 if this is the first one. */ + +newlink: + entry_contents = GETGC(link); + if (hiptr == (entry_contents & HTHIMASK) ) + { + ModEntry(link, entry_contents, ptr, casep, dellink); + /* ModEntry returns or goes to dellink */ + } + + /* collision didn't match */ + entry_contents = GETGC((GCENTRY *)link + 1); + if (entry_contents == 0) goto nolink; + + /* try the next link in the collision table */ + prev = link; + link = HTcoll + entry_contents; + goto newlink; + +dellink: + if (prev) GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); + else GETGC((GCENTRY *)entry) = (GETGC((GCENTRY *)link + 1)) | 1; + FreeLink(link); + link = HTcoll + (GETGC((GCENTRY *)entry)) - 1; + if (GETGC(link + 1) == 0) + { + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); + FreeLink(link); + } + return NIL; + +nolink: /* no match */ + + GetLink(link); + GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + NewEntry(link, hiptr, casep, ptr); + } + + +/************************************************************************/ +/* */ +/* r e d _ h t f i n d */ +/* */ +/* Version of HTFIND used during reclaims (part of GC process) */ +/* Same purpose, but doesn't increment the GC count-down, and */ +/* DELREF can add 0-refcount entries to the table. */ +/* */ +/************************************************************************/ + +LispPTR rec_htfind(LispPTR ptr, int casep) +{ + register GCENTRY *entry, *link, *prev; + register GCENTRY entry_contents, hiptr; + register struct htlinkptr *htlptr; + + /* if the NOREF bit is on in the type table entry, do + not reference count this pointer. Used for non-reference + counted types like symbols, and also when the GC is + disabled. */ + /* + * Following two tests were moved into GCLOOKUP macro + * for efficency. + */ +/* + if (GetTypeEntry(ptr) & TT_NOREF) + return NIL; +*/ + /* if *GcDisabled_word is T then do nothing */ + /* FS: this test should not be needed (because type table should + be cleared). Also, this test seems to cause an infinite + ucode loop in remimplicitkeyhash on the 386i */ + +/* if(*GcDisabled_word == ATOM_T) return(NIL); */ + + /* GC hash table entries have the high 8 bits of the + pointer stored in the middle. Set up hiptr to have + the high bits of the pointer ready to store or test + against */ + + hiptr = (((unsigned int)ptr) >> (16-HTHISHIFT) ) & HTHIMASK; + + /* entry points at the place in the main hash table + where this pointer is stored. The 'hash' isn't one really; + it just uses the low bits of the pointer. */ + + entry = HTmain + (LOLOC(ptr) >> 1); + + entry_contents = GETGC(entry); + + if (entry_contents == 0) RecNewEntry(entry, hiptr, casep, ptr); + /* NewEntry returns */ + + if (entry_contents & 1) + { /* low bit means a collision entry */ + /* entry_contents-1 removes low bit */ + link = HTcoll + (entry_contents - 1); + prev = 0; + goto newlink; + } + + if (hiptr == (entry_contents & HTHIMASK)) + { + RecModEntry(entry, entry_contents, ptr, casep, delentry); + /* ModEntry returns or will go to delentry */ + } + + /* new collision */ + + GetLink(link); + GetLink(prev); + GETGC((GCENTRY *)prev + 1) = 0; + GETGC((GCENTRY *)prev) = entry_contents; + GETGC((GCENTRY *)link + 1) = prev - HTcoll; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + + RecNewEntry(link, hiptr, casep, ptr); + + +delentry: + GETGC(entry) = 0; + return NIL; + +/* start here when a collision is detected. link is a pointer to + the entry in the collision table, prev is the previous collision + entry or 0 if this is the first one. */ + +newlink: + entry_contents = GETGC(link); + if (hiptr == (entry_contents & HTHIMASK) ) + { + RecModEntry(link, entry_contents, ptr, casep, dellink); + /* ModEntry returns or goes to dellink */ + } + /* collision didn't match */ + entry_contents = GETGC(link + 1); + if (entry_contents == 0) + { + goto nolink; + } + /* try the next link in the collision table */ + prev = link; + link = HTcoll + entry_contents; + goto newlink; + +dellink: + if (prev) GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); + else GETGC((GCENTRY *)entry) = (GETGC((GCENTRY *)link + 1)) | 1; + + FreeLink(link); + link = HTcoll + ((GETGC((GCENTRY *)entry)) - 1); + if (GETGC((GCENTRY *)link + 1) == 0) + { + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); + FreeLink(link); + } + return NIL; + +nolink: /* no match */ + + GetLink(link); + GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + RecNewEntry(link, hiptr, casep, ptr); + + +} + + diff --git a/src/gcmain3.c b/src/gcmain3.c new file mode 100755 index 0000000..a46c86a --- /dev/null +++ b/src/gcmain3.c @@ -0,0 +1,629 @@ +/* $Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/*************************************************************************/ +/* */ +/* File Name : gcmain3.c */ +/* */ +/*************************************************************************/ +/* */ +/* Creation Date : July-7-1987 */ +/* Written by Tomoru Teruuchi */ +/* */ +/*************************************************************************/ +/* */ +/* Functions : gcmapscan(); */ +/* gcmapunscan(); */ +/* gcscanstack(); */ +/* */ +/* */ +/*************************************************************************/ +/* Descreption : */ +/* */ +/*************************************************************************/ +/* \Tomtom */ +/*************************************************************************/ + +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "emlglob.h" +#include "stack.h" +#include "cell.h" +#include "ifpage.h" +#include "gc.h" + +#ifdef GCC386 +#include "inlnPS2.h" +#endif + + + +#define WORDSPERCELL 2 +#define MAXHTCNT 63 +#define PADDING 4 +#define FNOVERHEADWORDS 8 +#define ADD_OFFSET(ptr, dloffset) ((LispPTR *) ((DLword *) (ptr) + (dloffset))) + +#ifdef BIGVM +#define BIND_BITS(value) ((unsigned int) (value) >> 28) +#define BF_FLAGS(value) ((unsigned int) (value) >> 29) +#define PTR_BITS(entry) ((unsigned int)(entry) & POINTERMASK) +#define GetSegnuminColl(entry1) (((entry1) & 0xFFFE) >> 1) +#define GetStkCnt(entry1) ((entry1) >> 16) +#define StkCntIsZero(entry1) (!((entry1) & 0xFFFF0000)) +#define StkrefP(entry1) ((entry1) & 0x10000) +#define SinglerefP(entry1) (((entry1) & 0xFFFE0000) == 0x20000) +#define Boundp(frame_field) ((frame_field) == 0) +#define Stkref(ptr) REC_GCLOOKUP(ptr, STKREF) +#define GcreclaimLp(ptr) while((ptr = gcreccell(ptr)) != NIL) \ + REC_GCLOOKUP(ptr, ADDREF) +#define HTLPTR ((struct htlinkptr *) (entry)) +#define HENTRY ((struct hashentry *) (entry)) +#define HTMAIN_ENTRY_COUNT (HTMAIN_SIZE >> 1) +#define STKREFBIT 0x10000 /* the bit that says "I'm on the stack" */ + +#else +#define BIND_BITS(value) ((unsigned int) (value) >> 24) +#define BF_FLAGS(value) ((unsigned int) (value) >> 29) +#define PTR_BITS(entry) ((unsigned int)((unsigned int)((entry) << 8) >> 8)) +#define GetSegnuminColl(entry1) ((entry1 & 0x01fe) >> 1) +#define GetStkCnt(entry1) ((entry1 & 0x0fe00) >> 9) +#define StkCntIsZero(entry1) (!((entry1) & 0x0fe00)) +#define StkrefP(entry1) ((entry1) & 0x0200) +#define SinglerefP(entry1) (((entry1) & 0xFC00) == 0x0400) +#define Boundp(frame_field) ((frame_field) == 0) +#define Stkref(ptr) REC_GCLOOKUP(ptr, STKREF) +#define GcreclaimLp(ptr) while((ptr = gcreccell(ptr)) != NIL) \ + REC_GCLOOKUP(ptr, ADDREF) +#define HTLPTR ((struct htlinkptr *) WORDPTR(entry)) +#define HENTRY ((struct hashentry *) WORDPTR(entry)) +#define HTMAIN_ENTRY_COUNT HTMAIN_SIZE +#define STKREFBIT 0x200 +#endif /* BIGVM */ + + +#ifdef GCC386 + /* byte-swapped, 386 assembler version */ +gcmapscan() + { + volatile DLword probe; + volatile DLword *entry; + volatile DLword offset; + volatile LispPTR ptr; + + asm volatile(" \n\ + movl $32768,%%edi / probe = HTSIZE. \n\ + .align 4 \n\ +nextentry: / nextentry: \n\ + decl %%edi \n\ + js returNIL \n\ + leal 0(,%%edi,2),%%esi \n\ + addl HTmain,%%esi /htlptr = (struct htlinkptr *)(HTmain+probe); \n\ + .align 4 \n\ +scanloop: \n\ + movl %%esi,%%edx \n\ + xorb $2,%%dl \n\ + movzwl (%%edx),%%eax / contents = ((struct htlinkptr *)WORDPTR(htlptr))->contents \n\ + testl %%eax,%%eax / if (contents && \n\ + je scanbot \n\ + testb $1,%%al \n\ + jne scanok \n\ + testb $254,%%ah \n\ + jne scanbot \n\ +scanok: \n\ + jmp scandone \n\ + .align 4 \n\ +scanbot: \n\ + addl $-2,%%esi / end of while loop. \n\ + decl %%edi \n\ + jns scanloop \n\ + jmp returNIL \n\ + \n\ + \n\ +scandone: \n\ + movl %%edx,%0 / entry = (DLword *) HTmain + probe. \n\ +retry: / retry: \n\ + movl %0,%%ecx \n\ + movzwl (%%ecx),%%eax \n\ + testb $1,%%al / if HENTRY->collision, \n\ + je nocollision \n\ + xorl %%esi,%%esi / prev = 0 \n\ + andl $65534,%%eax \n\ +linkloop: // linkloop: \n\ + leal 0(,%%eax,2),%%ecx \n\ + addl HTcoll,%%ecx \n\ + movw 2(%%ecx),%%ax / offset = ((struct htcoll *)link)->free_ptr; \n\ + testb $254,%%ah / if StkCountIsZero(offset) \n\ + jne stknz \n\ + sall $15,%%eax / , (probe << 1)); \n\ + andl $16711680,%%eax \n\ + leal 0(,%%edi,2),%%edx \n\ + orl %%eax,%%edx \n\ + movl %%edx,%2 / to ptr. \n\ + testl %%esi,%%esi / DelLink. if (prev != 0) \n\ + je prevZ \n\ + leal 2(%%esi),%%edx / GETWORD((DLword *)prev + 1) = GETWORD((DLword *)link + 1) \n\ + xorb $2,%%dl \n\ + leal 2(%%ecx),%%eax \n\ + xorb $2,%%al \n\ + movw (%%eax),%%ax \n\ + jmp freelink \n\ + .align 4 \n\ +prevZ: \n\ + movl %0,%%edx / else GETWORD((DLword *)entry) = GETWORD((DLword *)link + 1) \n\ + leal 2(%%ecx),%%eax \n\ + xorb $2,%%al \n\ + movw (%%eax),%%ax \n\ + orb $1,%%al \n\ +freelink: / FreeLink \n\ + movw %%ax,(%%edx) \n\ + movl %%ecx,%%eax \n\ + xorb $2,%%al \n\ + movw $0,(%%eax) \n\ + leal 2(%%ecx),%%eax \n\ + xorb $2,%%al \n\ + movl HTcoll,%%edx / GETWORD(link+1) = GETWORD(HTcoll); \n\ + xorb $2,%%dl \n\ + movw (%%edx),%%dx \n\ + movw %%dx,(%%eax) \n\ + movl HTcoll,%%edx / GETWORD(HTcoll) = (link - HTcoll); \n\ + xorb $2,%%dl \n\ + movl %%ecx,%%eax \n\ + subl HTcoll,%%eax \n\ + sarl $1,%%eax \n\ + movw %%ax,(%%edx) \n\ + movl %0,%%esi / link = (DLword *)HTcoll + GetLinkptr(GETWORD((DLword *)entry \n\ + movw (%%esi),%%ax \n\ + andl $65534,%%eax \n\ + addl %%eax,%%eax \n\ + movl %%eax,%%ecx \n\ + addl HTcoll,%%ecx \n\ + leal 2(%%ecx),%%edx / if (GETWORD((DLword *)link + 1) == 0) { \n\ + xorb $2,%%dl \n\ + cmpw $0,(%%edx) \n\ + jne sgclp1 \n\ + movl %%ecx,%%eax / GETWORD((DLword *)entry) = GETWORD((DLword *)link) \n\ + xorb $2,%%al \n\ + movw (%%eax),%%bx \n\ + movw %%bx,(%%esi) \n\ + movw $0,(%%eax) / FreeLink: GETWORD(link) = 0 \n\ + movl HTcoll,%%eax / GETWORD(link+1) = GETWORD(HTcoll) \n\ + xorb $2,%%al \n\ + movw (%%eax),%%bx \n\ + movw %%bx,(%%edx) \n\ + movl %%ecx,%%ebx \n\ + subl HTcoll,%%ebx \n\ + sarl $1,%%ebx \n\ + movw %%bx,(%%eax) \n\ + .align 4 \n\ +sgclp1: / start of gcloop 1 - do setup \n\ + movl GcDisabled_word,%%ecx \n\ + movl MDStypetbl,%%ebx \n\ +gclp1: / GcreclaimLp: \n\ + pushl %2 \n\ + call gcreccell \n\ + addl $4,%%esp \n\ + movl %%eax,%2 \n\ + testl %%eax,%%eax \n\ + je eogclp1 \n\ + shrl $9,%%eax \n\ + leal 0(%%ebx,%%eax,2),%%eax \n\ + xorb $2,%%al \n\ + cmpw $0,(%%eax) \n\ + jl gclp1 \n\ + cmpl $76,(%%ecx) \n\ + je gclp1 \n\ + pushl $0 \n\ + pushl %2 \n\ + call rec_htfind \n\ + addl $8,%%esp \n\ + jmp gclp1 \n\ + .align 4 \n\ + .align 4 \n\ +eogclp1: \n\ + movl %0,%%eax / if (HTLPTR->contents == 0) \n\ + cmpw $0,(%%eax) \n\ + je nextentry / goto nextentry; \n\ + jmp retry / else goto retry; \n\ + .align 4 \n\ + .align 4 \n\ + \n\ +stknz: \n\ + movw (%%ecx),%%ax / if ((offset = ((struct htcoll *)link)->next_free)) \n\ + testw %%ax,%%ax \n\ + je nextentry \n\ + movl %%ecx,%%esi \n\ + andl $65535,%%eax \n\ + jmp linkloop \n\ + .align 4 \n\ + .align 4 \n\ +nocollision: \n\ + testw $65024,(%%ecx) / if (StkCntIsZero(HTLPTR->contents)) { \n\ + jne nextentry \n\ + movw (%%ecx),%%dx /ptr = VAG2(HENTRY->segnum, (probe << 1)); \n\ + sall $15,%%edx \n\ + andl $16711680,%%edx \n\ + leal (,%%edi,2),%%eax \n\ + orl %%eax,%%edx \n\ + movl %%edx,%2 \n\ + movw $0,(%%ecx) / HTLPTR->contents = 0 \n\ + .align 4 \n\ + movl GcDisabled_word,%%ecx \n\ + movl MDStypetbl,%%ebx \n\ +gclp2: / GcreclaimLp \n\ + pushl %2 \n\ + call gcreccell \n\ + addl $4,%%esp \n\ + movl %%eax,%2 \n\ + testl %%eax,%%eax \n\ + je nextentry \n\ + shrl $9,%%eax \n\ + leal 0(%%ebx,%%eax,2),%%eax \n\ + xorb $2,%%al \n\ + cmpw $0,(%%eax) \n\ + jl gclp2 \n\ + cmpl $76,(%%ecx) \n\ + je gclp2 \n\ + pushl $0 \n\ + pushl %2 \n\ + call rec_htfind \n\ + addl $8,%%esp \n\ + jmp gclp2 \n\ + .align 4 \n\ +returNIL: \n\ + " : "=g" (entry), "=g" (offset), "=g" (ptr) : : "ax", "dx", "cx", "bx", "si", "di"); + + return NIL; + } +#else + + +gcmapscan(void) +{ + register GCENTRY probe; + register GCENTRY *entry; + GCENTRY offset, dbgentry, dbgcontents; + register LispPTR ptr; + + probe = HTMAIN_ENTRY_COUNT; + nextentry: + while ((probe = gcscan1(probe)) != NIL) + { + entry = (GCENTRY *)HTmain + probe; + dbgentry = GETGC(entry); + retry: + if (HENTRY->collision) + { + register GCENTRY *prev; + register GCENTRY *link; + LispPTR content, dbgfree; + + prev = (GCENTRY *)0; + link = (GCENTRY *)HTcoll + GetLinkptr((content = HTLPTR->contents)); + linkloop: + offset = ((struct htcoll *)link)->free_ptr; + dbgfree = ((struct htcoll *)link)->next_free; + if (StkCntIsZero(offset)) + { + /* Reclaimable object */ + ptr = VAG2(GetSegnuminColl(offset), (probe << 1)); + DelLink(link, prev, entry); + GcreclaimLp(ptr); + if (HTLPTR->contents == 0) + goto nextentry; + else + goto retry; + } + if ((offset = ((struct htcoll *)link)->next_free)) + { + prev = link; + link = (GCENTRY *)(HTcoll + offset); + goto linkloop; + } + goto nextentry; + } + if (StkCntIsZero(dbgcontents = HTLPTR->contents)) { + ptr = VAG2(HENTRY->segnum, (probe << 1)); + HTLPTR->contents = 0; + GcreclaimLp(ptr); + } + } + return(NIL); + } +#endif /* GCC386 */ + + + + +gcmapunscan(void) +{ + register GCENTRY probe; + register GCENTRY *entry; + GCENTRY offset; + register LispPTR ptr; + + probe = HTMAIN_ENTRY_COUNT; + while ((probe = gcscan2(probe)) != NIL) { + entry = (GCENTRY *)HTmain + probe; + retry: + if (HENTRY->collision) { + register GCENTRY *prev; + register GCENTRY *link; + + prev = (GCENTRY *)0; + link = (GCENTRY *)(HTcoll + GetLinkptr(HTLPTR->contents)); + scnlp: + offset = ((struct htcoll *)link)->free_ptr; + if (StkrefP(offset)) { + if (SinglerefP(offset)) { + DelLink(link, prev, entry); + goto retry; + } else { + GETGC((GCENTRY *)link) = + offset & (~ STKREFBIT); + } + } + if ((offset = ((struct htcoll *)link)->next_free)) { + prev = link; + link = (GCENTRY *)(HTcoll + offset); + goto scnlp; + } + } else if (HENTRY->stackref) { + if (HENTRY->count == 1) + HTLPTR->contents = 0; + else + HENTRY->stackref = 0; + } + } + return(NIL); +} + + + + +gcscanstack(void) +{ + register Bframe *bascframe; + Bframe *obascframe; + LispPTR scanptr,scanend; + UNSIGNED scanend68K; + struct fnhead *nametable; + int ftyp; + int pvcount; + + scanptr = VAG2(STK_HI,InterfacePage->stackbase); + scanend = VAG2(STK_HI,InterfacePage->endofstack); + scanend68K = (UNSIGNED) Addr68k_from_LADDR(scanend); + bascframe = (Bframe *)Addr68k_from_LADDR(scanptr); + + if (0 != 3 & (UNSIGNED)bascframe) + { + char debugStr[100]; + sprintf(debugStr, "Frame ptr (0x%x) not to word bound " + "at start of gcscanstack.", bascframe); + error(debugStr); + } + + while (1) { + + /*This is endless loop until encountering tail of stack */ + + ftyp = (int)bascframe->flags; + switch(ftyp) + { + case STK_FX: + { + { + register struct frameex1 *frameex; + register struct fnhead *fnheader; + frameex = (struct frameex1 *)bascframe; + scanptr = LADDR_from_68k(frameex); + { + register LispPTR fn_head; +#ifdef BIGVM + fn_head = (LispPTR) (frameex->fnheader); +#else + fn_head = (LispPTR) + VAG2(frameex->hi2fnheader, + frameex->lofnheader); +#endif /* BIGVM */ + Stkref(fn_head); + fnheader = (struct fnhead *) + Addr68k_from_LADDR(fn_head); + }; + { + register int pcou; + register LispPTR *pvars; + pvars =(LispPTR *) + ((DLword *)bascframe + FRAMESIZE); + for (pcou = fnheader->nlocals;pcou-- != 0;) { + register LispPTR value; + value = *pvars; + if Boundp(BIND_BITS(value)) Stkref(value); + ++pvars; + }; /* for */ + }; /* register int pcou */ + + { + register UNSIGNED qtemp; + register UNSIGNED next; + register UNSIGNED ntend; + + next = qtemp = (UNSIGNED) + Addr68k_from_StkOffset(frameex->nextblock); + /* this is offset */ + ntend = 0; /* init flag */ + if (frameex->validnametable) { + register LispPTR nametable; +#ifdef BIGVM + nametable = frameex->nametable; +#define hi2nametable (nametable >> 16 ) +#else + register unsigned int hi2nametable; + register unsigned int lonametable; + lonametable = frameex->lonametable; + hi2nametable = frameex->hi2nametable; + nametable = VAG2(hi2nametable,lonametable); +#endif /* BIGVM */ + if (STK_HI == hi2nametable) + { + Stkref(fnheader->framename); +#ifdef BIGVM + qtemp = (UNSIGNED) + Addr68k_from_StkOffset(nametable&0xFFFF); +#else + qtemp = (UNSIGNED) + Addr68k_from_StkOffset(lonametable); +#endif + ntend = (UNSIGNED) ( + ((DLword *)qtemp) + + FNHEADSIZE + + (((struct fnhead *)qtemp)->ntsize)*2); + } else Stkref(nametable); + }; /* frameex->validnametable */ + + obascframe = bascframe; + bascframe = (Bframe *) + ADD_OFFSET(bascframe, FRAMESIZE+PADDING+ + (((fnheader->pv)+1)<<2)); + + if (0 != 3 & (UNSIGNED)bascframe) + { + char debugStr[100]; + sprintf(debugStr, "Frame ptr (0x%x) not to word bound " + "in gcscanstack() STK_FX case; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + + scantemps: + while((UNSIGNED)bascframe < (UNSIGNED )qtemp) { + register LispPTR value; + value = *((LispPTR *) bascframe); + if Boundp(BIND_BITS(value)) Stkref(value); + bascframe++; + }; /* while */ + + if (ntend != 0) { + obascframe = bascframe; + bascframe = (Bframe *) + Addr68k_from_StkOffset(ntend); + if (0 != 3 & (UNSIGNED)bascframe) + { + char debugStr[100]; + sprintf(debugStr, "Frame ptr (0x%x) not to word bound " + "in gcscanstack() scantemps; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + + qtemp = next; + ntend = 0; + goto scantemps; + }; + + obascframe = bascframe; + bascframe = (Bframe *) next; + + if (0 != 3 & (UNSIGNED)bascframe) + { + char debugStr[100]; + sprintf(debugStr, "Frame ptr (0x%x) not to word bound " + "in gcscanstack(), end scantemps; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + + + }; /* LOCAL regs qtemp next */ + }; /* local regs fnheader frameex */ + break; + }; + case STK_GUARD:/* stack's tail ? */ { + if ((UNSIGNED) bascframe >= (UNSIGNED) scanend68K) + return(NIL); + else { + obascframe = bascframe; + bascframe = (Bframe *)((DLword *) + bascframe + bascframe->ivar); + + if (0 != 3 & (UNSIGNED)bascframe) + { + char debugStr[100]; + sprintf(debugStr, "Frame ptr (0x%x) not to word bound " + "in gcscanstack() STK_GUARD; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + + }; + break; + }; + case STK_FSB: { + obascframe = bascframe; + bascframe = (Bframe *)((DLword *) + bascframe + bascframe->ivar); + + if (0 != 3 & (UNSIGNED)bascframe) + { + char debugStr[100]; + sprintf(debugStr, "Frame ptr (0x%x) not to word bound " + "in gcscanstack() STK_FSB; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + + break; + }; + default: /* must be basic frame !! */ + { + register LispPTR bf_word; + while(STK_BF != BF_FLAGS(bf_word = *((LispPTR *)bascframe))) + { Stkref(PTR_BITS(bf_word)); + bascframe++; + }; + bascframe++; + }; + + + /* **** NOTE THIS CODE DOES NOT COMPILE CORRECTLY ON THE SUN 4 + {register LispPTR bf_word; + while(STK_BF != BF_FLAGS( + bf_word = *((LispPTR *)bascframe++))) + { Stkref(PTR_BITS(bf_word)); + }; + }; + **** */ + }; /* switch */ + }; /* while(1) */ +} + + + + + + diff --git a/src/gcoflow.c b/src/gcoflow.c new file mode 100755 index 0000000..54441e6 --- /dev/null +++ b/src/gcoflow.c @@ -0,0 +1,118 @@ +/* $Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/*************************************************************************/ +/* */ +/* File Name : gcpunt.c */ +/* */ +/*************************************************************************/ +/* */ +/* Creation Date : July-8-1987 */ +/* Written by Tomoru Teruuchi */ +/* */ +/*************************************************************************/ +/* */ +/* Functions : gc_handleoverflow(arg); */ +/* gcmaptable(arg); */ +/* */ +/*************************************************************************/ +/* Descreption : */ +/* */ +/*************************************************************************/ +/* \Tomtom */ +/*************************************************************************/ + + +#include "version.h" + + +#include "lispemul.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "gc.h" + + + +#define MAXSMALLP 65535 +#define HTBIGENTRYSIZE 4 +#define WORDSPERPAGE 256 +#define MAXTYPENUMBER INIT_TYPENUM +#define Oddp(num) (((num % 2) != 0)?1:0) +#define Evenp(num,prim) (((num % prim) == 0)?1:0) +#define Increment_Allocation_Count(n) \ + if (*Reclaim_cnt_word != NIL) \ + if (*Reclaim_cnt_word > n) \ + (*Reclaim_cnt_word) -= n; \ + else { *Reclaim_cnt_word = NIL; \ + doreclaim(); \ + }; \ + + +gc_handleoverflow(DLword arg) +{ struct htoverflow *cell; + struct dtd *ptr; + LispPTR cellcnt; + LispPTR addr; + cell = (struct htoverflow *)HToverflow; + /* This proc. protected from interrupt */ + while((addr = cell->ptr) != NIL) + { + REC_GCLOOKUP(addr, cell->pcase); + cell->ptr = 0; + cell->pcase = 0; + ++cell; /* (\ADDBASE CELL WORDSPERCELL) */ + }; + ptr = (struct dtd *)GetDTD(TYPE_LISTP); + /* same as "extern struct dtd *ListpDTD" */ + if ((cellcnt = ptr->dtd_cnt0) > 1024) + { Increment_Allocation_Count(cellcnt); + ptr->dtd_oldcnt += cellcnt; + ptr->dtd_cnt0 = 0; + }; + return(arg); + } + +gcmaptable(DLword arg) +{ struct htoverflow *cell; + struct dtd *ptr; + LispPTR cellcnt; + int typnum; + LispPTR addr; + cell = (struct htoverflow *)HToverflow; + /* This proc. protected from interrupt */ + while((addr = cell->ptr) != NIL) + { + REC_GCLOOKUP(addr, cell->pcase); + cell->ptr = 0; + cell->pcase = 0; + ++cell; /* (\ADDBASE CELL WORDSPERCELL) */ + }; + for(typnum = 1; typnum <= *MaxTypeNumber_word; ++typnum) + /* applied alltype */ + { ptr = (struct dtd *)GetDTD(typnum); + if ((cellcnt = ptr->dtd_cnt0) != 0) + { ptr->dtd_oldcnt += cellcnt; + ptr->dtd_cnt0 = 0; + Increment_Allocation_Count(cellcnt); + }; + }; + return(arg); + } + + + + diff --git a/src/gcr.c b/src/gcr.c new file mode 100755 index 0000000..c73b881 --- /dev/null +++ b/src/gcr.c @@ -0,0 +1,186 @@ +/* $Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ +/* */ +/* File Name : gcr.c */ +/* */ +/*************************************************************************/ +/* */ +/* Creation Date : Oct-12-1987 */ +/* Written by Tomoru Teruuchi */ +/* */ +/*************************************************************************/ +/* Functions : gcarrangementstack() */ +/* doreclaim(); */ +/* dogc01(); */ +/* disablegc1(noerror); */ +/* */ +/*************************************************************************/ +/* Description : */ +/* This files' functions is the invocator that may invoke the reclaimer. */ +/* gcarrangementstack() */ +/* This function's role is narrowing the gap between the */ +/* contextswitch and the subrcall. */ +/* In the original Lisp Source, as the contextswitch process may */ +/* clear the remain area to FSB,there is no problem in scannig stack*/ +/* .But in the subrcall,there isn't such process. */ +/* Therefore, the function is required to set the remain stack area */ +/* to FSB. And this function does so. */ +/* dogc01() */ +/* This function is the mere caller of the reclaimer. */ +/* The callees are gcscanstack(), gcmapscan() and gcunmapscan(). */ +/* doreclaim() */ +/* This function is the real top level function of the reclaimer. */ +/* But currently this function is not used(may be used in Future.) */ +/* This function may have a problem. It is to manipulate "clock" */ +/* for keeping the GC's time period. */ +/* disablegc1(noerror) +/* This function is the rescue function,when the HTcoll table is */ +/* overflow and so on.After this function's process is over, the */ +/* keyhandler will sense the interrupt table state and call the */ +/* function \DOGCDISABLEDINTERRUPT for reporting to Users that */ +/* this system status is dangerous and you should save your works. */ +/* */ +/*************************************************************************/ +/* \tomtom */ +/*************************************************************************/ + + +#include "version.h" + + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "stack.h" +#include "gc.h" + + + +#define MAXSMALLP 65535 +#define HTBIGENTRYSIZE 4 +#define WORDSPERPAGE 256 +#define WORDSPERCELL 2 +#define MAXTYPENUMBER INIT_TYPENUM +#define STK_HI 1 + +#ifndef BYTESWAP + struct interruptstate + { unsigned nil1 :3; + unsigned gcdisabled :1; + unsigned vmemfull :1; + unsigned stackoverflow :1; + unsigned storagefull :1; + unsigned waitinginterrupt :1; + unsigned nil2 :8; + DLword intcharcode; + }; +#else + struct interruptstate + { + DLword intcharcode; + unsigned nil2 :8; + unsigned waitinginterrupt :1; + unsigned storagefull :1; + unsigned stackoverflow :1; + unsigned vmemfull :1; + unsigned gcdisabled :1; + unsigned nil1 :3; + }; +#endif /* BYTESWAP */ + + +gcarrangementstack(void) +{ LispPTR tmpnextblock; + PushCStack; + tmpnextblock = LADDR_from_68k(CurrentStackPTR+=WORDSPERCELL); + CURRENTFX->nextblock = LOLOC(tmpnextblock); +if ((UNSIGNED)EndSTKP == (UNSIGNED)CurrentStackPTR) error("creating 0-long stack block."); + GETWORD(CurrentStackPTR)=STK_FSB_WORD; + GETWORD(CurrentStackPTR+1)=(((UNSIGNED)EndSTKP-(UNSIGNED)CurrentStackPTR)>>1); +} + + +/****************************************************************/ +/* The following function is the caller that is the reclaimer. */ +/* And, this function is same as \DOGC1 in Lisp because in the */ +/* C's implimentation the contextswitch is not required for the */ +/* remaining the system status. */ +/****************************************************************/ + +dogc01(void) +{ + gcarrangementstack(); + gcscanstack(); + gcmapscan(); + gcmapunscan(); + PopCStack; + return(NIL); + } + +/*!!!!!! should update clock in Miscstats */ + +doreclaim(void) +{ + int gctm1; + MISCSTATS gcmisc; + + if (*GcDisabled_word == NIL) + { + update_miscstats(); + gcmisc = *((MISCSTATS *)MiscStats); + *Reclaim_cnt_word = NIL; + if (*GcMess_word != NIL) flip_cursor(); + dogc01(); + if (*GcMess_word != NIL) flip_cursor(); + *Reclaim_cnt_word = *ReclaimMin_word; + update_miscstats(); + MiscStats->gctime = MiscStats->gctime + + MiscStats->totaltime - gcmisc.totaltime + + MiscStats->swapwaittime - gcmisc.swapwaittime; + } + } + + + +disablegc1(int noerror) +{ + struct interruptstate *gcinterruptstate; + int count, i; + DLword typeword; + gcinterruptstate = (struct interruptstate *) + Addr68k_from_LADDR(*INTERRUPTSTATE_word); + count = (128)*256; /* This is test value. 128 is *MdsTTsize(\MDSTTsize) */ + for(i = 0;i < count;i++) + { + typeword = GETWORD((DLword *)Addr68k_from_LADDR(LADDR_from_68k(MDStypetbl)+i)); + GETWORD((DLword *)Addr68k_from_LADDR(LADDR_from_68k(MDStypetbl)+i) ) + = (typeword | TT_NOREF); + } + *Reclaim_cnt_word = NIL; + *ReclaimMin_word = NIL; + if ((noerror == NIL) && (*GcDisabled_word == NIL)) + { + gcinterruptstate->gcdisabled = T; + *PENDINGINTERRUPT_word = ATOM_T; + }; + *GcDisabled_word = ATOM_T; + return(NIL); + } diff --git a/src/gcrcell.c b/src/gcrcell.c new file mode 100755 index 0000000..54c326f --- /dev/null +++ b/src/gcrcell.c @@ -0,0 +1,390 @@ +/* $Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/*************************************************************************/ +/* */ +/* File Name : gcrcell.c */ +/* */ +/*************************************************************************/ +/* */ +/* Creation Date : July-7-1987 */ +/* Written by Tomoru Teruuchi */ +/* */ +/*************************************************************************/ +/* */ +/* Functions : */ +/* gcreccell(cell); */ +/* freelistcell(cell); */ +/* */ +/* */ +/*************************************************************************/ +/* Descreption : */ +/* */ +/* The functions "gcreccell" and "freelistcell" are the translated */ +/* functions from the Lisp functions "\GCRECLAIMCELL" that is the UFN */ +/* function of the opcode "RECLAIMCELL", and "\FREELISTCELL". */ +/* These functions may have the following characteristics : */ +/* */ +/* gcreccell(cell) LispPTR cell */ +/* This function may always return NIL(= 0), as the Lisp */ +/* macro .RECLAIMCELLLP. in more upper level may use this */ +/* return value as the further Garbage's pointer.(The Opcode*/ +/* "RECLAIMCELL"'s function is specified as this, but its */ +/* UFN function is not. The gcreccell function's */ +/* behavior is same as the UFN function for speed and */ +/* simplicity,this is, this function is closed in this level*/ +/* ) */ +/* This function may reclaim the data of all types that is */ +/* Garbage.Especially, the data whose types are ARRAYBLOCK */ +/* (= 0), STACKP(= 8),VMEMPAGEP(= 10) and CODEBLOCK(= 54,55,*/ +/* 56,57,58,59,60,61,62,63) may be reclaimed by each special*/ +/* processes that are specified and invoked by this function*/ +/* .The data whose type is LISTP is the main data type */ +/* processed in this function actually and only then the */ +/* function "freelistcell" may be called for making linkage */ +/* of free list. */ +/* */ +/* freelistcell(cell) LispPTR cell */ +/* This function may make the linkage of free list of the */ +/* cons cell.The header of this linkage is DTD->NEXTPAGE of */ +/* LISTP and each cons page has its internal linkage of free*/ +/* cells.This return value is not considered as not used. */ +/* */ +/*************************************************************************/ +/* \Tomtom */ +/*************************************************************************/ + +#include +#include "lispemul.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "stack.h" +#include "cell.h" +#include "ifpage.h" +#include "gc.h" +#include "dbprint.h" + +#ifdef NEWCDRCODING +#undef CONSPAGE_LAST +#define CONSPAGE_LAST 0x0ffffffff +#else +#undef CONSPAGE_LAST +#define CONSPAGE_LAST 0x0ffff +#endif /* NEWCDRCODING */ + +#define TODO_LIMIT 1000 +#define ADD_TO_DO(ptr,offset) \ + if (do_count < TODO_LIMIT) \ + { \ + if (ptr & 0xF0000000) error("illegal ptr in addtodo"); \ + to_do[do_count] = (ptr); \ + to_do_offset[do_count] = offset; \ + todo_uses++; \ + /*REC_GCLOOKUP((ptr), ADDREF);*/ \ + do_count++; \ + } else { /* error("GC missing some to-do's"); */ todo_misses++; } + +unsigned todo_uses = 0; +unsigned todo_misses = 0; +unsigned todo_reads = 0; + + +/************************************************************************/ +/* */ +/* g c r e c c e l l */ +/* */ +/* Reclaim a cell, doing necessary finalization &c. */ +/* */ +/************************************************************************/ + +gcreccell(LispPTR cell) +{ + register ConsCell *ptr; + struct dtd *typdtd; + DLword typ; + register LispPTR tmpptr, donext, tmpcell, val; + LispPTR ptrfield, carfield; + int index, code; + LispPTR *field; + int freecnt; + LispPTR freeptr; + +#ifdef NEWCDRCODING + LispPTR to_do[TODO_LIMIT]; /* table of pointers to follow, since Cdr coding lost */ + short to_do_offset[TODO_LIMIT]; /* offset in datatype */ + unsigned do_count = 0; /* counter of entries in to_do table */ +#endif /* NEWCDRCODING */ + + val = NIL; + tmpptr = cell; + index = -1; + donext = NIL; + lp: + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr&-2); +/* # ifdef CHECK + if (refcnt(tmpptr) != 1) error("reclaiming cell w/refcnt not 1"); + # endif +*/ +#ifdef DEBUG + if (tmpptr & 1) error("Reclaiming cell pointer with low bit 1."); +#else + tmpptr &= -2; /* turn off low bit of pointer, so we never reclaim odd'ns */ +#endif + + if ((tmpptr & 0x0FFF0000) == 0x60000) error("freeing an old atom??"); + + typ = GetTypeNumber(tmpptr); +#ifdef DEBUG + if (typ==6) printf("Reclaiming array ptr 0x%x.\n", tmpptr); +#endif + switch(typ) + { + case TYPE_LISTP: + { + if ((code = ptr->cdr_code) == CDR_INDIRECT) /* indirect */ + { tmpcell = ptr->car_field; /* Monitor */ + freelistcell(tmpptr); + ptr = (ConsCell *) Addr68k_from_LADDR(tmpcell); + tmpptr = tmpcell; + code = ptr->cdr_code; + }; + if (index != -1) /* car part */ + index = -1; + else + { + REC_GCLOOKUPV(car(tmpptr), DELREF, val); + if (val != NIL) + { + ptr->car_field = donext; + ptr->cdr_code = code; + donext = tmpptr; + goto doval; + }; + } + REC_GCLOOKUPV(cdr(tmpptr), DELREF, val); + if (code <= CDR_MAXINDIRECT) + { +#ifdef NEWCDRCODING + tmpcell = tmpptr + ((code - CDR_INDIRECT) << 1); +#else + tmpcell = POINTER_PAGEBASE(tmpptr) + + ((code - CDR_INDIRECT) << 1); +#endif /* NEWCDRCODING */ + freelistcell(tmpcell); + }; + freelistcell(tmpptr); + goto doval; + }; + case TYPE_ARRAYBLOCK: + if ((index == -1) && reclaimarrayblock(tmpptr)) + goto trynext; + else break; + case TYPE_STACKP: + if ((index == -1) && reclaimstackp(tmpptr)) goto trynext; + break; + case TYPE_VMEMPAGEP: + if ((index == -1) && releasingvmempage(tmpptr)) + { + goto trynext; + } + else break; + case TYPE_CODEHUNK1: + case TYPE_CODEHUNK2: + case TYPE_CODEHUNK3: + case TYPE_CODEHUNK4: + case TYPE_CODEHUNK5: + case TYPE_CODEHUNK6: + case TYPE_CODEHUNK7: + case TYPE_CODEHUNK8: + case TYPE_CODEHUNK9: + case TYPE_CODEHUNK10: + if ((index == -1) && reclaimcodeblock(tmpptr)) goto trynext; + else break; + default: ; + }; + normal: + typdtd = (struct dtd *)GetDTD(typ); + ptrfield = typdtd->dtd_ptrs; + if (index != -1) + { + index = (index << 1); + ptrfield = cdr(ptrfield); + while ((car(ptrfield) & 0x0ffff) != index) ptrfield = cdr(ptrfield); + index = -1; + }; + while(ptrfield != NIL) + { + carfield = car(ptrfield); + ptrfield = cdr(ptrfield); + carfield &= 0x0ffff; + REC_GCLOOKUPV((POINTERMASK & + *(LispPTR *)Addr68k_from_LADDR(tmpptr+carfield)), + DELREF, val); +#ifndef NEWCDRCODING + if (val != NIL) + { + if (ptrfield != NIL) + { + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); + ptr->car_field = donext; + ptr->cdr_code = ((car(ptrfield) & 0x0ffff) >> 1); + donext = tmpptr; + goto doval; + } + else goto addtofreelist; + }; +#else + if (val != NIL) + { + if (ptrfield != NIL) + { + if ((carfield = car(ptrfield) & 0x0ffff) >> 1 < 15) + { + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); + ptr->car_field = donext; + ptr->cdr_code = ((car(ptrfield) & 0x0ffff) >> 1); + donext = tmpptr; + goto doval; + } + else + { ADD_TO_DO(tmpptr, (car(ptrfield) & 0xffff)>>1); goto doval; } + } + else goto addtofreelist; + }; +#endif /* NEWCDRCODING */ + }; + addtofreelist: + field = (LispPTR *)Addr68k_from_LADDR(tmpptr); + *field = typdtd->dtd_free; + typdtd->dtd_free = tmpptr & POINTERMASK; +#ifdef DTDDEBUG + check_dtd_chain(GetTypeNumber(tmpptr & POINTERMASK)); +#endif + + /******************************/ + /* */ + /* Freeing one cell made another cell's refcnt = 0. */ + /* ADDREF the second cell (to remove it from the GC table) */ + /* and reclaim it. */ + /************************************************************/ + doval: + if (val != NIL) + { + tmpptr = val; + REC_GCLOOKUP(tmpptr, ADDREF); +/* GCLOOKUP(0x8000, ADDREF,tmpptr); */ + val = NIL; + goto lp; + }; + + /***************************************************************/ + /* */ + /* Finished freeing the main cell, but we may have saved other */ + /* cells whose refcnt's went to 0 along the way. This is */ + /* where we work down the list of saved items to free. */ + /* */ + /****************************************************************/ + trynext: + if (donext != NIL) + { + tmpptr = donext; + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); + donext = (LispPTR)ptr->car_field; + index = ptr->cdr_code; + goto lp; + }; +#ifdef NEWCDRCODING + if (do_count) /* If there are other cells to collect */ + { + do_count--; + tmpptr = to_do[do_count]; + index = to_do_offset[do_count]; + todo_reads++; + /*REC_GCLOOKUP(tmpptr, ADDREF); */ + goto lp; + } +#endif /*NEWCDRCODING */ + return(NIL); + } + + +/************************************************************************/ +/* */ +/* f r e e l i s t c e l l */ +/* */ +/* */ +/* */ +/************************************************************************/ + +freelistcell(LispPTR cell) +{ + struct conspage *pbase; + register ConsCell *cell68k; + unsigned int offset, prior, celloffset; + + cell68k = (ConsCell *)Addr68k_from_LADDR(cell); + pbase = (struct conspage *)Addr68k_from_LPAGE(POINTER_PAGE(cell)); + celloffset = (LispPTR)cell & 0xFF; +#ifdef NEWCDRCODING + if (celloffset < 8) + error("freeing CONS cell that's really freelist ptr"); +#endif /* NEWCDRCODING */ + + if (pbase->count) /* There are free cells on the page already */ + { + prior = 0; + + for (offset = pbase->next_cell; offset; + offset = FREECONS(pbase,offset) -> next_free) + { +#ifdef NEWCDRCODING + if ((6^offset) < (6^celloffset)) +#else + if (offset < celloffset) +#endif /* NEWCDRCODING */ + { + break; + } + prior = offset; + } + + if (prior) FREECONS(pbase, prior)->next_free = celloffset; + else pbase->next_cell = celloffset; + ((freecons *)cell68k) -> next_free = offset; + } + else /* NO FREE CELLS. Just replace next_free. */ + { + pbase->next_cell = celloffset; + FREECONS(pbase,celloffset)->next_free = 0; /* And this is end of the chain */ + } + + if ((++pbase->count > 32) && (pbase->next_page == CONSPAGE_LAST)) + { + pbase->next_page = ListpDTD->dtd_nextpage; + ListpDTD->dtd_nextpage = POINTER_PAGE(cell); + }; + + } + diff --git a/src/gcscan.c b/src/gcscan.c new file mode 100755 index 0000000..2338a04 --- /dev/null +++ b/src/gcscan.c @@ -0,0 +1,105 @@ +/* $Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/*************************************************************************/ +/* */ +/* File Name : gcscan.c */ +/* */ +/*************************************************************************/ +/* */ +/* Creation Date : July-7-1987 */ +/* Written by Tomoru Teruuchi */ +/* */ +/*************************************************************************/ +/* */ +/* Functions : */ +/* gcscan1(probe) */ +/* gcscan2(probe) */ +/* */ +/*************************************************************************/ +/* Descreption : */ +/* */ +/* The functions "gcscan1" and "gcscan2" are the translated functions */ +/* from the Lisp Functions "\GCSCAN1" & "\GCSCAN2". */ +/* These functions' role is to scan the HTmain Table and return the */ +/* existing entry(by "gcscan1") & the entry whose STKBIT field is ON */ +/* (by "gcscan2").These functions are the UFN functions that are called */ +/* by OPCODES "GCSCAN1" & "GCSCAN2". */ +/* */ +/* gcscan1 */ +/* INPUT : probe (the startng offset in the HTmain table) */ +/* OUTPUT : the entry's offset or NIL (no more entry existing) */ +/* */ +/* gcscan2 */ +/* INPUT : probe (the starting offset in the HTmain table) */ +/* OUTPUT : the entry's offset or NIL (no more entry existing) */ +/*************************************************************************/ +/* \Tomtom */ +/*************************************************************************/ + +#include "lispemul.h" +#include "lspglob.h" +#include "gc.h" +#include "lsptypes.h" + +#ifdef BIGVM +#define HTSTKBIT 0x10000 /* = 512 */ +#define HTENDS ((struct hashentry *) htlptr) +#define GetStkCnt(entry1) (entry1 >> 16) +#else +#define HTSTKBIT 0x200 /* = 512 */ +#define HTENDS ((struct hashentry *) htlptr) +#define GetStkCnt(entry1) (entry1 >> 9) +#endif /* BIGVM */ + + + + +DLword gcscan1 (register int probe) + /* probe is offset */ + { register struct htlinkptr *htlptr; /* overlay access method */ + register int contents; + while (--probe >= 0) /* End of HTmain Table ? */ + { + /* Start addr. of scanning */ + htlptr = (struct htlinkptr *)(HTmain+probe); + contents = ((struct htlinkptr *)GCPTR(htlptr))->contents; + if (contents && (((struct hashentry *)GCPTR(HTENDS))->collision + || (GetStkCnt(contents) == 0))) + return(probe); + } + return(NIL); + } + + + +DLword gcscan2 (register int probe) + /* probe is offset */ + { + register struct htlinkptr *htlptr; /* overlay access method */ + while (--probe >= 0) /* End of HTmain Table ? */ + { + htlptr = (struct htlinkptr *)(HTmain+probe); + /* Start addr. of scanning */ + if (((HTSTKBIT | 1) & ((struct htlinkptr *)GCPTR(htlptr))->contents) != 0) + return(probe); /* stackref or collision ON */ + } + return(NIL); + } diff --git a/src/gvar2.c b/src/gvar2.c new file mode 100755 index 0000000..67b1a95 --- /dev/null +++ b/src/gvar2.c @@ -0,0 +1,101 @@ +/* $Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyright (C) Venue"; + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include +#include "lispemul.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "adr68k.h" +#include "gc.h" +#include "emlglob.h" +#include "cell.h" +#include "dbprint.h" + + + +/************************************************************************/ +/* */ +/* N _ O P _ g v a r _ */ +/* */ +/* GVAR_ opcode (027). Assign a value to a global variable. */ +/* */ +/* atom_index is the "atom number," either the lo half of the */ +/* old litatom, or the new-atom itself. */ +/* */ +/* * call gclookup with DELREF and address of GVAR slot. */ +/* * call gclookup with ADDREF and TopOFStack. */ +/* * replace GVAR slot with tos. */ +/* * If Hash Table is overflow, call fn1ext. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_gvar_(register LispPTR tos, unsigned int atom_index) +{ + register LispPTR *pslot; /* pointer to argued GVAR slot */ + +#ifdef BIGATOMS + if (0 != (atom_index & SEGMASK)) + pslot = (LispPTR *) Addr68k_from_LADDR(atom_index + NEWATOM_VALUE_OFFSET); + else +#endif /* BIGATOMS */ + +#ifdef BIGVM + pslot = ((LispPTR *) AtomSpace) + (5 * atom_index) + NEWATOM_VALUE_PTROFF; +#else + pslot = (LispPTR *) Valspace + atom_index; +#endif /* BIGVM */ + DEBUGGER(if (tos&0xF0000000) error("Setting GVAR with high bits on")); + FRPLPTR(((struct xpointer*)pslot)->addr, tos); + return(tos); + } + + + + +/************************************************************************/ +/* */ +/* N _ O P _ r p l p t r */ +/* */ +/* RPLPTR opcode (024). Replace a pointer field somewhere, */ +/* updating the reference counts for the old value and the new */ +/* value (DELREF and ADDREF, respectively). */ +/* */ +/* tos_m_1 is the base, and alpha is a word-offset for finding */ +/* the cell to replace contents of. */ +/* tos is the new value. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_rplptr(register LispPTR tos_m_1, register LispPTR tos, unsigned int alpha) +{ + register DLword *pslot; /* pointer to argued slot (68 address) */ + + pslot = Addr68k_from_LADDR(tos_m_1 + alpha ); + FRPLPTR( ((struct xpointer*)pslot)->addr,tos); + return(tos_m_1); + } + + diff --git a/src/hacks.c b/src/hacks.c new file mode 100755 index 0000000..c759b34 --- /dev/null +++ b/src/hacks.c @@ -0,0 +1,44 @@ +/* $Id: hacks.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: hacks.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/* These functions are created so that you can split a float into */ +/* four integers. The general idea behind these functions is to */ + /* act as a caster between different entitys on the stack */ + +int pickapart1(int i1, int i2, int i3, int i4) +{ + return(i1); +} + +int pickapart2(int i1, int i2, int i3, int i4) +{ + return(i2); +} + +int pickapart3(int i1, int i2, int i3, int i4) +{ + return(i3); +} + +int pickapart4(int i1, int i2, int i3, int i4) +{ + return(i4); +} diff --git a/src/hardrtn.c b/src/hardrtn.c new file mode 100755 index 0000000..53b0fee --- /dev/null +++ b/src/hardrtn.c @@ -0,0 +1,334 @@ +/* $Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyright (C) Venue"; + + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/********************************************************************/ +/* + File Name : hardrtn.c + + Edited by Takeshi Shimizu + Date: 10-MAY-88 + + RET VAL: If success: 0 + else (NO SPACE in STACK) 1 -> should cause HARDRESET + +*/ +/********************************************************************/ +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "adr68k.h" +#include "address.h" +#include "lspglob.h" +#include "emlglob.h" +#include "cell.h" +#include "stack.h" +#include "return.h" + +#define MAKE_FXCOPY(fx68k) { BEFORE_CONTEXTSW; \ + if((fx68k=(FX*)make_FXcopy(fx68k)) == 0){ \ + return(1); /* Whole space exhausted */} \ + AFTER_CONTEXTSW; \ + CHECK_FX(fx68k);} + void incusecount68k(FX *fx68k),decusecount68k(register FX *frame68k); +/********************************************************************/ +/* + Func Name : slowreturn() + + Edited by Takeshi Shimizu + DATE: 10-MAY-88 + + RET VAL : If 0 success + If 1 NO STACK SPACE->uraid-> HARDRESET + +*/ +/********************************************************************/ + +slowreturn(void) +{ + register DLword *next68k; + register DLword *freeptr; + register Bframe *currentBF; + register FX *returnFX; + extern FX *make_FXcopy(register FX *fx68k); + + S_CHECK(SLOWP(CURRENTFX), "CURRENTFX not SLOWP"); + +/* Get returnee's FX from CURRENTFX->alink , It's SLOWP case */ +returnFX= (FX*)Addr68k_from_StkOffset(CURRENTFX->alink-11); + +if((CURRENTFX->alink & 0xFFFE) != CURRENTFX->clink) + { /* ALINK != CLINK */ +#ifdef STACKCHECK + printf("A!=C\n"); +#endif + /* return to CLINK fx */ + SETALINK(CURRENTFX,CURRENTFX->clink); + decusecount68k(returnFX); + returnFX = (FX*)Addr68k_from_StkOffset(CURRENTFX->clink - FRAMESIZE); + } + +if(returnFX->usecount !=0) + { /* COPY returnee's FX */ +#ifdef STACKCHECK + printf("returnFX->usecount !=0\n"); +#endif + MAKE_FXCOPY(returnFX);/* smashes returnFX */ + } + +retry : /* this is retry entry after MAKE_FXCOPY etc */ + + next68k = Addr68k_from_StkOffset(returnFX->nextblock) ; + currentBF = (Bframe *)Addr68k_from_StkOffset(CURRENTFX->blink); + +if(GETWORD(next68k) == STK_FSB_WORD) + { +another:freeptr = ((DLword *)CURRENTFX)-2 ; + if( BFRAMEPTR(freeptr)->residual) + { + if(BFRAMEPTR(currentBF)->usecnt == 0) + { + /* make FREEBLOCK for real BF */ + GETWORD(IVar) = STK_FSB_WORD; + GETWORD(IVar +1) =(((UNSIGNED)currentBF - (UNSIGNED)IVar)>>1 )+2 ; + if (0 == GETWORD(IVar+1)) error("creating 0-len block"); + } + else + BFRAMEPTR(currentBF)->usecnt --; + } + else + freeptr = IVar ; /* reset free ptr: not residual case */ + + /* free FX + BF(dummy or real) */ + GETWORD(freeptr) = STK_FSB_WORD; + GETWORD(freeptr +1)= ((UNSIGNED)EndSTKP - (UNSIGNED)freeptr)>>1 ; + if (0 == GETWORD(freeptr+1)) error("creating 0-len block"); + S_CHECK(EndSTKP >= freeptr, "EndSTKP < freeptr!"); + S_CHECK(FSB_size(freeptr) >= MINEXTRASTACKWORDS, + "free block < min size, after deciding it fits."); + + PVar=((DLword *)returnFX) + FRAMESIZE ; + /* Now right CURRENTFX(PVar) is set */ + + if (GETWORD(next68k) != STK_FSB_WORD) + error("OP_return: MP9316"); + + freeptr = next68k ; + while(GETWORD(freeptr)==STK_FSB_WORD) + EndSTKP = freeptr = freeptr + GETWORD(freeptr+1); + + if(CURRENTFX->incall) + { /* this frame is Interrupted */ + error("Stack error: INCALL bit found in returnee frame"); + } + else + { + if (CURRENTFX->nopush) + { + CURRENTFX->nopush =NIL; + CurrentStackPTR = next68k-2 ; + TopOfStack = *((LispPTR *)CurrentStackPTR) ; + CurrentStackPTR-=2; + + } + else + CurrentStackPTR = next68k-2 ; + + S_CHECK(EndSTKP >= freeptr, "EndSTKP < freeptr"); + + FastRetCALL; +#ifdef LISPTRACE + printf("TRACE: return from "); + print(fnobj->framename); + printf(" :<= "); + print(TopOfStack);printf("\n"); +#endif + return(0); /* normal return */ + } + +}/* FSB end */ +else if (next68k != IVar) + { +#ifdef STACKCHECK + printf("next68k != IVar and not FSB\n"); +#endif + MAKE_FXCOPY(returnFX);/* smashes returnFX */ + goto retry; + } +else if (BFRAMEPTR(currentBF)->usecnt != 0) + { +#ifdef STACKCHECK + printf("currentBF->usecnt != 0"); +#endif + MAKE_FXCOPY(returnFX);/* smashes returnFX */ + goto retry; + } +else { + if((next68k == IVar)|| (BFRAMEPTR(currentBF)->usecnt ==0)) + goto another; + else error("Shouldn't"); + } + +} /* slowreturn end */ + + + + + +FX *make_FXcopy(register FX *fx68k) +{ + register int size; + int nametbl_on_stk=NIL; + register DLword *new68k; + register Bframe *retbf68k; + extern DLword *freestackblock(DLword n, StackWord *start68k, int align); + +#ifdef FLIPCURSOR + flip_cursorbar(5); +#endif + + CHECK_FX(fx68k); + size = FX_size(fx68k) + DLWORDSPER_CELL; +#ifdef BIGVM + if(fx68k->validnametable && ((fx68k->nametable >> 16)==STK_HI)) +#else + if(fx68k->validnametable && (fx68k->hi2nametable==STK_HI)) +#endif /* BIGVM */ + { + /* frame contains a name table, so we care that the alignment + of the new block be same as old */ +#ifdef STACKCHECK + { DLword n; +#ifdef BIGVM + n = fx68k->nametable & 0xFFFF; +#else + n=fx68k->lonametable; +#endif /* BIGVM */ + if((n <= StkOffset_from_68K(fx68k)) + && (n >= fx68k->nextblock)) + error("hardreturn:nametable check"); + } +#endif + nametbl_on_stk = T; + /* Find a free stack block */ + new68k=freestackblock(size,(StackWord *)CURRENTFX, + (StkOffset_from_68K(fx68k)-DLWORDSPER_CELL)% DLWORDSPER_QUAD); + } /*if end */ + else new68k=freestackblock(size,(StackWord *)CURRENTFX,-1); /* No align */ + + if(new68k == 0) return(0); /* No more space for STACK */ + + /* blt(dest,source,size) */ + blt(new68k,(((DLword*)fx68k) - DLWORDSPER_CELL),size); + + ((Bframe*)new68k)->residual =T; + new68k = new68k + DLWORDSPER_CELL; /* now NEW points to the FX */ + ((FX*)new68k)->nextblock=(StkOffset_from_68K(new68k) + size)-DLWORDSPER_CELL; + retbf68k=(Bframe*)Addr68k_from_StkOffset(GETBLINK(fx68k)); + /* Set true BFptr,not the residual */ + SETBLINK(new68k,GETBLINK(fx68k)); + ((FX*)new68k)->usecount=0; + CHECK_BF(retbf68k); + +#ifdef BIGVM + if(nametbl_on_stk) + ((FX*)new68k)->nametable += (((UNSIGNED)new68k - (UNSIGNED)fx68k)>>1); +#else + if(nametbl_on_stk) + ((FX*)new68k)->lonametable += (((UNSIGNED)new68k - (UNSIGNED)fx68k)>>1); +#endif + /* increment use count of basic frame of returnee because + we made another FX which points to it */ + retbf68k->usecnt ++; + SET_FASTP_NIL(fx68k); + /* increment use count of CLINK of returnee + because we made a copy of returnee */ + incusecount68k((FX *)Addr68k_from_StkOffset(GETCLINK(fx68k))); + + if(GETCLINK(fx68k) != GETALINK(fx68k)) + { + incusecount68k((FX *)Addr68k_from_StkOffset(GETALINK(fx68k))); + } + + decusecount68k(fx68k);/* if usecon==0 -> FSB */ + SETACLINK(CURRENTFX,StkOffset_from_68K(new68k)); + CHECK_FX(new68k); + CHECK_FX(CURRENTFX); +#ifdef STACKCHECK + stack_check(0); +#endif +#ifdef FLIPCURSOR + flip_cursorbar(5); +#endif + + return((FX*)new68k); + } /* make_FXcopy end */ + + + + +#define MAXSAFEUSECOUNT 200 + +void incusecount68k(FX *fx68k) +{ + StackWord *scanptr68k; + + if(FX_INVALIDP(fx68k)) return; + +CHECK_FX(fx68k); + +if((++(fx68k->usecount)) > MAXSAFEUSECOUNT) + error("MP9324:Stack frame use count maximum exceeded"); + +scanptr68k=(StackWord*)Addr68k_from_StkOffset(fx68k->nextblock); +switch(STKWORD(scanptr68k)->flags) + { + case STK_NOTFLG: + while(STKWORD(scanptr68k)->flags !=STK_BF) + scanptr68k = (StackWord *) + (((DLword *)scanptr68k) + + DLWORDSPER_CELL); + break; + + case STK_BF: break; + + default : return; + /* break; */ + } /* switch end */ + +/* DEBUG */ +S_CHECK((((Bframe*)scanptr68k)->residual==T) || + ( ((Bframe*)scanptr68k)->ivar== fx68k->nextblock) , + "BF not residual, and IVER /= nextblock of prior frame"); + +scanptr68k = (StackWord *) (((DLword *)scanptr68k) + DLWORDSPER_CELL); + +if(STKWORD(scanptr68k)->flags == STK_FX) +{ + CHECK_FX(scanptr68k); + SET_FASTP_NIL(scanptr68k); +} + +} /* incusecount68k end */ + diff --git a/src/hasbcopy b/src/hasbcopy new file mode 100755 index 0000000..88befcf --- /dev/null +++ b/src/hasbcopy @@ -0,0 +1,8 @@ +Cldeetr.c +dlpi.c +ether.c +ldeether.c +ocrproc.c +oether.c +oldeether.c +socket.c diff --git a/src/id b/src/id new file mode 100755 index 0000000..ac2256d --- /dev/null +++ b/src/id @@ -0,0 +1,2 @@ +/* $Id$ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id$ Copyright (C) Venue"; diff --git a/src/imagefile.c b/src/imagefile.c new file mode 100755 index 0000000..f37594f --- /dev/null +++ b/src/imagefile.c @@ -0,0 +1,375 @@ +/* $Id: imagefile.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: imagefile.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include + +#define NOT_IMAGEFILE 0 +#define TYPE_SUNRASTER 1 +#define TYPE_PBM 2 +#define TYPE_PPM 3 + +struct image_info { + int depth; + int width; + int height; +}; + +struct rgb { + unsigned char r; + unsigned char g; + unsigned char b; +}; + +Pixrect *PPM_to_Pixrect() + , *PBM_to_Pixrect() + , *SunRaster_to_Pixrect(); + +#define MAX_BUFF_SIZE 1024 +static char buff[ MAX_BUFF_SIZE ]; + +int +Pixrect_to_File( pix, name ) +Pixrect *pix; +char *name; +{ + FILE *file; + int err = 0; + + switch( pix->pr_depth ) { + case 1: + file = fopen( name, "w" ); + err = Pixrect_to_PBM( file, pix ); + fclose( file ); + break; + case 32: + file = fopen( name, "w" ); + err = Pixrect_to_PPM( file, pix ); + fclose( file ); + break; + case 8: + break; + defaults: + break; + } /* end switch( pix->depth ) */ + + return( err ); +} /* end Pixrect_to_File */ + +Pixrect +*File_to_Pixrect( name ) +char *name; +{ + FILE *file; + Pixrect *pix; + int type; + + file = fopen( name, "r" ); + + type = image_file_type( file ); + + switch( type ) { + case TYPE_SUNRASTER: + pix = SunRaster_to_Pixrect( file ); + break; + case TYPE_PBM: + pix = PBM_to_Pixrect( file ); + break; + case TYPE_PPM: + pix = PPM_to_Pixrect( file ); + break; + defaults: + break; + } /* end switch */ + + fclose( file ); + + return( pix ); + +} /* end File_to_Pixrect */ + +#define magic_number_PBM "P4" +#define magic_number_PPM "P6" + +Pixrect_to_PPM( file, pix ) +FILE *file; +Pixrect *pix; +{ + struct image_info info; + + info.width = pix->pr_width; + info.height = pix->pr_height; + info.depth = pix->pr_depth; + write_PPM_header( file, &info ); + + write_raw_PPM( file, mpr_d(pix)->md_image + , pix->pr_width, pix->pr_height ); + +} /* end Pixrect_to_PPM */ + +Pixrect +*PPM_to_Pixrect( file ) +FILE *file; +{ + Pixrect *pix; + struct image_info info; + + read_PPM_header( file, &info ); + pix = mem_create( info.width, info.height, 32 ); + read_raw_PPM( file, mpr_d(pix)->md_image, info.width, info.height ); + + return( pix ); +} /* PPM_to_Pixrect */ + +Pixrect_to_PBM( file, pix ) +FILE *file; +Pixrect *pix; +{ + struct image_info info; + + info.width = pix->pr_width; + info.height = pix->pr_height; + info.depth = pix->pr_depth; + write_PBM_header( file, &info ); + + write_raw_PBM( file, mpr_d(pix)->md_image + , pix->pr_width, pix->pr_height ); + +} /* end Pixrect_to_PBM */ + +Pixrect +*PBM_to_Pixrect( file ) +FILE *file; +{ + Pixrect *pix; + struct image_info info; + + read_PPM_header( file, &info ); + pix = mem_create( info.width, info.height, 32 ); + read_raw_PPM( file, mpr_d(pix)->md_image, info.width, info.height ); + + return( pix ); + +} /* end PBM_to_Pixrect */ + +Pixrect +*SunRaster_to_Pixrect( file ) +FILE *file; +{ + Pixrect *pix; + colormap_t cmap; + + cmap.type = RMT_NONE; + + pix = pr_load( file, &cmap ); + + return( pix ); +} /* end SunRaster_to_Pixrect */ + +write_raw_PBM( file, data, width, height ) +FILE *file; +unsigned char *data; +int width + , height; +{ + int i + , n + , flg + , len; + + n = ( (width + 15) / 16 ) * 2; /* bytes per line */ + flg = ( width%16 ) / 8; /* PBM is byts alignment */ + for( i=0; ichannel.R; + color24.g = ((union fbunit *)data)->channel.G; + color24.b = ((union fbunit *)data)->channel.B; + len = fwrite( &color24, sizeof( color24 ), 1, file ); + } /* end for( j ) */ + } /* end for( i ) */ +} /* end write_raw_PPM */ + +read_raw_PPM( file, data, width, height ) +FILE *file; +unsigned char *data; +int width + , height; +{ + struct rgb color24; + int i + , j + , len; + + for( i=0; ichannel.R = color24.r; + ((union fbunit *)data)->channel.G = color24.g; + ((union fbunit *)data)->channel.B = color24.b; + } /* end for( j ) */ + } /* end for( i ) */ +} /* endi read_raw_PPM */ + +int +image_file_type( file ) +FILE *file; +{ + int c + , file_type; + + if( (c = getc( file )) == -1 ) return( NOT_IMAGEFILE ); + + switch( c ) { + case 'Y': /* may be Sun Raster format */ + file_type = TYPE_SUNRASTER; + break; + case 'P': { + if( (c = getc( file )) == -1 ) return( NOT_IMAGEFILE ); + if( c == '4' ) file_type = TYPE_PBM; + else if( c == '6' ) file_type = TYPE_PPM; + else file_type = NOT_IMAGEFILE; + } /* end case P */ + break; + defaults: + file_type = NOT_IMAGEFILE; + break; + } /* end switch( c ) */ + + rewind( file ); + + return( file_type ); +} /* end image_file_type */ + +read_PBM_header( file, info ) +FILE *file; +struct image_info *info; +{ + int err; + + err = skip_line( file ); + if( err == 0 ) return( err ); + + err = read_available_line( file, buff ); + if( err == 0 ) return( err ); + err = sscanf( buff, "%d %d", &(info->width), &(info->height) ); + if( err == 0 ) return( err ); + + return( err ); + +} /* end read_PBM_header */ + +write_PBM_header( file, info ) +FILE *file; +struct image_info *info; +{ + fprintf( file, "P4\n" ); + fprintf( file, "%d %d\n", info->width, info->height ); +} /* write_PBM_header */ + +read_PPM_header( file, info ) +FILE *file; +struct image_info *info; +{ + int err; + + err = skip_line( file ); + if( err == 0 ) return( err ); + + err = read_available_line( file, buff ); + if( err == 0 ) return( err ); + err = sscanf( buff, "%d %d", &(info->width), &(info->height) ); + if( err == 0 ) return( err ); + + err = skip_line( file ); + + return( err ); + +} /* read_PPM_header */ + +write_PPM_header( file, info ) +FILE *file; +struct image_info *info; +{ + fprintf( file, "P6\n" ); + fprintf( file, "%d %d\n", info->width, info->height ); + fprintf( file, "255\n" ); +} /* end write_PPM_header */ + +int +skip_line( file ) +FILE *file; +{ + char *err; + char buff[ MAX_BUFF_SIZE ]; + + err = fgets( buff, (int)MAX_BUFF_SIZE, file ); + return( (int)err ); +} /* end skip_line */ + +int +read_available_line( file, buff ) +FILE *file; +char *buff; +{ + char *err; + err = fgets( buff, MAX_BUFF_SIZE, file ); + while( (err != 0) && (buff[0] == '#') ) { + err = fgets( buff, MAX_BUFF_SIZE, file ); + } /* end while */ + return( (int)err ); +} /* end read_available_line */ diff --git a/src/imagefile2.c b/src/imagefile2.c new file mode 100755 index 0000000..c52050e --- /dev/null +++ b/src/imagefile2.c @@ -0,0 +1,180 @@ +/* $Id: imagefile2.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: imagefile2.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include + +#define FALSE 0 +#define TRUE !FALSE + +typedef struct { + FILE *file; + struct rasterfile rh; + colormap_t colormap; +} RASTERFILE_INFO; + +unsigned int +open_rasterfile( filename ) +char *filename; +{ + FILE *file; + RASTERFILE_INFO *fileinfo; + int status; + + if( (fileinfo = (RASTERFILE_INFO*)malloc( sizeof( RASTERFILE_INFO ) )) == 0 ) { + return( 0 ); + } /* end if( fileinfo ) */ + + if( (fileinfo->file = fopen( filename, "r" )) != 0 ) { + if( (status = pr_load_header( fileinfo->file + , &(fileinfo->rh) )) == 0 ) { + if( fileinfo->rh.ras_magic == RAS_MAGIC ) { + /* RasterFile */ + pr_load_colormap( fileinfo->file + , &(fileinfo->rh) + , &(fileinfo->colormap) ); + /* normal case */ + return( (unsigned int)fileinfo ); + } /* end if( fileinfo->rh.ras_magic ) */ + fclose( fileinfo->file ); + } /* end if( status ) */ + } /* end if( file ) */ + + free( fileinfo ); + return( 0 ); /* error return */ + +} /* end open_rasterfile */ + +unsigned int +create_rasterfile( filename ) +char *filename; +{ + RASTERFILE_INFO *fileinfo; + + if( !(fileinfo = (RASTERFILE_INFO*)malloc( sizeof( RASTERFILE_INFO ) )) ) { + return( 0 ); + } /* end if( fileinfo ) */ + fileinfo->file = fopen( filename, "w" ); + + fileinfo->rh.ras_magic = 0; + + return( (unsigned int)fileinfo ); + +} /* end create_rasterfile */ + +close_rasterfile( fileinfo ) +RASTERFILE_INFO *fileinfo; +{ + fclose( fileinfo->file ); + free( (char*)fileinfo ); +} /* end close_rasterfile */ + +unsigned int +read_rasterfile( fileinfo ) +RASTERFILE_INFO *fileinfo; +{ + Pixrect *pict; + pict = pr_load_std_image( fileinfo->file + , &(fileinfo->rh) + , &(fileinfo->colormap) ); + return( (unsigned int)pict ); + +} /* end read_rasterfile */ + +int +write_rasterfile( fileinfo, pix ) +RASTERFILE_INFO *fileinfo; +Pixrect *pix; +{ + int status; + + if( fileinfo->rh.ras_magic == RAS_MAGIC ) { + if( ( fileinfo->rh.ras_width != pix->pr_size.x ) + || ( fileinfo->rh.ras_height != pix->pr_size.y ) + || ( fileinfo->rh.ras_depth != pix->pr_depth ) ) { + return( FALSE ); + } /* end if( .. ) */ + } else { + if( !(status = init_rasterfile_header( fileinfo, pix )) ) { + return( FALSE ); + } /* end if( !status ) */ + } /* end if( fileinfo->rh.ras_magic ) */ + + if( (status = pr_dump_image( pix, fileinfo->file, &(fileinfo->rh) )) == NULL ) { + return( TRUE ); /* normal return */ + } + return( FALSE ); +} /* end write_rasterfile */ + +int +init_rasterfile_header( fileinfo, pix ) +RASTERFILE_INFO *fileinfo; +Pixrect *pix; +{ + Pixrect *ret_pix; + int status; + + switch( pix->pr_depth ) { + case 32: + if( !(ret_pix = pr_dump_init( pix, &(fileinfo->rh) + , NULL, 0 )) ) { + return( FALSE ); + } /* end if( ret_pix ) */ + + fileinfo->rh.ras_length = fileinfo->rh.ras_width * fileinfo->rh.ras_height * 4; + fileinfo->rh.ras_type = RT_STANDARD; + + if( (status = pr_dump_header( fileinfo->file + , &(fileinfo->rh), NULL )) ) { + return( FALSE ); + } /* end if( status ) */ + break; + case 1: + case 8: + default: + return( FALSE ); + break; + } /* end switch( pix->pr_depth ) */ + + return( TRUE ); +} /* end init_rasterfile_header */ + +int +position_rasterfile( fileinfo, n ) +RASTERFILE_INFO *fileinfo; +int n; +{ + long position; + int status; + + if( n > 0 ) { + position = sizeof( struct rasterfile ) + + (n - 1)*fileinfo->rh.ras_length; + if( (status = fseek( fileinfo->file + , position, (int)0 )) == 0 ) { + /* normal return */ + return( TRUE ); + } /* end if( status ) */ + } /* end if( n ) */ + + /* error return */ + return( FALSE ); + +} /* end position_rasterfile */ diff --git a/src/inet.c b/src/inet.c new file mode 100755 index 0000000..46807f3 --- /dev/null +++ b/src/inet.c @@ -0,0 +1,480 @@ +/* $Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +#include "version.h" + + +#include +#include +#ifndef DOS +#include +#include +#include +#ifdef ISC +#include +#include +#endif /* ISC */ + +#ifdef OS5 +#include +#endif /* OS5 */ + +#include +#include +#include +#include +#include +#include +#endif /* DOS */ +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "arith.h" +#include "emlglob.h" +#include "lspglob.h" +#include "adr68k.h" +#include "ether.h" +#include "dbprint.h" +#include "locfile.h" + +#ifdef HPUX +#define FASYNC O_NONBLOCK +#endif /* NPUX */ + +#ifdef ISC +#define FASYNC O_NONBLOCK +#define SIGIO SIGPOLL +#endif /* ISC */ + + +#ifdef GCC386 +#include "inlnPS2.h" +#endif + + +#ifdef OS5 +#define ToMem memmove +#else +#define ToMem memcpy +#endif /* !OS5 */ + +#define TCPhostlookup 0 +#define TCPservicelookup 1 +#define TCPsocket 2 +#define TCPclose 3 +#define TCPconnect 4 +#define TCPsend 5 +#define TCPrecv 6 +#define TCPListen 7 +#define TCPAccept 8 + +#define INETpeername 64 /* (socket buf) => buf has name, returns len */ +#define INETpeeraddr 65 +#define INETgetname 66 /* Address to name translation */ + +#define UDPListen 128 +#define UDPConnect 129 +#define UDPSendto 130 +#define UDPRecvfrom 131 + + +extern u_int LispIOFds, LispReadFds; +extern int *Lisp_errno; + +subr_TCP_ops (op, nameConn, proto, length, bufaddr, maxlen) + int op; + LispPTR nameConn, proto, length, bufaddr, maxlen; + { +#ifndef DOS + int sock, len, buflen, res; + char namestring[100]; + char servstring[50]; + struct sockaddr_in addr; + struct hostent *host; + struct servent *service; + struct sockaddr_in farend; + int addr_class, protocol; + char *buffer; + int result; +#ifdef RS6000 + static int one=1; /* Used in TCPconnect */ +#endif +#ifdef HPUX + static int one=1; /* Used in TCPconnect */ +#endif + + switch (op & 0xFFFF) + { + case TCPhostlookup: LispStringToCString(nameConn, namestring, 100); + host = gethostbyname(namestring); + if (!host) return(NIL); + N_ARITH_SWITCH(*(int *)host->h_addr); + break; + + case TCPservicelookup: LispStringToCString(nameConn, namestring, 100); + LispStringToCString(proto, servstring, 50); + service = getservbyname(namestring, servstring); + if (!service) return(NIL); + return(GetSmallp(service->s_port)); + break; + + case TCPsocket: addr_class = LispNumToCInt(nameConn); + protocol = LispNumToCInt(proto); + result = socket(addr_class, protocol, 0); +#ifdef RS6000 + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) + | FNDELAY | FASYNC); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ + +#endif /* HPUX */ + +#endif /* RS6000 */ + + return(GetSmallp(result)); + break; + + case TCPconnect: /* args: hostname, socket# */ + memset(&farend, 0, sizeof farend); + N_GETNUMBER(nameConn, res, string_host); + farend.sin_addr.s_addr = htons(res); + goto host_ok; + string_host: + LispStringToCString(nameConn, namestring, 100); + host = gethostbyname(namestring); + if (!host) return(NIL); + ToMem( (char *)&farend.sin_addr, + (char *)host->h_addr, + host->h_length); + host_ok: + sock = LispNumToCInt(proto); + result = socket(AF_INET, SOCK_STREAM, 0); + farend.sin_family = AF_INET; + ToMem( (char *)&farend.sin_addr, + (char *)host->h_addr, + host->h_length); + farend.sin_port = sock; + if (connect(result, (struct sockaddr *)&farend, + sizeof farend)<0) + { + perror("TCP connect"); + return(NIL); + } +#ifdef RS6000 + /* FNDELAY alone isn't enough on aix */ + /* (don't know if FIONBIO alone is enough) */ + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) + | FNDELAY); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ + +#endif /* HPUX */ + +#endif /* RS6000 */ + + return(GetSmallp(result)); + break; + + case TCPsend: /* args: conn, buffer, len */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + len = LispNumToCInt(length); + DBPRINT(("sock: %d, len %d.\n", sock, len)); + +#ifdef BYTESWAP + word_swap_page(buffer, (len + 3) >> 2); +#endif /* BYTESWAP */ + + + result = send(sock, buffer, len, 0); + +#ifdef BYTESWAP + word_swap_page(buffer, (len + 3) >> 2); +#endif /* BYTESWAP */ + + + if (result < 0) + { + perror("TCP send"); return(NIL); + } + return(GetSmallp(result)); + break; + + case TCPrecv: /* args: conn, buffer, maxlen */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + len = LispNumToCInt(length); + result = read(sock, buffer, len); + if (result < 0) + { + if (errno == EWOULDBLOCK) + return(ATOM_T); + perror("TCP read"); + *Lisp_errno = errno; + return(NIL); + } +#ifdef BYTESWAP + word_swap_page(buffer, (result + 3) >> 2); +#endif /* BYTESWAP */ + + return(GetSmallp(result)); + break; + + + case TCPclose: sock = LispNumToCInt(nameConn); + LispIOFds &= ~(1<h_name); + return(GetSmallp(strlen(host->h_name))); + break; + + case INETgetname: /* host addr, buffer for name string */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + res = sizeof(addr); + addr.sin_addr.s_addr = sock; + host = gethostbyaddr((const char *)&addr, res, 0); + if (!host) return(GetSmallp(0)); + strcpy(buffer, host->h_name); + return(GetSmallp(strlen(host->h_name))); + break; + + case UDPListen: /* socket# to listen on */ + sock = LispNumToCInt(nameConn); + result = socket(AF_INET, SOCK_DGRAM, 0); + farend.sin_family = AF_INET; + farend.sin_port = sock; + farend.sin_addr.s_addr = INADDR_ANY; + if (bind(result, (struct sockaddr *)&farend, sizeof(farend))<0) + { + perror("UDP bind"); + close(result); + return(NIL); + } +#ifdef RS6000 + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) + | FNDELAY | FASYNC); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ + +#endif /* HPUX */ + +#endif /* RS6000 */ + + LispIOFds |= (1 << result); /* so we get interrupts */ + LispReadFds |= LispIOFds; + DBPRINT(("LispIOFds = 0x%x.\n", LispIOFds)); + return(GetSmallp(result)); + break; + + case UDPSendto: /* fd-socket# addr remote-socket buffer len*/ + sock = LispNumToCInt(nameConn); + farend.sin_family = AF_INET; + farend.sin_port = LispNumToCInt(length); + farend.sin_addr.s_addr = LispNumToCInt(proto); + buffer = (char *) Addr68k_from_LADDR(bufaddr); + buflen = LispNumToCInt(maxlen); + + DBPRINT(("UDP send: socket = %d, remote-port = %d.\n", + sock, farend.sin_port)); + DBPRINT((" remote-addr = 0x%x, buflen = %d.\n", + farend.sin_addr.s_addr, buflen)); + + +#ifdef BYTESWAP + word_swap_page(buffer, (buflen + 3) >> 2); +#endif /* BYTESWAP */ + + + if (result = sendto(sock, buffer, buflen, 0, + (struct sockaddr *)&farend, sizeof farend) <0) + +#ifdef BYTESWAP + word_swap_page(buffer, (buflen + 3) >> 2); +#endif /* BYTESWAP */ + + + { + perror("UDP Send"); + printf(" fd = %d, addr = 0x%x.\n", sock, + farend.sin_addr.s_addr); + return(NIL); + } + return(GetSmallp(result)); + break; + + case UDPRecvfrom: /* fd-socket# buffer len addr-cell port-cell*/ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + buflen = LispNumToCInt(length); + res = sizeof farend; + if ((result = recvfrom(sock, buffer, buflen, 0, + (struct sockaddr *)&farend, &res)) <0) + { + perror("UDP Recv"); + return(NIL); + } + + DBPRINT(("UDP recv: socket = %d, len = %d.\n", + sock, result)); + DBPRINT((" remote-addr = 0x%x, remote-port = %d.\n", + farend.sin_addr.s_addr, farend.sin_port)); + DBPRINT((" bufsize = %d, addrcell = 0x%x, portcell = 0x%x.\n", + buflen, bufaddr, maxlen)); + + *((int *)Addr68k_from_LADDR(bufaddr)) = (int)farend.sin_addr.s_addr; + *((int *)Addr68k_from_LADDR(maxlen)) = (int)farend.sin_port; + +#ifdef BYTESWAP + word_swap_page(buffer, (result + 3) >> 2); +#endif /* BYTESWAP */ + + return(GetSmallp(result)); + break; + + + default: return(NIL); + break; + } +#endif /* DOS */ + } + diff --git a/src/initdsp.c b/src/initdsp.c new file mode 100755 index 0000000..779fe73 --- /dev/null +++ b/src/initdsp.c @@ -0,0 +1,931 @@ +/* $Id: initdsp.c,v 1.2 1999/01/03 02:07:08 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: initdsp.c,v 1.2 1999/01/03 02:07:08 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +/* + * file : initdsp.c + * Author : Osamu Nakamura + */ + + + +#include + +#ifndef NOPIXRECT +#ifndef DOS +#ifdef XWINDOW +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#else +#include +#include +#include +#endif /* XWINDOW */ +/* #include */ +#include +#include +#include +#include +#include +#include +#endif /* DOS */ +#include +#endif /* NOPIXRECT */ + +#ifdef OS4 +#include +#endif /* OS4 */ + +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "emlglob.h" +#include "display.h" +#include "devconf.h" + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" +#include "dbprint.h" + +#ifdef ISC +#define getpagesize() 512 +#endif /* ISC */ + +#ifdef DOS +#define getpagesize() 512 +#endif /* DOS */ + +#if defined(XWINDOW) || defined(DOS) +#include "devif.h" +DLword *DisplayRegion68k_end_addr; +extern DspInterface currentdsp; +int DisplayWidth8; +extern DspInterfaceRec _curdsp, _coldsp; +#endif /* DOS */ + + +/* from /usr/include/sun/fbio.h some machines don't have following def. */ +#ifndef FBTYPE_SUNROP_COLOR +#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */ +#define FBTYPE_SUNFAST_COLOR 12 +#endif + +#ifndef NOPIXRECT +struct screen LispScreen; +struct pixrect *CursorBitMap, *InvisibleCursorBitMap; +struct pixrect *SrcePixRect, *DestPixRect; +#ifdef DISPLAYBUFFER + int black = 0, white = -1; + struct pixrect *ColorDisplayPixrect, + *DisplayRegionPixrect; +#define COPY_PIXRECT_TO_COLOR (PIX_SRC /*| PIX_DONTCLIP */) +#ifdef DEBUG + int oldred[2], oldgreen[2], oldblue[2]; +#endif /* DEBUG */ +#endif /* DISPLAYBUFFER */ +#endif /* NOPIXRECT */ + +int LispWindowFd; +int FrameBufferFd; + +int displaywidth, displayheight, DisplayRasterWidth, DisplayType; +int DisplayByteSize; +DLword *DisplayRegion68k; /* 68k addr of #{}22,0 */ + +#ifdef DISPLAYBUFFER +/* both vars has same value. That is the end of Lisp DisplayRegion */ +DLword *DisplayRegion68k_end_addr; +#endif + +/* some functions use this variable when undef DISPLAYBUFFER */ +DLword *DISP_MAX_Address; + +#ifdef SUNDISPLAY +struct cursor CurrentCursor, InvisibleCursor; +struct winlock DisplayLockArea; +#endif /* SUNDISPLAY */ + +extern DLword *EmCursorBitMap68K; +extern int errno; +extern IFPAGE *InterfacePage; + +int DebugDSP = T; + +#ifdef COLOR +extern DLword *ColorDisplayRegion68k; +extern int MonoOrColor; +#endif /* COLOR */ + +#ifdef XWINDOW +DLword *DisplayRegion68k_end_addr; +int LispDisplayWidth + , LispDisplayHeight; +extern int *Xdisplay; /* DAANGER -jarl nilsson 27-apr-92 */ +#endif /* XWINDOW */ + +#ifdef SUNDISPLAY +/* For SunOS4.1 Window Security Feature. */ +int Win_security_p; +#include +#define SV_ACQUIRE "/bin/sunview1/sv_acquire" +#define SV_RELEASE "/bin/sunview1/sv_release" +#endif /* SUNDISPLAY */ + + +/* ================================================================ */ +/* Now takes 68k address, function renamed for safety */ + +init_display2(display_addr, display_max) + int display_addr, display_max; + { + int mmapstat; + int fbgattr_result; + char *texture_base, *malloc(); + +#ifdef SUNDISPLAY + struct fbtype my_screen; + char groups[PIXPG_OVERLAY+1]; + struct fbgattr FBattr; + struct pixrect *ColorFb; +#endif /* SUNDISPLAY */ + +#ifdef SUNDISPLAY + + /* For SunOS4.1 Window Security Feature. */ + + union wait status; + + /* Window Security is available? */ + if (!access(SV_ACQUIRE, F_OK)) + Win_security_p = 1; + else + Win_security_p = 0; + + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ + (void)fprintf(stderr, "init_display: Fork failed.\n"); + exit(1); + + case 0: /* Child */ + (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); + /* should not return */ + (void)fprintf(stderr, "init_display: exec for sv_acquire failed\n"); + exit(1); + + default: /* Parent */ + /* do nothing */ + break; + } + (void)wait(&status); /* child dies after changing 6 */ + + if (status.w_retcode != 0) { + (void)fprintf(stderr, + "init_display: failed to set ownership of win devices\n"); + exit(1); + } + } + +#endif /* SUNDISPLAY */ + +#ifdef SUNDISPLAY + if( (LispWindowFd = win_screennew( &LispScreen )) == -1) + { + perror("init_display: can't create LispWindow\n"); + exit( -1 ); + } + else + { +#ifdef KBINT + /* int_io_open(LispWindowFd); JDS 4/27/94 move to initkbd, to try preventing the move-mouse-never-get-kbd bug */ +#endif + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); + } +#endif /* SUNDISPLAY */ + + DisplayRegion68k = (DLword *) display_addr; + +#ifdef SUNDISPLAY + if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1) + { + perror("init_display: can't open FrameBuffer\n"); + exit( -1 ); + } + + /* initialize Display parameters */ + if (ioctl(FrameBufferFd, FBIOGTYPE , &my_screen)== -1) + { + perror("init_display: can't find screen parameters\n"); + exit( -1 ); + } + displaywidth = my_screen.fb_width; + displayheight = my_screen.fb_height; +#endif /* SUNDISPLAY */ + +#if (defined(XWINDOW) || defined(DOS)) + (currentdsp->device.enter)(currentdsp); + displaywidth = currentdsp->Display.width; + displayheight = currentdsp->Display.height; +#endif /* XWINDOW */ + + DisplayRasterWidth = displaywidth / BITSPER_DLWORD; + + if ((displaywidth * displayheight) > display_max) + { + displayheight = display_max / displaywidth; + } + DISP_MAX_Address = DisplayRegion68k + DisplayRasterWidth * displayheight; + DBPRINT(("FBIOGTYPE w x h = %d x %d\n", displaywidth, displayheight)); + + + +#ifdef DOS + DisplayWidth8 = displaywidth / 8; +#endif /* DOS */ + + DBPRINT(("FBIOGTYPE w x h = %d x %d\n", displaywidth, displayheight)); +#if (!defined(XWINDOW) && !defined(DOS)) + DBPRINT((" (real) type = %d\n", my_screen.fb_type )); + DBPRINT((" (real) bpp = %d\n", my_screen.fb_depth )); +#endif /* XWINDOW */ + +#ifdef SUNDISPLAY +/** now attempt to use the FBIOGATTR call for more information **/ + + fbgattr_result = ioctl(FrameBufferFd, FBIOGATTR, &FBattr); + if( fbgattr_result >= 0 ) + { + DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type)); + DBPRINT((" (real) size = %d x %d\n", FBattr.fbtype.fb_width, + FBattr.fbtype.fb_height)); + DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type )); + DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth )); + DBPRINT((" emuls= %d %d %d %d\n", + FBattr.emu_types[0], FBattr.emu_types[1], + FBattr.emu_types[2], FBattr.emu_types[3])); + } + else + { /* fill in defaults */ + FBattr.real_type = my_screen.fb_type; + } + DBPRINT (("init_display: FBIOGATTR_result = %d\n", fbgattr_result)); +/* probe for DISPLAY type */ +/********************************************************************** + * FB-TYPE REAL-TYPE + * BW2 2 x + * CG2 3 3 + * CG3 8 6 + * CG4 2 8 + * CG6 8 12 + * CG8 6 7 + * CG9(GP1) 4 4 ;gpconfig -f -b + * CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 + * ;We assume This config for GXP model + ***********************************************************************/ +/* Medley supports real (or emulated) BW2, so check for that first */ +#ifndef DISPLAYBUFFER + + if ( (my_screen.fb_type == FBTYPE_SUN2BW ) /* real or emulated bwtwo */ + ||(my_screen.fb_type == FBTYPE_SUN3COLOR) ) /* Sun 3 color? */ + switch ( FBattr.real_type ) + { + case FBTYPE_SUN2BW : DisplayType = SUN2BW; + break; + + case FBTYPE_MEMCOLOR : /* memory 24-bit (CG8) */ + { + DisplayType = SUNMEMCOLOR; + ColorFb = pr_open("/dev/fb"); + pr_available_plane_groups( ColorFb, sizeof(groups), groups); + if(groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) + { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, + PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + } + break; + + case FBTYPE_SUN4COLOR : /* cg4 */ + case FBTYPE_SUNROP_COLOR : /* cg9(GXP) */ + { /* need to clear overlay plane */ + DisplayType = SUN4COLOR; + ColorFb = pr_open("/dev/fb"); + pr_available_plane_groups( ColorFb, sizeof(groups), groups); + if(groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) + { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, + PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + break; + } + + default : + printf("initdisplay: Unsupported FBreal_type %d\n", + FBattr.real_type); + DisplayType = (my_screen.fb_type) << 3; + /* should be able to proceed, since its an emulated bwtwo */ + } + else + { /* not currently a SUN2BW, perhaps can emulate it? */ + if ( fbgattr_result >= 0 ) + { /* got gattrs, can try sattr */ +#ifdef DEBUG + error ( "fb bwtwo emulation not implemented, q to proceed\n" ); +#endif /* DEBUG */ + } + else + { + error ( "Not cgfour or bwtwo, q to attempt to proceed" ); + } + printf("initdisplay: Unsupported FBreal_type %d\n", FBattr.real_type); + DisplayType = (my_screen.fb_type) << 3; + /* try to muddle on */ + } +#else /* DISPLAYBUFFER is defined, then: */ + DisplayRegion68k_end_addr = DisplayRegion68k + + DisplayRasterWidth * displayheight; +if ( my_screen.fb_type == FBTYPE_SUN2BW ) /* real or emulated bwtwo */ + switch ( FBattr.real_type ) + { + case FBTYPE_SUN4COLOR : + { /* need to clear overlay plane */ + DisplayType = SUN4COLOR; + ColorFb = pr_open("/dev/fb"); + pr_available_plane_groups( ColorFb, sizeof(groups), groups); + if(groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) + { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, + PIX_CLR, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); + } + ColorDisplayPixrect = ColorFb; + break; + } + + default : ColorDisplayPixrect = pr_open("/dev/fb"); + break; + } + +else if( my_screen.fb_type == FBTYPE_SUN4COLOR ) { /* cg3 or cg6 */ + switch ( FBattr.real_type ) { + case FBTYPE_SUN3COLOR: /* cg3 */ + /* DisplayType = SUN3COLOR; */ + DisplayType = (FBattr.real_type) << 3; + break; + case FBTYPE_SUNFAST_COLOR: /* cg6 */ + /* DisplayType = SUNFASTCOLOR; */ + DisplayType = (FBattr.real_type) << 3; + break; + default: /* unknown display */ + DisplayType = (FBattr.real_type) << 3; + break; + } /* end switch */ + ColorDisplayPixrect = pr_open("/dev/fb"); +} /* end else if() */ + + else ColorDisplayPixrect = pr_open("/dev/fb"); + DisplayRegionPixrect = mem_point(displaywidth, displayheight, + 1, display_addr); +#ifdef I386 + ((struct mpr_data *)DisplayRegionPixrect->pr_data)->md_flags |= MP_I386; + ((struct mpr_data *)ColorDisplayPixrect->pr_data)->md_flags |= MP_I386; +#endif + +#ifdef DEBUG + pr_getcolormap(ColorDisplayPixrect, 0, 2, oldred, oldgreen, oldblue); +#endif /* DEBUG */ + DBPRINT(("Color map for color pixrect:\n 0: R: %d, G: %d, B: %d\n 1: R: %d, G: %d, B: %d\n", oldred[0], oldgreen[0], oldblue[0], oldred[1], oldgreen[1], oldblue[1])); + DBPRINT(("Color depth = %d.\n", ColorDisplayPixrect->pr_depth)); + pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); + pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, + (1<pr_depth)-1, 1, + &black, &black, &black); +#endif + + DisplayLockArea.wl_rect.r_width = displaywidth; + DisplayLockArea.wl_rect.r_height = displayheight; + +#endif /* SUNDISPLAY */ + +#ifdef XWINDOW + DisplayType = SUN2BW; + DisplayRegion68k_end_addr = DisplayRegion68k + + DisplayRasterWidth * displayheight; +#endif /* XWINDOW */ + + init_cursor(); + DisplayByteSize= ((displaywidth * displayheight / 8 + (getpagesize()-1) ) + & -getpagesize()); + + DBPRINT(("Display address: 0x%x\n",DisplayRegion68k)); + DBPRINT((" length : 0x%x\n",DisplayByteSize)); + DBPRINT((" pg size: 0x%x\n",getpagesize())); + +#ifdef SUNDISPLAY +#ifndef DISPLAYBUFFER + mmapstat = (int)mmap( DisplayRegion68k, + DisplayByteSize, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0 ); + + DBPRINT(("after mmap: 0x%x\n",mmapstat)); + + if(mmapstat == -1) + { + perror("init_display: ERROR at mmap system call\n"); + exit( 0 ); + } +#endif /* ifndef DISPLAYBUFFER */ + + DBPRINT(("after mem_point\n")); +#endif /* SUNDISPLAY */ + +#ifdef DOS + (currentdsp->cleardisplay)(currentdsp); +#else /* DOS */ + clear_display(); +#endif /* DOS */ + + DBPRINT(("after clear_display()\n")); + +#ifndef NOPIXRECT + /* initialize pixrect used in pilotbitblt */ + SrcePixRect = mem_point( 0, 0, 1, NULL ); + DestPixRect = mem_point( 0, 0, 1, NULL ); +#endif /* NOPIXRECT */ + + DBPRINT(("exiting init_display\n")); +} + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +init_cursor() + { + +#ifndef NOPIXRECT + CursorBitMap = mem_create( CURSORWIDTH, CURSORHEIGHT, 1 ); + mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3;/* 2(byte) */ +#endif /* NOPIXRECT */ + +#ifdef SUNDISPLAY + CurrentCursor.cur_xhot = 0; + CurrentCursor.cur_yhot = 0; + CurrentCursor.cur_shape = CursorBitMap; + CurrentCursor.cur_function = PIX_SRC | PIX_DST; +#endif /* SUNDISPLAY */ + + /* Invisible Cursor */ + +#ifndef NOPIXRECT + InvisibleCursorBitMap = mem_create( 0, 0, 1 ); +#endif /* NOPIXRECT */ + +#ifdef SUNDISPLAY + InvisibleCursor.cur_xhot = 0; + InvisibleCursor.cur_yhot = 0; + InvisibleCursor.cur_shape = InvisibleCursorBitMap; + InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST; + win_setcursor( LispWindowFd, &InvisibleCursor); + win_setmouseposition(LispWindowFd, 0, 0); +#endif /* SUNDISPLAY */ + + } + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +set_cursor() + { +#ifdef SUNDISPLAY +#ifdef OLD_CURSOR + (mpr_d(CursorBitMap))->md_image = + (short *)(IOPage->dlcursorbitmap); + /* BitmapBase of CurrentCursor + * is set to IOPage->dlcursorbitmap + */ + if( win_setcursor( LispWindowFd, &CurrentCursor )== -1) + perror("SET Cursor"); + if( win_setmouseposition(LispWindowFd, 0, 0)==-1) + perror("SET Mouse POS"); +#else + if( win_setcursor(LispWindowFd,&InvisibleCursor) ==-1) + perror("SET Cursor:"); +#endif +#endif /* SUNDISPLAY */ + +#ifdef XWINDOW + Init_XCursor(); +#endif /* XWINDOW */ + + DBPRINT(("After Set cursor\n")); +} + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +display_before_exit() + { +#ifdef SUNDISPLAY + union wait status; +#endif /* SUNDISPLAY */ + +#ifdef TRUECOLOR + truecolor_before_exit(); +#endif /* TRUECOLOR */ + + clear_display(); +#ifdef SUNDISPLAY + /* win_remove( LispWindowFd ); */ + win_screendestroy( LispWindowFd ); +#ifdef KBINT + int_io_close(LispWindowFd); +#endif + close( LispWindowFd ); + + if (Win_security_p) { + + switch (vfork()) { + case -1: /* Error */ + (void)fprintf(stderr, "display_before_exit: Fork failed.\n"); + exit(1); + + case 0: /* Child */ + (void)execl(SV_RELEASE, "sv_release", 0); + /* should not return */ + (void)fprintf(stderr, + "display_before_exit: exec for sv_release failed\n"); + exit(1); + + default: /* Parent */ + /* do nothing */ + break; + } + (void)wait(&status); + if (status.w_retcode != 0) { + (void)fprintf(stderr, + "display_before_raid: failed to set ownership of win devices\n"); + exit(1); + } + } + +#endif /* SUNDISPLAY */ + +#if defined(XWINDOW) || defined(DOS) + (currentdsp->device.exit)(currentdsp); +#endif /* DOS */ + } + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +#ifndef COLOR +clear_display() + { +#ifdef SUNDISPLAY +#ifndef DISPLAYBUFFER + register short *word; + register int w, h; + word =(short*) DisplayRegion68k; + for (h = displayheight; (h--);) + { + for (w = DisplayRasterWidth; (w--);) {*word++ = 0;} + } +#else + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, + PIX_CLR, + ColorDisplayPixrect, 0, 0); + /* Original images are still kept in SYSOUT(DisplayRegion) */ + /* clear_CG6; */ +#endif /* DISPLAYBUFFER */ + +#endif /* SUNDISPLAY */ + +#ifdef DOS + TPRINT(("Enter Clear_display\n")); + (currentdsp->cleardisplay)(currentdsp); + TPRINT(("Exit Clear_display\n")); +#endif /* DOS */ + + } + +#else /* COLOR */ + +clear_display() +{ + register short *word; + register int w, h; + if( MonoOrColor == MONO_SCREEN ) { +#ifndef DISPLAYBUFFER + word = DisplayRegion68k; + for( h=displayheight; (h--);) { + for( w=DisplayRasterWidth; (w--);) {*word++ = 0;} + } /* end for(h) */ +#else /* DISPLAYBUFFER */ + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, + PIX_CLR,ColorDisplayPixrect, 0, 0); +#endif /* DISPLAYBUFFER */ + } else { /* MonoOrColo is COLOR_SCREEN */ + word = (short *)ColorDisplayRegion68k; + for( h=displayheight; (h--);) { + for( w=DisplayRasterWidth*8; (w--);) {*word++ = 0;} + } /* end for(h) */ + } /* end if(MonoOrColor) */ +} +#endif /* COLOR */ + +#ifdef DISPLAYBUFFER + +#ifdef I386 +#define EVENADDR(ptr) (0xFFFFFFFE & (int)ptr) +#else +#define EVENADDR(ptr) (ptr) +#endif + +#endif /* DISPLAYBUFFER */ + +#if defined(DISPLAYBUFFER) || defined(DOS) +/************************************************************************/ +/* */ +/* i n _ d i s p l a y _ s e g m e n t */ +/* */ +/* Returns T if the base address for this bitblt is in the */ +/* display segment. */ +/* */ +/************************************************************************/ +/* Change as MACRO by osamu '90/02/08 + * new macro definition is in display.h +in_display_segment(baseaddr) + register DLword *baseaddr; + { + if ((DisplayRegion68k <= baseaddr) && + (baseaddr <=DISP_MAX_Address)) return(T); + return(NIL); + } +------------------ */ +#endif /* DISPLAYBUFFER */ + + +/************************************************************************/ +/* */ +/* f l u s h _ d i s p l a y _ b u f f e r */ +/* */ +/* Copy the entire Lisp display bank to the real frame buffer */ +/* [Needs to be refined for efficiency.] */ +/* */ +/************************************************************************/ + +flush_display_buffer() + { +#ifdef SUNDISPLAY +#ifdef DISPLAYBUFFER +#ifdef I386 + bit_reverse_region( DisplayRegion68k, displaywidth, + displayheight, DLWORD_PERLINE); +#endif + + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, + COPY_PIXRECT_TO_COLOR, + DisplayRegionPixrect, 0, 0); + +#ifdef I386 + bit_reverse_region( DisplayRegion68k, displaywidth, + displayheight, DLWORD_PERLINE); +#endif +#endif /* DISPLAYBUFFER */ +#endif /* SUNDISPLAY */ + +#ifdef XWINDOW + (currentdsp->bitblt_to_screen)(currentdsp, + DisplayRegion68k, + currentdsp->Vissible.x, + currentdsp->Vissible.y, + currentdsp->Vissible.width, + currentdsp->Vissible.height ); +#elif DOS + TPRINT(("Enter flush_display_buffer\n")); + (currentdsp->bitblt_to_screen)(currentdsp, + DisplayRegion68k, + 0, 0, + currentdsp->Display.width, + currentdsp->Display.height ); + TPRINT(("Exit flush_display_buffer\n")); +#endif /* DOS */ + } + + +/************************************************************************/ +/* */ +/* f l u s h _ d i s p l a y _ r e g i o n */ +/* */ +/* Copy a region of the Lisp display bank to the real frame */ +/* buffer. */ +/* */ +/* x */ +/* y */ +/* w the width of the piece to display, in pixels */ +/* h the height of the piece to display, in pixels */ +/* */ +/************************************************************************/ +#define BITEPER_DLBYTE 8 +#define DLBYTE_PERLINE (displaywidth/8) + +flush_display_region(x, y, w, h) + int x, y, w, h; + { +#ifdef SUNDISPLAY +#ifdef DISPLAYBUFFER + + pr_rop(ColorDisplayPixrect, x, y, w, h, + COPY_PIXRECT_TO_COLOR, + DisplayRegionPixrect, x, y); +#endif /* DISPLAYBUFFER */ + +#endif /* SUNDISPLAY */ + + +#if (defined(XWINDOW) || defined(DOS)) + TPRINT(("Enter flush_display_region x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); + TPRINT(("Exit flush_display_region\n")); +#endif /* DOS */ +} +#ifdef BYTESWAP +byte_swapped_displayregion(x , y , w , h) + int x ,y,w,h; +{ + extern unsigned char reversedbits[]; + register unsigned int *longptr,*lineptr; + register int linecount,wordlimit; + + + /* Get QUAD byte aligned pointer */ + longptr = (unsigned int *) + (((UNSIGNED)((DLword*)DisplayRegion68k + (DLWORD_PERLINE * y)) + + ((x +7)>>3)) & 0xfffffffc); + + bit_reverse_region(longptr, w, h, DLWORD_PERLINE); + + return; + + }/* byte_swapped_displayregion end */ +#endif /* BYTESWAP */ + + + +/************************************************************************/ +/* */ +/* f l u s h _ d i s p l a y _ l i n e r e g i o n */ +/* */ +/* Copy a region of the Lisp display bank to the real frame */ +/* buffer. */ +/* */ +/* x */ +/* ybase the offset from top of bitmap, as the address of the */ +/* first word of the line to start on. */ +/* w the width of the piece to display, in pixels */ +/* h the height of the piece to display, in pixels */ +/* */ +/************************************************************************/ + +flush_display_lineregion(x, ybase, w, h) + UNSIGNED x, ybase, w, h; +#ifdef I386 + { /*flush_display_buffer(); */ + int y; + y = ((DLword *)ybase-DisplayRegion68k)/DLWORD_PERLINE; + + bit_reverse_region(ybase, displaywidth, h,DLWORD_PERLINE); + pr_rop(ColorDisplayPixrect, x, y, displaywidth, h, + COPY_PIXRECT_TO_COLOR, + DisplayRegionPixrect, x, y); + + bit_reverse_region(ybase, displaywidth, h,DLWORD_PERLINE); + + } +#else + { + int y; + y = ((DLword *)ybase-DisplayRegion68k)/DLWORD_PERLINE; +#ifdef SUNDISPLAY +#ifdef DISPLAYBUFFER + + pr_rop(ColorDisplayPixrect, x, + y, w, h, + COPY_PIXRECT_TO_COLOR, + DisplayRegionPixrect, x, y); +#endif /* DISPLAYBUFFER */ + +#endif /* SUNDISPLAY */ + +#if (defined(XWINDOW) || defined(DOS)) + TPRINT(("Enter flush_display_lineregion x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); + TPRINT(("Exit flush_display_lineregion\n")); +#endif /* DOS */ + + } +#endif /* I386 */ + +/************************************************************************/ +/* */ +/* f l u s h _ d i s p l a y _ p t r r e g i o n */ +/* */ +/* Copy a region of the Lisp display bank to the real frame */ +/* buffer. */ +/* */ +/* bitoffset bit offset into word pointed to by ybase */ +/* ybase the offset from top of bitmap, as the address of the */ +/* word containing the upper-leftmost bit changed. */ +/* w the width of the piece to display, in pixels */ +/* h the height of the piece to display, in pixels */ +/* */ +/************************************************************************/ + +#define BITSPERWORD 16 + +flush_display_ptrregion(ybase, bitoffset, w, h) + UNSIGNED bitoffset, ybase, w, h; +#ifdef I386 + { flush_display_buffer(); } +#else + { + int y, x, baseoffset, realw; + baseoffset = (((DLword *)ybase)-DisplayRegion68k); + y = baseoffset/DLWORD_PERLINE; + x = bitoffset + (BITSPERWORD*(baseoffset - (DLWORD_PERLINE * y))); +#endif /* I386 */ + +#if (defined(SUNDISPLAY) && defined(DISPLAYBUFFER)) + pr_rop(ColorDisplayPixrect, x, y, w, h, COPY_PIXRECT_TO_COLOR, + DisplayRegionPixrect, x, y); +#elif (defined(XWINDOW) || defined(DOS)) + TPRINT(("Enter flush_display_ptrregion\n x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); + TPRINT(("Exit flush_display_ptrregion\n")); +#endif /* DOS */ + } diff --git a/src/initkbd.c b/src/initkbd.c new file mode 100755 index 0000000..df90ec3 --- /dev/null +++ b/src/initkbd.c @@ -0,0 +1,810 @@ +/* $Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +#include +#include +#ifndef DOS +#include +#endif /* DOS */ +#ifdef SUNDISPLAY +#include +#include +#endif /* SUNDISPLAY */ + +#ifdef DOS +#include /* "#pragma interrupt" & '_chain_intr'*/ +#include /* defines REGS & other structs */ +#include /* define NULL */ +#include +#include +#include +#endif /* DOS */ + +#include +#ifdef SUNDISPLAY +#ifndef DOS +#include +#include +#include +#include +#include +#endif /* DOS */ +#endif /* SUNDISPLAY */ + +#ifdef DOS +#define KBD_COMMAND_PORT 0x64 +#define KBD_ENABLE 0xAE +#define KBD_DISABLE 0xAD +#define KBD_RESET 0xF6 + +#define PORT_8042 0x60 +#define KBD_SCAN_CODE_PORT 0x60 + +#define KBD_resend 0xFE +#define KBD_ack 0xFA +#define KBD_echo_responce 0xEE +#define KBD_failiure 0xFD +#define KBD_prefix 0xE0 +#define KBD_pause_prefix 0xE1 +#define KBD_overflow 0x00 + +#define INTA00 0x20 /* The 8259 port */ +#define ENDOFINTERRUPT 0x20 + +#define PRTSC_KEY 0x37 +#define HOME_KEY 0x47 +#define UPARROW_KEY 0x48 +#define PGUP_KEY 0x49 +#define LEFTARROW_KEY 0x4b +#define RIGHTARROW_KEY 0x4d +#define END_KEY 0x4f +#define DOWNARROW_KEY 0x50 +#define PGDOWN_KEY 0x51 +#define INS_KEY 0x52 +#define DEL_KEY 0x53 + +void (*prev_int_09)(); /* keeps address of previous 09 handlr*/ +#pragma interrupt(DOSkbd) +void DOSkbd(void); /* the flih-kbd handler INT 0x09 */ +unsigned char inchar = 0; + +extern int KBDEventFlg; +#endif /* DOS */ + +#ifdef XWINDOW +#include +#include +#include +#include +#include "XKeymap.h" +#include "xdefs.h" +#endif /* XWINDOW */ + + +#ifdef ISC +#include +#endif /* ISC */ + + +#include "lispemul.h" +#include "lispmap.h" +#include "lspglob.h" +#include "adr68k.h" +#include "address.h" + +#include "devconf.h" +#include "iopage.h" +#include "ifpage.h" +#include "keyboard.h" + +#ifdef XWINDOW +#include "devif.h" +extern DspInterface currentdsp; +#endif /* XWINDOW */ + +#ifdef DOS +#include "devif.h" +extern MouseInterface currentmouse; +extern KbdInterface currentkbd; +extern DspInterface currentdsp; +#endif /* DOS */ +#ifdef SUNDISPLAY +extern struct screen LispScreen; +#endif /* SUNDISPLAY */ + + +extern int LispWindowFd; +int LispKbdFd; +extern int errno; + +/* for debug */ +int DebugKBD = NIL; +FILE *KBlog; + +u_int LispReadFds = 0; +#ifdef SUNDISPLAY +struct inputmask LispEventMask; +#endif /* SUNDISPLAY */ +#ifdef xXWINDOW +struct inputmask LispEventMask; +#endif /* XWINDOW */ + + +IOPAGE *IOPage68K; + +DLword *EmMouseX68K; +DLword *EmMouseY68K; +DLword *EmCursorX68K; +DLword *EmCursorY68K; +DLword *EmRealUtilin68K; +DLword *EmUtilin68K; +DLword *EmKbdAd068K; +DLword *EmKbdAd168K; +DLword *EmKbdAd268K; +DLword *EmKbdAd368K; +DLword *EmKbdAd468K; +DLword *EmKbdAd568K; +DLword *EmDispInterrupt68K; +DLword *EmCursorBitMap68K; + +/*u_char SUNLispKeyMap[128];*/ +u_char *SUNLispKeyMap; + +/* keymap for type3 */ +u_char SUNLispKeyMap_for3[128] = { + +/* 0 */ -1, 61, -1, 91, -1, 97, 99, -1, +/* 8 */ 100, -1, 67, -1, 68, -1, 101, -1, +/* 16*/ 66, 104, 80, 47, -1, 73, 74, 75, +/* 24*/ -1, 92, 63, -1, -1, 33, 32, 17, +/* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, +/* 40*/ 10, 59, 45, 13, -1, 81, 82, 83, +/* 48*/ -1, 14, -1, 62, -1, 34, 19, 18, +/* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, +/* 64*/ 58, 29, 15, -1, 84, 85, 87, -1, +/* 72*/ 111, 89, -1, -1, 36, 21, 20, 5, +/* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, +/* 88*/ 105, 44, -1, 94, 69, 70, -1, 90, +/* 96*/ -1, 46, -1, 41, 40, 24, 37, 7, +/*104*/ 39, 54, 55, 27, 42, 12, 60, 71, +/*112*/ 98, 76, 72, -1, -1, -1, -1, 56, +/*120*/ 31, 57, 93, -1, -1, -1, -1, -1, + }; + +/* for type4 */ + +u_char SUNLispKeyMap_for4[128] = { + +/* 0 */ -1, 61, -1, 91, -1, 97, 99, 106, +/* 8 */ 100, 107, 67, 108, 68, 47, 101, 30, +/* 16*/ 66, 104, 80, 31, -1, 75, 110, 74, +/* 24*/ -1, 109, 63, -1, -1, 33, 32, 17, +/* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, +/* 40*/ 10, 59, 45, 15, -1, 64, 65, 95, +/* 48*/ -1, 14, 13, 89, -1, 34, 19, 18, +/* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, +/* 64*/ 58, 29, 13, 93, 81, 82, 83, 96, +/* 72*/ 111, 62, -1, -1, 36, 21, 20, 5, +/* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, +/* 88*/ 105, 44, 76, 84, 85, 87, 98, 90, +/* 96*/ -1, 46, 73, 41, 40, 24, 37, 7, +/*104*/ 39, 54, 55, 27, 42, 12, 60, 71, +/*112*/ 94, 69, 70, -1, -1, -1, 92, 56, +/*120*/ 86, 57, 88, -1, 103, 102, -1, -1, + }; + +/* for jle */ + +u_char SUNLispKeyMap_jle[128] = { + +/* 0 */ -1, 61, -1, 91, -1, 97, 99, 106, +/* 8 */ 100, 107, 67, 108, 68, 47, 101, 71, +/* 16*/ 66, 104, 80, 31, -1, 75, 110, 74, +/* 24*/ -1, 109, 63, -1, -1, 33, 32, 17, +/* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, +/* 40*/ 59, 45, 30, 15, -1, 64, 65, 95, +/* 48*/ -1, 14, 13, 89, -1, 34, 19, 18, +/* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, +/* 64*/ 58, 29, 13, 93, 81, 82, 83, 96, +/* 72*/ 111, 62, -1, -1, 36, 21, 20, 5, +/* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, +/* 88*/ 105, 44, 76, 84, 85, 87, 98, 90, +/* 96*/ -1, 46, 73, 41, 40, 24, 37, 7, +/*104*/ 39, 54, 55, 27, 42, 12, 60, 10, +/*112*/ 94, 69, 70, 72, 103, 109, 92, 56, +/*120*/ 86, 57, 88, -1, -1, 102, -1, -1, + }; +/* [40] 10->59 */ +/* [41] 59->45 */ +/* [42] 45->30 */ +/* [111] 71->10 */ +/* [115] -1 -> 72 Kakutei */ +/* [116] -1 -> 103 Henkan */ +/* [117] -1 -> 109 Nihongo On-Off */ + + + +/* For IBM Risc System 6000 */ + +u_char SUNLispKeyMap_RS6000[128] = { + +/* 7 */ -1, -1, 45, 32, 17, 16, 1, 0, +/* 15*/ 2, 4, 53, 22, 8, 10, 59, -1, +/* 23*/ 15, 34, 19, 18, 3, 48, 49, 51, +/* 31*/ 6, 23, 25, 11, 58, 29, 105, 56, +/* 39*/ 21, 20, 5, 35, 50, 52, 38, 9, +/* 47*/ 26, 43, 28, -1, 44, 41, -1, 40, +/* 55*/ 24, 37, 7, 39, 54, 55, 27, 42, +/* 63*/ 12, -1, 60, 36, -1, 31, 57, 93, +/* 71*/ -1, 47, -1, -1, -1, -1, -1, -1, +/* 79*/ -1, -1, -1, -1, 89, 46, -1, -1, +/* 87*/ 129, 62, 90, -1, 130, 131, 63, 91, +/* 95*/ -1, -1, 132, 73, 81, 84, 94, -1, +/*103*/ 65, 82, 85, 69, 98, 95, 83, 87, +/*111*/ 70, 13, 96, 102, -1, 128, -1, 33, +/*119*/ -1, 97, 99, 100, 67, 68, 101, 66, +/*127*/ 104, 80, 106, 107, 92, 76, 14, 61, +/*136*/ + }; + + + +/* For DECStation 3100 */ + +u_char SUNLispKeyMap_DEC3100[256] = { + +/* 7*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 15*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 23*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 31*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 39*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 47*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 55*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 63*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 71*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 79*/ -1, -1, -1, -1, -1, -1, -1, 97, +/* 87*/ 99, 100, 67, 68, -1, -1, -1, -1, +/* 95*/ -1, -1, -1, -1, -1, 101, 66, 104, +/*103*/ 80, 106, -1, -1, -1, -1, -1, -1, +/*111*/ -1, -1, 107, 108, -1, -1, -1, -1, +/*119*/ -1, -1, -1, -1, -1, 92, 76, -1, +/*127*/ -1, -1, -1, -1, -1, -1, -1, -1, +/*135*/ -1, -1, -1, 90, 91, 46, 93, 89, +/*143*/ 47, -1, -1, 98, -1, 13, 76, 94, +/*151*/ 69, 70, 84, 85, 87, 102, 81, 82, +/*159*/ 83, -1, -1, -1, -1, -1, -1, -1, +/*167*/ 129, 132, 131, 130, -1, -1, -1, 41, +/*175*/ 36, 56, 31, -1, -1, -1, -1, -1, +/*183*/ -1, -1, -1, -1, -1, 15, 44, 34, +/*191*/ 33, 32, 19, 21, 40, -1, 17, 18, +/*199*/ 20, 24, 45, -1, 16, 3, 5, 37, +/*207*/ -1, 1, 48, 35, 7, 57, -1, 0, +/*215*/ 49, 50, 39, -1, 2, 51, 52, 54, +/*223*/ -1, 4, 6, 38, 55, -1, 53, 23, +/*231*/ 9, 27, -1, 22, 25, 26, 42, -1, +/*239*/ 8, 11, -1, 43, 12, -1, 59, 29, +/*247*/ 105, -1, 10, 58, 28, -1, -1, -1 + + }; + + +u_char SUNLispKeyMap_HP9000[135] = + { +/* 7*/ -1, -1, -1, 93, 31, 60, 41, 36, +/* 15*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 23*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 31*/ -1, 39, 7, 37, 24, 40, -1, -1, +/* 39*/ -1, -1, -1, -1, -1, -1, -1, -1, +/* 47*/ -1, 52, 50, 35, 5, 20, 21, -1, +/* 55*/ 56, 6, 51, 49, 48, 3, 18, 19, +/* 63*/ 34, 4, 2, 0, 1, 16, 17, 32, +/* 71*/ 45, -1, -1, -1, -1, -1, -1, -1, +/* 79*/ -1, 68, 67,100, 99, 97, -1, -1, +/* 87*/ -1, 68,101, 66,104, 80, 13, -1, +/* 95*/ -1, 53, 22, 8, 10, 59, 15, -1, +/* 103*/ -1, 23, 25, 11, 58, 29,105, -1, +/* 111*/ -1, 38, 9, 26, 43, 28, 44, -1, +/* 119*/ -1, 55, 27, 42, 12, -1, -1, -1, +/* 127*/ 47, 54, 57, -1, -1, -1, -1, -1 +}; + +u_char *XGenericKeyMap; /* filled in with malloc if needed */ + + +/* For the IBM-101 kbd FF marks exceptions */ + +#ifdef NEVER +u_char DOSLispKeyMap_101[0x80] = +{ +/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ + +/* 0*/ 0xff, 33, 32, 17, 16, 1, 0, 2, 4, 53, 22, 8, 10, 59, 15, 34, +/* 1*/ 19, 18, 3, 48, 49, 51, 6, 23, 25, 11, 58, 29, 44, 36, 21, 20, +/* 2*/ 5, 35, 50, 52, 38, 9, 26, 43, 28, 45, 41, 105, 40, 24, 37, 7, +/* 3*/ 39, 54, 55, 27, 42, 12, 60, 95, 31, 57, 56, 97, 99, 100, 67, 68, +/* 4*/ 101, 66, 104, 80, 106, 73, 74, 81, 82, 83, 96, 84, 85, 87, 102, 94, +/* 5*/ 69, 70, 98, 13,0xff,0xff,0xff, 107, 108,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +/* 6*/ 89, 62, 63, 46, 90, 91, 130, 129, 131, 132, 92, 61,0xff,0xff,0xff,0xff, +/* 7*/ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +}; +#endif /* NEVER */ + +/* For the IBM-101 kbd FF marks exceptions */ +u_char DOSLispKeyMap_101[0x80] = +{ +/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ + +/* 0*/ 0xff, 33, 32, 17, 16, 1, 0, 2, 4, 53, 22, 8, 10, 59, 15, 34, +/* 1*/ 19, 18, 3, 48, 49, 51, 6, 23, 25, 11, 58, 29, 44, 36, 21, 20, +/* 2*/ 5, 35, 50, 52, 38, 9, 26, 43, 28, 45, 41, 105, 40, 24, 37, 7, +/* 3*/ 39, 54, 55, 27, 42, 12, 60, 95, 31, 57, 56, 97, 99, 100, 67, 68, +/* 4*/ 101, 66, 104, 80, 106, 73, 74, 62, 130, 63, 96, 129, 85, 132, 102, 90, +/* 5*/ 131, 91, 89, 46,0xff,0xff,0xff, 107, 108,0xff,0xff,0xff,0xff,0xff,0xff,0xff, +/* 6*/ 89, 62, 63, 46, 90, 91, 130, 129, 131, 132, 92, 61,0xff,0xff,0xff,0xff, +/* 7*/ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +}; + + +init_keyboard(flg) + int flg ; /* if 0 init else re-init */ + { + int keytrans; + + set_kbd_iopointers(); + +#ifdef SUNDISPLAY + if( (LispKbdFd = open( LispScreen.scr_kbdname , O_RDWR)) == -1) + { + fprintf( stderr, "can't open %s\n", LispScreen.scr_kbdname); + exit( -1 ); + } +#endif /* SUNDISPLAY */ + + if(flg==0) + { + keyboardtype(LispKbdFd); + } + +#ifdef SUNDISPLAY + keytrans = TR_UNTRANS_EVENT; /* keyboard does not encode key */ + if(ioctl( LispKbdFd, KIOCTRANS, &keytrans)== -1) + { + fprintf( stderr, "Error at ioctl errnoo =%d\n", errno); + exit( -1 ); + } + close( LispKbdFd ); +#ifdef KBINT + int_io_open(LispWindowFd); /* from init_dsp, try to prevent mouse-move-no-kbd bug */ +#endif /* KBINT */ + seteventmask( &LispEventMask ); +#elif xXWINDOW + init_Xevent(); + + seteventmask( &LispEventMask ); + +#elif XWINDOW + init_Xevent(currentdsp); + +#elif DOS + if (flg == 0) + { /* Install the handlers ONLY when we */ + /* init the kbd the init the kbd the */ + /* first time. */ + + /* turn on kbd */ + make_kbd_instance(currentkbd); + (currentkbd->device.enter)(currentkbd); + + /* turn on mouse */ + make_mouse_instance(currentmouse); + (currentmouse->device.enter)(currentmouse, currentdsp); + } + /* outp( KBD_COMMAND_PORT, KBD_RESET); Reset the kbd */ +#endif /* XWINDOW DOS */ + } + + + + +/* ----------------------------------------------------------------*/ + +device_before_exit() +{ +#ifdef SUNDISPLAY + int keytrans; + + if( (LispKbdFd = open( LispScreen.scr_kbdname , O_RDWR)) == -1){ + fprintf( stderr, "can't open %s\n", LispScreen.scr_kbdname); + exit( -1 ); + } + + keytrans = TR_EVENT; /* keyboard encodes key */ + if(ioctl( LispKbdFd, KIOCTRANS, &keytrans)== -1){ + fprintf( stderr, "Error at ioctl errnoo =%d\n", errno); + exit( -1 ); + } + close( LispKbdFd ); + +#elif DOS + (currentmouse->device.exit)(currentmouse, currentdsp); + (currentkbd->device.exit)(currentkbd); +#endif /* SUNDISPLAY DOS*/ + display_before_exit(); +} + + + + +/* ----------------------------------------------------------------*/ + +set_kbd_iopointers() +{ + IOPage68K = (IOPAGE *)IOPage; + EmMouseX68K = (DLword *) &(IOPage68K->dlmousex); + EmMouseY68K = (DLword *) &(IOPage68K->dlmousey); + EmCursorX68K = (DLword *) &(IOPage68K->dlcursorx); + EmCursorY68K = (DLword *) &(IOPage68K->dlcursory); + EmRealUtilin68K = (DLword *) &(IOPage68K->dlutilin); + /* EmUtilin68K is for KEYDOWNP1 macro or etc. */ + EmUtilin68K = (DLword *) &(InterfacePage->fakemousebits); + EmKbdAd068K = (DLword *) &(IOPage68K->dlkbdad0); + EmKbdAd168K = (DLword *) &(IOPage68K->dlkbdad1); + EmKbdAd268K = (DLword *) &(IOPage68K->dlkbdad2); + EmKbdAd368K = (DLword *) &(IOPage68K->dlkbdad3); + EmKbdAd468K = (DLword *) &(IOPage68K->dlkbdad4); + EmKbdAd568K = (DLword *) &(IOPage68K->dlkbdad5); + EmDispInterrupt68K = (DLword *) &(IOPage68K->dldispinterrupt); + EmCursorBitMap68K = (DLword *) (IOPage68K->dlcursorbitmap); + + *EmRealUtilin68K = KB_ALLUP; + *EmKbdAd068K = KB_ALLUP; + *EmKbdAd168K = KB_ALLUP; + *EmKbdAd268K = KB_ALLUP; + *EmKbdAd368K = KB_ALLUP; + *EmKbdAd468K = KB_ALLUP; + *EmKbdAd568K = KB_ALLUP; + +} + + + + +/* ----------------------------------------------------------------*/ + +#ifdef SUNDISPLAY +seteventmask( eventmask ) +struct inputmask *eventmask; +{ + input_imnull( eventmask ); + eventmask->im_flags |= IM_ASCII | IM_NEGASCII | IM_NEGEVENT; + + win_setinputcodebit ( eventmask, MS_LEFT ); + win_setinputcodebit ( eventmask, MS_MIDDLE ); + win_setinputcodebit ( eventmask, MS_RIGHT ); + win_setinputcodebit ( eventmask, LOC_MOVE ); + win_unsetinputcodebit( eventmask, LOC_STILL ); + win_unsetinputcodebit( eventmask, LOC_MOVEWHILEBUTDOWN ); + win_unsetinputcodebit( eventmask, LOC_WINENTER ); + win_unsetinputcodebit( eventmask, LOC_WINEXIT ); + + win_setinputmask( LispWindowFd, eventmask, eventmask, WIN_NULLLINK); +} +#endif /* SUNDISPLAY */ + + + +char* getenv(); /* ---- external entry points --------*/ + +#define MIN_KEYTYPE 3 +#define KB_AS3000J (7 + MIN_KEYTYPE) +#define KB_RS6000 (8 + MIN_KEYTYPE) +#define KB_DEC3100 (9 + MIN_KEYTYPE) +#define KB_HP9000 (10+ MIN_KEYTYPE) +#define KB_X (11+ MIN_KEYTYPE) +#define KB_DOS (12+MIN_KEYTYPE) + +/* KB_SUN4 not defined in older OS versions */ +#ifndef KB_SUN4 +#define KB_SUN4 4 +#endif + +#ifndef KB_SUN2 + /* These KB types nog defined outside Sun world,so define them here */ +#define KB_SUN2 2 +#define KB_SUN3 3 +#endif /* KB_SUN2 */ + + +/* For the JLE keyboard */ +#define KB_JLE 5 + + + +/************************************************************************/ +/* */ +/* m a k e _ X _ k e y m a p */ +/* */ +/* Starting from the generic-X-keyboard mapping in XKeymap.h, */ +/* construct a keyboard map for this machine, using the rules */ +/* shown in the header file. */ +/* */ +/* */ +/************************************************************************/ + +#ifdef XWINDOW +u_char * make_X_keymap() + { + u_char *table = (u_char *)malloc(256); /* the final result table */ + int lisp_codes_used[256]; /* Keep track of the Lisk key #s we've used */ + int last_KEYSYM = -1; + int sym_used = 0; + int *key_sym_pairs = generic_X_keymap; + int i = 0; + KeySym * mapping; + KeyCode first; + int codecount, symspercode, minkey, maxkey; + + for (; i<256; i++) + { /* clear the tables we just allocated */ + lisp_codes_used[i] = 0; + table[i]=255; /* The "no key assigned" code */ + } +XLOCK; + +#ifdef WHAT_THE_DICKENS_HAPPENED_HERE + XDisplayKeycodes(ConnectionNumber(currentdsp->display_id), &minkey, &maxkey); +#else /* WHAT_THE_DICKENS_HAPPENED_HERE */ + XDisplayKeycodes(currentdsp->display_id, &minkey, &maxkey); +#endif /* WHAT_THE_DICKENS_HAPPENED_HERE */ + + codecount = maxkey + 1 - minkey; + +#ifdef WHAT_THE_DICKENS_HAPPENED_HERE + mapping = XGetKeyboardMapping(ConnectionNumber(currentdsp->display_id), minkey, codecount, &symspercode); +#else /* WHAT_THE_DICKENS_HAPPENED_HERE */ + mapping = XGetKeyboardMapping(currentdsp->display_id, minkey, codecount, &symspercode); +#endif /* WHAT_THE_DICKENS_HAPPENED_HERE */ + +XUNLOCK; + + for (; *key_sym_pairs != -1; ) + { + int reusable = *key_sym_pairs++, + code = *key_sym_pairs++, + sym = *key_sym_pairs++, + xcode; + + if (sym_used && (sym == last_KEYSYM)) continue; + + sym_used = 0; + last_KEYSYM = sym; + + + xcode = find_unused_key(mapping, minkey, codecount, + symspercode, sym, table); + + if (xcode==0) continue; + if ((!reusable) && (lisp_codes_used[code] != 0)) continue; + + sym_used = 1; + last_KEYSYM = sym; + lisp_codes_used[code] = 1; + table[xcode-7] = code; + + + } + +#ifdef DEBUG + for (i=0; i < 256; i += 8) + { + printf("\n\n\tKeyboard mapping table\n\n"); + printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", + table[i], table[i+1], table[i+2], table[i+3], + table[i+4], table[i+5], table[i+6], table[i+7]); + } +#endif /* DEBUG */ + + + return(table); + } + +int find_unused_key(map, minkey, len, syms, sym, table) + KeySym *map; + int minkey, len, syms, sym; + u_char *table; + { + int i; + + for (i=0; i<(len*syms); i++) + { + if (sym == map[i]) + { + int code = minkey + (i/syms); + if (table[code-7] != 255) continue; + return(code); + } + } + return(0); + } + +#endif /* XWINDOW */ + + +/************************************************************************/ +/* */ +/* k e y b o a r d t y p e */ +/* */ +/* Determine what kind of keyboard we're dealing with, by */ +/* checking the LDEKBDTYPE shell variable. It it's not set, */ +/* either default it (for DEC, IBM), or complain and exit. */ +/* Valid LDEKBDTYPE values: */ +/* type3 Sun type-3 keyboard */ +/* type4 Sun type-4 keyboard */ +/* rs6000 IBM RS/6000 */ +/* hp9000 HP 9000 series 800 or 700 */ +/* dec3100 DECstation 3100 or 5000 */ +/* x generic X keyboard map */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +keyboardtype(fd) + int fd; + { + int type; + int i; + char *key; + + for(i=0;i<5000;i++){/* IDLE LOOP */} /* because of a SunOS bug */ + + /* clear the keyboard field in devconfig */ + InterfacePage->devconfig &= 0xfff8; + + /************************************************************ + Due to the problems of SunOS 4.0 & 4.0.1 + calling ioctl never return the correct keyboard type. + So,these 2 lines are commented out ...(Take)->AR11100 + *************************************************************/ + + /* Get keytype from LDEKBDTYPE */ + if ((key = getenv("LDEKBDTYPE")) == 0) { +#ifdef FUJI + /* obnoxious behavior */ + mess_reset(); + printf("!!CAUTION: LDEKBDTYPE is not set.\n"); + printf("Please retry after setting LDEKBDTYPE correctly.\n"); + printf("Usage: setenv LDEKBDTYPE \n"); + printf(" (one of type2, type3, type4, jle, or as3000j)"); + exit(0); /* exit to shell */ +#else +#ifdef DECSTN + type = KB_DEC3100; +#else +#ifdef RS6000 + type = KB_RS6000; +#else +#ifdef HP9000 + type = KB_HP9000; +#else +#ifdef XWINDOW + type = KB_X; +#elif DOS + type = KB_DOS; +#else + if(ioctl(fd,KIOCTYPE,&type) !=0) { + error("keyboardtype:IOCTL(KIOCTYPE) fails (cont. w. type-3"); + type = KB_SUN3; + } /* otherwise, type is set */ +#endif /* XWINDOW */ +#endif /* HP9000 */ + +#endif /* RS6000 */ + +#endif /* DECSTN */ + +#endif /* FUJI */ + +#ifdef XWINDOW +#undef FUJI +#endif /* XWINDOW */ + + }/* if end */ + else { + if (strcmp("as3000j", key)==0) type = KB_AS3000J; + else if (strcmp("type4", key)==0) type = KB_SUN4; + else if (strcmp("type2", key)==0) type = KB_SUN2; + else if (strcmp("jle", key)==0) type = KB_JLE; + else if (strcmp("rs6000", key)==0) type = KB_RS6000; + else if (strcmp("dec3100", key)==0) type = KB_DEC3100; + else if (strcmp("hp9000", key)==0) type = KB_HP9000; + else if (strcmp("X", key)==0) type = KB_X; + else if (strcmp("x", key)==0) type = KB_X; + else type = KB_SUN3; /* default */ + } + + + switch(type) { + case KB_SUN2 : /* type2, we still use keymap for type3 */ + SUNLispKeyMap = SUNLispKeyMap_for3; + /* MIN_KEYTYPE is 3,so we can't set devconfig correctly */ + /* Therefore type2 may treat as type3 */ + InterfacePage->devconfig |= 0; + break; + case KB_SUN3 : /* type3 */ + SUNLispKeyMap = SUNLispKeyMap_for3; + InterfacePage->devconfig |= type-MIN_KEYTYPE; + break; + case KB_SUN4 : /* type4 */ + SUNLispKeyMap = SUNLispKeyMap_for4; + InterfacePage->devconfig |= type-MIN_KEYTYPE; + break; + case KB_JLE : /* JLE */ + /*printf("jle\n"); */ + SUNLispKeyMap=SUNLispKeyMap_jle; + InterfacePage->devconfig |= type-MIN_KEYTYPE; + /* InterfacePage->devconfig |= 4-MIN_KEYTYPE; */ + break; + case KB_AS3000J : /* for AS, use type4 map */ + SUNLispKeyMap = SUNLispKeyMap_for4; + InterfacePage->devconfig |= type-MIN_KEYTYPE;/* 7 */ + break; + case KB_RS6000: + SUNLispKeyMap = SUNLispKeyMap_RS6000; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 8 */ + break; + case KB_DEC3100: + SUNLispKeyMap = SUNLispKeyMap_DEC3100; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 9 */ + break; + case KB_HP9000: + SUNLispKeyMap = SUNLispKeyMap_HP9000; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ + break; +#ifdef XWINDOW + case KB_X: + XGenericKeyMap = (u_char *)make_X_keymap(); + SUNLispKeyMap = XGenericKeyMap; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ + break; +#endif /* XWINDOW */ + +#ifdef DOS + case KB_DOS: + SUNLispKeyMap = DOSLispKeyMap_101; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ + break; +#endif /* DOS */ + default: { char errmsg [ 200 ]; + sprintf ( errmsg, "Unsupported keyboard type: %d", type); + printf ( "%s\n", errmsg); + printf ( "Configuring keyboard for type-3\n", errmsg); + SUNLispKeyMap = SUNLispKeyMap_for3; + InterfacePage->devconfig |= KB_SUN3-MIN_KEYTYPE; + break; + } + } + +}/* end keyboardtype*/ diff --git a/src/initsout.c b/src/initsout.c new file mode 100755 index 0000000..a6e54c9 --- /dev/null +++ b/src/initsout.c @@ -0,0 +1,544 @@ +/* $Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ +/************************************************************************/ +/* */ +/* Make connections between lisp and C emulator */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +#include +#include +#include +#ifndef DOS +#include +#else +#undef HAS_GETHOSTID +#endif /* DOS */ +#include "hdw_conf.h" +#include "lispemul.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "adr68k.h" +#include "ifpage.h" +#include "iopage.h" +#include "cell.h" +#include "devconf.h" +#include "dbprint.h" +#include "lldsp.h" +#include "gc.h" /* for ADDREF & GCLOOKUP */ + +/********** definitions for bitblt. add by osamu **********/ +DLword TEXTURE_atom; +DLword MERGE_atom; +DLword INPUT_atom; +DLword INVERT_atom; +DLword ERASE_atom; +DLword PAINT_atom; +DLword REPLACE_atom; +/************ end definitions for bitblt.*****************/ + + + +#ifdef BIGVM +#define GCENTRY LispPTR +#else +#define GCENTRY DLword +#endif + +/************************************************************************/ +/* */ +/* f i x p _ v a l u e */ +/* */ +/* Set up a system value to be a FIXP cell. */ +/* */ +/************************************************************************/ + +#ifdef BIGVM +LispPTR * fixp_value(LispPTR *ptr) +{ + LispPTR val = *ptr; + + if (val < (S_NEGATIVE | 0xFFFF)) + { + LispPTR newval = N_OP_createcell(S_POSITIVE | TYPE_FIXP); + LispPTR *newcell; newcell = (LispPTR *) Addr68k_from_LADDR(newval); + *newcell = val & 0xFFFF; /* it was smallp, so fill in */ + *ptr = newval; + GCLOOKUP(newval, ADDREF); /* so it has a refcount */ + return((LispPTR *)newcell); + } + return((LispPTR *)Addr68k_from_LADDR(val)); + } + +#else + /* In old system, this is just a NO-OP */ +#define fixp_value +#endif /* BIGVM */ + + + +/************************************************************************/ +/* */ +/* i n i t _ i f p a g e */ +/* */ +/* Set up the interface page: Fill in the machine-type, the */ +/* ethernet-ID, the virtual-memory limit (32Mb or less, depending */ +/* on what the -m specified), make space for display type. */ +/* */ +/* */ +/************************************************************************/ + +#define PAGES_IN_MBYTE 2048 + +init_ifpage(int sysout_size) +{ + extern long MDate; + extern int DisplayType; +#ifdef NEW_STORAGE + extern int Storage_expanded; + int new_lastvmem ; +#endif + /* + Initialize IFPAGE + */ + InterfacePage->machinetype = KATANA; /* 3 is katana */ +#ifdef NOETHER +#else + init_ifpage_ether(); /* store ethernet ID in IF page */ +#endif /* NOETHER */ + /*InterfacePage->dl24bitaddressable = (sysout_size == 32? 0xffff : 0);*/ + InterfacePage->dl24bitaddressable = (sysout_size == 8? 0: 0xffff); +#ifdef NEW_STORAGE + new_lastvmem = (sysout_size * PAGES_IN_MBYTE)-1; + + if((!Storage_expanded) && (InterfacePage->dllastvmempage != new_lastvmem)) + { + fprintf(stderr,"You can't expand VMEM\n"); + exit(-1); + } + else + { /* Set value which will be set to \\LASTVMEMFILEPAGE in LISP */ + InterfacePage->dllastvmempage = new_lastvmem; + /* Also you can expand lisp space even if \\STOAGEFULL was T */ + *STORAGEFULL_word = NIL; + } + /* Set current process size */ + InterfacePage->process_size = sysout_size ; +#else + InterfacePage->dllastvmempage = LASTVMEMPAGE; +#endif /* NEW_STORAGE */ + + +#ifdef BIGVM + /* For BIGVM system, save the value in \LASTVMEMFILEPAGE for lisp's use */ + if ((LispPTR)LASTVMEMFILEPAGE_word != 0xFFFFFFFF) *LASTVMEMFILEPAGE_word = InterfacePage->dllastvmempage; +#endif /* BIGVM */ + + + /* unfortunately, Lisp only looks at a 16 bit serial number */ +#ifdef HAS_GETHOSTID + InterfacePage->serialnumber = 0xffff & gethostid(); +#endif /* HAS_GETHOSTID */ + + /* get user name and stuff into vmem; this is the VMEM buffer; + This is a BCPL string -- it starts with a length count. C strings + are null terminated instead */ +#ifndef DOS + {struct passwd *pwd; + char *s = (char*)Addr68k_from_LADDR(0155001); + /* try getpwuid first; use cuserid if it fails */ + if((pwd = getpwuid(getuid())) == NULL) cuserid(s+1); + else strcpy(s+1, pwd->pw_name); + *s = (char)strlen(s+1); + } +#endif /* DOS */ + + /* sec from Oct-13-87 12:00 It's My birthday(take) */ + /* MDate may be set by makefile(by mkvdate.c) */ + InterfacePage->rversion = (MDate - 561150000)/ (60*60*24); + + /* For DisplayType ,I couldn't insert this line into init_display */ + InterfacePage->devconfig &= 0xff87; + InterfacePage->devconfig |= DisplayType; + } + + + +/************************************************************************/ +/* */ +/* i n i t _ i o p a g e */ +/* */ +/* Clean up the IO page: Set the keyboard map to "all keys up." */ +/* */ +/************************************************************************/ + +init_iopage(void) +{ + + /* + * Initialize IOPAGE + */ + IOPage->dlkbdad0 = 65535; /* ALL UP */ + IOPage->dlkbdad1 = 65535; /* ALL UP */ + IOPage->dlkbdad2 = 65535; /* ALL UP */ + IOPage->dlkbdad3 = 65535; /* ALL UP */ + IOPage->dlkbdad4 = 65535; /* ALL UP */ + IOPage->dlkbdad5 = 65535; /* ALL UP */ + IOPage->dlutilin = 65535; /* ALL UP */ + + } + + + +/************************************************************************/ +/* */ +/* b u i l d _ l i s p _ m a p */ +/* */ +/* Create the atom-pointers used by C to deal with the lisp */ +/* SYSOUT. */ +/* */ +/************************************************************************/ + +extern int for_makeinit; + +extern LispPTR *MakeAtom68k(char *string); + +build_lisp_map(void) +{ + DLword index; + + Stackspace = (DLword *) Addr68k_from_LADDR(STK_OFFSET); + Plistspace = (DLword *) Addr68k_from_LADDR(PLIS_OFFSET); + DTDspace = (DLword *) Addr68k_from_LADDR(DTD_OFFSET); + MDStypetbl = (DLword *) Addr68k_from_LADDR(MDS_OFFSET); + AtomHT = (DLword *) Addr68k_from_LADDR(ATMHT_OFFSET); + Pnamespace = (DLword *) Addr68k_from_LADDR(PNP_OFFSET); + AtomSpace = (DLword *) Addr68k_from_LADDR(ATOMS_OFFSET); + Defspace = (DLword *) Addr68k_from_LADDR(DEFS_OFFSET); + Valspace = (DLword *) Addr68k_from_LADDR(VALS_OFFSET); + + DBPRINT(("Stackspace = 0x%x.\n", Stackspace)); + DBPRINT(("AtomHT = 0x%x.\n", AtomHT)); + + ListpDTD = (struct dtd *)GetDTD(TYPE_LISTP); + +#ifdef BIGVM + FPtoVP = (LispPTR *) Addr68k_from_LADDR(FPTOVP_OFFSET); +#else + FPtoVP = (DLword *) Addr68k_from_LADDR(FPTOVP_OFFSET); +#endif /* BIGVM */ + IOPage = (IOPAGE *) Addr68k_from_LADDR(IOPAGE_OFFSET); + InterfacePage = (IFPAGE *) Addr68k_from_LADDR(IFPAGE_OFFSET); + MiscStats = (MISCSTATS *) Addr68k_from_LADDR(MISCSTATS_OFFSET); + + UFNTable = (DLword *) Addr68k_from_LADDR(UFNTBL_OFFSET); + DisplayRegion = (DLword *) Addr68k_from_LADDR(DISPLAY_OFFSET); + + HTmain = (GCENTRY *) Addr68k_from_LADDR(HTMAIN_OFFSET); + HToverflow = (GCENTRY *) Addr68k_from_LADDR(HTOVERFLOW_OFFSET); + HTbigcount = (GCENTRY *) Addr68k_from_LADDR(HTBIG_OFFSET); + HTcoll = (GCENTRY *) Addr68k_from_LADDR(HTCOLL_OFFSET); + + +/**** cache values *****/ + Reclaim_cnt_word = MakeAtom68k("\\RECLAIM.COUNTDOWN"); + + /*** cache values for gcreclaimer : added by T. Teruuchi 30-Sep-1987 ***/ + + GcDisabled_word = MakeAtom68k("\\GCDISABLED"); + + + + /*** following cache values are the solution for array reclaimer ***/ + + FreeBlockBuckets_word = MakeAtom68k("\\FREEBLOCKBUCKETS"); + Array_Block_Checking_word = MakeAtom68k("ARRAYBLOCKCHECKING"); + ArrayMerging_word = MakeAtom68k("\\ARRAYMERGING"); + ArraySpace_word = MakeAtom68k("\\ARRAYSPACE"); + ArraySpace2_word = MakeAtom68k("\\ARRAYSPACE2"); + ArrayFrLst_word = MakeAtom68k("\\ArrayFrLst"); + ArrayFrLst2_word = MakeAtom68k("\\ArrayFrLst2"); + Hunk_word = MakeAtom68k("\\HUNKING?"); + System_Buffer_List_word = MakeAtom68k("SYSTEMBUFFERLIST"); + + /*** The following cache values are for the top level reclaimer ***/ + + GcMess_word = MakeAtom68k("GCMESS"); + ReclaimMin_word = MakeAtom68k("\\RECLAIMMIN"); + + /*** The following caches are for Symbol lookup April-28,1988 Tomtom ***/ + + Package_from_Index_word = MakeAtom68k("*PACKAGE-FROM-INDEX*"); + Package_from_Name_word = MakeAtom68k("*PACKAGE-FROM-NAME*"); + Keyword_Package_word = MakeAtom68k("*KEYWORD-PACKAGE*"); + DBPRINT(("Package_from_Index_word = 0x%x.\n", Package_from_Index_word)); + DBPRINT(("Package_from_Name_word = 0x%x.\n", Package_from_Name_word)); + + /*** The following atom-index cache is for CL:VALUES opcode JDS 4/5/89 ***/ + + MVLIST_index = MAKEATOM("\\MVLIST"); + + /* * * Atoms for closure-cache interface * * */ + + if (for_makeinit) + { + Closure_Cache_Enabled_word = (LispPTR *)malloc(4); + *Closure_Cache_Enabled_word = NIL; + + Closure_Cache_word = (LispPTR *)malloc(4); + *Closure_Cache_word = NIL; + + Deleted_Implicit_Hash_Slot_word = (LispPTR *)malloc(4); + *Deleted_Implicit_Hash_Slot_word = NIL; + } + else + { + DBPRINT(("%d %d %d %d %d", Stackspace, + Plistspace, DTDspace, MDStypetbl, AtomHT)); + + index = get_package_atom("*CLOSURE-CACHE-ENABLED*", 23, "SI", 2, NIL); + Closure_Cache_Enabled_word = GetVALCELL68k(index); + + index = get_package_atom("*CLOSURE-CACHE*", 15, "SI", 2, NIL); + Closure_Cache_word = GetVALCELL68k(index); + + index = get_package_atom("*DELETED-IMPLICIT-HASH-SLOT*", 28, "XCL", 3,NIL); + Deleted_Implicit_Hash_Slot_word = GetVALCELL68k(index); + + } + +/*** THE following CACHE values are added by Take. ***/ +/* The fixp_value calls make sure that those values are held + in FIXP cells (and the ..._word variable points to that cell) + so that the BIGVM code can go beyond 16 bits of page # */ + + + STORAGEFULLSTATE_index = MAKEATOM("\\STORAGEFULLSTATE"); + STORAGEFULLSTATE_word = MakeAtom68k("\\STORAGEFULLSTATE"); + STORAGEFULL_word = MakeAtom68k("\\STORAGEFULL"); + PENDINGINTERRUPT_word = MakeAtom68k("\\PENDINGINTERRUPT"); + LeastMDSPage_word = fixp_value(MakeAtom68k("\\LeastMDSPage")); + SecondMDSPage_word = fixp_value(MakeAtom68k("\\SecondMDSPage")); + SecondArrayPage_word = fixp_value(MakeAtom68k("\\SecondArrayPage")); + INTERRUPTSTATE_word = MakeAtom68k("\\INTERRUPTSTATE"); + SYSTEMCACHEVARS_word = MakeAtom68k("\\SYSTEMCACHEVARS"); + MACHINETYPE_word = MakeAtom68k("\\MACHINETYPE"); + LASTVMEMFILEPAGE_word = fixp_value(MakeAtom68k("\\LASTVMEMFILEPAGE")); + VMEM_FULL_STATE_word = MakeAtom68k("\\VMEM.FULL.STATE"); + Next_MDSpage_word = fixp_value(MakeAtom68k("\\NxtMDSPage")); + Next_Array_word = fixp_value(MakeAtom68k("\\NxtArrayPage")); + MDS_free_page_word = MakeAtom68k("\\MDSFREELISTPAGE"); + + + /*** The following are STK-OVER-FLOW stuff * Take **/ + STACKOVERFLOW_word = MakeAtom68k("\\STACKOVERFLOW"); + GuardStackAddr_word = MakeAtom68k("\\GuardStackAddr"); + LastStackAddr_word = MakeAtom68k("\\LastStackAddr"); + NeedHardreturnCleanup_word = MakeAtom68k("\\NEED.HARDRESET.CLEANUP"); + + /*** The addition of cache values for Bitblt by osamu April 13, 1988 ***/ + TEXTURE_atom = MAKEATOM("TEXTURE"); + MERGE_atom = MAKEATOM("MERGE"); + INPUT_atom = MAKEATOM("INPUT"); + INVERT_atom = MAKEATOM("INVERT"); + ERASE_atom = MAKEATOM("ERASE"); + PAINT_atom = MAKEATOM("PAINT"); + REPLACE_atom = MAKEATOM("REPLACE"); + + + /*** Do initialization for specific devices ***/ + init_for_keyhandle(); /* keyboard-interrupt handler */ + init_for_bltchar(); /* BLTCHAR speed-up */ + init_for_bitblt(); /* BITBLT-to-display speed-up */ + + } + + + +/************************************************************************/ +/* */ +/* i n i t _ f o r _ k e y h a n d l e */ +/* */ +/* */ +/* */ +/************************************************************************/ + +init_for_keyhandle(void) +{ + DLword index; + extern DLword *CTopKeyevent; + extern LispPTR *KEYBOARDEVENTQUEUE68k; + extern LispPTR *KEYBUFFERING68k; + extern LispPTR DOBUFFEREDTRANSITION_index; + extern LispPTR INTERRUPTFRAME_index; + extern LispPTR *TIMER_INTERRUPT_PENDING68k; + extern LispPTR *PENDINGINTERRUPT68k; + extern LispPTR *MOUSECHORDTICKS68k; + extern LispPTR *LASTUSERACTION68k; + extern LispPTR ATOM_STARTED; + extern LispPTR *CLastUserActionCell68k; + + extern LispPTR *CURSORDESTHEIGHT68k; + extern LispPTR *CURSORDESTWIDTH68k; + + extern LispPTR *CURSORHOTSPOTX68k; + extern LispPTR *CURSORHOTSPOTY68k; + extern LispPTR *SOFTCURSORUPP68k; + extern LispPTR *SOFTCURSORWIDTH68k; + extern LispPTR *SOFTCURSORHEIGHT68k; + extern LispPTR *CURRENTCURSOR68k; + + + extern LispPTR *PERIODIC_INTERRUPT68k; + extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; + extern LispPTR PERIODIC_INTERRUPTFRAME_index; + extern LispPTR DORECLAIM_index; + extern LispPTR *IOINTERRUPTFLAGS_word; + + CURSORDESTHEIGHT68k = MakeAtom68k("\\CURSORDESTHEIGHT"); + CURSORDESTWIDTH68k = MakeAtom68k("\\CURSORDESTWIDTH"); + CURSORHOTSPOTX68k = MakeAtom68k("\\CURSORHOTSPOTX"); + CURSORHOTSPOTY68k = MakeAtom68k("\\CURSORHOTSPOTY"); + + SOFTCURSORUPP68k = MakeAtom68k("\\SOFTCURSORUPP"); + SOFTCURSORWIDTH68k = MakeAtom68k("\\SOFTCURSORWIDTH"); + SOFTCURSORHEIGHT68k = MakeAtom68k("\\SOFTCURSORHEIGHT"); + CURRENTCURSOR68k = MakeAtom68k("\\CURRENTCURSOR"); + + ATOM_STARTED= MAKEATOM("STARTED"); + + KEYBOARDEVENTQUEUE68k = MakeAtom68k("\\KEYBOARDEVENTQUEUE"); + KEYBUFFERING68k = MakeAtom68k("\\KEYBUFFERING"); + + PENDINGINTERRUPT68k = MakeAtom68k("\\PENDINGINTERRUPT"); + MOUSECHORDTICKS68k = MakeAtom68k("\\MOUSECHORDTICKS"); + LASTUSERACTION68k = MakeAtom68k("\\LASTUSERACTION"); + + CLastUserActionCell68k= (LispPTR*) + Addr68k_from_LADDR(*LASTUSERACTION68k& 0xffffff); + + + DOBUFFEREDTRANSITION_index = MAKEATOM("\\DOBUFFEREDTRANSITIONS"); + INTERRUPTFRAME_index = MAKEATOM("\\INTERRUPTFRAME"); + + CTopKeyevent= (DLword*)Addr68k_from_LADDR(*KEYBOARDEVENTQUEUE68k); + + PERIODIC_INTERRUPT68k = MakeAtom68k("\\PERIODIC.INTERRUPT"); + PERIODIC_INTERRUPT_FREQUENCY68k + = MakeAtom68k("\\PERIODIC.INTERRUPT.FREQUENCY"); + + PERIODIC_INTERRUPTFRAME_index = MAKEATOM("\\PERIODIC.INTERRUPTFRAME"); + DORECLAIM_index = MAKEATOM("\\DORECLAIM"); +#ifndef INIT + index = get_package_atom("\\MAIKO.IO-INTERRUPT-FLAGS", 25, "INTERLISP", 9, NIL); + IOINTERRUPTFLAGS_word = GetVALCELL68k(index); +#endif + } + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +init_for_bltchar(void) +{ LispPTR index; + char *IL; + + extern LispPTR *TOPWDS68k; + extern LispPTR BLTCHAR_index; + extern LispPTR TEDIT_BLTCHAR_index; + +#ifdef COLOR + extern LispPTR *SCREENBITMAPS68k; + extern LispPTR SLOWBLTCHAR_index; + extern LispPTR *COLORSCREEN68k; /* \\COLORSCREEN */ + extern LispPTR COLORSCREEN_index; +#endif + IL = "INTERLISP"; + + if(!for_makeinit) + { + BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18,IL,9,NIL); + TEDIT_BLTCHAR_index = get_package_atom("\\TEDIT.BLTCHAR", 14,IL,9,NIL); + }; + TOPWDS68k = MakeAtom68k("\\TOPWDS"); + +#ifdef COLOR + if(!for_makeinit) + { + SLOWBLTCHAR_index= get_package_atom("\\PUNT.SLOWBLTCHAR", + 17, "INTERLISP", 9, NIL); + + index = MAKEATOM("\\SCREENBITMAPS"); + SCREENBITMAPS68k = GetVALCELL68k(index); + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); + } + +#endif /* COLOR */ + + } + + + +/************************************************************************/ +/* */ +/* i n i t _ f o r _ b i t b l t */ +/* */ +/* */ +/* */ +/************************************************************************/ + +init_for_bitblt(void) +{ + LispPTR index; + char *IL; + + extern LispPTR BITBLTBITMAP_index; + extern LispPTR BLTSHADEBITMAP_index; +#ifdef COLOR + extern LispPTR *COLORSCREEN68k; + extern LispPTR COLORSCREEN_index; +#endif /* COLOR */ + + + if(!for_makeinit) + { + BITBLTBITMAP_index=get_package_atom("\\PUNT.BITBLT.BITMAP",19, + "INTERLISP",9, NIL); + BLTSHADEBITMAP_index=get_package_atom("\\PUNT.BLTSHADE.BITMAP",21, + "INTERLISP",9, NIL); + +#ifdef COLOR + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); +#endif /* COLOR */ + + } + + } diff --git a/src/intcall.c b/src/intcall.c new file mode 100755 index 0000000..153a14a --- /dev/null +++ b/src/intcall.c @@ -0,0 +1,132 @@ +/* $Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "stack.h" +#include "return.h" +#include "emlglob.h" +#include "lspglob.h" +#include "initatms.h" +#include "cell.h" +#include "tosfns.h" + + + +cause_interruptcall(register unsigned int atom_index) + /* Atomindex for Function you want to invoke */ +{ + register struct definition_cell *defcell68k ; /* Definition Cell PTR */ + register short pv_num ; /* scratch for pv */ + register struct fnhead *tmp_fn; + int rest ; /* use for arignments */ + + CURRENTFX->nopush = T; + CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR)+4; + PushCStack ; /* save TOS */ + + /* Setup IVar */ + IVar = Addr68k_from_StkOffset(CURRENTFX->nextblock) ; + + /* Set PC to the Next Instruction and save into pre-FX */ + CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) ; + + + /* Get DEFCELL 68k address */ + defcell68k =(struct definition_cell *) GetDEFCELL68k(atom_index) ; + + /* Interrupt FN should be compiled code */ + tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ) ; + +/* This used to be >=, but I think that was a change from earlier, + when it was originally >. I changed it back on 2/2/98 to see + if that fixes stack overflow toruble. --JDS */ +if((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) > (UNSIGNED)EndSTKP ) + { + + /*printf("Intrrupt:$$ STKOVER when "); + print(atom_index); + printf(" was called *****\n");*/ + DOSTACKOVERFLOW(0,-1); + } + FuncObj = tmp_fn ; + SWAPPED_FN_CHECK; /* Check for need to re-swap code stream */ + if( FuncObj->na >= 0 ) + { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = 0 - (FuncObj->na) ; + + while(rest <0) { + PushStack(NIL_PTR) ; + rest++; + } + CurrentStackPTR -= (rest<<1) ; + } /* if end */ + + /* Set up BF */ +CurrentStackPTR+=2; + GETWORD(CurrentStackPTR) = BF_MARK ; + GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock ; +CurrentStackPTR+=2; + + /* Set up FX */ + GETWORD(CurrentStackPTR) = FX_MARK; + + /* Now SET new FX */ + /* Make it SLOWP */ + ((FX*)CurrentStackPTR)->alink = StkOffset_from_68K(PVar) + 1; + ((FX*)CurrentStackPTR)->blink = StkOffset_from_68K(DUMMYBF(CurrentStackPTR)); + ((FX*)CurrentStackPTR)->clink = StkOffset_from_68K(PVar) ; + PVar = (DLword *)CurrentStackPTR + FRAMESIZE; +#ifdef BIGVM + ((FX*)CurrentStackPTR)->fnheader = + (defcell68k->defpointer); +#else + ((FX*)CurrentStackPTR)->lofnheader = + (defcell68k->defpointer) & 0x0ffff ; + ((FX*)CurrentStackPTR)->hi2fnheader = + ((defcell68k->defpointer) & SEGMASK) >> 16 ; +#endif /* BIGVM */ + + CurrentStackPTR = PVar ; + + /* Set up PVar area */ + pv_num = FuncObj->pv+1 ; + while(pv_num > 0) { + *((LispPTR *)CurrentStackPTR) = 0x0ffffffff ; + CurrentStackPTR += DLWORDSPER_CELL ; + *((LispPTR *)CurrentStackPTR) = 0x0ffffffff ; + CurrentStackPTR += DLWORDSPER_CELL ; + pv_num--; + } + + /* Set PC points New Function's first OPCODE */ + PC = (ByteCode *)FuncObj + FuncObj->startpc ; + CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR); + MAKEFREEBLOCK(CurrentStackPTR , ((UNSIGNED)EndSTKP - (UNSIGNED)CurrentStackPTR) >> 1); +} /* end */ diff --git a/src/kbdif.c b/src/kbdif.c new file mode 100755 index 0000000..8ffbea5 --- /dev/null +++ b/src/kbdif.c @@ -0,0 +1,54 @@ +/* $Id: kbdif.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: kbdif.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +/* * K Y E B O A R D I N T E R F A C E * */ + + +#include "lispemul.h" +#include "dbprint.h" +#include "devif.h" + +KbdInterfaceRec _curkbd; +KbdInterface currentkbd = &_curkbd; + +#ifdef DOS +extern void Kbd_event(); +extern void EnterDosKbd(); +extern void ExitDosKbd(); +extern unsigned long GenericReturnT(); +#endif /* DOS */ + + +make_kbd_instance(KbdInterface kbd) +{ +#ifdef DOS + kbd->device_event = &Kbd_event; /* */ + kbd->device.enter = &EnterDosKbd; + kbd->device.exit = &ExitDosKbd; + kbd->device.before_raid = &ExitDosKbd; + kbd->device.after_raid = &EnterDosKbd; + kbd->device.active = FALSE; +#elif XWINDOW +#endif /* DOS or XWINDOW */ +} diff --git a/src/kbdsubrs.c b/src/kbdsubrs.c new file mode 100755 index 0000000..5246af3 --- /dev/null +++ b/src/kbdsubrs.c @@ -0,0 +1,222 @@ +/* $Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#ifdef DOS +#include +#include +#else +#include +#include +#include +#endif /* DOS */ + +#ifdef SUNDISPLAY +#include +#include +#include +#endif /* SUNDISPLAY */ + +#include "lispemul.h" + +#ifdef DOS +#define PORT_A 0x60 +#define KBD_COMMAND_PORT 0x64 +#define KBD_ENABLE 0xAE +#define KBD_DISABLE 0xAD + +#include "devif.h" +extern KbdInterface currentkbd; +extern DspInterface currentdsp; +#elif XWINDOW +#include "devif.h" +extern KbdInterface currentkbd; +extern DspInterface currentdsp; +#endif /* DOS */ + +/**************************************************** + * + * KB_enable() entry of SUBRCALL 82 1 + * called from (\KB_enable X) + * + ****************************************************/ + +#ifndef XWINDOW +extern struct screen LispScreen; +#endif /* XWINDOW */ + + +#ifdef XWINDOW +#include +#endif /* XWINDOW */ + +extern int LispWindowFd, + LispReadFds; + +extern int errno; + +KB_enable( args ) +LispPTR *args; /* args[0] : ON/OFF flag + * T -- ON + * NIL -- OFF + */ +{ + if( args[0] == ATOM_T ) +#ifdef SUNDISPLAY + LispReadFds |= 1<< LispWindowFd; +#elif XWINDOW + enable_Xkeyboard(currentdsp); +#elif DOS + (currentkbd->device.enter)(currentkbd); + /* outp( KBD_COMMAND_PORT, KBD_ENABLE); */ +#endif /* DOS */ + + else if( args[0] == NIL ) +#ifdef SUNDISPLAY + LispReadFds &= ~(1 << LispWindowFd); +#elif XWINDOW + disable_Xkeyboard(currentdsp); +#elif DOS + (currentkbd->device.exit)(currentkbd); + /* outp( KBD_COMMAND_PORT, KBD_DISABLE); */ +#endif /* DOS */ + else{ + error("KB_enable: illegal arg \n"); + printf("KB_enable: arg = %d\n", args[0] ); + } +} + + + +/**************************************************** + * + * KB_beep() entry of SUBRCALL 80 2 + * called from (\KB_beep SW FREQ) + * + ****************************************************/ +/* +struct timeval belltime ={ + 0,100 +}; +*/ +extern int LispKbdFd; + +#ifdef DOS + int bell_status_word; +#endif /* DOS */ + +KB_beep( args ) +LispPTR *args; /* args[0] : ON/OFF flag + * T -- ON + * NIL -- OFF + * args[1] : frequency + */ +{ + int keycommand; + +#ifdef SUNDISPLAY +/* belltime.tv_usec = args[1] & 0xffff; + win_bell(LispWindowFd, belltime, 0); +*/ + if( (LispKbdFd = open( LispScreen.scr_kbdname, O_RDWR)) == -1) + fprintf( stderr, "can't open %s, errno=%d\n", + LispScreen.scr_kbdname, errno); + + if( args[0] == ATOM_T ){ + keycommand = KBD_CMD_BELL; /* Turn on the bell */ + if(ioctl( LispKbdFd, KIOCCMD, &keycommand)== -1) + fprintf( stderr, "Error at ioctl errno =%d\n", errno); + } + else{ + keycommand = KBD_CMD_NOBELL; /* Turn off the bell */ + if(ioctl( LispKbdFd, KIOCCMD, &keycommand)== -1) + fprintf( stderr, "Error at ioctl errno =%d\n", errno); + } + + close( LispKbdFd ); + +#elif XWINDOW + if( args[0] == ATOM_T ) + beep_Xkeyboard(currentdsp); +#elif DOS + if( args[0] == ATOM_T ){ + bell_status_word = inp( 0x61 ); + outp( 0x61, bell_status_word | 0x3 ); /* Turn on the speaker */ + /* Prepare timer by sending 10111100 to port 43. */ + outp( 0x43, 0xb6 ); + + /* Divide input frequency by timer ticks per second and + * write (byte by byte) to timer. */ + outp( 0x42, (char)(1193180L / (LispIntToCInt(args[1]))) ); + outp( 0x42, (char)(1193180L / (LispIntToCInt(args[1])) >> 8) ); + } else { + outp( 0x61, bell_status_word & ~0x3 ); /* Turn off the speaker (with */ + /* bits 0 and 1). */ + + } +#endif /* SUNDISPLAY, XWINDOW, DOS */ + + + +} + + + +/**************************************************** + * + * KB_setmp() entry of SUBRCALL 81 1 + * called from (\KB_setMP MPCODE) + * + ****************************************************/ + +KB_setmp( args ) +LispPTR *args; /* args[0] : MPCODE */ +{ + +#ifdef DEBUG + printf("MP: %d\n", args[0] & 0xffff ); +#endif +} + + +/**************************************************** + * + * KB_setled() + * Set the status LED's on the kbd. + * arg[0] Caps lock LED. + * arg[1] Num lock LED. + * arg[2] Scroll lock LED. + * NIL -> LED off + * not NIL -> LED on. + * + ****************************************************/ + +KB_setled( args ) +LispPTR *args; +{ +#ifdef DOS + outp(PORT_A, (unsigned char)0xED); + outp(PORT_A, (unsigned char)(((args[0] != NIL) << 2) | + ((args[1] != NIL) << 1) | + (args[2] != NIL))); +#endif /* DOS */ +} + diff --git a/src/keyevent.c b/src/keyevent.c new file mode 100755 index 0000000..184bdf9 --- /dev/null +++ b/src/keyevent.c @@ -0,0 +1,880 @@ +/* $Id: keyevent.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: keyevent.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/* + * This file contains the routines that interface Lisp to the + * Sun keyboard and mouse. + * + */ + +#include +#include +#include +#ifndef DOS +#include +#include +#include +#else +#include +#endif /* DOS */ +#ifdef DOS + +#include /* Defines "#pragma interrupt" */ +#include /* Defines REGS & other structs */ +#include /* _XSTACK struct definition */ +#pragma interrupt(Mouse_hndlr) + +void Mouse_hndlr(void); /* Fields mouse events from driver */ + /* (during servicing of mouse interrupt) */ + +#elif XWINDOW +#else +#include +#include +#include +#include +#include +#endif /* DOS */ + + +#ifdef ISC +#include +#include +#define SIGIO SIGPOLL +#endif /* ISC */ + + +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "address.h" +#include "stack.h" +#include "keyboard.h" +#include "display.h" +#include "lsptypes.h" + + +#include "iopage.h" +#include "ifpage.h" + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" + +#include "dbprint.h" +#if (defined(DOS) || defined(XWINDOW)) +#include "devif.h" +extern DspInterface currentdsp, colordsp; +extern IOPAGE *IOPage68K; +#endif /* DOS */ + +#ifdef ISC + /*****************************************************/ + /* ISC Unix uses POLL, rather than SELECT, because */ + /* SELECT causes intermittent wild jumps. This is */ + /* the pollfd structure to drive it. */ + /*****************************************************/ +#include +struct pollfd pollfds[33] = { {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0}, + {0, POLLIN|POLLOUT, 0} }; +#endif /* ISC */ + + + +/* for contextsw */ +#define AS_OPCODE 1 +#define AS_CPROG 0 + +/* EmMouseX68K are already swapped, no need for GETWORD */ +#define MouseMove(x,y) {*((DLword *)EmMouseX68K) = x; \ + *((DLword *)EmMouseY68K) = y;} +#ifdef NEVER +#ifndef BYTESWAP +#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ + if( bitvalue) \ + *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ + |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ + else \ + *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ + &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ + } +#else + +/* convert to real 68 k address, then do arithmetic, and convert + back to i386 address pointer */ + +#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ + int real68kbase; \ + real68kbase = 2 ^ ((int)(base68k)); \ + if( bitvalue) \ + GETWORD((DLword*)(real68kbase) + (((u_short)(offset))>>4 )) \ + |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ + else \ + GETWORD((DLword*)(real68kbase) + (((u_short)(offset))>>4 )) \ + &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ + } +#endif +#endif /* NEVER */ + +extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K,*EmUtilin68K; +extern DLword *EmKbdAd168K,*EmKbdAd268K,*EmKbdAd368K,*EmKbdAd468K,*EmKbdAd568K; +extern u_char *SUNLispKeyMap; +extern u_int LispReadFds, LispWindowFd; +extern int RS232CReadFds, RS232C_remain_data, XLocked; +int XNeedSignal = 0; /* T if an X interrupt happened while XLOCK asserted */ + +#ifdef NOETHER +extern u_int LogFileFd; +#else +extern int ether_fd; +extern u_int LogFileFd, EtherReadFds; +#endif /* NOETHER */ + +extern DLword *DisplayRegion68k; + +u_int LispIOFds = 0; +#ifndef DOS +static struct timeval SelectTimeout = { + 0, 0 +}; +#endif /* DOS */ + + +#ifdef XWINDOW +static int Xcount=1; +extern int Event_Req; +#endif /* XWINDOW */ + + + +extern MISCSTATS *MiscStats; + LispPTR *LASTUSERACTION68k; + LispPTR *CLastUserActionCell68k; + LispPTR *CURSORDESTHEIGHT68k; + LispPTR *CURSORDESTWIDTH68k; + + LispPTR *CURSORHOTSPOTX68k; + LispPTR *CURSORHOTSPOTY68k; + LispPTR *SOFTCURSORUPP68k; + LispPTR *SOFTCURSORWIDTH68k; + LispPTR *SOFTCURSORHEIGHT68k; + LispPTR *CURRENTCURSOR68k; + +extern DLword *EmCursorX68K; +extern DLword *EmCursorY68K; + +#ifndef BYTESWAP +typedef struct + { + unsigned nil : 8; + unsigned type: 8; + unsigned num : 16; + } SNum; +#else +typedef struct + { + unsigned num : 16; + unsigned type: 8; + unsigned nil : 8; + } SNum; + +#endif /* BYTESWAP */ + +#define IDiff(x68k,y68k) (((SNum*)(x68k))->num - ((SNum*)(y68k))->num) + +/* EmXXXX68K are already swapped, no need for GETWORD */ + +#ifdef OLD_CURSOR +#define TrackCursor(cx,cy) {*CLastUserActionCell68k = MiscStats->secondstmp;\ + *EmCursorX68K = cx; \ + *EmCursorY68K = cy;} +#else +#define TrackCursor(cx,cy) {*CLastUserActionCell68k = MiscStats->secondstmp;\ + taking_mouse_down();\ + taking_mouse_up(cx,cy); \ + *EmCursorX68K= cx;\ + *EmCursorY68K= cy;} +#endif /* OLD_CURSOR */ + + + +/* function that checks to see if more input is waiting on a file; + if some is, it bumps FileIOFlag so it'll get seen next time around */ +/* commented out is some code that would also clobber + Irq_Stk_Check & Irq_Stk_End to force + a new interrupt as rapidly as possible; it causes odd behavior... + needs some study and thought */ + +/* this is currently called EVERY time the timer expires. It checks for + keyboard input */ + + +LispPTR *MOUSECHORDTICKS68k; + +/**NEW GLOBAL***-> will be moved***/ +LispPTR *KEYBOARDEVENTQUEUE68k; +LispPTR *KEYBUFFERING68k; +int KBDEventFlg=NIL; +DLword *CTopKeyevent; + +LispPTR DOBUFFEREDTRANSITION_index; +LispPTR INTERRUPTFRAME_index; +LispPTR *TIMER_INTERRUPT_PENDING68k; +LispPTR *PENDINGINTERRUPT68k; +LispPTR ATOM_STARTED; +LispPTR *PERIODIC_INTERRUPT68k; +LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; +LispPTR PERIODIC_INTERRUPTFRAME_index; +LispPTR DORECLAIM_index; + +LispPTR *IOINTERRUPTFLAGS_word; + +int URaid_req=NIL; +int ScreenLocked=NIL; + +DLword MonoCursor_savebitmap[CURSORHEIGHT]; /* for mono cursor save-image */ +#define COLOR_DEPTH 8 +#define COLORPIXELS_IN_LONGWORD 4 +#define COLORPIXELS_IN_DLWORD 2 +DLword ColorCursor_savebitmap[CURSORWIDTH/COLORPIXELS_IN_DLWORD * CURSORHEIGHT]; + +/************************************************************************/ +/* */ +/* G E T S I G N A L D A T A */ +/* */ +/* Handler for the SIGIO interrupt, which happens */ +/* 1. When a key transition happens */ +/* 2. On mouse moves */ +/* 3. When TCP input becomes available. */ +/* 4. When a NIT ethernet packet becomes available. */ +/* 5. When a console/log/stderr msg needs to be printed. */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* Statics: LispReadFds A 32-bit vector with a 1 for each */ +/* FD that can get SIGIO interrupts. */ +/* */ +/* LispWindowFd The keyboard/window FD, for keyboard */ +/* and mouse events. */ +/* */ +/* LispIOFds A bit vector of TCP FDs, or other */ +/* FDs Lisp is doing async I/O on. */ +/* Activity on any of these will signal */ +/* the Lisp IOInterrupt interrupt. */ +/* */ +/* ether_fd The raw ethernet FD, for 10MB I/O */ +/* */ +/* EtherReadFds A bit vector with the raw enet's */ +/* bit turned on. To speed up processing. */ +/* */ +/* LogFileFd A bit vector with the log-file's */ +/* bit on, for capturing console msgs. */ +/* */ +/* */ +/* */ +/************************************************************************/ + +getsignaldata(sig, code, scp) + int sig, code; + struct sigcontext *scp; + { +#ifndef DOS +#ifndef XWINDOW + struct inputevent event; +#endif /* XWINDOW */ + + static int rfds, wfds, efds, res; + +#ifdef ISC + int fdcount = 0; + int bit; +#endif + +#ifdef XWINDOW +#if (defined(APOLLO) || defined(sun)) + if( Event_Req ) + { + if (!XLocked++) getXsignaldata(currentdsp); + else XNeedSignal = 1; + Event_Req = FALSE; + XLocked--; + } +#endif +#endif /* XWINDOW */ + + +/* #ifndef KBINT */ + rfds = LispReadFds; + efds = LispReadFds; + /* label and ifs not needed if only keyboard on SIGIO */ +getmore: +#ifdef ISC + for (res=0, bit=1; res<32; res++, bit <<= 1) + if (LispReadFds&bit) + { + pollfds[fdcount++].fd = res; + } + if ((res = poll(pollfds, fdcount, 0)) > 0) +#else + if(select(32, (fd_set *)&rfds, NULL, (fd_set *)&efds, &SelectTimeout) >= 0 ) +#endif + { + DBPRINT(("SIGIO: fd mask(r/e) = 0x%x/0x%x.\n", rfds, efds)); + +#ifdef SUNDISPLAY + if( rfds & (1 << LispWindowFd) ) + { +/* #endif */ + while( input_readevent(LispWindowFd, &event) >= 0 ) + { + /*if(!kb_event( &event )) {goto getmore;};*/ + if((KBDEventFlg+=kb_event( &event ))>0) + { + /* immidiately request for IRQ check */ + Irq_Stk_End=Irq_Stk_Check=0; + } + } +/* #ifndef KBINT */ + } +#endif /* SUNDISPLAY */ + +#ifdef XWINDOW + if (rfds & (1 << ConnectionNumber(currentdsp->display_id))) + { + if (!XLocked) getXsignaldata(currentdsp); + else XNeedSignal = 1; + } + +#endif /* XWINDOW */ + +#ifdef NOETHER +#else + if (rfds & EtherReadFds) + { /* Raw ethernet (NIT) I/O happened, so handle it. */ + DBPRINT(("Handling enet interrupt.\n\n")); + check_ether(); + } +#endif /* NOETHER */ + + +#ifdef RS232 + if (((rfds & RS232CReadFds) == RS232CReadFds) || + (RS232C_remain_data && rs232c_lisp_is_ready())) rs232c_read(); +#endif /* RS232 */ + + +#ifdef LOGINT + if (rfds & LogFileFd) + { /* There's info in the log file. Tell Lisp to print it. */ + flush_pty(); /* move the msg(s) to the log file */ + + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word)) + ->LogFileIO = 1; + + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End=Irq_Stk_Check=0; + } +#endif + if (rfds & LispIOFds) + { /* There's activity on a Lisp-opened FD. Tell Lisp. */ + u_int *flags; + flags = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); + *flags = rfds & LispIOFds; + + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word)) + ->IOInterrupt = 1; + + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End=Irq_Stk_Check=0; + } + + } +/* #endif */ +#endif /* DOS */ + } /* end getsignaldata */ + + + + +/************************************************************************/ +/* */ +/* k b _ e v e n t */ +/* */ +/* Given an event from the kbd code, return 1 if a key transition */ +/* occurred, 0 if one didn't occur. */ +/* */ +/************************************************************************/ +#if (!defined(XWINDOW) && !defined(DOS)) +extern int for_makeinit; + +int kb_event( event ) +register struct inputevent *event; + { + register u_int upflg; + int kn; + DLword w,r; + KBEVENT *kbevent; + +#ifdef INIT + +/* generate some code to check if we are running as an INIT. Don't + needlessly generate this code, and don't return if we aren't + running with the -INIT flag turned on. --was 2/7/89 */ + + if (for_makeinit) + { + return(0); + }; + +#endif + + upflg = event_is_up( event ); + +#ifdef SHOWKEYSTROKES + printf("Key # %d, upflg %d.\n", (unsigned short)event->ie_code, upflg); +#endif + + switch( ((unsigned short)event->ie_code) ) + { + case LOC_MOVE: +#ifndef OLD_CURSOR + if(!ScreenLocked) +#endif + { ScreenLocked=T; + MouseMove( event->ie_locx, event->ie_locy ); + TrackCursor(event->ie_locx,event->ie_locy ); + ScreenLocked=NIL; + } + return(0); + + case MS_LEFT: /*mouse_button( MOUSE_LEFT, upflg );*/ + PUTBASEBIT68K( EmRealUtilin68K, MOUSE_LEFT, upflg ); + break; + + case MS_MIDDLE: /*mouse_button( MOUSE_MIDDLE, upflg );*/ + PUTBASEBIT68K( EmRealUtilin68K, MOUSE_MIDDLE, upflg ); + break; + + case MS_RIGHT: /*mouse_button( MOUSE_RIGHT, upflg );*/ + PUTBASEBIT68K( EmRealUtilin68K, MOUSE_RIGHT, upflg ); + break; + + default: /* keystroke */ + if((kn=SUNLispKeyMap[((unsigned short)event->ie_code)]) > -1) + kb_trans( kn, upflg ); + else + printf("kb_event: unknown key number=%d\n", + event->ie_code ); + + break; + }; + { + do_ring: + /* Emxxx do not use GETWORD */ + if(((*EmKbdAd268K) & 2113) == 0) + {/*Ctrl-shift-NEXT*/ + error("****** EMERGENCY Interrupt ******"); + (*EmKbdAd268K)=KB_ALLUP; /*reset*/ + ((RING*)CTopKeyevent)->read=0; /* reset queue */ + ((RING*)CTopKeyevent)->write=MINKEYEVENT; + /*return(0);*/ + } + else if(((*EmKbdAd268K) & 2114) == 0) + { /* Ctrl-Shift-DEL */ + (*EmKbdAd268K)=KB_ALLUP; /*reset*/ + URaid_req=T; + ((RING*)CTopKeyevent)->read=0; /* reset queue */ + ((RING*)CTopKeyevent)->write=MINKEYEVENT; + + /*return(0);*/ + } + +#ifdef OS4_TYPE4BUG + else if(((*EmKbdAd268K) & 2120) == 0) + { /* Ctrl-Shift-Return */ + error("****** EMERGENCY Interrupt ******"); + (*EmKbdAd268K)=KB_ALLUP; /*reset*/ + ((RING*)CTopKeyevent)->read=0; /* reset queue */ + ((RING*)CTopKeyevent)->write=MINKEYEVENT; + /*return(0);*/ + } +#endif + + r=RING_READ(CTopKeyevent); + w=RING_WRITE(CTopKeyevent); + + if(r==w) goto KBnext; /* event queue FULL */ + + kbevent=(KBEVENT*)(CTopKeyevent+ w); + +/* RCLK(kbevent->time); */ + + kbevent->W0= (*EmKbdAd068K); /* Emxxxx do not use GETWORD */ + kbevent->W1= (*EmKbdAd168K); + kbevent->W2= (*EmKbdAd268K); + kbevent->W3= (*EmKbdAd368K); + kbevent->W4= (*EmKbdAd468K); + kbevent->W5= (*EmKbdAd568K); + kbevent->WU= (*EmRealUtilin68K); + + if(r==0) /* Queue was empty */ ((RING*)CTopKeyevent)->read=w; + if(w >= MAXKEYEVENT) ((RING*)CTopKeyevent)->write = MINKEYEVENT; + else ((RING*)CTopKeyevent)->write = w + KEYEVENTSIZE; + + KBnext: + if(*KEYBUFFERING68k == NIL) *KEYBUFFERING68k=ATOM_T; + + } /* if *EmRealUtilin68K end */ + return(1); + } +#endif /* neither XWINDOW nor DOS*/ + + + + +/************************************************************************/ +/* */ +/* k b _ t r a n s */ +/* */ +/* Return the transition code?? */ +/* */ +/************************************************************************/ + +kb_trans( keycode, upflg ) + u_short keycode; + u_short upflg; + { + extern IFPAGE *InterfacePage; + if( keycode < 64 ) /* DLKBDAD0 ~ 3 */ + { PUTBASEBIT68K( EmKbdAd068K, keycode, upflg );} + else if( keycode >= 80 )/* DLKBDAD4, 5 */ + { PUTBASEBIT68K( EmKbdAd068K, keycode - 16, upflg );} + else if( keycode >= 64 && keycode < 80 )/* DLUTILIN */ + { + PUTBASEBIT68K( EmRealUtilin68K, (keycode & 15), upflg ); + PUTBASEBIT68K( EmUtilin68K, (keycode & 15), upflg ); + } +} + + + + +/**********************************************************/ +/* + MOUSE tracking +*/ +/**********************************************************/ + + +typedef struct + { + LispPTR CUIMAGE; + LispPTR CUMASK; + LispPTR CUHOTSPOTX; + LispPTR CUHOTSPOTY; + LispPTR CUDATA; + } CURSOR ; + +#define DLWORD_PERLINE (displaywidth/16) +#define HARD_CURSORWIDTH 16 +#define HARD_CURSORHEIGHT 16 +#define COLOR_BITSPER_PIXEL 8 +/* For MonoOrColor */ +#define MONO_SCREEN 0 +#define COLOR_SCREEN 1 +#define CursorClippingX(posx,width) { \ + if( displaywidth < (posx + HARD_CURSORWIDTH)) { \ + LastCursorClippingX=width=displaywidth-posx;} \ + else { LastCursorClippingX=width=HARD_CURSORWIDTH;}} + +#define CursorClippingY(posy,height){ \ + if(displayheight < (posy + HARD_CURSORHEIGHT)) { \ + LastCursorClippingY = height = displayheight - posy;} \ + else { LastCursorClippingY = height = HARD_CURSORHEIGHT;}} + +extern int displaywidth, displayheight; +extern int DisplayInitialized ; +extern int MonoOrColor; /* MONO_SCREEN or COLOR_SCREEN */ +int LastCursorClippingX=HARD_CURSORWIDTH; +int LastCursorClippingY = HARD_CURSORHEIGHT; +int LastCursorX=0; +int LastCursorY=0; + + +#ifndef COLOR +/* FOR MONO ONLY */ +taking_mouse_down() + { + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + +#ifdef DOS + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); +#else + if(!DisplayInitialized) return; + + /* restore saved image */ + srcbase=MonoCursor_savebitmap; + dstbase=DisplayRegion68k +( (LastCursorY) * DLWORD_PERLINE); /* old y */ + sx=0; + dx = LastCursorX; /* old x */ + w = LastCursorClippingX; /* Old clipping */ + h= LastCursorClippingY; + srcbpl =HARD_CURSORWIDTH; + dstbpl =displaywidth; + op=0; + new_bitblt_code; +#ifdef DISPLAYBUFFER + flush_display_region(dx, (LastCursorY), w, h); +#endif /* DISPLAYBUFFER */ +#endif /* DOS */ + } +#else + + /* For COLOR & MONO */ +extern DLword *ColorDisplayRegion68k; + /* It assumes that MONO screen size and COLOR screen size are identical */ +taking_mouse_down() + { + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + + if(!DisplayInitialized) return; + /* restore saved image */ + sx=0; + + if(MonoOrColor == MONO_SCREEN) + { + dx = LastCursorX; /* old x */ + srcbase=MonoCursor_savebitmap; + dstbase=DisplayRegion68k +( (LastCursorY) * DLWORD_PERLINE); /* old y */ + w = LastCursorClippingX; /* Old clipping */ + h= LastCursorClippingY; + srcbpl =HARD_CURSORWIDTH; + dstbpl =displaywidth; + } + else + { + dx = LastCursorX * COLOR_BITSPER_PIXEL; /* old x */ + srcbase=ColorCursor_savebitmap; + dstbase= ColorDisplayRegion68k + + ((LastCursorY) * DLWORD_PERLINE * COLOR_BITSPER_PIXEL); /* old y */ + w = LastCursorClippingX * COLOR_BITSPER_PIXEL; /* Old clipping */ + h= LastCursorClippingY; + srcbpl =HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL; + dstbpl =displaywidth * COLOR_BITSPER_PIXEL ; + } + op=0; + new_bitblt_code; +#ifdef DISPLAYBUFFER + if( MonoOrColor == MONO_SCREEN ) + flush_display_region(dx, LastCursorY, w, h); +#endif +} +#endif /* COLOR */ + + +/* I'll make it MACRO */ +taking_mouse_up(newx,newy) + int newx,newy; + { +#ifdef DOS + (currentdsp->mouse_vissible)(newx, newy); +#else + if(!DisplayInitialized) return; + /* save hidden bitmap */ + cursor_hidden_bitmap(newx,newy); + /* Copy Cursor Image */ +#ifndef INIT + copy_cursor(newx,newy); +#endif + LastCursorX=newx; + LastCursorY=newy; +#endif + } + +/* LastCursorClippingX must be set brfore calling + To avoid duplicate caluculation */ +#ifndef COLOR +/* FOR MONO ONLY */ +copy_cursor(newx,newy) + int newx,newy; + { + register DLword *srcbase, *dstbase; + register int offsetx,offsety; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + extern DLword *EmCursorBitMap68K; + /* copy cursor image */ + srcbase = EmCursorBitMap68K; + dstbase= DisplayRegion68k +(newy * DLWORD_PERLINE) ; + sx=0; + dx=newx; + w=LastCursorClippingX; + h=LastCursorClippingY;; + srcbpl=HARD_CURSORWIDTH; + dstbpl=displaywidth; + op=2; /* OR-in */ + new_bitblt_code; +#ifdef DISPLAYBUFFER + flush_display_region(dx, newy, w, h); +#endif + } + +/* store bitmap image inside rect. which specified by x,y */ +cursor_hidden_bitmap(x,y) + int x,y; + { + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + /* save image */ + srcbase=DisplayRegion68k +( y* DLWORD_PERLINE) ; + dstbase=MonoCursor_savebitmap; + sx=x; + dx=0; + CursorClippingX(x,w); /* w and LastCursorClippingX rest */ + CursorClippingY(y,h); /* h and LastCursorClippingY reset */ + srcbpl =displaywidth; + dstbpl=HARD_CURSORWIDTH; + op= 0; /* replace */ + new_bitblt_code; + } + +#else +/* For COLOR & MONO */ +#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) +copy_cursor(newx,newy) + int newx,newy; + { + register DLword *srcbase, *dstbase; + register int offsetx,offsety; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; + static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + CURSOR *cursor68k; + BITMAP *bitmap68k; + extern DLword *EmCursorBitMap68K; + /* copy cursor image */ + if(MonoOrColor == MONO_SCREEN) + { + srcbase = EmCursorBitMap68K; + dstbase= DisplayRegion68k +(newy * DLWORD_PERLINE) ; + sx=0; + dx=newx; + w=LastCursorClippingX; + h=LastCursorClippingY;; + srcbpl=HARD_CURSORWIDTH; + dstbpl=displaywidth; + } + else + { + cursor68k = (CURSOR*)Addr68k_from_LADDR(*CURRENTCURSOR68k); + bitmap68k=(BITMAP*)Addr68k_from_LADDR(cursor68k->CUIMAGE); + srcbase =(DLword*) Addr68k_from_LADDR(bitmap68k->bmbase); + dstbase= ColorDisplayRegion68k +(newy * DLWORD_PERLINE * COLOR_BITSPER_PIXEL) ; + sx=0; + dx=newx * COLOR_BITSPER_PIXEL; + w=IMIN(LastCursorClippingX,LOLOC(bitmap68k->bmwidth)) * COLOR_BITSPER_PIXEL; + h=IMIN(LastCursorClippingY,LOLOC(bitmap68k->bmheight)); + /* srcbpl=HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL;*/ + srcbpl = bitmap68k->bmwidth * COLOR_BITSPER_PIXEL; + dstbpl=displaywidth * COLOR_BITSPER_PIXEL; + } + op=2; /* OR-in */ + new_bitblt_code; +#ifdef DISPLAYBUFFER + if( MonoOrColor == MONO_SCREEN ) + flush_display_region(dx, newy, w, h); +#endif + } + +/* store bitmap image inside rect. which specified by x,y */ +cursor_hidden_bitmap(x,y) +int x,y; +{ +register DLword *srcbase, *dstbase; +static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; +static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; +/* save image */ +if(MonoOrColor == MONO_SCREEN) { + srcbase=DisplayRegion68k +( y* DLWORD_PERLINE) ; + dstbase=MonoCursor_savebitmap; + sx=x; + dx=0; + CursorClippingX(x,w); /* w and LastCursorClippingX rest */ + CursorClippingY(y,h); /* h and LastCursorClippingY reset */ + srcbpl =displaywidth; + dstbpl=HARD_CURSORWIDTH; +} +else { + srcbase=ColorDisplayRegion68k +(y * DLWORD_PERLINE * COLOR_BITSPER_PIXEL); + dstbase= ColorCursor_savebitmap; + sx=x * COLOR_BITSPER_PIXEL ; + dx=0; + CursorClippingX(x,w); /* w and LastCursorClippingX rest */ + CursorClippingY(y,h); /* h and LastCursorClippingY reset */ + w = w * COLOR_BITSPER_PIXEL; + srcbpl =displaywidth * COLOR_BITSPER_PIXEL ; + dstbpl=HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL; +} +op= 0; /* replace */ +new_bitblt_code; +} +#endif /* COLOR */ + diff --git a/src/keylib.c b/src/keylib.c new file mode 100755 index 0000000..848ab35 --- /dev/null +++ b/src/keylib.c @@ -0,0 +1,251 @@ +/* $Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1999 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/* ============================================================================== + The functions defined in this file were called by KEYMAKER.C & KEYTESTER.C + + Creation Date: May, 1988 + ============================================================================== */ + +#include +#include +#include + + +#define GOLDEN_RATIO_HACK -478700649 +#define ULONG_MAX 4294967295 + +/* meaning of symbolic constant used: + + FAILURE2 invalid date */ + +#define FAILURE2 -2 + +unsigned long make_verification(long unsigned int x, long unsigned int y); +unsigned long date_integer16(const char *date); +unsigned long idate(const char *str); +unsigned long modify(long unsigned int hostid); + + +/* =========================================================================== + MAKE_VERIFICATION forms a new 32-bit integer by messaging the two input + long integers x and y. The number was created from the lower bits toward + higher bits. + =============================================================================*/ + +unsigned long make_verification (long unsigned int x, long unsigned int y) +{ + return (imod64bit(x , y , 4) | + (imod64bit(x , y , 6) << 3) | + (imod64bit(x , y , 13) << 6) | + (imod64bit(x , y , 25) << 10) | + (imod64bit(x , y , 30) << 15) | + (imod64bit(x , y , 63) << 20) | + (imod64bit(x , y , 5) << 26) | + (imod64bit(x , y , 7) << 29) ); + } + + +/* =========================================================================== + IMOD64BIT computs (IMOD X Y). + X is a 64-bit integer; x1 is the higher 32-bit while x0 is the lower 32-bit. + Y is less than 65535. + (((ULONG_MAX % y) + 1 ) % y) is equivalent to (expt 2 32) % y + =============================================================================*/ + + +imod64bit (long unsigned int x1, long unsigned int x0, long unsigned int y) +{ +/* JDS 990601 ansi return (((x0 % y) + ((x1 % y) * (((ULONG_MAX % y) + 1 ) % y) )) % y); */ + return (((x0 % y) + ((x1 % y) * ((y + 1 ) % y) )) % y); +} + +/* ============================================================ + DATE_INTEGER16 takes a date string and return an intger + =============================================================*/ + +unsigned long date_integer16 (const char *date) +{ + unsigned long const1 , const2; + + const1 = 17152 ; + const2 = 86400 ; + return ((idate(date) - const1 ) / const2); +} + + +/* =================================================================== + IDATE takes a date string (dd-mmm-yy or dd mmm yy) and return an + integer. + dd - date in decimal digits + mmm - month name in alphabetic form or decimal digits + yy - year in decimal digits ; can be 2 or 4 digits + If date1 is before date2 then (idate date1) < (idate date2). + If date string is not valid, FAILURE2 is returned. + =====================================================================*/ + +unsigned long idate(const char *str) +{ + char ds[50]; + char *decdigits = {"0123456789"}; + char *tokendelimiters = {" -"}; + char *yptr, *mptr, *dptr, *ptr1; + + int day, month, year, maxday; + int i, len ,s; + unsigned long days_since_day0, sec, hour; + + static char *month_name[13] = {"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", + "SEP", "OCT", "NOV", "DEC"}; + + static int days_each_month[13] = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + static int days_since_jan1st[12] = {0,31,59,90,120,151,181,212,243,273,304,334} ; + + /* copy input string to a local one */ + ds[0] = '\0'; + strcpy(ds,str); + + /* get day, month, and year string tokens */ + if ((dptr = strtok(ds, tokendelimiters)) == NULL) return FAILURE2; + if ((mptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2; + if ((yptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2; + + + /* validate year and convert it to numeric form 19xx */ + if (strspn (yptr, decdigits) != strlen(yptr)) return FAILURE2; + if ((year = atoi(yptr)) <= 100) year += 1900; + if (year < 1970 || year > 2050) return FAILURE2; + + + /* validate month and convert it to numeric form if necessary */ + if (strspn (mptr,decdigits) == (len = (strlen(mptr)))) + { + /* input month is in numeric form */ + if ((month = atoi(mptr)) < 1 || month > 12) return FAILURE2; + } + else + { + /* input month is in alphabetic form */ + + /* we're only interested in the first 3 chars */ + if (len > 3) *(mptr+3) = '\0'; + + ptr1 = mptr; + + + /* make sure month name is in upper case letters */ + for (i = 0 ; (s = *(ptr1+i)) != '\0' ; ++i) + if (islower(s)) *(ptr1+i) = toupper(s); + + + /* find out its corresponding numeric value */ + for (i = 1 ; i <= 12 ; ++i) + if ( strcmp(*(month_name+i), mptr) == 0) + { month = i ; + break; + }; + if (i == 13) return FAILURE2; + }; + + /* set up maxday to be the number of days of that month */ + maxday = days_each_month[month]; + + /* watch out for leap year */ + if (month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) ++maxday; + + + /* validate day */ + if ( strspn(dptr,decdigits) != strlen(dptr) || (day = atoi(dptr)) < 1 || maxday < day) + return FAILURE2; + + + year -= 1901; --month; + days_since_day0 = days_since_jan1st[month] + (day - 1) + (365 * year) + (year / 4); + + if (month > 1 && year % 4 == 3 && year != -1) ++days_since_day0; + + + hour = (24 * days_since_day0) + 7; +/* JDS 990601 ANSI cleanup sec = (60 * (60 * hour)) ^ -2147483648L ; */ + sec = (60 * (60 * hour)) ^ 0x80000000 ; + /* printf("\n days_since_day0: %ld hour: %ld sec: %ld\n", days_since_day0 , hour ,sec); */ + return sec; + } + + +/* ============================================================ + MODIFY turns on/off certain bits of the passed + in 32-bit hostid, depending on the value of (hostid % 16). + =============================================================*/ + +unsigned long modify (long unsigned int hostid) +{ + unsigned long dividor; + +#ifdef xBIGVM + hostid ^= 0xa3f5069e; +#endif /* xBIGVM */ + + dividor = 16; + switch (hostid % dividor) + { + case 0: hostid = hostid | 0x48004802; + break; + case 1: hostid = hostid ^ 0xfedc5793; + break; + case 2: hostid = hostid ^ 0x9981afe3; + break; + case 3: hostid = hostid & 0xffcb6ffd; + break; + case 4: hostid = hostid ^ 0x3489dfa8; + break; + case 5: hostid = hostid | 0x77012877; + break; + case 6: hostid = hostid & 0xefc9fffd; + break; + case 7: hostid = hostid | 0x22311300; + break; + case 8: hostid = hostid & 0xdadf8871; + break; + case 9: hostid = hostid ^ 0xe8c948ad; + break; + case 10: hostid = hostid | 0x12488412; + break; + case 11: hostid = hostid & 0xeffdea87; + break; + case 12: hostid = hostid ^ 0xad8ce639; + break; + case 13: hostid = hostid | 0x88221144; + break; + case 14: hostid = hostid & 0xfffb6edd; + break; + default: hostid = hostid ^ 0xfffddeee; + break; + }; + /* printf("\n ** new host id: result: %x ", hostid); */ + return hostid; +} + + + + + + diff --git a/src/keymaker.c b/src/keymaker.c new file mode 100755 index 0000000..09c68ab --- /dev/null +++ b/src/keymaker.c @@ -0,0 +1,251 @@ +/* $Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + +/* ===================================================================== + This function is used to generate copyright protection keys for + enue's Medley software. It prompts for a machine's host id and + the software's expiration date before generating a set of 3 keys. + + The external functions called were stored in file 'keylib.o'. + + Creation Date: May, 1988 + ===================================================================== */ + +#include +#include +#include + +#define GOLDEN_RATIO_HACK -478700649 +#define floadbyte(number,pos) ((number >> pos) & 0xFFFF) +#define hash_unhash(number,hashkey) (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey,16) + floadbyte(hashkey,0)) )) +#define KEYNUMBERS 3 + + +/* meaning of symbolic constants used: + + FAILURE1 invalid hostid + FAILURE2 invalid date entered from terminal + FAILURE3 can't open logfile in the command line */ + +#define FAILURE1 -1 +#define FAILURE2 -2 +#define FAILURE3 -3 + + +unsigned long make_verification(long unsigned int x, long unsigned int y); +unsigned long date_integer16(char *date); +unsigned long idate(char *str); +unsigned long modify(long unsigned int hostid); + + + +/************************************************************************/ +/* */ +/* w r i t e r e s u l t s */ +/* */ +/* Prints the newly-generated key, along with identifying info */ +/* */ +/************************************************************************/ + +writeresults(FILE *fp, char *host, char *expdate, int key1, int key2, int key3, char *info) +{ + fprintf(fp, "Host ID: %-14s Expiration: %-9s",host, expdate); + fprintf(fp, " Key: %8x %8x %8x", key1, key2, key3); + fprintf(fp, " Doc: %s\n", info); + } + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +main(int argc, char **argv) +{ + int logfile = 0; /* set to 1 if logfile on command line */ + FILE *fp; /* file pointer for the logfile */ + unsigned long hostid; + long keyarray[KEYNUMBERS]; + char *hexdigits = {"-0123456789abcdefABCDEF"}; + char s[50], hstr[50], expdate[30], saveexpdate[30], cc; + char infostring[500]; + char *sptr, *ptr, *digitstring; + char *hptr = {" "}; + char **hhptr = &hptr; + int base = 10; + int i,j,c; + int commandlineargs; + + commandlineargs = (argc > 2); + /* If we have more than one argv we assume this is used as a filter */ + + /* == check if user enters logfile name in the command line == */ + + if ((argc > 1) & !commandlineargs) + { + if ((fp = fopen(*++argv,"a")) == NULL) + { + printf("\n Can't open %s \n", *argv); + exit(FAILURE3); + }; + logfile = 1; + }; + + /* == prompt for machine's host id, verify, then do some modification == */ + + if (commandlineargs) + { + /* assume that the second argument is hex-hostid */ + sptr = *++argv; + hostid = strtol(sptr,hhptr,16); + + } + else + { + printf("\n\nEnter Host ID (starts with 0x if the number is hexidecimal): "); + gets(s); + sptr = strtok(s," "); + + /* decide the base */ + if (((ptr = strchr(sptr,'0')) != NULL) && + (*(ptr+1) == 'x' || *(ptr+1) == 'X')) base = 16; + +#ifdef INDIGO + hostid = strtoul(sptr,hhptr,base); +#elif defined(OS5) + hostid = strtoul(sptr,hhptr,base); +#else + hostid = strtol(sptr,hhptr,base); +#endif + + /* look for syntax error */ + if (**hhptr != '\0') + { + printf("\nInvalid Host ID \n"); + exit(FAILURE1); + }; + + /* make sure Host ID is less than 32 bits */ + if (base == 16) + { sprintf(hstr, "%x", hostid); + for (i = 0 ; (cc = *(sptr+i)) != '\0' ; ++i) + if (isupper(cc)) *(sptr+i) = tolower(cc); + for (i = 0 ; (cc = *(hstr+i)) != '\0' ; ++i) + if (isupper(cc)) *(hstr+i) = tolower(cc); + digitstring = "123456789abcdef"; + } + else + { sprintf(hstr, "%u", hostid); + digitstring = "123456789"; + }; + + ptr = strpbrk(sptr,digitstring); + if ((ptr == NULL && *sptr != '0' && *hstr != '0') || + (ptr != NULL && strcmp(ptr,hstr) != 0)) + { + printf("\nInvalid Host ID \n"); + exit(FAILURE1); + } + }; + hostid = modify(hostid); + + /* == prompt for the expiration date and validate it == */ + + if (!commandlineargs) + { + /* assume that info is not needed when we use argc,argv */ + printf("\n\nEnter information string (one line only, below)\n:"); + gets(infostring); + } + /* == prompt for the expiration date and validate it == */ + + if (commandlineargs) + { + + strcpy(expdate,*++argv); + + } else { + + printf("Enter Software Expiration Date (dd-mmm-yy or never): "); + gets(expdate); + + } + strcpy(saveexpdate,expdate); + /* check for 'never' entry */ + if ((expdate[0] == 'N') || (expdate[0] == 'n')) + { + for (i = 0 ; (c = expdate[i]) != '\0' ; ++i) + if (islower(c)) expdate[i] = toupper(c); + + if ( strcmp(expdate, "NEVER") == 0) + strcpy(expdate, "29-DEC-77"); + else { + printf("\nInvalid Software Expiration Date\n"); + exit(FAILURE2); + }; + }; + + /* validate the date */ + if ( idate(expdate) == FAILURE2) + { + printf("\nInvalid Software Expiration Date\n"); + exit(FAILURE2); + }; + + /* == generate 3 keys == */ + keyarray[0] = hash_unhash(hostid, hostid); + keyarray[1] = hash_unhash( ((date_integer16(expdate) << 16) | 0), hostid); + keyarray[2] = make_verification(keyarray[0], keyarray[1]); + + + /* == report the results == */ + + if (commandlineargs) + { + printf("%8x %8x %8x\n", *keyarray, *(keyarray+1), *(keyarray+2)); + } + else + { + /* if logfile is open, append the results to the end of the file */ + if (logfile == 1) + { + if (argc > 2) + { + fprintf(fp,"\n%s",*++argv); + printf("\n%s",*argv); + } + writeresults( fp, sptr, saveexpdate, + *keyarray, *(keyarray+1), *(keyarray+2), + infostring); + fclose(fp); + }; + writeresults( stdout, sptr, saveexpdate, + *keyarray, *(keyarray+1), *(keyarray+2), + infostring); + /* display the results on the terminal */ + }; + exit(0); +} diff --git a/src/keytst.c b/src/keytst.c new file mode 100755 index 0000000..eee2892 --- /dev/null +++ b/src/keytst.c @@ -0,0 +1,201 @@ +/* $Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +/* ========================================================================= + The functions defined in this file are used to validate the copyright + protection keys for NewCo's Maiko software. The main function is + 'keytester', which takes an input key string and returns a status + code after processing the keys. + + The external functions called were stored in file 'keylib.o'. + + Creation date: May, 1988 + ====================================================================== */ + +#include +#include +#include + +#ifdef HPUX + /* On HPUX, use the UNAME syscall to get hostid */ +#include +#endif + + +#define GOLDEN_RATIO_HACK -478700649 +#define floadbyte(number,pos) ((number >> pos) & 0xFFFF) +#define hash_unhash(number,hashkey) (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey,16) + floadbyte(hashkey,0)) )) +#define KEYNUMBERS 3 +#define RC0 0 + +/* meaning of symbolic constants used: + + FAILURE2 invalid date + FAILURE3 invalid key + FAILURE4 key expired + FAILURE99 invalid date (this shouldn't happen unless string format returned by ctime got changed) */ + +#define FAILURE2 -2 +#define FAILURE3 -3 +#define FAILURE4 -4 +#define FAILURE99 -99 + + + +unsigned long make_verification(long unsigned int x, long unsigned int y); +unsigned long date_integer16(char *date); +unsigned long idate(char *str); +unsigned long modify(long unsigned int hostid); + + +/* ===================================================================== + KEYTESTER checks the input key string. + It returns 0 if the keys are valid, otherwise it returns non-0. + ====================================================================== */ +int keytester(char *keystring) +{ unsigned long keyarray[KEYNUMBERS]; /* array which holds numeric keys */ + unsigned long hostid ; /* 32-bit unique identifier of the current host */ + unsigned long hashedword; + int rc; /* return code */ +#ifdef HPUX + struct utsname unameinfo; +#endif + + + /* check the keys and convert them from hexdecimal strings to numbers */ + if (keystring == NULL) return FAILURE3; + if ( read_hex(keystring , keyarray) == FAILURE3) return FAILURE3 ; + + + /* get machines host id */ +#ifdef HPUX + uname(&unameinfo); + hostid = atol(unameinfo.idnumber); +#else + hostid = gethostid(); + printf("hostid = 0x%x\n", hostid); +#endif + + hostid = modify(hostid); + + /* generate hashword */ + hashedword = hash_unhash(keyarray[1] , hostid); + + /* validate keys */ + if (keyarray[0] != hash_unhash(hostid , hostid)) return FAILURE3; + if ((rc = ok_date(floadbyte(hashedword , 16))) != RC0) return rc; + if (keyarray[2] != make_verification(keyarray[0] , keyarray[1])) + return FAILURE3; + + return 0; + } + +/* ===================================================================== + READ_HEX reads in keys from the input string , validates them, then + stores them in the input array. + ====================================================================== */ + +int read_hex(char *s1, long unsigned int *array) +{ + char *s2 = {" "}; + char *ptr; + char *hexdigits = {"0123456789abcdefABCDEF"}; + int i ; + + for (i = 0 ; (i < KEYNUMBERS) && ((ptr = strtok(s1 , s2)) != NULL) ; ++i) + { + + /* make sure the key contains only hexadecimal characters */ + if ( (strspn (ptr,hexdigits)) != strlen(ptr)) return FAILURE3; + + /* convert key to numeric format*/ +#ifdef HPUX + *(array + i) = strtoul(ptr,NULL,16); /* On HP, must convert to unsigned */ +#elif defined(APOLLO) + *(array + i) = strtoul(ptr,NULL,16); /* On APOLLO, must convert to unsigned */ +#elif defined(INDIGO) + *(array + i) = strtoul(ptr,NULL,16); /* On Indigo, must convert to unsigned */ +#elif defined(RS6000) + *(array + i) = strtoul(ptr,NULL,16); /* On RS/6000, must convert to unsigned */ +#elif defined(OSF1) + *(array + i) = strtoul(ptr,NULL,16); /* On Alpha, must convert to unsigned */ +#else + *(array + i) = strtol(ptr,NULL,16); /* On suns, this works OK */ +#endif +printf("0x%x ", *(array+i)); fflush(stdout); + /* continue search the next one */ + s1 = NULL; + }; + + if (i == KEYNUMBERS) return RC0; + else return FAILURE3; + } + +/* ============================================ + OK_DATE checks the expiration of the key + ============================================ */ + +int ok_date (long unsigned int date) +{ + char current_date[30]; + char *mptr, *dptr, *yptr, *str; + long realtime , *clock; + + /* first check if the expiration date is set to indefinite */ + + printf("\narg date: %ld %x\n", date, date); + printf("\narg date ?????: %ld %x\n", date_integer16("29-DEC-77"), date_integer16("29-DEC-77")); + + if (date == date_integer16("29-DEC-77")) return RC0; + + + /* next check if current date is less than or equal to the expiration date */ + /* get the current date string */ + realtime = time(0); + clock = &realtime; + str = (char *) ctime(clock); + + /* delete day and time info and rearrange the string format to be dd-mmm-yy */ + mptr = strtok(str," "); + mptr = strtok(NULL," "); + dptr = strtok(NULL," "); + yptr = strtok(NULL," "); + yptr = strtok(NULL," \n"); /* watch out for newline char */ + current_date[0] = '\0'; + strcat(current_date , dptr); + strcat(current_date , "-"); + strcat(current_date , mptr); + strcat(current_date , "-"); + strcat(current_date , yptr); + + /* check the date */ + if (idate(current_date) == FAILURE2) return FAILURE99; + + + printf("*current date*: %ld %x\n", date_integer16(current_date), date_integer16(current_date)); + + return (date_integer16(current_date) <= date ) ? RC0 : FAILURE4; + } + + + diff --git a/src/keytstno.c b/src/keytstno.c new file mode 100755 index 0000000..384d937 --- /dev/null +++ b/src/keytstno.c @@ -0,0 +1,26 @@ +/* $Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyright (C) Venue"; + +/* Loaded instead of keytst.c, with unlocked definition of keytester */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +keytester (void) +{ + return 0; + } diff --git a/src/kprint.c b/src/kprint.c new file mode 100755 index 0000000..0521682 --- /dev/null +++ b/src/kprint.c @@ -0,0 +1,253 @@ +/* $Id: kprint.c,v 1.2 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: kprint.c,v 1.2 1999/05/31 23:35:36 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + +#include +#include "print.h" +#include "address.h" +#include "lispemul.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "initatms.h" +#include "cell.h" +#include "emlglob.h" +#include "lispmap.h" +#include "adr68k.h" + + +int PrintMaxLevel= 3; +int Printdepth=0; +int PrintMaxLen = 10; +int PrintLen[20] ; + +/************************************************************************/ +/* */ +/* P R I N D A T U M */ +/* */ +/************************************************************************/ + +prindatum(LispPTR x) +{ + NEWSTRINGP *newstring ; + struct dtd *dtd_base; + int typen; + LispPTR typename; + + if(Printdepth >= PrintMaxLevel) + { + if (Printdepth = PrintMaxLevel){ if(GetTypeNumber(x)==TYPE_LISTP) + { + printf("(-)"); + } + else printf("*");} + return; + } + + x = x & POINTERMASK; + switch (typen = GetTypeNumber(x)) + { + case TYPE_LITATOM: +#ifdef BIGATOMS + case TYPE_NEWATOM: +#endif /* BIGATOMS */ + print_atomname(x); + break; + case TYPE_LISTP: + Printdepth++; + PrintLen[Printdepth] = 0; + printf("%c" , LEFT_PAREN); /* print "(" */ + lp: if (PrintLen[Printdepth] ++ > PrintMaxLen) {printf("%c", RIGHT_PAREN); Printdepth--; break;} + prindatum(car(x)); + if (Listp (cdr(x)) == 0) + { /* print dotted pair */ + if ((x = cdr(x)) != NIL) + { + printf(" . "); + prindatum(x); + } + } + else + { + printf("%c" , SPACE); + x = cdr(x); + goto lp; + } + printf("%c" , RIGHT_PAREN); /* print ")" */ + Printdepth--; + break; + + case TYPE_SMALLP: + if ((x & SEGMASK) == S_POSITIVE) + printf("%d" , LOLOC(x)); /* print positive smallp */ + else + printf("%d" , (LOLOC(x) | 0xffff0000)); /* print negative smallp */ + break; + case TYPE_FIXP: + print_fixp(x); /* print fixp */ + break; + case TYPE_FLOATP: + print_floatp(x); + break; + case TYPE_STRINGP: + print_string(x); /* print string */ + break; + case TYPE_ONED_ARRAY : + case TYPE_GENERAL_ARRAY : + newstring=(NEWSTRINGP *)Addr68k_from_LADDR(x); + if(newstring->stringp){ + print_NEWstring(x); + break; } + + default: + dtd_base = (struct dtd *)GetDTD(typen); + printf("{"); +#ifdef BIGVM + if((typename = dtd_base->dtd_name) != 0) +#else + if((typename = dtd_base->dtd_namelo+(dtd_base->dtd_namehi<<16)) != 0) +#endif + print_atomname(typename); + else printf("unknown"); + printf("}0x"); + printf("%x" , x); /* print lisp address in hex */ + } +} + + +/************************************************************************/ +/* */ +/* P R I N T */ +/* */ +/* Equivalent to the Lisp function PRINT, prints the object. */ +/* */ +/************************************************************************/ + +LispPTR print(LispPTR x) +{ + Printdepth=0; + prindatum(x&POINTERMASK); + /* printf("\n"); */ /* print CR */ + return (x); + } + + + +/************************************************************************/ +/* */ +/* p r i n t _ s t r i n g */ +/* */ +/* Print a Lisp string. */ +/* */ +/************************************************************************/ + +print_string(LispPTR x) +{ + struct stringp *string_point; + DLword st_length; + DLbyte *string_base; + + int i; + + + string_point = (struct stringp *)Addr68k_from_LADDR(x); + st_length = string_point->length; + string_base = (DLbyte *)Addr68k_from_LADDR(string_point->base); + + printf("%c" , DOUBLEQUOTE); /* print %" */ + + for (i = 1 ; i <= st_length ; i++) + { + printf("%c" , GETBYTE(string_base)); + string_base++; + } + + printf("%c" , DOUBLEQUOTE); /* print %" */ + } + + + +/************************************************************************/ +/* */ +/* p r i n t _ N E W s t r i n g */ +/* */ +/* Print a Lyric-style string (the Commonlisp-array kind), as */ +/* opposed to the older special-case STRINGP kind from Koto. */ +/* */ +/************************************************************************/ + +print_NEWstring(LispPTR x) +{ + NEWSTRINGP *string_point; + DLword st_length; + DLbyte *string_base; + + int i; + + string_point = (NEWSTRINGP *)Addr68k_from_LADDR(x); + st_length = string_point->fillpointer; + string_base = (DLbyte *)Addr68k_from_LADDR(string_point->base); + string_base += string_point->offset ; + + printf("%c" , DOUBLEQUOTE); /* print %" */ + + for (i = 0 ; i < st_length ; i++) + { + printf("%c" , GETBYTE(string_base)); + string_base++; + } + + printf("%c" , DOUBLEQUOTE); /* print %" */ + } + + + +/************************************************************************/ +/* */ +/* p r i n t _ f i x p */ +/* */ +/* Print a lisp integer (but not a bignum!) */ +/* */ +/************************************************************************/ + +print_fixp(LispPTR x) +{ + int *addr_fixp; + + addr_fixp = (int *)Addr68k_from_LADDR(x); + printf("%d" , *addr_fixp); + } + + + +/************************************************************************/ +/* */ +/* p r i n t _ f l o a t p */ +/* */ +/* Print a lisp floating-point value. */ +/* */ +/************************************************************************/ + +print_floatp(LispPTR x) +{ + float *addr_floatp; + + addr_floatp = (float *)Addr68k_from_LADDR(x); + printf("%f" , *addr_floatp); + } + + diff --git a/src/launch.asm b/src/launch.asm new file mode 100755 index 0000000..53d0606 --- /dev/null +++ b/src/launch.asm @@ -0,0 +1,363 @@ +;; # @(#) launch.asm Version 1.1 (12/29/94). Copyright Venue # +;************************************************************************ +;* * +;* l a u n c h . a s m * +;* * +;* This is the launcher for Medley on DOS. It: * +;* * +;* * Looks for and validates any -m memsize argument on the * +;* command line. Only values in the range 8 - 32 are allowed. * +;* * +;* * Loads the real Medley emulator, emul.exe, from the same * +;* directory that the launcher came from. * +;* * +;* * Sets the Intel DOS Extender's profile to the requested * +;* memory size + 3Mb (to allow for the emulator, internal * +;* data areas, etc.) * +;* * +;* * Set the termination address in the child process's PSP, * +;* so control returns to the launcher when Medley terminates. * +;* * +;* * Jumps to the emulator's start address. * +;* * +;* * Upon return, just terminates cleanly. * +;* * +;* [We could perhaps do some diagnosis here of error returns?] * +;* * +;* * +;* * +;************************************************************************ + +;************************************************************************/ +;* */ +;* (C) Copyright 1993, 1994 Venue. All Rights Reserved. */ +;* Manufactured in the United States of America. */ +;* */ +;* The contents of this file are proprietary information */ +;* belonging to Venue, and are provided to you under license. */ +;* They may not be further distributed or disclosed to third */ +;* parties without the specific permission of Venue. */ +;* */ +;************************************************************************/ + +.model small +.386p +.stack 100h +.data + align 8 + ;******************************************************** + ;* Parameter block for INT 214B, that loads medley.exe * + ;******************************************************** +envseg DW 0 ; environment (0 = copy mine) +cmdip DW ? ; command-line-tail pointer +cmdcs DW ? +fcb1 DD ? ; dummy first FCB to fill in +fcb2 DD ? ; " 2nd FCB, not here in DOS 4.01??? +stk DD ? ; SS:SP for emul.exe, filled in by loader +csip DD ? ; start addr for emul.exe, filled in by loader + + + +retad DD FAR PTR myret ; cs:ip return address, to put in + ; child PSP, so we get control back. + + + ;* Error messages, misc strings, and work areas* + align 8 +memval dd 0 +errstg DB 'ERROR: Couldn''t free excess storage.',13,10,'$' +noload db 'ERROR: Loading emulator failed: $' +loaded db 'LOAD SUCCESSFUL.',13,10,'$' +nominfo db 'ERROR: -m must be followed by a number 8 - 64.',13,10,'$' +badexe db 'ERROR: emul.exe is corrupted.',13,10,'$' +emulpath DB 'emul.exe',0 ; name of the real emulator. +mflag db '-m' ; to search for -m/-M in cmd line +mmflag db '-M' +profile db 'PRO' ; to find the DOS extender profile +cmdline db 128 dup (?) ; hold the cmd line tail for real emulator + + ;* Error-message table for failures loading emul.exe + align 2 +errtbl dw OFFSET ng0msg ; 0 = unknown failure + dw OFFSET ng1msg ; 1 = "invalid function" + dw OFFSET ng2msg ; 2 = file not found + dw OFFSET ng3msg ; 3 = path not found + dw OFFSET ng4msg ; 4 = too many open files + dw OFFSET ng5msg ; 5 = access denied + dw OFFSET ng0msg ; 6 = not possible error + dw OFFSET ng0msg ; 7 = not possible error + dw OFFSET ng8msg ; 8 = insufficient storage + dw OFFSET ng0msg ; 9 = not possible + dw OFFSET ngamsg ; A = bad environment + dw OFFSET ngbmsg ; B = bad format (corrupt .exe?)a + +ng0msg db 'Unknown problem',13,10,'$' +ng1msg db 'Invalid Function',13,10 + db 'Make sure you are running DOS 4.0 or later.',13,10,'$' +ng2msg db 'File not found.',13,10 + db 'CD to proper directory, or set PATH.',13,10,'$' +ng3msg db 'Path not found.',13,10 + db 'CD to proper directory, or set PATH.',13,10,'$' +ng4msg db 'Too many files open.',13,10 + db 'Shut down some TSRs that have file open?',13,10,'$' +ng5msg db 'Access denied.',13,10 + db 'Make sure of your access rights to emul.exe?',13,10,'$' +ng8msg db 'Not enough memory.',13,10 + db 'Shut down some TSR applications?',13,10,'$' +ngamsg db 'Environment corrupt.',13,10 + db 'Check using SET; You may need to re-boot.',13,10,'$' +ngbmsg db 'EXE file corrupted.',13,10,'$' + db 'You may need to restore from backup or re-install.',13,10,'$' +.code + + + +;************************************************************************ +;* * +;* M A C R O S * +;* * +;* prints Given a string ptr in DX, print it to the display. * +;* * +;* kill Exit cleanly, using INT 21/4C * +;* * +;************************************************************************ + +prints macro text + mov dx, OFFSET text + mov ah,9 + int 21h + endm + +kill macro + mov ah,4ch + int 21h + endm + + + +;************************************************************************ +;* * +;* M A I N E N T R Y * +;* * +;* * +;* * +;* * +;* * +;************************************************************************ + +PUBLIC main +main PROC NEAR + + mov ax,ds ; Save memory-block start for freeing + mov es,ax ; excess memory in a bit. + + mov ax,@data ; DS points to start of data segment + mov ds,ax + + mov cmdcs, ax ; Copy the command line for the emulator + mov cmdip, OFFSET cmdline + + mov di, OFFSET cmdline + mov cx,128 + mov bx,es + mov dx,ds + mov es,dx + mov ds,bx + mov si,80h + + rep + movsb + + mov es,bx ; Free the excess memory that DOS gives + mov ds,dx ; us (we need it for the emulator) + + mov ax,4a00h + mov bx,090h ; We only need 900h bytes for this program + int 21h + jnc freeok + + prints errstg ; Couldn't free spare space; punt. + kill + + ;************************************************ + ;* Search the command line for -m or -M * + ;************************************************ +freeok: + mov di,81h ; start of command line tail + mov si, OFFSET mflag + mov cx, 2 + + mov bx,81h + add bl,es:[80h] + +m1lp: call strcmp + je fndm + + add di, 1 + cmp di, bx + jl m1lp + + mov di,81h ; start of command line tail + mov si, OFFSET mmflag + +m2lp: call strcmp + je fndm + + add di, 1 + cmp di, bx + jl m2lp + + mov memval,02400000h ; memory value not set--use 35MB total. + jmp doload + +fndm: add di,2 ; Found "-m". Now look for a number + cmp di,bx ; (Make sure it's not end of line) + jnl nogoodm + +ok1: + mov edx, 0 ; Holds the memory-requirement value + mov ax,0 ; holds characters as we read + + ;************************************************ + ;* Skip over spaces/tabs before any number * + ;************************************************ +skiplp: + mov al, es:[di] + inc di + cmp al, 20h ; spaces + je skiplp + cmp al, 09h ; tabs + je skiplp + cmp di,bx ; make sure we're still in the string + jle cnvst ; Yup, we've got the first char, so enter + ; the conversion loop part-way down. + +nogoodm: + prints nominfo ; no arg to -m, or it's bad; Punt. + kill + + ;******************************************************** + ; Convert the numeric argument to -m; result in edx. * + ;******************************************************** +cnvlp: mov al,es:[di] + add di, 1 +cnvst: cmp al, 30h + jl endcnv + cmp al, 39h + jg endcnv + sub al, 30h + imul dx, 10 + add dx, ax + jmp cnvlp + +endcnv: + cmp edx,0 ; if still 0, no valid chars! + je nogoodm + cmp edx, 8 ; must be in the range [8, 32] + jl nogoodm + cmp edx,64 + jg nogoodm + + add edx, 3 ; add 3mb for data areas, etc, and + sal edx, 20 ; convert to megabytes + mov memval, edx ; save memory requested + + ;************************************************ + ;* Load the real emulator .EXE file, emul.exe * + ;************************************************ +doload: mov dx, OFFSET emulpath + mov ax, seg envseg + mov es, ax + mov bx, OFFSET envseg + mov ax,4b01h ; load-don't-start + int 21h + jnc loadok + + add ax,ax + mov si,ax + prints noload + mov bx,OFFSET errtbl + mov dx,ds:[bx+si] + mov ah,9 + int 21h + kill + +loadok: ; Load succeeded. + mov ah,51h ; get PSP address for child + int 21h + mov es, bx ; get segment for DI addressing + +; mov cx,128 ; copy the command line tail +; mov di,80h ; (which appears to be flaky in DOS 4) +; mov si, offset cmdline +; rep +; movsb + + mov eax,retad + mov dword ptr es:[+0ah], eax ; set up return address. + + cmp memval, 0 ; If no -m value given, just + je dorun ; go start the emulator. + + mov di,0 ; Search for the Intel Extender's PROFILE + mov si, OFFSET profile ; (see extender.h) + mov cx, 3 ; (length is 3 bytes) + +srchlp: call strcmp + je gotprof ; found the profile; fix it. + add di, 1 + cmp di, 2048 + jle srchlp + + prints badexe ; No extender profile, so the emulator + kill ; EXE must be corrupt. Punt. + +gotprof: + mov eax,memval ; Fill in the memory requirement. + mov es:[di+1bch], eax + +;******************************************************** +;* * +;* Set up the stack seg/pointer & start medley. * +;* * +;******************************************************** +dorun: lss sp,stk ; load stack SS & SP regs + mov ax, es ; copy PSP ptr to ax & ds, since some + mov bx, ds ; code expects it in both places. + mov fs,bx ; Also, copy DS to FS, so we still have + mov ds,ax ; a base for the indirect jump . . . + jmp fs:[csip] ; to start-of-medley. + +myret: kill ; we get back here, so quit gracefully. + +main endp + + + +;************************************************************************/ +;* */ +;* s t r c m p */ +;* */ +;* Compare [ds]di and es:[si] for (CX) characters. If the */ +;* strings are equal, the Zero flag is set when this returns. */ +;* */ +;* All registers are preserved. */ +;* */ +;************************************************************************/ + +strcmp proc near + cld + push di + push si + push cx + + repe + cmpsb + + pop cx + pop si + pop di + ret +strcmp endp + +END diff --git a/src/ldeboot.c b/src/ldeboot.c new file mode 100755 index 0000000..1729496 --- /dev/null +++ b/src/ldeboot.c @@ -0,0 +1,288 @@ +/* $Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ Copyright (C) Venue"; + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-98 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#if defined(sun) && !defined(OS5) +#define USESUNSCREEN +#else +#undef USESUNSCREEN +#endif + +#include +#include + +#include +#ifdef USESUNSCREEN +#ifdef OS5 +#include +#else +#include +#endif /* OS5 */ +#endif /* USESUNSCREEN */ + +#include +#include + +#ifdef XWINDOW +#ifndef SYSVONLY +#include +#endif /* SYSVONLY */ + +#include +#include +#include "XVersion.h" +#define LDEX "ldex" +extern char *getenv(); +#endif /* XWINDOW */ + + +#define LDEMONO "ldesingle" +#define LDECOLOR "ldemulti" +#define LDETRUECOLOR "ldetruecolor" + +#define FBTYPE_SUNFAST_COLOR 12 + +char filetorun[30]; + + + +/************************************************************************/ +/* */ +/* m a i n */ +/* */ +/* Kick-start program for the "Lisp Development Environment" (lde) */ +/* */ +/************************************************************************/ + +main(argc, argv) + int argc; char **argv; + { + char Earg[30], Ename[30], **newargv; + int i; +#ifdef USESUNSCREEN + struct fbtype my_screen; +#endif /* USESUNSCREEN */ + + + int FrameBufferFd; + +#ifdef USESUNSCREEN + struct fbinfo FB_info; + struct fbgattr FBattr; +#endif /* USESUNSCREEN */ + + + + /* Kickstart program for the Lisp Development Environment (LDE). + Display Device emulator + CG3, CG6 lde.multi + BW2, CG2, CG4, CG9 lde.single + + FB-TYPE REAL-TYPE + BW2 2 x + CG2 3 3 + CG3 8 6 + CG4 2 8 + CG6 8 12 + CG8 6 7 + CG9(GP1) 4 4 ;gpconfig -f -b + CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 + ;We assume This config for GXP model + */ + +#ifdef XWINDOW + /* If X-Server exists on the host specified in -display option + or environment variable DISPLAY, ldex is started. Othewise + ldesingle or ldemulti. + */ + { + char *Display_Name = (char *)NULL ; + Display *Xdisplay = (Display *)NULL; + int i , option; + char *pos; + + for( i=1; i= 0) + { + if( FBattr.real_type == FBTYPE_SUN3COLOR || /* cg3 */ + FBattr.real_type == FBTYPE_SUNFAST_COLOR ) /* cg6 */ + { + strcpy(filetorun, LDECOLOR); + } + } + else + { /* if( ioctl... */ + perror("lde: This Display Model does not supported\n"); + exit( -1 ); + } + } + else if( my_screen.fb_type == FBTYPE_SUN2BW ) + { /* bw2, cg4 or cg9 */ + strcpy(filetorun, LDEMONO); + } + else if( my_screen.fb_type == FBTYPE_SUN3COLOR ) + { + if(ioctl(FrameBufferFd,FBIOGATTR,&FBattr) >= 0) + { + if( FBattr.real_type == FBTYPE_MEMCOLOR ) /* cg8 */ + { + strcpy(filetorun, LDETRUECOLOR); + } + } + else + { /* if( ioctl... */ + perror("lde: This Display Model does not supported\n"); + exit( -1 ); + } + + } + else if( my_screen.fb_type == FBTYPE_SUN2COLOR ) + { /* cg2 */ + strcpy(filetorun, LDEMONO); + } + else + { + perror("lde: This Display Model does not supported\n"); + exit (-1); + }; /* endif( my_screen... */ + + close(FrameBufferFd); + +#endif /* USESUNSCREEN */ + + + + +#ifdef FORKCOMM +/* JRB - call fork_Unix here, while we're REALLY small, unless -NF is + specified, of course... */ + for(i=0; i + +#ifdef USE_DLPI +#include +#include +#include + +#if defined(SVR4) && !defined(SUNOS5) +char *devices[] = { + "emd0", "emd1", "emd2", "emd3", "emd4", + 0 +}; +#endif + +#ifdef SUNOS5 +#include + +char *devices[] = { + "le0", "le1", "le2", "le3", "le4", + "ie0", "ie1", "ie2", "ie3", "ie4", + "qe0", "qe1", "qe2", "qe3", "qe4", "qe5", "qe6", "qe7", + "fddi0", "fddi1", "fddi2", "fddi3", "fddi4", + "bf0", "bf1", + 0 +}; +#endif +#endif /* USE_DLPI */ + +#ifndef NOETHER +#include +#include +#include +#include +#ifdef OS4 +#include +#endif /* OS4 */ + +#include +#include +#include +#include +#include +#ifndef USE_DLPI +#include +#ifdef OS4 +#include +#include +#include +#endif /* OS4 */ +#endif /* USE_DLPI */ + +#include +#include +#include + +#endif /* NOETHER */ + + + +int ether_fd = -1; /* file descriptor for ether socket */ +int ether_intf_type = 0; /* IF type? from DLPI */ +unsigned char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address */ +char filetorun[30] = "lde"; + + + +main(argc, argv, envp) int argc; char **argv, **envp; +{ + char Earg[30], Ename[30], **newargv; + int i; + int flags; +#ifdef USE_DLPI + static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; + struct strioctl si; +#endif /* USE_DLPI */ + + +#ifndef NOETHER + + /* Only do the ether kick=-start if we've got to. */ + +/* Kickstart program for the Lisp Development Environment (LDE). + Run this as setuid root to open the LDE ether socket. + Passes all arguments through to LDE plus -E + to communicate open ether socket. + + looks like this: + ::::::: + + where is the number of the open + socket (decimal), and - are hex of the socket's + 48-bit Ethernet address, and is the name of the + Ethernet device as found by SIOCGIFCONF. +*/ + +if (!geteuid()){ +#ifdef USE_DLPI + /* Use DLPI to connect to the ethernet. This code is stolen + from NFSWATCH4.3 + */ + + if ( ether_fd = setup_dlpi_dev(NULL)) { /* Open an ether interface */ + ether_intf_type = dlpi_devtype(ether_fd); +printf("opened ldeether fd %d.\n", ether_fd); + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pfmod") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } + + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(pf); + si.ic_dp = (char *)&pf; + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ioctl: I_STR PFIOCSETF"); + return(-1); + } + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | O_NDELAY ); + +#else + /* N O T D L P I C O D E */ + + +#ifndef OS4 + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { +#else /* OS4 */ + + if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { +#endif /* OS4 */ + + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + +#ifdef OS4 + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } +#endif /* OS4 */ + + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; +#ifndef OS4 + if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ + + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + (void) close(s); + } + if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + strcpy(Ename, if_data.ifc_req[0].ifr_name); + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + + +#endif /* USE_DLPI */ +#ifdef DEBUG + printf("init_ether: **** Ethernet starts ****\n"); +#endif + } else { +I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + /* exit(); */ + } + seteuid(getuid()); + } + +#endif /* NOETHER */ + +/* OK, right here do other stuff like scan args */ +/* finally crank up LDE; first copy the original args */ + +newargv = (char **) malloc((argc + 1 + (ether_fd > 0)*2) * sizeof (char **)); +newargv[0] = filetorun; /* or whatever... */ +for(i=1; i 0) { + newargv[i++] = "-E"; +#ifdef USE_DLPI + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x", ether_fd, + ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5]); +#else + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, + ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); +#endif /* USE_DLPI */ + newargv[i++] = Earg; + printf("ether = %d:%x:%x:%x:%x:%x:%x:%s", ether_fd, + ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); +} +newargv[i] = 0; + +/* then execve the LDE executable */ +execvp(filetorun, newargv); +perror(filetorun); +exit(1); +} + +#endif /* NOETHER */ + diff --git a/src/ldsout.c b/src/ldsout.c new file mode 100755 index 0000000..efe15a8 --- /dev/null +++ b/src/ldsout.c @@ -0,0 +1,408 @@ +/* $Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1998 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + + +#include "version.h" + + + + +#include +#include +#ifndef DOS +#include +#endif /* DOS */ +#include +#include + +#ifdef SYSVONLY +#include +#endif /* SYSVONLY */ + +#ifdef DOS +#include +#endif /* DOS */ + + +#include "adr68k.h" +#include "lispemul.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "lspglob.h" +#include "ifpage.h" +#include "dbprint.h" + +#ifdef GCC386 +#include "inlnPS2.h" +#endif /* GCC386 */ + +#define IFPAGE_ADDRESS 512 +#define DEFAULT_MAX_SYSOUTSIZE 64 /* in Mbyte */ +#define DEFAULT_PRIME_SYSOUTSIZE 8 +#define MAX_EXPLICIT_SYSOUTSIZE 256 /* Max possible sysout size is 64Mb */ +#define MBYTE 0x100000 /* 1 Mbyte */ +extern int errno; + +/* Flag for indication whether process space + is going to expand or not */ +int Storage_expanded; /* T or NIL */ + + + /* RISCOS doesn't have valloc, and malloc works OK there. */ +#ifdef SYSVONLY +#define valloc malloc +#endif /* SYSVONLY */ + + +#ifdef OSF1 +#define valloc malloc +#endif /* OSF1 */ + + +char *valloc(); + + +/************************************************************************/ +/* */ +/* s y s o u t _ l o a d e r */ +/* */ +/* Load the sysout file into memory. */ +/* */ +/************************************************************************/ +#if defined(DOS) || defined (XWINDOW) +#include "devif.h" +static char *metersyms = "-\\|/"; +extern DspInterface currentdsp; +#endif /* DOS || XWINDOW */ + +sysout_loader(sysout_file_name, sys_size) + char *sysout_file_name; + int sys_size; /* sysout size in megabytes */ +{ + int sysout; /* SysoutFile descriptor */ + + IFPAGE ifpage; /* IFPAGE */ + + char *fptovp_scratch; /* scratch area for FPTOVP */ +#ifdef BIGVM + unsigned int fptovp[0x40000]; /* FPTOVP */ +#else + DLword fptovp[0x10000]; /* FPTOVP */ +#endif /* BIGVM */ + long fptovp_offset; /* FPTOVP start offset */ + + char *lispworld_scratch; /* scratch area for lispworld */ + long lispworld_offset; /* lispworld offset */ + + unsigned sysout_size;/* sysout size in page */ + struct stat stat_buf; /* file stat buf */ + int i, vp; + + int machinetype; + char errmsg [ 255 ]; + + int j = 0; + + machinetype = 0; + + /* Checks for specifying the process size (phase I) */ + /* If sys_size == 0 figure out the proper size later */ + if((sys_size != 0) && (sys_size < DEFAULT_PRIME_SYSOUTSIZE)) + { + perror("You have to specify more than 8MB for process size"); + exit(-1); + } + else if ( sys_size > MAX_EXPLICIT_SYSOUTSIZE) + { + perror("256Mb is the maximum legal sysout size."); + exit(-1); + } + + /* + * first read the IFPAGE(InterfacePage) + */ + + /* open SysoutFile */ + sysout = open(sysout_file_name, O_RDONLY, NULL); + if (sysout == -1) + { + sprintf( errmsg, + "sysout_loader: can't open sysout file: %s", + sysout_file_name); + perror( errmsg ); + exit(-1); + } + + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) + { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + + /* reads IFPAGE into scratch_page */ + if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) + { + perror("sysout_loader: can't read IFPAGE"); + exit(-1); + } + +#ifdef BYTESWAP + word_swap_page((unsigned int *)&ifpage, + (3+sizeof(IFPAGE))/4); +#endif + + /* Check the sysout and emulator for compatibility: + The sysout's ifpage.lversion must be >= LVERSION, and + the sysout's ifpage.minbversion must be <= MINBVERSION + */ +#ifndef NOVERSION + if (ifpage.lversion < LVERSION) + { + fprintf(stderr, "Lisp VM is too old for this emulator.\n"); + fprintf(stderr, "(version is %d, must be at least %d.)\n", + ifpage.lversion, LVERSION); + exit(-1); + } + + if (ifpage.minbversion > MINBVERSION) + { + fprintf(stderr, "Emulator is too old for this Lisp VM.\n"); + fprintf(stderr, "(version is %d, must be at least %d.)\n", + MINBVERSION, ifpage.minbversion); + exit(-1); + } +#endif /* NOVERSION */ +#ifdef NEW_STORAGE + if(sys_size == 0) /* use default or the previous one */ + { + if(ifpage.process_size == 0) /* Pure LISP.SYSOUT */ + sys_size = DEFAULT_MAX_SYSOUTSIZE; /* default for pure SYSOUT */ + else + sys_size = ifpage.process_size; /* use previous one */ + } + + /* Checks for specifying the process size (phase II) */ + if((ifpage.storagefullstate == SFS_ARRAYSWITCHED) || + (ifpage.storagefullstate == SFS_FULLYSWITCHED)) + { + /* Storage may be allocated from Secondary space */ + /* Therefore you can not change \\DefaultSecondMDSPage */ + if(ifpage.process_size != sys_size) + { + char tmp[200]; + sprintf(tmp, "\nsysout loader: Error, secondary space in use. You can't specify size.\nProcess size = %d\nSys size = %d\n", ifpage.process_size, sys_size); +#ifdef DOS + /* Note that we have an initialized display by now. */ + /* Hence we have to observe the display protocol. */ + VESA_errorexit( tmp ); +#else + fprintf(stderr,"sysout_loader: You can't specify the process size.\n"); + fprintf(stderr,"Because, secondary space is already used.\n"); + fprintf(stderr,"(size is %d, you specified %d.)\n", ifpage.process_size, sys_size); + exit(-1); +#endif /* DOS */ + } + /*Can use this sys_size as the process size */ + /* The sys_size should be same as the previous one */ + Storage_expanded=NIL; + } + else + { /* assumes that we can expand the process space */ + Storage_expanded=T; + /* You can use secondary space , though it was STORAGEFULL + So, STORAGEFULL may be set to NIL later */ + } +#else + if(sys_size == 0) sys_size = DEFAULT_MAX_SYSOUTSIZE; +#endif /* NEW_STORAGE */ + + + + /* allocate Virtual Memory Space */ + + lispworld_scratch = valloc(sys_size * MBYTE); + + if (lispworld_scratch == NULL) + { + fprintf(stderr,"sysout_loader: can't allocate Lisp %dMBytes VM \n", + sys_size); + exit(-1); + } + + /* now you can access lispworld */ + Lisp_world = (DLword *) lispworld_scratch; + + DBPRINT(("VM allocated = 0x%x at 0x%x\n", sys_size * MBYTE, Lisp_world)); + DBPRINT(("Native Load Address = 0x%x\n", native_load_address)); + + + /* + * get FPTOVP location and SysoutFile size + */ + + /* get FPTOVP location from IFPAGE */ + fptovp_offset = ifpage.fptovpstart; + + DBPRINT(("FPTOVP Location %d \n", fptovp_offset)); + + /* get sysout file size in halfpage(256) */ + if (fstat(sysout, &stat_buf) == -1) + { + perror("sysout_loader: can't get sysout file size"); + exit(-1); + } + sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2; + + DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2)); + DBPRINT(("vmem size = 0x%x\n", ifpage.nactivepages)); + + /* do some simple checks to see if this is really a sysout */ + if(ifpage.key != IFPAGE_KEYVAL) + { + printf("sysout_loader: %s isn't a sysout:\nkey is %x, should be %x\n", + sysout_file_name, ifpage.key, IFPAGE_KEYVAL); + exit(1); + } + + machinetype = ifpage.machinetype; + + if(( stat_buf.st_size & 0x1ff) != 0) + printf("CAUTION::sysout & 0x1ff = 0x%x\n", + stat_buf.st_size & BYTESPER_PAGE); + + if(ifpage.nactivepages != ( sysout_size /2) ) + { + printf("sysout_loader:IFPAGE says sysout size is %d\n", + ifpage.nactivepages); + printf("But, sysout size from UNIX is %d\n",sysout_size /2); + exit(-1); + } + + /* + * Now get FPTOVP + */ + + /* seek to FPTOVP */ +#ifdef BIGVM + fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 4; +#else + fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 2; +#endif + if (lseek(sysout, fptovp_offset, 0) == -1) + { + perror("sysout_loader: can't seek to FPTOVP"); + exit(-1); + } + + /* read FPTOVP */ + +#ifdef BIGVM + /* fptovp is now in cells, not words */ + if (read(sysout, fptovp, sysout_size*2) == -1) + { + perror("sysout_loader: can't read FPTOVP"); + exit(-1); + } + +#ifdef BYTESWAP + word_swap_page(fptovp, (sysout_size/2)+1); /* So space to swap is twice as big, too. */ +#endif /* BYTESWAP */ + +#else + + if (read(sysout, fptovp, sysout_size) == -1) + { + perror("sysout_loader: can't read FPTOVP"); + exit(-1); + } + +#ifdef BYTESWAP + word_swap_page(fptovp, (sysout_size/4)+1); +#endif /* BYTESWAP */ + +#endif /* BIGVM */ + + /* + * Initialize the display (note now passing 68k address!!!) + */ + init_display2(Addr68k_from_LADDR(DISPLAY_OFFSET), 65536 * 16 * 2); + + /* read sysout file to lispworld */ + + for (i = 0; i < (sysout_size / 2); i++) + { +#ifdef DOS + /* Dial that floats from left to right on the top line of the */ + /* displaty. Dial shows % of sysout loaded by digits and */ + /* position. */ + int columns; + switch (currentdsp->graphicsmode){ + case 0x104: columns = 120; /* 131 - 10 */ + break; + case 0x102: columns = 69; /* 79 - 10 */ + break; + default: columns = 69; /* 79 - 10 */ + break; + } + _settextposition((short)0, (short)0); + if ((i & 0xf) == 0){ + for (j = 0; j < (columns * i) / (sysout_size >> 1); j++) putchar(' '); + printf("-=(%2d%%)=-\n", (100 * i) / (sysout_size >> 1)); + } +#endif /* DOS */ + if (GETPAGEOK(fptovp,i) != 0177777) + { + if (lseek(sysout, i * BYTESPER_PAGE, 0) == -1) + { + perror("sysout_loader: can't seek sysout file"); + exit(-1); + }; + lispworld_offset = GETFPTOVP(fptovp,i) * BYTESPER_PAGE; + if (read(sysout, lispworld_scratch + + lispworld_offset , BYTESPER_PAGE) == -1) + { + printf("sysout_loader: can't read sysout file at %d\n", i); + printf(" offset was 0x%x (0x%x pages).\n", + lispworld_offset, GETFPTOVP(fptovp,i)); + perror("read() error was"); + { int j; + for (j = 0; j < 10; j++) printf(" %d: 0x%x ", j, GETFPTOVP(fptovp,j)); + } + exit(-1); + }; +#ifdef BYTESWAP + word_swap_page(lispworld_scratch+lispworld_offset, 128); +#endif + + }; + } + + DBPRINT(("sysout file is read completely.\n")); + + +#if (defined(DISPLAYBUFFER) || defined(XWINDOW) || defined(DOS)) + TPRINT(("Flushing display buffer...\n")) + flush_display_buffer(); + TPRINT(("After Flushing display buffer\n")) +#endif /* DISPLAYBUFFER || XWINDOW || DOS */ + + close(sysout); + return(sys_size); + } diff --git a/src/lineblt8.c b/src/lineblt8.c new file mode 100755 index 0000000..546474a --- /dev/null +++ b/src/lineblt8.c @@ -0,0 +1,232 @@ +/* $Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyright (C) Venue"; + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lispemul.h" + +#ifdef ISC +#include +#endif /* ISC */ + + +#define COLOR8ARRAYSIZE 16 +#define BITSPERNIBBLE 4 +#define BITSPERDLWORD 16 + +DLword BitMaskArray[]={32768,16384,8192,4096,2048,1024, + 512,256,128,64,32,16,8,4,2,1}; +unsigned int ConvBM_tbl[] = { + 0 , 0xff , 0xff00 , 0xffff , + 0xff0000 , 0xff00ff , 0xffff00 , 0xffffff , + 0xff000000 , 0xff0000ff , 0xff00ff00 , 0xff00ffff , + 0xffff0000 , 0xffff00ff , 0xffffff00 , 0xffffffff }; +unsigned int BMask_tbl[] = { 0xf , 7 , 3 , 1 }; + +#define noop 1 + +/*************************************************************** + Macro:WriteLongW +**************************************************************/ +#define WriteLongW(srcpattern,destptr,op1,op2) {\ + register cnt;\ + register u_char *des,*src;\ + for(cnt=0,des=(u_char*)destptr,src=(u_char*)(&(srcpattern));\ + cnt <4 ; cnt++,des++,src++)\ + (*des) op1 (*src);} + + +/*************************************************************** + Macro:LineBLT8 + srcWptr : DLword ptr + offset : Bits offset + width : Bits width to copy + dstLptr : Destination's LispPTR ptr + op1,op2 : operations in C(=,|=,^=,&=,^) + ERASE only uses op2 +**************************************************************/ + /* srcw points DLword which contains the nibble processed now */ + /* offset indicates MSB in the nibble */ + /* width:before copy,make sure the nibble is inside source bitmap */ + /* width:after copy,decremented by BITSPERNIBBLE. + therefore,width indictes the rest bits in source bitmap */ + +#define LineBLT8(srcWptr,offset,width,dstLptr,op1,op2){ \ + register DLword *srcw; \ + register u_int temp1; \ + for(srcw= (srcWptr) + (offset)/BITSPERDLWORD ; \ + ((width) -BITSPERNIBBLE)>= 0; \ + (width) -=BITSPERNIBBLE, \ + (dstLptr) = (u_char *) ((u_int *)(dstLptr) + 1), \ + (offset)+=BITSPERNIBBLE) \ + {\ + switch((offset) % 16) {\ + case 0 : WriteLongW(color_array[(*srcw )>> 12],dstLptr,op1,op2);\ + break;\ + case 1 : WriteLongW(color_array[(*srcw & 0x7800) >> 11],dstLptr,op1,op2); \ + break;\ + case 2 : WriteLongW(color_array[(*srcw & 0x3c00) >> 10],dstLptr,op1,op2); \ + break;\ + case 3 : WriteLongW(color_array[(*srcw & 0x1e00) >> 9],dstLptr,op1,op2);\ + break;\ + case 4 : WriteLongW(color_array[(*srcw & 0x0f00) >> 8],dstLptr,op1,op2);\ + break;\ + case 5 : WriteLongW(color_array[(*srcw & 0x0780) >> 7],dstLptr,op1,op2);\ + break;\ + case 6 : WriteLongW(color_array[(*srcw & 0x03c0) >> 6],dstLptr,op1,op2);\ + break;\ + case 7 : WriteLongW(color_array[(*srcw & 0x01e0) >> 5],dstLptr,op1,op2);\ + break;\ + case 8 : WriteLongW(color_array[(*srcw & 0x00f0) >> 4],dstLptr,op1,op2);\ + break;\ + case 9 : WriteLongW(color_array[(*srcw & 0x0078) >> 3],dstLptr,op1,op2);\ + break;\ + case 10 : WriteLongW(color_array[(*srcw & 0x003c) >> 2],dstLptr,op1,op2);\ + break;\ + case 11 : WriteLongW(color_array[(*srcw & 0x001e) >> 1],dstLptr,op1,op2);\ + break;\ + case 12 : WriteLongW(color_array[*srcw & 0xf],dstLptr,op1,op2);\ + srcw++; /* move srcw pointer */\ + break;\ + case 13 : temp1= (*srcw & 7) << 1 ;\ + temp1 |= ((*(++srcw)) & 0x8000)>> 15 ;/** Compiler's BUG?*/\ + WriteLongW(color_array[temp1],dstLptr,op1,op2);\ + break;\ + case 14 : temp1= ((*srcw & 3) << 2) ;\ + temp1 |= ((*(++srcw) & 0xc000)>> 14) ;\ + WriteLongW(color_array[temp1],dstLptr,op1,op2);\ + break;\ + case 15 : temp1= ((*srcw & 1) << 3);\ + temp1 |= ((*(++srcw) & 0xe000)>> 13) ;\ + WriteLongW(color_array[temp1],dstLptr,op1,op2);\ + break;\ + } /* switch end */\ + } /* for end */\ +/* process for the rest bits (0~3)*/\ +switch(width)\ +{ register u_char *destc;\ + register int mod;\ + case 0: /* already finished */\ + break;\ + case 1: \ + case 2:\ + case 3: destc=(u_char *)dstLptr;\ + while(width--){\ + if(BitMaskArray[mod =(offset %16)] & *srcw) \ + (*destc++) op1 (color1);\ + else (*destc++) op1 (color0);\ + if(mod == 15) srcw++;\ + offset++;\ + } /* WHILE END */\ + break;\ + default: ;/* error */\ +}/* switch end */\ +} /* MACRO END */ + + +/************************************************************************/ +/* */ +/* l i n e b l t 8 */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/* destination is always ColorFontCache's line */ + +/* I don't care sourcetype & operation NOW */ + +lineBlt8(DLword *srcbase, register int offset, register u_char *destl, register int width, u_char color0, u_char color1, LispPTR sourcetype, LispPTR operation) + + + /* register u_int *destl;*/ + /* for SPARC */ + + /* Background color */ + /* foreground color */ + + /*operation type PAINT,REPLACE or INVERT */ + + { + static unsigned char beforecolor0=0; + static unsigned char beforecolor1=0; + static color_array[COLOR8ARRAYSIZE]; + + extern DLword REPLACE_atom; + extern DLword INPUT_atom; + extern DLword INVERT_atom; + extern DLword PAINT_atom; + extern DLword ERASE_atom; + + + + DLword *baseword; /* Assume dest word always quad aligned */ + + + if(sourcetype == INVERT_atom) + { + register tempcol; + tempcol = color0; + color0 = color1; + color1 = tempcol; + } + if((beforecolor0 != color0) || (beforecolor1 != color1)) + { + /* making color-mapped array */ + register i; + register u_int longcol0,longcol1; + + beforecolor0 = color0; + beforecolor1 = color1; + longcol0 = (color0 << 24) | (color0 << 16) | (color0 << 8) | color0; + longcol1 = (color1 << 24) | (color1 << 16) | (color1 << 8) | color1; + + for(i=0;i < COLOR8ARRAYSIZE;i++) + { + color_array[i] = ConvBM_tbl[i] & longcol1; + color_array[i] |= (~(ConvBM_tbl[i])) & longcol0; + } + } /* otherwise previous colors are same as current one. use cached one */ + + if(operation == REPLACE_atom) + { + LineBLT8(srcbase,offset,width,destl,=,noop); + } + else if (operation == INVERT_atom) + { + LineBLT8(srcbase,offset,width,destl,^=,noop); + } + else if (operation == PAINT_atom) + { + LineBLT8(srcbase,offset,width,destl,|=,noop); + } + else if (operation == ERASE_atom) + { /*erase */ + LineBLT8(srcbase,offset,width,destl,&=~,noop); + } + else error("lineBlt8:Illegal operation specified"); + + } +/* lineBlt8 end */ + diff --git a/src/lisp2c.c b/src/lisp2c.c new file mode 100755 index 0000000..5061e3d --- /dev/null +++ b/src/lisp2c.c @@ -0,0 +1,139 @@ +/* $Id: lisp2c.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lisp2c.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyright (C) Venue"; +/* File containing the conversion functions between lisp and C */ +/* -jarl */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "lispemul.h" +#include "lspglob.h" +#include "emlglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "medleyfp.h" +#include "arith.h" + + + + +int LispStringP(LispPTR object) +{ + int type; + + type = ((OneDArray *)Addr68k_from_LADDR(object))->typenumber; + return((type == THIN_CHAR_TYPENUMBER) || (type == FAT_CHAR_TYPENUMBER)); +} + + + +int LispStringLength (LispPTR lispstring) +{ + OneDArray *arrayp; + + arrayp = (OneDArray *)(Addr68k_from_LADDR(lispstring)); + return(arrayp->fillpointer); +} + + + +LispStringToCStr (LispPTR lispstring, char *cstring) +{ + OneDArray *arrayp; + char *base; + short *sbase; + int i, Len; + + arrayp = (OneDArray *)(Addr68k_from_LADDR((UNSIGNED)lispstring)); + Len = arrayp->fillpointer; + + switch(arrayp->typenumber) + { + case THIN_CHAR_TYPENUMBER: + base = ((char *) + (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) + + ((int)(arrayp->offset)); + for(i=0;ibase))) + + ((int)(arrayp->offset)); + base = (char *)sbase; + for(i=0;i 0xFFFF) { /* its a fixp! */ + register LispPTR *wordp; + wordp = (LispPTR *) createcell68k(TYPE_FIXP); + *((int *)wordp) = cint; + return(LADDR_from_68k(wordp)); + } else if (cint >= 0) { /* its a positive smallp! */ + return(S_POSITIVE | cint); + } else { /* its a negative smallp! */ + return(S_NEGATIVE | (0xFFFF & cint)); + } +} + +DLword CIntToSmallp(int cint) +{ + if (abs(cint) > 0xFFFF) { /* its a fixp! */ + error("Arg not a Smallp.\n"); + } else if (cint >= 0) { /* its a positive smallp! */ + return(S_POSITIVE | cint); + } else { /* its a negative smallp! */ + return(S_NEGATIVE | (0xFFFF & cint)); + } +} diff --git a/src/llcolor.c b/src/llcolor.c new file mode 100755 index 0000000..d152608 --- /dev/null +++ b/src/llcolor.c @@ -0,0 +1,359 @@ +/* $Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include + +#ifndef NOPIXRECT +#include +#include +#include +#include +#include +#include +#include +#endif /* NOPIXRECT */ + +#include +#include +#include + +#include + +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "emlglob.h" +#include "display.h" +#include "devconf.h" + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" +#include "dbprint.h" + +int MonoOrColor=MONO_SCREEN; +DLword *ColorDisplayRegion68k; +int Dispcolorsize; +int Inited_Color = NIL; +extern struct pixrect *ColorDisplayPixrect; +extern int displaywidth + , displayheight + , FrameBufferFd; + +/*******************************************************************/ +/* Func name : cgfour_init_color_display(args) + Arg(s) : COLOR BITMAP ADDRESS(LISPPTR) + Desc : Assign to SUBR 0210 + mmap LispPTR to Color Display FB. + By Takeshi +*/ +/*******************************************************************/ +#ifdef COLOR +cgfour_init_color_display(color_bitmapbase) /* SUBR 0210 */ + LispPTR color_bitmapbase; /* COLOR BITMAP ADDRESS */ + { + struct pixrect *ColorFb; + struct pixrect *color_source; + int mmapstat; + + if(MonoOrColor == COLOR_SCREEN) { + printf("You can not initialize the color screen from inside color screen. \n"); + } + + ColorDisplayRegion68k = Addr68k_from_LADDR(color_bitmapbase ); + + Dispcolorsize = ((displaywidth * displayheight + (getpagesize()-1) ) + & -getpagesize()); /* 8 bit depth */ +#ifndef DISPLAYBUFFER + ColorFb = pr_open("/dev/fb"); +#else + ColorFb = ColorDisplayPixrect; +#endif /* DISPLAYBUFFER */ + + +#ifndef DISPLAYBUFFER + color_source = mem_point(displaywidth,displayheight,8, + ColorDisplayRegion68k); + + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); + pr_rop(ColorFb,0,0,displaywidth,displayheight,PIX_SRC, + color_source,0,0); + + mmapstat = (int)mmap(ColorDisplayRegion68k , + Dispcolorsize, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x40000 ); + if(mmapstat == -1){ + perror("cgfour_init_color_display: ERROR at mmap system call\n"); + error ("cgfour_init_color_display: ERROR at mmap system call\n You may be able to continue by typing 'q'"); + } +#endif /* DISPLAYBUFFER */ + + + printf("COLOR-INIT OK BMBASE=0x%x\nNATIVE:= 0x%x)\n", + color_bitmapbase,ColorDisplayRegion68k); + + Inited_Color = T; /* Color display is active. */ + + return(color_bitmapbase); + } /* end cgfour_init_color_display */ + +#else /* COLOR */ + +cgfour_init_color_display(color_bitmapbase) /* SUBR 0210 */ + LispPTR color_bitmapbase; /* COLOR BITMAP ADDRESS */ +{ + printf( "Color is not supported.\n" ); +} +#endif /* COLOR */ + +/*******************************************************************/ +/* Func name : cgfour_change_screen_mode(which_screen) + Arg(s) : MONO_SCREEN OR COLOR_SCREEN + Desc : Assign to SUBR 0211 + Change screen Mono to Color,vice versa. + By Takeshi +*/ +/*******************************************************************/ +#ifdef COLOR +cgfour_change_screen_mode(which_screen) + LispPTR which_screen; + { /* subr 0211 */ + struct pixrect *ColorFb; + extern ScreenLocked; + extern DLword *EmCursorX68K,*EmCursorY68K; + + int mmapstat; + +#ifndef DISPLAYBUFFER + ColorFb = pr_open("/dev/fb"); +#else + ColorFb = ColorDisplayPixrect; +#endif /* DISPLAYBUFFER */ + + ScreenLocked=T; + taking_mouse_down(); + + switch (which_screen & 0xf) { + case MONO_SCREEN : { /* resume mono screen */ +#ifdef DISPLAYBUFFER + mmapstat = (int)munmap( ColorDisplayRegion68k, Dispcolorsize ); + if( mmapstat == -1){ + perror("cg_four_change_screen: ERROR at munmap system call\n"); + exit( 0 ); + } /* end if(mmapstat) */ + save_color_screen(); +#endif /* DISPLAYBUFFER */ + + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb,0,0, + ColorFb->pr_width, + ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); +#ifdef DISPLAYBUFFER + flush_display_buffer(); +#endif /* DISPLAYBUFFER */ + + MonoOrColor = MONO_SCREEN; + break; + } + case COLOR_SCREEN : { +#ifndef DISPLAYBUFFER + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb,0,0, + ColorFb->pr_width, + ColorFb->pr_height, PIX_CLR, 0, 0, 0); +#endif /* DISPLAYBUFFER */ + + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); +#ifdef DISPLAYBUFFER + restore_color_screen(); + mmapstat = (int)mmap(ColorDisplayRegion68k , + Dispcolorsize, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x40000 ); + if(mmapstat == -1){ + perror("cg_four_change_screen: ERROR at mmap system call\n"); + exit(0); + } +#endif /* DISPLAYBUFFER */ + + MonoOrColor = COLOR_SCREEN; + break; + } + default : { + error("cgfour_change_screen_mode:Unknown mode:"); + } + }; + +#ifndef DISPLAYBUFFER + pr_close(ColorFb); +#endif /* DISPLAYBUFFER */ + + + taking_mouse_up(*EmCursorX68K,*EmCursorY68K); + ScreenLocked=NIL; + return(which_screen); + } +#else /* COLOR */ + +cgfour_change_screen_mode(which_screen) + LispPTR which_screen; +{ + printf( "Color is not supported.\n" ); +} +#endif /* COLOR */ + + +/*******************************************************************/ +/* Func name : cgfour_set_colormap(args) + Arg(s) : Passed by args + index: colormap index(0~255) + red,green,blue:(0~255) + Desc : Assign to SUBR 0212 + Set Colormap entry + By Takeshi +*/ +/*******************************************************************/ +unsigned char RED_colormap; +unsigned char GRN_colormap; +unsigned char BLU_colormap; + +#ifdef COLOR +cgfour_set_colormap(args) + LispPTR args[]; + { + int index; + struct pixrect *ColorFb; + + index=args[0] & 0xff; + + RED_colormap = (unsigned char) (args[1] & 0xff); + GRN_colormap = (unsigned char) (args[2] & 0xff); + BLU_colormap = (unsigned char) (args[3] & 0xff); + + ColorFb = pr_open("/dev/fb"); + + if (pr_putcolormap(ColorFb,index,1, + &RED_colormap, + &GRN_colormap, + &BLU_colormap)==-1) + perror("putcolormap:"); + pr_close(ColorFb); + return(T); + } +#else /* COLOR */ + +cgfour_set_colormap(args) + LispPTR args[]; +{ + printf( "Color is not supported.\n" ); +} +#endif /* COLOR */ + + +#ifdef COLOR +#ifdef DISPLAYBUFFER +static struct pixrect *saved_screen; +static int Screen_Saved = T; + +save_color_screen() +{ + if( !Screen_Saved ) { + saved_screen = mem_point( displaywidth + , displayheight + , 8 + , ColorDisplayRegion68k ); + pr_rop( saved_screen + , 0, 0, displaywidth, displayheight + , PIX_SRC, ColorDisplayPixrect, 0, 0 ); + Screen_Saved = T; + } /* end if(!Screen_Saved) */ +} /* end save_color_screen() */ + +restore_color_screen() +{ + if( Screen_Saved ) { + saved_screen = mem_point( displaywidth + , displayheight + , 8 + , ColorDisplayRegion68k ); + pr_rop( ColorDisplayPixrect + , 0, 0, displaywidth, displayheight + , PIX_SRC, saved_screen, 0, 0 ); + Screen_Saved = NIL; + } /* end if(Screen_Saved) */ +} /* end restore_color_screen() */ +#endif /* DISPLAYBUFFER */ + + +static unsigned char red_colormap[256] + , green_colormap[256] + , blue_colormap[256]; +static int Saved_Colormap = NIL; +save_colormap() +{ + struct pixrect *Color_Fb; + + if( !Saved_Colormap ) { + Color_Fb = pr_open( "/dev/fb" ); + if( (pr_getcolormap( Color_Fb, 0 , 256 + , red_colormap + , green_colormap + , blue_colormap )) == -1 ) + perror("save_color_map:"); + else + Saved_Colormap = T; + + pr_close( Color_Fb ); + } /* end if( !Saved_Colormap ) */ +} /* end save_colormap() */ + +restore_colormap() +{ + struct pixrect *Color_Fb; + + if( Saved_Colormap ) { + Color_Fb = pr_open( "/dev/fb" ); + if( (pr_putcolormap( Color_Fb, 0 , 256 + , red_colormap + , green_colormap + , blue_colormap )) == -1 ) + perror("restore_color_map:"); + pr_close( Color_Fb ); + Saved_Colormap = NIL; + } /* end if( Saved_Colormap ) */ +} /* end restore_colormap() */ +#endif /* COLOR */ + + diff --git a/src/llstk.c b/src/llstk.c new file mode 100755 index 0000000..ef40df3 --- /dev/null +++ b/src/llstk.c @@ -0,0 +1,1261 @@ +/* $Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/******************************************************************/ +/* + File Name : llstk.c + Desc. : Low Level stack operations + Including : + + Edited by : Takeshi Shimizu(March 14, 1988) + +*/ +/******************************************************************/ +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "address.h" +#include "lsptypes.h" +#include "initatms.h" +#include "lspglob.h" +#include "emlglob.h" +#include "cell.h" +#include "stack.h" +#include "return.h" + +extern int extended_frame; + + + + +/******************************************************************/ +/* + Func Name : moveframe(oldfx68k) + + Edited by : Take(March 14, 1988) +*/ +/******************************************************************/ +LispPTR moveframe(register FX *oldfx68k) +{ + register int size; + register DLword *next68k; + register DLword *new68k; + DLword *freestackblock(DLword n, StackWord *start68k, int align); + DLword *extendstack(void); + int nametbl_on_stk =NIL; + int at_eos = NIL; + + PreMoveFrameCheck(oldfx68k); +#ifdef FLIPCURSOR + flip_cursorbar(10); +#endif + + size = FX_size(oldfx68k) + DLWORDSPER_CELL; + S_CHECK(size > 0, "size of stack block < 0"); + next68k=Addr68k_from_StkOffset(oldfx68k->nextblock); + +tryfsb: + if(FSBP(next68k)) + { + /* merge free blocks */ + new68k = next68k + FSB_size(next68k); + if(FSBP(new68k)) + { + for(;FSBP(new68k); new68k = new68k + FSB_size(new68k)) + FSB_size(next68k) += FSB_size(new68k); + new68k=(DLword *)oldfx68k; + goto out; + } + else if(StkOffset_from_68K(new68k) == InterfacePage->endofstack) + { + if((StkOffset_from_68K(new68k) > LOLOC(*GuardStackAddr_word)) && + ((*STACKOVERFLOW_word)== NIL) ) + at_eos = T; /* search FSB in earler STACK area by freestackblock */ + else if(extendstack() != NIL) + { + new68k=(DLword *)oldfx68k; + goto out; + } + else + { + /* These lines are different from Original Code */ + return(0xFFFF); /* No space */ + } + }/* else if end */ + + } + + CHECK_FX(oldfx68k); + + S_CHECK(oldfx68k->usecount == 0, "use count > 0"); + /* we don't check \INTERRUPTABLE */ +#ifdef BIGVM + if(oldfx68k->validnametable && ((oldfx68k->nametable>>16)==STK_HI)) +#else + if(oldfx68k->validnametable && (oldfx68k->hi2nametable==STK_HI)) +#endif /* BIGVM */ + { + /* frame contains a name table, so we care that the alignment + of the new block be same as old */ +#ifdef STACKCHECK + { DLword n; +#ifdef BIGVM + n = oldfx68k->nametable & 0xFFFF; +#else + n=oldfx68k->lonametable; +#endif /* BIGVM */ + if((n <= StkOffset_from_68K(oldfx68k)) + && (n >= oldfx68k->nextblock)) + { WARN("moveframe:check!!", sff(LADDR_from_68k(oldfx68k)));} + } +#endif + nametbl_on_stk = T; + /* Find a free stack block */ + new68k=freestackblock(size,(StackWord *)oldfx68k, + (LADDR_from_68k(oldfx68k)-DLWORDSPER_CELL)% DLWORDSPER_QUAD); + } + else + new68k=freestackblock(size,(StackWord *)oldfx68k,-1);/* Not needed to align */ + + + if(new68k==0) return(0xFFFF); /* exhausted */ +if (new68k < Stackspace) error("freestackblock returned gunk."); + + if( at_eos && ((UNSIGNED)new68k > (UNSIGNED)oldfx68k)) + { + /* extendstack already done in freestackblock */ + ((STKBLK*)new68k)->flagword = STK_FSB_WORD; +if (((STKBLK *)new68k)->size == 0) error("0-long stack freeblock."); + goto tryfsb; + } + + /* copy frame and dummy bf pointer too */ + blt(new68k,(((DLword*)oldfx68k) - DLWORDSPER_CELL),size); + + ((Bframe*)new68k)->residual =T; + new68k = new68k + DLWORDSPER_CELL; /* now NEW points to the FX */ + ((FX*)new68k)->nextblock = (StkOffset_from_68K(new68k) + size) + -DLWORDSPER_CELL; + /* (CHECK (fetch (BF CHECKED) of (fetch (FX BLINK) of OLDFRAME)))*/ + CHECK_BF(Addr68k_from_StkOffset(GETBLINK(oldfx68k))); + + /* Set true BFptr,not residual */ + SETBLINK(new68k,GETBLINK(oldfx68k)); + + if(nametbl_on_stk) + { + S_CHECK(( (((UNSIGNED)new68k - (UNSIGNED)oldfx68k)>>1) % DLWORDSPER_QUAD) == 0, + "Misalignment of stack blocks, with nametable on stack"); +#ifdef BIGVM + ((FX*)new68k)->nametable += (((UNSIGNED)new68k - (UNSIGNED)oldfx68k)>>1); +#else + ((FX*)new68k)->lonametable += (((UNSIGNED)new68k - (UNSIGNED)oldfx68k)>>1); +#endif + } + if( ((Bframe*)DUMMYBF(oldfx68k))->residual ) + { + MAKEFREEBLOCK(((DLword*)oldfx68k)-DLWORDSPER_CELL , size); + } + else + { + MAKEFREEBLOCK(oldfx68k,size - DLWORDSPER_CELL); + } + +out: +#ifdef FLIPCURSOR + flip_cursorbar(10); +#endif + + return(S_POSITIVE|StkOffset_from_68K(new68k)); + } /* moveframe end */ + + +/******************************************************************/ +/* + Func Name : do_stackoverflow(incallp) + + retval: If There is no space for stack then return 1 + else return 0 + incallp: + If Calling during function call,incallp=T + else NIL + Edited by : Take(March 28, 1988) +*/ +/******************************************************************/ +int do_stackoverflow(int incallp) +{ + register DLword *next68k; + DLword newfx; + DLword savenext; + DLword *oldPVar; + int movedistance; + LispPTR moveframe(register FX *oldfx68k); +#ifdef STACKCHECK + LispPTR stackcontents; + LispPTR TopIVAR; + + stackcontents= *((LispPTR*)CurrentStackPTR); + TopIVAR= *((LispPTR*)IVar); +#endif + + /* Don't care PC,FuncObj, */ + /*if incall flag ON ,Don't care IVar + ,became resudual and it is pointed by copied FX's BLINK*/ + oldPVar=PVar; + + if(*NeedHardreturnCleanup_word) + { + warn("HardreturnCleanup in do_stackoverflow"); + } + if(incallp) + { + savenext=CURRENTFX->nextblock; /* save old nextblock */ + } + + BEFORE_CONTEXTSW; /* Don't Use MIDPUNT and Don't care IFPAGE */ + + + /* Call MOVEFRAME directly */ + if((newfx=(DLword)moveframe(CURRENTFX)) == 0xFFFF) + { + /* To make immidiately call HARDRESET */ + Irq_Stk_Check = 0; + Irq_Stk_End=0; + return(1); /* Whole space exausted */ + } + + + /* Return from MOVEFRAME directly */ + + PVar=(DLword*)Addr68k_from_StkOffset(newfx+FRAMESIZE); + movedistance= ((UNSIGNED)PVar-(UNSIGNED)oldPVar) >>1; + AFTER_CONTEXTSW; + + if(incallp) + { + /* set next(it pointed to old IVar) with offset */ + CURRENTFX->nextblock= savenext + movedistance; + + /* including Last Arg(kept in TOS */ +#ifdef BIGVM + S_CHECK(FuncObj == (struct fnhead *) + Addr68k_from_LADDR(CURRENTFX->fnheader), + "in call, but stack frame doesn't match FN being executed." ); +#else + S_CHECK(FuncObj == (struct fnhead *) + Addr68k_from_LADDR( + (CURRENTFX->hi2fnheader << 16) | + CURRENTFX->lofnheader), + "in call, but stack frame doesn't match FN being executed." ); +#endif /* BIGVM */ + CHECK_FX(CURRENTFX); + + /* We should re-Set up IVAR,CURRENTFX->nextblock */ + IVar += movedistance; + } /* incallp */ + + return(0); /* Normal return */ + /* If incallp ,we CAN continue executing FN or APPLY by just returning */ + /* new PVar will set in funcall */ + }/* end do_stackoverflow */ + + + + + + + +/******************************************************************/ +/* + Func Name : extendstack() + Desc. : if LastStackAddr_word is exceeded,then allocate + one new lisppage for STACK area. + + Edited by : Take(March 14, 1988) + +*/ +/******************************************************************/ +DLword *extendstack(void) +{ + register LispPTR easp; + register LispPTR scanptr; + + easp = InterfacePage->endofstack; + + if (easp < LOLOC(*LastStackAddr_word)) + { + if((easp > LOLOC(*GuardStackAddr_word)) && + ((*STACKOVERFLOW_word)== NIL) ) + { extended_frame = 1; + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->stackoverflow = 1; + *STACKOVERFLOW_word = *PENDINGINTERRUPT_word=ATOM_T; + } + newpage(STK_OFFSET|(scanptr=easp+2)); + /* I don't concern about DOLOCKPAGES */ + + MAKEFREEBLOCK(Addr68k_from_StkOffset(scanptr),DLWORDSPER_PAGE-2); + InterfacePage->endofstack = scanptr=easp+DLWORDSPER_PAGE; + SETUPGUARDBLOCK( + Addr68k_from_StkOffset(InterfacePage->endofstack), 2); + MAKEFREEBLOCK(Addr68k_from_StkOffset(easp) , 2); + return((DLword*)Addr68k_from_StkOffset(scanptr)); + } + else return(NIL); + } /* end extendstack */ + + + + + +/******************************************************************/ +/* + Func Name : freestackblock(n,sart,align) + Desc. : Search the FSB has specified size n or more + Return useful area's ptr. + If there is no space for STACK,return 0 + + Edited by : take(15-Jul-87) + take(11-Apr-88) +*/ +/******************************************************************/ + +DLword *freestackblock(DLword n, StackWord *start68k, int align) + /* size you want(in DLword) */ + /* searching will start68k at here */ + /* if Negative,it needn't align */ + { + register int wantedsize; + register StackWord *scanptr68k; +StackWord *ooscan, *oscan; + register StackWord *orig68k; + register STKBLK *freeptr68k; + register StackWord *easp68k; + register DLword freesize; + + DLword *extendstack(void); + + if (n%2) error("asking for odd-length stack block"); + + /* compute actually size you needed */ + wantedsize = n + STACKAREA_SIZE + MINEXTRASTACKWORDS; + + easp68k =(StackWord*) (Addr68k_from_StkOffset(InterfacePage->endofstack)); + + + /*** DEBUG ***/ + S_CHECK(n>2, "asking for block < 2 words long"); + S_CHECK(start68k != 0, "start68k = 0"); + S_CHECK(start68k >= + (StackWord*)Addr68k_from_StkOffset(InterfacePage->stackbase), + "start68k before stack base"); + +STARTOVER : + if(start68k) scanptr68k = start68k; + else scanptr68k = + (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + +SCAN : switch((unsigned)(STKWORD(scanptr68k)->flags)) + { + case STK_FSB : goto FREESCAN; + break; + case STK_GUARD: if((UNSIGNED)scanptr68k < (UNSIGNED)easp68k) + goto FREESCAN; + if (start68k) + { + scanptr68k =(StackWord *)Addr68k_from_StkOffset + (InterfacePage->stackbase); + goto SCAN; + } + else goto NEWPAGE; + break; + case STK_FX : scanptr68k =(StackWord *)Addr68k_from_StkOffset( + ((FX*)scanptr68k)->nextblock); + break; + default : orig68k = scanptr68k; + + while(STKWORD(scanptr68k)->flags != STK_BF) + { + S_WARN(STKWORD(scanptr68k)->flags==STK_NOTFLG, + "NOTFLG not on", scanptr68k); + scanptr68k = (StackWord *) + (((DLword *)scanptr68k) + + DLWORDSPER_CELL); + }; + +#ifdef STACKCHECK + if(((Bframe*)scanptr68k)->residual) + { if(scanptr68k != orig68k) + { + WARN("freestackblock:scanptr68k !=org", + printf(":0x%x\n", + LADDR_from_68k(scanptr68k))); + } + } + else + { + if(((Bframe*)scanptr68k)->ivar + != StkOffset_from_68K(orig68k)) + { + WARN("BF doesn't point TopIVAR", + printf(":0x%x\n", + LADDR_from_68k(scanptr68k))); + } + } +#endif + /* Used to be a +=, but SunOS4/Sparc compiles it wrong */ + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + + DLWORDSPER_CELL); + break; + + } /* end switch(scanptr68k */ + +NEXT: if(scanptr68k != start68k) + { + S_CHECK((UNSIGNED)scanptr68k <=(UNSIGNED)easp68k, "scan ptr past end of stack"); + goto SCAN; + } +NEWPAGE : easp68k =(StackWord*)extendstack(); + if(easp68k) goto STARTOVER; + else + { + warn("freestackblock:StackFull MP9319"); + return(0); + } + +FREESCAN : freeptr68k=(STKBLK *)scanptr68k; + freesize=FSB_size(freeptr68k); +FREE: + ooscan = oscan; oscan = scanptr68k; + scanptr68k = (StackWord *)(((DLword *)freeptr68k) + freesize); + if (freesize == 0) error("FREESIZE = 0"); + + switch((unsigned)(STKWORD(scanptr68k)->flags)) + { + case STK_FSB: freesize = freesize + FSB_size(scanptr68k); + goto FREE; + + case STK_GUARD: if((UNSIGNED)scanptr68k<(UNSIGNED)easp68k) + { + freesize = freesize + FSB_size(scanptr68k); + goto FREE; + } + break; + + default : break; + + } /* end switch(scanp.. */ + + if(freesize >= wantedsize) + { + if((align<0) || + (align==(StkOffset_from_68K(freeptr68k) % DLWORDSPER_QUAD))) + wantedsize= MINEXTRASTACKWORDS; + else wantedsize= MINEXTRASTACKWORDS+DLWORDSPER_CELL; + + scanptr68k =(StackWord*) (((DLword *)freeptr68k) + wantedsize); + + SETUPGUARDBLOCK(scanptr68k, n); + MAKEFREEBLOCK(freeptr68k,wantedsize); + MAKEFREEBLOCK(((DLword*)scanptr68k) + n, freesize - wantedsize -n); + return((DLword*)scanptr68k); + } + else MAKEFREEBLOCK( freeptr68k, freesize); + + goto NEXT; + } /* freestackblock end */ + + + + +/******************************************************************/ +/* + Func Name : decusecount68k(frame) + Desc. : Search the FSB has specified size n or more + Return useful are ptr. + + Edited by : take(March 14, 1988) +*/ +/******************************************************************/ +#define BF_size(ptr68k) ((StkOffset_from_68K(ptr68k)) - ((Bframe*)(ptr68k))->ivar + 2) + +decusecount68k(register FX *frame68k) +{ + DLword *alink68k; + register Bframe *blink68k; + DLword *clink68k; + register DLword *ivar68k; + register int size; + +if(FX_INVALIDP(frame68k)) return; +CHECK_FX(frame68k); +/* I don't check if \INTERRUPTABLE is NIL */ + while(StkOffset_from_68K(frame68k)) + { + if(frame68k->usecount != 0) + { + frame68k->usecount--; + return; + } + else + { + alink68k = Addr68k_from_StkOffset(GETALINK(frame68k)); + blink68k =(Bframe*) Addr68k_from_StkOffset(GETBLINK(frame68k)); + clink68k = Addr68k_from_StkOffset(GETCLINK(frame68k)); + + size = FX_size(frame68k); + + if(((Bframe*)DUMMYBF(frame68k))->residual) + { /* this frame has dummy BF */ + MAKEFREEBLOCK(((DLword*)frame68k) -DLWORDSPER_CELL,size+DLWORDSPER_CELL); + } + else + { + MAKEFREEBLOCK(frame68k,size); + } + + if(blink68k->usecnt !=0) + { + blink68k->usecnt--; + } + else + { + /*** ivar68k=Addr68k_from_StkOffset(blink68k->ivar); + GETWORD(ivar68k)=STK_FSB_WORD; + GETWORD(ivar68k+1)=ivar68k -(DLword *)blink68k +2; **/ + + MAKEFREEBLOCK(Addr68k_from_StkOffset(blink68k->ivar), + BF_size(blink68k)); + } + if(alink68k!= clink68k) + decusecount68k((FX *)alink68k); + + frame68k = (FX*)clink68k; + + } /* else end */ + + }/*while end */ +} /* decusecount68k end */ + + + + + +#ifdef ORG_FILPCORSORBAR +extern DLword *EmCursorBitMap68K; +extern int LispWindowFd; + +#ifdef XWINDOW +extern int Current_Hot_X, Current_Hot_Y; +#endif /* XWINDOW */ + + +extern struct cursor CurrentCursor; +flip_cursorbar(n) + int n; + { + GETWORD(EmCursorBitMap68K +n) = ~(GETWORD(EmCursorBitMap68K +n)); +#ifdef SUNDISPLAY + win_setcursor(LispWindowFd,&CurrentCursor); +#endif /* SUNDISPLAY */ + +#ifdef XWINDOW + /* JDS 011213 When using current_hot_y, remember fn does 15-it! */ + Set_XCursor( Current_Hot_X, 15-Current_Hot_Y ); +#endif /* XWINDOW */ + +} +#else +extern short *DisplayRegion68k; +extern int DisplayRasterWidth; + +flip_cursorbar(int n) + { + register short *word; + word = DisplayRegion68k + (n * DisplayRasterWidth); + GETWORD(word) ^= 0xFFFF; + } +#endif + + + + + +/**************************************************************/ +/* + blt(dest,source,size) +*/ +/**************************************************************/ +blt(register DLword *dest68k, register DLword *source68k, int nw) +{ +/******* OLD def , + Due to C compiler's bug, we can't use pre-decriment for register val + source68k += nw; + dest68k += nw; + while(nw) + { + GETWORD(--dest68k)= GETWORD(--source68k); + nw--; + } +**** OLD def ****/ + source68k = source68k + nw-1; + dest68k = dest68k + nw-1; + while(nw--) + { + GETWORD(dest68k--) = GETWORD(source68k--); + } + + +} + + + +/**************************************************************/ +/* + stack_check(start68k) + for DEBUG +*/ +/**************************************************************/ +stack_check(StackWord *start68k) +{ + StackWord *scanptr68k; + StackWord *endstack68k; + DLword *top_ivar; + DLword save_nextblock; + DLword savestack1,savestack2; + DLword setflg=NIL; + DLword freesize; + +#ifdef FSBCHECK + struct big_fsbs { DLword offset; DLword size;} bigFSB[100]; + int bigFSBindex=0; + + memset((char*)bigFSB, 0, 100 * 2 * 2); +#endif + + if((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) + ||(!FSBP(CurrentStackPTR))) + { + if((DLword*)CURRENTFX >= CurrentStackPTR) + { + WARN("CURRENTFX >= CurrentStackPTR??\n", + printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", + LADDR_from_68k(CURRENTFX),LADDR_from_68k(CurrentStackPTR))); + } + setflg=T; + printf("set CURRENTFX->nextblock in debugger. But it will be reset after this check \n"); + save_nextblock=CURRENTFX->nextblock; + savestack1= GETWORD(CurrentStackPTR+2); + savestack2= GETWORD(CurrentStackPTR+3); + CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR+2); + GETWORD(CurrentStackPTR+2)=STK_FSB_WORD; + GETWORD(CurrentStackPTR+3)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR+2))>>1); + } + + + if(start68k) scanptr68k =start68k; + else scanptr68k = + (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + endstack68k=(StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); + + if(STKWORD(endstack68k)->flags !=STK_GUARD) + printf("?? endstack is not GUARD BLK\n"); + + while(scanptr68k flags)) + { + case STK_FSB : freesize= FSB_size(scanptr68k); + if (freesize == 0) + { + warn("FSB freesize = 0!"); + } +#ifdef FSBCHECK + if(freesize > STACKAREA_SIZE+MINEXTRASTACKWORDS) + { + if(bigFSBindex < 100) + { + bigFSB[bigFSBindex].offset = StkOffset_from_68K(scanptr68k); + bigFSB[bigFSBindex].size = freesize; + bigFSBindex++; + } + } +#endif + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + freesize); + putchar('F'); + break; + + case STK_GUARD: freesize = FSB_size(scanptr68k); + if (freesize == 0) + { + warn("Guard block freesize = 0!"); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + freesize); + putchar('G'); + break; + + case STK_FX : CHECK_FX(scanptr68k); + scanptr68k =(StackWord *)Addr68k_from_StkOffset( + ((FX*)scanptr68k)->nextblock); + putchar('X'); + break; + + default: top_ivar=(DLword*)scanptr68k; + while(STKWORD(scanptr68k)->flags != STK_BF) + { + if (STKWORD(scanptr68k)->flags!=STK_NOTFLG) + { + WARN("StackCheck:!=STK_NOTFLG", + printf("content:0x%x\n",GETWORD(scanptr68k))); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + DLWORDSPER_CELL); + }/* while end */; + CHECK_BF(scanptr68k); + if(((Bframe*)scanptr68k)->residual) + { + if((DLword*)scanptr68k != top_ivar) + printf("Residual has real IVAR:0x%x\n", + LADDR_from_68k(scanptr68k)); + } + else + { + if(((Bframe*)scanptr68k)->ivar + != StkOffset_from_68K(top_ivar)) + printf("BF doesn't point TopIVAR:0x%x\n", + LADDR_from_68k(scanptr68k)); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + + DLWORDSPER_CELL); + putchar('B'); + break; + + }/*switch end */ + + if(scanptr68k != start68k) + { + if(scanptr68k >endstack68k) + { + WARN("scanptr exceeded end stack", + printf("scanptr68k=0x%x endstack68k=0x%x",scanptr68k,endstack68k)); + } + } + }/* while end */ + +#ifdef FSBCHECK +if(bigFSBindex!=0){ + int i; + + printf("\nBIG FSB(s):\n"); + + for(i=0;inextblock=save_nextblock; + GETWORD(CurrentStackPTR+2)=savestack1; + GETWORD(CurrentStackPTR+3)=savestack2; + } + +}/*stack_check end */ + + +/**************************************************************/ +/* + walk_stack(start68k) + for DEBUG + + Walk the stack, printing information about what we + see as we go. Unlike stack_check, this prints frame + names, alink/clink/next values, free-block lengths, etc. + +*/ +/**************************************************************/ +walk_stack(StackWord *start68k) +{ + StackWord *scanptr68k; + StackWord *endstack68k; + DLword *top_ivar; + DLword save_nextblock; + DLword savestack1,savestack2; + DLword setflg=NIL; + DLword freesize; + + + if((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) + ||(!FSBP(CurrentStackPTR))) + { + if((DLword*)CURRENTFX >= CurrentStackPTR) + { + WARN("CURRENTFX >= CurrentStackPTR??\n", + printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", + LADDR_from_68k(CURRENTFX),LADDR_from_68k(CurrentStackPTR))); + } + setflg=T; + printf("set CURRENTFX->nextblock in debugger. But it will be reset after this check \n"); + save_nextblock=CURRENTFX->nextblock; + savestack1= GETWORD(CurrentStackPTR+2); + savestack2= GETWORD(CurrentStackPTR+3); + CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR+2); + GETWORD(CurrentStackPTR+2)=STK_FSB_WORD; + GETWORD(CurrentStackPTR+3)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR+2))>>1); + } + + /* Start from where caller specifies, (as real address!); if addr=0 */ + /* start from stackbase. */ + + if(start68k) + { + scanptr68k =(StackWord *) ((unsigned long)start68k & -2 ); + printf("Starting at 0x%x.", (DLword*)scanptr68k-Stackspace); + } + else + { + scanptr68k = + (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + printf("Stack base = 0x%x.", (DLword*)scanptr68k-Stackspace); + } + + endstack68k=(StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); + + printf(" End of stack = 0x%x.\n\n", (DLword*)endstack68k-Stackspace); + + if(STKWORD(endstack68k)->flags !=STK_GUARD) + printf("?? endstack is not GUARD BLK\nendstack = 0x%x, flags = %d\n\n", + endstack68k, STKWORD(endstack68k)->flags); + + while(scanptr68k < endstack68k) + { + switch((unsigned)(STKWORD(scanptr68k)->flags)) + { + /* Free stack block */ + case STK_FSB : freesize= FSB_size(scanptr68k); + printf("%04x: Free block (len %d/0x%x)\n", + (DLword*)scanptr68k-Stackspace, freesize, + freesize); + + if (freesize == 0) + { + freesize = 2; + } + + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + freesize); + + break; + + case STK_GUARD: freesize = FSB_size(scanptr68k); + printf("%04x: Guard block (len %d/0x%x)\n", + (DLword*)scanptr68k-Stackspace, freesize, + freesize); + if (freesize == 0) + { + freesize = 2; + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + freesize); + + break; + + case STK_FX : CHECK_FX(scanptr68k); + + printf("%04x: ", + (DLword*)scanptr68k-Stackspace); + + { + FX *fx = (FX *)scanptr68k; + struct fnhead *fnobj; +#ifdef BIGVM + fnobj = (struct fnhead *) + Addr68k_from_LADDR(fx->fnheader); +#else + fnobj = (struct fnhead *) + Addr68k_from_LADDR( + ((int)fx->hi2fnheader << 16) + | fx->lofnheader); +#endif /* BIGVM */ + print(fnobj->framename); + printf("\talink: 0x%04x, clink: 0x%04x, next: 0x%04x\n", + fx->alink, fx->clink, fx->nextblock); + } + + { + Bframe *dummybf,*mtmp; + int mblink; + + /* Now make sure the FX is connected to */ + /* a Basic Frame. */ + + dummybf=(Bframe*)DUMMYBF(scanptr68k); + + /* Check for connection via BLINK field: */ + if(StkOffset_from_68K(dummybf) + != GETBLINK(scanptr68k)) + { + mblink=GETBLINK(scanptr68k); + mtmp=(Bframe*) + Addr68k_from_StkOffset(mblink); + if( ( dummybf->residual == NIL ) || + ( dummybf->ivar != mtmp->ivar ) ) + printf(" [Bad residual]\n"); + } + } + + scanptr68k =(StackWord *)Addr68k_from_StkOffset( + ((FX*)scanptr68k)->nextblock); + break; + + default: top_ivar=(DLword*)scanptr68k; + while(STKWORD(scanptr68k)->flags != STK_BF) + { + if (STKWORD(scanptr68k)->flags!=STK_NOTFLG) + { + printf("%04x: Bad BF IVAR 0x%x\n", + (DLword*)scanptr68k-Stackspace, + GETWORD(scanptr68k)); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + DLWORDSPER_CELL); + }/* while end */; + /* CHECK_BF(scanptr68k); */ + { + Bframe *bf = (Bframe *)scanptr68k; + printf("%04x: BF usecnt %d, resid %d, padding %d, ivar 0x%04x\n", + (DLword*)scanptr68k-Stackspace, + bf->usecnt, bf->residual, bf->padding, + bf->ivar); + + if(((Bframe*)scanptr68k)->ivar + != StkOffset_from_68K(top_ivar)) + printf(" [but top_ivar = 0x%04x]\n", + top_ivar - Stackspace); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + + DLWORDSPER_CELL); + break; + + }/*switch end */ + + if(scanptr68k != start68k) + { + if(scanptr68k >endstack68k) + { + WARN("scanptr exceeded end stack", + printf("scanptr68k=0x%x endstack68k=0x%x",scanptr68k,endstack68k)); + } + } + }/* while end */ + +#ifdef FSBCHECK +if(bigFSBindex!=0){ + int i; + + printf("\nBIG FSB(s):\n"); + + for(i=0;inextblock=save_nextblock; + GETWORD(CurrentStackPTR+2)=savestack1; + GETWORD(CurrentStackPTR+3)=savestack2; + } + + } /* walk_stack end */ + + +/**************************************************************/ +/* + quick_stack_check() + for DEBUGING using FNSTKCHECK +*/ +/**************************************************************/ +quick_stack_check(void) +{ + StackWord *start68k; + StackWord *scanptr68k; + StackWord *endstack68k; + DLword *top_ivar; + DLword save_nextblock; + DLword savestack1,savestack2; + DLword setflg=NIL; + DLword freesize; + +#ifdef FSBCHECK + struct big_fsbs { DLword offset; DLword size;} bigFSB[100]; + int bigFSBindex=0; + + memset((char*)bigFSB, 0, 100 * 2 * 2); +#endif + + if((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) + ||(!FSBP(CurrentStackPTR))) + { + if((DLword*)CURRENTFX >= CurrentStackPTR) + { + return(0); + WARN("CURRENTFX >= CurrentStackPTR??\n", + printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", + LADDR_from_68k(CURRENTFX),LADDR_from_68k(CurrentStackPTR))); + } + setflg=T; + save_nextblock=CURRENTFX->nextblock; + savestack1= GETWORD(CurrentStackPTR+2); + savestack2= GETWORD(CurrentStackPTR+3); + CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR+2); + GETWORD(CurrentStackPTR+2)=STK_FSB_WORD; + GETWORD(CurrentStackPTR+3)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR+2))>>1); + } + + + scanptr68k = start68k = + (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + endstack68k=(StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); + + if(STKWORD(endstack68k)->flags !=STK_GUARD) + printf("?? endstack is not GUARD BLK\n"); + + while(scanptr68k flags)) + { + case STK_FSB : freesize= FSB_size(scanptr68k); + if (freesize == 0) + { + warn("FSB freesize = 0!"); + return(1); + } +#ifdef FSBCHECK + if(freesize > STACKAREA_SIZE+MINEXTRASTACKWORDS){ + if(bigFSBindex < 100){ + bigFSB[bigFSBindex].offset = StkOffset_from_68K(scanptr68k); + bigFSB[bigFSBindex].size = freesize; + bigFSBindex++; + } + } +#endif + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + freesize); + break; + case STK_GUARD: freesize = FSB_size(scanptr68k); + if (freesize == 0) + { + warn("Guard block freesize = 0!"); + return(1); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + freesize); + break; + case STK_FX : CHECK_FX(scanptr68k); + scanptr68k =(StackWord *)Addr68k_from_StkOffset( + ((FX*)scanptr68k)->nextblock); + break; + default: top_ivar=(DLword*)scanptr68k; + while(STKWORD(scanptr68k)->flags != STK_BF) { + if (STKWORD(scanptr68k)->flags!=STK_NOTFLG) + { + warn("StackCheck:!=STK_NOTFLG"); + printf("content:0x%x\n",GETWORD(scanptr68k)); + return(1); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + DLWORDSPER_CELL); + }/* while end */; + CHECK_BF(scanptr68k); + if(((Bframe*)scanptr68k)->residual) + { + if((DLword*)scanptr68k != top_ivar) + printf("Residual has real IVAR:0x%x\n",LADDR_from_68k(scanptr68k)); + } + else + { + if(((Bframe*)scanptr68k)->ivar + != StkOffset_from_68K(top_ivar)) + printf("BF doesn't point TopIVAR:0x%x\n",LADDR_from_68k(scanptr68k)); + } + scanptr68k = (StackWord *) + ((DLword *)scanptr68k + + DLWORDSPER_CELL); + break; + }/*switch end */ + if(scanptr68k != start68k) + { + if(scanptr68k >endstack68k) + { + WARN("scanptr exceeded end stack",printf("scanptr68k=0x%x endstack68k=0x%x",scanptr68k,endstack68k)); + } + } +}/* while end */ +#ifdef FSBCHECK +if(bigFSBindex!=0){ + int i; + + printf("\nBIG FSB(s):\n"); + + for(i=0;inextblock=save_nextblock; + GETWORD(CurrentStackPTR+2)=savestack1; + GETWORD(CurrentStackPTR+3)=savestack2; + } + return(0); + +}/* quick_stack_check end */ + + + + + + + +/************************************************************************/ +/* */ +/* C H E C K _ F X */ +/* */ +/* Consistency checks on a Frame Extension; used when the */ +/* STACKCHECK compile switch is on. */ +/* */ +/* The function just returns if things are OK; calls error */ +/* if there are problems. */ +/* */ +/************************************************************************/ + +check_FX(FX *fx68k) +{ + Bframe *dummybf,*mtmp; + int mblink; + + /* The FX better really be an FX */ + + if(((FX*)(fx68k))->flags != STK_FX) + error("CheckFX:NOT FX"); + + /* Make sure the NEXTBLOCK field of the FX */ + /* Points BEYOND the start of the FX; some */ + /* stack blocks have been corrupted this */ + /* way. --JDS 2/3/98 */ + + if (fx68k->nextblock < StkOffset_from_68K(fx68k)/*+FRAMESIZE*/) + { + error("FX's nextblock field < the FFX."); + } + + /* Now make sure the FX is connected to */ + /* a Basic Frame. */ + + dummybf=(Bframe*)DUMMYBF(fx68k); + + /* Check for connection via BLINK field: */ + if(StkOffset_from_68K(dummybf) == GETBLINK(fx68k)) return; + + mblink=GETBLINK(fx68k); + mtmp=(Bframe*)Addr68k_from_StkOffset(mblink); + if( ( dummybf->residual != NIL ) && + ( dummybf->ivar == mtmp->ivar ) ) + return; + else error("CheckFX:bad residual case"); + + + } /* END check_FX */ + + + + + +/************************************************************************/ +/* */ +/* C H E C K _ B F */ +/* */ +/* Check a Basic Frame (BF) for consistency. This is used */ +/* when STACKCHECK is defined. */ +/* */ +/************************************************************************/ + +check_BF(Bframe *bf68k) +{ + Bframe *iptr68k; + + /* For starterd, it must BE a BF */ + if(bf68k->flags != STK_BF) error("checkBF:not BF1"); + + /* If the frame is residual (whatever that means), it's OK */ + if(bf68k->residual == T) return; + else + { + if (bf68k->ivar & 1) error("IVAR is ODD in a BF"); + else for (iptr68k=(Bframe*)Addr68k_from_StkOffset(bf68k->ivar); + iptr68k <=(Bframe*)(((DLword*)bf68k)-2); + iptr68k++ ) /* inc 2DLword */ + { + /* Make sure none of the "ivar" slots have stack-type */ + /* bits set. */ + if(iptr68k->flags!=STK_NOTFLG) + warn("CheckBF:Stack-bits set in IVAR"); + } + } + + } /* end check_BF */ + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +check_stack_rooms(FX *fx68k) +{ + int size; + DLword *freeptr68k,*endstk68k; + + CHECK_FX(fx68k); + freeptr68k=Addr68k_from_StkOffset(fx68k->nextblock); + if(!FSBP(freeptr68k)) + error("check_stack_rooms: nextblock doesn't point to an FSB"); + /*endstk68k=freeptr68k + FSB_size(freeptr68k); + size=((UNSIGNED)endstk68k - (UNSIGNED)CurrentStackPTR) >> 1;*/ + return(FSB_size(freeptr68k)); + + } /* end check_stack_rooms */ diff --git a/src/loader.c b/src/loader.c new file mode 100755 index 0000000..408b36a --- /dev/null +++ b/src/loader.c @@ -0,0 +1,221 @@ +/* $Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "sys/exec.h" /* choose one you like */ +#include +#include "lispemul.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "lspglob.h" +#include "arith.h" + +char *sbrk(); +unsigned getpagesize(), getpid(); +char * malloc(); + +#define roundup( a, b) ((((unsigned)(a)+(b)-1)/(b))*(b)) + +/* A macro to convert a Lisp String to a C string */ +#define LispStringToCString(Lisp, C){ \ + LispPTR *naddress; \ + char *base; \ + int length; \ + int offset; \ + naddress = (LispPTR *)(Addr68k_from_LADDR(Lisp)); \ + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); \ + offset = (int)(((OneDArray *)naddress)->offset); \ + length = ((OneDArray *)naddress)->totalsize; \ + strncpy(C, base + offset, length); \ + C[length] = '\0'; \ + } + + +int dynamic_load_code(args) + LispPTR *args; +/* args[0]: LispPTR to file name. + args[1]: native addr of where to load the code + + returns: List(load_addr, entry_point, length) +*/ +{ +char file_name[512]; +int load_address; +int entry_point; + + LispStringToCString(args[0], file_name); + N_GETNUMBER(args[1], load_address, return_error); + return(load_native_object(load_address, file_name)); +return_error: + printf("error in dynamic load: 0x%x\n",args[1]); + return(NIL_PTR); +} + +load_native_object(load_address, dynamic_file) + unsigned load_address; + char *dynamic_file; +{ + int load_length, entry_point; + typedef char *charstrptr; + typedef charstrptr charstrlist[2]; + charstrlist p; + int fd, asize, i; + struct exec hdr; + + fd = open( dynamic_file, 0 ); + if (fd == -1) return(0); + if (read( fd, &hdr, sizeof hdr ) == -1) return(0); + + load_length = hdr.a_text+hdr.a_data; + +#ifdef DEBUG + printf("Load Size: %x, Header Rec Size %x\n",load_length,sizeof hdr); + printf("Data Size: %x, Text Size %x\n",hdr.a_data, hdr.a_text); +#endif + + if (read( fd, load_address, load_length ) == -1) return(0); + entry_point = (int) ( (CFuncPTR)asmcall(load_address) ); + {register int r0, r1, r2; + ARITH_SWITCH((int) load_address, r0); + ARITH_SWITCH((int) entry_point, r1); + ARITH_SWITCH(load_length, r2); + return(N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2, NIL_PTR)))); + } +} + +/* **** system call subr, living in sb_OLD_COMPILE_LOAD_NATIVE slot *** */ + +int do_system_call(arg) + LispPTR arg; +{ +char cmd_str[512]; +register int result; +register int lisp_result; + + LispStringToCString(arg, cmd_str); +#ifdef DEBUG + printf(":: %s \n",cmd_str); +#endif + int_timer_off(); + result = system(cmd_str); + int_timer_on(); + ARITH_SWITCH(result, lisp_result); + return(lisp_result); +} + + +/* ****** stuff below is old & should be removed when the subr is *** */ + +int dynamic_load (host_file, dynamic_file, load_address, needs_compile, needs_link, do_load) + char *host_file, *dynamic_file; + unsigned load_address, needs_compile, needs_link, do_load; + +{ + int result = 0; + char fnamec[80], fnameo[80], fnameil[80], cc_str[255], ld_str[255]; + unsigned pagsiz = getpagesize(); + + host_file = "lisp"; /* TEMPORARY ********** */ + + printf("loading: %s into %s \n",dynamic_file,host_file); + if (load_address == 0) load_address = roundup(sbrk(0),pagsiz); + sprintf(fnamec, "%s.c", dynamic_file); + sprintf(fnameo, "%s.o", dynamic_file); + sprintf(fnameil, "%s.il", dynamic_file); + sprintf(cc_str,"/bin/cc -pipe -c %s -o %s %s -O -I/users/krivacic/maiko/inc /users/krivacic/maiko/src/disp68K.il",fnamec,fnameo,fnameil); + sprintf(ld_str,"/bin/ld -N -s -Ttext %x -A /users/krivacic/maiko/bin/%s -o %s %s -lc", + load_address,host_file,dynamic_file,fnameo); + + + if (needs_compile) + {result = exec_command(cc_str); + if (result) return(0); + } + if (needs_link) + {result = exec_command(ld_str); + if (result) return(0); + } + if (do_load) {char rm_str[200]; + result = load_object(load_address, dynamic_file); + sprintf(rm_str,"/bin/rm %s %s %s %s",fnamec, fnameil, fnameo, dynamic_file); +/* *** exec_command(rm_str); *** */ + } + TopOfStack = result; + return(result); + +} /*dynamic_load */ + +exec_command(cmd_str) + char *cmd_str; +{ typedef char *charstrptr; + typedef charstrptr charstrlist[21]; + charstrlist p; + char ws[21][80]; + int i, ii, cmd_length; + + int_timer_off(); + i = system(cmd_str); + int_timer_on(); + return(i); + +} /*exec_command */ + +load_object(load_address, dynamic_file) + unsigned load_address; + char *dynamic_file; +{ + int load_length, entry_point; + typedef char *charstrptr; + typedef charstrptr charstrlist[2]; + charstrlist p; + int fd, asize, i; + struct exec hdr; + char *addr2; + unsigned pagsiz = getpagesize(); + + fd = open( dynamic_file, 0 ); + if (fd == -1) return(0); + if (read( fd, &hdr, sizeof hdr ) == -1) return(0); + + asize = roundup(hdr.a_text+hdr.a_data+hdr.a_bss, pagsiz)+pagsiz; +#ifdef DEBUG + printf("Load Size: %x, Header Rec Size %x\n",asize,sizeof hdr); + printf("Data Size: %x, Text Size %x\n",hdr.a_data, hdr.a_text); +#endif + addr2 = sbrk(asize); + addr2 = (char *)roundup(addr2,pagsiz); + + if ( load_address != (unsigned)addr2 ){ return(NIL_PTR); } + + load_length = hdr.a_text+hdr.a_data; + read( fd, addr2, load_length ); + entry_point = (int) ( (CFuncPTR)asmcall(addr2) ); + {register int r0, r1, r2; +#ifdef DEBUG + printf("Values 0x%x & 0x%x\n",entry_point,load_length); +#endif + ARITH_SWITCH((int) addr2, r0); + ARITH_SWITCH((int) entry_point, r1); + ARITH_SWITCH(load_length, r2); +#ifdef DEBUG + printf("Returning 0x%x & 0x%x\n",r1,r2); +#endif + return(N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2)))); + } +} diff --git a/src/loopsops.c b/src/loopsops.c new file mode 100755 index 0000000..5bcb328 --- /dev/null +++ b/src/loopsops.c @@ -0,0 +1,475 @@ +/* $Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +/* + LOOPS opcodes: + + FetchMethodOrHelp(object, selector) -> MethodFn + LookupIV(object, iv) -> Index into iDescrs + GetValue(object, iv) + PutValue(object, iv, val) +*/ + +#include "lispemul.h" +#include "lsptypes.h" +#include "cell.h" +#include "lispmap.h" +#include "lspglob.h" +#include "adr68k.h" +#include "stack.h" +#include "gc.h" + +LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword packlen, int externalp); +static char il_string[]="INTERLISP"; +#define GET_IL_ATOM(string) get_package_atom((string),(sizeof(string)-1), \ + il_string,9,NIL) + +#define AtomValPtr(index) Addr68k_from_LADDR(*(GetVALCELL68k(index))) + +#ifdef BIGVM +#define DTD_FROM_LADDR(x) \ + (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_name) +#else +#define DTD_FROM_LADDR(x) \ + (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_namelo + \ + (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_namehi<<16)) +#endif /* BIGVM */ + +/* These assume 0 <= POSINT <= 65535 */ +#define SMALLP_FROM_POSINT(x) ((x) | S_POSITIVE) +#define POSINT_FROM_SMALLP(x) ((x) & 0xffff) + +#define RETCALL(fn,argnum) return lcfuncall(fn,argnum,3) + +/* #define PUNT (-1)*/ + +#define METH_CACHE_INDEX(CLASS,SELECTOR) (1023 & ((CLASS) ^ (SELECTOR))) +#define IV_CACHE_INDEX(VARLIST,IV) (1023 & ((VARLIST) ^ (IV))) + +#define LC_TYPEP(obj,typeATOM) (DTD_FROM_LADDR((obj)) == typeATOM) + +#define INSTANCEP(obj) (LC_TYPEP((obj),atom_instance)) +#define CLASSP(obj) (LC_TYPEP((obj),atom_class)) + +#define INSTANCE_OR_PUNT(obj,fn,argnum) \ + { if (!LC_TYPEP((obj),atom_instance)) \ + RETCALL(fn,argnum); \ + } + +#define INSTANCE_CLASS_OR_PUNT(obj,fn,argnum) \ + { register LispPTR tmp = DTD_FROM_LADDR(obj); \ + if (tmp != atom_instance && tmp != atom_class) \ + RETCALL(fn,argnum); \ + } + +#define LC_INIT if (atom_instance == 0) LCinit() + + +#define GET_IV_INDEX(objptr,iv,dest,otherwise) \ +{ \ + register struct LCIVCacheEntry *ce; \ + register LispPTR iNames=objptr->iNames; \ + \ + ce = &(LCIVCache[IV_CACHE_INDEX(iNames, iv)]); \ + if (ce->iNames == iNames && ce->iv == iv){ \ + (dest) = POSINT_FROM_SMALLP(ce->index); \ + }else{ \ + if (! Listp(iNames)) { \ + otherwise; \ + }else{ \ + register int i=0; \ + while (1) { \ + if ( car(iNames) == iv) { \ + ce->iNames = objptr->iNames; \ + ce->iv = iv; \ + ce->index = SMALLP_FROM_POSINT(i); \ + (dest) = i; \ + break; \ + }else{ \ + i++; \ + if ((iNames = cdr(iNames)) == NIL_PTR) { \ + otherwise; \ + } \ + } \ + } \ + } \ + } \ +} + + +struct LCClass { /* class datatype */ + LispPTR metaClass, ivNames, ivDescrs, + classUnitRec, localIVs, cvNames, + cvDescrs, className, supers, subClasses, + otherClassDescription, selectors, methods, localSupers; +}; + +struct LCInstance { /* instance datatype */ + LispPTR class, iNames, iDescrs, instMiscField; +}; + +struct LCMethodCacheEntry { + LispPTR class, selector, method_fn, junk; +} *LCMethodCache; + +struct LCIVCacheEntry { + LispPTR iNames, iv, index, junk; +} *LCIVCache; + +LispPTR atom_instance = 0, /* various atom indices */ + atom_class, + atom_annotatedValue, + atom_FetchMethodOrHelp_LCUFN, + atom_FetchMethod_LCUFN, + atom_FindVarIndex_LCUFN, + atom_GetIVValue_LCUFN, + atom_PutIVValue_LCUFN; + +/* Called once to initialize the "constants" above */ + +LCinit(void) { + atom_instance = GET_IL_ATOM("instance"); + atom_class = GET_IL_ATOM("class"); + atom_annotatedValue = GET_IL_ATOM("annotatedValue"); + atom_FetchMethodOrHelp_LCUFN = GET_IL_ATOM("\\FetchMethodOrHelp-LCUFN"); + atom_FetchMethod_LCUFN = GET_IL_ATOM("\\FetchMethod-LCUFN"); + atom_FindVarIndex_LCUFN = GET_IL_ATOM("\\FindVarIndex-LCUFN"); + atom_GetIVValue_LCUFN = GET_IL_ATOM("\\GetIVValue-LCUFN"); + atom_PutIVValue_LCUFN = GET_IL_ATOM("\\PutIVValue-LCUFN"); + LCMethodCache = (struct LCMethodCacheEntry *) + AtomValPtr(GET_IL_ATOM("*Global-Method-Cache*")); + LCIVCache = (struct LCIVCacheEntry *) + AtomValPtr(GET_IL_ATOM("*Global-IV-Cache-Block*")); + return NIL_PTR; /* in case called from lisp */ +} + +/* Type check fn */ +/* We only check for instance and class, neither of which has supertypes, + so the loop is unnecessary. */ +/* * * NOT USED * * */ +#ifdef NEVER +int LCTypeOf(thing, typename) +register LispPTR thing,typename; +{ + register struct dtd *dtd68k; +#ifdef BIGVM + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(thing)); + typename != (dtd68k->dtd_name); + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype) ) { + if( dtd68k->dtd_supertype == 0) return 0; + } +#else + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(thing)); + typename != dtd68k->dtd_namelo+(dtgd68k->dtd_namehi<<16) ; + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype) ) { + if( dtd68k->dtd_supertype == 0) return 0; + } +#endif /* BIGVM */ + return 1; +} +#endif /* NEVER */ + + +/* Method lookup using global cache */ + +LispPTR LCFetchMethodOrHelp(register LispPTR object, register LispPTR selector) +{ + register struct LCInstance *objptr; + register struct LCMethodCacheEntry *ce; + register LispPTR cur_class; + + LC_INIT; + + INSTANCE_CLASS_OR_PUNT(object,atom_FetchMethodOrHelp_LCUFN,2); + + objptr = (struct LCInstance *) Addr68k_from_LADDR(object); + ce = &(LCMethodCache[METH_CACHE_INDEX((cur_class = objptr->class), selector)]); + if(ce->class == cur_class && ce->selector == selector) + return ce->method_fn; + + /* not in cache, search class then supers */ + { + LispPTR supers = ((struct LCClass *)Addr68k_from_LADDR(cur_class))->supers; + + for (;;) { + register i=0; + register LispPTR val; + register LispPTR *selectorptr; + register struct LCClass *classptr; + + classptr = (struct LCClass *)Addr68k_from_LADDR(cur_class); + if (classptr->selectors == NIL_PTR) { + goto next_class; + }else{ + selectorptr = (LispPTR *)Addr68k_from_LADDR(classptr->selectors); + } + + while ((val = selectorptr[i++]) != NIL_PTR) { + if (val == selector) { + ce->class = objptr->class; + ce->selector = selector; + return (ce->method_fn = + ((LispPTR *)Addr68k_from_LADDR(classptr->methods))[i-1]) ; + } + }; + +next_class: + if( (cur_class = car(supers) ) == NIL_PTR) + break; + supers = cdr(supers); + } + } + + /* we didn't find it at all; punt */ + RETCALL(atom_FetchMethodOrHelp_LCUFN,2); + +/* return lcfuncall(atom_FetchMethodOrHelp_LCUFN,2,3); */ +/* return PUNT;*/ +} + + +LispPTR LCFetchMethod(register LispPTR class, register LispPTR selector) +{ + register struct LCMethodCacheEntry *ce; + + LC_INIT; + + /* Check cache before doing type check */ + ce = &(LCMethodCache[METH_CACHE_INDEX(class, selector)]); + if(ce->class == class && ce->selector == selector) + return ce->method_fn; + + /* it wasn't there, go search class then supers */ + + if (!LC_TYPEP(class, atom_class)) RETCALL(atom_FetchMethod_LCUFN,2); + { + register LispPTR cur_class = class; + LispPTR supers = ((struct LCClass *)Addr68k_from_LADDR(cur_class))->supers; + + for (;;) { + register i=0; + register LispPTR val; + register struct LCClass *classptr; + register LispPTR *selectorptr; + + classptr = (struct LCClass *)Addr68k_from_LADDR(cur_class); + if (classptr->selectors == NIL_PTR) goto next_class; + else selectorptr = (LispPTR *)Addr68k_from_LADDR(classptr->selectors); + + while ((val = selectorptr[i++]) != NIL_PTR) { + if (val == selector) { + ce->class = class; + ce->selector = selector; + return (ce->method_fn = + ((LispPTR *)Addr68k_from_LADDR(classptr->methods))[i-1]); + } + }; + +next_class: + if( (cur_class = car(supers) ) == NIL_PTR) + break; + supers = cdr(supers); + } + } + + /* we didn't find it at all; return NIL */ + return NIL_PTR; +} + +LispPTR LCFindVarIndex(register LispPTR iv, register LispPTR object) +{ + register struct LCInstance *objptr; + register struct LCIVCacheEntry *ce; + register LispPTR iNames; + + LC_INIT; + + INSTANCE_CLASS_OR_PUNT(object,atom_FindVarIndex_LCUFN,2); + + objptr = (struct LCInstance *) Addr68k_from_LADDR(object); + ce = &(LCIVCache[IV_CACHE_INDEX((iNames = objptr->iNames), iv)]); + if (ce->iNames == iNames && ce->iv == iv) + return ce->index; + + if (! Listp(iNames)) return NIL_PTR; /* FastFindIndex lisp macro (& others?) */ + /* needs this check too ! */ + { + register int i; + + for (i=0; i++; (iNames = cdr(iNames)) != NIL_PTR) { + if ( car(iNames) == iv) { + ce->iNames = objptr->iNames; + ce->iv = iv; + return (ce->index = SMALLP_FROM_POSINT(i)); + } + } + return NIL_PTR; + } +} + + +#if 01 + +LispPTR +LCGetIVValue(register LispPTR object, register LispPTR iv) +{ + register struct LCInstance *objptr; + register LispPTR val; + register int index; + + LC_INIT; + INSTANCE_OR_PUNT(object,atom_GetIVValue_LCUFN,2); + + objptr = (struct LCInstance *) Addr68k_from_LADDR(object); + GET_IV_INDEX(objptr,iv,index,goto pnut); + val = ((LispPTR *) Addr68k_from_LADDR(objptr->iDescrs))[index]; + if (!LC_TYPEP(val, atom_annotatedValue)) return val; + pnut: + RETCALL(atom_GetIVValue_LCUFN,2); +/* + return LCGetActiveValue(object,val); +*/ +} + +LCPutIVValue(register LispPTR object, register LispPTR iv, register LispPTR val) +{ + register struct LCInstance *objptr; + register LispPTR *valptr; + register int index; + + LC_INIT; + INSTANCE_OR_PUNT(object,atom_PutIVValue_LCUFN,3); + + objptr = (struct LCInstance *) Addr68k_from_LADDR(object); + GET_IV_INDEX(objptr,iv,index,goto pnut); + valptr = &(((LispPTR *) Addr68k_from_LADDR(objptr->iDescrs))[index]); + if (!LC_TYPEP(*valptr, atom_annotatedValue)) { + FRPLPTR((*valptr), val); + return val; + } + pnut: + RETCALL(atom_PutIVValue_LCUFN,3); +/* + return LCPutActiveValue(object,*valptr,val); +*/ +} + +#endif + + + +lcfuncall(register unsigned int atom_index, register int argnum, register int bytenum) + /* Atomindex for Function to invoke */ + /* Number of ARGS on TOS and STK */ + /* Number of bytes of Caller's + OPCODE(including multi-byte) */ +{ + register struct definition_cell *defcell68k; /* Definition Cell PTR */ + register short pv_num; /* scratch for pv */ + register struct fnhead *tmp_fn; + int rest; /* use for arignments */ + int closurep=NIL; + register CClosure *closure68k; + + if (atom_index == 0xffffffff) error("Loops punt to nonexistant fn"); + + /* Get Next Block offset from argnum */ + CURRENTFX->nextblock = (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) + - (argnum<<1)+4 /* +3 */; + + /* Setup IVar */ + IVar = Addr68k_from_LADDR((((LispPTR)(CURRENTFX->nextblock)) | STK_OFFSET)); + + /* Set PC to the Next Instruction and save into FX */ + CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) + bytenum; + + PushCStack; /* save TOS */ + + /* Get DEFCELL 68k address */ + defcell68k =(struct definition_cell *) GetDEFCELL68k(atom_index); + + tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ); + + if((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) + >= (UNSIGNED)EndSTKP ) + { + LispPTR test; + test= *((LispPTR*)CurrentStackPTR); + DOSTACKOVERFLOW(argnum,bytenum-1); + S_CHECK(test==*((LispPTR*)CurrentStackPTR), "overflow in ccfuncall"); + } + FuncObj = tmp_fn; + + if( FuncObj->na >= 0 ) + { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = argnum - FuncObj->na; + + while(rest <0) { + PushStack(NIL_PTR); + rest++; + } + CurrentStackPTR -= (rest<<1); + } /* if end */ + + /* Set up BF */ + CurrentStackPTR+=2; + GETWORD(CurrentStackPTR) = BF_MARK; + GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock; + CurrentStackPTR+=2; + + /* Set up FX */ + GETWORD(CurrentStackPTR) = FX_MARK; + + /* Now SET new FX */ + ((struct frameex1 *)CurrentStackPTR)->alink = LADDR_from_68k(PVar); + PVar = (DLword *)CurrentStackPTR + FRAMESIZE; +#ifdef BIGVM + ((struct frameex1 *)CurrentStackPTR)->fnheader = + (defcell68k->defpointer); +#else + ((struct frameex1 *)CurrentStackPTR)->lofnheader = + (defcell68k->defpointer) & 0x0ffff; + ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = + ((defcell68k->defpointer) & SEGMASK) >> 16; + ((struct frameex1 *)CurrentStackPTR)->hi1fnheader = 0; +#endif /* BIGVM */ + + CurrentStackPTR = PVar; + + /* Set up PVar area */ + pv_num = FuncObj->pv+1; /* Changed Apr.27 */ + + while(pv_num > 0) { + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; + CurrentStackPTR += DLWORDSPER_CELL; + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; + CurrentStackPTR += DLWORDSPER_CELL; + pv_num--; + } + + /* Set PC points New Function's first OPCODE */ + PC = (ByteCode *)FuncObj + FuncObj->startpc; + + return -2; /* signal to OP_miscn to leave stack & pc alone */ +} /* end lcfuncall */ + diff --git a/src/lowlev1.c b/src/lowlev1.c new file mode 100755 index 0000000..e5e030e --- /dev/null +++ b/src/lowlev1.c @@ -0,0 +1,163 @@ +/* $Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" + +int mask_array[16] = { 1, 3, 7, 0xf, + 0x1f, 0x3f, 0x7f, 0xff, + 0x1ff, 0x3ff, 0x7ff, 0xfff, + 0x1fff, 0x3fff, 0x7fff, 0xffff}; + + +/************************************************************ + N_OP_putbitsnfd + entry PUTBITS.N.FD OPCODE[0317] + + 1. <> + TopOfStack: NewValue + *((int *)(CurrentStackPTR)): base address. + alpha: word offset. + beta: High nibble -- number of the first bit of the field + Low nibble -- (number of the size of the fiel) - 1 + 2. Data is @[TopOfStack + alpha] + 3. Shift and mask the data. + 4. Set the data at [TopOfStack + alpha]. + 5. <> + return: ?? + +***********************************************************/ +LispPTR N_OP_putbitsnfd(register LispPTR base, register LispPTR data, int word_offset, register int beta) +{ +register DLword *pword; +register int shift_size, field_size, fmask; + +#ifdef CHECK + if (base > POINTERMASK) {error("getbits: base out of range");} + if (beta > 0xFF) {error("bad beta argument to PUTBITS");} +#endif + + if( (SEGMASK & data ) != S_POSITIVE ) { ERROR_EXIT(data); }; + + pword = Addr68k_from_LADDR( base + word_offset ); + field_size = 0xF & beta; + shift_size = 15 - (beta >> 4) - field_size; + fmask = mask_array[field_size] << shift_size; + GETWORD(pword) = ( (data << shift_size) & fmask) | (GETWORD(pword) & (~fmask)); + + return(base); +} + +/************************************************************ + N_OP_getbitsnfd + entry GETBITS.N.FD OPCODE[0312] + + 1. <> + TopOfStack: base address. + alpha: word offset. + beta: High nibble -- number of the first bit of the field + Low nibble -- (number of the size of the fiel) - 1 + 2. Data is @[TopOfStack + alpha] + 3. Shift and mask the data. + 4. <> + return: hi - S_POSITIVE + lo - mask & shifted data + +***********************************************************/ +LispPTR N_OP_getbitsnfd(int base_addr, register int word_offset, int beta) +{ +register DLword *pword; +register short first; +register short size; + + + pword = Addr68k_from_LADDR( base_addr + word_offset ); + size = 0xF & beta; + first = beta >> 4; + +#ifdef CHECK + if (base_addr > POINTERMASK) {error("getbits: base out of range");} + if (first+size > 15) {error("getbits beta too big");} +#endif + + return(S_POSITIVE | + ( ( GETWORD(pword) >> (16 - (first + size + 1)) ) + & mask_array[size] ) ) ; +} + + +/************************************************************ + N_OP_putbasen + entry PUTBASE.N OPCODE[0315] + + 1. <> + TopOfStack: Low Word - replace data + *(CurrentStackPTR): base address. + alpha: offset. + 2. if high word of TopOFStack is not SMALLPL, + then call ufn2incS, + else replace (base address + offset) with data. + 3. increment PC by 2. + 4. <> + return: base address. + (Called only by Native code) +***********************************************************/ + +LispPTR N_OP_putbasen(register LispPTR base, register LispPTR tos, int n) +{ + base = POINTERMASK & base; + if( (SEGMASK & tos ) != S_POSITIVE ) {ERROR_EXIT(tos);} + else{ + GETWORD((DLword *) Addr68k_from_LADDR( base + n )) = GetLoWord(tos); + return(base); + } +} + +/************************************************************ + N_OP_putbaseptrn + entry PUTBASEPTR.N OPCODE[0316] + + 1. <> + TopOfStack: replace data (2 words) + *(CurrentStackPTR): base address. + alpha: offset. + 2. replace (base address + offset) with data. + 3. save base address to TopOfStack + 3. increment PC by 2. + 4. <> + return: base address. + (Called only by Native code) +***********************************************************/ + +LispPTR N_OP_putbaseptrn(register LispPTR base, register LispPTR tos, int n) +{ + base = POINTERMASK & base; + *((LispPTR *) Addr68k_from_LADDR( base + n )) = tos & POINTERMASK; + return(base); + +} + diff --git a/src/lowlev2.c b/src/lowlev2.c new file mode 100755 index 0000000..aa739d5 --- /dev/null +++ b/src/lowlev2.c @@ -0,0 +1,137 @@ +/* $Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" + +/*** NOTE: these routines likely not called (see inlinedefsC.h) ***/ + +/************************************************************ + N_OP_addbase + entry ADDBASE OPCODE[0320] + + 1. <> + TopOfStack: offset + *(CurrentStackPTR): base address + 2. if High word of TopOfStack is SMALLPL or SMALLNEG, + then add base address and offset and set result to TopOfStack. + else call ufn2incs. + 4. <> + return: new address + +***********************************************************/ + +LispPTR N_OP_addbase(register int base, register int offset) +{ + base = POINTERMASK & base; + switch( (SEGMASK & offset) ){ + case S_POSITIVE: + return(base + (offset & 0x0000FFFF)); + case S_NEGATIVE: + return(base + (offset | 0xFFFF0000)); + default: + switch( (GetTypeNumber(offset)) ){ + case TYPE_FIXP: + /* overflow or underflow isn't check */ + return(base + *(int *)Addr68k_from_LADDR(offset)); + default: /* floatp also */ + ERROR_EXIT(offset); + }/* end switch */ + }/* end switch */ +} + +/************************************************************ + N_OP_getbasebyte + entry GETBASEBYTE OPCODE[0302] + + 1. <> + *(--CurrentStackPTR): base address. + TopOfStack: Low word - byte offset. + 2. if high word of TopOfStack is not SMALLPL, + then call ufn2incS. + else fetch 8 bits word at (base address + byte offset). + 4. <> + return: Least Low Byte - fetched data + +***********************************************************/ + +N_OP_getbasebyte(register LispPTR base_addr, register int byteoffset) +{ + switch( (SEGMASK & byteoffset) ){ + case S_POSITIVE: + byteoffset = byteoffset & 0x0000FFFF; + break; + case S_NEGATIVE: + byteoffset = byteoffset | 0xFFFF0000; + break; + default: + switch( (GetTypeNumber(byteoffset)) ){ + case TYPE_FIXP: + byteoffset = *((int *)Addr68k_from_LADDR(byteoffset)); + break; + default: /* floatp also fall thru */ + ERROR_EXIT(byteoffset); + }/* end switch */ + break; + }/* end switch */ + return((0xFF & (GETBYTE((char*)Addr68k_from_LADDR((POINTERMASK & base_addr)) + byteoffset))) | S_POSITIVE); +} + +/************************************************************ + N_OP_putbasebyte + entry PUTBASEBYTE OPCODE[0307] + + 1. <> + TopOfStack: Least Low Byte - replace data. + *((int *)(CurrentStackPTR-1)): byte offset. + *((int *)(CurrentStackPTR-2)): base address. + 4. <> + return: Least Low Byte - replace data ? + +***********************************************************/ + +N_OP_putbasebyte(register LispPTR base_addr, register int byteoffset, register int tos) +{ + if(((SEGMASK & tos ) != S_POSITIVE) || ((unsigned short)tos >= 256)) + ERROR_EXIT(tos); + switch( (SEGMASK & byteoffset) ){ + case S_POSITIVE: + byteoffset &= 0x0000FFFF; + break; + case S_NEGATIVE: + byteoffset |= 0xFFFF0000; + break; + default: + /* ucode and ufn don't handle displacement not smallp */ + ERROR_EXIT(tos); + }/* end switch */ + GETBYTE(((char*)Addr68k_from_LADDR(POINTERMASK & base_addr)) + byteoffset) = 0xFF & tos; + return ( tos ); +} + + diff --git a/src/lpdual.c b/src/lpdual.c new file mode 100755 index 0000000..966ac5e --- /dev/null +++ b/src/lpdual.c @@ -0,0 +1,191 @@ +/* $Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "lpdefs.h" +#include "lpglobl.h" + +#ifdef alliant +#pragma global safe (Eta_rownr, Eta_value) +#pragma global assoc +#endif + +#ifdef OS4 +rowdual(rownr) +int *rownr; +#else +void rowdual(int *rownr) +#endif +{ + int i; + double f, g, minrhs; + short artifs; + +#ifdef alliant +#pragma safe (Rhs, Upbo, Bas) +#endif + + if (Verbose) + printf("rowdual\n"); + (*rownr) = 0; + minrhs = -EPSB; + i = 0; + artifs = FALSE; + while (i < Rows && !artifs) + { + i++; + f = Upbo[Bas[i]]; + if (f == 0 && Rhs[i] != 0) + { + artifs = TRUE; + (*rownr) = i; + } + else + { + if (Rhs[i] < f - Rhs[i]) + g = Rhs[i]; + else + g = f - Rhs[i]; + if (g < minrhs) + { + minrhs = g; + (*rownr) = i; + } + } + } +} /* rowdual */ + +#ifdef OS4 +short coldual(numeta, rownr, colnr, minit, prow, drow) + int *numeta, *rownr, *colnr; + short *minit; + double *prow, *drow; +#else +short coldual(int *numeta, + int *rownr, + int *colnr, + short *minit, + double *prow, + double *drow) +#endif +{ + int i, j, r, varnr; + double theta, quot, pivot, d, f, g; + +#ifdef alliant +#pragma safe (Rhs, Upbo, Bas, Cend, Endetacol, prow, drow, Basis, Lower) +#endif + + if (Verbose) + printf("coldual\n"); + if (!(*minit)) + { + for (i = 0; i <= Rows; i++) + { + prow[i] = 0; + drow[i] = 0; + } + drow[0] = 1; + prow[(*rownr)] = 1; + for (i = (*numeta); i >= 1; i--) + { + d = 0; + f = 0; + r = Eta_rownr[Endetacol[i] - 1]; + for (j = Endetacol[i - 1]; j < Endetacol[i]; j++) + { + /* this is where the program consumes most cpu time */ + f = f + prow[Eta_rownr[j]] * Eta_value[j]; + d = d + drow[Eta_rownr[j]] * Eta_value[j]; + } + if (abs(f) < EPSEL) + prow[r] = 0; + else + prow[r] = f; + if (abs(d) < EPSEL) + drow[r] = 0; + else + drow[r] = d; + } + for (i = 1; i <= Columns; i++) + { + varnr = Rows + i; + if (!Basis[varnr]) + { + d = -Extrad * drow[0]; + f = 0; + for (j = Cend[i - 1]; j < Cend[i]; j++) + { + d += drow[Mat[j].rownr] * Mat[j].value; + f += prow[Mat[j].rownr] * Mat[j].value; + } + drow[varnr] = d; + prow[varnr] = f; + } + } + +#ifdef alliant +#pragma loop novector +#endif + + for (i = 0; i <= Sum; i++) + { + if (abs(prow[i]) < EPSEL) + prow[i] = 0; + if (abs(drow[i]) < EPSD) + drow[i] = 0; + } + } + if (Rhs[(*rownr)] > Upbo[Bas[(*rownr)]]) + g = -1; + else + g = 1; + pivot = 0; + (*colnr) = 0; + theta = INFINITE; + for (i = 1; i <= Sum; i++) + { + if (Lower[i]) + d = prow[i] * g; + else + d = -prow[i] * g; + if (d < 0) + if (!Basis[i]) + if (Upbo[i] > 0) + { + if (Lower[i]) + quot = -drow[i] / (double) d; + else + quot = drow[i] / (double) d; + if (quot < theta) + { + theta = quot; + pivot = d; + (*colnr) = i; + } + else + if (quot == theta) + if (abs(d) > abs(pivot)) + { + pivot = d; + (*colnr) = i; + } + } + } + return ((*colnr) > 0); +} /* coldual */ diff --git a/src/lpkit.c b/src/lpkit.c new file mode 100755 index 0000000..61655a8 --- /dev/null +++ b/src/lpkit.c @@ -0,0 +1,1856 @@ +/* $Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "lpkit.h" +#include "lpglob.h" +#include +#include +#include + +/* Globals */ +lprec *Lp=NULL; /* pointer to active problem */ +int Rows; +int Columns; +int Sum; +int Non_zeros; +int Level; +matrec *Mat; +int *Col_no; +int *Col_end; +int *Row_end; +REAL *Orig_rh; +REAL *Rh; +REAL *Rhs; +short *Must_be_int; +REAL *Orig_upbo; +REAL *Orig_lowbo; +REAL *Upbo; +REAL *Lowbo; +int *Bas; +short *Basis; +short *Lower; +int Eta_alloc; +int Eta_size; +REAL *Eta_value; +int *Eta_row_nr; +int *Eta_col_end; +int Num_inv; +REAL *Solution; +REAL *Best_solution; +REAL Infinite; +REAL Epsilon; +REAL Epsb; +REAL Epsd; +REAL Epsel; + +REAL TREJ; +REAL TINV; + +short Maximise; +short Floor_first; +REAL Extrad; + +int Warn_count; /* used in CHECK version of rounding macro */ +#ifdef NEVER +void error(char *format, ...) +{ + va_list ap; + va_start(ap, format); + vfprintf(stderr, format, ap); + fputc('\n', stderr); + va_end(ap); + exit(FAIL); +} +#endif + +lprec *make_lp(int rows, int columns) +{ + lprec *newlp; + int i, sum; + sstate *st; /* to save state in MILP runs */ + + sum=rows+columns; + if(rows < 0 || columns < 0) + error("rows < 0 or columns < 0"); + CALLOC(newlp, 1, lprec); + + strcpy(newlp->lp_name, "unnamed"); + newlp->active=FALSE; + newlp->verbose=FALSE; + newlp->print_duals=FALSE; + newlp->print_sol=FALSE; + newlp->debug=FALSE; + newlp->print_at_invert=FALSE; + newlp->trace=FALSE; + + newlp->rows=rows; + newlp->columns=columns; + newlp->sum=sum; + newlp->rows_alloc=rows; + newlp->columns_alloc=columns; + newlp->sum_alloc=sum; + newlp->names_used=FALSE; + + newlp->obj_bound=DEF_INFINITE; + newlp->infinite=DEF_INFINITE; + newlp->epsilon=DEF_EPSILON; + newlp->epsb=DEF_EPSB; + newlp->epsd=DEF_EPSD; + newlp->epsel=DEF_EPSEL; + newlp->non_zeros=0; + newlp->mat_alloc=1; + CALLOC(newlp->mat, newlp->mat_alloc, matrec); + CALLOC(newlp->col_no, newlp->mat_alloc, int); + CALLOC(newlp->col_end, columns + 1, int); + CALLOC(newlp->row_end, rows + 1, int); + newlp->row_end_valid=FALSE; + CALLOC(newlp->orig_rh, rows + 1, REAL); + CALLOC(newlp->rh, rows + 1, REAL); + CALLOC(newlp->rhs, rows + 1, REAL); + CALLOC(newlp->must_be_int, sum + 1, short); + for(i = 0; i <= sum; i++) + newlp->must_be_int[i]=FALSE; + CALLOC(newlp->orig_upbo, sum + 1, REAL); + for(i = 0; i <= sum; i++) + newlp->orig_upbo[i]=newlp->infinite; + CALLOC(newlp->upbo, sum + 1, REAL); + CALLOC(newlp->orig_lowbo, sum + 1, REAL); + CALLOC(newlp->lowbo, sum + 1, REAL); + + newlp->basis_valid=TRUE; + CALLOC(newlp->bas, rows+1, int); + CALLOC(newlp->basis, sum + 1, short); + CALLOC(newlp->lower, sum + 1, short); + for(i = 0; i <= rows; i++) + { + newlp->bas[i]=i; + newlp->basis[i]=TRUE; + } + for(i = rows + 1; i <= sum; i++) + newlp->basis[i]=FALSE; + for(i = 0 ; i <= sum; i++) + newlp->lower[i]=TRUE; + + newlp->eta_valid=TRUE; + newlp->eta_size=0; + newlp->eta_alloc=10000; + newlp->max_num_inv=DEFNUMINV; + + newlp->nr_lagrange=0; + + CALLOC(newlp->eta_value, newlp->eta_alloc, REAL); + CALLOC(newlp->eta_row_nr, newlp->eta_alloc, int); + CALLOC(newlp->eta_col_end, newlp->rows_alloc + newlp->max_num_inv, int); + + newlp->bb_rule=FIRST_NI; + newlp->break_at_int=FALSE; + newlp->break_value=0; + + newlp->iter=0; + newlp->total_iter=0; + CALLOC(newlp->solution, sum + 1, REAL); + CALLOC(newlp->best_solution, sum + 1, REAL); + CALLOC(newlp->duals, rows + 1, REAL); + + newlp->maximise = FALSE; + newlp->floor_first = TRUE; + + newlp->scaling_used = FALSE; + newlp->columns_scaled = FALSE; + + CALLOC(newlp->ch_sign, rows + 1, short); + + for(i = 0; i <= rows; i++) + newlp->ch_sign[i] = FALSE; + + st = newlp->solve_states = NULL; + for (i=0; i < Sum + 2; i++) + { + if (st) /* There's an old state-saver to use; re-use it. */ + { + st->saved = 0; /* clear the in-use field */ + st->notint = 0; /* And the not-integer field */ + st = st->next; + } + else + { + st = (sstate *) malloc(sizeof(sstate)); + if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */ + st->next = newlp->solve_states; + st->saved = 0; + st->notint = 0; /* And the not-integer field */ + newlp->solve_states = st; + st = (sstate *)NULL; + } + } + + newlp->valid = FALSE; + + return(newlp); +} + +void delete_lp(lprec *lp) +{ + int i; + + if(lp->active) + Lp=NULL; + if(lp->names_used) + { + free(lp->row_name); + free(lp->col_name); + } + free(lp->mat); + free(lp->col_no); + free(lp->col_end); + free(lp->row_end); + free(lp->orig_rh); + free(lp->rh); + free(lp->rhs); + free(lp->must_be_int); + free(lp->orig_upbo); + free(lp->orig_lowbo); + free(lp->upbo); + free(lp->lowbo); + free(lp->bas); + free(lp->basis); + free(lp->lower); + free(lp->eta_value); + free(lp->eta_row_nr); + free(lp->eta_col_end); + free(lp->solution); + free(lp->best_solution); + free(lp->duals); + free(lp->ch_sign); + if(lp->scaling_used) + free(lp->scale); + if(lp->nr_lagrange>0) + { + free(lp->lag_rhs); + free(lp->lambda); + free(lp->lag_con_type); + for(i=0; i < lp->nr_lagrange; i++) + free(lp->lag_row[i]); + free(lp->lag_row); + } + + free(lp); + lp=NULL; +} + +lprec *copy_lp(lprec *lp) +{ + lprec *newlp; + int i, rowsplus, colsplus, sumplus; + + rowsplus=lp->rows_alloc+1; + colsplus=lp->columns_alloc+1; + sumplus=lp->sum_alloc+1; + + MALLOCCPY(newlp, lp, 1, lprec); /* copy all non pointers */ + + newlp->active=FALSE; + + if(newlp->names_used) + { + MALLOCCPY(newlp->col_name, lp->col_name, colsplus, nstring); + MALLOCCPY(newlp->row_name, lp->row_name, rowsplus, nstring); + } + + MALLOCCPY(newlp->mat, lp->mat, newlp->mat_alloc, matrec); + MALLOCCPY(newlp->col_end, lp->col_end, colsplus, int); + MALLOCCPY(newlp->col_no, lp->col_no, newlp->mat_alloc, int); + MALLOCCPY(newlp->row_end, lp->row_end, rowsplus, int); + MALLOCCPY(newlp->orig_rh, lp->orig_rh, rowsplus, REAL); + MALLOCCPY(newlp->rh, lp->rh, rowsplus, REAL); + MALLOCCPY(newlp->rhs, lp->rhs, rowsplus, REAL); + MALLOCCPY(newlp->must_be_int, lp->must_be_int, sumplus, short); + MALLOCCPY(newlp->orig_upbo, lp->orig_upbo, sumplus, REAL); + MALLOCCPY(newlp->orig_lowbo, lp->orig_lowbo, sumplus, REAL); + MALLOCCPY(newlp->upbo, lp->upbo, sumplus, REAL); + MALLOCCPY(newlp->lowbo, lp->lowbo, sumplus, REAL); + MALLOCCPY(newlp->bas, lp->bas, rowsplus, int); + MALLOCCPY(newlp->basis, lp->basis, sumplus, short); + MALLOCCPY(newlp->lower, lp->lower, sumplus, short); + MALLOCCPY(newlp->eta_value, lp->eta_value, lp->eta_alloc, REAL); + MALLOCCPY(newlp->eta_row_nr, lp->eta_row_nr, lp->eta_alloc, int); + MALLOCCPY(newlp->eta_col_end, lp->eta_col_end, + lp->rows_alloc + lp->max_num_inv, int); + MALLOCCPY(newlp->solution, lp->solution, sumplus, REAL); + MALLOCCPY(newlp->best_solution, lp->best_solution, sumplus, REAL); + MALLOCCPY(newlp->duals, lp->duals, rowsplus, REAL); + MALLOCCPY(newlp->ch_sign, lp->ch_sign, rowsplus, short); + + if(newlp->scaling_used) + MALLOCCPY(newlp->scale, lp->scale, sumplus, REAL); + + if(newlp->nr_lagrange > 0) + { + MALLOCCPY(newlp->lag_rhs, lp->lag_rhs, newlp->nr_lagrange, REAL); + MALLOCCPY(newlp->lambda, lp->lambda, newlp->nr_lagrange, REAL); + MALLOCCPY(newlp->lag_con_type, lp->lag_con_type, newlp->nr_lagrange, + short); + MALLOC(newlp->lag_row, newlp->nr_lagrange, REAL*); + for(i = 0; i < newlp->nr_lagrange; i++) + MALLOCCPY(newlp->lag_row[i], lp->lag_row[i], colsplus, REAL); + } + return(newlp); +} + +void inc_mat_space(lprec *lp, int maxextra) +{ + if(lp->non_zeros + maxextra >= lp->mat_alloc) + { + lp->mat_alloc = lp->non_zeros + maxextra; + REALLOC(lp->mat, lp->mat_alloc, matrec); + REALLOC(lp->col_no, lp->mat_alloc, int); + if (lp->active) + { + Mat=lp->mat; + Col_no=lp->col_no; + } + } +} + +void inc_row_space(lprec *lp) +{ + if(lp->rows > lp->rows_alloc) + { + lp->rows_alloc=lp->rows+10; + lp->sum_alloc=lp->rows_alloc+lp->columns_alloc; + REALLOC(lp->orig_rh, lp->rows_alloc + 1, REAL); + REALLOC(lp->rh, lp->rows_alloc + 1, REAL); + REALLOC(lp->rhs, lp->rows_alloc + 1, REAL); + REALLOC(lp->orig_upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->orig_lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->best_solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->row_end, lp->rows_alloc + 1, int); + REALLOC(lp->basis, lp->sum_alloc + 1, short); + REALLOC(lp->lower, lp->sum_alloc + 1, short); + REALLOC(lp->must_be_int, lp->sum_alloc + 1, short); + REALLOC(lp->bas, lp->rows_alloc + 1, int); + REALLOC(lp->duals, lp->rows_alloc + 1, REAL); + REALLOC(lp->ch_sign, lp->rows_alloc + 1, short); + REALLOC(lp->eta_col_end, lp->rows_alloc + lp->max_num_inv, int); + if(lp->names_used) + REALLOC(lp->row_name, lp->rows_alloc + 1, nstring); + if(lp->scaling_used) + REALLOC(lp->scale, lp->sum_alloc + 1, REAL); + if(lp->active) + set_globals(lp); + } +} + +void inc_col_space(lprec *lp) +{ + if(lp->columns >= lp->columns_alloc) + { + lp->columns_alloc=lp->columns+10; + lp->sum_alloc=lp->rows_alloc+lp->columns_alloc; + REALLOC(lp->must_be_int, lp->sum_alloc + 1, short); + REALLOC(lp->orig_upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->orig_lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->best_solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->basis, lp->sum_alloc + 1, short); + REALLOC(lp->lower, lp->sum_alloc + 1, short); + if(lp->names_used) + REALLOC(lp->col_name, lp->columns_alloc + 1, nstring); + if(lp->scaling_used) + REALLOC(lp->scale, lp->sum_alloc + 1, REAL); + REALLOC(lp->col_end, lp->columns_alloc + 1, int); + if(lp->active) + set_globals(lp); + } +} + +void set_mat(lprec *lp, int Row, int Column, REAL Value) +{ + int elmnr, lastelm, i; + + if(Row > lp->rows || Row < 0) + error("Row out of range"); + if(Column > lp->columns || Column < 1) + error("Column out of range"); + if(lp->scaling_used) + Value *= lp->scale[Row] * lp->scale[lp->rows + Column]; + + if(TRUE /*abs(Value) > lp->epsilon*/) + { + if (lp->basis[Column] == TRUE && Row > 0) + lp->basis_valid = FALSE; + lp->eta_valid = FALSE; + elmnr = lp->col_end[Column-1]; + while((elmnr < lp->col_end[Column]) ? + (lp->mat[elmnr].row_nr != Row) : FALSE) + elmnr++; + + if((elmnr != lp->col_end[Column]) ? + (lp->mat[elmnr].row_nr == Row) : FALSE ) + if (lp->scaling_used) + { + if(lp->ch_sign[Row]) + lp->mat[elmnr].value = + -Value * lp->scale[Row] * lp->scale[Column]; + else + lp->mat[elmnr].value = + Value * lp->scale[Row] * lp->scale[Column]; + } + else + { + if(lp->ch_sign[Row]) + lp->mat[elmnr].value = -Value; + else + lp->mat[elmnr].value = Value; + } + else + { + /* check if more space is needed for matrix */ + inc_mat_space(lp,1); + + /* Shift the matrix */ + lastelm=lp->non_zeros; + for(i = lastelm; i > elmnr ; i--) + lp->mat[i]=lp->mat[i-1]; + for(i = Column; i <= lp->columns; i++) + lp->col_end[i]++; + + /* Set new element */ + lp->mat[elmnr].row_nr=Row; + + if (lp->scaling_used) + { + if(lp->ch_sign[Row]) + lp->mat[elmnr].value=-Value*lp->scale[Row]*lp->scale[Column]; + else + lp->mat[elmnr].value=Value*lp->scale[Row]*lp->scale[Column]; + } + else + { + if(lp->ch_sign[Row]) + lp->mat[elmnr].value=-Value; + else + lp->mat[elmnr].value=Value; + } + + lp->row_end_valid=FALSE; + + lp->non_zeros++; + if (lp->active) + Non_zeros=lp->non_zeros; + } + } +} + +void set_obj_fn(lprec *lp, REAL *row) +{ + int i; + for(i = 1; i <= lp->columns; i++) + set_mat(lp, 0, i, row[i]); +} + +void str_set_obj_fn(lprec *lp, char *row) +{ + int i; + REAL *arow; + char *p, *newp; + CALLOC(arow, lp->columns + 1, REAL); + p = row; + for(i = 1; i <= lp->columns; i++) + { + arow[i] = (REAL) strtod(p, &newp); + if(p==newp) + error("Bad string in str_set_obj_fn"); + else + p=newp; + } + set_obj_fn(lp, arow); + free(arow); +} + + +void add_constraint(lprec *lp, REAL *row, short constr_type, REAL rh) +{ + matrec *newmat; + int i, j; + int elmnr; + int stcol; + int *addtoo; + int *num,*rownum, row_nr; + REAL theta; + + MALLOC(addtoo, lp->columns + 1, int) + + for(i = 1; i <= lp->columns; i++) + if(row[i]!=0) + { + addtoo[i]=TRUE; + lp->non_zeros++; + } + else + addtoo[i]=FALSE; + + MALLOC(newmat, lp->non_zeros, matrec); + inc_mat_space(lp, 0); + lp->rows++; + lp->sum++; + inc_row_space(lp); + + if(lp->scaling_used) + { + /* shift scale */ + for(i=lp->sum; i > lp->rows; i--) + lp->scale[i]=lp->scale[i-1]; + lp->scale[lp->rows]=1; + } + + if(lp->names_used) + sprintf(lp->row_name[lp->rows], "r_%d", lp->rows); + + if(lp->scaling_used && lp->columns_scaled) + for(i = 1; i <= lp->columns; i++) + row[i] *= lp->scale[lp->rows+i]; + + if(constr_type==GE) + lp->ch_sign[lp->rows] = TRUE; + else + lp->ch_sign[lp->rows] = FALSE; + + elmnr = 0; + stcol = 0; + for(i = 1; i <= lp->columns; i++) + { + for(j = stcol; j < lp->col_end[i]; j++) + { + newmat[elmnr].row_nr=lp->mat[j].row_nr; + newmat[elmnr].value=lp->mat[j].value; + elmnr++; + } + if(addtoo[i]) + { + if(lp->ch_sign[lp->rows]) + newmat[elmnr].value = -row[i]; + else + newmat[elmnr].value = row[i]; + newmat[elmnr].row_nr = lp->rows; + elmnr++; + } + stcol=lp->col_end[i]; + lp->col_end[i]=elmnr; + } + + memcpy(lp->mat, newmat, lp->non_zeros*sizeof(matrec)); + + free(newmat); + free(addtoo); + + for(i=lp->sum ; i > lp->rows; i--) + { + lp->orig_upbo[i]=lp->orig_upbo[i-1]; + lp->orig_lowbo[i]=lp->orig_lowbo[i-1]; + lp->basis[i]=lp->basis[i-1]; + lp->lower[i]=lp->lower[i-1]; + lp->must_be_int[i]=lp->must_be_int[i-1]; + } + + for(i= 1 ; i <= lp->rows; i++) + if(lp->bas[i] >= lp->rows) + lp->bas[i]++; + + if(constr_type==LE || constr_type==GE) + { + lp->orig_upbo[lp->rows]=lp->infinite; + } + else if(constr_type==EQ) + { + lp->orig_upbo[lp->rows]=0; + } + else + { + fprintf(stderr, "Wrong constraint type\n"); + exit(FAIL); + } + + lp->orig_lowbo[lp->rows]=0; + + if(constr_type==GE && rh != 0) + lp->orig_rh[lp->rows]=-rh; + else + lp->orig_rh[lp->rows]=rh; + + lp->row_end_valid=FALSE; + + lp->bas[lp->rows]=lp->rows; + lp->basis[lp->rows]=TRUE; + lp->lower[lp->rows]=TRUE; + + if(lp->active) + set_globals(lp); + lp->eta_valid=FALSE; +} + +void str_add_constraint(lprec *lp, + char *row_string, + short constr_type, + REAL rh) +{ + int i; + REAL *aRow; + char *p, *newp; + CALLOC(aRow, lp->columns + 1, REAL); + p = row_string; + + for(i = 1; i <= lp->columns; i++) + { + aRow[i] = (REAL) strtod(p, &newp); + if(p==newp) + error("Bad string in str_add_constr"); + else + p=newp; + } + add_constraint(lp, aRow, constr_type, rh); + free(aRow); +} + +void del_constraint(lprec *lp, int del_row) +{ + int i, j; + unsigned elmnr; + int startcol; + int row_nr; + + if(del_row<1 || del_row>lp->rows) + { + fprintf(stderr, "There is no constraint nr. %d\n", del_row); + exit(FAIL); + } + + elmnr=0; + startcol=0; + + for(i = 1; i <= lp->columns; i++) + { + for(j=startcol; j < lp->col_end[i]; j++) + { + if(lp->mat[j].row_nr!=del_row) + { + lp->mat[elmnr]=lp->mat[j]; + if(lp->mat[elmnr].row_nr > del_row) + lp->mat[elmnr].row_nr--; + elmnr++; + } + else + lp->non_zeros--; + } + startcol=lp->col_end[i]; + lp->col_end[i]=elmnr; + } + for(i = del_row; i < lp->rows; i++) + { + lp->orig_rh[i] = lp->orig_rh[i+1]; + lp->ch_sign[i] = lp->ch_sign[i+1]; + lp->bas[i] = lp->bas[i+1]; + if(lp->names_used) + strcpy(lp->row_name[i], lp->row_name[i+1]); + } + for(i = 1; i < lp->rows; i++) + if(lp->bas[i] > del_row) + lp->bas[i]--; + + for(i=del_row; i < lp->sum; i++) + { + lp->lower[i]=lp->lower[i+1]; + lp->basis[i]=lp->basis[i+1]; + lp->orig_upbo[i]=lp->orig_upbo[i+1]; + lp->orig_lowbo[i]=lp->orig_lowbo[i+1]; + lp->must_be_int[i]=lp->must_be_int[i+1]; + if(lp->scaling_used) + lp->scale[i]=lp->scale[i+1]; + } + + lp->rows--; + lp->sum--; + + lp->row_end_valid=FALSE; + + if(lp->active) + set_globals(lp); + lp->eta_valid=FALSE; + lp->basis_valid=FALSE; +} + +void add_lag_con(lprec *lp, REAL *row, short con_type, REAL rhs) +{ + int i; + REAL sign; + if(con_type == LE || con_type == EQ) + sign=1; + else if(con_type == GE) + sign=-1; + else + error("con_type not implemented\n"); + + lp->nr_lagrange++; + if(lp->nr_lagrange==1) + { + CALLOC(lp->lag_row, lp->nr_lagrange, REAL*); + CALLOC(lp->lag_rhs, lp->nr_lagrange, REAL); + CALLOC(lp->lambda, lp->nr_lagrange, REAL); + CALLOC(lp->lag_con_type, lp->nr_lagrange, short); + } + else + { + REALLOC(lp->lag_row, lp->nr_lagrange, REAL*); + REALLOC(lp->lag_rhs, lp->nr_lagrange, REAL); + REALLOC(lp->lambda, lp->nr_lagrange, REAL); + REALLOC(lp->lag_con_type, lp->nr_lagrange, short); + } + CALLOC(lp->lag_row[lp->nr_lagrange-1], lp->columns+1, REAL); + lp->lag_rhs[lp->nr_lagrange-1]=rhs * sign; + for( i=1; i <= lp->columns; i++) + lp->lag_row[lp->nr_lagrange-1][i]=row[i] * sign; + lp->lambda[lp->nr_lagrange-1]=0; + lp->lag_con_type[lp->nr_lagrange-1]=(con_type == EQ); +} + +void str_add_lag_con(lprec *lp, char *row, short con_type, REAL rhs) +{ + int i; + REAL *a_row; + char *p, *new_p; + CALLOC(a_row, lp->columns + 1, REAL); + p = row; + + for(i = 1; i <= lp->columns; i++) + { + a_row[i] = (REAL) strtod(p, &new_p); + if(p==new_p) + error("Bad string in str_add_lag_con"); + else + p=new_p; + } + add_lag_con(lp, a_row, con_type, rhs); + free(a_row); +} + + +void add_column(lprec *lp, REAL *column) +{ + int i, j, elmnr, row_nr, *num, *rownum; + + lp->columns++; + lp->sum++; + inc_col_space(lp); + inc_mat_space(lp, lp->rows+1); + + if(lp->scaling_used) + { + for(i = 0; i <= lp->rows; i++) + column[i]*=lp->scale[i]; + lp->scale[lp->sum]=1; + } + + elmnr=lp->col_end[lp->columns-1]; + for(i = 0 ; i <= lp->rows ; i++) + if(column[i] != 0) + { + lp->mat[elmnr].row_nr=i; + if(lp->ch_sign[i]) + lp->mat[elmnr].value=-column[i]; + else + lp->mat[elmnr].value=column[i]; + lp->non_zeros++; + elmnr++; + } + lp->col_end[lp->columns]=elmnr; + lp->orig_lowbo[lp->sum]=0; + lp->orig_upbo[lp->sum]=lp->infinite; + lp->lower[lp->sum]=TRUE; + lp->basis[lp->sum]=FALSE; + lp->must_be_int[lp->sum]=FALSE; + if(lp->names_used) + sprintf(lp->col_name[lp->columns], "var_%d", lp->columns); + + + lp->row_end_valid=FALSE; + + if(lp->active) + { + Sum=lp->sum; + Columns=lp->columns; + Non_zeros=lp->non_zeros; + } +} + +void str_add_column(lprec *lp, char *col_string) +{ + int i; + REAL *aCol; + char *p, *newp; + CALLOC(aCol, lp->rows + 1, REAL); + p = col_string; + + for(i = 0; i <= lp->rows; i++) + { + aCol[i] = (REAL) strtod(p, &newp); + if(p==newp) + error("Bad string in str_add_column"); + else + p=newp; + } + add_column(lp, aCol); + free(aCol); +} + +void del_column(lprec *lp, int column) +{ + int i, j, from_elm, to_elm, elm_in_col; + if(column > lp->columns || column < 1) + error("Column out of range in del_column"); + for(i = 1; i <= lp->rows; i++) + { + if(lp->bas[i]==lp->rows+column) + lp->basis_valid=FALSE; + else if(lp->bas[i] > lp->rows+column) + lp->bas[i]--; + } + for(i = lp->rows+column; i < lp->sum; i++) + { + if(lp->names_used) + strcpy(lp->col_name[i-lp->rows], lp->col_name[i-lp->rows+1]); + lp->must_be_int[i]=lp->must_be_int[i+1]; + lp->orig_upbo[i]=lp->orig_upbo[i+1]; + lp->orig_lowbo[i]=lp->orig_lowbo[i+1]; + lp->upbo[i]=lp->upbo[i+1]; + lp->lowbo[i]=lp->lowbo[i+1]; + lp->basis[i]=lp->basis[i+1]; + lp->lower[i]=lp->lower[i+1]; + if(lp->scaling_used) + lp->scale[i]=lp->scale[i+1]; + } + for(i = 0; i < lp->nr_lagrange; i++) + for(j = column; j <= lp->columns; j++) + lp->lag_row[i][j]=lp->lag_row[i][j+1]; + to_elm=lp->col_end[column-1]; + from_elm=lp->col_end[column]; + elm_in_col=from_elm-to_elm; + for(i = from_elm; i < lp->non_zeros; i++) + { + lp->mat[to_elm]=lp->mat[i]; + to_elm++; + } + for(i = column; i < lp->columns; i++) + lp->col_end[i]=lp->col_end[i+1]-elm_in_col; + lp->non_zeros -= elm_in_col; + lp->row_end_valid=FALSE; + lp->eta_valid=FALSE; + + lp->sum--; + lp->columns--; + if(lp->active) + set_globals(lp); +} + +void set_upbo(lprec *lp, int column, REAL value) +{ + if(column > lp->columns || column < 1) + error("Column out of range"); + if(lp->scaling_used) + value /= lp->scale[lp->rows + column]; + if(value < lp->orig_lowbo[lp->rows + column]) + error("Upperbound must be >= lowerbound"); + lp->eta_valid = FALSE; + lp->orig_upbo[lp->rows+column] = value; +} + +void set_lowbo(lprec *lp, int column, REAL value) +{ + if(column > lp->columns || column < 1) + error("Column out of range"); + if(lp->scaling_used) + value /= lp->scale[lp->rows + column]; + if(value > lp->orig_upbo[lp->rows + column]) + error("Upperbound must be >= lowerbound"); + lp->eta_valid = FALSE; + lp->orig_lowbo[lp->rows+column] = value; +} + +void set_int(lprec *lp, int column, short must_be_int) +{ + if(column > lp->columns || column < 1) + error("Column out of range"); + lp->must_be_int[lp->rows+column]=must_be_int; + if(must_be_int==TRUE) + if(lp->columns_scaled) + unscale_columns(lp); +} + +void set_rh(lprec *lp, int row, REAL value) +{ + if(row > lp->rows || row < 0) + error("Row out of Range"); + if(row == 0) /* setting of RHS of OF not meaningful */ + { + fprintf(stderr, + "Warning: attempt to set RHS of objective function, ignored\n"); + return; + } + if(lp->scaling_used) + if(lp->ch_sign[row]) + lp->orig_rh[row] = -value * lp->scale[row]; + else + lp->orig_rh[row] = value * lp->scale[row]; + else + if(lp->ch_sign[row]) + lp->orig_rh[row] = -value; + else + lp->orig_rh[row] = value; + lp->eta_valid = FALSE; +} + +void set_rh_vec(lprec *lp, REAL *rh) +{ + int i; + if(lp->scaling_used) + for(i = 1; i <= lp->rows; i++) + if(lp->ch_sign[i]) + lp->orig_rh[i]=-rh[i]*lp->scale[i]; + else + lp->orig_rh[i]=rh[i]*lp->scale[i]; + else + for(i=1; i <= lp->rows; i++) + if(lp->ch_sign[i]) + lp->orig_rh[i]=-rh[i]; + else + lp->orig_rh[i]=rh[i]; + lp->eta_valid=FALSE; +} + +void str_set_rh_vec(lprec *lp, char *rh_string) +{ + int i; + REAL *newrh; + char *p, *newp; + CALLOC(newrh, lp->rows + 1, REAL); + p = rh_string; + + for(i = 1; i <= lp->rows; i++) + { + newrh[i] = (REAL) strtod(p, &newp); + if(p==newp) + error("Bad string in str_set_rh_vec"); + else + p=newp; + } + set_rh_vec(lp, newrh); + free(newrh); +} + + +void set_maxim(lprec *lp) +{ + int i; + if(lp->maximise==FALSE) + { + for(i = 0; i < lp->non_zeros; i++) + if(lp->mat[i].row_nr==0) + lp->mat[i].value*=-1; + lp->eta_valid=FALSE; + } + lp->maximise=TRUE; + lp->ch_sign[0]=TRUE; + if(lp->active) + Maximise=TRUE; +} + +void set_minim(lprec *lp) +{ + int i; + if(lp->maximise==TRUE) + { + for(i = 0; i < lp->non_zeros; i++) + if(lp->mat[i].row_nr==0) + lp->mat[i].value = -lp->mat[i].value; + lp->eta_valid=FALSE; + } + lp->maximise=FALSE; + lp->ch_sign[0]=FALSE; + if(lp->active) + Maximise=FALSE; +} + +void set_constr_type(lprec *lp, int row, short con_type) +{ + int i; + if(row > lp->rows || row < 1) + error("Row out of Range"); + if(con_type==EQ) + { + lp->orig_upbo[row]=0; + lp->basis_valid=FALSE; + if(lp->ch_sign[row]) + { + for(i = 0; i < lp->non_zeros; i++) + if(lp->mat[i].row_nr==row) + lp->mat[i].value*=-1; + lp->eta_valid=FALSE; + lp->ch_sign[row]=FALSE; + if(lp->orig_rh[row]!=0) + lp->orig_rh[row]*=-1; + } + } + else if(con_type==LE) + { + lp->orig_upbo[row]=lp->infinite; + lp->basis_valid=FALSE; + if(lp->ch_sign[row]) + { + for(i = 0; i < lp->non_zeros; i++) + if(lp->mat[i].row_nr==row) + lp->mat[i].value*=-1; + lp->eta_valid=FALSE; + lp->ch_sign[row]=FALSE; + if(lp->orig_rh[row]!=0) + lp->orig_rh[row]*=-1; + } + } + else if(con_type==GE) + { + lp->orig_upbo[row]=lp->infinite; + lp->basis_valid=FALSE; + if(!lp->ch_sign[row]) + { + for(i = 0; i < lp->non_zeros; i++) + if(lp->mat[i].row_nr==row) + lp->mat[i].value*=-1; + lp->eta_valid=FALSE; + lp->ch_sign[row]=TRUE; + if(lp->orig_rh[row]!=0) + lp->orig_rh[row]*=-1; + } + } + else + error("Constraint type not (yet) implemented"); +} + +REAL mat_elm(lprec *lp, int row, int column) +{ + REAL value; + int elmnr; + if(row < 0 || row > lp->rows) + error("Row out of range in mat_elm"); + if(column < 1 || column > lp->columns) + error("Column out of range in mat_elm"); + value=0; + elmnr=lp->col_end[column-1]; + while(lp->mat[elmnr].row_nr != row && elmnr < lp->col_end[column]) + elmnr++; + if(elmnr != lp->col_end[column]) + { + value = lp->mat[elmnr].value; + if(lp->ch_sign[row]) + value = -value; + if(lp->scaling_used) + value /= lp->scale[row] * lp->scale[lp->rows + column]; + } + return(value); +} + + +void get_row(lprec *lp, int row_nr, REAL *row) +{ + int i, j; + REAL RowMult; + if(row_nr <0 || row_nr > lp->rows) + error("Row nr. out of range in get_row"); + for(i = 1; i <= lp->columns; i++) + { + row[i]=0; + for(j=lp->col_end[i-1]; j < lp->col_end[i]; j++) + if(lp->mat[j].row_nr==row_nr) + row[i]=lp->mat[j].value; + if(lp->scaling_used) + row[i] /= lp->scale[lp->rows+i] * lp->scale[row_nr]; + } + if(lp->ch_sign[row_nr]) + for(i=0; i <= lp->columns; i++) + if(row[i]!=0) + row[i] = -row[i]; +} + +void get_column(lprec *lp, int col_nr, REAL *column) +{ + int i; + + if(col_nr < 1 || col_nr > lp->columns) + error("Col. nr. out of range in get_column"); + for(i = 0; i <= lp->rows; i++) + column[i]=0; + for(i = lp->col_end[col_nr-1]; i < lp->col_end[col_nr]; i++) + column[lp->mat[i].row_nr]=lp->mat[i].value; + for(i = 0; i <= lp->rows; i++) + if(column[i] !=0) + { + if(lp->ch_sign[i]) + column[i]*=-1; + if(lp->scaling_used) + column[i]/=(lp->scale[i] * lp->scale[lp->rows+col_nr]); + } +} + +void get_reduced_costs(lprec *lp, REAL *rc) +{ + int varnr, i, j; + REAL f; + + if(!lp->basis_valid) + error("Not a valid basis in get_reduced_costs"); + set_globals(lp); + if(!lp->eta_valid) + invert(); + for(i = 1; i <= lp->sum; i++) + rc[i] = 0; + rc[0] = 1; + btran(rc); + for(i = 1; i <= lp->columns; i++) + { + varnr = lp->rows + i; + if(!Basis[varnr]) + if(Upbo[varnr] > 0) + { + f = 0; + for(j = Col_end[i - 1]; j < Col_end[i]; j++) + f += rc[Mat[j].row_nr] * Mat[j].value; + rc[varnr] = f; + } + } + for(i = 1; i <= Sum; i++) + my_round(rc[i], Epsd); +} + +short is_feasible(lprec *lp, REAL *values) +{ + int i, elmnr; + REAL *this_rhs; + REAL dist; + + if(lp->scaling_used) + { + for(i = lp->rows+1; i <= lp->sum; i++) + if( values[i - lp->rows] < lp->orig_lowbo[i]*lp->scale[i] + || values[i - lp->rows] > lp->orig_upbo[i]*lp->scale[i]) + return(FALSE); + } + else + { + for(i = lp->rows+1; i <= lp->sum; i++) + if( values[i - lp->rows] < lp->orig_lowbo[i] + || values[i - lp->rows] > lp->orig_upbo[i]) + return(FALSE); + } + CALLOC(this_rhs, lp->rows+1, REAL) + for(i = 1; i <= lp->columns; i++) + for(elmnr = lp->col_end[i - 1]; elmnr < lp->col_end[i]; elmnr++) + this_rhs[lp->mat[elmnr].row_nr] += lp->mat[elmnr].value * values[i]; + for(i = 1; i <= lp->rows; i++) + { + dist = lp->orig_rh[i] - this_rhs[i]; + my_round(dist, 0.001) + if((lp->orig_upbo[i] == 0 && dist != 0) || dist < 0) + { + free(this_rhs); + return(FALSE); + } + } + free(this_rhs); + return(TRUE); +} + +short column_in_lp(lprec *lp, REAL *testcolumn) +{ + int i, j; + short ident; + REAL value; + + if(lp->scaling_used) + for(i = 1; i <= lp->columns; i++) + { + ident = TRUE; + j = lp->col_end[i-1]; + while(ident && (j < lp->col_end[i])) + { + value = lp->mat[j].value; + if(lp->ch_sign[lp->mat[j].row_nr]) + value = -value; + value /= lp->scale[lp->rows+i]; + value /= lp->scale[lp->mat[j].row_nr]; + value -= testcolumn[lp->mat[j].row_nr]; + if(my_abs(value) > 0.001) /* should be some epsilon? MB */ + ident=FALSE; + j++; + } + if(ident) + return(TRUE); + } + else + for(i = 1; i <= lp->columns; i++) + { + ident = TRUE; + j = lp->col_end[i-1]; + while(ident && j < lp->col_end[i]) + { + value = lp->mat[j].value; + if(lp->ch_sign[lp->mat[j].row_nr]) + value *= -1; + value -= testcolumn[lp->mat[j].row_nr]; + if( my_abs(value) > 0.001 ) + ident=FALSE; + j++; + } + if(ident) + return(TRUE); + } + return(FALSE); +} + + +void print_lp(lprec *lp) +{ + int i, j; + REAL *fatmat; + CALLOC(fatmat, (lp->rows + 1) * lp->columns, REAL); + for(i = 1; i <= lp->columns; i++) + for(j = lp->col_end[i-1]; j < lp->col_end[i]; j++) + fatmat[(i - 1) * (lp->rows + 1) + lp->mat[j].row_nr]=lp->mat[j].value; + + printf("problem name: %s\n", lp->lp_name); + printf(" "); + for(j = 1; j <= lp->columns; j++) + if(lp->names_used) + printf("%8s ", lp->col_name[j]); + else + printf("Var[%3d] ", j); + if(lp->maximise) + { + printf("\nMaximise "); + for(j = 0; j < lp->columns; j++) + printf("% 8.2f ",-fatmat[j*(lp->rows+1)]); + } + else + { + printf("\nMinimize "); + for(j = 0; j < lp->columns; j++) + printf("% 8.2f ", fatmat[j*(lp->rows+1)]); + } + printf("\n"); + for(i = 1; i <= lp->rows; i++) + { + if(lp->names_used) + printf("%9s ", lp->row_name[i]); + else + printf("Row[%3d] ", i); + for(j = 0; j < lp->columns; j++) + if(lp->ch_sign[i] && fatmat[j*(lp->rows+1)+i] != 0) + printf("% 8.2f ",-fatmat[j*(lp->rows+1)+i]); + else + printf("% 8.2f ", fatmat[j*(lp->rows+1)+i]); + if(lp->orig_upbo[i]==lp->infinite) + if(lp->ch_sign[i]) + printf(">= "); + else + printf("<= "); + else + printf(" = "); + if(lp->ch_sign[i]) + printf("% 8.2f\n",-lp->orig_rh[i]); + else + printf("% 8.2f\n", lp->orig_rh[i]); + } + printf("Type "); + for(i = 1; i <= lp->columns; i++) + if(lp->must_be_int[lp->rows+i]==TRUE) + printf(" Int "); + else + printf(" Real "); + printf("\nupbo "); + for(i = 1; i <= lp->columns; i++) + if(lp->orig_upbo[lp->rows+i]==lp->infinite) + printf(" Inf "); + else + printf("% 8.2f ", lp->orig_upbo[lp->rows+i]); + printf("\nlowbo "); + for(i = 1; i <= lp->columns; i++) + printf("% 8.2f ", lp->orig_lowbo[lp->rows+i]); + printf("\n"); + for(i = 0; i < lp->nr_lagrange; i++) + { + printf("lag[%3d] ", i); + for(j = 1; j <= lp->columns; j++) + printf("% 8.2f ", lp->lag_row[i][j]); + if(lp->orig_upbo[i]==lp->infinite) + if(lp->lag_con_type[i] == GE) + printf(">= "); + else if(lp->lag_con_type[i] == LE) + printf("<= "); + else if(lp->lag_con_type[i] == EQ) + printf(" = "); + printf("% 8.2f\n", lp->lag_rhs[i]); + } + + free(fatmat); +} + +void set_row_name(lprec *lp, int row, nstring new_name) +{ + int i; + + if(!lp->names_used) + { + CALLOC(lp->row_name, lp->rows_alloc + 1, nstring); + CALLOC(lp->col_name, lp->columns_alloc + 1, nstring); + lp->names_used=TRUE; + for(i = 0; i <= lp->rows; i++) + sprintf(lp->row_name[i], "r_%d", i); + for(i = 1; i <= lp->columns; i++) + sprintf(lp->col_name[i], "var_%d", i); + } + strcpy(lp->row_name[row], new_name); +} + +void set_col_name(lprec *lp, int column, nstring new_name) +{ + int i; + + if(!lp->names_used) + { + CALLOC(lp->row_name, lp->rows_alloc + 1, nstring); + CALLOC(lp->col_name, lp->columns_alloc + 1, nstring); + lp->names_used=TRUE; + for(i = 0; i <= lp->rows; i++) + sprintf(lp->row_name[i], "r_%d", i); + for(i = 1; i <= lp->columns; i++) + sprintf(lp->col_name[i], "var_%d", i); + } + strcpy(lp->col_name[column], new_name); +} + +static REAL minmax_to_scale(REAL min, REAL max) +{ + REAL scale; + + /* should do something sensible when min or max is 0, MB */ + if((min == 0) || (max == 0)) + return((REAL)1); + + scale = 1 / pow(10, (log10(min) + log10(max)) / 2); + return(scale); +} + +void unscale_columns(lprec *lp) +{ + int i, j; + + /* unscale mat */ + for(j = 1; j <= lp->columns; j++) + for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value /= lp->scale[lp->rows + j]; + + /* unscale bounds as well */ + for(i = lp->rows + 1; i < lp->sum; i++) + { + if(lp->orig_lowbo[i] != 0) + lp->orig_lowbo[i] *= lp->scale[i]; + if(lp->orig_upbo[i] != lp->infinite) + lp->orig_upbo[i] *= lp->scale[i]; + } + + for(i=lp->rows+1; i<= lp->sum; i++) + lp->scale[i]=1; + lp->columns_scaled=FALSE; + lp->eta_valid=FALSE; +} + +void unscale(lprec *lp) +{ + int i, j; + + if(lp->scaling_used) + { + + /* unscale mat */ + for(j = 1; j <= lp->columns; j++) + for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value /= lp->scale[lp->rows + j]; + + /* unscale bounds */ + for(i = lp->rows + 1; i < lp->sum; i++) + { + if(lp->orig_lowbo[i] != 0) + lp->orig_lowbo[i] *= lp->scale[i]; + if(lp->orig_upbo[i] != lp->infinite) + lp->orig_upbo[i] *= lp->scale[i]; + } + + /* unscale the matrix */ + for(j = 1; j <= lp->columns; j++) + for(i = lp->col_end[j-1]; i < lp->col_end[j]; i++) + lp->mat[i].value /= lp->scale[lp->mat[i].row_nr]; + + /* unscale the rhs! */ + for(i = 0; i <= lp->rows; i++) + lp->orig_rh[i] /= lp->scale[i]; + + free(lp->scale); + lp->scaling_used=FALSE; + lp->eta_valid=FALSE; + } +} + + +void auto_scale(lprec *lp) +{ + int i, j, row_nr, IntUsed; + REAL *row_max, *row_min, *scalechange, absval; + REAL col_max, col_min, col_scale; + + if(!lp->scaling_used) + { + MALLOC(lp->scale, lp->sum_alloc + 1, REAL); + for(i=0; i <= lp->sum; i++) + lp->scale[i]=1; + } + MALLOC(row_max, lp->rows + 1, REAL); + MALLOC(row_min, lp->rows + 1, REAL); + MALLOC(scalechange, lp->sum + 1, REAL); + + /* initialise min and max values */ + for(i = 0; i <= lp->rows; i++) + { + row_max[i]=0; + row_min[i]=lp->infinite; + } + + /* calculate min and max absolute values of rows */ + for(j = 1; j <= lp->columns; j++) + { + + for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + { + row_nr = lp->mat[i].row_nr; + absval = my_abs(lp->mat[i].value); + if(absval!=0) + { + row_max[row_nr] = my_max(row_max[row_nr], absval); + row_min[row_nr] = my_min(row_min[row_nr], absval); + } + } + } + /* calculate scale factors for rows */ + for(i = 0; i <= lp->rows; i++) + { + scalechange[i] = minmax_to_scale(row_min[i], row_max[i]); + lp->scale[i] *= scalechange[i]; + } + + /* now actually scale the matrix */ + for(j = 1; j <= lp->columns; j++) + for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value *= scalechange[lp->mat[i].row_nr]; + + /* and scale the rhs! */ + for(i = 0; i <= lp->rows; i++) + lp->orig_rh[i] *= scalechange[i]; + + free(row_max); + printf("after free r_max. "); + free(row_min); + printf("after free rmin. "); + + IntUsed=FALSE; + i=lp->rows+1; + while(!IntUsed && i <= lp->sum) + { + IntUsed=lp->must_be_int[i]; + i++; + } + if(!IntUsed) + { + REAL col_max, col_min, col_scale; + + /* calculate scales */ + for(j = 1; j <= lp->columns; j++) + { + col_max = 0; + col_min = lp->infinite; + for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + { + if(lp->mat[i].value!=0) + { + col_max = my_max(col_max, my_abs(lp->mat[i].value)); + col_min = my_min(col_min, my_abs(lp->mat[i].value)); + } + } + scalechange[lp->rows + j] = minmax_to_scale(col_min, col_max); + lp->scale[lp->rows + j] *= scalechange[lp->rows + j]; + } + + /* scale mat */ + for(j = 1; j <= lp->columns; j++) + for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value *= scalechange[lp->rows + j]; + + /* scale bounds as well */ + for(i = lp->rows + 1; i < lp->sum; i++) + { + if(lp->orig_lowbo[i] != 0) + lp->orig_lowbo[i] /= scalechange[i]; + if(lp->orig_upbo[i] != lp->infinite) + lp->orig_upbo[i] /= scalechange[i]; + } + lp->columns_scaled=TRUE; + } + printf("b4 free scch. "); + free(scalechange); + printf("after free scch. "); + lp->scaling_used=TRUE; + lp->eta_valid=FALSE; +} + +void reset_basis(lprec *lp) +{ + lp->basis_valid=FALSE; +} + +void print_solution(lprec *lp) +{ + int i; + + fprintf(stdout, "Value of objective function: %16.10g\n", + (double)lp->best_solution[0]); + + /* print normal variables */ + for(i = 1; i <= lp->columns; i++) + if(lp->names_used) + fprintf(stdout, "%-10s%16.5g\n", lp->col_name[i], + (double)lp->best_solution[lp->rows+i]); + else + fprintf(stdout, "Var [%4d] %16.5g\n", i, + (double)lp->best_solution[lp->rows+i]); + + /* print achieved constraint values */ + if(lp->verbose) + { + fprintf(stdout, "\nActual values of the constraints:\n"); + for(i = 1; i <= lp->rows; i++) + if(lp->names_used) + fprintf(stdout, "%-10s%16.5g\n", lp->row_name[i], + (double)lp->best_solution[i]); + else + fprintf(stdout, "%Row [%4d] %16.5g\n", i, + (double)lp->best_solution[i]); + } + + if((lp->verbose || lp->print_duals)) + { + if(lp->max_level != 1) + fprintf(stdout, + "These are the duals from the node that gave the optimal solution.\n"); + else + fprintf(stdout, "\nDual values:\n"); + for(i = 1; i <= lp->rows; i++) + if(lp->names_used) + fprintf(stdout, "%-10s%16.5g\n", lp->row_name[i], + (double)lp->duals[i]); + else + fprintf(stdout, "Row [%4d] %16.5g\n", i, (double)lp->duals[i]); + } +} /* Printsolution */ + +void write_LP(lprec *lp, FILE *output) +{ + int i, j; + REAL *row; + nstring var_name; + + MALLOC(row, lp->columns+1, REAL); + if(lp->maximise) + fprintf(output, "max:"); + else + fprintf(output, "min:"); + + get_row(lp, 0, row); + for(i = 1; i <= lp->columns; i++) + if(row[i] != 0) + { + if(row[i] == -1) + fprintf(output, " -"); + else if(row[i] == 1) + fprintf(output, " +"); + else + fprintf(output, " %+g ", row[i]); + if(lp->names_used) + fprintf(output, "%s", lp->col_name[i]); + else + fprintf(output, "x%d", i); + } + fprintf(output, ";\n"); + + for(j = 1; j <= lp->rows; j++) + { + if(lp->names_used) + fprintf(output, "%s:", lp->row_name[j]); + get_row(lp, j, row); + for(i = 1; i <= lp->columns; i++) + if(row[i] != 0) + { + if(row[i] == -1) + fprintf(output, " -"); + else if(row[i] == 1) + fprintf(output, " +"); + else + fprintf(output, " %+g ", row[i]); + if(lp->names_used) + fprintf(output, "%s", lp->col_name[i]); + else + fprintf(output, "x%d", i); + } + if(lp->orig_upbo[j] == 0) + fprintf(output, " ="); + else if(lp->ch_sign[j]) + fprintf(output, " >"); + else + fprintf(output, " <"); + if(lp->ch_sign[j]) + fprintf(output, " %g;\n",-lp->orig_rh[j]); + else + fprintf(output, " %g;\n", lp->orig_rh[j]); + } + for(i = lp->rows+1; i <= lp->sum; i++) + { + if(lp->orig_lowbo[i] != 0) + { + if(lp->names_used) + fprintf(output, "%s > %g;\n", lp->col_name[i - lp->rows], + lp->orig_lowbo[i]); + else + fprintf(output, "x%d > %g;\n", i - lp->rows, + lp->orig_lowbo[i]); + } + if(lp->orig_upbo[i] != lp->infinite) + { + if(lp->names_used) + fprintf(output, "%s < %g;\n", lp->col_name[i - lp->rows], + lp->orig_upbo[i]); + else + fprintf(output, "x%d < %g;\n", i - lp->rows, lp->orig_upbo[i]); + } + } + + + i=1; + while(!lp->must_be_int[lp->rows+i] && i <= lp->columns) + i++; + if(i <= lp->columns) + { + if(lp->names_used) + fprintf(output, "\nint %s", lp->col_name[i]); + else + fprintf(output, "\nint x%d", i); + i++; + for(; i <= lp->columns; i++) + if(lp->must_be_int[lp->rows+i]) + if(lp->names_used) + fprintf(output, ",%s", lp->col_name[i]); + else + fprintf(output, ", x%d", i); + fprintf(output, ";\n"); + } + free(row); +} + + + + +void write_MPS(lprec *lp, FILE *output) +{ + int i, j, marker; + REAL *column; + + + MALLOC(column, lp->rows+1, REAL); + marker=0; + fprintf(output, "NAME %s\n", lp->lp_name); + fprintf(output, "ROWS\n"); + for(i = 0; i <= lp->rows; i++) + { + if(i==0) + fprintf(output, " N "); + else + if(lp->orig_upbo[i]==lp->infinite) + if(lp->ch_sign[i]) + fprintf(output, " G "); + else + fprintf(output, " L "); + else + fprintf(output, " E "); + if(lp->names_used) + fprintf(output, "%s\n", lp->row_name[i]); + else + fprintf(output, "r_%d\n", i); + } + + fprintf(output, "COLUMNS\n"); + j = 0; + for(i = 1; i <= lp->columns; i++) + { + if((lp->must_be_int[i+lp->rows]) && (marker % 2)==0) + { + fprintf(output, + " MARK%04d 'MARKER' 'INTORG'\n", + marker); + marker++; + } + if((!lp->must_be_int[i+lp->rows]) && (marker % 2)==1) + { + fprintf(output, + " MARK%04d 'MARKER' 'INTEND'\n", + marker); + marker++; + } + get_column(lp, i, column); + j=0; + if(lp->maximise) + { + if(column[j] != 0) + { + if(lp->names_used) + fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], + lp->row_name[j], -column[j]); + else + fprintf(output, " var_%-4d r_%-6d %g\n", i, j, + -column[j]); + } + } + else + { + if(column[j] != 0) + { + if(lp->names_used) + fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], + lp->row_name[j], column[j]); + else + fprintf(output, " var_%-4d r_%-6d %g\n", i, j, + column[j]); + } + } + for(j=1; j <= lp->rows; j++) + if(column[j] != 0) + { + if(lp->names_used) + fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], + lp->row_name[j], column[j]); + else + fprintf(output, " var_%-4d r_%-6d %g\n", i, j, + column[j]); + } + } + if((marker % 2) ==1) + { + fprintf(output, " MARK%04d 'MARKER' 'INTEND'\n", + marker); + marker++; + } + + fprintf(output, "RHS\n"); + for(i = 1; i <= lp->rows; i++) + { + if(lp->ch_sign[i]) + { + if(lp->names_used) + fprintf(output, " RHS %-8s %g\n", lp->row_name[i], + (double)-lp->orig_rh[i]); + else + fprintf(output, " RHS r_%-6d %g\n", i, + (double)-lp->orig_rh[i]); + } + else + { + if(lp->names_used) + fprintf(output, " RHS %-8s %g\n", lp->row_name[i], + (double)lp->orig_rh[i]); + else + fprintf(output, " RHS r_%-6d %g\n", i, + (double)lp->orig_rh[i]); + } + } + + fprintf(output, "BOUNDS\n"); + if(lp->names_used) + for(i = lp->rows + 1; i <= lp->sum; i++) + { + if(lp->orig_upbo[i] < lp->infinite) + fprintf(output, " UP BND %-8s %g\n", + lp->col_name[i- lp->rows], (double)lp->orig_upbo[i]); + if(lp->orig_lowbo[i] != 0) + fprintf(output, " LO BND %-8s %g\n", + lp->col_name[i- lp->rows], (double)lp->orig_lowbo[i]); + } + else + for(i = lp->rows + 1; i <= lp->sum; i++) + { + if(lp->orig_upbo[i] < lp->infinite) + fprintf(output, " UP BND var_%-4d %g\n", + i - lp->rows, (double)lp->orig_upbo[i]); + if(lp->orig_lowbo[i] != 0) + fprintf(output, " LO BND var_%-4d %g\n", i - lp->rows, + (double)lp->orig_lowbo[i]); + } + fprintf(output, "ENDATA\n"); + free(column); +} + +void print_duals(lprec *lp) +{ + int i; + for(i = 1; i <= lp->rows; i++) + if(lp->names_used) + fprintf(stdout, "%10s [%3d] % 10.4f\n", lp->row_name[i], i, + lp->duals[i]); + else + fprintf(stdout, "Dual [%3d] % 10.4f\n", i, lp->duals[i]); +} + +void print_scales(lprec *lp) +{ + int i; + if(lp->scaling_used) + { + for(i = 0; i <= lp->rows; i++) + fprintf(stdout, "Row[%3d] scaled at % 10.6f\n", i, lp->scale[i]); + for(i = 1; i <= lp->columns; i++) + fprintf(stdout, "Column[%3d] scaled at % 10.6f\n", i, + lp->scale[lp->rows + i]); + } +} diff --git a/src/lplexyy.c b/src/lplexyy.c new file mode 100755 index 0000000..6230625 --- /dev/null +++ b/src/lplexyy.c @@ -0,0 +1,878 @@ +/* $Id: lplexyy.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lplexyy.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifndef BIGATOMS +# include "stdio.h" +# define U(x) x +# define NLSTATE yyprevious=YYNEWLINE +# define BEGIN yybgin = yysvec + 1 + +# define INITIAL 0 +# define YYLERR yysvec +# define YYSTATE (yyestate-yysvec-1) +# define YYOPTIM 1 +# define YYLMAX 200 +# define output(c) putc(c,yyout) +# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) +# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} +# define yymore() (yymorfg=1) +# define ECHO fprintf(yyout, "%s",yytext) +# define REJECT { nstr = yyreject(); goto yyfussy;} +int yyleng; extern char yytext[]; +int yymorfg; +extern char *yysptr, yysbuf[]; +int yytchar; +FILE *yyin = {stdin}, *yyout = {stdout}; +extern int yylineno; +struct yysvf { + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops;}; +struct yysvf *yyestate; +extern struct yysvf yysvec[], *yybgin; +extern int yylook(); +#ifdef __cplusplus +extern "C" { +#endif +#define yywrap() (1) +extern int yylex(); +extern int yyreject(); +extern int yyracc(int); +extern int yyless(int); +#ifdef __cplusplus +} +#endif +# define COMMENT 2 +# define YYNEWLINE 10 +yylex(){ +int nstr; extern int yyprevious; +while((nstr = yylook()) >= 0) +yyfussy: switch(nstr){ +case 0: +if(yywrap()) return(0); break; +case 1: +{ + BEGIN COMMENT; +} +break; +case 2: +{ + BEGIN INITIAL; +} +break; +case 3: +{ +} +break; +case 4: +{ +} +break; +case 5: +{ +} +break; +case 6: +{ + return(COMMA); +} +break; +case 7: +{ + return(MINIMISE); +} +break; +case 8: +{ + return(MAXIMISE); +} +break; +case 9: +{ + sscanf((char *)yytext,"%lf",&f); + return(CONS); +} +break; +case 10: +{ + Sign=0; + for(x=0;xyystoff; + if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ + yyz = yystate->yyother; + if(yyz == 0)break; + if(yyz->yystoff == yycrank)break; + } + *yylastch++ = yych = input(); + yyfirst=0; + tryagain: +# ifdef LEXDEBUG + if(debug){ + fprintf(yyout,"char "); + allprint(yych); + putchar('\n'); + } +# endif + yyr = yyt; + if ( (int)yyt > (int)yycrank){ + yyt = yyr + yych; + if (yyt <= yytop && yyt->verify+yysvec == yystate){ + if(yyt->advance+yysvec == YYLERR) /* error transitions */ + {unput(*--yylastch);break;} + *lsp++ = yystate = yyt->advance+yysvec; + goto contin; + } + } +# ifdef YYOPTIM + else if((int)yyt < (int)yycrank) { /* r < yycrank */ + yyt = yyr = yycrank+(yycrank-yyt); +# ifdef LEXDEBUG + if(debug)fprintf(yyout,"compressed state\n"); +# endif + yyt = yyt + yych; + if(yyt <= yytop && yyt->verify+yysvec == yystate){ + if(yyt->advance+yysvec == YYLERR) /* error transitions */ + {unput(*--yylastch);break;} + *lsp++ = yystate = yyt->advance+yysvec; + goto contin; + } + yyt = yyr + YYU(yymatch[yych]); +# ifdef LEXDEBUG + if(debug){ + fprintf(yyout,"try fall back character "); + allprint(YYU(yymatch[yych])); + putchar('\n'); + } +# endif + if(yyt <= yytop && yyt->verify+yysvec == yystate){ + if(yyt->advance+yysvec == YYLERR) /* error transition */ + {unput(*--yylastch);break;} + *lsp++ = yystate = yyt->advance+yysvec; + goto contin; + } + } + if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ +# ifdef LEXDEBUG + if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); +# endif + goto tryagain; + } +# endif + else + {unput(*--yylastch);break;} + contin: +# ifdef LEXDEBUG + if(debug){ + fprintf(yyout,"state %d char ",yystate-yysvec-1); + allprint(yych); + putchar('\n'); + } +# endif + ; + } +# ifdef LEXDEBUG + if(debug){ + fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); + allprint(yych); + putchar('\n'); + } +# endif + while (lsp-- > yylstate){ + *yylastch-- = 0; + if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ + yyolsp = lsp; + if(yyextra[*yyfnd]){ /* must backup */ + while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ + lsp--; + unput(*yylastch--); + } + } + yyprevious = YYU(*yylastch); + yylsp = lsp; + yyleng = yylastch-yytext+1; + yytext[yyleng] = 0; +# ifdef LEXDEBUG + if(debug){ + fprintf(yyout,"\nmatch "); + sprint(yytext); + fprintf(yyout," action %d\n",*yyfnd); + } +# endif + return(*yyfnd++); + } + unput(*yylastch); + } + if (yytext[0] == 0 /* && feof(yyin) */) + { + yysptr=yysbuf; + return(0); + } + yyprevious = yytext[0] = input(); + if (yyprevious>0) + output(yyprevious); + yylastch=yytext; +# ifdef LEXDEBUG + if(debug)putchar('\n'); +# endif + } + } +#endif + diff --git a/src/lplexyy.c.X b/src/lplexyy.c.X new file mode 100644 index 0000000..e69de29 diff --git a/src/lpmain.c b/src/lpmain.c new file mode 100755 index 0000000..b0cb665 --- /dev/null +++ b/src/lpmain.c @@ -0,0 +1,331 @@ +/* $Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lpkit.h" +#include "lpglob.h" +#include "lppatch.h" +#include +#include + +#ifdef OS4 +#include +#endif /* OS4 */ + +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "adr68k.h" +#include "arith.h" + + +#define CFREE(x) if (x) { free(x); (x) = (void *)0; } + +lprec *Medley_lp = NULL; /* The lp description for us */ +int SolveCount = 0; /* Counter for interrupting periodically */ +jmp_buf LP_jmpbuf; + +static lprec *initmilp(lprec *lp) +{ + int i,j, rownr; + int *num, *rownum; + sstate *st; /* for saving state at timeouts */ + + if (!lp) CALLOC(lp, 1, lprec); + + /* Done already in lisp. Rows--; */ + Sum = Rows + Columns; + + strcpy(lp->lp_name, "LOTS-TP integer program"); + + lp->active = FALSE; + lp->verbose = FALSE; + lp->print_duals = FALSE; + lp->print_sol = FALSE; + lp->debug = FALSE; + lp->print_at_invert = FALSE; + lp->trace = FALSE; + + lp->rows = Rows; + lp->columns = Columns; + lp->sum = Rows + Columns; + lp->rows_alloc = Rows; + lp->columns_alloc = Columns; + lp->sum_alloc = lp->sum; + + lp->names_used = FALSE; + + lp->obj_bound = DEF_INFINITE; + lp->bb_rule = FIRST_NI; + lp->break_at_int = FALSE; + lp->infinite = DEF_INFINITE; + lp->epsilon = DEF_EPSILON; + lp->epsb = DEF_EPSB; + lp->epsd = DEF_EPSD; + lp->epsel = DEF_EPSEL; + lp->non_zeros = Non_zeros; + lp->mat_alloc = Non_zeros; + lp->row_end_valid = FALSE; + + CFREE(lp->mat); + MALLOC(lp->mat, Non_zeros, matrec); + + CFREE(lp->col_no); + CALLOC(lp->col_no, Non_zeros, int); + + CFREE(lp->col_end); + CALLOC(lp->col_end, Columns + 1, int); + + CFREE(lp->row_end); + CALLOC(lp->row_end, Rows + 1, int); + + CFREE(lp->orig_rh); + CALLOC(lp->orig_rh, Rows + 1, REAL); + + CFREE(lp->rh); + CALLOC(lp->rh, Rows + 1, REAL); + + CFREE(lp->rhs); + CALLOC(lp->rhs, Rows + 1, REAL); + + CFREE(lp->must_be_int); + CALLOC(lp->must_be_int, Sum + 1, short); + + CFREE(lp->orig_upbo); + MALLOC(lp->orig_upbo, Sum + 1, REAL); + + CFREE(lp->upbo); + CALLOC(lp->upbo, Sum + 1, REAL); + + CFREE(lp->orig_lowbo); + CALLOC(lp->orig_lowbo, Sum + 1, REAL); + + CFREE(lp->lowbo); + CALLOC(lp->lowbo, Sum + 1, REAL); + + for(i = 0; i <= Sum; i++) + { + lp->orig_upbo[i] = lp->infinite; + lp->orig_lowbo[i] = 0; + } + lp->basis_valid = TRUE; + + CFREE(lp->bas); + CALLOC(lp->bas, Rows+1, int); + + CFREE(lp->basis); + CALLOC(lp->basis, Sum + 1, short); + + CFREE(lp->lower); + CALLOC(lp->lower, Sum + 1, short); + + for(i = 0; i <= Rows; i++) + { + lp->bas[i] = i; + lp->basis[i] = TRUE; + } + for(i = Rows + 1; i <= Sum; i++) + lp->basis[i] = FALSE; + for(i = 0 ; i <= Sum; i++) + lp->lower[i] = TRUE; + + lp->eta_valid = TRUE; + lp->eta_size = 0; + lp->eta_alloc = 10000; + lp->max_num_inv=DEFNUMINV; + + CFREE(lp->eta_value); + CALLOC(lp->eta_value, 10000, REAL); + + CFREE(lp->eta_row_nr); + CALLOC(lp->eta_row_nr, 10000, int); + + CFREE(lp->eta_col_end); + CALLOC(lp->eta_col_end, Rows + lp->max_num_inv + 1, int); + + lp->iter = 0; + lp->total_iter = 0; + + CFREE(lp->solution); + CALLOC(lp->solution, Sum + 1, REAL); + + CFREE(lp->best_solution); + CALLOC(lp->best_solution, Sum + 1, REAL); + + CFREE(lp->duals); + CALLOC(lp->duals, Rows + 1, REAL); + + lp->maximise = FALSE; + lp->floor_first = TRUE; + + lp->scaling_used = FALSE; + + CALLOC(lp->ch_sign, Rows + 1, short); + + for(i = 0; i <= Rows; i++) + lp->ch_sign[i] = FALSE; + + + st = lp->solve_states = NULL; + for (i=0; i < Sum + 2; i++) + { + if (st) /* There's an old state-saver to use; re-use it. */ + { + st->saved = 0; /* clear the in-use field */ + st->notint = 0; /* And the not-integer field */ + st = st->next; + } + else + { + st = (sstate *) malloc(sizeof(sstate)); + if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */ + st->next = lp->solve_states; + st->saved = 0; + st->notint = 0; /* And the not-integer field */ + lp->solve_states = st; + st = (sstate *)NULL; + } + } + + lp->valid = FALSE; + + return(lp); +} + + + +int lpmain (LispPTR lispresults) +{ + int i, failure; + float* results = (float *)Addr68k_from_LADDR(lispresults); + + /* solve it */ + + SolveCount = 0; /* reset the "timer", to limit length of a run */ + + if(failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure); + + /* solve it */ + + Level = 0; + + failure = milpsolve(Medley_lp->solve_states, Orig_upbo, Orig_lowbo, Basis, Lower, Bas); + + Medley_lp->eta_size = Eta_size; + Medley_lp->eta_alloc = Eta_alloc; + Medley_lp->num_inv = Num_inv; + + if ((failure == INT_SOLN) || (failure == OPTIMAL)) + for (i=0; i < Sum+1; i++) results[i] = Best_solution[i]; + + return(S_POSITIVE | failure); /* Tell him what happened so far. */ + +} /* main */ + + + + + +#ifdef OS4 +int lpsetup(rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound) + int rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound; +#else +int lpsetup (int rows, int cols, int nonnuls, + int rhs, int relns, int cend, int mat, int ints, + int lowbo, int upbo, int objbound) +#endif /* OS4 */ +{ + double obj_bound = -Infinite; + int failure, i, autoscale; + + if(failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure); + + /* mallopt(M_DEBUG, 1);*/ /*debugging!!!!*/ + + Rows = rows&0xFFFF; + Columns = cols&0xFFFF; + Non_zeros = nonnuls&0xFFFF; + + printf("Rows = %d. Cols = %d. Non-zeros = %d.\n", Rows, Columns, Non_zeros); + + Medley_lp = initmilp(Medley_lp); + readlispinput(Medley_lp, + Addr68k_from_LADDR(rhs), + Addr68k_from_LADDR(relns), + Addr68k_from_LADDR(cend), + Addr68k_from_LADDR(mat), + Addr68k_from_LADDR(ints), + Addr68k_from_LADDR(lowbo), + Addr68k_from_LADDR(upbo)); + + + auto_scale(Medley_lp); /* Scale values */ + + Medley_lp->total_iter = 0; + Medley_lp->max_level = 1; + Medley_lp->total_nodes = 0; + + set_globals(Medley_lp); /* Set global vars for the run */ + if(Isvalid(Medley_lp)) + { + if (objbound) + { + Medley_lp->obj_bound = Best_solution[0] = *((float *) Addr68k_from_LADDR(objbound)); + } + else if(Maximise && Medley_lp->obj_bound == Infinite) + Best_solution[0]=-Infinite; + else if(!Maximise && Medley_lp->obj_bound==-Infinite) + Best_solution[0] = Infinite; + else + Best_solution[0] = Medley_lp->obj_bound; + + Level = 0; + + if(!Medley_lp->basis_valid) + { + for(i = 0; i <= Medley_lp->rows; i++) + { + Medley_lp->basis[i] = TRUE; + Medley_lp->bas[i] = i; + } + for(i = Medley_lp->rows+1; i <= Medley_lp->sum; i++) + Medley_lp->basis[i] = FALSE; + for(i = 0; i <= Medley_lp->sum; i++) + Medley_lp->lower[i] = TRUE; + Medley_lp->basis_valid = TRUE; + } + + Medley_lp->eta_valid = FALSE; + } + return (0); +} /* lpsetup */ + + + + + + + + + + diff --git a/src/lpread.c b/src/lpread.c new file mode 100755 index 0000000..e17a23e --- /dev/null +++ b/src/lpread.c @@ -0,0 +1,137 @@ +/* $Id: lpread.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpread.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/* + ============================================================================ + NAME : read.c + PURPOSE : translation of lp-problem and storage in sparse matrix + SHORT : Subroutines for yacc program to store the input in an intermediate + data-structure. The yacc and lex programs translate the input. + First the problemsize is determined and the date is read into + an intermediate structure, then readinput fills the sparse matrix. + USAGE : call yyparse(); to start reading the input. + call readinput(); to fill the sparse matrix. + ============================================================================ + Rows : contains the amount of rows + 1 + Rows-1 is the amount of constraints (no bounds) + Rows also contains the rownr 0 which is the objectfunction + Columns : contains the amount of columns (different variable names + found in the constraints) + Nonnuls : contains the amount of nonnuls = sum of different entries + of all columns in the constraints and in the objectfunction + Hash_tab : contains all columnnames on the first level of the structure + the row information is kept under each column structure + in a linked list (also the objext funtion is in this structure) + Bound information is also stored under under the column name + First_rside : points to a linked list containing all relational operators + and the righthandside values of the constraints + the linked list is in reversed order with respect to the + rownumbers + ============================================================================ + */ +#include "lpkit.h" +#include "lpglob.h" + +extern REAL Infinite; + +/* + * transport the data from the intermediate structure to the sparse matrix + * and free the intermediate structure + */ + +#ifdef OS4 +readlispinput(lp, lisprhs, lisprelns, + lispcend, lispmat, lispints, lisplowbo, lispupbo) +lprec *lp; +float *lisprhs; +short *lisprelns; +int *lispcend; +lispmr *lispmat; +short *lispints; +float *lisplowbo; +float *lispupbo; +#else +void readlispinput(lprec *lp, + float *lisprhs, + short *lisprelns, + int *lispcend, + lispmr *lispmat, + short *lispints, + float *lisplowbo, + float *lispupbo) +#endif /* OS4 */ +{ + int i, j, k, index, nn_ind; + int x; + + /* initialize lower and upper bound arrays */ + for (i = 0; i <= Sum; i++) + { + lp->orig_lowbo[i] = lisplowbo[i]; + + if(lispupbo[i] > 1.0e20) lp->orig_upbo[i] = Infinite; + else lp->orig_upbo[i] = lispupbo[i]; + } + + for (i = Rows;i >= 0;i--) + { + lp->orig_rh[i] = lisprhs[i]; + } + + + + + memcpy(lp->col_end, lispcend, (Columns+1)*sizeof(int)); +#ifdef BYTESWAP + for (i=0; imust_be_int[i] = lispints[i^1]; +#else + memcpy(lp->must_be_int, lispints, (Sum+1)*sizeof(short)); +#endif /* BYTESWAP */ + + + for (i=0; i< Non_zeros; i++) + { + lp->mat[i].row_nr = lispmat[i].rownr; + lp->mat[i].value = lispmat[i].value; + } + + set_maxim(lp); /* We always maximize. */ + + for (i = Rows;i > 0;i--) + { +#ifdef BYTESWAP + set_constr_type(lp, i, lisprelns[i^1]); +#else + set_constr_type(lp, i, lisprelns[i]); +#endif /* BYTESWAP */ + } + +} /* readlispinput */ + + +/* ===================== END OF read.c ===================================== */ + + + + + diff --git a/src/lpsolve.c b/src/lpsolve.c new file mode 100755 index 0000000..158862e --- /dev/null +++ b/src/lpsolve.c @@ -0,0 +1,1564 @@ +/* $Id: lpsolve.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpsolve.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lpkit.h" +#include "lpglob.h" + +#include "lispemul.h" + +#ifdef DOS +#include "devif.h" +#endif /* DOS */ + +extern int KBDEventFlg; +extern int *KEYBUFFERING68k; +#ifdef DOS +extern MouseInterface currentmouse; +#endif /* DOS */ + +/* Globals used by solver */ +short JustInverted; +short Status; +short Doiter; +short DoInvert; +short Break_bb; + +void set_globals(lprec *lp) +{ + sstate *st; + int i; + + if(Lp != NULL) + Lp->active = FALSE; + Lp = lp; + Rows = lp->rows; + Columns = lp->columns; + Sum = Rows + Columns; + Non_zeros = lp->non_zeros; + Mat = lp->mat; + Col_no = lp->col_no; + Col_end = lp->col_end; + Row_end = lp->row_end; + Rh = lp->rh; + Rhs = lp->rhs; + Orig_rh = lp->orig_rh; + Must_be_int = lp->must_be_int; + Orig_upbo = lp->orig_upbo; + Orig_lowbo = lp->orig_lowbo; + Upbo = lp->upbo; + Lowbo = lp->lowbo; + Bas = lp->bas; + Basis = lp->basis; + Lower = lp->lower; + Eta_alloc = lp->eta_alloc; + Eta_size = lp->eta_size; + Num_inv = lp->num_inv; + Eta_value = lp->eta_value; + Eta_row_nr = lp->eta_row_nr; + Eta_col_end = lp->eta_col_end; + Solution = lp->solution; + Best_solution = lp->best_solution; + Infinite = lp->infinite; + Epsilon = lp->epsilon; + Epsb = lp->epsb; + Epsd = lp->epsd; + Epsel = lp->epsel; + + /* ?? MB */ + TREJ = TREJ; + TINV = TINV; + + Maximise = lp->maximise; + Floor_first = lp->floor_first; + lp->active = TRUE; + +} + +void ftran(int start, + int end, + REAL *pcol) +{ + int i, j, k, r; + REAL theta; + + for(i = start; i <= end; i++) + { + k = Eta_col_end[i] - 1; + r = Eta_row_nr[k]; + theta = pcol[r]; + if(theta != 0) + for(j = Eta_col_end[i - 1]; j < k; j++) + pcol[Eta_row_nr[j]] += theta * Eta_value[j]; /* cpu expensive line */ + pcol[r] *= Eta_value[k]; + } + /* round small values to zero */ + for(i = 0; i <= Rows; i++) + my_round(pcol[i], Epsel); +} /* ftran */ + +void btran(REAL *row) +{ + int i, j, k; + REAL f; + + for(i = Eta_size; i >= 1; i--) + { + f = 0; + k = Eta_col_end[i] - 1; + for(j = Eta_col_end[i - 1]; j <= k; j++) + f += row[Eta_row_nr[j]] * Eta_value[j]; + my_round(f, Epsel); + row[Eta_row_nr[k]] = f; + } +} /* btran */ + + +short Isvalid(lprec *lp) +{ + int i, j, *rownum, *colnum; + int *num, row_nr; + + if(!lp->row_end_valid) + { + MALLOC(num, lp->rows + 1, int); + MALLOC(rownum, lp->rows + 1, int); + for(i = 0; i <= lp->rows; i++) + { + num[i] = 0; + rownum[i] = 0; + } + for(i = 0; i < lp->non_zeros; i++) + rownum[lp->mat[i].row_nr]++; + lp->row_end[0] = 0; + for(i = 1; i <= lp->rows; i++) + lp->row_end[i] = lp->row_end[i - 1] + rownum[i]; + for(i = 1; i <= lp->columns; i++) + for(j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) + { + row_nr = lp->mat[j].row_nr; + if(row_nr != 0) + { + num[row_nr]++; + lp->col_no[lp->row_end[row_nr - 1] + num[row_nr]] = i; + } + } + free(num); + free(rownum); + lp->row_end_valid = TRUE; + } + if(lp->valid) + return(TRUE); + CALLOC(rownum, lp->rows + 1, int); + CALLOC(colnum, lp->columns + 1, int); + for(i = 1 ; i <= lp->columns; i++) + for(j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) + { + colnum[i]++; + rownum[lp->mat[j].row_nr]++; + } + for(i = 1; i <= lp->columns; i++) + if(colnum[i] == 0) + if(lp->names_used) + fprintf(stderr, "Warning: Variable %s not used in any constraints\n", + lp->col_name[i]); + else + fprintf(stderr, "Warning: Variable %d not used in any constaints\n", + i); + free(rownum); + free(colnum); + lp->valid = TRUE; + return(TRUE); +} + +static void resize_eta(void) +{ + Eta_alloc *= 2; + REALLOC(Eta_value, Eta_alloc, REAL); + Lp->eta_value = Eta_value; + REALLOC(Eta_row_nr, Eta_alloc, int); + Lp->eta_row_nr = Eta_row_nr; +} /* resize_eta */ + + +static void condensecol(int row_nr, + REAL *pcol) +{ + int i, elnr; + + elnr = Eta_col_end[Eta_size]; + + if(elnr + Rows + 2 > Eta_alloc) /* maximum local growth of Eta */ + resize_eta(); + + for(i = 0; i <= Rows; i++) + if(i != row_nr && pcol[i] != 0) + { + Eta_row_nr[elnr] = i; + Eta_value[elnr] = pcol[i]; + elnr++; + } + Eta_row_nr[elnr] = row_nr; + Eta_value[elnr] = pcol[row_nr]; + elnr++; + Eta_col_end[Eta_size + 1] = elnr; +} /* condensecol */ + + +static void addetacol(void) +{ + int i, j, k; + REAL theta; + + j = Eta_col_end[Eta_size]; + Eta_size++; + k = Eta_col_end[Eta_size]; + theta = 1 / (REAL) Eta_value[k - 1]; + Eta_value[k - 1] = theta; + for(i = j; i < k - 1; i++) + Eta_value[i] *= -theta; + JustInverted = FALSE; +} /* addetacol */ + +static void setpivcol(short lower, + int varin, + REAL *pcol) +{ + int i, colnr; + REAL f; + + if(lower) + f = 1; + else + f = -1; + for(i = 0; i <= Rows; i++) + pcol[i] = 0; + if(varin > Rows) + { + colnr = varin - Rows; + for(i = Col_end[colnr - 1]; i < Col_end[colnr]; i++) + pcol[Mat[i].row_nr] = Mat[i].value * f; + pcol[0] -= Extrad * f; + } + else + if(lower) + pcol[varin] = 1; + else + pcol[varin] = -1; + ftran(1, Eta_size, pcol); +} /* setpivcol */ + + +static void minoriteration(int colnr, + int row_nr) +{ + int i, j, k, wk, varin, varout, elnr; + REAL piv, theta; + + varin = colnr + Rows; + elnr = Eta_col_end[Eta_size]; + wk = elnr; + Eta_size++; + if(Extrad != 0) + { + Eta_row_nr[elnr] = 0; + Eta_value[elnr] = -Extrad; + elnr++; + } + for(j = Col_end[colnr - 1] ; j < Col_end[colnr]; j++) + { + k = Mat[j].row_nr; + if(k == 0 && Extrad != 0) + Eta_value[Eta_col_end[Eta_size -1]] += Mat[j].value; + else if(k != row_nr) + { + Eta_row_nr[elnr] = k; + Eta_value[elnr] = Mat[j].value; + elnr++; + } + else + piv = Mat[j].value; + } + Eta_row_nr[elnr] = row_nr; + Eta_value[elnr] = 1 / (REAL) piv; + elnr++; + theta = Rhs[row_nr] / (REAL) piv; + Rhs[row_nr] = theta; + for(i = wk; i < elnr - 1; i++) + Rhs[Eta_row_nr[i]] -= theta * Eta_value[i]; + varout = Bas[row_nr]; + Bas[row_nr] = varin; + Basis[varout] = FALSE; + Basis[varin] = TRUE; + for(i = wk; i < elnr - 1; i++) + Eta_value[i] /= - (REAL) piv; + Eta_col_end[Eta_size] = elnr; +} /* minoriteration */ + +static void rhsmincol(REAL theta, + int row_nr, + int varin) +{ + int i, j, k, varout; + REAL f; + + if(row_nr > Rows + 1) + { + fprintf(stderr, "Error: rhsmincol called with row_nr: %d, rows: %d\n", + row_nr, Rows); + fprintf(stderr, "This indicates numerical instability\n"); + /* exit(1); */ ERROR(ERR_NUM); + } + j = Eta_col_end[Eta_size]; + k = Eta_col_end[Eta_size + 1]; + for(i = j; i < k; i++) + { + f = Rhs[Eta_row_nr[i]] - theta * Eta_value[i]; + my_round(f, Epsb); + Rhs[Eta_row_nr[i]] = f; + } + Rhs[row_nr] = theta; + varout = Bas[row_nr]; + Bas[row_nr] = varin; + Basis[varout] = FALSE; + Basis[varin] = TRUE; +} /* rhsmincol */ + + +void invert(void) +{ + int i, j, v, wk, numit, varnr, row_nr, colnr, varin; + REAL f, theta; + REAL *pcol; + short *frow; + short *fcol; + int *rownum, *col, *row; + int *colnum; + + if(Lp->print_at_invert) + fprintf(stderr, "Start Invert iter %7d eta_size %4d rhs[0] %16.4f \n", + Lp->iter, Eta_size,-Rhs[0]); + + CALLOC(rownum, Rows + 1, int); + CALLOC(col, Rows + 1, int); + CALLOC(row, Rows + 1, int); + CALLOC(pcol, Rows + 1, REAL); + CALLOC(frow, Rows + 1, short); + CALLOC(fcol, Columns + 1, short); + CALLOC(colnum, Columns + 1, int); + + for(i = 0; i <= Rows; i++) + frow[i] = TRUE; + + for(i = 0; i < Columns; i++) + fcol[i] = FALSE; + + for(i = 0; i < Rows; i++) + rownum[i] = 0; + + for(i = 0; i <= Columns; i++) + colnum[i] = 0; + + for(i = 0; i <= Rows; i++) + if(Bas[i] > Rows) + fcol[Bas[i] - Rows - 1] = TRUE; + else + frow[Bas[i]] = FALSE; + + for(i = 1; i <= Rows; i++) + if(frow[i]) + for(j = Row_end[i - 1] + 1; j <= Row_end[i]; j++) + { + wk = Col_no[j]; + if(fcol[wk - 1]) + { + colnum[wk]++; + rownum[i - 1]++; + } + } + for(i = 1; i <= Rows; i++) + Bas[i] = i; + for(i = 1; i <= Rows; i++) + Basis[i] = TRUE; + for(i = 1; i <= Columns; i++) + Basis[i + Rows] = FALSE; + + for(i = 0; i <= Rows; i++) + Rhs[i] = Rh[i]; + + for(i = 1; i <= Columns; i++) + { + varnr = Rows + i; + if(!Lower[varnr]) + { + theta = Upbo[varnr]; + for(j = Col_end[i - 1]; j < Col_end[i]; j++) + Rhs[Mat[j].row_nr] -= theta * Mat[j].value; + } + } + for(i = 1; i <= Rows; i++) + if(!Lower[i]) + Rhs[i] -= Upbo[i]; + Eta_size = 0; + v = 0; + row_nr = 0; + Num_inv = 0; + numit = 0; + while(v < Rows) + { + row_nr++; + if(row_nr > Rows) + row_nr = 1; + v++; + if(rownum[row_nr - 1] == 1) + if(frow[row_nr]) + { + v = 0; + j = Row_end[row_nr - 1] + 1; + while(!(fcol[Col_no[j] - 1])) + j++; + colnr = Col_no[j]; + fcol[colnr - 1] = FALSE; + colnum[colnr] = 0; + for(j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) + if(frow[Mat[j].row_nr]) + rownum[Mat[j].row_nr - 1]--; + frow[row_nr] = FALSE; + minoriteration(colnr, row_nr); + } + } + v = 0; + colnr = 0; + while(v Columns) + colnr = 1; + v++; + if(colnum[colnr] == 1) + if(fcol[colnr - 1]) + { + v = 0; + j = Col_end[colnr - 1] + 1; + while(!(frow[Mat[j - 1].row_nr])) + j++; + row_nr = Mat[j - 1].row_nr; + frow[row_nr] = FALSE; + rownum[row_nr - 1] = 0; + for(j = Row_end[row_nr - 1] + 1; j <= Row_end[row_nr]; j++) + if(fcol[Col_no[j] - 1]) + colnum[Col_no[j]]--; + fcol[colnr - 1] = FALSE; + numit++; + col[numit - 1] = colnr; + row[numit - 1] = row_nr; + } + } + for(j = 1; j <= Columns; j++) + if(fcol[j - 1]) + { + fcol[j - 1] = FALSE; + setpivcol(Lower[Rows + j], j + Rows, pcol); + row_nr = 1; + while((!(frow[row_nr] && pcol[row_nr])) && row_nr <= Rows) + row_nr++; /* this sometimes sets row_nr to Rows + 1 and makes + rhsmincol crash. Solved in 2.0? MB */ + if(row_nr == Rows + 1) + { printf("Inverting failed"); ERROR(ERR_NUM); } + frow[row_nr] = FALSE; + condensecol(row_nr, pcol); + theta = Rhs[row_nr] / (REAL) pcol[row_nr]; + rhsmincol(theta, row_nr, Rows + j); + addetacol(); + } + for(i = numit - 1; i >= 0; i--) + { + colnr = col[i]; + row_nr = row[i]; + varin = colnr + Rows; + for(j = 0; j <= Rows; j++) + pcol[j] = 0; + for(j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) + pcol[Mat[j].row_nr] = Mat[j].value; + pcol[0] -= Extrad; + condensecol(row_nr, pcol); + theta = Rhs[row_nr] / (REAL) pcol[row_nr]; + rhsmincol(theta, row_nr, varin); + addetacol(); + } + for(i = 1; i <= Rows; i++) + my_round(Rhs[i], Epsb); + if(Lp->print_at_invert) + fprintf(stderr, + "End Invert eta_size %4d rhs[0] %16.4f\n", + Eta_size,-Rhs[0]); + + JustInverted = TRUE; + DoInvert = FALSE; + free(rownum); + free(col); + free(row); + free(pcol); + free(frow); + free(fcol); + free(colnum); +} /* invert */ + +static short colprim(int *colnr, + short minit, + REAL *drow) +{ + int varnr, i, j; + REAL f, dpiv; + + dpiv = -Epsd; + (*colnr) = 0; + if(!minit) + { + for(i = 1; i <= Sum; i++) + drow[i] = 0; + drow[0] = 1; + btran(drow); + for(i = 1; i <= Columns; i++) + { + varnr = Rows + i; + if(!Basis[varnr]) + if(Upbo[varnr] > 0) + { + f = 0; + for(j = Col_end[i - 1]; j < Col_end[i]; j++) + f += drow[Mat[j].row_nr] * Mat[j].value; + drow[varnr] = f; + } + } + for(i = 1; i <= Sum; i++) + my_round(drow[i], Epsd); + } + for(i = 1; i <= Sum; i++) + if(!Basis[i]) + if(Upbo[i] > 0) + { + if(Lower[i]) + f = drow[i]; + else + f = -drow[i]; + if(f < dpiv) + { + dpiv = f; + (*colnr) = i; + } + } + if(Lp->trace) + if((*colnr)>0) + fprintf(stderr, "col_prim:%7d, reduced cost: % 18.10f\n", + (*colnr), dpiv); + else + fprintf(stderr, + "col_prim: no negative reduced costs found, optimality!\n"); + if(*colnr == 0) + { + Doiter = FALSE; + DoInvert = FALSE; + Status = OPTIMAL; + } + return((*colnr) > 0); +} /* colprim */ + +static short rowprim(int colnr, + int *row_nr, + REAL *theta, + REAL *pcol) +{ + int i; + REAL f, quot; + + (*row_nr) = 0; + (*theta) = Infinite; + for(i = 1; i <= Rows; i++) + { + f = pcol[i]; + if(my_abs(f) < TREJ) + f = 0; + if(f != 0) + { + quot = 2 * Infinite; + if(f > 0) + quot = Rhs[i] / (REAL) f; + else + if(Upbo[Bas[i]] < Infinite) + quot = (Rhs[i] - Upbo[Bas[i]]) / (REAL) f; + my_round(quot, Epsel); + if(quot < (*theta)) + { + (*theta) = quot; + (*row_nr) = i; + } + } + } + if((*row_nr) == 0) + for(i = 1; i <= Rows; i++) + { + f = pcol[i]; + if(f != 0) + { + quot = 2 * Infinite; + if(f > 0) + quot = Rhs[i] / (REAL) f; + else + if(Upbo[Bas[i]] < Infinite) + quot = (Rhs[i] - Upbo[Bas[i]]) / (REAL) f; + my_round(quot, Epsel); + if(quot < (*theta)) + { + (*theta) = quot; + (*row_nr) = i; + } + } + } + + if((*theta) < 0) + { + fprintf(stderr, "Warning: Numerical instability, qout = %f\n", (*theta)); + fprintf(stderr, "pcol[%d] = % 18.10f, rhs[%d] = % 18.8f , upbo = % f\n", + (*row_nr), f, (*row_nr), Rhs[(*row_nr)], Upbo[Bas[(*row_nr)]]); + } + if((*row_nr) == 0) + { + if(Upbo[colnr] == Infinite) + { + Doiter = FALSE; + DoInvert = FALSE; + Status = UNBOUNDED; + } + else + { + i = 1; + while(pcol[i] >= 0 && i <= Rows) + i++; + if(i > Rows) /* empty column with upperbound! */ + { + Lower[colnr] = FALSE; + Rhs[0] += Upbo[colnr]*pcol[0]; + Doiter = FALSE; + DoInvert = FALSE; + } + else if(pcol[i]<0) + { + (*row_nr) = i; + } + } + } + if((*row_nr) > 0) + Doiter = TRUE; + if(Lp->trace) + fprintf(stderr, "row_prim:%7d, pivot element:% 18.10f\n", (*row_nr), + pcol[(*row_nr)]); + + return((*row_nr) > 0); +} /* rowprim */ + +static short rowdual(int *row_nr) +{ + int i; + REAL f, g, minrhs; + short artifs; + + (*row_nr) = 0; + minrhs = -Epsb; + i = 0; + artifs = FALSE; + while(i < Rows && !artifs) + { + i++; + f = Upbo[Bas[i]]; + if(f == 0 && (Rhs[i] != 0)) + { + artifs = TRUE; + (*row_nr) = i; + } + else + { + if(Rhs[i] < f - Rhs[i]) + g = Rhs[i]; + else + g = f - Rhs[i]; + if(g < minrhs) + { + minrhs = g; + (*row_nr) = i; + } + } + } + + if(Lp->trace) + { + if((*row_nr)>0) + { + fprintf(stderr, + "row_dual:%7d, rhs of selected row: % 18.10f\n", + (*row_nr), Rhs[(*row_nr)]); + if(Upbo[Bas[(*row_nr)]] < Infinite) + fprintf(stderr, + " upper bound of basis variable: % 18.10f\n", + Upbo[Bas[(*row_nr)]]); + } + else + fprintf(stderr, "row_dual: no infeasibilities found\n"); + } + + return((*row_nr)>0); +} /* rowdual */ + +static short coldual(int row_nr, + int *colnr, + short minit, + REAL *prow, + REAL *drow) +{ + int i, j, r, varnr; + REAL theta, quot, pivot, d, f, g; + + Doiter = FALSE; + if(!minit) + { + for(i = 0; i <= Rows; i++) + { + prow[i] = 0; + drow[i] = 0; + } + drow[0] = 1; + prow[row_nr] = 1; + for(i = Eta_size; i >= 1; i--) + { + d = 0; + f = 0; + r = Eta_row_nr[Eta_col_end[i] - 1]; + for(j = Eta_col_end[i - 1]; j < Eta_col_end[i]; j++) + { + /* this is where the program consumes most cpu time */ + f += prow[Eta_row_nr[j]] * Eta_value[j]; + d += drow[Eta_row_nr[j]] * Eta_value[j]; + } + my_round(f, Epsel); + prow[r] = f; + my_round(d, Epsel); + drow[r] = d; + } + for(i = 1; i <= Columns; i++) + { + varnr = Rows + i; + if(!Basis[varnr]) + { + d = - Extrad * drow[0]; + f = 0; + for(j = Col_end[i - 1]; j < Col_end[i]; j++) + { + d = d + drow[Mat[j].row_nr] * Mat[j].value; + f = f + prow[Mat[j].row_nr] * Mat[j].value; + } + drow[varnr] = d; + prow[varnr] = f; + } + } + for(i = 0; i <= Sum; i++) + { + my_round(prow[i], Epsel); + my_round(drow[i], Epsd); + } + } + if(Rhs[row_nr] > Upbo[Bas[row_nr]]) + g = -1; + else + g = 1; + pivot = 0; + (*colnr) = 0; + theta = Infinite; + for(i = 1; i <= Sum; i++) + { + if(Lower[i]) + d = prow[i] * g; + else + d = -prow[i] * g; + if((d < 0) && (!Basis[i]) && (Upbo[i] > 0)) + { + if(Lower[i]) + quot = -drow[i] / (REAL) d; + else + quot = drow[i] / (REAL) d; + if(quot < theta) + { + theta = quot; + pivot = d; + (*colnr) = i; + } + else if((quot == theta) && (my_abs(d) > my_abs(pivot))) + { + pivot = d; + (*colnr) = i; + } + } + } + if(Lp->trace) + fprintf(stderr, "col_dual:%7d, pivot element: % 18.10f\n", (*colnr), + prow[(*colnr)]); + + if((*colnr)>0) + Doiter = TRUE; + + return((*colnr) > 0); +} /* coldual */ + +static void iteration(int row_nr, + int varin, + REAL *theta, + REAL up, + short *minit, + short *low, + short primal, + REAL *pcol) +{ + int i, k, varout; + REAL f; + REAL pivot; + + Lp->iter++; + (*minit) = (*theta) > (up + Epsb); + if((*minit)) + { + (*theta) = up; + (*low) = !(*low); + } + k = Eta_col_end[Eta_size + 1]; + pivot = Eta_value[k - 1]; + for(i = Eta_col_end[Eta_size]; i < k; i++) + { + f = Rhs[Eta_row_nr[i]] - (*theta) * Eta_value[i]; + my_round(f, Epsb); + Rhs[Eta_row_nr[i]] = f; + } + if(!(*minit)) + { + Rhs[row_nr] = (*theta); + varout = Bas[row_nr]; + Bas[row_nr] = varin; + Basis[varout] = FALSE; + Basis[varin] = TRUE; + if(primal && pivot < 0) + Lower[varout] = FALSE; + if(!(*low) && up < Infinite) + { + (*low) = TRUE; + Rhs[row_nr] = up - Rhs[row_nr]; + for(i = Eta_col_end[Eta_size]; i < k; i++) + Eta_value[i] = -Eta_value[i]; + } + addetacol(); + Num_inv++; + } + if(Lp->trace) + { + fprintf(stderr, "Theta = %16.4g ", (*theta)); + if((*minit)) + { + if(!Lower[varin]) + fprintf(stderr, + "Iteration:%6d, variable%5d changed from 0 to its upper bound of %12f\n", + Lp->iter, varin, Upbo[varin]); + else + fprintf(stderr, + "Iteration:%6d, variable%5d changed its upper bound of %12f to 0\n", + Lp->iter, varin, Upbo[varin]); + } + else + fprintf(stderr, + "Iteration:%6d, variable%5d entered basis at:% 18.10f\n", + Lp->iter, varin, Rhs[row_nr]); + if(!primal) + { + f = 0; + for(i = 1; i <= Rows; i++) + if(Rhs[i] < 0) + f -= Rhs[i]; + else + if(Rhs[i] > Upbo[Bas[i]]) + f += Rhs[i] - Upbo[Bas[i]]; + fprintf(stderr, "feasibility gap of this basis:% 18.10f\n", + (double)f); + } + else + fprintf(stderr, + "objective function value of this feasible basis: % 18.10f\n", + (double)Rhs[0]); + } +} /* iteration */ + + +static int solvelp(void) +{ + int i, j, iter, varnr; + REAL f, theta; + short primal; + REAL *drow, *prow, *Pcol; + short minit; + int colnr, row_nr; + short *test; + + CALLOC(drow, Sum + 1, REAL); + CALLOC(prow, Sum + 1, REAL); + CALLOC(Pcol, Rows + 1, REAL); + CALLOC(test, Sum +1, short); + + Lp->iter = 0; + minit = FALSE; + Status = RUNNING; + DoInvert = FALSE; + Doiter = FALSE; + i = 0; + primal = TRUE; + while(i != Rows && primal) + { + i++; + primal = Rhs[i] >= 0 && Rhs[i] <= Upbo[Bas[i]]; + } + if(Lp->trace) + { + if(primal) + fprintf(stderr, "Start at feasible basis\n"); + else + fprintf(stderr, "Start at infeasible basis\n"); + } + if(!primal) + { + drow[0] = 1; + for(i = 1; i <= Rows; i++) + drow[i] = 0; + Extrad = 0; + for(i = 1; i <= Columns; i++) + { + varnr = Rows + i; + drow[varnr] = 0; + for(j = Col_end[i - 1]; j < Col_end[i]; j++) + if(drow[Mat[j].row_nr] != 0) + drow[varnr] += drow[Mat[j].row_nr] * Mat[j].value; + if(drow[varnr] < Extrad) + Extrad = drow[varnr]; + } + } + else + Extrad = 0; + if(Lp->trace) + fprintf(stderr, "Extrad = %f\n", Extrad); + minit = FALSE; + + while(Status == RUNNING) + { + Doiter = FALSE; + DoInvert = FALSE; + + if(primal) + { + if(colprim(&colnr, minit, drow)) + { + setpivcol(Lower[colnr], colnr, Pcol); + if(rowprim(colnr, &row_nr, &theta, Pcol)) + condensecol(row_nr, Pcol); + + } + } + else /* not primal */ + { + if(!minit) + rowdual(&row_nr); + if(row_nr > 0 ) + { + if(coldual(row_nr, &colnr, minit, prow, drow)) + { + setpivcol(Lower[colnr], colnr, Pcol); + /* getting div by zero here ... MB */ + if(Pcol[row_nr] == 0) + { + fprintf(stderr, + "An attempt was made to divide by zero (Pcol[%d])\n", + row_nr); + fprintf(stderr, + "This indicates numerical instability\n"); + Doiter = FALSE; + if(!JustInverted) + { + fprintf(stderr, "Reinverting Eta\n"); + DoInvert = TRUE; + } + else + { + fprintf(stderr, "Can't reinvert, failure\n"); + Status = FAILURE; + } + } + else + { + condensecol(row_nr, Pcol); + f = Rhs[row_nr] - Upbo[Bas[row_nr]]; + if(f > 0) + { + theta = f / (REAL) Pcol[row_nr]; + if(theta <= Upbo[colnr]) + Lower[Bas[row_nr]] = !Lower[Bas[row_nr]]; + } + else /* f <= 0 */ + theta = Rhs[row_nr] / (REAL) Pcol[row_nr]; + } + } + else + Status = INFEASIBLE; + } + else + { + primal = TRUE; + Doiter = FALSE; + Extrad = 0; + DoInvert = TRUE; + } + } + if(Doiter) + iteration(row_nr, colnr, &theta, Upbo[colnr], &minit, &Lower[colnr], + primal, Pcol); + if(Num_inv >= Lp->max_num_inv) + DoInvert = TRUE; + if(DoInvert) + { + if(Lp->print_at_invert) + fprintf(stderr, "Inverting: Primal = %d\n", primal); + invert(); + } + } + + Lp->total_iter += Lp->iter; + + free(drow); + free(prow); + free(Pcol); + free(test); + + return(Status); +} /* solvelp */ + + +static short is_int(REAL value) +{ + REAL tmp; + + tmp = value - (REAL)floor((double)value); + if(tmp < Epsilon) + return(TRUE); + if(tmp > (1 - Epsilon)) + return(TRUE); + return(FALSE); +} /* is_int */ + +static void construct_solution(REAL *sol) +{ + int i, j, basi; + REAL f; + + /* zero all results of rows */ + memset(sol, '\0', (Rows + 1) * sizeof(REAL)); + + if(Lp->scaling_used) + { + for(i = Rows + 1; i <= Sum; i++) + sol[i] = Lowbo[i] * Lp->scale[i]; + for(i = 1; i <= Rows; i++) + { + basi = Bas[i]; + if(basi > Rows) + sol[basi] += Rhs[i] * Lp->scale[basi]; + } + for(i = Rows + 1; i <= Sum; i++) + if(!Basis[i] && !Lower[i]) + sol[i] += Upbo[i] * Lp->scale[i]; + + for(j = 1; j <= Columns; j++) + { + f = sol[Rows + j]; + if(f != 0) + for(i = Col_end[j - 1]; i < Col_end[j]; i++) + sol[Mat[i].row_nr] += (f / Lp->scale[Rows+j]) + * (Mat[i].value / Lp->scale[Mat[i].row_nr]); + } + + for(i = 0; i <= Rows; i++) + { + if(my_abs(sol[i]) < Epsb) + sol[i] = 0; + else + if(Lp->ch_sign[i]) + sol[i] = -sol[i]; + } + } + else + { + for(i = Rows + 1; i <= Sum; i++) + sol[i] = Lowbo[i]; + for(i = 1; i <= Rows; i++) + { + basi = Bas[i]; + if(basi > Rows) + sol[basi] += Rhs[i]; + } + for(i = Rows + 1; i <= Sum; i++) + if(!Basis[i] && !Lower[i]) + sol[i] += Upbo[i]; + for(j = 1; j <= Columns; j++) + { + f = sol[Rows + j]; + if(f != 0) + for(i = Col_end[j - 1]; i < Col_end[j]; i++) + sol[Mat[i].row_nr] += f * Mat[i].value; + } + + for(i = 0; i <= Rows; i++) + { + if(my_abs(sol[i]) < Epsb) + sol[i] = 0; + else + if(Lp->ch_sign[i]) + sol[i] = -sol[i]; + } + } +} /* construct_solution */ + +static void calculate_duals(void) +{ + int i; + + /* initialise */ + for(i = 1; i <= Rows; i++) + Lp->duals[i] = 0; + Lp->duals[0] = 1; + btran(Lp->duals); + if(Lp->scaling_used) + for(i = 1; i <= Rows; i++) + Lp->duals[i] *= Lp->scale[i]/Lp->scale[0]; + + /* the dual values are the reduced costs of the slacks */ + /* When the slack is at its upper bound, change the sign. Can this happen? */ + for(i = 1; i <= Rows; i++) + { + if(Lp->basis[i]) + Lp->duals[i] = 0; + else if( Lp->ch_sign[0] == Lp->ch_sign[i]) + Lp->duals[i] = -Lp->duals[i]; + } +} + +int milpsolve(sstate *st, + REAL *upbo, + REAL *lowbo, + short *sbasis, + short *slower, + int *sbas) +{ + int i, j, failure, notint, is_worse; + REAL theta, tmpreal; + + + /* First, check for "time-out", time to give control back to lisp */ + if(st->next) st = st->next; + else + for (i=0; i< 20; i++) + { /* Need more state-saving space, so create 20 more. */ + sstate * newst; + newst = (sstate *)malloc(sizeof(sstate)); + if (!st) ERROR(ERR_ST); + newst->next = st->next; + st->next = newst; + newst->saved = newst->notint = 0; + } + + if (st->saved) + { if (st->saved == ST_SOLN) { st->saved = 0; return(OPTIMAL); } } + else if (SolveCount++ > 100) return(TIMEOUT); /* Time out every 100 LP solves */ + else if ((KBDEventFlg>0) && *KEYBUFFERING68k == ATOM_T) + return(TIMEOUT); /* Time out on key/mouse clicks */ +#ifdef DOS + else if (currentmouse->Cursor.Moved) return(TIMEOUT); /* Time out if mouse moves in DOS */ +#endif /* DOS */ + + if(Break_bb) + return(BREAK_BB); + Level++; + Lp->total_nodes++; + if(Level > Lp->max_level) + Lp->max_level = Level; + + if (! st->saved) + { /* We're coming into this fresh, rather than returnin from a TIMEOUT. */ + /* make fresh copies of upbo, lowbo, rh as solving changes them */ + memcpy(Upbo, upbo, (Sum + 1) * sizeof(REAL)); + memcpy(Lowbo, lowbo, (Sum + 1) * sizeof(REAL)); + memcpy(Basis, sbasis, (Sum + 1) * sizeof(short)); + memcpy(Lower, slower, (Sum + 1) * sizeof(short)); + memcpy(Bas, sbas, (Rows + 1) * sizeof(int)); + memcpy(Rh, Orig_rh, (Rows + 1) * sizeof(REAL)); + + if(Lp->anti_degen) + { + for(i = 1; i <= Columns; i++) + { + tmpreal = (REAL) (rand() % 100 * 0.00001); + if(tmpreal > Epsb) + Lowbo[i + Rows] -= tmpreal; + tmpreal = (REAL) (rand() % 100 * 0.00001); + if(tmpreal > Epsb) + Upbo[i + Rows] += tmpreal; + } + Lp->eta_valid = FALSE; + } + + if(!Lp->eta_valid) + { + for(i = 1; i <= Columns; i++) + if(Lowbo[Rows + i] != 0) + { + theta = Lowbo[ Rows + i]; + if(Upbo[Rows + i]eta_valid = TRUE; + } + + failure = solvelp(); + + if(Lp->anti_degen) + { + memcpy(Upbo, upbo, (Sum + 1) * sizeof(REAL)); + memcpy(Lowbo, lowbo, (Sum + 1) * sizeof(REAL)); + memcpy(Rh, Orig_rh, (Rows + 1) * sizeof(REAL)); + + for(i = 1; i <= Columns; i++) + if(Lowbo[Rows + i] != 0) + { + theta = Lowbo[ Rows + i]; + if(Upbo[Rows + i]eta_valid = TRUE; + failure = solvelp(); + } + + if(failure == INFEASIBLE && Lp->verbose) + fprintf(stderr, "level%4d INF\n", Level); + } + else failure = OPTIMAL; /* Coming back thru after a timeout; we got OPTIMAL last time, so do it again. */ + + + if(failure == OPTIMAL) /* there is a solution */ + { + if (!st->saved) + { + construct_solution(Solution); + + + /* if this solution is worse than the best sofar, this branch must die */ + if(Maximise) + is_worse = Solution[0] <= Best_solution[0]; + else /* minimising! */ + is_worse = Solution[0] >= Best_solution[0]; + + if(is_worse) + { + if(Lp->verbose) + fprintf(stderr, "level%4d OPT NOB value %f bound %f\n", + Level, Solution[0], Best_solution[0]); + Level--; + return(MILP_FAIL); + } + + /* check if solution contains enough ints */ + st->notint = notint = 0; + if(Lp->bb_rule == FIRST_NI) + { + notint = 0; + i = Rows + 1; + while(i <= Sum && notint == 0) + { + if(Must_be_int[i] && !is_int(Solution[i])) + if(lowbo[i] == upbo[i]) /* this var is already fixed */ + { + fprintf(stderr, + "Warning: integer var %d is already fixed at %d, but has non-integer value %g\n", + i - Rows, (int)lowbo[i], Solution[i]); + fprintf(stderr, "Perhaps the -e option should be used\n"); + } + else + st->notint = notint = i; + i++; + } + } + if(Lp->bb_rule == RAND_NI) + { + int nr_not_int, select_not_int; + nr_not_int = 0; + for(i = Rows + 1; i <= Sum; i++) + if(Must_be_int[i] && !is_int(Solution[i])) + nr_not_int++; + if(nr_not_int == 0) + notint = 0; + else + { + select_not_int=(rand() % nr_not_int) + 1; + i = Rows + 1; + while(select_not_int > 0) + { + if(Must_be_int[i] && !is_int(Solution[i])) + select_not_int--; + i++; + } + st->notint = notint = i - 1; + } + } + } + else notint = st->notint; /* Coming back in, use old value. */ + + if(Lp->verbose == TRUE) + if(notint) + fprintf(stderr, "level %3d OPT value %f\n", Level, Solution[0]); + else + fprintf(stderr, "level %3d OPT INT value %f\n", Level, Solution[0]); + + if(notint) /* there is at least one value not yet int */ + { + /* set up two new problems */ + REAL *new_upbo, *new_lowbo; + REAL new_bound; + short *new_lower,*new_basis; + int *new_bas; + int resone, restwo; + + /* allocate room for them */ + MALLOC(new_upbo, Sum + 1, REAL); + MALLOC(new_lowbo, Sum + 1, REAL); + MALLOC(new_lower, Sum + 1, short); + MALLOC(new_basis, Sum + 1, short); + MALLOC(new_bas, Rows + 1, int); + memcpy(new_upbo, upbo, (Sum + 1) * sizeof(REAL)); + memcpy(new_lowbo, lowbo, (Sum + 1) * sizeof(REAL)); + memcpy(new_lower, Lower, (Sum + 1) * sizeof(short)); + memcpy(new_basis, Basis, (Sum + 1) * sizeof(short)); + memcpy(new_bas, Bas, (Rows +1) * sizeof(int)); + + + if(Floor_first) + { + if (st->saved) new_bound = st->bound; + else st->bound = new_bound = ceil(Solution[notint]) - 1; + /* this bound might conflict */ + if (st->saved >= ST_HI) resone = st->res1; /* We got the upper bound earlier; skip lower */ + else if(new_bound < lowbo[notint]) + { + resone = MILP_FAIL; + } + else /* bound feasible */ + { + new_upbo[notint] = new_bound; + Lp->eta_valid = FALSE; + st->saved = ST_LO; + resone = milpsolve(st, new_upbo, lowbo, new_basis, new_lower, + new_bas); + Lp->eta_valid = FALSE; + st->res1 = resone; + if ((resone == INT_SOLN) || (resone == TIMEOUT)) + { + Level--; + free(new_upbo); + free(new_lowbo); + free(new_lower); + free(new_basis); + free(new_bas); + return resone; + } + + } + new_bound += 1; + if(new_bound > upbo[notint]) + { + restwo = MILP_FAIL; + } + else /* bound feasible */ + { + new_lowbo[notint] = new_bound; + st->saved = ST_HI; + Lp->eta_valid = FALSE; + restwo = milpsolve(st, upbo, new_lowbo, new_basis, new_lower, + new_bas); + Lp->eta_valid = FALSE; + st->res2 = restwo; + if ((restwo == INT_SOLN) || (restwo == TIMEOUT)) + { + Level--; + free(new_upbo); + free(new_lowbo); + free(new_lower); + free(new_basis); + free(new_bas); + return restwo; + } + + } + } + else /* take ceiling first */ + { + new_bound = ceil(Solution[notint]); + /* this bound might conflict */ + if(new_bound > upbo[notint]) + { + resone = MILP_FAIL; + } + else /* bound feasible */ + { + new_lowbo[notint] = new_bound; + Lp->eta_valid = FALSE; + resone = milpsolve(st, upbo, new_lowbo, new_basis, new_lower, + new_bas); + Lp->eta_valid = FALSE; + } + new_bound -= 1; + if(new_bound < lowbo[notint]) + { + restwo = MILP_FAIL; + } + else /* bound feasible */ + { + new_upbo[notint] = new_bound; + Lp->eta_valid = FALSE; + restwo = milpsolve(st, new_upbo, lowbo, new_basis, new_lower, + new_bas); + Lp->eta_valid = FALSE; + } + } + if(resone && restwo) /* both failed and must have been infeasible */ + failure = INFEASIBLE; + else + failure = OPTIMAL; + + free(new_upbo); + free(new_lowbo); + free(new_basis); + free(new_lower); + free(new_bas); + } + else /* all required values are int */ + { + + if(Maximise) + is_worse = Solution[0] < Best_solution[0]; + else + is_worse = Solution[0] > Best_solution[0]; + + if(!is_worse) /* Current solution better */ + { + if(Lp->debug || (Lp->verbose && !Lp->print_sol)) + fprintf(stderr, + "*** new best solution: old: %g, new: %g ***\n", + (double)Best_solution[0], (double)Solution[0]); + memcpy(Best_solution, Solution, (Sum + 1) * sizeof(REAL)); + calculate_duals(); + if(Lp->print_sol) + print_solution(Lp); + if(Lp->break_at_int) + { + if(Maximise && (Best_solution[0] > Lp->break_value)) + Break_bb = TRUE; + if(!Maximise && (Best_solution[0] < Lp->break_value)) + Break_bb = TRUE; + } + st->saved = INT_SOLN; /* Tell caller we found -a- solution */ + failure = INT_SOLN; /* & remember that fact for next time. */ + } + } + } + + /* failure can have the values OPTIMAL, UNBOUNDED and INFEASIBLE. */ + /* INT_SOLN, TIMEOUT, or MILP_FAIL */ + Level--; + st->saved = 0; /* We're done at this level, so mark the ST empty. */ + return(failure); +} /* milpsolve */ + + + +int solve(lprec *lp) +{ + int result, i; + + if(!lp->active) + set_globals(lp); + + lp->total_iter = 0; + lp->max_level = 1; + lp->total_nodes = 0; + + if(Isvalid(lp)) + { + if(Maximise && lp->obj_bound == Infinite) + Best_solution[0]=-Infinite; + else if(!Maximise && lp->obj_bound==-Infinite) + Best_solution[0] = Infinite; + else + Best_solution[0] = lp->obj_bound; + + Level = 0; + + if(!lp->basis_valid) + { + for(i = 0; i <= lp->rows; i++) + { + lp->basis[i] = TRUE; + lp->bas[i] = i; + } + for(i = lp->rows+1; i <= lp->sum; i++) + lp->basis[i] = FALSE; + for(i = 0; i <= lp->sum; i++) + lp->lower[i] = TRUE; + lp->basis_valid = TRUE; + } + + lp->eta_valid = FALSE; + Break_bb = FALSE; + result = milpsolve(lp->solve_states, Orig_upbo, Orig_lowbo, Basis, Lower, Bas); + lp->eta_size = Eta_size; + lp->eta_alloc = Eta_alloc; + lp->num_inv = Num_inv; + } + return(result); +} + +/* * * * lag_solve used to be here * * * * */ + + diff --git a/src/lptran.c b/src/lptran.c new file mode 100755 index 0000000..4b03993 --- /dev/null +++ b/src/lptran.c @@ -0,0 +1,98 @@ +/* $Id: lptran.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lptran.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "lpdefs.h" +#include "lpglobl.h" + +#ifdef alliant +#pragma global safe (Eta_rownr, Eta_value) +#pragma global assoc +#endif + + +#ifdef OS4 +ftran(start, end, pcol) +int start, end; double *pcol; +#else +void ftran(int start, + int end, + double *pcol) +#endif +{ + int i, j; + int k, r; + double theta; + +#ifdef alliant +#pragma safe (pcol, Endetacol) +#pragma routine permutation (Eta_rownr) +#endif + + if (Verbose) + printf("ftran\n"); + for (i = start; i <= end; i++) + { + k = Endetacol[i] - 1; + r = Eta_rownr[k]; + theta = pcol[r]; + if (theta != 0) + for (j = Endetacol[i - 1]; j < k; j++) + pcol[Eta_rownr[j]] += theta * Eta_value[j]; /* cpu expensive line */ + pcol[r] *= Eta_value[k]; + } + +#ifdef alliant +#pragma loop novector +#endif + + for (i = 0; i <= Rows; i++) + if (abs(pcol[i]) < EPSEL) + pcol[i] = 0; +} /* ftran */ + + +#ifdef OS4 +btran(numc, row) +int numc; double *row; +#else +void btran(int numc, + double *row) +#endif +{ + int i, j, k; + double f; + +#ifdef alliant +#pragma safe (row, Endetacol) +#endif + + if (Verbose) + printf("btran\n"); + for (i = numc; i >= 1; i--) + { + f = 0; + k = Endetacol[i]; + for (j = Endetacol[i - 1]; j < k; j++) + f += row[Eta_rownr[j]] * Eta_value[j]; + if (abs(f) < EPSEL) + row[Eta_rownr[k - 1]] = 0; + else + row[Eta_rownr[k - 1]] = f; + } +} /* btran */ diff --git a/src/lpwrite.c b/src/lpwrite.c new file mode 100755 index 0000000..e4bbf8f --- /dev/null +++ b/src/lpwrite.c @@ -0,0 +1,134 @@ +/* $Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "lpdefs.h" +#include "lpglobl.h" +#ifdef OS4 +#include +#include +#else +#include +#endif + +/* this is the ansi version ... */ + +#ifdef OS4 +print_solution(stream, sol) +FILE *stream; double *sol; +#else +void print_solution(FILE *stream, double *sol) +#endif +{ + int i; + + fprintf(stream, "Value of objective function: %16.5g\n", sol[0]); + + /* print normal variables */ + for (i = Rows + 1; i <= Sum; i++) + if (0 != sol[i]) fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]); + + /* print dual variables */ + if(Verbose || Print_duals) + { + fprintf(stream, "\nValues of the dual variables:\n"); + for (i = 1; i <= Rows; i++) + if (0 != sol[i]) fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]); + } +} /* print_solution */ + + +#ifdef OS4 +print_indent() +#else +void print_indent(void) +#endif +{ + int i; + + fprintf(stderr, "%2d", Level); + for(i = Level; i > 0; i--) + fprintf(stderr, "--"); + fprintf(stderr, "> "); +} /* print_indent */ + + +#ifdef OS4 +debug_print_solution(sol) +double *sol; +#else +void debug_print_solution(double *sol) +#endif +{ + int i; + + if(Debug) + for (i = 0; i <= Sum; i++) + { + print_indent(); + if (sol[i] != 0) fprintf(stderr, "%-10s%16.5g\n", Names[i], sol[i]); + } +} /* debug_print_solution */ + + +#ifdef OS4 +debug_print_bounds(upbo, lowbo) +double *upbo, *lowbo; +#else +void debug_print_bounds(double *upbo, double *lowbo) +#endif +{ + int i; + + if(Debug) + for(i = Rows + 1; i <= Sum; i++) + { + if(lowbo[i] != 0) + { + print_indent(); + fprintf(stderr, "%s > %10.3g\n", Names[i], lowbo[i]); + } + if(upbo[i] != INFINITE) + { + print_indent(); + fprintf(stderr, "%s < %10.3g\n", Names[i], upbo[i]); + } + } +} /* debug_print_bounds */ + + +#ifdef OS4 +debug_print(format) +char *format; +{ return 0; } +#else +void debug_print(char *format, ...) +{ + va_list ap; + + if(Debug) + { + va_start(ap, format); + print_indent(); + vfprintf(stderr, format, ap); + fputc('\n', stderr); + va_end(ap); + } +} /* debug_print */ + +#endif diff --git a/src/lpytab.c b/src/lpytab.c new file mode 100755 index 0000000..997eb43 --- /dev/null +++ b/src/lpytab.c @@ -0,0 +1,740 @@ +/* $Id: lpytab.c,v 1.2 1999/01/03 02:07:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpytab.c,v 1.2 1999/01/03 02:07:21 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifndef BIGATOMS + +# define VAR 257 +# define CONS 258 +# define SIGN 259 +# define AR_M_OP 260 +# define RE_OP 261 +# define END_C 262 +# define COMMA 263 +# define COLON 264 +# define MINIMISE 265 +# define MAXIMISE 266 + +# line 10 "lp.y" +#include "lpdefines.h" +#include "lpglobals.h" + +/* globals */ +char Last_var[NAMELEN]; +char Constraint_name[NAMELEN]; +int Lin_term_count; +double f; +int x; +int Sign; +int isign; /* internal_sign variable to make sure nothing goes wrong */ + /* with lookahead */ +int make_neg; /* is true after the relational operator is seen in order */ + /* to remember if lin_term stands before or after re_op */ +#define yyclearin yychar = -1 +#define yyerrok yyerrflag = 0 +extern int yychar; +extern int yyerrflag; +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 150 +#endif +#ifndef YYSTYPE +#define YYSTYPE int +#endif +YYSTYPE yylval, yyval; +typedef int yytabelem; +# define YYERRCODE 256 + +# line 193 "lp.y" + +# include "lexyy.c" +yytabelem yyexca[] ={ +-1, 1, + 0, -1, + -2, 0, +-1, 31, + 257, 15, + -2, 31, + }; +# define YYNPROD 38 +# define YYLAST 87 +yytabelem yyact[]={ + + 10, 11, 9, 34, 36, 51, 56, 57, 5, 4, + 50, 52, 23, 44, 36, 24, 35, 10, 20, 18, + 26, 10, 20, 27, 31, 20, 18, 10, 11, 9, + 15, 20, 18, 10, 11, 42, 40, 17, 14, 16, + 19, 32, 13, 8, 6, 8, 8, 38, 25, 21, + 22, 7, 47, 37, 43, 29, 33, 30, 46, 45, + 28, 12, 3, 2, 1, 0, 39, 0, 0, 0, + 0, 0, 41, 0, 0, 48, 0, 0, 0, 49, + 0, 0, 0, 0, 53, 55, 54 }; +yytabelem yypact[]={ + + -1000, -1000, -257, -227, -230, -230, -1000, -247, -1000, -1000, + -1000, -237, -233, -1000, -1000, -261, -245, -1000, -1000, -1000, + -237, -1000, -1000, -1000, -1000, -224, -1000, -221, -1000, -1000, + -222, -261, -1000, -244, -1000, -1000, -1000, -236, -224, -1000, + -1000, -1000, -1000, -252, -1000, -240, -240, -236, -1000, -1000, + -1000, -1000, -251, -1000, -255, -1000, -1000, -1000 }; +yytabelem yypgo[]={ + + 0, 64, 63, 62, 61, 60, 42, 38, 59, 39, + 58, 57, 41, 56, 54, 37, 53, 52, 40, 51, + 48, 47, 44 }; +yytabelem yyr1[]={ + + 0, 2, 1, 4, 4, 6, 8, 6, 10, 7, + 5, 5, 11, 11, 12, 13, 14, 14, 14, 9, + 16, 9, 17, 9, 15, 15, 19, 20, 19, 21, + 19, 18, 18, 18, 3, 3, 3, 22 }; +yytabelem yyr2[]={ + + 0, 1, 8, 2, 4, 2, 1, 8, 1, 11, + 0, 2, 2, 4, 7, 3, 3, 5, 7, 2, + 1, 6, 1, 8, 2, 3, 2, 1, 6, 1, + 8, 3, 5, 7, 5, 5, 2, 5 }; +yytabelem yychk[]={ + + -1000, -1, -2, -3, 266, 265, -22, -19, -18, 259, + 257, 258, -4, -6, -7, 257, -9, -15, 259, -18, + 258, -22, -22, 259, 262, -20, 257, 260, -5, -6, + -11, 257, -12, -13, 264, 261, 259, -16, -21, -18, + 257, -12, 257, -14, 257, -8, -10, -17, -15, -18, + 262, 257, 263, -7, -9, -15, 257, 262 }; +yytabelem yydef[]={ + + 1, -2, 0, 0, 0, 0, 36, 0, 26, 27, + 31, 0, 10, 3, 5, 31, 0, 19, 20, 24, + 25, 34, 35, 29, 37, 0, 32, 0, 2, 4, + 11, -2, 12, 0, 6, 8, 22, 0, 0, 28, + 33, 13, 15, 0, 16, 0, 0, 0, 21, 30, + 14, 17, 0, 7, 0, 23, 18, 9 }; +typedef struct { char *t_name; int t_val; } yytoktype; +#ifndef YYDEBUG +# define YYDEBUG 0 /* don't allow debugging */ +#endif + +#if YYDEBUG + +yytoktype yytoks[] = +{ + "VAR", 257, + "CONS", 258, + "SIGN", 259, + "AR_M_OP", 260, + "RE_OP", 261, + "END_C", 262, + "COMMA", 263, + "COLON", 264, + "MINIMISE", 265, + "MAXIMISE", 266, + "-unknown-", -1 /* ends search */ +}; + +char * yyreds[] = +{ + "-no such reduction-", + "inputfile : /* empty */", + "inputfile : objective_function constraints int_declarations", + "constraints : constraint", + "constraints : constraints constraint", + "constraint : real_constraint", + "constraint : VAR COLON", + "constraint : VAR COLON real_constraint", + "real_constraint : x_lineair_sum RE_OP", + "real_constraint : x_lineair_sum RE_OP x_lineair_sum END_C", + "int_declarations : /* empty */", + "int_declarations : real_int_decls", + "real_int_decls : int_declaration", + "real_int_decls : real_int_decls int_declaration", + "int_declaration : int_declarator vars END_C", + "int_declarator : VAR", + "vars : VAR", + "vars : vars VAR", + "vars : vars COMMA VAR", + "x_lineair_sum : x_lineair_term", + "x_lineair_sum : SIGN", + "x_lineair_sum : SIGN x_lineair_term", + "x_lineair_sum : x_lineair_sum SIGN", + "x_lineair_sum : x_lineair_sum SIGN x_lineair_term", + "x_lineair_term : lineair_term", + "x_lineair_term : CONS", + "lineair_sum : lineair_term", + "lineair_sum : SIGN", + "lineair_sum : SIGN lineair_term", + "lineair_sum : lineair_sum SIGN", + "lineair_sum : lineair_sum SIGN lineair_term", + "lineair_term : VAR", + "lineair_term : CONS VAR", + "lineair_term : CONS AR_M_OP VAR", + "objective_function : MAXIMISE real_of", + "objective_function : MINIMISE real_of", + "objective_function : real_of", + "real_of : lineair_sum END_C", +}; +#endif /* YYDEBUG */ +/* + * Copyright 1987 Silicon Graphics, Inc. - All Rights Reserved + */ + +#ident "$Revision: 1.2 $" + +/* +** Skeleton parser driver for yacc output +*/ + +/* +** yacc user known macros and defines +*/ +#define YYERROR goto yyerrlab +#define YYACCEPT return(0) +#define YYABORT return(1) +#define YYBACKUP( newtoken, newvalue )\ +{\ + if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ + {\ + yyerror( "syntax error - cannot backup" );\ + goto yyerrlab;\ + }\ + yychar = newtoken;\ + yystate = *yyps;\ + yylval = newvalue;\ + goto yynewstate;\ +} +#define YYRECOVERING() (!!yyerrflag) +#ifndef YYDEBUG +# define YYDEBUG 1 /* make debugging available */ +#endif + +/* +** user known globals +*/ +int yydebug; /* set to 1 to get debugging */ + +/* +** driver internal defines +*/ +#define YYFLAG (-1000) + +/* +** global variables used by the parser +*/ +YYSTYPE yyv[ YYMAXDEPTH ]; /* value stack */ +int yys[ YYMAXDEPTH ]; /* state stack */ + +YYSTYPE *yypv; /* top of value stack */ +int *yyps; /* top of state stack */ + +int yystate; /* current state */ +int yytmp; /* extra var (lasts between blocks) */ + +int yynerrs; /* number of errors */ +int yyerrflag; /* error recovery flag */ +int yychar; /* current input token number */ + + + +/* +** yyparse - return 0 if worked, 1 if syntax error not recovered from +*/ +int +yyparse() +{ + register YYSTYPE *yypvt; /* top of value stack for $vars */ + + /* + ** Initialize externals - yyparse may be called more than once + */ + yypv = &yyv[-1]; + yyps = &yys[-1]; + yystate = 0; + yytmp = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = -1; + + goto yystack; + { + register YYSTYPE *yy_pv; /* top of value stack */ + register int *yy_ps; /* top of state stack */ + register int yy_state; /* current state */ + register int yy_n; /* internal state number info */ + + /* + ** get globals into registers. + ** branch to here only if YYBACKUP was called. + */ + yynewstate: + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + goto yy_newstate; + + /* + ** get globals into registers. + ** either we just started, or we just finished a reduction + */ + yystack: + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + + /* + ** top of for (;;) loop while no reductions done + */ + yy_stack: + /* + ** put a state and value onto the stacks + */ +#if YYDEBUG + /* + ** if debugging, look up token value in list of value vs. + ** name pairs. 0 and negative (-1) are special values. + ** Note: linear search is used since time is not a real + ** consideration while debugging. + */ + if ( yydebug ) + { + register int yy_i; + + printf( "State %d, token ", yy_state ); + if ( yychar == 0 ) + printf( "end-of-file\n" ); + else if ( yychar < 0 ) + printf( "-none-\n" ); + else + { + for ( yy_i = 0; yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val == yychar ) + break; + } + printf( "%s\n", yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + if ( ++yy_ps >= &yys[ YYMAXDEPTH ] ) /* room on stack? */ + { + yyerror( "yacc stack overflow" ); + YYABORT; + } + *yy_ps = yy_state; + *++yy_pv = yyval; + + /* + ** we have a new state - find out what to do + */ + yy_newstate: + if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) + goto yydefault; /* simple state */ +#if YYDEBUG + /* + ** if debugging, need to mark whether new token grabbed + */ + yytmp = yychar < 0; +#endif + if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) + yychar = 0; /* reached EOF */ +#if YYDEBUG + if ( yydebug && yytmp ) + { + register int yy_i; + + printf( "Received token " ); + if ( yychar == 0 ) + printf( "end-of-file\n" ); + else if ( yychar < 0 ) + printf( "-none-\n" ); + else + { + for ( yy_i = 0; yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val == yychar ) + break; + } + printf( "%s\n", yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) + goto yydefault; + if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ + { + yychar = -1; + yyval = yylval; + yy_state = yy_n; + if ( yyerrflag > 0 ) + yyerrflag--; + goto yy_stack; + } + + yydefault: + if ( ( yy_n = yydef[ yy_state ] ) == -2 ) + { +#if YYDEBUG + yytmp = yychar < 0; +#endif + if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) + yychar = 0; /* reached EOF */ +#if YYDEBUG + if ( yydebug && yytmp ) + { + register int yy_i; + + printf( "Received token " ); + if ( yychar == 0 ) + printf( "end-of-file\n" ); + else if ( yychar < 0 ) + printf( "-none-\n" ); + else + { + for ( yy_i = 0; + yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val + == yychar ) + { + break; + } + } + printf( "%s\n", yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + /* + ** look through exception table + */ + { + register int *yyxi = yyexca; + + while ( ( *yyxi != -1 ) || + ( yyxi[1] != yy_state ) ) + { + yyxi += 2; + } + while ( ( *(yyxi += 2) >= 0 ) && + ( *yyxi != yychar ) ) + ; + if ( ( yy_n = yyxi[1] ) < 0 ) + YYACCEPT; + } + } + + /* + ** check for syntax error + */ + if ( yy_n == 0 ) /* have an error */ + { + /* no worry about speed here! */ + switch ( yyerrflag ) + { + case 0: /* new error */ + yyerror( "syntax error" ); + goto skip_init; + yyerrlab: + /* + ** get globals into registers. + ** we have a user generated syntax type error + */ + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + yynerrs++; + skip_init: + case 1: + case 2: /* incompletely recovered error */ + /* try again... */ + yyerrflag = 3; + /* + ** find state where "error" is a legal + ** shift action + */ + while ( yy_ps >= yys ) + { + yy_n = yypact[ *yy_ps ] + YYERRCODE; + if ( yy_n >= 0 && yy_n < YYLAST && + yychk[yyact[yy_n]] == YYERRCODE) { + /* + ** simulate shift of "error" + */ + yy_state = yyact[ yy_n ]; + goto yy_stack; + } + /* + ** current state has no shift on + ** "error", pop stack + */ +#if YYDEBUG +# define _POP_ "Error recovery pops state %d, uncovers state %d\n" + if ( yydebug ) + printf( _POP_, *yy_ps, + yy_ps[-1] ); +# undef _POP_ +#endif + yy_ps--; + yy_pv--; + } + /* + ** there is no state on stack with "error" as + ** a valid shift. give up. + */ + YYABORT; + case 3: /* no shift yet; eat a token */ +#if YYDEBUG + /* + ** if debugging, look up token in list of + ** pairs. 0 and negative shouldn't occur, + ** but since timing doesn't matter when + ** debugging, it doesn't hurt to leave the + ** tests here. + */ + if ( yydebug ) + { + register int yy_i; + + printf( "Error recovery discards " ); + if ( yychar == 0 ) + printf( "token end-of-file\n" ); + else if ( yychar < 0 ) + printf( "token -none-\n" ); + else + { + for ( yy_i = 0; + yytoks[yy_i].t_val >= 0; + yy_i++ ) + { + if ( yytoks[yy_i].t_val + == yychar ) + { + break; + } + } + printf( "token %s\n", + yytoks[yy_i].t_name ); + } + } +#endif /* YYDEBUG */ + if ( yychar == 0 ) /* reached EOF. quit */ + YYABORT; + yychar = -1; + goto yy_newstate; + } + }/* end if ( yy_n == 0 ) */ + /* + ** reduction by production yy_n + ** put stack tops, etc. so things right after switch + */ +#if YYDEBUG + /* + ** if debugging, print the string that is the user's + ** specification of the reduction which is just about + ** to be done. + */ + if ( yydebug ) + printf( "Reduce by (%d) \"%s\"\n", + yy_n, yyreds[ yy_n ] ); +#endif + yytmp = yy_n; /* value to switch over */ + yypvt = yy_pv; /* $vars top of value stack */ + /* + ** Look in goto table for next state + ** Sorry about using yy_state here as temporary + ** register variable, but why not, if it works... + ** If yyr2[ yy_n ] doesn't have the low order bit + ** set, then there is no action to be done for + ** this reduction. So, no saving & unsaving of + ** registers done. The only difference between the + ** code just after the if and the body of the if is + ** the goto yy_stack in the body. This way the test + ** can be made before the choice of what to do is needed. + */ + { + /* length of production doubled with extra bit */ + register int yy_len = yyr2[ yy_n ]; + + if ( !( yy_len & 01 ) ) + { + yy_len >>= 1; + yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ + yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + + *( yy_ps -= yy_len ) + 1; + if ( yy_state >= YYLAST || + yychk[ yy_state = + yyact[ yy_state ] ] != -yy_n ) + { + yy_state = yyact[ yypgo[ yy_n ] ]; + } + goto yy_stack; + } + yy_len >>= 1; + yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ + yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + + *( yy_ps -= yy_len ) + 1; + if ( yy_state >= YYLAST || + yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) + { + yy_state = yyact[ yypgo[ yy_n ] ]; + } + } + /* save until reenter driver code */ + yystate = yy_state; + yyps = yy_ps; + yypv = yy_pv; + } + /* + ** code supplied by user is placed in this switch + */ + switch( yytmp ) + { + +case 1: +# line 32 "lp.y" +{ + init_read(); + isign = 0; + make_neg = 0; +} break; +case 6: +# line 49 "lp.y" +{ + add_constraint_name(Last_var, Rows); +} break; +case 8: +# line 58 "lp.y" +{ + store_re_op(); + make_neg = 1; +} break; +case 9: +# line 64 "lp.y" +{ + if(Lin_term_count == 0) + { + fprintf(stderr, "WARNING line %d: constraint contains no variables\n", + yylineno); + null_tmp_store(); + } + + if(Lin_term_count > 1) + Rows++; + + if(Lin_term_count == 1) + store_bounds(); + + Lin_term_count = 0; + isign = 0 ; + make_neg = 0; + Constraint_name[0] = '\0'; +} break; +case 14: +# line 93 "lp.y" +{Having_ints = 1;} break; +case 15: +# line 96 "lp.y" +{/* check_decl(yytext);*/} break; +case 16: +# line 99 "lp.y" +{add_int_var((char *)yytext);} break; +case 17: +# line 100 "lp.y" +{add_int_var((char *)yytext);} break; +case 18: +# line 101 "lp.y" +{add_int_var((char *)yytext);} break; +case 20: +# line 106 "lp.y" +{ + isign = Sign; +} break; +case 22: +# line 112 "lp.y" +{ + isign = Sign; +} break; +case 25: +# line 120 "lp.y" +{ + if ( (isign || !make_neg) + && !(isign && !make_neg)) /* but not both! */ + f = -f; + rhs_store(f); + isign = 0; +} break; +case 27: +# line 131 "lp.y" +{ + isign = Sign; +} break; +case 29: +# line 137 "lp.y" +{ + isign = Sign; +} break; +case 31: +# line 144 "lp.y" +{ + if ( (isign || make_neg) + && !(isign && make_neg)) /* but not both! */ + var_store(Last_var, Rows, (double)-1); + else + var_store(Last_var, Rows, (double)1); + isign = 0; +} break; +case 32: +# line 154 "lp.y" +{ + if ( (isign || make_neg) + && !(isign && make_neg)) /* but not both! */ + f = -f; + var_store(Last_var, Rows, f); + isign = 0; +} break; +case 33: +# line 164 "lp.y" +{ + if ( (isign || make_neg) + && !(isign && make_neg)) /* but not both! */ + f = -f; + var_store(Last_var, Rows, f); + isign = 0; +} break; +case 34: +# line 174 "lp.y" +{ + Maximise = TRUE; +} break; +case 35: +# line 178 "lp.y" +{ + Maximise = FALSE; +} break; +case 37: +# line 186 "lp.y" +{ + Rows++; + Lin_term_count = 0; + isign = 0; + make_neg = 0; +} break; + } + goto yystack; /* reset registers in driver code */ +} +#endif diff --git a/src/lpytab.c.X b/src/lpytab.c.X new file mode 100644 index 0000000..e69de29 diff --git a/src/lsthandl.c b/src/lsthandl.c new file mode 100755 index 0000000..b118913 --- /dev/null +++ b/src/lsthandl.c @@ -0,0 +1,145 @@ +/* $Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +/************************************************************************/ +/* + Including : OP_fmemb + OP_listget + +*/ +/**********************************************************************/ + +#include "version.h" + +#include "lispemul.h" +#include "emlglob.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "cell.h" + + +/***********************************************************************/ +/* N_OP_fmemb */ +/**********************************************************************/ + +LispPTR +N_OP_fmemb(register LispPTR item, register LispPTR tos) +{ /* OP 34Q */ + + while(Listp(tos)) { + if ( item == car(tos) ) return tos; + tos = cdr(tos); + /* if we get an interrupt, punt so we can handle it safely */ + if (!Irq_Stk_End) { + TIMER_EXIT(tos); + } + } + if(tos) ERROR_EXIT(tos); + return tos; + +} /* N_OP_fmemb end */ + + + +/***********************************************************************/ +/* + Func Name : fmemb(item,list) + >>For User programming<< + NOTE: You should not handle long list, because it doesn't care + about interrupt. + +*/ +/**********************************************************************/ + +LispPTR +fmemb(register LispPTR item, register LispPTR list) +{ + + while(Listp(list)) { + if(item == car(list)) + return (list); + list = cdr(list); + } + + if(list) return(list); + return (list); + +} /* fmemb end */ + + + +/***********************************************************************/ +/* + Func Name : N_OP_listget + Opcode : 47Q + */ +/**********************************************************************/ + +extern struct cadr_cell cadr(LispPTR cell_adr); /** declaration only **/ + +#define SAVE_ERROR_EXIT2(topcstk,tos) {Scratch_CSTK=topcstk; ERROR_EXIT(tos);} + +#define S_N_CHECKANDCADR2(sour,dest,tos,tcstk) \ +{register LispPTR parm = sour; \ + if(GetTypeNumber(parm) != TYPE_LISTP){ \ + SAVE_ERROR_EXIT2(tcstk,tos); \ + } else \ + dest = cadr(parm); \ +} + + + +LispPTR +N_OP_listget(register LispPTR plist, register LispPTR tos) +{ + REGISTER struct cadr_cell cadrobj; + + while ( plist != NIL_PTR ) { + S_N_CHECKANDCADR2(plist, cadrobj, tos, plist); + + if ( cadrobj.car_cell == tos ) { + + if(cadrobj.cdr_cell == NIL_PTR) return NIL_PTR; + + if(Listp(cadrobj.cdr_cell)) + return(car(cadrobj.cdr_cell)); + else /* must punt in case car/cdrerr */ + SAVE_ERROR_EXIT2(plist,tos); + } + + if( ! Listp(cadrobj.cdr_cell) ) + { /* this list ended before we found prop */ + return ( NIL_PTR ); + } + + S_N_CHECKANDCADR2(cadrobj.cdr_cell, cadrobj, tos, plist); + plist = cadrobj.cdr_cell; + + if (!Irq_Stk_End) { + /* for continuation, it becomes plist on next time */ + Scratch_CSTK = plist; + TIMER_EXIT(tos); + } + } + + return(NIL_PTR); + +}/* N_OP_listget end */ + + diff --git a/src/main.c b/src/main.c new file mode 100755 index 0000000..7ba0a77 --- /dev/null +++ b/src/main.c @@ -0,0 +1,888 @@ +/* $Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/* + * main.c + * This file includes main() + */ + +#include "lispemul.h" +#include "dbprint.h" +#include +#ifndef DOS +#include +#include +#else +#define MAXPATHLEN 128 +#define R_OK 04 +#define index strchr +#define rindex strrchr +#include +#include +#include +#endif /* DOS */ + +#ifndef NOETHER +#ifndef USE_DLPI +#include /* needed for Ethernet stuff below */ +#endif /* USE_DLPI */ +#endif /* NOETHER */ +#include +#ifndef SYSVONLY +#ifndef DOS +#include +#endif /* DOS */ +#else /* SYSVONLY -IS- ON */ +#include +#include +#endif /* SYSVONLY */ + +#ifndef DOS +#include +#endif /* DOS */ + +#include +#ifndef DOS +#include +#endif /* DOS */ + +#ifdef RISCOS +#include +#endif /* RISCOS */ + + +#ifdef ISC +#include +#include +#endif + +#include + +#include "emlglob.h" +#include "address.h" +#include "adr68k.h" +#include "stack.h" +#include "return.h" + +#include "lspglob.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "ifpage.h" +#include "iopage.h" + +#include "debug.h" +#include "profile.h" + +#include "timeout.h" + +DLword *Lisp_world; /* lispworld */ + +/********** 68k address for Lisp Space **********/ +DLword *Atomspace; +DLword *Stackspace; +DLword *Plistspace; +DLword *DTDspace; +DLword *MDStypetbl; +DLword *AtomHT; +DLword *Pnamespace; +DLword *AtomSpace; +DLword *Defspace; +DLword *Valspace; +DLword *Spospspace; +DLword *Snegspace; + +/********** For Virtual Memory Management **********/ +#ifdef BIGVM +LispPTR *FPtoVP; +#else +DLword *FPtoVP; +#endif /* BIGVM */ +DLword *PAGEMap; +DLword *PageMapTBL; +DLword *LockedPageTable; + +/********** For Interface to LispMicro/Device **********/ +DLword *IOCBPage; +IOPAGE *IOPage; +IFPAGE *InterfacePage; +MISCSTATS *MiscStats; + +/********** UFN Table **********/ +DLword *UFNTable; + +/********** Tables for GC **********/ +#ifdef BIGVM +LispPTR *HTmain; +LispPTR *HToverflow; +LispPTR *HTbigcount; +LispPTR *HTcoll; +#else +DLword *HTmain; +DLword *HToverflow; +DLword *HTbigcount; +DLword *HTcoll; +#endif /* BIGVM */ + +/********** Display **********/ +DLword *DisplayRegion; +int DisplayInitialized = NIL; + +DLword *Arrayspace; +DLword *MDS_space_bottom; +DLword *PnCharspace; +struct dtd *ListpDTD; + + +/********** For Lisp Emulator **********/ +struct state MachineState; + +/**********************************/ +/*** Share val with LISP code ******/ + +DLword *MDS_free_page; +DLword *Next_MDSpage; +DLword *Next_Array; +/*******************************************/ + +/** CACHE LISP SYSVAL ***/ +LispPTR *Next_MDSpage_word; +LispPTR *Next_Array_word; +LispPTR *MDS_free_page_word; + +LispPTR *Reclaim_cnt_word ; + +/*** Cache Values for reclaimer by Tomtom 30-Sep-1987 ***/ +LispPTR *GcDisabled_word; +LispPTR *CdrCoding_word; +LispPTR *FreeBlockBuckets_word; +LispPTR *Array_Block_Checking_word; +LispPTR *ArrayMerging_word; +LispPTR *ArraySpace_word; +LispPTR *ArraySpace2_word; +LispPTR *ArrayFrLst_word; +LispPTR *ArrayFrLst2_word; +LispPTR *Hunk_word; +LispPTR *System_Buffer_List_word; + +/*** The end of the addition of cache values on reclaimer ***/ + + +/*** cache values for the top level reclaimer's implementation ***/ + +LispPTR *GcMess_word; +LispPTR *ReclaimMin_word; +LispPTR *GcTime1_word; +LispPTR *GcTime2_word; +LispPTR *MaxTypeNumber_word; + +/*** The end of the addition of cache values for top reclaimer by Tomtom + 15-Oct-1987 ***/ + +/* Pointers for closure caching */ + +LispPTR *Package_from_Index_word; +LispPTR *Package_from_Name_word; +LispPTR *Keyword_Package_word; +LispPTR *Closure_Cache_Enabled_word; +LispPTR *Closure_Cache_word; +LispPTR *Deleted_Implicit_Hash_Slot_word; +LispPTR First_index; + +/*** The end of Pointers for closure caching ***/ + +/* CACHE values for 32Mb MDS/Array by Take */ +LispPTR *STORAGEFULLSTATE_word; +LispPTR *STORAGEFULL_word; +LispPTR *PENDINGINTERRUPT_word; +LispPTR *LeastMDSPage_word; +LispPTR *SecondMDSPage_word; +LispPTR *SecondArrayPage_word; +LispPTR *INTERRUPTSTATE_word; +LispPTR *SYSTEMCACHEVARS_word; +LispPTR *MACHINETYPE_word; + +LispPTR STORAGEFULLSTATE_index; +LispPTR *LASTVMEMFILEPAGE_word; +LispPTR *VMEM_FULL_STATE_word ; + +/** Array for N-tran **/ + +int native_load_address; +LispPTR native_closure_env = NOBIND_PTR; + +/** Pipes for Unix Interface **/ +int UnixPipeIn; +int UnixPipeOut; +int UnixPID; +int please_fork = 1; + +/*** STACK handle staff(Takeshi) **/ +LispPTR *STACKOVERFLOW_word; +LispPTR *GuardStackAddr_word; +LispPTR *LastStackAddr_word; +LispPTR *NeedHardreturnCleanup_word; + +/*** Ethernet stuff (JRB) **/ +#ifndef NOETHER +extern int ether_fd; +extern u_char ether_host[6]; +#endif /* NOETHER */ + +extern struct sockaddr_nit snit; + +#ifdef INIT +int for_makeinit = 1; +#else +int for_makeinit = 0; +#endif /* INIT */ + +int kbd_for_makeinit = 0; +int save_argc; +char **save_argv; +int display_max = 65536*16*2; + +/* diagnostic flag for sysout dumping */ +extern int maxpages; + +/** For call makepathname inside main() **/ +extern int *Lisp_errno; +extern int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ + +char keystring[128]; + +#define FALSE 0 +#define TRUE !FALSE + +char *getenv(); +int Lisp_Xinitialized = FALSE; +char sysout_name[1024]; /* Set by read_Xoption, in the X version. */ +int sysout_size = 0; /* ditto */ + +#if defined(DOS) || defined (XWINDOW) +#include "devif.h" +extern DspInterface currentdsp; +#endif /* DOS || XWINDOW */ + +extern long MDate; +extern int nokbdflag; +extern int nomouseflag; +#ifdef DOS +extern void dispatch(); + +int dosdisplaymode = 0; +int twobuttonflag = FALSE; +int eurokbd = TRUE; /* Assume eurokbd by default. */ +char *helpstring = "\n\ +medley [sysout-name] [] ...\n\ +Where are:\n\ + sysout-name The filename of your sysout.(see manual.)\n\ + -m Virtual memory size in Mega Bytes(from 8 to 32)\n\ + -vga Use standard VGA 640x480 screen resolution\n\ + -vesa102 Use VESA 800x600 screen resolution\n\ + -vesa104 Use VESA 1024x768 screen resolution\n\ + -2button Force two button mouse handling\n\ + -3button Force three button mouse handling\n\ + -noeurokbd Force old style kbd handling (for 2.0 and earlier sysouts)\n\ + -eurokbd Force new style kbd handling (for 2.01 and later sysouts)\n\ + -nokbd Turn the kbd handling off (for debugging only)\n\ + -nomouse Turn the mouse handling off (for debugging only)\n\ + -info Print general info about the system\n\ + -help Print this message\n"; +#elif XWINDOW +char *helpstring = "\n\ + either setenv LDESRCESYSOUT or do:\n\ + medley [] []\n\ + -info Print general info about the system\n\ + -help Print this message\n\ + -k access-key Your access key\n\ + -d[isplay] host:srv.scr The host, X server and screen you want Medley on\n\ + -bw The Medley screen borderwidth\n\ + -g[eometry] ] The Medley screen geometry\n\ + -sc[reen] x] The Medley screen geometry\n"; +#else /* not DOS, not XWINDOW */ +char *helpstring = "\n\ + either setenv LDESRCESYSOUT or do:\n\ + lde[ether] [sysout-name] [-k access-key] []\n\ + -info Print general info about the system\n\ + -help Print this message\n"; +#endif /* DOS */ +/************************************************************************/ +/* */ +/* M A I N E N T R Y P O I N T */ +/* */ +/* */ +/************************************************************************/ + +main(argc, argv) + int argc ; + char **argv ; + { + int i; + char *envname; + extern int TIMER_INTERVAL; + char keytyped [ 255 ]; + +#ifndef NOFORN + if (dld_find_executable (argv[0]) == 0) { + perror("Name of executable not found."); + } else if (dld_init (dld_find_executable (argv[0])) != 0) { + dld_perror( "Can't init DLD." ); + }; +#endif /* NOFORN */ + +#ifdef XWINDOW + read_Xoption( &argc, argv ); +#endif /* XWINDOW */ + + + save_argc = argc; + save_argv = argv; + +#ifdef PROFILE + moncontrol(0); /* initially stop sampling */ +#endif /* PROFILE */ + + +/* Sysout is found as follows: + If the first argument doesn't begin with '-', assume it's the sysout + Look at the environment variable LDESRCESYSOUT if that fails + Look for ~/lisp.virtualmem if that fails + Barf and print the command line if tha fails +*/ + +#ifdef FSERROR + /* For call makepathname */ + Lisp_errno = &Dummy_errno; +#endif + + i=1; + + if (argv[i] && ((strcmp(argv[i], "-info") == 0) || + (strcmp(argv[i], "-INFO") == 0))) { + print_info_lines(); + exit(0); + } + + if (argv[i] && + ((strcmp(argv[i], "-help") == 0) || + (strcmp(argv[i], "-HELP") == 0))) + { + fprintf(stderr, helpstring ); + exit(0); + } + + if(argc > 1 && argv[1][0] != '-') + { + strcpy(sysout_name, argv[1]); + i++; + } + else if ((envname = getenv("LDESRCESYSOUT")) != NULL) + { + strcpy(sysout_name, envname); + } + else if ((envname = getenv("LDESOURCESYSOUT")) != NULL) + strcpy(sysout_name, envname); +#ifdef DOS + else if( !makepathname("lisp.vm", sysout_name) +#else + else if( !makepathname("~/lisp.virtualmem", sysout_name) +#endif /* DOS */ + || access(sysout_name, R_OK)) + { + fprintf(stderr, "Couldn't find a sysout to run;\n"); + fprintf(stderr, helpstring ); + exit(1); + } +/* OK, sysout name is now in sysout_name, and i is moved past a supplied name */ + + for ( ; i < argc; i += 1 ) + { /* step by 1 in case of typo */ + + /* -t and -m are undocumented and somewhat dangerous... */ + + if (! strcmp(argv[i], "-t")) + { /**** timer interval ****/ + if(argc > ++i) TIMER_INTERVAL = atoi(argv[i]); + else + { + fprintf(stderr, "Missing argument after -t\n"); + exit(1); + } + } + + else if (! strcmp(argv[i], "-m")) + { /**** sysout size ****/ + if(argc > ++i) sysout_size = atoi(argv[i]); + else + { + fprintf(stderr, "Missing argument after -m\n"); + exit(1); + } + } + + else if (! strcmp(argv[i], "-NF")) + { /**** Don't fork (for dbxing) ****/ + please_fork = 0; + } + + else if ( ! strcmp(argv[i], "-INIT")) + { /*** init sysout, no packaged */ + for_makeinit = 1; + } + else if (! strcmp(argv[i], "-k")) + { /**** security key ****/ + + if(argc > ++i) { (void)strcpy(keystring, argv[i]); } + else + { + fprintf(stderr, "Missing argument after -k\n"); + exit(1); + } + } + +#ifdef DOS + else if ((strcmp(argv[i], "-vga") == 0) || + (strcmp(argv[i], "-VGA") == 0)) + { + dosdisplaymode = 1; + } + else if ((strcmp(argv[i], "-vesa102") == 0) || + (strcmp(argv[i], "-VESA102") == 0)) + { + dosdisplaymode = 0x102; + } + else if ((strcmp(argv[i], "-vesa104") == 0) || + (strcmp(argv[i], "-VESA104") == 0)) + { + dosdisplaymode = 0x104; + } + else if ((strcmp(argv[i], "-2button") == 0) || + (strcmp(argv[i], "-2BUTTON") == 0)) { + twobuttonflag = TRUE; + } + else if ((strcmp(argv[i], "-3button") == 0) || + (strcmp(argv[i], "-3BUTTON") == 0)) { + twobuttonflag = FALSE; + } + else if ((strcmp(argv[i], "-noeurokbd") == 0) || + (strcmp(argv[i], "-NOEUROKBD") == 0)) { + eurokbd = FALSE; + } + else if ((strcmp(argv[i], "-eurokbd") == 0) || + (strcmp(argv[i], "-EUROKBD") == 0)) { + eurokbd = TRUE; + } + else if ((strcmp(argv[i], "-nokbd") == 0) || + (strcmp(argv[i], "-NOKBD") == 0)) { + nokbdflag = TRUE; + } + else if ((strcmp(argv[i], "-nomouse") == 0) || + (strcmp(argv[i], "-NOMOUSE") == 0)) { + nomouseflag = TRUE; + } + +#endif /* DOS */ + + /* Can only do this under SUNOs, for now */ + else if (! strcmp(argv[i], "-E")) + { /**** ethernet info ****/ +#ifdef NOETHER +#else + int b0, b1, b2, b3, b4, b5; +#ifdef USE_DLPI + if(argc > ++i && sscanf(argv[i],"%d:%x:%x:%x:%x:%x:%x",ðer_fd, + &b0, &b1, &b2, &b3, &b4, &b5) == 7) +#else + if(argc > ++i && sscanf(argv[i],"%d:%x:%x:%x:%x:%x:%x:%s",ðer_fd, + &b0, &b1, &b2, &b3, &b4, &b5, snit.snit_ifname) == 8) +#endif /* USE_FDLPI */ + { + ether_host[0] = b0; ether_host[1] = b1; + ether_host[2] = b2; ether_host[3] = b3; + ether_host[4] = b4; ether_host[5] = b5; + } + else + { + fprintf(stderr, "Missing or bogus -E argument\n"); + ether_fd = -1; + exit(1); + } +#endif /* NOETHER */ + + } + /* diagnostic flag for big vmem write() calls */ + else if (! strcmp(argv[i], "-xpages")) + { + if(argc > ++i) maxpages = atoi(argv[i]); + else + { + fprintf(stderr, "Missing argument after -xpages\n"); + exit(1); + } + } + } + + /* Sanity checks. */ +#ifdef DOS + probemouse(); /* See if the mouse is connected. */ +#else + if ( getuid() != geteuid() ) { + fprintf(stderr, "Effective user is not real user. Setting euid to uid.\n"); + seteuid(getuid()); + } +#endif /* DOS */ + + if ( keystring ) /* key given, so safe to copy */ + strcpy ( keytyped, keystring ); + + if ( keytester(keystring) ) { /* keytester destroys keystring */ + fprintf (stderr, "Sorry, invalid or expired access key.\n" ); + fprintf (stderr, "Key tried: %s\n", keytyped ); + exit(-1); + } + +#ifndef NOETHER + init_ether(); /* modified by kiuchi Nov. 4 */ +#endif /* NOETHER */ + + +#ifdef FORKCOMM + /* Fork Unix was called in kickstarter; if we forked, look up the */ + /* pipe handles to the subprocess and set them up. */ + + if(FindUnixPipes()) /* must call the routine to allocate storage, */ + { /* in case we're re-starting a savevm w/open ptys */ + if(please_fork) + fprintf(stderr, + "Failed to find UNIXCOMM file handles; no processes\n"); + } +#else + /* Fork Unix Interface subprocess before we create anything big; */ + /* interrupts need to be blocked here so subprocess won't see them */ + /* This should actually live in the kickstarter... */ + +#ifdef DOS + init_host_filesystem(); +#else + if(please_fork){int_block(); fork_Unix();} +#endif /* DOS */ +#endif /* FORKCOMM */ +#if defined(DOS) || defined (XWINDOW) + make_dsp_instance(currentdsp, 0, 0, 0, 1 ); /* All defaults the first time */ +#endif /* DOS || XWINDOW */ + + /* Load sysout to VM space and returns real sysout_size(not 0) */ + sysout_size= sysout_loader(sysout_name, sysout_size); + + build_lisp_map(); /* built up map */ + + init_ifpage(sysout_size); /* init interface page */ + init_iopage(); + init_miscstats(); +#ifdef NEW_STORAGE + init_storage(); +#endif /* NEW_STORAGE */ + + set_cursor(); + + /* file system directory enumeration stuff */ + if (!init_finfo()) + { + fprintf(stderr, "Cannot allocate internal data.\n"); + exit(1); + } +#ifdef RS232 + rs232c_init(); +#endif + + /* Get OS message to ~/lisp.log and print the message to prompt window */ + if(!for_makeinit) + { +#ifdef SUNDISPLAY + mess_init(); +#endif /* SUNDISPLAY */ + + init_keyboard(0); /* can't turn on the keyboard yet or you will die + in makeinit. Pilotbitblt will turn it on if + you used the proper switches when building LDE. + JDS -- 1/18/90 also BITBLTSUB does it now. */ + } + +#ifdef I386 +/* 80387 initialization */ + asm(".data"); + asm(".align 4"); + asm("__FP_trunc:"); + asm(" .globl __FP_trunc"); + asm(".byte 0x3f"); + asm(".byte 0x0c"); + asm("__FP_round:"); + asm(" .globl __FP_round"); + asm(".byte 0x3f"); + asm(".byte 0x00"); + asm(".text"); + asm("fldcw __FP_round"); +#elif DOS + _setrealmode(0x3f); /* Don't interrupt on FP overflows */ + _getrealerror(); +#endif /* I386 */ + + + + +#ifdef RS6000 + /****************************************************/ + /* For the IBM RS/6000, we have to initialize its */ + /* notion of the time zone, so gettimeofday works */ + /****************************************************/ + + tzset(); +#endif /* RS6000 */ + +#if defined(ISC) || defined(DOS) + tzset(); +#endif + +#ifdef OS5 + tzset(); +#endif /* OS5 */ + + + /* now start up lisp */ + start_lisp(); + } + + + + +/************************************************************************/ +/* */ +/* s t a r t _ l i s p */ +/* */ +/* This is the function that actually starts up the lisp emulator. */ +/* */ +/* */ +/************************************************************************/ + +start_lisp() + { + DLword *freeptr,*next68k; + + /*******************************/ + /* First, turn off any pending interrupts from during VMEMSAVE. */ + /* This keeps US from trying to handle OLD interrupts. */ + /*******************************/ +#ifndef INIT + { INTSTAT * intstate = + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + intstate->ETHERInterrupt = 0; + intstate->LogFileIO = 0; + intstate->IOInterrupt = 0; + intstate->waitinginterrupt = 0; + intstate->intcharcode = 0; + } +#endif /* INIT */ + + TopOfStack=0; + Error_Exit = 0; + + MState->pvar = (DLword *) Addr68k_from_LADDR( STK_OFFSET + | InterfacePage->currentfxp) + + FRAMESIZE; + + freeptr = next68k = Addr68k_from_LADDR(STK_OFFSET | CURRENTFX->nextblock); + + if (GETWORD(next68k) != STK_FSB_WORD) + error("Starting Lisp: Next stack block isn't free!"); + + while(GETWORD(freeptr)==STK_FSB_WORD) + EndSTKP = freeptr = freeptr + GETWORD(freeptr+1); + + CurrentStackPTR =next68k -2; + + FastRetCALL; + + /* JRB - The interrupt intitialization must be done right before */ + /* entering the bytecode dispatch loop; interrupts get */ + /* unblocked here */ + int_init(); +#ifdef DOS + _dpmi_lockregion((void *)&dispatch, 32768); +#endif /* DOS */ + dispatch(); + } + + + + +/************************************************************************/ +/* */ +/* m a k e p a t h n a m e */ +/* */ +/* */ +/* */ +/************************************************************************/ + +makepathname(src, dst) + register char *src; + register char *dst; + { + register int len; + register char *base, *cp; + register struct passwd *pwd; + char name[MAXPATHLEN]; + + base = src; + switch ( *base ) + { + case '.': +#ifdef DOS + if(getcwd(dst, MAXPATHLEN) == 0) +#else + if(getwd(dst) == 0) +#endif /* DOS */ + { /* set working directory */ +#ifdef FSERROR + *Lisp_errno = errno; +#endif + return(0); + } + switch ( *(base+1) ) + { + case '.': + if(*(base+2) == '/') + { /* Now, base == "../xxxx" */ + cp = (char *)strrchr(dst, '/'); + if(cp == 0) return(0); + *cp = '\0'; + strcat(dst, base+2); + return(1); + } + else return(0); + case '/': + /* Now, base == "./xxx" */ + strcat(dst, base+1); + return(1); + default: + return(0); + } + case '~': +#ifdef FSERROR + ERRSETJMP(0); +#else + SETJMP(0); +#endif + if( *(base+1) == '/') + { + /* path is "~/foo" */ +#ifdef DOS + pwd = 0; +#else + TIMEOUT( pwd = getpwuid( getuid()) ); +#endif /* DOS */ + if(pwd == NULL) + { +#ifdef FSERROR + *Lisp_errno = errno; +#endif + return(0); + } +#ifndef DOS + sprintf(dst, "%s%s", pwd->pw_dir, base+1); +#endif + return(1); + } + else + { + /* path is "~foo/" */ + if((cp=(char *)strchr(base+1, '/')) == 0) return(0); + else + { + len = (UNSIGNED)cp - (UNSIGNED)base -1; + strncpy(name, base+1, len); + name[len] = '\0'; +#ifndef DOS + TIMEOUT( pwd = getpwnam(name) ); +#endif /* DOS */ + if(pwd == NULL) + { +#ifdef FSERROR + *Lisp_errno = errno; +#endif + return(0); + } +#ifndef DOS + sprintf(dst, "%s%s", pwd->pw_dir, cp); +#endif /* DOS */ + return(1); + } + } + default: + strcpy(dst, src); + return(1); + } + } + + + +print_info_lines () + { +#if (RELEASE == 200) + printf("Emulator for Medley release 2.0\n"); +#elif (RELEASE == 201) + printf("Emulator for Medley release 2.01\n"); +#elif (RELEASE == 210) + printf("Emulator for Medley release 2.1\n"); +#elif (RELEASE == 300) + printf("Emulator for Medley release 3.0\n"); +#elif (RELEASE == 350) + printf("Emulator for Medley release 3.5\n"); +#elif (RELEASE == 351) + printf("Emulator for Medley release 3.51\n"); +#endif /* RELEASE */ + printf("Creation date: %s", ctime(&MDate)); +#ifdef DEMO + printf("Demonstration emulator, not for commercial use\n"); +#endif /* DEMO */ +#ifdef LPSOLVE + printf("Contains lp_solve LP solver.\n"); +#endif /* LPSOLVE */ +#ifdef BIGBIGVM + printf("Supports 256Mb virtual memory.\n"); +#elif BIGVM + printf("Supports 64Mb virtual memory.\n"); +#else + printf("Supports 32Mb virtual memory.\n"); +#endif /* BIGVM */ +#ifdef NOVERSION + printf("Does not enforce SYSOUT version matching.\n"); +#endif /* NOVERSION */ +#ifdef NOFORN + printf("Has no foreign-function-call interface.\n"); +#endif /* NOFORN */ +#ifdef NOEUROKBD + printf("No support for European keyboards.\n"); +#else + printf("Supports Sun European Type-4/5 keyboards.\n"); +#endif /* NOEUROKBD */ + + } diff --git a/src/misc7.c b/src/misc7.c new file mode 100755 index 0000000..2b4d1e1 --- /dev/null +++ b/src/misc7.c @@ -0,0 +1,133 @@ +/* $Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/* misc7.c + */ +#include +#ifndef DOS +#include +#endif /* DOS */ +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "gc.h" +#include "arith.h" +#include "my.h" +#include "bitblt.h" +#include "dbprint.h" +/* osamu '90/02/08 + * add display.h, because in_display_secment() is changed as + * macro. difinition is in display.h + */ +#include "display.h" + +#ifndef NOPIXRECT +#include +#include + +#include +#include +#include +#include +#endif + + + + /*************************************************/ + /* Possible operation fields for FBITMAPBIT */ + /*************************************************/ + +#define OP_INVERT 0 /* Invert the bit at the given location */ +#define OP_ERASE 1 /* Turn the given bit off. */ +#define OP_READ 2 /* Just read the bit that's there. */ +#define OP_PAINT 3 /* Turn the bit on. */ + + +extern int LispWindowFd; +extern int ScreenLocked; + + +/*** N_OP_misc7 -- pseudocolor or fbitmapbit ***/ +N_OP_misc7(arg1, arg2, arg3, arg4, arg5, arg6, arg7, alpha) + int alpha; + register LispPTR arg1, arg2, arg3, arg4, arg5, arg6, arg7; + { + DLword *base; + int x, y, operation, heightminus1, rasterwidth, oldbit; + int displayflg; + + DBPRINT(("MISC7 op with alpha byte %d.\n", alpha)); + + if (alpha != 1) ERROR_EXIT(arg7); + + base = Addr68k_from_LADDR(arg1); + N_GETNUMBER(arg2, x, doufn); + N_GETNUMBER(arg3, y, doufn); + N_GETNUMBER(arg4, operation, doufn); + N_GETNUMBER(arg5, heightminus1, doufn); + N_GETNUMBER(arg6, rasterwidth, doufn); + + DBPRINT(("MISC7 args OK.\n")); + + displayflg = n_new_cursorin(base, x, (heightminus1 - y), 1, 1); + + base = base + (rasterwidth * (heightminus1 - y)) + (0xFFFF & (x>>4)); + x = 32768 >> (x & 0xF); + + oldbit = x & *base; + + ScreenLocked = T; + +#ifdef SUNDISPLAY + if (displayflg) HideCursor; +#endif /* SUNDISPLAY */ + + + switch (operation) + { + case OP_INVERT: *base ^= x; break; + case OP_ERASE: *base &= ~x; break; + case OP_READ: break; + default: *base |= x; + }; + +#ifdef SUNDISPLAY +#ifdef DISPLAYBUFFER + if (in_display_segment(base)) flush_display_ptrregion(base, 0, 16, 1); +#endif + if (displayflg) ShowCursor; +#endif /* SUNDISPLAY */ + + +#ifdef XWINDOW + if (in_display_segment(base)) flush_display_ptrregion(base, 0, 16, 1); +#endif /* XWINDOW */ + + + ScreenLocked = NIL; + DBPRINT(("FBITMAPBIT old bit = 0x%x.\n", oldbit)); + return(S_POSITIVE | (oldbit ? 1 : 0)); + +doufn: ERROR_EXIT(arg7); + +} /* end N_OP_misc7() */ + diff --git a/src/miscn.c b/src/miscn.c new file mode 100755 index 0000000..64776c4 --- /dev/null +++ b/src/miscn.c @@ -0,0 +1,217 @@ +/* $Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/***********************************************************/ +/* + File Name: miscn.c + Including: OP_miscn +*/ +/***********************************************************/ + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "arith.h" +#include "subrs.h" +#include "profile.h" + +/***********************************************************/ +/* + Func Name : OP_miscn + + Interface: Global Machine State + Returns: (must UFN) + 0 = continue, C code succeeded. + 1 = must UFN, C code failed. +*/ +/***********************************************************/ + +int OP_miscn(int misc_index, int arg_count) +{ + register LispPTR *stk; + register int result; + static LispPTR args[255]; + +/* Put the Args into a Vector */ + + args[0] = NIL_PTR; + stk = ((LispPTR *) CurrentStackPTR) + 1; + + {register int arg_num = arg_count; + if (arg_num > 0) { + *stk++ = (LispPTR) TopOfStack; + while(arg_num > 0) args[--arg_num] = *--stk; + } + } + +/* Select the Misc Number */ + +switch(misc_index) + { + case miscn_USER_SUBR: + {register LispPTR user_subr, user_args; + N_GETNUMBER(args[0], user_subr, do_ufn); + if ((result = UserSubr(user_subr, arg_count-1, &args[1])) < 0) + goto do_ufn; + } + break; + case miscn_SXHASH: result = SX_hash(args); + break; + + case miscn_STRING_EQUAL_HASHBITS: + result = STRING_EQUAL_HASHBITS(args); + break; + + case miscn_STRINGHASHBITS: + result = STRING_HASHBITS(args); + break; + + case miscn_VALUES: + if ( arg_count > 255 ) { + error ( "miscn: arg_count too big! continue punts" ); + goto do_ufn; + break; + } + result = values(arg_count, args); + break; + + case miscn_VALUES_LIST: + /*** debugging: should be impossible, but ADB found this once -FS *****/ + if ( arg_count > 255 ) { + error ( "miscn: arg_count too big! continue punts" ); + goto do_ufn; + break; + } + result = values_list(arg_count, args); + break; + + case miscn_LCFetchMethod: + result = LCFetchMethod(args[0],args[1]); + if (result < 0) goto lc_ufn; + break; + + case miscn_LCFetchMethodOrHelp: + result = LCFetchMethodOrHelp(args[0],args[1]); + if (result < 0) goto lc_ufn; + break; + + case miscn_LCFindVarIndex: + result = LCFindVarIndex(args[0],args[1]); + if (result < 0) goto lc_ufn; + break; + + case miscn_LCGetIVValue: + result = LCGetIVValue(args[0],args[1]); + if (result < 0) goto lc_ufn; + break; + + case miscn_LCPutIVValue: + result = LCPutIVValue(args[0],args[1],args[2]); + if (result < 0) goto lc_ufn; + break; +#ifdef RS232 + case miscn_RAW_RS232C_OPEN: + if((result = raw_rs232c_open(args[0]))==NIL) + goto do_ufn; + + break; + + case miscn_RAW_RS232C_CLOSE: + if((result = raw_rs232c_close(args[0]))==NIL) + goto do_ufn; + + break; + + + case miscn_RAW_RS232C_SETPARAM: + if((result = raw_rs232c_setparams(args[0],args[1])) + == NIL) goto do_ufn; + break; + case miscn_RAW_RS232C_GETPARAM: + /******/ break; + case miscn_RAW_RS232C_READ: + if((result = raw_rs232c_read(args[0],args[1],args[2])) + == NIL) goto do_ufn; + break; + case miscn_RAW_RS232C_WRITE: + if((result = raw_rs232c_write(args[0],args[1],args[2])) + == NIL) goto do_ufn; + break; + case miscn_RAW_RS232C_SETINT: + if((result = raw_rs232c_setint(args[0],args[1])) + ==NIL) goto do_ufn; + break; + case miscn_CHATTER: + result = chatter(args); + break; +#endif /* RS232 */ + +#ifdef JLISP + case miscn_EJLISP: +#ifndef NOWNN + result = ejlisp(args); +#endif + break; +#endif /* JLISP */ + +#ifdef CDROM + case miscn_CDAUDIO: + result = cdaudio(args); + break; + case miscn_CDROM: + result = cdrom(args); + break; +#endif /* CDROM */ + + case /* miscn_CALL_C*/ 014:/* result = call_c_fn(args); */ + break; + + default : + goto do_ufn; + break; + + }/* switch end */ + +/* Setup Global Machine State for a Normal Return */ + + PC += 3; + CurrentStackPTR = (DLword *) (stk - 1); + TopOfStack = (LispPTR) result; + return(0); + +/* A UFN request, so return 1 & don't change the Machine State */ + +do_ufn: + return(1); +lc_ufn: + if (result == -2) { + return(0); /* have built new stack frame */ + }else{ + goto do_ufn; + } + + +}/* OP_miscn */ diff --git a/src/mkatom.c b/src/mkatom.c new file mode 100755 index 0000000..73dd4ce --- /dev/null +++ b/src/mkatom.c @@ -0,0 +1,453 @@ +/* $Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ Copyright (C) Venue"; + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/**********************************************************************/ +/* + File Name : makeatom.c + + Desc. : Create atom + + Date : January 29, 1987 + Edited by : Takeshi Shimizu + Change : create_symbol + take,30-Jun + 1 May 1987 take + 28 Aug. 1987 take + + Including : make_atom + compute_hash + create_symbol + compare_chars + parse_number +*/ +/**********************************************************************/ + + +#include "lispemul.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "cell.h" +#include "dbprint.h" + +#define ATOMoffset 2 /* NIL NOBIND */ +#define MAX_ATOMINDEX 0xffff /* max number of atoms */ + +#define Atom_reprobe( hash , char ) ((((char) ^ (hash))| 1) & 63 ) + +extern DLword *Lisp_world ; + +/**********************************************************************/ +/* + Func name : compute_hash + + Compute hash value from chars. + THIS ONLY WORKS CORRECTLY ON EMULATOR STRINGS. + Don't use it with strings in lisp-space. + + Date : January 29, 1987 + Chan. Aug. 27 87 take + Edited by : Takeshi Shimizu +*/ +/**********************************************************************/ + + +compute_hash (char *char_base, DLword offset, DLword length) +{ + DLword hash; + DLword number; + DLword temp1,temp2; + DLword *word_base; + char_base +=offset; + hash = (int)(*(char_base)) << 8 ; /* get first byte */ + char_base++ ; /* skip length area */ + + for (number= 1; number <= length -1; char_base++, number++) + { + hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; + temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; + hash = (int)(temp1 + (*(char_base))) & 0x0ffff ; + } + + return (hash); + +} /* end compute_hash */ + +/**********************************************************************/ +/* + Func name : compute_lisp_hash + + Compute hash value from chars. WORKS ONLY ON LISP CHARS. + + Date : January 29, 1987 + Chan. Aug. 27 87 take + Edited by : Takeshi Shimizu +*/ +/**********************************************************************/ + + +compute_lisp_hash (char *char_base, DLword offset, DLword length, DLword fatp) +{ + DLword hash; + DLword number; + DLword temp1,temp2; + DLword *word_base; + + if (length == 0) return(0); + + if (fatp) + { /* fat characters in the string to be searched. */ + word_base = (DLword *)char_base; + word_base +=offset; + hash = (DLword)(0xFF & GETWORD(word_base)) << 8 ; /* get first byte */ + word_base++ ; /* skip length area */ + + for (number= 1; number <= length -1; word_base++, number++) + { + hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; + temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; + hash = (int)(temp1 + (0xFF & GETWORD(word_base))) & 0x0ffff ; + } + } + else + { + char_base +=offset; + hash = (int)(0xFF & GETBYTE(char_base)) << 8 ; /* get first byte */ + char_base++ ; /* skip length area */ + + for (number= 1; number <= length -1; char_base++, number++) + { + hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; + temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; + hash = (int)(temp1 + (0xFF & GETBYTE(char_base))) & 0x0ffff ; + } + } + return (hash); + +} /* end compute_lisp_hash */ + +/**********************************************************************/ +/* + Func name : compare_chars + + Compare two strings, char1, char2 + char1 -- in the LISP address space (& potentially + byte swapped!) + char2 -- in emulator space, and obeying the "natural" + ordering of bytes in a string. + + Date : January 29, 1987 + Edited by : Takeshi Shimizu + (why not call strncmp directly??) + Because we need to account for byte ordering!! --JDS + AND we need to compare NS chars (which have 0s in the string) correctly! +*/ +/**********************************************************************/ + +compare_chars(register char *char1, register char *char2, register DLword length) +{ +#ifndef BYTESWAP + if (memcmp ( char1, char2, length ) == 0) +#else + if (bytecmp ( char1, char2, length )) +#endif /* BYTESWAP */ + + { + return(T); + } + else + { + return(NIL); + } + + } /* end compare_chars */ +#ifdef BYTESWAP +bytecmp (char1, char2, len) + char *char1; + char *char2; + int len; + { + int index; + for (index=0; index 57 ) /* greater than '9 */ + return((LispPTR)(ATOMoffset + (first_char -10)) ); + else if (first_char > 47) /* between '0 to '9 */ + return((LispPTR)(S_POSITIVE + (first_char - 48)) ); + /* fixed S_... mar-27-87 take */ + else /* other one char. atoms */ + return ((LispPTR)(ATOMoffset +first_char)); + } /* if(length==1.. end */ + else if ((non_numericp ==NIL) &&(first_char <= '9')) + /* more than 10 arithmetic aon + - mixed atom process */ + { + if((hash_entry = parse_number(char_base+offset,length))!=0) + return((LispPTR)hash_entry); /* if NIL that means THE ATOM is +- mixed litatom */ + /* 15 may 87 take */ + } + + hash = compute_hash(char_base, offset,length) ; + + } /* if(lengt.. end */ + else + { + hash = 0; + first_char = 255 ; + } + +/* This point corresponds with LP in Lisp source */ + +/* following for loop never exits until it finds new hash enty or same atom */ + for ( reprobe=Atom_reprobe(hash ,first_char) ; + (hash_entry= GETWORD(AtomHT+hash)) != 0 ; + hash = ((hash + reprobe) & 0xffff) ) + { + atom_index = hash_entry -1 ; + /* get pname pointer */ + pnptr = (PNCell *)GetPnameCell( atom_index); + pname_base= (char *)Addr68k_from_LADDR(POINTERMASK & pnptr->pnamebase) ; + + if ((length == GETBYTE(pname_base) ) && + (compare_chars(++pname_base,char_base+offset,length) ==T)) + { + DBPRINT(("FOUND the atom. \n")); + return ( atom_index ); /* find already existed atom */ + } + DBPRINT(("HASH doesn't hit. reprobe!\n")); + + } /* for end */ + +/* we can't find that atom, then we should make new atom */ + DBPRINT(("HASH NEVER HIT. Returning -1.\n")); + return(0xffffffff); +/** Don't create newatom now **/ +} /* make_atom end */ + + + + + + +/*********************************************************************/ +/* + Func name : parse_number + + Desc : It can treat -65534 to 65535 integer + Returns SMALLP PTR + Date : 1,May 1987 Take + 15 May 87 take +*/ +/*********************************************************************/ + +/* Assume this func. should be called with C string in "char_base" */ +LispPTR parse_number(char *char_base, short int length) +{ + register LispPTR sign_mask ; + register LispPTR val ; + register int radix ; + register int *cell68k; + + +#ifdef TRACE2 + printf("TRACE: parse_number()\n"); +#endif + + /* Check for Radix 8(Q) postfixed ?? */ + if( (*(char_base +(length -1))) == 'Q') + { + radix= 8; + length--; + } + else radix = 10 ; + + /* Check for Sign */ + sign_mask =S_POSITIVE ; + + if((*(char_base) == '+') || (*(char_base) == '-')) + { + sign_mask = ((*char_base++) =='+') ? S_POSITIVE : S_NEGATIVE ; + length--; + } + + for(val=0;length>0;length--) + { + if ( (((*char_base)) < '0' ) || ( '9' < ((*char_base))) ) + return(NIL); + val = radix * val + (*char_base++) - '0' ; + } + + if(val > 0xffffffff) + error("parse_number : Overflow ...exceeded range of FIXP"); + + if((sign_mask == S_POSITIVE)&&(val > 0xffff)) + { + cell68k = (int *)createcell68k(TYPE_FIXP); + *cell68k = val ; + return(LADDR_from_68k(cell68k)); + } + else if((sign_mask == S_NEGATIVE) && (val > 0xffff)) + { + cell68k =(int *) createcell68k(TYPE_FIXP); + *cell68k = ~val +1 ; + return(LADDR_from_68k(cell68k)); + } + + else if(sign_mask == S_NEGATIVE) + return(sign_mask | (~((DLword)val) + 1)); + else + { + return(sign_mask | val); + } + } + /* end parse_number */ diff --git a/src/mkcell.c b/src/mkcell.c new file mode 100755 index 0000000..c75de94 --- /dev/null +++ b/src/mkcell.c @@ -0,0 +1,245 @@ +/* $Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/***********************************************************************/ +/* + File Name : mkcell.c + + Desc : + + Date : Jun. 4, 1987 + Edited by : Takeshi Shimizu + Changed : 9 Jun 1987 take + 26 Oct. 1987 take(add mask) + + Including : OP_createcell + + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "cell.h" +#include "gc.h" + +static LispPTR oldoldfree; +static LispPTR oldfree; + +LispPTR *alloc_mdspage(register short int type); +LispPTR initmdspage(register LispPTR *base, register DLword size, register LispPTR prev); + +LispPTR N_OP_createcell(register LispPTR tos) +{ + register struct dtd *dtd68k; + register DLword *ptr,*lastptr; + register LispPTR newcell ; + register unsigned int type ; + + if((tos & SEGMASK) != S_POSITIVE) ERROR_EXIT(tos); + type = tos & 0xffff ; + +#ifdef DTDDEBUG + if(type==TYPE_LISTP) + error("N_OP_createcell : Can't create Listp cell with CREATECELL"); + check_dtd_chain(type); +#endif + + + dtd68k = (struct dtd *)GetDTD(type); + + oldoldfree = oldfree; + oldfree = dtd68k->dtd_free; + + if(dtd68k->dtd_size == 0) ERROR_EXIT(tos); + /* error("OP_createcell : Attempt to create a cell not declared yet"); */ + +retry : + if((tos=newcell=((dtd68k->dtd_free)&POINTERMASK)) != NIL) + { + ptr = (DLword *)Addr68k_from_LADDR(newcell); +if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error"); + /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ + dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK; + if (dtd68k->dtd_free & 0x8000001) error("bad entry on free chain."); + + dtd68k->dtd_oldcnt++; + + /* clear 0 */ + for(lastptr=ptr + dtd68k->dtd_size ; + ptr != lastptr ; ptr++) + { GETWORD(ptr) = 0 ; } + +/* IncAllocCnt(1); */ + GCLOOKUP(tos, DELREF); + return(tos); + } + else + { + dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry) , + dtd68k->dtd_size ,NIL); + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + goto retry ; + } + +} /* N_OP_createcell end */ + + + + + +DLword *createcell68k(unsigned int type) +{ + register struct dtd *dtd68k; + register DLword *ptr,*lastptr; + register ConsCell *newcell68k; + register LispPTR newcell ; +#ifdef DTDDEBUG + if(type==TYPE_LISTP) + error("createcell : Can't create Listp cell with CREATECELL"); + if(type==TYPE_STREAM) stab(); + + check_dtd_chain(type); + +#endif + + dtd68k = (struct dtd *)GetDTD(type); + + if(dtd68k->dtd_size == 0) + error("createcell : Attempt to create a cell not declared yet"); + +retry : + if((newcell=(dtd68k->dtd_free & POINTERMASK)) != NIL) + { +#ifdef DTDDEBUG + if(type != GetTypeNumber(newcell)) + error("createcell : BAD cell in dtdfree"); + if(newcell > POINTERMASK) + error("createcell : BAD Lisp address"); +#endif + + ptr = Addr68k_from_LADDR(newcell) ; + +if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error"); + + /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ + dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK ; + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + +#ifdef DTDDEBUG + if((dtd68k->dtd_free!=0)&&(type != GetTypeNumber(dtd68k->dtd_free)) ) + error("createcell : BAD cell in next dtdfree"); + check_dtd_chain(type); + +#endif + + dtd68k->dtd_oldcnt++; + + /* clear 0 */ + for(lastptr=ptr + dtd68k->dtd_size ; + ptr != lastptr ; ptr++) + { GETWORD(ptr) = 0 ; } + +/* IncAllocCnt(1); */ + GCLOOKUP(newcell, DELREF); + +#ifdef DTDDEBUG + check_dtd_chain(type); +#endif + + + return(Addr68k_from_LADDR(newcell)); + + } + else + { + dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry) , + dtd68k->dtd_size ,NIL); + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + +#ifdef DTDDEBUG + check_dtd_chain(type); +#endif + + goto retry ; + } + + +} /* createcell68k end */ + + +/**********************************************************/ +/* Create a Cell of Specified Type & Set to given Value */ +/* Works with 32 bit typed values only. */ +/* (Initially used only by native code) */ +/**********************************************************/ + +LispPTR Create_n_Set_Cell(unsigned int type, LispPTR value) +{ + register struct dtd *dtd68k; + register DLword *ptr,*lastptr; + register ConsCell *newcell68k; + register LispPTR newcell ; + + dtd68k = (struct dtd *)GetDTD(type); + + if(dtd68k->dtd_size == 0) + error("createcell : Attempt to create a cell not declared yet"); + +retry : + if((newcell=(dtd68k->dtd_free & POINTERMASK)) != NIL) + { + ptr = Addr68k_from_LADDR(newcell) ; + + /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ + + dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK ; + dtd68k->dtd_oldcnt++; + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + + /* clear 0 */ + for(lastptr=ptr + dtd68k->dtd_size ; + ptr != lastptr ; ptr++) + { GETWORD(ptr) = 0 ; } + +/* IncAllocCnt(1); */ + GCLOOKUP(newcell, DELREF); + (* ((LispPTR *) Addr68k_from_LADDR(newcell))) = value; + return(newcell); + + } + else + { + dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry) , + dtd68k->dtd_size ,NIL); + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + + goto retry ; + } + + +} /* createcell68k end */ + diff --git a/src/mkkey.c b/src/mkkey.c new file mode 100755 index 0000000..4ee6594 --- /dev/null +++ b/src/mkkey.c @@ -0,0 +1,19 @@ +/* $Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + diff --git a/src/mkkey.c.X b/src/mkkey.c.X new file mode 100644 index 0000000..e69de29 diff --git a/src/mkvdate.c b/src/mkvdate.c new file mode 100755 index 0000000..46ed845 --- /dev/null +++ b/src/mkvdate.c @@ -0,0 +1,80 @@ +/* $Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* m a k e v d a t e . c */ +/* */ +/* Make the version number to place in the emulator. That number */ +/* will be smashed into the running sysout at the field */ +/* InterfacePage->rversion. The version number is the number */ +/* of whole days since 12:00 13-Oct-87 (Takeshi's birthday). */ +/* */ +/* This program prints a single line: */ +/* long MDate = */ +/* */ +/* That output is redirected to create the file vdate.c, which */ +/* is then compiled as part of the emulator MAKE. */ +/* */ +/************************************************************************/ + + +#ifdef OSF1 +#include "time.h" +#endif + +#include +#ifdef USETIMEFN +#include +#elif DOS +#include +#else +#include +#endif /* USETIMEFN */ + + +#ifdef USETIMEFN + /* RISCOS doesn't have the BSD time functions */ +main() + { + long dtime; + time(&dtime); + fprintf(stderr, "Mdate :%d\n", dtime); + printf("long MDate= %d;\n", dtime); + exit(0); + } +#else + /* Version for every other Unix */ +main(void) +{ + struct timeval time; + + gettimeofday(&time, NULL); + fprintf(stderr, "Mdate :%d\n", time.tv_sec); + fprintf(stderr, "Version: %s\n", ctime(&time.tv_sec)); + + printf("long MDate= %d;\n", time.tv_sec); + exit(0); + } + +#endif /* SYSVONLY */ + diff --git a/src/mnwevent.c b/src/mnwevent.c new file mode 100755 index 0000000..b7b9322 --- /dev/null +++ b/src/mnwevent.c @@ -0,0 +1,688 @@ +/* $Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include + +#include +#include + +/* #include "XVersion.h" */ +#include "lispemul.h" +#include "lsptypes.h" +#include "MyWindow.h" +#include "dbprint.h" +#include "mnxdefs.h" +#include "keyboard.h" +#include "lspglob.h" +#include "adr68k.h" +#include "cell.h" + +#ifndef FALSE +#define FALSE 0 +#define TRUE !FALSE +#endif /* FALSE */ + +extern XEvent report; + +extern DLword *CTopMNWEvent; +int MNWEventFlg=0; /* Count of MNW events needing service */ + +DspInterfaceRec *FD_to_dspif[32]; /* Map from FD # to a display */ +int MNWReadFds = 0; + +DLword *CTopMNWEvent; +LispPTR DOMNWEVENT_index; +LispPTR *MNWEVENTQUEUE68k; + +extern LispPTR *MakeAtom68k(); + +extern DLword *EmCursorX68K + , *EmCursorY68K; +extern DLword *EmMouseX68K + , *EmMouseY68K + , *EmKbdAd068K + , *EmRealUtilin68K; +extern LispPTR *CLastUserActionCell68k; +extern MISCSTATS *MiscStats; + +extern int KBDEventFlg; +LispPTR *MNWBUFFERING68k = 0; + +/************************************************************************/ +/* Find_window */ +/* Find the wif corresponding to the Xwindow. This function also places */ +/* the found wif at the head of the chain. The rationale for this is */ +/* that a window that has gotten signals is likely to be the target of */ +/* the next signal also. The next time we look for this wif we'll find */ +/* at the head of the chain. (This is bubblesort) */ +/* */ +/************************************************************************/ +WindowInterface Find_window(dspif, Xwindow) + DspInterface dspif; + Window Xwindow; +{ + WindowInterface curr, prev; + + if(dspif->CreatedWifs == (WindowInterface)NULL) return(NIL); + if(dspif->CreatedWifs->blackframe == Xwindow) return(dspif->CreatedWifs); + + /* Find the wif we are interested in. */ + for(prev = dspif->CreatedWifs, curr = prev->next; + ((curr != (WindowInterface)NULL) && (curr->blackframe != Xwindow)); + curr = curr->next, prev = prev->next){} + if(curr == (WindowInterface)NULL) return(NIL); /* wif not found */ + + /* Bubble curr to the head of the list */ + prev->next = curr->next; + curr->next = dspif->CreatedWifs; + dspif->CreatedWifs = curr; + return(curr); +} + +/************************************************************************/ +/* Callback handling mechanism. */ +/* These procedures handle the callbacks from widgets. */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* NewEvent */ +/* Get a pointer to the next event in line in the Lisp eventqueue. */ +/* Return NULL if fail. This is the head of DoRing. */ +/************************************************************************/ +MNWEvent *NewEvent() +{ + if (! CTopMNWEvent ) + { + LispPTR index; + index = get_package_atom("\\MNWEVENTQUEUE", 14, "INTERLISP", 9, NIL); + if (index != 0xFFFFFFFF) + { + MNWEVENTQUEUE68k = GetVALCELL68k(index); + DOMNWEVENT_index = get_package_atom("\\DOMNWEVENT", 11, "INTERLISP", 9, NIL); + CTopMNWEvent= (DLword*)Addr68k_from_LADDR(*MNWEVENTQUEUE68k); + } + } + if (CTopMNWEvent) + { DLword w, r; + r=RING_READ(CTopMNWEvent); + w=RING_WRITE(CTopMNWEvent); + + if (r != w) return((MNWEvent*)(CTopMNWEvent+ w)); + } + return(NULL); +} +/************************************************************************/ +/* SignalMNWEvent */ +/* Tell Lisp that an event happened. This is the tail part of DoRing */ +/* */ +/************************************************************************/ +SignalMNWEvent() +{ + DLword w, r; + if (CTopMNWEvent) { + r=RING_READ(CTopMNWEvent); + w=RING_WRITE(CTopMNWEvent); + + if(r==0) /* Queue was empty */ + ((RING*)CTopMNWEvent)->read=w; + if(w >= MAXMNWEVENT) ((RING*)CTopMNWEvent)->write = MINMNWEVENT; + else ((RING*)CTopMNWEvent)->write = w + MNWEVENTSIZE; + + if (*MNWBUFFERING68k == NIL) *MNWBUFFERING68k = ATOM_T; + if (MNWEventFlg++ > 0) Irq_Stk_End = Irq_Stk_Check = 0; /* Ask for interrupt */ + } +} + +void HandleMotion(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XMotionEvent *xevent; + Boolean *continue_to_dispatch; +{ + MNWPointerMotionEvent *mevent; + + { + *CLastUserActionCell68k = MiscStats->secondstmp; + (*((DLword *)EmMouseX68K)) = *EmCursorX68K = xevent->x_root; + (*((DLword *)EmMouseY68K)) = *EmCursorY68K = xevent->y_root; + /* printf("mouse x %d, y %d\n", xevent->x_root, xevent->y_root); */ + DoRing(); + if(( KBDEventFlg ) > 0) + { + /* immidiately request for IRQ check */ + Irq_Stk_End=Irq_Stk_Check=0; + } + } +} + + +void HandleButton(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XButtonEvent *xevent; + Boolean *continue_to_dispatch; +{ + MNWButtonEvent *mevent; + + lisp_Xbutton(xevent, 0); + +} + + + +void HandleKey(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XKeyEvent *xevent; + Boolean *continue_to_dispatch; +{ + + lisp_Xkeyboard(xevent, 0); + +#ifdef NEVER + if((mevent = NewEvent()) != NULL){ + mevent->screen = wif->MedleyScreen; + mevent->window = wif->MedleyWindow; + mevent->event = MNWButton; + mevent->pos.x = xevent->x_root; + mevent->pos.y = xevent->y_root; + mevent->button.left = xevent->state | Button1Mask; + mevent->button.middle = xevent->state | Button2Mask; + mevent->button.right = xevent->state | Button3Mask; + SignalMNWEvent(); + } +#endif /* NEVER */ +} + + + + +void HandleCrossing(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XCrossingEvent *xevent; + Boolean *continue_to_dispatch; +{ + switch (xevent->type) + { + case EnterNotify: DoMNWRing(MNWMouseIn, wif->MedleyScreen, wif->MedleyWindow, 0, 0, 0, 0); + break; + + case LeaveNotify: if (NotifyInferior != xevent->detail) + DoMNWRing(MNWMouseOut, wif->MedleyScreen, wif->MedleyWindow, 0, 0, 0, 0); + break; + } + } + + + +void HandleBackgroundCrossing(widget, dspif, xevent, continue_to_dispatch) + Widget widget; + DspInterface dspif; + XCrossingEvent *xevent; + Boolean *continue_to_dispatch; +{ + switch (xevent->type) + { + case EnterNotify: DoMNWRing(MNWMouseIn, dspif->screen, 0, 0, 0, 0, 0); + break; + + case LeaveNotify: if (NotifyInferior != xevent->detail) + DoMNWRing(MNWMouseOut, dspif->screen, 0, 0, 0, 0, 0); + break; + } + } + + + +void HandleFocus(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XFocusChangeEvent *xevent; + Boolean *continue_to_dispatch; +{ + MNWFocusEvent *mevent; +/* + if((mevent = (MNWFocusEvent *)NewEvent()) != NULL){ + mevent->screen = wif->MedleyScreen; + mevent->window = wif->MedleyWindow; + if(xevent->type == FocusIn) mevent->event = MNWFocusIn; + else mevent->event = MNWFocusOut; + SignalMNWEvent(); + } +*/ +} + +void HandleStructure(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XAnyEvent *xevent; + Boolean *continue_to_dispatch; +{ + LispPTR screen, MWindow; + Window window; + Display *display; + DspInterfaceRec *dspif; + + screen = wif->MedleyScreen; + MWindow = wif->MedleyWindow; + window = xevent->window; + dspif = wif->dspif; + display = dspif->handle; + + switch (xevent->type) + { + case UnmapNotify: DoMNWRing(MNWClose, screen, MWindow, 0, 0, 0, 0); + break; + + case MapNotify: break; + + case ConfigureNotify: if (!wif) break; /* don't change inner windows */ + /* if (wif->moving || wif->reshaping) + { + wif->moving = wif->reshaping = 0; + break; + } + else */ + { + int l, b, b2, w, h; + XConfigureEvent *ev = (XConfigureEvent *) xevent; + /* printf("M/S event send %d, x %d, y %d, w %d, h %d\n", + xevent->send_event, ev->x, ev->y, + ev->width, ev->height); */ + + l = ev->x; + b = ev->y; + +#ifdef INDIGO + /* apparent bug in SGI's x server */ + if ((!xevent->send_event) && (l==0) && (b == 0)) +#else + if ((!xevent->send_event)) +#endif /* INDIGO */ + { + Window parent, root, *children; + int nch; + + XQueryTree(display, window, &root, &parent, &children, &nch); + XFree(children); + if (parent != root) XTranslateCoordinates(display, parent, + dspif->root, + ev->x, ev->y, + &l, &b, &window); + /* printf("[translated x %d, y %d]\n", l, b); */ + } + + b2 = HeightOfScreen(wif->screen) - b - ev->height; + + if ((wif->topregion.width == ev->width) && + (wif->topregion.height == ev->height)) + { + if ((wif->topregion.x != l) || (wif->topregion.y != b)) + { + /* printf("movew to %d, %d.\n", l+wif->outerregion.x, b2+wif->outerregion.y); */ + DoMNWRing(MNWMove, screen, MWindow, l+wif->outerregion.x, b2+wif->outerregion.y, + ev->width-(wif->topregion.width - wif->outerregion.width), ev->height-(wif->topregion.height - wif->outerregion.height)); + } + } + else /* if ((ev->x != wif->outerregion.x) || (ev->y != wif->outerregion.y)) */ + { + /* printf("shapew to %d, %d, %d, %d.\n", l+wif->outerregion.x, b2+wif->outerregion.y, + ev->width-(wif->topregion.width - wif->outerregion.width), ev->height-(wif->topregion.height - wif->outerregion.height)); */ + DoMNWRing(MNWShapeReq, screen, MWindow, l+wif->outerregion.x, b2+wif->outerregion.y, + ev->width-(wif->topregion.width - wif->outerregion.width), ev->height-(wif->topregion.height - wif->outerregion.height)); + } + } + break; + + case ReparentNotify: if (wif) wif->parent = ((XReparentEvent *)xevent)->parent; + break; + + + } +} + + + +void HandleBackgroundButton(widget, wif, xevent, continue_to_dispatch) + Widget widget; + LispPTR wif; + XButtonEvent *xevent; + Boolean *continue_to_dispatch; +{ + MNWButtonEvent *mevent; + + + { /* Copied from HandleMotion -- tell Lisp of mouse move */ + *CLastUserActionCell68k = MiscStats->secondstmp; + (*((DLword *)EmMouseX68K)) = *EmCursorX68K = xevent->x_root; + (*((DLword *)EmMouseY68K)) = *EmCursorY68K = xevent->y_root; + DoRing(); + if(( KBDEventFlg ) > 0) + { + /* immediately request for IRQ check */ + Irq_Stk_End=Irq_Stk_Check=0; + } + } + + lisp_Xbutton(xevent, 0); +#ifdef NEVER + if((xevent->type == ButtonPress) && + ((mevent = (MNWButtonEvent *)NewEvent()) != NULL)) + { + mevent->screen = wif/*->MedleyScreen*/; + mevent->window = 0; + mevent->event = MNWButton; + mevent->pos.x = xevent->x_root; + mevent->pos.y = xevent->y_root; + mevent->button.left = xevent->state | Button1Mask; + mevent->button.middle = xevent->state | Button2Mask; + mevent->button.right = xevent->state | Button3Mask; + SignalMNWEvent(); + } +#endif +} + + +/* Handle expose events on the frame widget -- print the title */ +void HandleTitle(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XExposeEvent *xevent; + Boolean *continue_to_dispatch; +{ + if (xevent->y <= 12) showtitle(wif->MedleyWindow, + ((MedleyWindow)Cptr(wif->MedleyWindow))->WTITLE); +} + + +/* Handle expose events on the frame widget -- print the title */ +void HandleExpose(widget, wif, xevent, continue_to_dispatch) + Widget widget; + WindowInterface wif; + XExposeEvent *xevent; + Boolean *continue_to_dispatch; + { + XCopyPlane(wif->dspif->handle, wif->backing, XtWindow(wif->windowwidget), + wif->ReplaceGC, + xevent->x, xevent->y, xevent->width, xevent->height, + xevent->x, xevent->y, 1); + } + + +void SignalVJmpScroll(widget, wif, percent_ptr) + Widget widget; + WindowInterface wif; + XtPointer percent_ptr; /* This is a *float */ +{ + MNWJumpScrollReqEvent *event; + + if((event = (MNWJumpScrollReqEvent *)NewEvent()) != NULL){ + event->screen = wif->MedleyScreen; + event->window = wif->MedleyWindow; + event->event = MNWScrollJmpReq; + event->xpercent = 0.0; + event->ypercent = *(float *)percent_ptr; + SignalMNWEvent(); + } +} + +void SignalHJmpScroll(widget, wif, percent_ptr) + Widget widget; + WindowInterface wif; + XtPointer percent_ptr; /* This is a *float */ +{ + MNWJumpScrollReqEvent *event; + + if((event = (MNWJumpScrollReqEvent *)NewEvent()) != NULL){ + event->screen = wif->MedleyScreen; + event->window = wif->MedleyWindow; + event->event = MNWScrollJmpReq; + event->ypercent = 0.0; + event->xpercent = *(float *)percent_ptr; + SignalMNWEvent(); + } +} + +void SignalVScroll(widget, wif, position) + Widget widget; + WindowInterface wif; + int position; +{ + MNWScrollReqEvent *event; + + if((event = (MNWScrollReqEvent *)NewEvent()) != NULL){ + event->screen = wif->MedleyScreen; + event->window = wif->MedleyWindow; + event->event = MNWScrollReq; + event->dx = 0; + event->dy = position; + SignalMNWEvent(); + } +} + +void SignalHScroll(widget, wif, position) + Widget widget; + WindowInterface wif; + int position; +{ + MNWScrollReqEvent *event; + + if((event = (MNWScrollReqEvent *)NewEvent()) != NULL){ + event->screen = wif->MedleyScreen; + event->window = wif->MedleyWindow; + event->event = MNWScrollReq; + event->dy = 0; + event->dx = - position; + SignalMNWEvent(); + } +} + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +getMNWsignaldata(fd) + int fd; +{ + Display *display; + DspInterfaceRec *dspif; + XEvent report; + Window window; + WindowInterfaceRec *wif; + LispPTR MWindow; + LispPTR screen; + + display = (dspif = FD_to_dspif[fd])->handle; + screen = dspif->screen; + TPRINT(( "TRACE: getXsignaldata()\n" )); + + while(XtAppPending(dspif->xtcontext)) + { + XtAppNextEvent(dspif->xtcontext, &report); + XtDispatchEvent(&report); + } + +#ifdef NEVER + while(XPending(display)) + { + /* XtAppNextEvent(dspif->xtcontext, &report); */ + XNextEvent( display, &report ); + window = report.xany.window; + + wif = Find_window(dspif, window); + + if (wif) { + switch (report.type) { + case KeyPress: + case KeyRelease: lisp_Xkeyboard(&report, 0); + break; + + case ButtonPress: + case ButtonRelease: lisp_Xbutton(&report, 0); + break; + + case MotionNotify: { + *CLastUserActionCell68k = MiscStats->secondstmp; + (*((DLword *)EmMouseX68K)) = *EmCursorX68K = report.xmotion.x_root; + (*((DLword *)EmMouseY68K)) = *EmCursorY68K = report.xmotion.y_root; + DoRing(); + if(( KBDEventFlg ) > 0) + { + /* immidiately request for IRQ check */ + Irq_Stk_End=Irq_Stk_Check=0; + } + } + break; + + case EnterNotify: if (MWindow) DoMNWRing(MNWMouseIn, screen, MWindow, 0, 0, 0, 0); + break; + + case LeaveNotify: if (NotifyInferior != report.xcrossing.detail) + DoMNWRing(MNWMouseOut, screen, MWindow, 0, 0, 0, 0); + break; + + case FocusIn: DoMNWRing(MNWFocusIn, screen, MWindow, 0, 0, 0, 0); + break; + + case FocusOut: DoMNWRing(MNWFocusOut, screen, MWindow, 0, 0, 0, 0); + break; + + case Expose: if (wif->not_exposed) + { + char *tmpstring; + BITMAP *bitmap; + + + showtitle(MWindow, ((MedleyWindow)Cptr(MWindow))->WTITLE); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(MWindow))->SAVE); + + MBMToDrawable(bitmap, dspif, wif, 0, 0, + wif->innerregion.x, wif->innerregion.y, + wif->innerregion.width, wif->innerregion.height); + XFlush(display); + wif->not_exposed = 0; /* don't expose it again */ + } + + break; + + case NoExpose: + + case CreateNotify: break; + + case DestroyNotify: + + case CirculateNotify: + if (PlaceOnBottom == report.xcirculate.place) + { + DspInterface dspif; + BITMAP *bitmap; + + dspif = DspIfFromMscr(screen); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(MWindow))->SAVE); + + /* Copy the whole black frame to the bitmap. */ + DrawableToMBM(bitmap, dspif, wif->blackframe, wif->screen, 0, 0, 0, 0, + wif->outerregion.width, wif->outerregion.height); + DrawableToMBM(bitmap, dspif, wif->handle, wif->screen, 0, 0, + wif->innerregion.x, wif->innerregion.y, + wif->innerregion.width, wif->innerregion.height); + + } + break; + + default: break; + } + } +/* else {*/ /* No wif found. Assume it is a widget window. */ + /* XtDispatchEvent(&report); */ +/* } */ + } +#endif /* NEVER */ +} /* end getMNWsignaldata() */ + + +/************************************************************************/ +/* */ +/* D o R i n g */ +/* */ +/* Take keyboard events and turn them into Lisp event info */ +/* (when running under X) */ +/* */ +/************************************************************************/ + +DoMNWRing(type, screen, window, l, b, wid, h) + int type; + LispPTR screen, window; + int l, b, wid, h; +{ + DLword w, r; + MNWEvent *event; + int foo = MNWEVENTSIZE; /* so we can examine the value */ + + if (! CTopMNWEvent ) + { + LispPTR index; + index = get_package_atom("\\MNWEVENTQUEUE", 14, "INTERLISP", 9, NIL); + if (index != 0xFFFFFFFF) + { + MNWEVENTQUEUE68k = GetVALCELL68k(index); + DOMNWEVENT_index = get_package_atom("\\DOMNWEVENT", 11, "INTERLISP", 9, NIL); + CTopMNWEvent= (DLword*)Addr68k_from_LADDR(*MNWEVENTQUEUE68k); + } + } + do_ring: + + if (CTopMNWEvent) + { + r=RING_READ(CTopMNWEvent); + w=RING_WRITE(CTopMNWEvent); + + if (r == w) return; + + event=(MNWEvent*)(CTopMNWEvent+ w); + + event->Any.event = type; + event->Any.screen = screen; + event->Any.window = window; + event->Any.pad[0] = l; + event->Any.pad[1] = b; + event->Any.pad[2] = wid; + event->Any.pad[3] = h; + if(r==0) /* Queue was empty */ + ((RING*)CTopMNWEvent)->read=w; + if(w >= MAXMNWEVENT) ((RING*)CTopMNWEvent)->write = MINMNWEVENT; + else ((RING*)CTopMNWEvent)->write = w + MNWEVENTSIZE; + + if (*MNWBUFFERING68k == NIL) *MNWBUFFERING68k = ATOM_T; + if (MNWEventFlg++ > 0) Irq_Stk_End = Irq_Stk_Check = 0; /* Ask for interrupt */ + } +} diff --git a/src/mnxmeth.c b/src/mnxmeth.c new file mode 100755 index 0000000..26c68a6 --- /dev/null +++ b/src/mnxmeth.c @@ -0,0 +1,3727 @@ +/* $Id: mnxmeth.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mnxmeth.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "lispemul.h" +#include "lspglob.h" +#include "cell.h" +#include "lsptypes.h" +#include "stream.h" +#include "array.h" +#include "dspdata.h" +#include "adr68k.h" +#include "mnxdefs.h" + +#include "ScrollBoxP.h" +#include "ScrollBox.h" + +#define BARTHICKNESS 10 +#define BARFRAME 1 + +int MedleyWindowType, MedleyScreenType, MedleyBitmapType; +int gcfunction[4] = {GXcopy, GXor, GXxor, GXandInverted}; +int bltshade_function[4] = {GXcopy, GXcopy, GXxor, GXcopy}; +int xtinitialized = False; + +extern DspInterfaceRec *FD_to_dspif[32]; /* map from FD # to display */ +extern int LispReadFds; +extern int MNWReadFds; +extern char *sysout_name; +extern int save_argc; +extern char **save_argv; + +extern DLword INVERT_atom; +extern DLword ERASE_atom; +extern DLword PAINT_atom; +extern DLword REPLACE_atom; + +/**************************************************************/ +/* Xerrhandler. */ +/* Utility function to make URaid the error handler for X. */ +/**************************************************************/ +int Xerrhandler( display, event ) + Display *display; + XErrorEvent *event; +{ + char msg[80]; + + XGetErrorText(display, event->error_code, msg, 80); + error(msg); +} + +intersectregions(reg1, reg2, result) + MRegion *reg1, *reg2, *result; +{ + result->x = max(reg1->x, reg2->x); + result->y = max(reg1->y, reg2->y); + result->width = result->x - min(reg1->x + reg1->width, + reg2->x + reg2->width); + result->height = result->y - min(reg1->y + reg1->height, + reg2->y + reg2->height); +} + +/**************************************************************/ +/* getwhiteborder */ +/* Utility function to calculate the white border of a window.*/ +/* Takes a medley window as its argument. */ +/**************************************************************/ +int getwhiteborder( medleywindow ) + LispPTR medleywindow; +{ + int border; + + if(((MedleyWindow)Cptr(medleywindow))->WBORDER) + border = LispIntToCInt(((MedleyWindow)Cptr(medleywindow))->WBORDER); + else + border = 0; + + if(border <= 1) + return(0); + else if(border <= 3) + return(1); + else return(2); +} + +/**************************************************************/ +/* getblackborder */ +/* Utility function to calculate the black border of a window.*/ +/* Takes a medley window as its argument. */ +/**************************************************************/ +int getblackborder( medleywindow ) + LispPTR medleywindow; +{ + int border; + + if(((MedleyWindow)Cptr(medleywindow))->WBORDER) + border = LispIntToCInt(((MedleyWindow)Cptr(medleywindow))->WBORDER); + else + border = 0; + + if(border <= 0) + return(0); + else if(border <= 2) + return(1); + else if(border <= 3) + return(2); + else return(border - 2); +} + +/**************************************************************/ +/* gettitlestring */ +/* Utility function to retrieve the titlestring from a window.*/ +/* Takes a medley window as its argument. Returns a pointer to*/ +/* a malloc'd c string or NULL if no string is present. */ +/**************************************************************/ +char *gettitlestring( medleywin ) + LispPTR medleywin; +{ + char *titlestring; + int strlen; + + if(((MedleyWindow)Cptr(medleywin))->WTITLE == NIL) + titlestring = NULL; + else { + strlen = LispStringLength(((MedleyWindow)Cptr(medleywin))->WTITLE); + titlestring = (char *)malloc(strlen + 1); + LispStringToCStr(((MedleyWindow)Cptr(medleywin))->WTITLE, titlestring); + } + return(titlestring); +} + +/**************************************************************/ +/* gettitleheight */ +/* Return the height of the title bar for this window. */ +/* Pick the value from the TITLEDS of the screen. */ +/**************************************************************/ +int gettitleheight( medleywin ) + LispPTR medleywin; +{ + if(((MedleyWindow)Cptr(medleywin))->WTITLE == NIL) + return(0); + else { + DISPLAYDATA *dd; + dd = TitleDDFromMw(medleywin); + return(abs(LispIntToCInt(dd->ddlinefeed))); + } +} + + + + +/**************************************************************/ +/* setlineattributes */ +/* This function attempts to syncronize the line data in lisp */ +/* and X. */ +/**************************************************************/ +void setlineattributes( display, dspif, wif, dd, mwidth, mdash ) + Display *display; + DspInterface dspif; + WindowInterface wif; + DISPLAYDATA *dd; + LispPTR mwidth, mdash; +{ + int l, lw, ls; + unsigned char *dash_list; + + lw = ( mwidth == NIL )?0:LispIntToCInt(mwidth); + ls = ( mdash == NIL )?LineSolid:LineOnOffDash; + + if( dd->ddoperation == INVERT_atom ) + { + XSetLineAttributes( display, wif->InvertGC, lw, ls, CapRound, JoinBevel); + XSetLineAttributes( display, dspif->PixIGC, lw, ls, CapRound, JoinBevel); + } + else if( dd->ddoperation == ERASE_atom ) + { + XSetLineAttributes( display, wif->EraseGC1, lw, ls, CapRound, JoinBevel); + XSetLineAttributes( display, wif->EraseGC2, lw, ls, CapRound, JoinBevel); + XSetLineAttributes( display, dspif->PixEGC, lw, ls, CapRound, JoinBevel); + } + else if( dd->ddoperation == PAINT_atom ) + { + XSetLineAttributes( display, wif->PaintGC1, lw, ls, CapRound, JoinBevel); + XSetLineAttributes( display, wif->PaintGC2, lw, ls, CapRound, JoinBevel); + XSetLineAttributes( display, dspif->PixPGC, lw, ls, CapRound, JoinBevel); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XSetLineAttributes( display, wif->ReplaceGC, lw, ls, CapRound, JoinBevel); + XSetLineAttributes( display, dspif->PixRGC, lw, ls, CapRound, JoinBevel); + } + + if( mdash != NIL ) { + l = LispStringLength( mdash ); + dash_list = (unsigned char *)malloc(l + 1); + LispStringToCStr( mdash , dash_list); + + if( dd->ddoperation == INVERT_atom ) + { + XSetDashes(display, wif->InvertGC, 0, dash_list, l); + XSetDashes(display, dspif->PixIGC, 0, dash_list, l); + } + else if( dd->ddoperation == ERASE_atom ) + { + XSetDashes(display, wif->EraseGC1, 0, dash_list, l); + XSetDashes(display, wif->EraseGC2, 0, dash_list, l); + XSetDashes(display, dspif->PixEGC, 0, dash_list, l); + } + else if( dd->ddoperation == PAINT_atom ) + { + XSetDashes(display, wif->PaintGC1, 0, dash_list, l); + XSetDashes(display, wif->PaintGC2, 0, dash_list, l); + XSetDashes(display, dspif->PixPGC, 0, dash_list, l); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XSetDashes(display, wif->ReplaceGC, 0, dash_list, l); + XSetDashes(display, dspif->PixRGC, 0, dash_list, l); + } + } +} + +settileorigin(medleywin, x, y) + LispPTR medleywin, x, y; +{ + WindowInterface wif; + Display *display; + + wif = WIfFromMw(medleywin); + display = XtDisplay(wif->windowwidget); + + XSetTSOrigin(display, wif->InvertGC, x, y); + XSetTSOrigin(display, wif->EraseGC1, x, y); + XSetTSOrigin(display, wif->EraseGC2, x, y); + XSetTSOrigin(display, wif->PaintGC1, x, y); + XSetTSOrigin(display, wif->PaintGC2, x, y); + XSetTSOrigin(display, wif->ReplaceGC, x, y); + XSetTSOrigin(display, wif->dspif->PixIGC, x, y); + XSetTSOrigin(display, wif->dspif->PixEGC, x, y); + XSetTSOrigin(display, wif->dspif->PixPGC, x, y); + XSetTSOrigin(display, wif->dspif->PixRGC, x, y); +} + + + +/**************************************************************/ +/**************************************************************/ +calculateshape( wif, x, y, width, height, topwidoffset, tophgtoffset) + WindowInterface wif; + LispPTR x, y, width, height; + int topwidoffset, tophgtoffset; +{ + + wif->windowreg.width = LispIntToCInt( width ); + wif->windowreg.height = LispIntToCInt( height ); + wif->windowreg.x = LispIntToCInt( x ); + wif->windowreg.y = LispIntToCInt( y ); + calcwif(wif, topwidoffset, tophgtoffset); +} + + +/**************************************************************/ +/* calcwif */ +/* layout the regions. All calculations based on the outer */ +/* region. The rest of the widget moves around this region. */ +/**************************************************************/ +calcwif(wif, xoff, yoff) + WindowInterface wif; + int xoff, yoff; +{ + int whiteborder, blackborder, blackborder2, titleheight, border; + + blackborder = getblackborder( wif->MedleyWindow ); + blackborder2 = blackborder + blackborder; + whiteborder = getwhiteborder( wif->MedleyWindow ); + + /* Calculate the top & outer region */ + wif->outerregion.y = 0; + wif->outerregion.x = 0; + + wif->outerregion.width = wif->windowreg.width; + wif->topregion.width = wif->outerregion.width + /* wif->outerregion.x; */ + xoff; + + wif->outerregion.height = wif->windowreg.height; + wif->topregion.height = wif->outerregion.height + yoff; + + wif->topregion.x = wif->windowreg.x - wif->outerregion.x; + wif->topregion.y = (HeightOfScreen( wif->screen ) + - wif->windowreg.y + - wif->windowreg.height); + + titleheight = gettitleheight( wif->MedleyWindow ); + + /* Calculate the inner region. */ + border = 2*(blackborder + whiteborder); + wif->innerregion.x = blackborder; + wif->innerregion.y = blackborder + titleheight; + wif->innerregion.width = wif->windowreg.width - border; + wif->innerregion.height = wif->windowreg.height - border - titleheight; + + wif->whiteborder = whiteborder; + wif->blackborder2 = blackborder2; + + sprintf(wif->gstring, "%dx%d+%d+%d", + wif->topregion.width, + wif->topregion.height, + wif->topregion.x, + wif->topregion.y); +} + + + +/**************************************************************/ +/**************************************************************/ +refreshwindow( medleywin ) + LispPTR medleywin; +{ + WindowInterface wif; + DISPLAYDATA *dd; + float top, shown; + + wif = WIfFromMw( medleywin ); + dd = ImDataFromMw(medleywin); + calcwif(wif, wif->topregion.width-wif->outerregion.width, + wif->topregion.height - wif->outerregion.height); + XtVaSetValues(wif->formwidget, + XtNclippX, dd->ddclippingleft, + XtNclippY, dd->ddclippingbottom, + XtNclippWidth, dd->ddclippingright - dd->ddclippingleft, + XtNclippHeight, dd->ddclippingtop - dd->ddclippingbottom, + NULL); + if(XtIsRealized(wif->topwidget)){ + XtConfigureWidget(wif->topwidget, + wif->topregion.x, + wif->topregion.y, + wif->topregion.width, + wif->topregion.height, 0); + + XtConfigureWidget(wif->framewidget, + wif->outerregion.x, + wif->outerregion.y, + wif->outerregion.width, + wif->outerregion.height, 0); + + XtConfigureWidget(wif->windowwidget, + wif->innerregion.x, + wif->innerregion.y, + wif->innerregion.width, + wif->innerregion.height, + wif->whiteborder); + } +} + + + +/************************************************************************/ +/* */ +/* Translate X & Y window coords, allowing for offsets. */ +/* */ +/* XVAL & YVAL are already real integers. */ +/* */ +/************************************************************************/ + +int translate_x(wif, xval) + int xval; + WindowInterface wif; + { + return (xval + (wif->xoffset - wif->windowreg.x + - (wif->blackborder2>>1) - wif->whiteborder )); + } + + + +int translate_y(wif, yval) + int yval; + WindowInterface wif; + { + return (yval + wif->yoffset + - (wif->windowreg.y + (wif->blackborder2>>1) + wif->whiteborder)); + } + + + + + + +extern void SignalVJmpScroll(); +extern void SignalVScroll(); +extern void SignalHJmpScroll(); +extern void SignalHScroll(); +extern void HandleBackgroundButton(); +extern void HandleBackgroundCrossing(); +extern void HandleButton(); +extern void HandleMotion(); +extern void HandleKey(); +extern void HandleCrossing(); +extern void HandleFocus(); +extern void HandleStructure(); +extern void HandleTitle(); +extern void HandleExpose(); + + +/**************************************************************/ +/* InitScratchDepth */ +/* Init the scratch image to fit the description of a bitmap */ +/**************************************************************/ +InitScratchDepth(image, MBM, scdepth) + XImage *image; + BITMAP *MBM; + int scdepth; +{ /* Set up the scratch image for this operation */ + image->width = MBM->bmwidth; + image->height = MBM->bmheight; + + /* depth 1 implies that X should colorize */ + if((MBM->bmbitperpixel & 0xFFFF) == 1) + { + image->depth = MBM->bmbitperpixel & 0xFFFF; + image->bits_per_pixel = 1; + image->bytes_per_line = + (((image->width+(BITSPER_DLWORD-1)) + / BITSPER_DLWORD) + * (BITSPER_DLWORD/8)); + if (image->format != XYBitmap) + { + image->format = XYBitmap; + _XInitImageFuncPtrs(image); + } + } + else/* if(image->format != ZPixmap) */ + { + image->depth = MBM->bmbitperpixel & 0xFFFF; + image->format = ZPixmap; + image->red_mask = (scdepth / 3); + image->green_mask = ((scdepth - image->red_mask) / 2); + image->blue_mask = (scdepth - image->red_mask - image->green_mask); + image->bits_per_pixel = image->depth; + _XInitImageFuncPtrs(image); + image->bytes_per_line = + ((((image->width * image->depth)+(BITSPER_DLWORD-1)) + / BITSPER_DLWORD) + * (BITSPER_DLWORD/8)); + } +} + + +/**************************************************************/ +/* MakeScratchImageFromBM */ +/* Convert a Lisp BITMAP to fit in the scratch image in the */ +/* dspif. Use the scratch image in subsequent computations. */ +/**************************************************************/ +MakeScratchImageFromBM(dspif, bitmap) + DspInterface dspif; + BITMAP *bitmap; +{ + InitScratchDepth(&dspif->image, bitmap, + DefaultDepthOfScreen(dspif->xscreen)); + + dspif->image.data = (char *)Cptr((LispPTR)bitmap->bmbase); +} + + + +/**************************************************************/ +/* MakeScratchImageFromInt */ +/* Convert a Lisp integer to be a bitmap in the scratch image */ +/* in the dspif. Use the scratch image in subsequent */ +/* computations. */ +/* DANGER!! This function presumes that you have a valid data */ +/* slot. ie. the caller have to make sure that the data area */ +/* is allocated. */ +/**************************************************************/ +int revbits[16] = {15, 7, 11, 3, 13, 5, 9, 1, 14, 6, 10, 2, 12, 4, 8, 0}; +MakeScratchImageFromInt(dspif, Texture) + DspInterface dspif; + int Texture; +{ + int width, height, pixpos, x, y; + unsigned char *bits = (unsigned char *) dspif->image.data; + unsigned int tbits; + width = height = 4; + pixpos = 0; + dspif->image.width = width; + dspif->image.height = height; + dspif->image.depth = 1; + dspif->image.format = XYBitmap; + dspif->image.bytes_per_line = + ((width+(BITSPER_DLWORD-1)) /BITSPER_DLWORD) * (BITSPER_DLWORD/8); + + + tbits= revbits[Texture >> 12]; + bits[0] = (tbits<<4) | tbits; + tbits= revbits[15 & (Texture >> 8)]; + bits[1] = (tbits<<4) | tbits; + tbits= revbits[15 & (Texture >> 4)]; + bits[2] = (tbits<<4) | tbits; + tbits= revbits[15 & (Texture)]; + bits[3] = (tbits<<4) | tbits; + +} + + + +/**************************************************************/ +/* settexture */ +/* Argument is a Medleywindow. This function scans the texture*/ +/* slot of the DISPLAYDATA structure. If that slot has a value*/ +/* the Xwindow's background is updated to match that value. */ +/* NOTE!!: Medley tiles from the lower left corner. X tiles */ +/* the background from the upper left corner. This is not */ +/* accounted for. */ +/**************************************************************/ +settexture(medleywin) + LispPTR medleywin; +{ + DspInterface dspif; + WindowInterface wif; + DISPLAYDATA *dd; + Pixmap bgpixmap; + Display *display; + + dspif = DspIfFromMw(medleywin); + wif = WIfFromMw(medleywin); + dd = ImDataFromMw(medleywin); + display = dspif->handle; + + if(dd->ddtexture != NIL){ + if(GetTypeNumber(dd->ddtexture) == TYPE_SMALLP) + if(LispIntToCInt(MScrFromMw(medleywin)->SCDEPTH) == 1){ + char id[64]; + dspif->image.data = id; /* Danger zone! read comment for function in next call */ + MakeScratchImageFromInt(dspif, LispIntToCInt(dd->ddtexture)); + } + else { + unsigned long pixval; + + pixval = ~(unsigned long)LispIntToCInt(dd->ddtexture); + /* Set the background for pixel ops in this window */ + XSetBackground(display, wif->InvertGC, pixval); + XSetBackground(display, wif->EraseGC1, pixval); + XSetBackground(display, wif->EraseGC2, pixval); + XSetBackground(display, wif->PaintGC1, pixval); + XSetBackground(display, wif->PaintGC2, pixval); + XSetBackground(display, wif->ReplaceGC, pixval); + XSetBackground(display, dspif->PixIGC, pixval); + XSetBackground(display, dspif->PixEGC, pixval); + XSetBackground(display, dspif->PixPGC, pixval); + XSetBackground(display, dspif->PixRGC, pixval); + XtVaSetValues(wif->windowwidget, XtNbackground, pixval, NULL); + return(NIL); + } + + else { /* Its a bitmap */ + MakeScratchImageFromBM(dspif, (BITMAP *)Cptr(dd->ddtexture)); + } + } + else { /* ddtexture is NIL */ + char id[64]; + dspif->image.data = id; /* Danger zone! read comment for function in next call */ + MakeScratchImageFromInt(dspif, 0); + } + + if(wif->bgpixmap){ + /* If we have an fgpixmap, junk it */ + XFreePixmap(display, wif->bgpixmap); + wif->bgpixmap = 0; + } + + bgpixmap = XCreatePixmapFromBitmapData + (display, + dspif->root, + dspif->image.data, + dspif->image.width, + dspif->image.height, + WhitePixelOfScreen(wif->screen), + BlackPixelOfScreen(wif->screen), + DefaultDepthOfScreen(wif->screen)); + XSetTile(display, wif->InvertGC, bgpixmap); + XSetTile(display, wif->EraseGC1, bgpixmap); + XSetTile(display, wif->EraseGC2, bgpixmap); + XSetTile(display, wif->PaintGC1, bgpixmap); + XSetTile(display, wif->PaintGC2, bgpixmap); + XSetTile(display, wif->ReplaceGC, bgpixmap); +/* XSetTile(display, dspif->PixIGC, bgpixmap); + XSetTile(display, dspif->PixEGC, bgpixmap); + XSetTile(display, dspif->PixPGC, bgpixmap); + XSetTile(display, dspif->PixRGC, bgpixmap); */ + XtVaSetValues(wif->windowwidget, XtNbackgroundPixmap, bgpixmap, NULL); + + wif->bgpixmap = bgpixmap; + + return(NIL); +} + + + + +MBMToDrawable(MBM, dspif, wif, srcx, srcy, dstx, dsty, width, height, operation) + BITMAP *MBM; + WindowInterface wif; + DspInterface dspif; + int srcx, srcy, dstx, dsty, width, height, operation; +{ + Window window; + window = XtWindow(wif->windowwidget); + + if((MBM->bmbitperpixel == 1) || + (MBM->bmbitperpixel == DefaultDepthOfScreen(wif->screen))) + { + InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(wif->screen)); + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + switch(operation) + { + case REPLACE: if (window) XPutImage(dspif->handle, window, wif->ReplaceGC, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixRGC, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; + + case INVERT: if (window) XPutImage(dspif->handle, + window, wif->InvertGC, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixIGC, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; + + case PAINT: if (window) XPutImage(dspif->handle, window, wif->PaintGC1, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + if (window) XPutImage(dspif->handle, window, wif->PaintGC2, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixPGC, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; + + case ERASE: if (window) XPutImage(dspif->handle, window, wif->EraseGC1, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + if (window) XPutImage(dspif->handle, window, wif->EraseGC2, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixEGC, + &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; + } + } + else { + /* JDS 2/22/94: I'm not sure this part is right; haven't thought about it. */ + int x, y; + InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(wif->screen)); + dspif->image.depth = DefaultDepthOfScreen(wif->screen); + dspif->image.data = (char *)malloc(dspif->image.bytes_per_line + * dspif->image.width + * dspif->image.depth); + + InitScratchDepth(&dspif->tmpimage, MBM, DefaultDepthOfScreen(wif->screen)); + dspif->tmpimage.data = (char *)Cptr((LispPTR)MBM->bmbase); + for(x = 0; x < MBM->bmwidth; x++) + for(y = 0; y < MBM->bmheight; y++) + XPutPixel(&dspif->image, x, y, XGetPixel(&dspif->tmpimage, x, y)); + if( operation == INVERT_atom ) + { + XPutImage(dspif->handle, window, wif->InvertGC, + &dspif->image, srcx,srcy,dstx,dsty,width,height); + } + else if( operation == ERASE_atom ) + { + XPutImage(dspif->handle, window, wif->EraseGC1, + &dspif->image, srcx,srcy,dstx,dsty,width,height); + XPutImage(dspif->handle, window, wif->EraseGC2, + &dspif->image, srcx,srcy,dstx,dsty,width,height); + } + else if( operation == PAINT_atom ) + { + XPutImage(dspif->handle, window, wif->PaintGC1, + &dspif->image, srcx,srcy,dstx,dsty,width,height); + XPutImage(dspif->handle, window, wif->PaintGC2, + &dspif->image, srcx,srcy,dstx,dsty,width,height); + } + else if( operation == REPLACE_atom ) + { + XPutImage(dspif->handle, window, wif->ReplaceGC, + &dspif->image, srcx,srcy,dstx,dsty,width,height); + } + free(dspif->image.data); + } +} + + + +/************************************************************************/ +/* DrawableToMBM */ +/* Copy a drawable to a Medley bitmap. All coordinates are in X style. */ +/* (i.e. y-coordinate assumed to be transformed) */ +/* Since XGetSubImage will generate an error if the drawable is outside */ +/* the rootwindow we have to get the geometry and clipp it with the */ +/* geometry of the root window. (Urk!) */ +/* This offcause means that anything outside the screen will have to be */ +/* ignored. (This has to be fixed. This sucks.). */ +/************************************************************************/ +DrawableToMBM(MBM, dspif, wif, xdrawable, xscreen, srcx, srcy, dstx, dsty, width, height, op) + BITMAP *MBM; + WindowInterface wif; + Screen *xscreen; + Drawable xdrawable; + DspInterface dspif; + int srcx, srcy, dstx, dsty, width, height, op; +{ +#ifdef NEVER + if(MBM->bmbitperpixel == DefaultDepthOfScreen(xscreen)) + { + InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(xscreen)); + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + XGetSubImage(dspif->handle, + xdrawable, + srcx, srcy, + width, height, + AllPlanes, + ZPixmap, + &dspif->image, dstx, dsty); + } + else + { + int x, y, scdepth; + BITMAP tmp; + + + scdepth = DefaultDepthOfScreen(xscreen); + tmp.bmwidth = MBM->bmwidth; + tmp.bmheight = MBM->bmheight; + tmp.bmbitperpixel = scdepth; + InitScratchDepth(&dspif->tmpimage, &tmp, scdepth); + dspif->tmpimage.depth = scdepth; + dspif->tmpimage.data = (char *)malloc(dspif->tmpimage.bytes_per_line + * dspif->tmpimage.width + * dspif->tmpimage.depth); + XGetSubImage(dspif->handle, + xdrawable, + srcx, srcy, + width, height, + AllPlanes, + ZPixmap, + &dspif->tmpimage, dstx, dsty); + + InitScratchDepth(&dspif->image, MBM, MBM->bmbitperpixel); + + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + for(x = 0; x < MBM->bmwidth; x++) + for(y = 0; y < MBM->bmheight; y++) + XPutPixel(&dspif->image, x, y, !XGetPixel(&dspif->tmpimage, x, y)); + free(dspif->tmpimage.data); + } +#else /* NEVER */ + InitScratchDepth(&dspif->image, MBM, 1); + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + XGetSubImage(dspif->handle, + xdrawable, + srcx, srcy, + width, height, + AllPlanes, + ZPixmap, + &dspif->image, dstx, dsty); +#endif /* Never */ + +} + + + +MNXBBTToXWindow( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to src BITMAP */ + /* args[2] = scr_x */ + /* args[3] = scr_y */ + /* args[4] = dst WINDOW */ + /* args[5] = dst_x */ + /* args[6] = dst_y */ + /* args[7] = width */ + /* args[8] = height */ + /* args[9] = operation */ +{ + WindowInterface wif; + DspInterface dspif; + Display *display; + BITMAP *bitmap; + int width, height, depth, srcy, dsty; + + wif = WIfFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = XDisplayFromMw(args[0]); + bitmap = (BITMAP *)Cptr(args[1]); + + if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + /* Transform the coordinates */ + width = LispIntToCInt(args[7]); + height = LispIntToCInt(args[8]); + dsty = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[6])) - height; + srcy = (bitmap->bmheight & 0xFFFF) - LispIntToCInt(args[3]) - height; + + MBMToDrawable(bitmap, dspif, wif, + LispIntToCInt(args[2]), /* src x */ + srcy, + translate_x(wif, LispIntToCInt(args[5])), /* dst x */ + dsty, width, height, args[9]&0xF); + XFlush(display); +} + + + + +MNXBBTFromXWindow( args ) + LispArgs args; /* args[0] = LispPTR to src WINDOW */ + /* args[1] = scr_x */ + /* args[2] = scr_y */ + /* args[3] = LispPTR to dst BITMAP */ + /* args[4] = dst_x */ + /* args[5] = dst_y */ + /* args[6] = width */ + /* args[7] = height */ + /* args[8] = operation */ + /* Things to remember: This function does not handle integer-textures */ + /* The handling of the OPERATION argument is done in lisp */ +{ + WindowInterface wif; + DspInterface dspif; + Display *display; + BITMAP *bitmap; + int width, height, depth, srcx, srcy, dstx, dsty; + + wif = WIfFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = XDisplayFromMw(args[0]); + bitmap = (BITMAP *)Cptr(args[3]); + + if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + + /* Transform the coordinates */ + srcx = max(0, translate_x(wif, LispIntToCInt(args[1]))); + dstx = LispIntToCInt(args[4]); + + width = min(LispIntToCInt(args[6]), wif->innerregion.width - max(0, srcx));; + height = min(LispIntToCInt(args[7]), wif->innerregion.height - LispIntToCInt(args[2]));; + srcy = max(0, wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - height); + dsty = (bitmap->bmheight & 0xFFFF) - LispIntToCInt(args[5]) - height; + + DrawableToMBM(bitmap, dspif, wif, wif->backing, wif->screen, srcx, srcy, dstx, dsty, width, height, args[8]&0xF); + + XFlush(display); + return(ATOM_T); +} + + +MNXBBTWinWin( args ) + LispArgs args; /* args[0] = LispPTR to src WINDOW */ + /* args[1] = scr_x */ + /* args[2] = scr_y */ + /* args[3] = LispPTR to dst WINDOW */ + /* args[4] = dst_x */ + /* args[5] = dst_y */ + /* args[6] = width */ + /* args[7] = height */ + /* args[8] = operation */ + /* Things to remember: This function does not handle integer-textures */ +{ + WindowInterface srcwif, dstwif; + DspInterface dspif; + Display *display; + Window swin, dwin; + BITMAP *bitmap; + DISPLAYDATA *dd; + int width, height, depth, srcy, dsty, srcx, dstx; + + srcwif = WIfFromMw(args[0]); + dstwif = WIfFromMw(args[3]); + dspif = DspIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + display = XtDisplay(srcwif->windowwidget); + swin = XtWindow(srcwif->windowwidget); + dwin = XtWindow(dstwif->windowwidget); + + + if (!srcwif->open) return(NIL); /* If window not open, don't do anything. */ + if (!dstwif->open) return(NIL); /* If window not open, don't do anything. */ + + + /* Transform the coordinates */ + width = LispIntToCInt(args[6]); + height = LispIntToCInt(args[7]); + dsty = dstwif->innerregion.height - translate_y(dstwif, LispIntToCInt(args[5])) - height; + srcy = srcwif->innerregion.height - translate_y(srcwif, LispIntToCInt(args[2])) - height; + srcx = translate_x(srcwif, LispIntToCInt(args[1])); + dstx = translate_x(dstwif, LispIntToCInt(args[4])); + + switch (args[8] & 0xF) + { + case INVERT: XCopyArea( display, swin, dwin, srcwif->InvertGC, + srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, + dspif->PixIGC, srcx, srcy, width, height, + dstx, dsty); + break; + + case ERASE: XCopyArea(display, swin, dwin, srcwif->EraseGC1, + srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, swin, dwin, srcwif->EraseGC2, + srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, + dspif->PixEGC, srcx, srcy, width, height, + dstx, dsty); + break; + + case PAINT: XCopyArea(display, swin, dwin, srcwif->PaintGC1, + srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, swin, dwin, srcwif->PaintGC2, + srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, + dspif->PixPGC, srcx, srcy, width, height, + dstx, dsty); + break; + + case REPLACE: XCopyArea(display, swin, dwin, srcwif->ReplaceGC, + srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, + dspif->PixRGC, srcx, srcy, width, height, + dstx, dsty); + break; + } + + XFlush(display); + return(ATOM_T); +} + + + +/************************************************************************/ +/* MNXcloseW */ +/* Close a window and save the inner region of the window. */ +/* NOTE! we don't save the whiteframe, blackframe or the title. This is */ +/* contrary to Medleys own window system. If you do tricks with the */ +/* SAVE field of the window, reconsider your evil ways. */ +/************************************************************************/ +MNXcloseW ( args ) + LispArgs args; +{ + Display *display; + WindowInterface wif; + DspInterface dspif; + BITMAP *bitmap; + + display = XDisplayFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + + if (!wif->open) return(NIL); /* If window not open, don't close it. */ + wif->open = 0; /* If it is, tell others it's closed. */ + + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); + DrawableToMBM(bitmap, dspif, wif, wif->backing, wif->screen, 0, 0, + /* wif->innerregion.x, wif->innerregion.y, */ 0, 0, + wif->innerregion.width, wif->innerregion.height, REPLACE); + XtUnrealizeWidget(wif->topwidget); + + XtRemoveEventHandler(wif->framewidget, + ButtonPressMask | ButtonReleaseMask, + False, HandleButton, wif); + XtRemoveEventHandler(wif->framewidget, + PointerMotionMask, + False, HandleMotion, wif); + XtRemoveEventHandler(wif->framewidget, + KeyPressMask | KeyReleaseMask, + False, HandleKey, wif); + XtRemoveEventHandler(wif->framewidget, + EnterWindowMask | LeaveWindowMask, + False, HandleCrossing, wif); + XtRemoveEventHandler(wif->framewidget, + FocusChangeMask, + False, HandleFocus, wif); + XtRemoveEventHandler(wif->framewidget, + ExposureMask, + False, HandleTitle, wif); + XtRemoveEventHandler(wif->windowwidget, + ExposureMask, + False, HandleExpose, wif); + XtRemoveEventHandler(wif->topwidget, + StructureNotifyMask, + False, HandleStructure, wif); + wif->not_exposed = 1; /* next time we open this, display it */ + XFlush(display); + return(ATOM_T); +} + + + +WindowInterface removewif(chain, wif) + WindowInterface chain, wif; +{ + /* Recursive unlink off the wif from chain */ + if(chain == (WindowInterface)NULL) + return(NULL); + else if(chain == wif) return(chain->next); + else { + chain->next = removewif(chain->next, wif); + return(chain); + } +} + + + +/************************************************************************/ +/* bubblewif */ +/* Make shure that the wif is the first wif in the chain of wifs on the */ +/* dspif. If not, make it so. */ +/* Return wif if we find wif. Return NIL if we don't find wif. */ +/* */ +/************************************************************************/ +WindowInterface bubblewif(dspif, wif) + DspInterface dspif; + WindowInterface wif; +{ + WindowInterface curr, prev; + + if(dspif->CreatedWifs == (WindowInterface)NULL) return(NIL); + if(dspif->CreatedWifs == wif) return(wif); + + /* Find the wif we are interested in. */ + for(prev = dspif->CreatedWifs, curr = prev->next; + ((curr != (WindowInterface)NULL) && (curr != wif)); + curr = curr->next, prev = prev->next); + if(curr == (WindowInterface)NULL) return(NIL); /* wif not found */ + + /* Bubble curr to the head of the list */ + prev->next = curr->next; + curr->next = dspif->CreatedWifs; + dspif->CreatedWifs = curr; + return(wif); +} + + + +/************************************************************************/ +/* destroyw/Xdestroyw */ +/* Destroy a window by freeing all structures associated with it. */ +/* */ +/************************************************************************/ +destroyw(dspif, wif, medleyw) + WindowInterface wif; + DspInterface dspif; + MedleyWindow medleyw; + +{ /* Tell X to destroy its part. */ + + if(wif->topwidget) XtDestroyWidget(wif->topwidget); + if(wif->InvertGC) XFreeGC(dspif->handle, wif->InvertGC); + if(wif->EraseGC1) XFreeGC(dspif->handle, wif->EraseGC1); + if(wif->EraseGC2) XFreeGC(dspif->handle, wif->EraseGC2); + if(wif->PaintGC1) XFreeGC(dspif->handle, wif->PaintGC1); + if(wif->PaintGC2) XFreeGC(dspif->handle, wif->PaintGC2); + if(wif->ReplaceGC) XFreeGC(dspif->handle, wif->ReplaceGC); + + XFreePixmap(dspif->handle, wif->backing); + + dspif->CreatedWifs = removewif(dspif->CreatedWifs, wif); + + /* Throw away the window and free the space. */ + (void)free(wif); + medleyw->NativeIf = 0; +} + + + +MNXdestroyW( args ) + LispArgs args; +{ +/* Medley interface to destroyw */ + destroyw( DspIfFromMw(args[0]), WIfFromMw(args[0]),Cptr(args[0])); + return(ATOM_T); +} + + + + +/************************************************************************/ +/* MNXdestroyDisplay */ +/* Closeing down the screen means that we have to invalidate all window */ +/* handles. When a window is opened (in Medley) we test the windows */ +/* handle. If it is NIL we have to reexternalize it before we open it. */ +/* */ +/************************************************************************/ + +MNXdestroyDisplay( args ) + LispArgs args; /* args[0] = LispPTR to MedleyScreen */ +{ + DspInterface dspif; + WindowInterface i; + MedleyScreen MScreen; + int Xfd; + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + + Xfd = ConnectionNumber(dspif->handle); + FD_to_dspif[Xfd] = 0; + LispReadFds &= ~(1 << Xfd); + MNWReadFds &= ~(1 << Xfd); + + if (dspif->cursor) XFreeCursor(dspif->handle, dspif->cursor); + dspif->cursor = 0; + + /* Smash the handles of all the created wifs. */ + if(dspif != NULL) + { + for(i = dspif->CreatedWifs; i != NULL; i = dspif->CreatedWifs) + destroyw(dspif, i, (MedleyWindow)Cptr(i->MedleyWindow)); + + if (dspif->legatewidget) XtDestroyWidget(dspif->legatewidget); + XtCloseDisplay(dspif->handle); + (void)free(dspif); + } +} + + + + +MNXmoveW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = non-NIL => skip actually moving it */ +{ + Display *dsp; + WindowInterface wif; + + dsp = XDisplayFromMw(args[0]); + wif = WIfFromMw(args[0]); + + if (!wif) return(NIL); /* no real window, no action. */ + wif->moving = 1; /* tell event handler to expect an event */ + + wif->windowreg.x = LispIntToCInt(args[1]); + wif->windowreg.y = LispIntToCInt(args[2]); + calcwif(wif, wif->topregion.width-wif->outerregion.width, + wif->topregion.height-wif->outerregion.height); + /* stolen from calculateshape */ + + /* printf("MOVEW to %d, %d.\n", wif->windowreg.x, wif->windowreg.y); */ + if (!args[3]) + { + if (wif->open) + XtMoveWidget( wif->topwidget + , wif->topregion.x + , wif->topregion.y + , 0); + else + { + wif->move_pend = 1; /* Save the move for when we open it. */ + } + XFlush(dsp); + } + return(ATOM_T); +} + + + +MNXshapeW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = width */ + /* args[4] = height */ +{ + Display *dsp; + WindowInterface wif; + XtWidgetGeometry geom; + + wif = WIfFromMw(args[0]); + if (!wif) return(NIL); /* no real window, no action. */ + wif->reshaping = 1; /* tell event handler to expect an event */ + + dsp = XDisplayFromMw(args[0]); + calculateshape( wif, args[1], args[2], args[3], args[4], + wif->topregion.width - wif->outerregion.width, + wif->topregion.height - wif->outerregion.height); + /* printf("SHAPEW to %d, %d, %d, %d.\n", args[1]&0xFFFF, args[2]&0xFFFF, + args[3]&0xFFFF, args[4]&0xFFFF); */ + if (wif->open) + { + refreshwindow( args[0] ); + XtVaSetValues(wif->formwidget, XtNextentX, 0, XtNextentY, 0, + XtNextentWidth, args[3] & 0xFFFF, + XtNextentHeight, args[4] & 0xFFFF, + NULL); + XtMoveWidget(wif->topwidget, args[1] & 0xFFFF, + HeightOfScreen(wif->screen) - + (args[2] & 0xFFFF) - wif->topregion.height); + } + else + { + wif->shape_pend = 1; + } + + XFreePixmap(wif->dspif->handle, wif->backing); + wif->backing = XCreatePixmap(dsp, wif->dspif->root, + args[3] & 0xFFFF, args[4] & 0xFFFF, 1); + + XFlush(dsp); + return(ATOM_T); +} + + + + +MNXtotopW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{ + Display *dsp; + WindowInterface wif; + + dsp = XDisplayFromMw(args[0]); + wif = WIfFromMw(args[0]); + + if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + XRaiseWindow( dsp, XtWindow(wif->topwidget)); + XFlush(dsp); + return(ATOM_T); +} + + + + +MNXburyW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{ + Display *dsp; + WindowInterface wif; + + dsp = XDisplayFromMw(args[0]); + wif = WIfFromMw(args[0]); + + if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + XLowerWindow( dsp, XtWindow(wif->topwidget)); + XFlush(dsp); + return(ATOM_T); +} + + + +MNXshrinkW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to icon MedleyWindow. */ + /* args[2] = Iconwindow x */ + /* args[3] = Iconwindow y */ + /* args[4] = Iconwindow width */ + /* args[5] = Iconwindow height */ +{ + Screen *screen; + Display *display; + XImage Xbm; + XWMHints Lisp_WMhints; + BITMAP *bitmap; + WindowInterface wif, iconwif; + DspInterface dspif; + int depth; + + dspif = DspIfFromMw(args[0]); + display = dspif->handle; + + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); + wif = WIfFromMw(args[0]); + + if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + iconwif = WIfFromMw(args[1]); + + XtVaSetValues(wif->topwidget, XtNiconWindow, iconwif->blackframe, NULL); + + DrawableToMBM(bitmap, dspif, wif, wif->backing, XtScreen(wif->topwidget), 0, 0, 0, 0, + wif->innerregion.width, wif->innerregion.height, REPLACE); + XIconifyWindow( XtDisplay(wif->topwidget) + , XtWindow(wif->topwidget) + , DefaultScreen(display)); + XFlush(display); + return(ATOM_T); +} + + + +MNXexpandW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{ + DspInterface dspif; + WindowInterface wif; + BITMAP *bitmap; + + wif = WIfFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + + if (! args[0]) return(NIL); + if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + XMapWindow(XtDisplay(wif->topwidget), XtWindow(wif->topwidget)); + showtitle(args[0]); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); + MBMToDrawable(bitmap, dspif, wif, 0, 0, 0, 0, + wif->innerregion.width, wif->innerregion.height, + REPLACE); + XFlush(XtDisplay(wif->topwidget)); + return(ATOM_T); +} + + + +MNXcreateW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = width */ + /* args[4] = height */ +{ + XGCValues gcv; + XVisualInfo vinfo, *vinfo2; + XSizeHints sizehints; + + Screen *screen; + Display *display; + Window *window; + MedleyScreenRec *mscreen; + + WindowInterface wif; + DspInterface dspif; + + int width, height, border, whiteborder, blackborder, titleheight; + int strlen, scrno, vcount; + char *tmpstring; + BITMAP *bitmap; + DISPLAYDATA *dd; + + /***********************************/ + /* Initialize the window structure */ + /***********************************/ + wif = (WindowInterface)malloc(sizeof(WindowInterfaceRec)); + WIfFromMw(args[0]) = wif; + mscreen = ScrnFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = XDisplayFromMw(args[0]); + + scrno = DefaultScreen(display); + wif->screen = ScreenOfDisplay( display, scrno); + wif->Dispatch = &(dspif->ImageOp); + wif->MedleyWindow = args[0]; /* so we know what WINDOW this corresponds to */ + /* Cache the MScreen for the benefit of the signals. */ + wif->MedleyScreen = ((MedleyWindow)Cptr(args[0]))->SCREEN; + wif->dspif = dspif; + wif->fgpixmap = 0; /* Cache for the foreground pixmap. */ + wif->bgpixmap = 0; /* Cache for the foreground pixmap. */ + whiteborder = getwhiteborder( args[0] ); + blackborder = getblackborder( args[0] ); + tmpstring = gettitlestring( args[0] ); + + dd = ImDataFromMw(args[0]); + wif->xoffset = LispIntToCInt(dd->ddxoffset); + wif->yoffset = LispIntToCInt(dd->ddyoffset); + /* Special case for Icons and windows with no content and only a titlebar */ + if (wif->innerregion.height == 0) whiteborder = 0; + + calculateshape( wif, args[1], args[2], args[3], args[4], 0, 0); + /********************************/ + /* Create the X window instance */ + /********************************/ + wif->topwidget = XtVaAppCreateShell + (tmpstring, tmpstring, + applicationShellWidgetClass, display, + XtNgeometry, wif->gstring, + XtNargc, save_argc, + XtNargv, save_argv, + XtNborderWidth, 0, + NULL); + + wif->formwidget = XtCreateManagedWidget + ("scrollBox", scrollBoxWidgetClass, wif->topwidget, + NULL, 0); + + wif->framewidget = XtVaCreateManagedWidget + ("frame", boxWidgetClass, wif->formwidget, + XtNheight, wif->outerregion.height, + XtNwidth, wif->outerregion.width, + XtNborderWidth, blackborder, + XtNbackground, BlackPixelOfScreen( wif->screen ), + XtNvSpace, 0, + XtNdefaultDistance, 0, + XtNhorizDistance, 0, + XtNvertDistance, 0, + NULL); + boxClassRec.core_class.compress_motion = False; + + wif->windowwidget = XtVaCreateManagedWidget + ("window", boxWidgetClass, wif->framewidget, + XtNheight, wif->innerregion.height, + XtNwidth, wif->innerregion.width, + XtNx, wif->innerregion.x, + XtNy, wif->innerregion.y, + XtNborderColor, WhitePixelOfScreen(wif->screen), + XtNborderWidth, whiteborder, + XtNvSpace, 0, + XtNdefaultDistance, 0, + XtNhorizDistance, 0, + XtNvertDistance, 0, + XtNbottom, XtChainBottom, + XtNleft, XtChainLeft, + NULL); + + gcv.function = GXcopy; + gcv.foreground = dspif->black; + gcv.background = dspif->white; + wif->ReplaceGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXxor; + gcv.foreground = (dspif->black) ^ (dspif->white); + gcv.background = 0; + wif->InvertGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXor; + gcv.foreground = dspif->black & (~ dspif->white); + gcv.background = 0; + wif->PaintGC1 = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXandInverted; + gcv.foreground = dspif->white & (~dspif->black); + gcv.background = 0; + wif->PaintGC2 = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXor; + gcv.foreground = dspif->white & (~dspif->black); + gcv.background = 0; + wif->EraseGC1 = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXandInverted; + gcv.foreground = dspif->black & (~dspif->white); + gcv.background = 0; + wif->EraseGC2 = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXandInverted; + gcv.foreground = dspif->black & (~dspif->white); + gcv.background = 0; + wif->gc = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + /* Push this wif onto the list of created wifs. */ + wif->next = dspif->CreatedWifs; + dspif->CreatedWifs = wif; + + wif->backing = XCreatePixmap(display, dspif->root, + args[3] & 0xFFFF, args[4] & 0xFFFF, 1); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); + MBMToDrawable(bitmap, dspif, wif, 0, 0, + wif->innerregion.x, wif->innerregion.y, + wif->innerregion.width, wif->innerregion.height, + REPLACE); + + free( tmpstring ); + return(ATOM_T); +} + + + + +/**************************************************************/ +/* showtitle */ +/* Update the title frame of the window. It is assumed that */ +/* the titlehight is the same as the abs(linefeed) height for */ +/* the displaydata of the screen. */ +/**************************************************************/ + +showtitle(win) + LispPTR win; +{ + BITMAP *bitmap; + DISPLAYDATA *dd; + WindowInterface wif; + DspInterface dspif; + char *tmpstring; + int xpos, dsty, i, width, stringlen, titleheight; + + wif = WIfFromMw(win); + dspif = DspIfFromMw(win); + + dd = TitleDDFromMw(win); + tmpstring = gettitlestring( win ); + titleheight = gettitleheight( win ); + if(tmpstring == NULL) return(ATOM_T); + stringlen = strlen(tmpstring); + + bitmap = (BITMAP *)Cptr(dd->ddpilotbbt); + MakeScratchImageFromBM(dspif, bitmap); + + /* Clear the window of prewious gunk. */ + XClearWindow(dspif->handle, wif->blackframe); + + /* Start text flush to the border */ + xpos = LispIntToCInt(((MedleyWindow)Cptr(win))->WBORDER); + dsty = titleheight - bitmap->bmheight + 2; /* The +2 is ad hoc */ + + /* Set the name property in the server */ + XtVaSetValues(wif->topwidget, XtNtitle, tmpstring, NULL); + + /* Add character set switching code... */ + + if((bitmap->bmbitperpixel == 1) || + (bitmap->bmbitperpixel == DefaultDepthOfScreen(wif->screen))) + for (i = 0; i < stringlen; i++) { + width = GETWORD((DLword*)Cptr(dd->ddwidthscache + tmpstring[i])); + XPutImage(dspif->handle, + wif->blackframe, + dspif->TitleGC, + &dspif->image, + GETWORD(Cptr(dd->ddoffsetscache + tmpstring[i])), /* src x */ + 0, /* src y */ + xpos, /* dst x */ + dsty, /* ??? dst y */ + width, + bitmap->bmheight /* height */ + ); + xpos += width; + } + else { + /* Take the long way out. Make an image of the cached bitmap and */ + /* convert it to the depth of the screen. Then dump it to the server */ + int x, y; + + dspif->image.width = bitmap->bmwidth; + dspif->image.height = bitmap->bmheight; + dspif->image.bytes_per_line = + ((bitmap->bmwidth+(BITSPER_DLWORD-1)) /BITSPER_DLWORD) * (BITSPER_DLWORD/8); + dspif->image.depth = DefaultDepthOfScreen(wif->screen); + dspif->image.data = (char *)malloc(dspif->image.bytes_per_line + * dspif->image.width + * dspif->image.depth); + + dspif->tmpimage.width = bitmap->bmwidth; + dspif->tmpimage.height = bitmap->bmheight; + dspif->tmpimage.depth = bitmap->bmbitperpixel & 0xFFFF; + dspif->tmpimage.data = (char *)Cptr((LispPTR)bitmap->bmbase); + dspif->tmpimage.bytes_per_line = + ((bitmap->bmwidth+(BITSPER_DLWORD-1)) /BITSPER_DLWORD) * (BITSPER_DLWORD/8); + for(x = 0; x < bitmap->bmwidth; x++) + for(y = 0; y < bitmap->bmheight; y++) + XPutPixel(&dspif->image, x, y, XGetPixel(&dspif->tmpimage, x, y)); + for (i = 0; i < stringlen; i++) { + width = GETWORD((DLword*)Cptr(dd->ddwidthscache + tmpstring[i])); + XPutImage(dspif->handle, + wif->blackframe, + dspif->TitleGC, + &dspif->image, + GETWORD(Cptr(dd->ddoffsetscache + tmpstring[i])), /* src x */ + 0, /* src y */ + xpos, /* dst x */ + dsty, /* ??? dst y */ + width, + bitmap->bmheight /* height */ + ); + xpos += width; + } + free(dspif->image.data); + } + free(tmpstring); + return(ATOM_T); +} + + + + +/************************************************************************/ +/* MNXopenW */ +/* Open a window and get the inner region of the window from the SAVE */ +/* slot on the MedWindow */ +/* NOTE! we don't get whiteframe, blackframe or the title. See MNXcloseW. */ +/************************************************************************/ +MNXopenW( args ) + LispArgs args; +{ + Display *display; + WindowInterface wif; + DspInterface dspif; + char *tmpstring; + BITMAP *bitmap; + XGCValues gcv; + Window window, root, parent, *children; + int nch; + + wif = WIfFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = dspif->handle; + + XtAddEventHandler(wif->framewidget, + ButtonPressMask | ButtonReleaseMask, + False, HandleButton, wif); + XtAddEventHandler(wif->framewidget, + PointerMotionMask, + False, HandleMotion, wif); + XtAddEventHandler(wif->framewidget, + KeyPressMask | KeyReleaseMask, + False, HandleKey, wif); + XtAddEventHandler(wif->framewidget, + EnterWindowMask | LeaveWindowMask, + False, HandleCrossing, wif); + XtAddEventHandler(wif->framewidget, + FocusChangeMask, + False, HandleFocus, wif); + XtAddEventHandler(wif->framewidget, + ExposureMask, + False, HandleTitle, wif); + XtAddEventHandler(wif->windowwidget, + ExposureMask, + False, HandleExpose, wif); + XtAddEventHandler(wif->topwidget, + StructureNotifyMask, + False, HandleStructure, wif); + + XtRealizeWidget(wif->topwidget); +#ifdef NEVER + if (wif->shape_pend) /* We reshaped while closed; do it for real here */ + { + refreshwindow( args[0] ); + XtVaSetValues(wif->formwidget, XtNextentX, 0, XtNextentY, 0, + XtNextentWidth, wif->windowreg.width, + XtNextentHeight, wif->windowreg.height, + NULL); + XtMoveWidget(wif->topwidget, wif->topregion.x, wif->topregion.y); + wif->move_pend = wif->shape_pend = 0; + } + else if (wif->move_pend) /* We moved while closed; do the move here. */ + { + wif->move_pend = 0; + XtMoveWidget( wif->topwidget + , wif->topregion.x + , wif->topregion.y + , 0); + } +#endif + wif->blackframe = XtWindow(wif->framewidget); + wif->handle = window = XtWindow(wif->windowwidget); + + /* wif->parent = XtWindow(wif->topwidget); */ + XQueryTree(display, XtWindow(wif->topwidget), &root, &parent, &children, &nch); + wif->parent = parent; + XFree(children); + + refreshwindow( args[0] ); + settileorigin( args[0], 0, wif->innerregion.height ); + settexture(args[0]); + showtitle( args[0] ); + XtSetSensitive(wif->framewidget, True); + XtSetSensitive(wif->windowwidget, True); + + if (!wif->backing) + { + wif->backing = XCreatePixmap(display, window, wif->outerregion.width, + wif->outerregion.height, 1); + } + + + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); + MBMToDrawable(bitmap, dspif, wif, 0, 0, + /* wif->innerregion.x, wif->innerregion.y, */ 0, 0, + wif->innerregion.width, wif->innerregion.height, + REPLACE); + + XRaiseWindow(display, XtWindow(wif->topwidget)); + + XFlush(display); + wif->open = 1; /* mark the window open. */ + return(ATOM_T); +} + + + + +MNXresetW( args ) + LispArgs args; +{ + Display *display; + WindowInterface wif; + DISPLAYDATA *dd; + + display = XDisplayFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) return(NIL); /* if the window is closed, do nothing */ + if(XtIsRealized(wif->topwidget)) + { +#ifdef NEVER + showtitle( args[0] ); + settexture(args[0]); + XClearWindow(display, XtWindow(wif->windowwidget)); +#else + bltshade_internal(display, 0, dd->ddtexture, 0, 0, wif->innerregion.width, + wif->innerregion.height, wif, wif->dspif); +#endif /* NEVER */ + } + XFlush(display); + return(ATOM_T); +} + + + +MNXSetOffsets(args) + LispArgs args; /* args[0] = window XOFFSET/YOFFSET changed in */ + /* args[1] = new XOFFSET */ + /* args[2] = new YOFFSET */ + { + Display *display; + WindowInterface wif; + + wif = WIfFromMw(args[0]); + wif->xoffset = LispIntToCInt(args[1]); + wif->yoffset = LispIntToCInt(args[2]); + + } + + +/*********************/ +/* Imageop Methods. */ +/*********************/ + + + +MNXdrawpoint( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = x */ + /* args[2] = y */ + /* args[3] = brush */ +{ + Display *display; + Window window; + DspInterface dspif; + WindowInterface wif; + int width, x, y; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + dd = ImDataFromMw( args[0] ); + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + if( args[3] == NIL ) + width = 0; + else + width = LispIntToCInt(args[3]); + + x = translate_x(wif, LispIntToCInt(args[1])); + y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])); + + /** Handle the four operation cases **/ + if( dd->ddoperation == INVERT_atom ) + { + XDrawPoint(display, window, wif->InvertGC, x, y); + XDrawPoint(display, wif->backing, dspif->PixIGC, x, y); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawPoint(display, window, wif->EraseGC1, x, y); + XDrawPoint(display, window, wif->EraseGC2, x, y); + XDrawPoint(display, wif->backing, dspif->PixEGC, x, y); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawPoint(display, window, wif->PaintGC1, x, y); + XDrawPoint(display, window, wif->PaintGC2, x, y); + XDrawPoint(display, wif->backing, dspif->PixPGC, x, y); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawPoint(display, window, wif->ReplaceGC, x, y); + XDrawPoint(display, wif->backing, dspif->PixRGC, x, y); + } + + XFlush(display); + return(NIL); +} + + + +/**************************************************************/ +/* MNXdrawline */ +/* color not yet implemented */ +/* Medleys Drawline can't handle dashing. */ +/* Thick lines in Medley are handled as parallellograms */ +/* instead of rectangles. */ +/* Remember that this method has an OPERATION arument in Lisp */ +/* so we have to fix that there. */ +/**************************************************************/ +MNXdrawline( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = x1 */ + /* args[2] = y1 */ + /* args[3] = x2 */ + /* args[4] = y2 */ + /* args[5] = width */ + /* Args[6] = dashing */ +{ + WindowInterface wif; + Display *display; + Window window; + DspInterface dspif; + int y1, y2, x1, x2; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + dd = ImDataFromMw( args[0] ); + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + /* Transform the Y coordinates */ + y1 = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])); + y2 = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[4])); + x1 = translate_x(wif, LispIntToCInt(args[1])); + x2 = translate_x(wif, LispIntToCInt(args[3])); + + setlineattributes(display, dspif, wif, dd, args[5], args[6]); + + if( dd->ddoperation == INVERT_atom ) + { + XDrawLine( display,window, wif->InvertGC, x1, y1, x2, y2); + XDrawLine( display, wif->backing, dspif->PixIGC, x1, y1, x2, y2); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawLine( display,window, wif->EraseGC1, x1, y1, x2, y2); + XDrawLine( display,window, wif->EraseGC2, x1, y1, x2, y2); + XDrawLine( display, wif->backing, dspif->PixEGC, x1, y1, x2, y2); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawLine( display,window, wif->PaintGC1, x1, y1, x2, y2); + XDrawLine( display,window, wif->PaintGC2, x1, y1, x2, y2); + XDrawLine( display, wif->backing, dspif->PixPGC, x1, y1, x2, y2); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawLine( display,window, wif->ReplaceGC, x1, y1, x2, y2); + XDrawLine( display, wif->backing, dspif->PixRGC, x1, y1, x2, y2); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + + + +/**************************************************************/ +/* MNXdrawcircle */ +/* Note: 23040 is 360 * 64 sixtyfourth degrees */ +/* It is assumed that the BRUSH argument is a fixp that */ +/* represents a ROUND brush. */ +/**************************************************************/ +MNXdrawcircle( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = radius */ + /* args[4] = brush */ + /* args[5] = dashing */ +{ + int radius, d, x, y; + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + radius = LispIntToCInt(args[3]); + d = radius << 1; + y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - radius; + x = translate_x(wif, LispIntToCInt(args[1])) - radius; + + setlineattributes(display, dspif, wif, dd, args[4], args[5]); + + if( dd->ddoperation == INVERT_atom ) + { + XDrawArc( display, window, wif->InvertGC, x, y, d, d, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixIGC, x, y, d, d, 0, 23040); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawArc( display, window, wif->EraseGC1, x, y, d, d, 0, 23040); + XDrawArc( display, window, wif->EraseGC2, x, y, d, d, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixEGC, x, y, d, d, 0, 23040); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawArc( display, window, wif->PaintGC1, x, y, d, d, 0, 23040); + XDrawArc( display, window, wif->PaintGC2, x, y, d, d, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixPGC, x, y, d, d, 0, 23040); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawArc( display, window, wif->ReplaceGC, x, y, d, d, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixRGC, x, y, d, d, 0, 23040); + } + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + + + +/**************************************************************/ +/* MNXdrawarc */ +/* It is assumed that the BRUSH argument is a fixp that */ +/* represents a ROUND brush. */ +/**************************************************************/ +MNXdrawarc( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = radius */ + /* args[4] = startangle in 64'ths degrees */ + /* args[5] = ndegrees in 64'ths degrees */ + /* args[6] = brush */ + /* args[7] = dashing */ + /* Brush and dashing args are ignored for the moment. */ +{ + int radius, d, x, y, start, ndeg; + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + radius = LispIntToCInt(args[3]); + d = radius << 1; + x = translate_x(wif, LispIntToCInt(args[1])) - radius; + y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - radius; + start = LispIntToCInt(args[4]); + ndeg = LispIntToCInt(args[5]); + + setlineattributes(display, dspif, wif,dd, args[6], args[7]); + + if( dd->ddoperation == INVERT_atom ) + { + XDrawArc( display, window, wif->InvertGC, x, y, d, d, start, ndeg); + XDrawArc( display, wif->backing, dspif->PixIGC, x, y, d, d, start, ndeg); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawArc( display, window, wif->EraseGC1, x, y, d, d, start, ndeg); + XDrawArc( display, window, wif->EraseGC2, x, y, d, d, start, ndeg); + XDrawArc( display, wif->backing, dspif->PixEGC, x, y, d, d, start, ndeg); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawArc( display, window, wif->PaintGC1, x, y, d, d, start, ndeg); + XDrawArc( display, window, wif->PaintGC2, x, y, d, d, start, ndeg); + XDrawArc( display, wif->backing, dspif->PixPGC, x, y, d, d, start, ndeg); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawArc( display, window, wif->ReplaceGC, x, y, d, d, start, ndeg); + XDrawArc( display, wif->backing, dspif->PixRGC, x, y, d, d, start, ndeg); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + +/**************************************************************/ +/* MNXdrawelipse */ +/* Note: 23040 is 360 * 64 sixtyfourth degrees */ +/* It is assumed that the BRUSH argument is a fixp that */ +/* represents a ROUND brush. */ +/**************************************************************/ +MNXdrawelipse( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = semiminorradius */ + /* args[4] = semimajorradius */ + /* args[5] = orientation */ + /* args[6] = brush */ + /* args[7] = dashing */ + +{ + int radius, d1, d2, x, y; + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + x = translate_x(wif, LispIntToCInt(args[1])) - radius; + y = wif->innerregion.height - translate_x(wif, LispIntToCInt(args[2])) - radius; + d1 = LispIntToCInt(args[3]); + d2 = LispIntToCInt(args[4]); + + setlineattributes(display, dspif, wif, dd, args[6], args[7]); + + if( dd->ddoperation == INVERT_atom ) + { + XDrawArc( display, window, wif->InvertGC, x, y, d1, d2, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixIGC, x, y, d1, d2, 0, 23040); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawArc( display, window, wif->EraseGC1, x, y, d1, d2, 0, 23040); + XDrawArc( display, window, wif->EraseGC2, x, y, d1, d2, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixEGC, x, y, d1, d2, 0, 23040); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawArc( display, window, wif->PaintGC1, x, y, d1, d2, 0, 23040); + XDrawArc( display, window, wif->PaintGC2, x, y, d1, d2, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixPGC, x, y, d1, d2, 0, 23040); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawArc( display, window, wif->ReplaceGC, x, y, d1, d2, 0, 23040); + XDrawArc( display, wif->backing, dspif->PixRGC, x, y, d1, d2, 0, 23040); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + +/**************************************************************/ +/* MNXfillcircle */ +/* Note: 23040 is 360 * 64 sixtyfourth degrees */ +/**************************************************************/ +MNXfillcircle( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = radius */ + /* Brush and dashing args are ignored for the moment. */ +{ + int radius, d, x, y; + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + radius = LispIntToCInt(args[3]); + d = radius << 1; + x = translate_x(wif, LispIntToCInt(args[1])) - radius; + y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - radius; + + if( dd->ddoperation == INVERT_atom ) + { + XFillArc( display, window, wif->InvertGC, x, y, d, d, 0, 23040); + XFillArc( display, wif->backing, dspif->PixIGC, x, y, d, d, 0, 23040); + } + else if( dd->ddoperation == ERASE_atom ) + { + XFillArc( display, window, wif->EraseGC1, x, y, d, d, 0, 23040); + XFillArc( display, window, wif->EraseGC2, x, y, d, d, 0, 23040); + XFillArc( display, wif->backing, dspif->PixEGC, x, y, d, d, 0, 23040); + } + else if( dd->ddoperation == PAINT_atom ) + { + XFillArc( display, window, wif->PaintGC1, x, y, d, d, 0, 23040); + XFillArc( display, window, wif->PaintGC2, x, y, d, d, 0, 23040); + XFillArc( display, wif->backing, dspif->PixPGC, x, y, d, d, 0, 23040); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XFillArc( display, window, wif->ReplaceGC, x, y, d, d, 0, 23040); + XFillArc( display, wif->backing, dspif->PixRGC, x, y, d, d, 0, 23040); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + +/**************************************************************/ +/* MNXwritepixel */ +/**************************************************************/ +MNXwritepixel( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = x */ + /* args[2] = y */ +{ + int x, y; + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + x = translate_x(wif, LispIntToCInt(args[1])); + y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])); + + if( dd->ddoperation == INVERT_atom ) + { + XDrawPoint( display, window, wif->InvertGC, x, y); + XDrawPoint( display, wif->backing, dspif->PixIGC, x, y); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawPoint( display, window, wif->EraseGC1, x, y); + XDrawPoint( display, window, wif->EraseGC2, x, y); + XDrawPoint( display, wif->backing, dspif->PixEGC, x, y); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawPoint( display, window, wif->PaintGC1, x, y); + XDrawPoint( display, window, wif->PaintGC2, x, y); + XDrawPoint( display, wif->backing, dspif->PixPGC, x, y); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawPoint( display, window, wif->ReplaceGC, x, y); + XDrawPoint( display, wif->backing, dspif->PixRGC, x, y); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + +/**************************************************************/ +/* MNXdrawpolygon */ +/* Lisp sends down a pointer to a vector of points. The vector*/ +/* is organized as [x1,y1,x2,y2,...] MNXdrawpolygon smashes this*/ +/* vector with the integer values converted to C integers. */ +/**************************************************************/ +MNXdrawpolygon( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to Pointvector */ + /* args[2] = Closedp */ +{ + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + int i; + Arrayp *pv; + short *xpt, y; + long *Mpt; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + pv = (Arrayp *)Cptr(args[1]); + Mpt = (long *)Cptr(pv->base); + xpt = (short *)Cptr(pv->base); + + /* XPoint is defined as shorts, base is defined as longs. */ + /* Pack the vector. */ + for (i = 0; i < pv->length; i++) xpt[i] = (short)Mpt[i]; + + /* Transmogrify the y coordinates */ + y = (short)wif->innerregion.height; + for (i = 1; i < pv->length; i += 2) + { + xpt[i] = y - translate_y(wif, xpt[i]); + xpt[i-1] = translate_x(wif, xpt[i-1]); + } + /* If CLOSED then set last point are eq to the first. */ + if (args[2] != NIL) { + xpt[pv->length++] = xpt[0]; + xpt[pv->length++] = xpt[1]; + } + + if( dd->ddoperation == INVERT_atom ) + { + XDrawLines( display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawLines( display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawLines( display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawLines( display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + +MNXfillpolygon( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to Pointvector */ + /* args[2] = Closedp */ +{ + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + int i; + Arrayp *pv; + short *xpt, y; + long *Mpt; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + pv = (Arrayp *)Cptr(args[1]); + Mpt = (long *)Cptr(pv->base); + xpt = (short *)Cptr(pv->base); + + /* XPoint is defined as shorts, base is defined as longs. */ + /* Pack the vector. */ + for (i = 0; i < pv->length; i++) xpt[i] = (short)Mpt[i]; + + /* Transmogrify the y coordinates */ + y = (short)wif->innerregion.height; + for (i = 1; i < pv->length; i += 2) + { + xpt[i] = y - translate_y(wif, xpt[i]); + xpt[i-1] = translate_x(wif, xpt[i-1]); + } + + /* If CLOSED then set last point are eq to the first. */ + if (args[2] != NIL) { + xpt[pv->length++] = xpt[0]; + xpt[pv->length++] = xpt[1]; + } + + if( dd->ddoperation == INVERT_atom ) + { + XFillPolygon( display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon( display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == ERASE_atom ) + { + XFillPolygon( display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon( display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon( display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == PAINT_atom ) + { + XFillPolygon( display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon( display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon( display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XFillPolygon( display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon( display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + +/**************************************************************/ +/* MNXdrawcurve */ +/* NOTE: Not yet implemented. Works like MNXdrawpolygon!!!!! */ +/* Lisp sends down a pointer to a vector of points. The vector*/ +/* is organized as [x1,y1,x2,y2,...] MNXdrawpolygon smashes this*/ +/* vector with the integer values converted to C integers. */ +/**************************************************************/ +MNXdrawcurve( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to Pointvector */ + /* args[2] = Closedp */ +{ + WindowInterface wif; + Window window; + Display *display; + DspInterface dspif; + int i; + Arrayp *pv; + short *xpt, y; + long *Mpt; + DISPLAYDATA *dd; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + pv = (Arrayp *)Cptr(args[1]); + Mpt = (long *)Cptr(pv->base); + xpt = (short *)Cptr(pv->base); + + /* XPoint is defined as shorts, base is defined as longs. */ + /* Pack the vector. */ + for (i = 0; i < pv->length; i++) xpt[i] = (short)Mpt[i]; + + /* Transmogrify the y coordinates */ + y = (short)wif->innerregion.height; + for (i = 1; i < pv->length; i += 2) + { + xpt[i] = y - translate_y(wif, xpt[i]); + xpt[i-1] = translate_x(wif, xpt[i-1]); + } + + /* If CLOSED then set last point are eq to the first. */ + if (args[2] != NIL) { + xpt[pv->length++] = xpt[0]; + xpt[pv->length++] = xpt[1]; + } + + if( dd->ddoperation == INVERT_atom ) + { + XDrawLines( display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == ERASE_atom ) + { + XDrawLines( display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == PAINT_atom ) + { + XDrawLines( display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XDrawLines( display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines( display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); + } + + XFlush(display); + return(NIL); /* Report that all is ok. */ +} + + +/************************************************************/ +/* MNXclippingregion */ +/************************************************************/ +MNXclippingregion( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = width */ + /* args[4] = height */ + +{ + WindowInterface wif; + Window window; + DspInterface dspif; + Display *display; + XRectangle rect; + DISPLAYDATA *dd; + + /* This is a noop. We read the region straight from the displaydata slots. */ + + return(ATOM_T); +} + +/**************************************************************/ +/* MNXoperation */ +/* Sets the GC for the window according to the following: */ +/* 0=replace, 1=paint, 2=invert, 3=erase */ +/* Remember that some functions have operation as argument and*/ +/* Thus have to call this function explicitly twice. Once to */ +/* set the new state and once to put the old state back. */ +/**************************************************************/ +MNXoperation( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = Smallp for function. */ +{ + WindowInterface wif; + Window window; + DspInterface dspif; + Display *display; + DISPLAYDATA *dd; + + wif = WIfFromMw(args[0]); + window = XWindowFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = XDisplayFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + /* This is a noop. We manipulate the GC from the displaydata slots. */ + + if (dd->ddoperation == REPLACE_atom) wif->op = 0; + else if (dd->ddoperation == PAINT_atom) wif->op = 1; + else if (dd->ddoperation == INVERT_atom) wif->op = 2; + else if (dd->ddoperation == ERASE_atom) wif->op = 3; + + return(NIL); +} + +/**************************************************************/ +/* MNXdspcolor */ +/* */ +/* */ +/* */ +/* */ +/**************************************************************/ +MNXdspcolor( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to FIXP or BITMAPP */ +{ + WindowInterface wif; + DspInterface dspif; + Display *display; + DISPLAYDATA *dd; + int fgcol; + char id[64]; + + wif = WIfFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = XDisplayFromMw(args[0]); + dd = ImDataFromMw( args[0] ); + + if(wif->fgpixmap){ + /* If we have an fgpixmap, junk it */ + XFreePixmap(display, wif->fgpixmap); + wif->fgpixmap = 0; + } + + if(TYPE_SMALLP == GetTypeNumber(args[1])) + if(LispIntToCInt(MScrFromMw(args[0])->SCDEPTH) == 1) { + /* A fixp on a BW screen: make a texture of this */ + dspif->image.data = id; + MakeScratchImageFromInt(dspif, LispIntToCInt(args[1])); + } + else { /* A fixp on a color screen: color the foreground */ + fgcol = ~LispIntToCInt(args[1]); + XSetForeground(display, wif->InvertGC, fgcol); + XSetForeground(display, wif->EraseGC1, fgcol); + XSetForeground(display, wif->EraseGC2, fgcol); + XSetForeground(display, wif->PaintGC1, fgcol); + XSetForeground(display, wif->PaintGC2, fgcol); + XSetForeground(display, wif->ReplaceGC, fgcol); + return(NIL); + } + else { + BITMAP *bitmap; + + bitmap = (BITMAP *)Cptr(args[1]); + MakeScratchImageFromBM(dspif, bitmap); + } + + if(dspif->image.depth == 1) { + wif->fgpixmap = XCreatePixmapFromBitmapData(dspif->handle, + XtWindow(wif->windowwidget), + dspif->image.data, + dspif->image.width, + dspif->image.height, + 0, + 1, + dspif->image.depth); + XSetStipple(display, wif->InvertGC, wif->fgpixmap); + XSetStipple(display, wif->EraseGC1, wif->fgpixmap); + XSetStipple(display, wif->EraseGC2, wif->fgpixmap); + XSetStipple(display, wif->PaintGC1, wif->fgpixmap); + XSetStipple(display, wif->PaintGC2, wif->fgpixmap); + XSetStipple(display, wif->ReplaceGC, wif->fgpixmap); + } + else { + wif->fgpixmap = XCreatePixmapFromBitmapData(dspif->handle, + XtWindow(wif->windowwidget), + dspif->image.data, + dspif->image.width, + dspif->image.height, + BlackPixelOfScreen(wif->screen), + WhitePixelOfScreen(wif->screen), + dspif->image.depth); + XSetTile(display, wif->InvertGC, wif->fgpixmap); + XSetTile(display, wif->EraseGC1, wif->fgpixmap); + XSetTile(display, wif->EraseGC2, wif->fgpixmap); + XSetTile(display, wif->PaintGC1, wif->fgpixmap); + XSetTile(display, wif->PaintGC2, wif->fgpixmap); + XSetTile(display, wif->ReplaceGC, wif->fgpixmap); + } + return(NIL); /* Report that all is ok. */ +} + +/**************************************************************/ +/* MNXdspbackcolor */ +/* */ +/* */ +/* */ +/* */ +/**************************************************************/ +MNXdspbackcolor ( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = background type 0=fixp for color 1=bitmap for stiple. */ + /* args[2] = background, fixp or bitmap */ +{ + settexture( args[0] ); +} + + + + +/************************************************************/ +/* MNXBitblt - can only copy from bitmap to window. we need */ +/* to make it do WINDOW -> BITMAP and WINDOW -> WINDOW */ +/************************************************************/ +MNXBitBltBW( ) +{ + error("Call to MNXBitBltBW. This function is not in use anymore."); +} + + + +MNXbltshadeBW( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to TEXTURE */ + /* args[2] = dst_x */ + /* args[3] = dst_y */ + /* args[4] = width */ + /* args[5] = height */ + /* args[6] = operation */ + /* args[7] = background, fixp or bitmap */ +{ + WindowInterface wif; + DspInterface dspif; + Display *display; + Screen *screen; + int width, height, depth, regheight, dstx, dsty; + char tmpstring[128], *data; + int op = args[6] & 0xFFFF; + + wif = WIfFromMw(args[0]); + dspif = DspIfFromMw(args[0]); + display = XDisplayFromMw(args[0]); + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + regheight = LispIntToCInt(args[5]); + width = LispIntToCInt(args[4]); + + dstx = translate_x(wif, LispIntToCInt(args[2])); + dsty = wif->innerregion.height + - translate_y(wif, LispIntToCInt(args[3])) - regheight; + + bltshade_internal(display, op, args[1], dstx, dsty, width, regheight, wif, dspif); + +} + + + +bltshade_internal(display, op, texture, dstx, dsty, width, regheight, wif, dspif) + Display *display; + LispPTR texture; + int op, dstx, dsty, width, regheight; + WindowInterface wif; + DspInterface dspif; +{ + Pixmap bgpixmap; + char id[64]; + + if(TYPE_SMALLP == GetTypeNumber(texture)) + { +#ifdef NEVER + if(dspif->depth == 1) + { +#endif /* NEVER */ + dspif->image.data = id; + MakeScratchImageFromInt(dspif, texture & 0xFFFF); +#ifdef NEVER + } + else + { /* Medley sez' color the foreground */ + XSetForeground(display, wif->gc, ~LispIntToCInt(texture)); + XFillRectangle(display, XtWindow(wif->windowwidget), wif->gc, + dstx, + dsty, + width, + regheight); + XFlush(display); + return(ATOM_T); + } +#endif /* NEVER */ + } + else { /* Its a bitmap. Medley sez' make a texture of this */ + BITMAP *bitmap; + + bitmap = (BITMAP *)Cptr(texture); + MakeScratchImageFromBM(dspif, bitmap); + } +#ifdef NEVER + if(dspif->image.depth == 1) + { +#endif /* NEVER */ + bgpixmap = XCreatePixmapFromBitmapData(dspif->handle, + XtWindow(wif->windowwidget), + dspif->image.data, + dspif->image.width, + dspif->image.height, + 0, + 1, + dspif->image.depth); + XSetStipple(display, wif->gc, bgpixmap); +#ifdef NEVER + } + else + { + bgpixmap = XCreatePixmapFromBitmapData(dspif->handle, + XtWindow(wif->windowwidget), + dspif->image.data, + dspif->image.width, + dspif->image.height, + BlackPixelOfScreen(wif->screen), + WhitePixelOfScreen(wif->screen), + dspif->image.depth); + XSetTile(display, wif->gc, bgpixmap); + } +#endif /* NEVER */ + + + + XSetFunction(display, wif->gc, bltshade_function[op % 4]); + switch(op) + { + case 0: + /* XSetFillStyle(display, wif->gc, FillOpaqueStippled); */ + XSetFillStyle(display, dspif->PixRGC, FillOpaqueStippled); + XSetStipple(display, dspif->PixRGC, bgpixmap); + XSetTSOrigin(display, dspif->PixRGC, dstx, dsty); + XFillRectangle(display, wif->backing, dspif->PixRGC, + dstx, dsty, width, regheight); + break; + case 1: + XSetFillStyle(display, wif->gc, FillStippled); + XSetFillStyle(display, dspif->PixRGC, FillStippled); + XSetStipple(display, dspif->PixRGC, bgpixmap); + XSetTSOrigin(display, dspif->PixRGC, dstx, dsty); + XFillRectangle(display, wif->backing, dspif->PixRGC, + dstx, dsty, width, regheight); + break; + case 2: + XSetForeground(display, wif->gc, dspif->white ^ dspif->black); + XSetFillStyle(display, wif->gc, FillStippled); + XSetFillStyle(display, dspif->PixIGC, FillStippled); + XSetStipple(display, dspif->PixIGC, bgpixmap); + XSetTSOrigin(display, dspif->PixIGC, dstx, dsty); + XFillRectangle(display, wif->backing, dspif->PixIGC, + dstx, dsty, width, regheight); + break; + case 3: + XSetForeground(display, wif->gc, dspif->white); + XSetFillStyle(display, wif->gc, FillStippled); + XSetFillStyle(display, dspif->PixEGC, FillStippled); + XSetStipple(display, dspif->PixEGC, bgpixmap); + XSetTSOrigin(display, dspif->PixEGC, dstx, dsty); + XFillRectangle(display, wif->backing, dspif->PixEGC, + dstx, dsty, width, regheight); + break; + } + +/* XSetTSOrigin(display, wif->gc, dstx, dsty); + XFillRectangle(display, XtWindow(wif->windowwidget), wif->gc, + dstx, dsty, width, regheight); */ + + XCopyPlane(display, wif->backing, XtWindow(wif->windowwidget), wif->ReplaceGC, + dstx, dsty, width, regheight, dstx, dsty, 1); + + XFreePixmap(display, bgpixmap); + switch(op) /* undo the changing of foreground color above */ + { + case 0: + case 1: XSetFillStyle(display, dspif->PixRGC, FillSolid); + break; + case 2: XSetForeground(display, wif->gc, dspif->black); + XSetFillStyle(display, dspif->PixIGC, FillSolid); + break; + case 3: XSetForeground(display, wif->gc, dspif->black); + XSetFillStyle(display, dspif->PixEGC, FillSolid); + break; + } + /* XSetFunction(display, wif->gc, gcfunction[wif->op % 4]); */ + XFlush(display); +} + + + + +XClearToEOL ( args ) + LispArgs args; /* args[0] = MedleyWindow */ +{ + Display *display; + Window window; + WindowInterface wif; + DISPLAYDATA *dd; + int dsty, dstx, height; + + dd = ImDataFromMw(args[0]); + display = XDisplayFromMw(args[0]); + window = XWindowFromMw(args[0]); + wif = WIfFromMw(args[0]); + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + height = abs(dd->ddlinefeed); + dstx = translate_x(wif, LispIntToCInt(args[1])); + dsty = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - height; + XClearArea( display, window, + dstx, + dsty, + 0, /* Out to the end */ + height, /* The height */ + False /* Don't generate exposure events */ + ); + XFlush(display); +} + + + +MNXNewPage ( args ) + LispArgs args; /* args[0] = MedleyWindow */ +{ + Display *display; + Window window; + + display = XDisplayFromMw(args[0]); + window = XWindowFromMw(args[0]); + /* ... */ + XFlush(display); +} + + + + +/************************************************************/ +/* MNXOutchar */ +/* NOTE this function returns NIL if we succeed and T if we */ +/* bump into the right margin. */ +/************************************************************/ +MNXOutchar ( args ) + LispArgs args; /* args[0] = MedleyWindow */ + /* args[1] = Charcode */ + /* args[2] = Stream */ + /* args[3] = DD */ + /* DSPXOFFSET and DSPYOFFSET are ignored here. */ +{ + /* Doesn't switch charsets. */ + Display *display; + Window window; + char tmpstring[2]; + DspInterface dspif; + WindowInterface wif; + Stream *s; + DISPLAYDATA *dd; + BITMAP *bitmap; + int cx, cy, char8code, right, rmargin, lmargin, newpos; + int w, height, sx, sy; + + dspif = DspIfFromMw(args[0]); + wif = WIfFromMw(args[0]); + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + display = dspif->handle; + window = XtWindow(wif->windowwidget); + + if (!window) return(NIL); /* No window, pretend we succeeded. */ + + + s = ((Stream *)Cptr(args[2])); + dd = ((DISPLAYDATA *)Cptr(args[3])); + char8code = LispIntToCInt(args[1]) & 255; + + /* Get the current position */ + cx = translate_x(wif, LispIntToCInt(dd->ddxposition)); + rmargin = LispIntToCInt(dd->ddrightmargin); + lmargin = LispIntToCInt(dd->ddleftmargin); + w = GETWORD((DLword*)Cptr(dd->ddcharimagewidths + char8code)); + + right = cx + w; + + if((right> rmargin )&&(cx >lmargin)) /* a linebreak. Punt. */ + return(ATOM_T); + + newpos = cx + GETWORD((DLword*)Cptr(dd->ddwidthscache + char8code )); + dd->ddxposition = CIntToLispInt(newpos); + + /* Y transform. Ypos is the baseline, it is adjusted by ascent */ + cy = translate_y(wif, LispIntToCInt(dd->ddyposition)); + cy = wif->innerregion.height - cy + - dd->ddcharsetascent; + + /* This bitmap should be cached on the server! */ + /* Do this in the CHANGECHARSET code. */ + bitmap = (BITMAP *)Cptr(dd->ddpilotbbt); + MakeScratchImageFromBM(dspif, bitmap); + + sx = GETWORD(Cptr(dd->ddoffsetscache + char8code)); + sy = 0; + + if( dd->ddoperation == INVERT_atom ) + { + XPutImage( display, window, wif->InvertGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + XPutImage( display, wif->backing, dspif->PixIGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + } + else if( dd->ddoperation == ERASE_atom ) + { + XPutImage( display, window, wif->EraseGC1, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + XPutImage( display, window, wif->EraseGC2, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + XPutImage( display, wif->backing, dspif->PixEGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + } + else if( dd->ddoperation == PAINT_atom ) + { + XPutImage( display, window, wif->PaintGC1, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + XPutImage( display, window, wif->PaintGC2, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + XPutImage( display, wif->backing, dspif->PixPGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + } + else if( dd->ddoperation == REPLACE_atom ) + { + XPutImage( display, window, wif->ReplaceGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + XPutImage( display, wif->backing, dspif->PixRGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); + } + + /* Increment the CHARPOSITION of the stream with 1 */ + s->CHARPOSITION++; + XFlush(display); + return(NIL); +} + + + + +/************************************************************/ +/* The WINDOWPROP interface */ +/************************************************************/ +MNXgetwindowprop( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{ +} + +MNXputwindowprop( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = Lispint to despatch on. */ + /* args[n] = args for the method. */ +{ + int method; + Window window; + XWindowAttributes attr; + WindowInterface wif; + + method = LispIntToCInt( args[1] ); + wif = WIfFromMw(args[0]); + + /* Discard the dispatching lispint and */ + /* make the argvector be on the form */ + /* ... */ + args[1] = args[0]; + args++; + + switch( method ){ + case MNWTitle: + showtitle( args[0] ); + break; + case MNWScrollFn: + XtVaSetValues(WIfFromMw(args[0])->formwidget, + XtNbarOnOff, (args[1] != NIL), + XtNmedleyWindow, wif, + XtNhScroll, &SignalHScroll, + XtNhJmpScroll, &SignalHJmpScroll, + XtNvScroll, &SignalVScroll, + XtNvJmpScroll, &SignalVJmpScroll, + NULL); + if (XtWindow(wif->topwidget)) + { + XGetWindowAttributes(wif->dspif->handle, XtWindow(wif->topwidget), &attr); + wif->topregion.width = attr.width; + wif->topregion.height = attr.height; + } + break; + case MNWNoScrollbars: + XtVaSetValues(WIfFromMw(args[0])->formwidget, + XtNbarOnOff, (args[1] == NIL), + NULL); + if (XtWindow(wif->topwidget)) + { + XGetWindowAttributes(wif->dspif->handle, XtWindow(wif->topwidget), &attr); + wif->topregion.width = attr.width; + wif->topregion.height = attr.height; + } + break; + case MNWScrollExtent: + XtVaSetValues(WIfFromMw(args[0])->formwidget, + XtNextentX, LispIntToCInt( args[1] ), + XtNextentY, LispIntToCInt( args[2] ), + XtNextentWidth, LispIntToCInt( args[3] ), + XtNextentHeight, LispIntToCInt( args[4] ), + NULL); + break; + case MNWScrollExtentUse: + break; + case MNWBorder: + refreshwindow( args[0] ); + break; + default: + break; + } +} + + + + +/************************************************************/ +/* Mouse position and friends. Have to be vectored through */ +/* the screen. */ +/************************************************************/ + + + + +static Cursor grab_cursor = 0; /* Cursor in effect while pointer is grabbed */ + +/************************************************************************/ +/* */ +/* G r a b P o i n t e r */ +/* args[0] = screen to do it on */ +/* args[1] = cursor to use (?) */ +/* args[2] = cursor hotspot x */ +/* args[3] = cursor hotspot y */ +/* */ +/* */ +/************************************************************************/ + +MNXGrabPointer(args) + LispArgs args; + /* args[0] = medley screen */ + /* args[1] = cursor to use, or NIL */ + { + Display *display; + WindowInterface wif; + DspInterface dspif; + char *tmpstring; + BITMAP *bitmap; + XGCValues gcv; + MedleyScreen MScreen; + Pixmap bits; + Window promptw; + int res, i; + extern unsigned char reversedbits[]; + unsigned char *src; + unsigned char srcbits[32]; /* holds the reversed bits for cursor */ + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + display = dspif->handle; + wif = dspif -> promptw; /* handle on the prompt window */ + promptw = XtWindow(wif->framewidget); + + if (args[1]) + { + + src = (unsigned char *) Cptr(args[1]); + for (i=0; i<32; i++) srcbits[i] = reversedbits[src[i]]; + + bits = XCreatePixmapFromBitmapData(display, dspif->root, srcbits, + 16, 16, 1, 0, 1); + grab_cursor = XCreatePixmapCursor(display, bits, bits, &dspif->black, &dspif->white, + args[2]&0xFFFF, 16-(args[3]&0xFFFF)); + } + else + { + grab_cursor = None; + } + + res = XGrabPointer(display, promptw, False, PointerMotionMask|ButtonPressMask|ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, + None, grab_cursor, CurrentTime); + + + if (grab_cursor != None) { XFreePixmap(display, bits); } + if (res == GrabSuccess) return (ATOM_T); + else return(NIL); + + } + + + + +MNXUngrabPointer(args) + LispArgs args; + { + Display *display; + WindowInterface wif; + DspInterface dspif; + char *tmpstring; + BITMAP *bitmap; + XGCValues gcv; + MedleyScreen MScreen; + int res; + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + display = dspif->handle; + + /* wif = WIfFromMw(args[0]); */ + + res = XUngrabPointer(display, CurrentTime); + + if (grab_cursor != None) XFreeCursor(display, grab_cursor); + + grab_cursor = None; + + return (ATOM_T); + + } + + + + +static int box_drawn = 0; /* T if there's a box on already */ + +MNXDrawBox(args) + LispArgs args; /* args[0] = Medley SCREEN to draw box on */ + /* args[1] = Left of box */ + /* args[2] = bottom of box */ + /* args[3] = width of box */ + /* args[4] = height of box */ + /* args[5] = T to force turning box off iff it's on */ + { + + Display *display; + WindowInterface wif; + DspInterface dspif; + MedleyScreen MScreen; + int res, l, b, w, h; + GC gc; + Window root; + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + display = dspif->handle; + gc = dspif->BoxingGC; + root = dspif->root; + + l = LispIntToCInt(args[1]); + b = LispIntToCInt(args[2]); + w = LispIntToCInt(args[3]); + h = LispIntToCInt(args[4]); + + if (w < 0) /* Negative width, change X coord and make it positive */ + { + l += w; + w = -w; + } + + if (h < 0) /* Negative height, change Y coord and make it positive */ + { + b += h; + h = -h; + } + + b = HeightOfScreen(dspif->xscreen) - b - h; /* convert to X's Y-coord */ + + if (args[5]) + { + if (box_drawn) XDrawRectangle(display, root, gc, l, b, w, h); + box_drawn = 0; + } + else + { + XDrawRectangle(display, root, gc, l, b, w, h); + box_drawn = !box_drawn; + } + } + + + + + +MNXMovePointer( args ) + LispArgs args; /* args[0] = LispPTR to SCREEN */ + /* args[1] = new pointer X */ + /* args[2] = new pointer Y */ +{ + Display *display; + WindowInterface wif; + DspInterface dspif; + MedleyScreen MScreen; + int res, l, b, w, h; + GC gc; + Window root; + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + display = dspif->handle; + gc = dspif->BoxingGC; + root = dspif->root; + + XWarpPointer(display, None, root, 0, 0, 0, 0, + args[1] & 0xFFFF, + args[2] & 0xFFFF); + return(ATOM_T); +} + + + + +MNXmouseconfirm( args ) + LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{ + /* Use a DIALOG WIDGET here. */ +} + + + + +MNXgarb( args ) + LispArgs args; /* args[0] = LispPTR to MedleyScreen */ + /* args[1] = NIL for GC off, non-NIL for GC on */ +{ + DspInterface dspif; + + dspif = DspIfFromMscr(args[0]); + if(dspif->gcindicator) + if(XtIsRealized(dspif->gcindicator)) + if(args[1] == NIL) + XClearWindow(XtDisplay(dspif->gcindicator), XtWindow(dspif->gcindicator)); + else + XFillRectangle(XtDisplay(dspif->gcindicator), XtWindow(dspif->gcindicator), + DefaultGCOfScreen(XtScreen(dspif->gcindicator)), 0, 0, + 8, + 8); +} + + + + +MNXMakePromptWindow( args ) + LispArgs args; /* args[0] = Lisp window, the prompt window */ +{ + Widget form, menu; + DspInterface dspif; + WindowInterface wif; + + wif = WIfFromMw(args[0]); + dspif = wif->dspif; + + dspif->promptw = wif; /* Save prompt window, for grabbing pointer events */ + + dspif->legatewidget = XtVaAppCreateShell + ("Medley Status", "Medley Status", + applicationShellWidgetClass, XDisplayFromMw(args[0]), + XtNargc, save_argc, + XtNargv, save_argv, + XtNborderWidth, 0, + NULL); + + form = XtVaCreateManagedWidget("bar", boxWidgetClass, dspif->legatewidget, NULL); + + dspif->gcindicator = XtVaCreateManagedWidget + ("gcindicator", boxWidgetClass, form, + XtNwidth, 8, + XtNheight, 8, + NULL); + + menu = XtVaCreateManagedWidget("Background", commandWidgetClass, form, NULL); + + XtAddEventHandler(menu, + ButtonPressMask | ButtonReleaseMask, + False, + HandleBackgroundButton, + dspif->screen); + XtAddEventHandler(dspif->legatewidget, + PointerMotionMask, + False, HandleMotion, 0); + XtAddEventHandler(dspif->legatewidget, + EnterWindowMask | LeaveWindowMask, + False, HandleBackgroundCrossing, dspif); + XtAddEventHandler(dspif->legatewidget, + KeyPressMask | KeyReleaseMask, + False, HandleKey, dspif); + XtRealizeWidget(dspif->legatewidget); + XtSetSensitive(dspif->legatewidget, True); + XtSetSensitive(form, True); + return(ATOM_T); +} + + + + +/************************************************************/ +/* */ +/* M N X S e t C u r s o r */ +/* */ +/* Set the cursor for all windows on a given screen. */ +/* */ +/************************************************************/ + + +static Cursor MNX_cursor = NULL; /* Cursor in active use */ + +MNXSetCursor(args) + LispArgs args; /* args[0] = Medley screen */ + /* args[1] = bits for new cursor */ + /* args[2] = hot-spot x */ + /* args[3] = hot-spot y */ + { + Display *display; + WindowInterface wif; + DspInterface dspif; + char *tmpstring; + BITMAP *bitmap; + XGCValues gcv; + MedleyScreen MScreen; + Pixmap bits; + Cursor new_cursor; + Window win; + unsigned char srcbits[32]; /* hold the reversed-bits for cursor */ + extern unsigned char reversedbits[]; + unsigned char *src; + int i; + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = DspIfFromMscr(args[0]); + display = dspif->handle; + + src = (unsigned char *) Cptr(args[1]); + for (i=0; i<32; i++) srcbits[i] = reversedbits[src[i]]; + + bits = XCreatePixmapFromBitmapData(display, dspif->root, srcbits, + 16, 16, 1, 0, 1); + new_cursor = XCreatePixmapCursor(display, bits, bits, &dspif->black, + &dspif->white, args[2]&0xFFFF, args[3]&0xFFFF); + + for (wif = dspif->CreatedWifs; wif; wif = wif->next) + if (win=XtWindow(wif->windowwidget)) + XDefineCursor(display, win, new_cursor); + + XFreePixmap(display, bits); + + if (dspif->cursor) { XFreeCursor(display, dspif->cursor); } + dspif->cursor = new_cursor; + + + return(NIL); + } + + + + +/************************************************************/ +/* I n i t D s p */ +/* */ +/* The slots for identifier, object type and window system */ +/* has to be filled in. */ +/************************************************************/ +InitDsp( args ) + LispArgs args; /* arg[0] = LispPTR to MedleyScreen */ +{ + DspInterface dspif; + MedleyScreen SCREEN; + char *tmpstring, *defaulthost; + int strlen; + Display *display; + Screen *screen; + XGCValues gcv; + int black, white; /* Pixel values for this display */ + int mask, diff, inverted; /* For finding a plane where they differ */ + Pixmap tpx; /* temp pixmap of depth 1 for creating GCs */ + int Xfd; + + + SCREEN = (MedleyScreen)Cptr(args[0]); + dspif = (DspInterface)malloc(sizeof(DspInterfaceRec)); + SCREEN->NativeIf = dspif; + + if (!xtinitialized){ + XtToolkitInitialize(); + xtinitialized = True; + } + dspif->xtcontext = XtCreateApplicationContext(); + + /* if NATIVE_INFO has a string use it for the hostname */ + /* else use the environment var DISPLAY or "unix:0.0" */ + if(LispStringP (SCREEN->NATIVE_INFO)) + { + strlen = LispStringLength(SCREEN->NATIVE_INFO); + tmpstring = (char *)alloca(strlen + 1); + LispStringToCStr(SCREEN->NATIVE_INFO, tmpstring); + dspif->handle = XtOpenDisplay( dspif->xtcontext, + tmpstring, + NULL, + "window", + NULL, + 0, + &save_argc, + save_argv); + } + else dspif->handle = XtOpenDisplay( dspif->xtcontext, + NULL, + NULL, + "window", + NULL, + 0, + &save_argc, + save_argv); + + /* Set up the native structure here */ + if (dspif->handle == NULL) return(CIntToLispInt(2)); + + XSetErrorHandler(Xerrhandler); + + display = dspif->handle; + dspif->xscreen = screen = DefaultScreenOfDisplay( display ); + + Xfd = ConnectionNumber(display); + FD_to_dspif[Xfd] = dspif; + LispReadFds |= (1 << Xfd); + MNWReadFds |= (1 << Xfd); +#ifndef ISC +#ifndef HPUX + fcntl(Xfd, F_SETOWN, getpid()); +#endif /* HPUX */ +#endif /* ISC */ + + dspif->screen = args[0]; /* So we know which SCREEN this display is */ + dspif->root = RootWindowOfScreen(screen); /* And the root window for the screen */ + dspif->gcindicator = 0; + dspif->legatewidget = 0; + dspif->cursor = 0; + + gcv.function = GXcopy; + gcv.foreground = dspif->white = WhitePixelOfScreen( screen ); + gcv.background = dspif->black = BlackPixelOfScreen( screen ); + dspif->TitleGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + tpx = XCreatePixmap(display, dspif->root, 10, 10, 1); + + gcv.function = GXcopy; + gcv.foreground = 1; + gcv.background = 0; + dspif->PixRGC = XCreateGC( display, tpx + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXor; + gcv.foreground = 1; + gcv.background = 0; + dspif->PixPGC = XCreateGC( display, tpx + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXxor; + gcv.foreground = 1; + gcv.background = 0; + dspif->PixIGC = XCreateGC( display, tpx + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXandInverted; + gcv.foreground = 1; + gcv.background = 0; + dspif->PixEGC = XCreateGC( display, tpx + , GCForeground | GCBackground | GCFunction + , &gcv ); + + + XFreePixmap(display, tpx); + + dspif->image.format = XYBitmap; + dspif->image.xoffset = 0; +#if (defined(BYTESWAP)) + dspif->image.byte_order = LSBFirst; +#else /* BYTESWAP */ + dspif->image.byte_order = MSBFirst; +#endif /* BYTESWAP */ + dspif->image.bitmap_unit = 16 /*BitmapUnit( dspif->handle )*/; + dspif->image.bitmap_bit_order = MSBFirst; + dspif->image.bitmap_pad = 16 /* 32 */; + _XInitImageFuncPtrs(&dspif->image); + + dspif->tmpimage.format = XYBitmap; + dspif->tmpimage.xoffset = 0; +#if (defined(BYTESWAP)) + dspif->tmpimage.byte_order = LSBFirst; +#else /* BYTESWAP */ + dspif->tmpimage.byte_order = MSBFirst; +#endif /* BYTESWAP */ + dspif->tmpimage.bitmap_unit = 16 /*BitmapUnit( dspif->handle )*/; + dspif->tmpimage.bitmap_bit_order = MSBFirst; + dspif->tmpimage.bitmap_pad = 16 /* 32 */; + _XInitImageFuncPtrs(&dspif->tmpimage); + + dspif->CreatedWifs = NULL; /* List of created wif. */ + /* Fill in the screen dimensions too! */ + SCREEN->SCWIDTH = + CIntToLispInt(WidthOfScreen(screen)); + SCREEN->SCHEIGHT = + CIntToLispInt(HeightOfScreen(screen)); +#ifndef NEVER + SCREEN->SCDEPTH = + CIntToLispInt(PlanesOfScreen(screen)); +#endif + + /* Methods for the display */ + dspif->Dispatch.Method.InitW = MNXcreateW; + dspif->Dispatch.Method.Openw = MNXopenW; + dspif->Dispatch.Method.Closew = MNXcloseW; + dspif->Dispatch.Method.MoveW = MNXmoveW; + dspif->Dispatch.Method.ShapeW = MNXshapeW; + dspif->Dispatch.Method.TotopW = MNXtotopW; + dspif->Dispatch.Method.BuryW = MNXburyW; + dspif->Dispatch.Method.ShrinkW = MNXshrinkW; + dspif->Dispatch.Method.ExpandW = MNXexpandW; + dspif->Dispatch.Method.DestroyW = MNXdestroyW; + dspif->Dispatch.Method.MakePromptW = MNXMakePromptWindow; + dspif->Dispatch.Method.DestroyMe = MNXdestroyDisplay; + dspif->Dispatch.Method.BBTtoWin = MNXBBTToXWindow; + dspif->Dispatch.Method.BBTfromWin = MNXBBTFromXWindow; + dspif->Dispatch.Method.BBTWinWin = MNXBBTWinWin; + dspif->Dispatch.Method.GetWindowProp = MNXgetwindowprop; + dspif->Dispatch.Method.PutWindowProp = MNXputwindowprop; + dspif->Dispatch.Method.GrabPointer = MNXGrabPointer; + dspif->Dispatch.Method.UngrabPointer = MNXUngrabPointer; + dspif->Dispatch.Method.DrawBox = MNXDrawBox; + dspif->Dispatch.Method.MovePointer = MNXMovePointer; + dspif->Dispatch.Method.MouseConfirm = MNXmouseconfirm; + dspif->Dispatch.Method.GCIndicator = MNXgarb; + dspif->Dispatch.Method.SetCursor = MNXSetCursor; + + /* ImageOp methods */ + dspif->ImageOp.Method.BitBlt = MNXBitBltBW; + dspif->ImageOp.Method.BltShade = MNXbltshadeBW; + dspif->ImageOp.Method.DrawPoint = MNXdrawpoint; + dspif->ImageOp.Method.DrawLine = MNXdrawline; + dspif->ImageOp.Method.DrawCurve = MNXdrawcurve; + dspif->ImageOp.Method.DrawCircle = MNXdrawcircle; + dspif->ImageOp.Method.FillCircle = MNXfillcircle; + dspif->ImageOp.Method.DrawCurve = MNXdrawcurve; + dspif->ImageOp.Method.DrawPolygon = MNXdrawpolygon; + dspif->ImageOp.Method.FillPolygon = MNXfillpolygon; + dspif->ImageOp.Method.DrawElips = MNXdrawelipse; + dspif->ImageOp.Method.WritePixel = MNXwritepixel; + dspif->ImageOp.Method.DrawArc = MNXdrawarc; + dspif->ImageOp.Method.OutcharFn = MNXOutchar; + dspif->ImageOp.Method.NewPage = MNXNewPage; + dspif->ImageOp.Method.ClippingRegion = MNXclippingregion; + dspif->ImageOp.Method.Operation = MNXoperation; + dspif->ImageOp.Method.Color = MNXdspcolor; + dspif->ImageOp.Method.BackColor = MNXdspbackcolor; + dspif->ImageOp.Method.Reset = MNXresetW; + dspif->ImageOp.Method.Offsets = MNXSetOffsets; + + XSynchronize(display, True); + + + + /**************************************************/ + /* Create GCs for BITBLTs from window to bitmap */ + /**************************************************/ + + diff = black & (~white); + inverted = 0; + + if (diff) + for (mask = 1; mask; mask<<= 1) { if (mask & diff) break;} + else + { + mask = 1; inverted = 1; + for (diff = white&(~black); mask; mask<<=1) + { if (mask & diff) break;} + } +#ifdef NEVER + gcv.function = GXcopy; + gcv.foreground = !inverted; + gcv.background = inverted; + dspif->GetRGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXxor; + dspif->GetIGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXor; + dspif->GetPGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + + gcv.function = GXandInverted; + dspif->GetEGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction + , &gcv ); + dspif->bw_plane = mask; + dspif->bw_inverted = inverted; +#endif /* NEVER */ + gcv.function = GXxor; + gcv.line_style = LineSolid; + gcv.line_width = 0; + gcv.foreground = 255; + gcv.background = 0; + dspif->BoxingGC = XCreateGC( display, dspif->root + , GCForeground | GCBackground | GCFunction | + GCLineWidth | GCLineStyle + , &gcv ); + XSetSubwindowMode( display, dspif->BoxingGC, IncludeInferiors); + + + /* Check the requested depth against possibilities */ + + if (SCREEN->SCDEPTH) + { int i; + int *dlist; + int dcount; + + dlist = XListDepths(display, + XScreenNumberOfScreen(screen), + &dcount); + for (i=0; iSCDEPTH & 0xFFFF)) + return(NIL); + return(CIntToLispInt(1)); /* Can't find depth */ + } + else + { + SCREEN->SCDEPTH = + CIntToLispInt(PlanesOfScreen(screen)); + } + return(NIL); +} + +/************************************************************/ +/* */ +/* i n i t _ m n w _ i n s t a n c e */ +/* */ +/* */ +/************************************************************/ +init_mnw_instance( args ) + LispPTR *args; +{ + int type; + + /* HACK !! HACK !! make this better later!! */ + MedleyWindowType = GetTypeNumber(*GetVALCELL68k(MAKEATOM("PROMPTWINDOW"))); + MedleyScreenType = GetTypeNumber(*GetVALCELL68k(MAKEATOM("LASTSCREEN"))); + MedleyBitmapType = 0; + + type = GetTypeNumber(args[0]); + + if(type == MedleyScreenType) { return(InitDsp(args)); } + else error("Bogus type\n"); + return(ATOM_T); +} + +/**************************************************************/ +/* d i s p a t c h _ m n w _ m e t h o d */ +/* */ +/* The arguments to the dispatcher are as follows */ +/* args[0] = methodindex, the index into the dispatch vector */ +/* args[1] = self, the object to dispatch from */ +/* args[n] = the misc arguments. */ +/* */ +/* The dispatcher finds the method dispatch table for the */ +/* object and dispatches the method. The method is called */ +/* with the methodindex removed. */ +/**************************************************************/ +dispatch_mnw_method( args ) + LispPTR *args; +{ + int type; + int index; + + index = LispIntToCInt(args[0]); + type = GetTypeNumber(args[1]); + + if(args[1] == NULL) + error("No object to dispatch from\n"); + + if(type == MedleyWindowType) { + WindowInterface wif; + + wif = WIfFromMw(args[1]); + if(wif == NULL){ + /* error("Attempt to dispatch on a non-native window.\n"); */ + return(NIL); + } + if((wif->Dispatch->vector[index]) == NULL){ + error("Display method not defined.\n"); + return(NIL); + } + /* Now, dispatch with the selector (first) arg shave off */ + return((wif->Dispatch->vector[index])(&args[1])); + } + else if(type == MedleyScreenType) { + DspInterface dspif; + + dspif = DspIfFromMscr(args[1]); + if(dspif == NULL){ + error("Attempt to dispatch on a non-native screen.\n"); + return(NIL); + } + if((dspif->Dispatch.vector[index]) == NULL){ + error("Display method not defined.\n"); + return(NIL); + } + /* Dispatch with selector and screen popped off */ + return((dspif->Dispatch.vector[index])(&args[2])); + } + else { + error("Bogus type\n"); + return(NIL); + } +} + diff --git a/src/mouseif.c b/src/mouseif.c new file mode 100755 index 0000000..85f1f5c --- /dev/null +++ b/src/mouseif.c @@ -0,0 +1,137 @@ +/* $Id: mouseif.c,v 1.2 1999/01/03 02:07:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mouseif.c,v 1.2 1999/01/03 02:07:26 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* * * * D O S M O U S E I N T E R F A C E * * * */ + + +#include "version.h" + + + +#include "lispemul.h" +#include "dbprint.h" +#include "devif.h" + +MouseInterfaceRec _curmouse; +MouseInterface currentmouse = &_curmouse; + +#ifdef DOS +#include + +int nomouseflag = FALSE; +extern DLword *Lisp_world; +extern LispPTR *LASTUSERACTION68k; +extern int twobuttonflag; + +extern void EnterDosMouse(); +extern void ExitDosMouse(); +extern void DosMouseAfterRaid(); +extern void DosMouseBeforeRaid(); +extern unsigned long GenericReturnT(); +extern void ThreeButtonHandler(); +extern void TwoButtonHandler(); +#endif /* DOS */ + +/*****************************************************************/ +/* p r o b e m o u s e */ +/* */ +/* Probe for mouse and return the number of buttons available. */ +/*****************************************************************/ +int probemouse() +{ + union REGS regs; + char c; + /*************************************************************************** + * Reset mouse driver, exit if no mouse driver present + ***************************************************************************/ + /* int 33h, case 0000, ax = drive installed, bx = # of buttons. */ + if (nomouseflag) { + return(666); /* return something, why not 666? */ + } + else { + regs.w.eax = 0; /* Func 0 = Reset mouse, ret. button info */ + int86(0x33, ®s, ®s); + + if(regs.x.ax == 0x0000) VESA_errorexit("No mouse driver found.", -1); + return(regs.x.bx); + } +} + +make_mouse_instance( mouse ) +MouseInterface mouse; +{ +#ifdef DOS + + int NumberOfButtons; + if (nomouseflag) { + mouse->device.enter = &GenericReturnT; + mouse->device.exit = &GenericReturnT; + mouse->device.before_raid = &GenericReturnT; + mouse->device.after_raid = &GenericReturnT; + mouse->device.active = FALSE; + NumberOfButtons = 3; + } + else { + mouse->device.enter = &EnterDosMouse; + mouse->device.exit = &ExitDosMouse; + mouse->device.before_raid = &DosMouseBeforeRaid; + mouse->device.after_raid = &DosMouseAfterRaid; + mouse->device.active = FALSE; + NumberOfButtons = probemouse(); + } + mouse->Button.StartTime = 2; + + mouse->Cursor.Last.width = 16; + mouse->Cursor.Last.height = 16; + + + + if (nomouseflag == FALSE) { + if(twobuttonflag) { /* We force two button handling. */ + mouse->Handler = &TwoButtonHandler; + mouse->Button.TwoButtonP = TRUE; + } + else /* Determine how many buttons we have. */ + switch(NumberOfButtons) { + case 0x0000: /* Other than 2 buttons, assume three */ + mouse->Button.TwoButtonP = FALSE; + mouse->Handler = &ThreeButtonHandler; + break; + case 0x0002: /* Two buttons. */ + mouse->Button.TwoButtonP = TRUE; + mouse->Handler = &TwoButtonHandler; + break; + case 0x0003: /* Three buttons. */ + mouse->Button.TwoButtonP = FALSE; + mouse->Handler = &ThreeButtonHandler; + break; + case 0xffff: /* Two buttons. */ + mouse->Button.TwoButtonP = TRUE; + mouse->Handler = &TwoButtonHandler; + break; + default: /* Strange case, assume three. */ + mouse->Button.TwoButtonP = FALSE; + mouse->Handler = &ThreeButtonHandler; + break; + } + } + /* mouse->timestamp = ((*LASTUSERACTION68k& 0xffffff) + Lisp_world); */ +#elif XWINDOW +#endif /* DOS or XWINDOW */ +} diff --git a/src/mvs.c b/src/mvs.c new file mode 100755 index 0000000..10692b9 --- /dev/null +++ b/src/mvs.c @@ -0,0 +1,353 @@ +/* $Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright (C) Venue"; + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* M U L T I P L E - V A L U E S U P P O R T */ +/* F U N C T I O N S */ +/* */ +/* Contains: values, values_list */ +/* */ +/************************************************************************/ + +#include + + +#include "lispemul.h" +#include "lispmap.h" +#include "lspglob.h" +#include "emlglob.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "stack.h" +#include "opcodes.h" + +#ifdef AIXPS2 +#include "inlnPS2.h" +#endif /* AIXPS2 */ + + /* to optionally swap the fnhead field of a frame */ +#ifdef BIGVM +#define SWA_FNHEAD +#else +#define SWA_FNHEAD swapx +#endif /* BIGVM */ + + + +LispPTR MVLIST_index; + + +/****************************************************************/ +/* */ +/* VALUES */ +/* */ +/* C-coded version of the function CL:VALUES */ +/* */ +/****************************************************************/ + +LispPTR values (int arg_count, register LispPTR *args) +{ + FX2 *caller, *prevcaller=0, *immediate_caller=0; + ByteCode *pc; + int unbind_count=0; + struct fnhead *fnhead; + int byteswapped; /* T if on 386 & reswapped code block */ + short opcode; + + caller = (FX2 *) CURRENTFX; + immediate_caller = caller; + +newframe: + if (caller == immediate_caller) + { + fnhead = (struct fnhead *) FuncObj; + pc = (ByteCode *) PC+3; /* to skip the miscn opcode we're in now */ + } + else + { + fnhead = (struct fnhead *) + Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); + pc = (ByteCode *)fnhead+(caller->pc); + } +#ifdef ISC + if(!fnhead->byteswapped) + { + byte_swap_code_block(fnhead); + fnhead->byteswapped=1; + } +#endif /* ISC */ + + + + +newpc: +#ifdef ISC + opcode = (short)((unsigned char) *((char *)pc)); +#else + opcode = (short)((unsigned char)GETBYTE((char *)pc)); +#endif + switch (opcode) + { + case opc_RETURN: + case opc_SLRETURN: prevcaller = caller; + caller = (FX2 *) (Stackspace+(unsigned)(GETCLINK(caller))); + goto newframe; + + case opc_FN1: if (MVLIST_index == Get_code_AtomNo(pc+1)) + { + if (unbind_count > 0) + simulate_unbind(caller, unbind_count, prevcaller); +#ifndef BIGATOMS + /* would add 3 to PC, but miscn return code does.*/ + if (caller == immediate_caller) PC = pc; +#else + /* BUT 3's not enough for big atoms, so add diff between FN op size & MISCN op size */ + if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE-3); +#endif /* BIGATOMS */ + + else caller->pc = (UNSIGNED)pc+ FN_OPCODE_SIZE-(UNSIGNED)fnhead; + return(make_value_list(arg_count, args)); + } + break; + + case opc_UNBIND: pc += 1; + unbind_count += 1; + goto newpc; + + case opc_JUMPX: { + register short displacement; +#ifdef ISC + displacement = (short) (*((char *)pc+1)); +#else + displacement = (short) (GETBYTE((char *)pc+1)); +#endif + if (displacement >= 128) displacement -= 256; + pc += displacement; + goto newpc; + } + + case opc_JUMPXX: { + register int displacement; + displacement = (int) Get_code_DLword(pc+1); + if (displacement >= 32768) displacement -= 65536; + pc += displacement; + goto newpc; + } + default: if ((opcode >= opc_JUMP) && (opcode < opc_FJUMP)) + { + pc += 2 + opcode - opc_JUMP; + goto newpc; + } + } + + /*****************************************/ + /* Default case: Return a single value. */ + /*****************************************/ + + if (arg_count>0) return(args[0]); + else return(NIL_PTR); + } + + + + +/****************************************************************/ +/* */ +/* VALUES_LIST */ +/* */ +/* C-coded version of the function CL:VALUES-LIST */ +/* */ +/****************************************************************/ + +LispPTR values_list (int arg_count, register LispPTR *args) +{ + FX2 *caller, *prevcaller=0, *immediate_caller=0; + ByteCode *pc; + int unbind_count=0; + struct fnhead *fnhead; + short opcode; + + caller = (FX2 *) CURRENTFX; + immediate_caller = caller; + +newframe: + if (caller == immediate_caller) + { + fnhead = (struct fnhead *) FuncObj; + pc = (ByteCode *) PC+3; /* Skip over the miscn opcode we're in now */ + } + else + { + fnhead = (struct fnhead *) + Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); + pc = (ByteCode *)fnhead+(caller->pc); + } + + +#ifdef ISC + if(!fnhead->byteswapped) + { + byte_swap_code_block(fnhead); + fnhead->byteswapped=1; + } +#endif /* ISC */ + + + + +newpc: +#ifdef ISC + opcode = (short)((unsigned char) *((char *)pc)); +#else + opcode = (short)((unsigned char)GETBYTE((char *)pc)); +#endif + switch (opcode) + { + case opc_RETURN: + case opc_SLRETURN: prevcaller = caller; + caller = (FX2 *) (Stackspace+(int)(GETCLINK(caller))); + goto newframe; + + case opc_FN1: if (MVLIST_index == Get_code_AtomNo(pc+1)) + { + if (unbind_count > 0) + simulate_unbind(caller, unbind_count, prevcaller); + /* would add 3 to PC, but miscn ret code does. */ +#ifndef BIGATOMS + if (caller == immediate_caller) PC = pc; +#else + /* BUT 3's not enough for big atoms, so add 1 */ + if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE-3); +#endif /* BIGATOMS */ + + else caller->pc = (UNSIGNED)pc+ FN_OPCODE_SIZE-(UNSIGNED)fnhead; + return(args[0]); + } + break; + + case opc_UNBIND: pc += 1; + unbind_count += 1; + goto newpc; + + case opc_JUMPX: { + register short displacement; +#ifdef ISC + displacement = (short) (*((char *)pc+1)); +#else + displacement = (short) (GETBYTE((char *)pc+1)); +#endif + if (displacement >= 128) displacement -= 256; + pc += displacement; + goto newpc; + } + + case opc_JUMPXX: { + register int displacement; + displacement = (int) Get_code_DLword(pc+1); + if (displacement >= 32768) displacement -= 65536; + pc += displacement; + goto newpc; + } + default: if ((opcode >= opc_JUMP) && (opcode < opc_FJUMP)) + { + pc += 2 + opcode - opc_JUMP; + goto newpc; + } + } + + /*****************************************/ + /* Default case: Return a single value. */ + /*****************************************/ + + if (Listp(args[0])) return(car(args[0])); + else return(args[0]); + } + + +/************************************************************************/ +/* */ +/* m a k e _ v a l u e _ l i s t */ +/* */ +/* Given a count of values to return, and a pointer to an */ +/* array containing the values, CONS up a list that contains */ +/* the values. This is because MVs are really returned on */ +/* the stack as a list -- SHOULD BE CHANGED! */ +/* */ +/************************************************************************/ + +make_value_list(int argcount, LispPTR *argarray) +{ + register LispPTR result = NIL_PTR; + register int i; + if (argcount == 0) return(NIL_PTR); + for (i = argcount-1; i>=0; i--) + { + result = cons(argarray[i], result); + } + return(result); + } + + + +/************************************************************************/ +/* */ +/* s i m u l a t e _ u n b i n d */ +/* */ +/* Simulate the effect of UNBIND on a frame, to back us up */ +/* to where we ought to be when we return multiple values. */ +/* */ +/* */ +/* */ +/************************************************************************/ + +simulate_unbind(FX2 *frame, int unbind_count, FX2 *returner) +{ + int unbind; + LispPTR *stackptr; + DLword *nextblock; + stackptr = (LispPTR *) (Stackspace+frame->nextblock); + nextblock = (DLword *) stackptr; + for (unbind = 0; unbind=0);); /* find the binding mark */ + value = (int)*stackptr; + lastpvar = (LispPTR *) ((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value));; + bindnvalues = (~value)>>16; + for(value=bindnvalues; --value >= 0;){*--lastpvar = 0xffffffff;} + /* This line caused \NSMAIL.READ.HEADING to smash memory, */ + /* so I removed it 21 Jul 91 --JDS. This was the only */ + /* difference between this function and the UNWIND code */ + /* in inlineC.h */ +/* MAKEFREEBLOCK(stackptr, (DLword *)stackptr-nextblock); */ + } + if (returner) returner->fast = 0; /* since we've destroyed congituity + /* in the stack, but that only + matters if there's a return. */ + } + + diff --git a/src/ocr.c b/src/ocr.c new file mode 100755 index 0000000..9d196a8 --- /dev/null +++ b/src/ocr.c @@ -0,0 +1,1613 @@ +/* $Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifdef OCR + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "adr68k.h" +#include "lispmap.h" +#include "lispemul.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "cell.h" +#include "arith.h" +#include "timeout.h" +#include "ocr.h" + +/* + * Socket descriptor to communicate with the OCR process + */ + +int OCR_sock = -1; +u_int shifted_OCR_sock; + +/* + * OCR process ID + */ + +int OCR_procID = -1; + +/* + * Lisp I/F to indicate wait status. + * Points to the value cell of IL:\OCR.STATE.FLAGS + */ + +LispPTR *OCR_state_word = NULL; + +/* + * Other Lisp I/F area + */ + +struct ocr_image_info *OCR_iminfo_block = NULL; + +/* + * Image size cache + */ + +static u_int OCR_image_size = 0; + +/* + * Local Definitions for clarify code + */ + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define NULL_STATE_WORD (OCR_state_word == NULL) + +#define WAITING_REASON (*(u_int *)Addr68k_from_LADDR(*OCR_state_word)) + +#define INIT_STATE_WORD {\ + DLword an;\ + extern int get_package_atom();\ + an = get_package_atom("\\OCR.STATE.FLAGS", 16, "INTERLISP", 9, NIL);\ + OCR_state_word = GetDEFCELL68k(an); \ +} + +#define SET_WAIT_FLG(reason) {\ + u_int *flagp;\ + flagp = (u_int *)Addr68k_from_LADDR(*OCR_state_word);\ + *flagp = reason;\ +} + +#define CLR_WAIT_FLG {\ + u_int *flagp;\ + flagp = (u_int *)Addr68k_from_LADDR(*OCR_state_word);\ + *flagp = 0;\ +} + +#define FD_BLOCK 1 +#define FD_NON_BLOCK 0 + +/* + * Local Functions + */ + +static int ocr_open(), ocr_scan(), ocr_iminfo(), ocr_fork(); +static int ocr_block_mode(), ocr_bulk_read(), ocr_wait(); +static int ocr_set_rpara(), ocr_read(); +static void ocr_close(), ocr_sig_handler(), ocr_irq(), ocr_set_handler(); +static void ocr_clr_handler(), ocr_device_reset(); +static void ocr_scan_finish(), ocr_img_upld_finish(), ocr_read_finish(); +static void ocr_code_conv(); +static LispPTR ocr_get_read_result(); + + +/* + * Subr OCR_COMM: + * + * According to the command indicated by args[0], dispatch to the appropriate + * routines. Each subroutine should return one of 1, 0 and -1 as its value. + * 1 means the command is completed successfully. 0 means the command is failed + * but the OCR process is still alive. -1 means the command is failed and + * OCR process seems dead. In -1 case, issue an interrupt request with interrupt + * mode OCR_ST_PROC_DEAD. This causes Lisp fall into a debugger after establishing + * unwind protected contour to reset OCR. + */ + +int +ocr_comm(args) +LispPTR *args; +{ + int com; + LispPTR val; + + N_GETNUMBER(args[0], com, INVAL); + switch (com) { + case DO_OPEN: + if (OCR_sock >= 0) { + val = GetSmallp(0); + } else { + val = ocr_open(); + if (val > 0) { + val = GetSmallp(val); + } else { + val = GetSmallp(0); + } + } + break; + + case DO_SCAN: + { + switch(ocr_scan((struct ocr_scan_para *) + Addr68k_from_LADDR(args[1]))) { + case 1: + val = ATOM_T; + break; + + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; + + case 0: + default: + val = NIL; + } + } + break; + + case DO_IMG_INFO: + if (OCR_sock < 0) { + val = NIL; + } else { + OCR_iminfo_block + = (struct ocr_image_info *)Addr68k_from_LADDR(args[2]); + + switch (ocr_iminfo((struct ocr_up_para *) + Addr68k_from_LADDR(args[1]))) { + case 1: + val = ATOM_T; + break; + + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; + + case 0: + default: + val = NIL; + } + } + break; + + case DO_IMG_UPLD: + { + BITMAP *bmp; + int len; + + bmp = (BITMAP *)Addr68k_from_LADDR(args[1]); + + len = ocr_bulk_read(OCR_sock, + (char *)Addr68k_from_LADDR(bmp->bmbase), + 10); + val = (len < 0) ? NIL : ATOM_T; + } + break; + + case DO_SET_RPARA: + { + int cnt; + u_char *pp; + + pp = (u_char *)Addr68k_from_LADDR(args[1]); + N_GETNUMBER(args[2], cnt, INVAL); + + switch (ocr_set_rpara(pp, cnt)) { + case 1: + val = ATOM_T; + break; + + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; + + case 0: + default: + val = NIL; + } + } + break; + + case DO_CLR_RPARA: + { + switch(ocr_clr_rpara()) { + case 1: + val = ATOM_T; + break; + + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; + + case 0: + default: + val = NIL; + } + } + break; + + case DO_READ: + { + switch(ocr_read()) { + case 1: + val = ATOM_T; + break; + + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; + + case 0: + default: + val = NIL; + } + } + break; + + case DO_GET_RESULT: + if (OCR_sock < 0) { + val = NIL; + } else { + val = ocr_get_read_result(OCR_sock); + } + break; + + case DO_CLOSE: + if (OCR_sock < 0) { + val = NIL; + } else { + ocr_close(); + val = ATOM_T; + } + break; + + case DO_CODE_CONV: + { + int len; + N_GETNUMBER(args[1], len, INVAL); + ocr_code_conv((u_char *)Addr68k_from_LADDR(args[2]), + len); + val = ATOM_T; + } + break; + + case DO_TEST: + { + extern DLword *createcell68k(); + u_char *np, *np2; + LispPTR lp; + + np = (u_char *)createcell68k(TYPE_VMEMPAGEP); + np2 = (u_char *)createcell68k(TYPE_VMEMPAGEP); + lp = cons(LADDR_from_68k(np2), NIL); + lp = cons(LADDR_from_68k(np), lp); + val = lp; + } + break; + + default: + error("ocr_comm: Invalid Comm byte"); + } + return(val); + INVAL: + return(NIL); +} + +/* + * Subr OCR_COMM: comm = OCR_OPEN + * + * Fork OCR process and isssue 'O' command to open OCR device. + */ + +static int +ocr_open() +{ + int cnt; + u_char pkt[PKTLEN]; + + OCR_sock = ocr_fork(); + if (OCR_sock < 0) { + return 0; + } else { + if (!ocr_block_mode(OCR_sock, FD_BLOCK)) return 0; + pkt[0] = 'O'; + pkt[1] = pkt[2] = 0; + if (write(OCR_sock, pkt, sizeof(pkt)) < 0) { + ocr_close(); + return 0; + } + + SETJMP(0); + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 20); + if (cnt == sizeof(pkt) && pkt[0] == 1) { + if (NULL_STATE_WORD) INIT_STATE_WORD; + ocr_set_handler(); + shifted_OCR_sock = 1 << OCR_sock; + return(OCR_sock); + } else { + return 0; + } + } +} + +/* + * Ask the pre-forked small emulator process to fork the OCR process + */ + +static int +ocr_fork() +{ + int sfd, nsfd; + char *addr; + int len, flag; + struct sockaddr_un sock; + u_char pkt[4]; + extern char *build_socket_pathname(); + extern int UnixPipeIn, UnixPipeOut; + + sfd = socket(AF_UNIX, SOCK_STREAM, 0); + if (sfd < 0) { + perror("ocr_fork: socket open"); + return -1; + } + + addr = build_socket_pathname(sfd); + sock.sun_family = AF_UNIX; + strcpy(sock.sun_path, addr); + + unlink(addr); + len = sizeof(sock.sun_family) + strlen(addr); + if (bind(sfd, &sock, len) < 0) { + perror("ocr_fork: bind"); + close(sfd); + return -1; + } + + if (listen(sfd, 1) < 0) { + perror("ocr_fork: listen"); + unlink(addr); + close(sfd); + return -1; + } + + pkt[0] = 'O'; + pkt[3] = sfd; + write(UnixPipeOut, pkt, 4); + + read(UnixPipeIn, pkt, 4); + if (pkt[3] == 1) { + retry: + SETJMP(-1); + S_TOUT_TIME(nsfd = accept(sfd, NULL, NULL), 20); + if (nsfd < 0) { + if (errno == EINTR) { + goto retry; + } else { + perror("ocr_fork: accept"); + unlink(addr); + close(sfd); + return -1; + } + } + close(sfd); + unlink(addr); + OCR_procID = pkt[1] << 8 | pkt[2]; + return(nsfd); + } else { + close(sfd); + unlink(addr); + return -1; + } +} + +/* + * Change blocking mode of a file descriptor. + */ + +static int +ocr_block_mode(fd, doblock) +int fd; +int doblock; +{ + int flags; + + if (fd < 0) return 0; + + flags = fcntl(fd, F_GETFL, 0); + if (flags < 0) return 0; + + if (doblock) { + flags &= ~FNDELAY; + } else { + flags |= FNDELAY; + } + + if (fcntl(fd, F_SETFL, flags) < 0) return 0; + + return 1; +} + +/* + * Cleanup routines + */ + +static void +ocr_device_reset() +{ + if (OCR_sock >= 0) { + u_char pkt[PKTLEN]; + + pkt[0] = 'A'; + pkt[1] = pkt[2] = 0; + write(OCR_sock, pkt, sizeof(pkt)); + + sleep(1); + } + return; +} + +static int +ocr_wait() +{ + u_char pkt[4]; + int status; + + if (OCR_procID > 0) { + + pkt[0] = 'w'; + pkt[1] = OCR_procID >> 8 & 0xFF; + pkt[2] = OCR_procID & 0xFF; + + write(UnixPipeOut, pkt, sizeof(pkt)); + read(UnixPipeIn, pkt, sizeof(pkt)); + + status = pkt[0] << 24 | pkt[1] << 16 | pkt[2] << 8 | pkt[3]; + + if (status != 0 && (WIFSIGNALED(status) || WIFEXITED(status))) { + return 1; + } else { + return 0; + } + + } + return 1; +} + +static void +ocr_close() +{ + int status, pid; + + if (OCR_sock >= 0) { + ocr_device_reset(); + (void)shutdown(OCR_sock, 2); + } + + OCR_sock = shifted_OCR_sock = -1; + ocr_clr_handler(); + + if (OCR_procID > 0) { + if (ocr_wait() == 0) { + int i; + kill(OCR_procID, SIGUSR1); + for (i = 0; i < 10; i++) { + if(ocr_wait()) break; + } + } + OCR_procID = -1; + } + return; +} + +/* + * Subr OCR_COMM: comm = OCR_SCAN + * + * Issue 'S' command to start scanning. 'S' commmand returns immediatedly + * without waiting device to finish scanning. + */ + +static int +ocr_scan(sp) +struct ocr_scan_para *sp; +{ + int cnt; + u_char pkt[PKTLEN]; + + + pkt[0] = 'S'; + pkt[1] = 0; + pkt[2] = sizeof(struct ocr_scan_para); + + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { + return 0; + } + if (write(OCR_sock, (char *)sp, sizeof(struct ocr_scan_para)) != + sizeof(struct ocr_scan_para)) { + return 0; + } + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + SET_WAIT_FLG(OCR_ST_SCANNING); + return 1; + } else { + return 0; + } +} + +/* + * Subr OCR_COMM: comm = OCR_IMG_INFO + * + * Issue 'I' command to get an information about the image being uploaded. + * 'I' commmand returns immediatedly without waiting OCR process to + * finish its work. + */ + +static int +ocr_iminfo(up) +struct ocr_up_para *up; +{ + int i, cnt; + u_char pkt[PKTLEN]; + + + pkt[0] = 'I'; + pkt[1] = 0; + pkt[2] = sizeof(struct ocr_up_para); + + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { + return 0; + } + if (write(OCR_sock, (char *)up, sizeof(struct ocr_up_para)) != + sizeof(struct ocr_up_para)) { + return 0; + } + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); + + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + SET_WAIT_FLG(OCR_ST_UPLDING); + return 1; + } else { + return 0; + } +} + +/* + * Subr OCR_COMM: comm = OCR_SET_RPARA + * + * Issue 'P' command to set read parameters. + */ + +static int +ocr_set_rpara(pp, num) +register u_char *pp; +register int num; +{ + register int cnt; + u_char pkt[PKTLEN]; + + pkt[0] = 'P'; + num = num * sizeof(struct ocr_read_para); + pkt[1] = num >> 8 & 0xFF; + pkt[2] = num & 0xFF; + + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { + return 0; + } + do { + cnt = write(OCR_sock, (char *)pp, num); + if (cnt < 0) { + return 0; + } else { + num -= cnt; + pp += cnt; + } + } while (num > 0); + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + return 1; + } else { + return 0; + } +} + +/* + * Subr OCR_COMM: comm = OCR_CLR_RPARA + * + * Issue 'C' command to clear all read parameters. + */ + +static int +ocr_clr_rpara() +{ + register int cnt; + u_char pkt[PKTLEN]; + + pkt[0] = 'C'; + pkt[1] = pkt[2] = 0; + + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { + return 0; + } + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + return 1; + } else { + return 0; + } +} + +/* + * Subr OCR_COMM: comm = OCR_READ + * + * Issue 'R' command to start reading. + * 'R' commmand returns immediatedly without waiting OCR process to + * finish its work. + */ + +static int +ocr_read() +{ + register int cnt; + u_char pkt[PKTLEN]; + + pkt[0] = 'R'; + pkt[1] = pkt[2] = 0; + + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { + return 0; + } + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + SET_WAIT_FLG(OCR_ST_READING) + return 1; + } else { + return 0; + } +} + +/* + * SIGUSR1 handler. + * + * If one of time consuming work is finished by OCR process, SIGUSR1 is signalled. + * Accoding to the waiting reason, do appropriate work, then to notify Lisp. + */ + +static void +ocr_sig_handler(sig, code, scp) +int sig, code; +struct sigcontext *scp; +{ + if (OCR_sock < 0) return; + + switch (WAITING_REASON) { + case OCR_ST_SCANNING: + ocr_scan_finish(); + break; + + case OCR_ST_UPLDING: + ocr_img_upld_finish(); + break; + + case OCR_ST_READING: + ocr_read_finish(); + break; + + default: + SET_WAIT_FLG(OCR_ST_FAIL); + + } + ocr_irq(); + return; +} + +static void +ocr_set_handler() +{ + struct sigvec sv; + + sv.sv_flags = sv.sv_mask = 0; + sv.sv_handler = ocr_sig_handler; + sigvec(SIGUSR1, &sv, NULL); + return; +} + +static void +ocr_clr_handler() +{ + struct sigvec sv; + extern void panicuraid(); + + sv.sv_flags = sv.sv_mask = 0; + sv.sv_handler = panicuraid; + sigvec(SIGUSR1, &sv, NULL); + return; +} + +/* + * Handle SIGUSR1 interrupt if state is scanning + */ + +static void +ocr_scan_finish() +{ + int cnt; + u_char pkt[PKTLEN]; + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) { + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + break; + } + } + return; + }); + + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + CLR_WAIT_FLG; + } else { + SET_WAIT_FLG(OCR_ST_FAIL); + } + return; +} + +/* + * Handle SIGUSR1 interrupt if state is image uploading + */ + +static void +ocr_img_upld_finish() +{ + int cnt; + u_char pkt[PKTLEN]; + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) { + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + break; + } + } + return; + }); + + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + S_TOUT_TIME(cnt = read(OCR_sock, + (char *)OCR_iminfo_block, + sizeof(struct ocr_image_info)), 5); + if (cnt == sizeof(struct ocr_image_info)) { + CLR_WAIT_FLG; + OCR_image_size = OCR_iminfo_block->size; + } else { + SET_WAIT_FLG(OCR_ST_FAIL); + } + } else { + SET_WAIT_FLG(OCR_ST_FAIL); + } + return; +} + +/* + * Handle SIGUSR1 interrupt if state is reading + */ + +static void +ocr_read_finish() +{ + int cnt; + u_char pkt[PKTLEN]; + + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) { + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + break; + } + } + return; + }); + + + S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); + + if (cnt == sizeof(pkt) && pkt[0] == 1) { + CLR_WAIT_FLG; + } else { + SET_WAIT_FLG(OCR_ST_FAIL); + } + return; +} + +/* + * Set up the interrupt stuff and issue a requst. + */ + +static void +ocr_irq() +{ + u_int *flagp; + extern LispPTR *IOINTERRUPTFLAGS_word; + extern LispPTR *IOINTERRUPTSTATE_word; + extern LispPTR *PENDINGINTERRUPT68k; + + if (OCR_sock < 0) return; + + flagp = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); + *flagp = shifted_OCR_sock; + + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word)) + ->IOInterrupt = 1; + + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End=Irq_Stk_Check=0; + + return; +} + +/* + * Bulk data transfer + */ + +static int +ocr_bulk_read(fd, buf, tout) +int fd, tout; +register char *buf; +{ + register u_int cnt, len = 0; + struct bd_header hd; + + SETJMP(-1); + + while (1) { + S_TOUT_TIME(cnt = read(fd, &hd, sizeof(struct bd_header)), tout); + if (cnt < 0) return -1; + if (hd.len == 0) return((hd.cont == BD_LAST) ? len : -1); + do { + S_TOUT_TIME(cnt = read(fd, buf, hd.len), tout); + if (cnt < 0) return -1; + hd.len -= cnt; + len += cnt; + buf += cnt; + } while (hd.len > 0); + if (hd.cont == BD_LAST) return len; + } +} + +static LispPTR +ocr_get_read_result(fd) +int fd; +{ + register u_int cnt, len, buflen; + struct bd_header hd; + u_char *buf, *ptr; + LispPTR val; + + SETJMP(NIL); + + S_TOUT_TIME(cnt = read(fd, &hd, sizeof(struct bd_header)), 1); + val = 0; + ptr = buf = NULL; + buflen = 0; + + while (hd.len > 0) { + if (buflen > 0) { + len = MIN(hd.len, buflen); + do { + S_TOUT_TIME(cnt = read(fd, ptr, len), 10); + if (cnt < 0) return(NIL); + hd.len -= cnt; + len -= cnt; + buflen -= cnt; + ptr += cnt; + } while (len > 0); + if (hd.len > 0) { + continue; + } else if (hd.cont != BD_CONT) { + break; + } else { + S_TOUT_TIME(cnt = + read(fd, &hd, sizeof(struct bd_header)), 1); + continue; + } + } else { + ptr = buf = (u_char *)createcell68k(TYPE_VMEMPAGEP); + if (buf == NULL) { + return(NIL); + } else { + val = cons(LADDR_from_68k(buf), val); + buflen = 512; + } + } + } + return(val); +} + +/* + * OCR specific code conversion + */ + +static u_short jis0[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x00A5, 0x005D, 0x005E, 0x005F, + + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2123, 0x2156, 0x2157, 0x2122, 0x00B7, 0x2572, 0x2521, + 0x2523, 0x2525, 0x2527, 0x2529, 0x2563, 0x2565, 0x2567, 0x2544, + + 0x213C, 0x2522, 0x2524, 0x2526, 0x2528, 0x252A, 0x252B, 0x252D, + 0x252F, 0x2531, 0x2533, 0x2535, 0x2537, 0x2539, 0x253B, 0x253D, + + 0x253F, 0x2541, 0x2544, 0x2546, 0x2548, 0x254A, 0x254B, 0x254C, + 0x254D, 0x254E, 0x254F, 0x2552, 0x2555, 0x2558, 0x255B, 0x255E, + + 0x255F, 0x2560, 0x2561, 0x2562, 0x2564, 0x2566, 0x2568, 0x2569, + 0x256A, 0x256B, 0x256C, 0x256D, 0x256F, 0x2573, 0x212B, 0x212C, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis1[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2121, 0x2122, 0x2123, 0x002C, 0x002E, 0x00B7, 0x003A, + 0x003B, 0x003F, 0x0021, 0x212B, 0x212C, 0x00C2, 0x00C1, 0x00C8, + + 0x00C3, 0x2223, 0x00CC, 0x2133, 0x2134, 0x2135, 0x2136, 0x2137, + 0x2138, 0x2139, 0x213A, 0x213B, 0x213C, 0xEF24, 0x213E, 0x002F, + + 0x005C, 0x007E, 0x003D, 0x007C, 0x2144, 0x003A, 0x00A9, 0x0027, + 0x00AA, 0x00BA, 0x0028, 0x0029, 0x214C, 0x214D, 0x005B, 0x005D, + + 0x007B, 0x007D, 0xEF32, 0xEF33, 0x00AB, 0x00BB, 0x2156, 0x2157, + 0x2158, 0x2159, 0x215A, 0x215B, 0x002B, 0x002D, 0x00B1, 0x00B4, + + 0x00B8, 0x003D, 0x2162, 0x003C, 0x003E, 0x2165, 0x2166, 0x2167, + 0x2168, 0x2169, 0x216A, 0x00B0, 0x216C, 0x216D, 0x216E, 0x00A5, + + 0x00A4, 0x00A2, 0x00A3, 0x0025, 0x0023, 0x0026, 0x002A, 0x0040, + 0x00A7, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis2[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2221, 0x2222, 0x2223, 0x2224, 0x2225, 0x2226, 0x2227, + 0x2228, 0x2229, 0x00AE, 0x00AC, 0x00AD, 0x00AF, 0x222E, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0xEF4A, 0xEF4C, 0xEF59, 0xEF58, 0xEF5B, 0xEF5A, + + 0xEF57, 0xEF56, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0xEFB6, 0xEFB7, 0xEF6A, 0xEF4F, 0xEF4E, 0xEFB5, + + 0xEFB4, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0xEF6C, 0xEF70, 0x2223, 0xEFBA, + + 0xEFB9, 0xEF72, 0x2223, 0xEF42, 0xEF43, 0x2223, 0x2223, 0xEF71, + 0xEF6F, 0xEF75, 0x226A, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0xF128, 0xEF41, 0x2223, 0x2223, 0x2223, 0xEF30, + 0xEF31, 0x00B0, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis3[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis6[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2641, 0x2642, 0x2644, 0x2645, 0x2646, 0x2649, 0x264A, + 0x264B, 0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, + + 0x2653, 0x2655, 0x2656, 0x2658, 0x2659, 0x265A, 0x265B, 0x265C, + 0x265D, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2661, 0x2662, 0x2664, 0x2665, 0x2666, 0x2669, 0x266A, + 0x266B, 0x266C, 0x266D, 0x266E, 0x266F, 0x2670, 0x2671, 0x2672, + + 0x2673, 0x2675, 0x2676, 0x2678, 0x2679, 0x267A, 0x267B, 0x267C, + 0x267D, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis84[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x7521, 0x7522, 0x7523, 0x7524, 0x7525, 0x7526, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis8[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0xEF69, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0xF128, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x7421, 0x7421, 0xEFFC, 0xEFFC, + 0x2220, 0x2220, 0xEFA8, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis9[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0xEFD1, 0xEFD2, 0xEFD3, 0xEFD4, + 0xEFD5, 0xEFD6, 0xEFD7, 0xEFD8, 0xEFD9, 0xEFDA, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0xEFD1, 0xEFD2, 0xEFD3, 0xEFD4, 0xEFD5, 0xEFD6, 0xEFD7, + + 0xEFD8, 0xEFD9, 0xEFDA, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0xEFC2, + + 0xEFC3, 0xEFC4, 0x2223, 0xEFC6, 0xEFC7, 0xEFC8, 0xEFC9, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis10[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x7409, 0x7421, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +static u_short jis14[256] = +{ + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2122, 0x2123, 0x2124, 0x2125, 0x2223, 0x2223, 0x213C, + 0xEF24, 0x213E, 0x213B, 0x2223, 0x2223, 0x2144, 0x2145, 0x00A9, + + 0x0027, 0x00AA, 0x00BA, 0x0028, 0x0029, 0x214C, 0x214D, 0x005B, + 0x005D, 0x007B, 0x007D, 0xEF32, 0xEF33, 0x00AB, 0x00BB, 0x2156, + + 0x2157, 0x2223, 0x2223, 0x215A, 0x215B, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 + +}; + +#define SJIS_TO_JIS(hp, lp) {\ + *(hp) -= (*(hp) > 0x9F) ? 0xB1 : 0x71;\ + *(hp) = (*(hp) << 1) + 1;\ + if (*(lp) > 0x9E) {\ + *(lp) -= 0x7E;\ + *(hp) += 1;\ + } else if (*(lp) > 0x7E) {\ + *(lp) -= 0x20;\ + } else {\ + *(lp) -= 0x1F;\ + }\ +} + +static void +ocr_code_conv(ptr, len) +register u_char *ptr; +register int len; +{ + while (len > 0) { + if (*ptr == 0xFF) { /* ASCII & Hankaku-kana */ + *(u_short *)ptr = jis0[*(ptr + 1)]; + } else { + + SJIS_TO_JIS(ptr, ptr + 1); + switch (*ptr) { + case 0X21: /* 1 Ku */ + *(u_short *)ptr = jis1[*(ptr + 1)]; + break; + case 0X22: /* 2 Ku */ + *(u_short *)ptr = jis2[*(ptr + 1)]; + break; + case 0X23: /* 3 Ku */ + *(u_short *)ptr = jis3[*(ptr + 1)]; + break; + case 0X26: /* 6 Ku */ + *(u_short *)ptr = jis6[*(ptr + 1)]; + break; + case 0X28: /* 8 Ku */ + *(u_short *)ptr = jis8[*(ptr + 1)]; + break; + case 0X29: /* 9 Ku */ + *(u_short *)ptr = jis9[*(ptr + 1)]; + break; + case 0X2A: /* 10 Ku */ + *(u_short *)ptr = jis10[*(ptr + 1)]; + break; + case 0X2E: /* 14 Ku */ + *(u_short *)ptr = jis14[*(ptr + 1)]; + break; + case 0X74: /* 84 Ku */ + *(u_short *)ptr = jis84[*(ptr + 1)]; + break; + default: + break; + } + } + ptr += 2; + len--; + } +} + + +#endif /* OCR */ + diff --git a/src/ocr.c.X b/src/ocr.c.X new file mode 100644 index 0000000..e69de29 diff --git a/src/ocrproc.c b/src/ocrproc.c new file mode 100755 index 0000000..3490dc9 --- /dev/null +++ b/src/ocrproc.c @@ -0,0 +1,1142 @@ +/* $Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifdef OCR + +#include +#include +#include +#include +#include +#include +#include "ocr.h" + +/* + * Cache parameter passed from Subr to postpone time consuming work + */ + +static struct ocr_scan_para OCR_scan_para; +static struct ocr_up_para OCR_up_para; + +/* + * Image size cache + */ + +static int OCR_image_size = 0; + +/* + * Number of regions to be read + */ + +static int OCR_read_regions = 0; + +/* + * Socket fd to communicate the primary emulator process + */ + +int OCR_sv = -1; + +/* + * Fd for the OCR device file + */ + +int OCR_fd = -1; + +/* + * Local definitions for clarify code + */ + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +/* + * Local functions + */ + +static int ocr_handle_comm(), ocr_init_sv(); +static int ocr_proc_scan(), ocr_proc_iminfo(), ocr_proc_set_rpara(); +static int ocr_proc_clr_rpara(), ocr_proc_read(), ocr_conv_read_data(); +static void ocr_do_postponed_work(), ocr_proc_img_upload(); +static void ocr_proc_exit(), ocr_init_signal(), notify_ready(); +static void ocr_proc_post_read(); + +/* + * OCR process + * + * Keep waiting 3 byte length command packet from the primary emulator process. + * The first byte of the packet indicates the work requested. The second and + * third byte indicate the extra packet length. The contents of the extra packet + * is command dependent. + * + * After finishing the work, sends back the another 3 byte length packet. The + * first byte of the returned packet indicates how the work has been done. 1 is + * success, and 0 is failure. + * + * If the work requested will take a long time, the packet with state 1 is just + * returned and the actual work will be postponed, After finishing the postponed + * work, another 3 byte length packet which indicates the result of the work + * is sent back to the primary emulator process, and SIGUSR1 is signalled to + * notify the completion of the initial request. + */ + +void +ocr_proc(ppid) +pid_t ppid; +{ + int len, postponed = 0; + u_char pkt[PKTLEN]; + static u_char epkt[EPKTLEN]; /* Maximum size of extra packet */ + + if (!ocr_init_sv()) return; + ocr_init_signal(); + + while (1) { + + if (postponed) { + ocr_do_postponed_work(postponed, ppid); + postponed = 0; + } else { + len = read(OCR_sv, pkt, sizeof(pkt)); + if (len == 0) { + /* + * Broken socket will return size 0. + * Assumes the parent dies + */ + ocr_proc_exit(); + } else if (len != sizeof(pkt)) { + pkt[0] = 0; + (void)write(OCR_sv, pkt, sizeof(pkt)); + } else { + if (pkt[1] == 0 && pkt[2] == 0) { + ocr_handle_comm(pkt, NULL, &postponed); + } else { + int elen; + + elen = pkt[1] << 8 | pkt[2]; + len = read(OCR_sv, epkt, elen); + if (len != elen) { + pkt[0] = 0; + (void)write(OCR_sv, pkt, sizeof(pkt)); + } else { + ocr_handle_comm(pkt, epkt, &postponed); + } + } + } + } + } +} + +/* + * Try to resett the device then exit. + */ + +static void +ocr_proc_exit() +{ + if (OCR_fd > 0) { + ioctl(OCR_fd, OCR_ABORT); + close(OCR_fd); + OCR_fd = -1; + } + exit(1); +} + +/* + * Handle the work requested from the primary emulator process + */ + +static int +ocr_handle_comm(pkt, epkt, reasonp) +u_char pkt[], epkt[]; +int *reasonp; +{ + int len; + + *reasonp = 0; + switch (pkt[0]) { + case 'O': /* Open */ + if (OCR_fd > 0) { + pkt[0] = 0; + } else { + OCR_fd = open(OCRDEV, O_RDWR); + if (OCR_fd < 0) { + perror("ocr_proc : OPEN"); + pkt[0] = 0; + } else { + pkt[0] = 1; + } + } + break; + + case 'S': /* Start scanning */ + { + if ((pkt[1] << 8 | pkt[2]) == + sizeof(struct ocr_scan_para)) { + bcopy(epkt, (char *)&OCR_scan_para, + sizeof(struct ocr_scan_para)); + *reasonp = OCR_ST_SCANNING; + pkt[0] = 1; + } else { + pkt[0] = 0; + } + } + break; + + case 'I': /* Start getting image info */ + { + if ((pkt[1] << 8 | pkt[2]) == + sizeof(struct ocr_up_para)) { + bcopy(epkt, (char *)&OCR_up_para, + sizeof(struct ocr_up_para)); + *reasonp = OCR_ST_UPLDING; + pkt[0] = 1; + } else { + pkt[0] = 0; + } + } + break; + + case 'P': /* Set read params */ + { + int len; + + len = pkt[1] << 8 | pkt[2]; + if (len % sizeof(struct ocr_read_para)) { + pkt[0] = 0; + } else { + len = len / sizeof(struct ocr_read_para); + if (len + OCR_read_regions > OCR_MAX_RD_PARAMS) { + pkt[0] = 0; + } else if (ocr_proc_set_rpara((struct ocr_read_para *) + epkt, len)) { + pkt[0] = 1; + } else { + pkt[0] = 0; + } + } + } + break; + + case 'C': /* Clear read params */ + { + if (ocr_proc_clr_rpara()) { + pkt[0] = 1; + } else { + pkt[0] = 0; + } + } + break; + + case 'R': /* Start reading */ + { + if (OCR_read_regions < 0) { + pkt[0] = 0; + } else { + *reasonp = OCR_ST_READING; + pkt[0] = 1; + } + } + break; + + case 'A': + if (OCR_fd > 0) ioctl(OCR_fd, OCR_ABORT); + exit(1); + + default: + return 0; + } + if (write(OCR_sv, pkt, PKTLEN) < 0) + return 0; + else + return 1; +} + +/* + * Handle postponed time consuming work. + */ + +static void +ocr_do_postponed_work(reason, ppid) +int reason; +pid_t ppid; +{ + u_char pkt[PKTLEN]; + + switch (reason) { + case OCR_ST_SCANNING: + if (ocr_proc_scan(&OCR_scan_para)) { + pkt[0] = 1; + } else { + pkt[0] = 0; + } + write(OCR_sv, pkt, sizeof(pkt)); + notify_ready(ppid); + break; + + case OCR_ST_UPLDING: + { + struct ocr_image_info iminfo; + + if (!ocr_proc_iminfo(&OCR_up_para, &iminfo)) { + pkt[0] = 0; + write(OCR_sv, pkt, sizeof(pkt)); + notify_ready(ppid); + } else { + ocr_proc_img_upload(&iminfo, ppid); + } + } + break; + + case OCR_ST_READING: + if (ocr_proc_read()) { + ocr_proc_post_read(ppid); + } else { + pkt[0] = 0; + write(OCR_sv, pkt, sizeof(pkt)); + notify_ready(ppid); + } + break; + + default: + pkt[0] = 0; + write(OCR_sv, pkt, sizeof(pkt)); + notify_ready(ppid); + break; + } + return; +} + +/* + * Notify primary emulator process that time consuming work has been done. + */ + +static void +notify_ready(ppid) +pid_t ppid; +{ + kill(ppid, SIGUSR1); +} + +/* + * Put the socket descriptor into blocking mode, and extend + * the buffer size. + */ + +static int +ocr_init_sv() +{ + + int flags; + + if (OCR_sv < 0) return 0; + + flags = fcntl(OCR_sv, F_GETFL, 0); + if (flags < 0) { + perror("ocr_init_sv: fcntl"); + return 0; + } + flags &= ~FNDELAY; + if (fcntl(OCR_sv, F_SETFL, flags) < 0) { + perror("ocr_init_sv: fcntl 2"); + return 0; + } + return 1; +} + +/* + * Make sure the fatal signall initialize the device then exit + */ + +static void +ocr_init_signal() +{ + struct sigvec sv; + + sv.sv_flags = sv.sv_mask = 0; + sv.sv_handler = ocr_proc_exit; + + sigvec(SIGHUP, &sv, NULL); + sigvec(SIGINT, &sv, NULL); + sigvec(SIGQUIT, &sv, NULL); + sigvec(SIGILL, &sv, NULL); + sigvec(SIGTRAP, &sv, NULL); + sigvec(SIGABRT, &sv, NULL); + sigvec(SIGEMT, &sv, NULL); + sigvec(SIGBUS, &sv, NULL); + sigvec(SIGSEGV, &sv, NULL); + sigvec(SIGSYS, &sv, NULL); + sigvec(SIGPIPE, &sv, NULL); + sigvec(SIGTERM, &sv, NULL); + sigvec(SIGLOST, &sv, NULL); + sigvec(SIGUSR1, &sv, NULL); + sigvec(SIGUSR2, &sv, NULL); + return; +} + +/* + * Scan image + */ + +static int +ocr_proc_scan(spp) +struct ocr_scan_para *spp; +{ + struct scan_params sp; + + switch (spp->size) { + case OCR_SIZE_A4: + sp.size = SIZE_A4; + break; + case OCR_SIZE_B4: + sp.size = SIZE_B4; + break; + case OCR_SIZE_A5: + sp.size = SIZE_A5; + break; + case OCR_SIZE_B5: + sp.size = SIZE_B5; + break; + case OCR_SIZE_LG: + sp.size = SIZE_LG; + break; + case OCR_SIZE_LT: + sp.size = SIZE_LT; + break; + default: + return 0; + } + switch (spp->direction) { + case OCR_DIRECT_VT: + sp.direction = DIRECT_VT; + break; + case OCR_DIRECT_HR: + sp.direction = DIRECT_HR; + break; + default: + return 0; + } + switch (spp->resolution) { + case OCR_RES_200: + sp.resolution = RES_200; + break; + case OCR_RES_240: + sp.resolution = RES_240; + break; + case OCR_RES_300: + sp.resolution = RES_300; + break; + case OCR_RES_400: + sp.resolution = RES_400; + break; + default: + return 0; + } + if (spp->adf) { + sp.scanner = SCANNER_AD; + } else { + sp.scanner = SCANNER_FL; + } + if (spp->binary) { + sp.dencity = DENC_AT; + switch (spp->filter) { + case OCR_FILTER_NR: + sp.filter = FILTER_NR; + break; + case OCR_FILTER_BP: + sp.filter = FILTER_BP; + break; + default: + return 0; + } + switch (spp->threshold) { + case OCR_THRES_0: + sp.threshold = THRES_0; + break; + case OCR_THRES_1: + sp.threshold = THRES_1; + break; + case OCR_THRES_2: + sp.threshold = THRES_2; + break; + case OCR_THRES_3: + sp.threshold = THRES_3; + break; + case OCR_THRES_4: + sp.threshold = THRES_4; + break; + case OCR_THRES_5: + sp.threshold = THRES_5; + break; + default: + return 0; + } + switch (spp->noise) { + case OCR_NOISE_0: + sp.noise = NOISE_0; + break; + case OCR_NOISE_2: + sp.noise = NOISE_2; + break; + case OCR_NOISE_3: + sp.noise = NOISE_3; + break; + case OCR_NOISE_4: + sp.noise = NOISE_4; + break; + case OCR_NOISE_5: + sp.noise = NOISE_5; + break; + default: + return 0; + } + switch (spp->doc) { + case OCR_DOC_NR: + sp.doc = DOC_NR; + break; + case OCR_DOC_NW: + sp.doc = DOC_NW; + break; + default: + return 0; + } + switch (spp->smooth) { + case OCR_SMTH_CH: + sp.smooth = SMTH_CH; + break; + case OCR_SMTH_IM: + sp.smooth = SMTH_IM; + break; + default: + return 0; + } + switch (spp->compo) { + case OCR_COMPO_LD: + sp.compo = COMPO_LD; + break; + case OCR_COMPO_PN: + sp.compo = COMPO_PN; + break; + case OCR_COMPO_PH: + sp.compo = COMPO_PH; + break; + case OCR_COMPO_PL: + sp.compo = COMPO_PL; + break; + default: + return 0; + } + } else { + switch (spp->dencity) { + case OCR_DENC_0: + sp.dencity = DENC_0; + break; + case OCR_DENC_1: + sp.dencity = DENC_1; + break; + case OCR_DENC_2: + sp.dencity = DENC_2; + break; + case OCR_DENC_3: + sp.dencity = DENC_3; + break; + case OCR_DENC_4: + sp.dencity = DENC_4; + break; + case OCR_DENC_5: + sp.dencity = DENC_5; + break; + case OCR_DENC_6: + sp.dencity = DENC_6; + break; + case OCR_DENC_7: + sp.dencity = DENC_7; + break; + default: + return 0; + } + sp.filter = FILTER_NR; + sp.threshold = THRES_0; + sp.noise = NOISE_0; + sp.doc = DOC_NR; + sp.smooth = SMTH_CH; + sp.compo = COMPO_LD; + } + if (ioctl(OCR_fd, OCR_SCAN, &sp) < 0) { + /* + * We could return detailed info about error + * by examining the state field in sp. + */ + return 0; + } else { + return 1; + } +} + +/* + * Kick start the image uploading and place the information about the + * image being uploaded into the ocr_image_infor structure. + */ + +static int +ocr_proc_iminfo(upp, infop) +struct ocr_up_para *upp; +struct ocr_image_info *infop; +{ + struct img_params upara; + struct ocr_stat st; + + switch (upp->resolution) { + case OCR_RES_200: + upara.resolution = RES_200; + break; + case OCR_RES_240: + upara.resolution = RES_240; + break; + case OCR_RES_300: + upara.resolution = RES_300; + break; + case OCR_RES_400: + upara.resolution = RES_400; + break; + default: + return 0; + } + switch (upp->compress) { + case OCR_COMP_NONE: + upara.compress = COMP_NONE; + break; + case OCR_COMP_2: + upara.compress = COMP_2; + break; + case OCR_COMP_4: + upara.compress = COMP_4; + break; + case OCR_COMP_8: + upara.compress = COMP_8; + break; + default: + return 0; + } + upara.region.xs = upp->xs; + upara.region.ys = upp->ys; + upara.region.xe = upp->xe; + upara.region.ye = upp->ye; + + + if (ioctl(OCR_fd, OCR_IMG_UPLOAD, &upara) < 0) return 0; + { + int i; + i = ioctl(OCR_fd, OCR_STAT, &st); + if (i < 0) { + return 0; + } else if (st.state != STATE_UPLDING) { + return 0; + } + } +/* if (!ioctl(OCR_fd, OCR_STAT, &st) || st.state != STATE_UPLDING) return 0; */ + + switch (st.data.image.resolution) { + case RES_200: + infop->resolution = OCR_RES_200; + break; + case RES_240: + infop->resolution = OCR_RES_240; + break; + case RES_300: + infop->resolution = OCR_RES_300; + break; + case RES_400: + infop->resolution = OCR_RES_400; + break; + default: + return 0; + } + switch (st.data.image.compress) { + case COMP_NONE: + infop->compress = OCR_COMP_NONE; + break; + case COMP_2: + infop->compress = OCR_COMP_2; + break; + case COMP_4: + infop->compress = OCR_COMP_4; + break; + case COMP_8: + infop->compress = OCR_COMP_8; + break; + default: + return 0; + } + infop->line_width = (u_int)st.data.image.line_width; + infop->size = (u_int)st.data.image.size; + infop->xs = st.data.image.region.xs; + infop->ys = st.data.image.region.ys; + infop->xe = st.data.image.region.xe; + infop->ye = st.data.image.region.ye; + + OCR_image_size = (int)st.data.image.size; + + return 1; + +} + +/* + * Set Read Parameters + */ + +static int +ocr_proc_set_rpara(rpp, len) +register struct ocr_read_para *rpp; +int len; +{ + register int cnt = len; + struct read_params rpara; + + if (OCR_fd < 0) { + return 0; + } else { + for (; cnt > 0; cnt--, rpp++) { + switch (rpp->format) { + case OCR_FMT_H1: + rpara.format = FMT_H1; + break; + case OCR_FMT_H2: + rpara.format = FMT_H2; + break; + case OCR_FMT_H3: + rpara.format = FMT_H3; + break; + case OCR_FMT_H4: + rpara.format = FMT_H4; + break; + case OCR_FMT_V1: + rpara.format = FMT_V1; + break; + case OCR_FMT_V2: + rpara.format = FMT_V2; + break; + case OCR_FMT_V3: + rpara.format = FMT_V3; + break; + case OCR_FMT_V4: + rpara.format = FMT_V4; + break; + default: + return 0; + } + rpara.cunit = CUNIT_PO; + rpara.csize = CSIZE_DFLT; + rpara.ckind = 0; + rpara.ckind |= (rpp->ck_num) ? CK_NUM : 0; + rpara.ckind |= (rpp->ck_alph) ? CK_ALPH : 0; + rpara.ckind |= (rpp->ck_grk) ? CK_GRK : 0; + rpara.ckind |= (rpp->ck_jvt) ? CK_JVT : 0; + rpara.ckind |= (rpp->ck_jhr) ? CK_JHR : 0; + rpara.ckind |= (rpp->ck_sym) ? CK_SYM : 0; + rpara.ckind |= (rpp->ck_kana) ? CK_KANA : 0; + rpara.ckind |= (rpp->ck_joyou) ? CK_JOYOU : 0; + rpara.ckind |= (rpp->ck_jis1) ? CK_JIS1 : 0; + rpara.ckind |= (rpp->ck_jmisc) ? CK_JMISC : 0; + rpara.ckind |= (rpp->ck_gaiji) ? CK_GAIJI : 0; + switch (rpp->deform) { + case OCR_DFRM_1: + rpara.cprop |= DFRM_1; + break; + case OCR_DFRM_2: + rpara.cprop |= DFRM_2; + break; + case OCR_DFRM_3: + rpara.cprop |= DFRM_3; + break; + case OCR_DFRM_4: + rpara.cprop |= DFRM_4; + break; + case OCR_DFRM_NR: + rpara.cprop |= DFRM_NR; + break; + case OCR_DFRM_6: + rpara.cprop |= DFRM_6; + break; + case OCR_DFRM_7: + rpara.cprop |= DFRM_7; + break; + case OCR_DFRM_8: + rpara.cprop |= DFRM_8; + break; + case OCR_DFRM_9: + rpara.cprop |= DFRM_9; + break; + defaul: + return 0; + } + if (OCR_REJ_0 <= rpp->reject && + rpp->reject <= OCR_REJ_5) { + rpara.cprop |= rpp->reject; + } else { + return 0; + } + rpara.region.xs = rpp->xs; + rpara.region.ys = rpp->ys; + rpara.region.xe = rpp->xe; + rpara.region.ye = rpp->ye; + + if (ioctl(OCR_fd, OCR_READ_PARA, &rpara) < 0) { + return 0; + } + } + OCR_read_regions += len; + return 1; + } +} + +/* + * Clear Read Parameters + */ + +static int +ocr_proc_clr_rpara() +{ + if (OCR_fd < 0 || ioctl(OCR_fd, OCR_READ_CLR) < 0) { + return 0; + } else { + return 1; + } +} + +/* + * Read + */ + +static int +ocr_proc_read() +{ + if (OCR_fd < 0 || ioctl(OCR_fd, OCR_READ) < 0) { + return 0; + } else { + return 1; + } +} + +/* + * Upload and transfer image data. Data transfer is done in such way that is + * compatible with ocr_bulk_read in 'ocr.c'. + */ + +static void +ocr_proc_img_upload(iminfop, ppid) +struct ocr_image_info *iminfop; +pid_t ppid; +{ + register int len, resid, firsttime = 1; + int cnt; + char rbuf[65536], pkt[PKTLEN]; + register char *ptr; + struct bd_header hd; + + resid = OCR_image_size; + + while (resid > 0) { + len = MIN(resid, sizeof(rbuf)); + cnt = read(OCR_fd, rbuf, len); + if (cnt < 0) { + pkt[0] = 0; + write(OCR_sv, pkt, sizeof(pkt)); + return; + } + resid -= cnt; + hd.len = (u_int)cnt; + hd.cont = (resid > 0) ? BD_CONT : BD_LAST; + if (firsttime) { + pkt[0] = 1; + write(OCR_sv, pkt, sizeof(pkt)); + write(OCR_sv, (char *)iminfop, + sizeof(struct ocr_image_info)); + write(OCR_sv, &hd, sizeof(struct bd_header)); + notify_ready(ppid); + firsttime = 0; + } else { + write(OCR_sv, &hd, sizeof(struct bd_header)); + } + for (ptr = rbuf; cnt > 0; cnt -= len, ptr += len) { + len = write(OCR_sv, ptr, cnt); + } + } + return; +} + +/* + * Get the read result from the device driver. The format of the data + * is converted to make it easy Lisp to use it. After converting the data, + * transfer data. Data transfer is done in such way that is + * compatible with ocr_bulk_read in 'ocr.c'. + */ + +static void +ocr_proc_post_read(ppid) +pid_t ppid; +{ + static u_char rbuf[65536]; + static u_char fbuf[65536]; + register u_char *ptr; + struct ocr_stat st; + register int cnt, len; + int amt, firsttime = 1; + struct bd_header hd; + + if (OCR_fd < 0) goto fail; + + if (ioctl(OCR_fd, OCR_STAT, &st) < 0 || + st.state != STATE_RDING) goto fail; + + while (st.state == STATE_RDING) { + if (sizeof(rbuf) - 2048 > st.data.rd_resid) { + /* + * 2048 is a margin to reformat the data. + */ + amt = len = st.data.rd_resid; + } else { + amt = len = sizeof(rbuf) - 2048; + } + ptr = rbuf; + do { + cnt = read(OCR_fd, ptr, len); + if (cnt < 0) { + goto fail; + } else { + len -= cnt; + ptr += cnt; + } + } while (len > 0); + + if (ioctl(OCR_fd, OCR_STAT, &st) < 0) goto fail; + + len = ocr_conv_read_data(rbuf, fbuf, amt); + if (len < 0) { + goto fail; + } else if (firsttime) { + u_char pkt[PKTLEN]; + + pkt[0] = 1; + write(OCR_sv, pkt, sizeof(pkt)); + notify_ready(ppid); + firsttime = 0; + } + + hd.len = (u_int)len; + hd.cont = (st.state == STATE_RDING) ? BD_CONT : BD_LAST; + + write(OCR_sv, &hd, sizeof(struct bd_header)); + for (ptr = fbuf; len > 0; len -= cnt, ptr += cnt) { + cnt = write(OCR_sv, ptr, len); + } + } + return; + + fail: + { + u_char pkt[PKTLEN]; + pkt[0] = 0; + write(OCR_sv, pkt, sizeof(pkt)); + notify_ready(ppid); + return; + } +} + +/* + * Reformat the read data to make a life of Lisp tremendously easy + */ + +static int +ocr_conv_read_data(sp, dp, len) +register u_char *sp, *dp; +register int len; +{ + bcopy(sp, dp, len); + return(len); +} + +/**************************************************** + **************************************************** + +#define INC_SP(pos) {\ + if (--len == 0) {\ + statep->jmp = (pos);\ + return(amt);\ + } else {\ + sp++;\ + }\ +} + +#define CONV_CODE_BLOCK { + static int pos, hi, lo; + + pos = 0; + + if (*sp == 0xEB) { + INC_SP(POS16); + pos16: + if (*sp == 0xA0) { + + if (*sp == 0x9F) { + /+ Lower certencity +/ + *dp++ = REJECT; + INC_SP(POS17); + pos17: + pos += 2; + hi = *sp; + INC_SP + + + +static int +ocr_conv_read_data(sp, dp, len, statep) +register u_char *sp, *dp; +register int len; +struct parse_state *statep; +{ + /+ + * for now... + +/ + + bcopy(sp, dp, len); + return(len); + + switch (statep->jmp) { + case POS1: goto pos1; + } + + amt = 0; + while (1) { + if (*sp == '0') { + INC_SP(POS1); + pos1: + if (*sp == '0') { + /+ Region start +/ + *dp++ = REG_START_CODE; + /+ Skip region number +/ + INC_SP(POS2); + pos2: + INC_SP(POS3); + pos3: + INC_SP(POS4); + pos4: + if (*sp == 0xFC) { + INC_SP(POS5); + pos5: + if (*sp == 0xFA) { + /+ Blank region +/ + *dp++ = REG_END_CODE; + continue; + } + } + /+ Skip a region header +/ + INC_SP(POS6); + pos6: + INC_SP(POS7); + pos7: + INC_SP(POS8); + pos8: + INC_SP(POS9); + pos9: + INC_SP(POS10); + pos10: + INC_SP(POS11); + pos11: + INC_SP(POS12); + pos12: + while (1) { + if (*sp == 0xFC) { + INC_SP(POS13); + pos13: + if (*sp == 0xFA) { + /+ Region end +/ + *dp++ = REG_END_CODE; + break; + } + } + /+ Skip a line number +/ + INC_SP(POS14); + pos14: + /+ Process a line +/ + while (1) { + if (*sp == 0xFC) { + INC_SP(POS15); + pos15: + if (*sp == 0xFB) { + /+ EOL +/ + break; + } + } + /+ Some code exists +/ + CONV_CODE_BLOCK; + } + if (statep.cr_line) *dp++ = EOL_CODE; + } + } + } + /+ Page end +/ + return(1) + } +} + + + if (*sp == '0' && *(sp + 1) == '0') { + /+ Region start +/ + *dp++ = REG_START_CODE; + /+ Skip region number +/ + sp += 4; + if (*sp == 0xFC && *(sp + 1) == 0xFA) { + /+ Blank region +/ + *dp++ = REG_END_CODE; + continue; + } else { + /+ Skip a region header +/ + sp += 8; + } + while (1) { + if (*sp == 0xFC && *(sp + 1) == 0xFA) { + /+ Region end +/ + *dp++ = REG_END_CODE; + break; + } else { + /+ Skip a line number +/ + sp += 2; + /+ Process one line +/ + while (*sp != 0xFC || *(sp + 1) != 0xFB) { + /+ Some codes exists +/ + CONV_CODE_BLOCK(sp, bp); + } + if (statep.cr_line) *dp++ = EOL_CODE; + } + } + } else { + /+ Page end +/ + } + } +} +********************************************* +*********************************************/ + +#endif /* OCR */ + diff --git a/src/ocrproc.c.X b/src/ocrproc.c.X new file mode 100644 index 0000000..e69de29 diff --git a/src/oether.c b/src/oether.c new file mode 100755 index 0000000..975680d --- /dev/null +++ b/src/oether.c @@ -0,0 +1,1015 @@ +/* $Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include +#ifndef DOS +#include +#include +#include +#include +#include +#ifndef NOETHER +#include +#include +#include +#include +#include +#include + +#include +#ifdef OS4 +#include +#include +#include +/* #include */ +#include +#endif /* OS4 */ + +#include +#include +#endif /* DOS */ +#endif /* NOETHER */ + +#include "lispemul.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "adr68k.h" +#include "ether.h" +#include "dbprint.h" + +u_int EtherReadFds; + +int ether_fd = -1; /* file descriptor for ether socket */ +u_char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address of this node */ +u_char broadcast[6] = {255, 255, 255, 255, 255, 255}; +int ether_bsize = 0; /* if nonzero then a receive is pending */ +u_char *ether_buf; /* address of receive buffer */ +u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) */ +extern LispPTR *PENDINGINTERRUPT68k; +extern u_int LispReadFds; + +int ETHEREventCount = 0; + +#define PacketTypeIP 0x0800 +#define PacketTypeARP 0x0806 +#define PacketTypeRARP 0x8035 +#define PacketTypeXNS 0x0600 +#define PacketTypePUP 0x0200 +#define PacketType3TO10 0x0201 + +#ifndef NOETHER +#ifdef OS4 +/* the receiving packetfilter structure */ +/* if this is changed, be sure to get the references to it in init_ether + and check the length (the second entry in the structure) */ +struct packetfilt goodpf = {0, 29,{ +ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeIP, /* punt if PacketTypeIP */ +ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeARP, /* or PacketTypeARP */ +ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 8, /* check our addr */ +ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 11, /* which is filled in */ +ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 14, /* in init_ether */ +ENF_AND, ENF_AND, +ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* check broadcast */ +ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* which is all ones */ +ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 0xFFFF, +ENF_AND, ENF_AND, +ENF_OR}}; + +/* a filter that rejects all packets to be used by ether_suspend and the + initial routine to flush out ether_fd */ +struct packetfilt nopf = {0, 1, {ENF_PUSHZERO}}; + +#endif /* OS4 */ + +int ether_in = 0; /* number of packets received */ +int ether_out = 0; /* number of packets sent */ +#ifndef OS4 +static struct nit_ioc nioc; +#endif /* OS4 */ + +#endif /* NOETHER */ + + + + +/************************************************************************/ +/* */ +/* e t h e r _ s u s p e n d */ +/* */ +/* Suspend receiving packets from the NIT socket. */ +/* 175/70/0 */ +/* */ +/************************************************************************/ + +ether_suspend(args) + LispPTR args[]; + { +#ifndef NOETHER +#ifdef OS4 + static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; +#endif /* OS4 */ + + if (ether_fd == -1) return(NIL); +#ifndef OS4 + nioc.nioc_typetomatch = NT_NOTYPES; + if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) + { + printf("ether_suspend: ioctl failed\n"); +#else /* OS4 */ + + /* The trick here is to install a packet filter */ + /* that rejects all packets, I think... */ + if ( ioctl(ether_fd, NIOCSETF, &nopf) != 0) + { + perror("ether_suspend: NIOCSETF failed\n"); +#endif /* OS4 */ + + return(NIL); + } +#endif /* NOETHER */ + + return(ATOM_T); + } /* ether_suspend */ + + + + +/************************************************************************/ +/* */ +/* e t h e r _ r e s u m e */ +/* */ +/* resume nit socket to receive all types of packets 175/71/0 */ +/* */ +/************************************************************************/ + +ether_resume(args) + LispPTR args[]; + { + if (ether_fd == -1) return(NIL); +#ifndef NOETHER +#ifndef OS4 + nioc.nioc_typetomatch = NT_ALLTYPES; + if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) + { + printf("ether_resume: ioctl failed\n"); +#else /* OS4 */ + +/* Install a packet filter that accepts all packets we want */ + if ( ioctl(ether_fd, NIOCSETF, &goodpf) != 0) + { + perror("ether_resume: NIOCSETF failed\n"); +#endif /* OS4 */ + + return(NIL); + } +#endif /* NOETHER */ + + return(ATOM_T); + } /* ether_resume */ + + + +/************************************************************************/ +/* */ +/* e t h e r _ c t r l r */ +/* */ +/* return T if ether controller is available 175/72/0 */ +/* */ +/************************************************************************/ + +ether_ctrlr(args) + LispPTR args[]; + { + if (ether_fd < 0) return(NIL); + return(ATOM_T); + } + + + +/********************************************************************** + * ether_reset(args) 175/73/0 + * reset ether controller and disable receipt of packets + **********************************************************************/ +ether_reset(args) + LispPTR args[]; + { + int i; + char hostnumber[6]; + + if (ether_fd < 0) {return(NIL);} + /* JRB - host number check removed here; if ether_fd is open here, + net is on... */ + ether_bsize = 0; /* deactivate receiver */ + return(ATOM_T); + } /* ether_reset */ + + + +/************************************************************************/ +/* */ +/* e t h e r _ g e t (175/74/2) */ +/* */ +/* Set up the Ethernet driver to receive a packet. The driver */ +/* first tries to read any pending packet from the net, and if */ +/* there is one, ether_get returns T. If there is no pending */ +/* packet, the failing read sets us up to get an interrupt when */ +/* a packet DOES arrive, and ether_get returns NIL. */ +/* */ +/* args[0] Length of the buffer we're passed */ +/* args[1] LISP address of a packet buffer */ +/* */ +/* sets ether_buf to the buffer address, for check_ether's use */ +/* sets ether_bsize to the buffer size. ether_bsize>0 means */ +/* it's OK to read packets from the network on interrupt. */ +/* */ +/************************************************************************/ + +ether_get(args) + LispPTR args[]; + { + LispPTR MaxByteCount; + LispPTR result = NIL; + int interrupt_mask; + +#ifndef NOETHER + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + + DBPRINT(("Ether Get. ")); + + interrupt_mask = sigblock(sigmask(SIGIO)); /* turn off ENET interrupts */ + if (ether_fd >= 0 && (MaxByteCount > 0)) + { + ether_buf = (u_char *)Addr68k_from_LADDR(args[1]); + ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ + result = get_packet(); +/* check_ether(); for old behavior, move comment to above line */ + } + sigsetmask(interrupt_mask); /* interrupts back on */ +#endif /* NOETHER */ + + + return (result); + } /* ether_get */ + + + +/********************************************************************** + * ether_send(args) 175/75/2 max_words,buffer_addr + * send a packet + **********************************************************************/ +#define OFFSET sizeof(sa.sa_data) + +ether_send(args) +LispPTR args[]; +{ +#ifndef NOETHER + /* + * Send a packet. + */ + struct sockaddr sa; + + LispPTR MaxByteCount; + char *BufferAddr; /* buffer address pointer(in native address) */ + + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + BufferAddr = (char *)Addr68k_from_LADDR(args[1]); + + if (ether_fd >= 0) { +#ifdef OS4 + struct strbuf ctl,data; + +#endif /* OS4 */ + + sa.sa_family = AF_UNSPEC; /* required for the NIT protocol */ + bcopy(BufferAddr, sa.sa_data, OFFSET); +#ifndef OS4 + if ( sendto(ether_fd, BufferAddr+OFFSET, MaxByteCount-OFFSET, 0, + &sa, sizeof(sa)) == (MaxByteCount-OFFSET) ); + else perror("Lisp Ether: sendto"); + ether_out++; +#else /* OS4 */ + + ctl.maxlen = ctl.len = sizeof(sa); + ctl.buf = (char *)&sa; + data.maxlen = data.len = MaxByteCount - OFFSET; + data.buf = BufferAddr + OFFSET; + if(putmsg(ether_fd, &ctl, &data, 0)<0) { + perror("Ether_send lost"); + return(NIL); + } + else { + ether_out++; + /* flush the buffers to make sure the packet leaves */ + /* maybe we'll use the buffering module some day... */ + ioctl(ether_fd, I_FLUSH, FLUSHW); + } +#endif /* OS4 */ + + } +#endif /* NOETHER */ + + + return(ATOM_T); +} /* ether_send */ + + + + +/********************************************************************** + * ether_setfilter(args) 175/75/1 filterbits + * check whether a packet has come. if does, notify iocb + **********************************************************************/ + +ether_setfilter(args) + LispPTR args[]; + { + return(NIL); + } /* ether_setfilter */ + + + + +/********************************************************************** + * ether_debug() + * returns the ethernet statistics. + **********************************************************************/ + +int estat[3]; + +int *ether_debug() + { +#ifndef NOETHER + estat[0] = 0; + if (ether_fd < 0) return(NIL); + printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", + ether_fd, ether_bsize, (int)ether_buf, + IOPage->dlethernet[3],ether_in,ether_out); +#endif /* NOETHER */ + + return(estat); + } /* end ether_debug */ + +#ifndef NOETHER +static struct timeval EtherTimeout = { + 0, 0 +}; +#endif /* NOETHER */ + + +/********************************************************************** + * check_ether() + * checks an incoming packet + **********************************************************************/ + +#ifndef OS4 +static int nitpos=0, nitlen=0; /* for NIT read buffer in OS3 */ +#endif + +check_ether() + { + /* + * If receiver active then check if any packets are + * available from the ethernet. If so, read the packet + * and signal the icb and return T. + */ + +#ifndef NOETHER +#ifndef OS4 + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* OS4 */ + + static int rfds; + int result; + int i; + u_long plen; + struct strbuf ctl, data; + char ctlbuf[2000]; +#endif /* OS4 */ + + + rfds = EtherReadFds; +#ifndef OS4 + i = 2; + if(/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) + { + if( (ether_fd >= 0) && (ether_bsize > 0) ) + { + while ( (select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) + && (i-- > 0) ) + { + if (nitpos>=nitlen) + { /* Used up last NIT buffer full; read another. */ + nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); + nitpos = 0; + } + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) + { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) + { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) + { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); + nitpos += fromlen; + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End=0; + *PENDINGINTERRUPT68k = ATOM_T; + /* return(NIL); */ + return(ATOM_T); + } + nitpos += fromlen; + break; + + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; + } + } + } + } + } +#else /* OS4 */ + + if(ether_fd >= 0 && ether_bsize > 0 +/* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 + * -- [on '90/02/14: getsignsldata() chech this] */ + && (rfds & (1 << ether_fd))) + { + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if(result >= 0 ) + { + if(data.len <= ether_bsize + && data.len > 0) + { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End=0; + *PENDINGINTERRUPT68k = ATOM_T; + return(NIL); /* return(ATOM_T); */ + } + } + else if (errno != EWOULDBLOCK) + { + perror("Check_ether read error:\n"); + } + } +#endif /* OS4 */ + +#endif /* NOETHER */ + + + return(NIL); + } /* end check_ether */ + + +/************************************************************************/ +/* */ +/* g e t _ p a c k e t */ +/* */ +/* Try getting a packet, ala check_ether, returning NIL if none, */ +/* T if one was received. This is used by ether_get only. */ +/* */ +/************************************************************************/ + +get_packet() + { +#ifndef NOETHER +#ifndef OS4 + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* OS4 */ + + static int rfds; + int result; + int i; + u_long plen; + struct strbuf ctl, data; + char ctlbuf[2000]; +#endif /* OS4 */ + + +#ifndef OS4 + while (1) + { + if (nitpos>=nitlen) + { /* Used up last NIT buffer full; read another. */ + nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); + if (nitlen < 0) return(NIL); /* No more packets to try. */ + nitpos = 0; + } + + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) + { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) + { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) + { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", + fromlen, nitpos, nitlen)); + nitpos += fromlen; + return(ATOM_T); + } + nitpos += fromlen; + break; + + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; + } + } + } + +#else /* OS4 */ + + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if(result >= 0 ) + { + if(data.len <= ether_bsize && data.len > 0) + { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + return(ATOM_T); + } + } + else if (errno != EWOULDBLOCK) perror("Check_ether read error:\n"); +#endif /* OS4 */ + +#endif /* NOETHER */ + + + return(NIL); + } /* end get_packet */ + + + + + +/********************************************************************** + * check_filter(buffer) + * see if this packet passes the current filter setting + * This is believed obsolete with packet filtering enabled + **********************************************************************/ + +check_filter(buffer) + u_char* buffer; + { + /* broadcast packets */ + if (ether_addr_equal(buffer, broadcast)) + switch(((short*)buffer)[6]) + { + case PacketTypeIP: return(0); + case PacketTypeARP: return(0); + default: return(1); + }; + /* my address */ + if (ether_addr_equal(buffer, ether_host)) + switch(((short*)buffer)[6]) + { + case PacketTypeIP: return(0); + case PacketTypeARP: return(0); + default: return(1); + }; + return(0); + } + + + +/********************************************************************** + * ether_addr_equal(add1, add2) + * checks ethernet addresses equality + * Also believed obsolete + **********************************************************************/ + +ether_addr_equal(add1, add2) + +u_char add1[], add2[]; + { + register int i; + for(i=0; i<6; i++) if (add1[i] != add2[i]) return(0); + return(1); + } + + + +/********************************************************************** + * init_uid() + * sets effective user-id to real user-id + **********************************************************************/ +init_uid() + { +#ifndef NOETHER + int rid; + rid = getuid(); + seteuid(rid); +#endif /* NOETHER */ + } + + + +/************************************************************************/ +/* i n i t _ i f p a g e _ e t h e r */ +/* */ +/* sets Lisp's idea of \my.nsaddress. Clears it if ether not */ +/* enabled */ +/* */ +/************************************************************************/ + +init_ifpage_ether() + { + InterfacePage->nshost0 = (DLword)((ether_host[0] << 8) + ether_host[1]); + InterfacePage->nshost1 = (DLword)((ether_host[2] << 8) + ether_host[3]); + InterfacePage->nshost2 = (DLword)((ether_host[4] << 8) + ether_host[5]); + } + + +#ifndef NOETHER + /* this needs to be a global so the name can be set by main() in Ctest */ + /* But NOETHER doesn't support NIT, so dyke it out for NOETHER */ +struct sockaddr_nit snit; +#endif /* NOETHER */ + + + + + +/************************************************************************/ +/* i n i t _ e t h e r */ +/* */ +/* open nit socket, called from main before starting BCE. */ +/* */ +/************************************************************************/ +init_ether() + { + +#ifndef NOETHER + + /* JRB - This code will have to be a bit different for SUN 4.0; the probable differences are in commented-out code below + (not ifdefed because they're untested...) + */ + int flags; + + /* ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 0; + ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->handledmask = 0; +*/ + if (ether_fd < 0) + { + /* it's not open yet, try and open it; + if it's already open here, it was opened by ldeether and + all the appropriate stuff was done to it there. + */ +#ifndef OS4 + if (getuid() != geteuid()) + { + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) + { + /* 4.0: socket -> open("/dev/nit", O_BOTH) */ + /* it's open, now query it and find out its name and address */ + /* JRB - must document that Maiko uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option to + specify which net board (suspect more than one net board on a + Maiko machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + /* 4.0 - before the SIOCGIFCONF, do: + bzero(ifbuf, sizeof(ifbuf)) + */ + if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) + { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ + + if (getuid() != geteuid()) + { + if ((ether_fd = open("/dev/nit", O_RDWR|FASYNC)) >= 0) + { + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option + to specify which net board (suspect more than one net + board on an LDE machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pf") < 0) + { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + perror("No socket for interface name"); + close(s); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; +#ifndef OS4 + return(NIL); +#else /* OS4 */ + + goto I_Give_Up; +#endif /* OS4 */ + + } +#ifndef OS4 + /* got its name, copy it into snit */ + strcpy(snit.snit_ifname, if_data.ifc_req[0].ifr_name); + /* 4.0, before the SIOCGIFADDR, do: + ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) + */ + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) + { + perror("Couldn't GIFADDR socket: Net is off"); +#else /* OS4 */ + + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) + { + perror("Couldn't get interface name from socket"); + close(s); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; +#ifndef OS4 + return(NIL); +#else /* OS4 */ + + goto I_Give_Up; +#endif /* OS4 */ + + } +#ifndef OS4 + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + init_uid(); + } +#else /* OS4 */ + + (void) close(s); +#endif /* OS4 */ + + } +#ifdef OS4 + if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) + { + perror("Couldn't NIOCBIND socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) + { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + DBPRINT(("init_ether: **** Ethernet starts ****\n")); + } + else + { +I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + exit(); + } + seteuid(getuid()); + } + +#endif /* OS4 */ + +} +if (ether_fd >= 0) { +#ifndef OS4 + /* bind the socket to an interface */ + snit.snit_family = AF_NIT; + bind(ether_fd, &snit, sizeof(snit)); +#else /* OS4 */ + +/* I think all you really have to do here is set the SNAP length, flags, + and configure the buffering module */ + unsigned long snaplen = 0; + struct timeval zerotime; +#endif /* OS4 */ + + +#ifndef OS4 + /* establish the operating modes */ + bzero(&nioc, sizeof(nioc)); + nioc.nioc_bufspace = 20000; + nioc.nioc_chunksize = 50; /* small chunks so each packet read */ + nioc.nioc_typetomatch = NT_ALLTYPES; + nioc.nioc_snaplen = 32767; + nioc.nioc_flags = 0; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("init_ether: ioctl failed\n"); +#else /* OS4 */ + + EtherReadFds |= (1 << ether_fd); + +/* first and foremost, flush out ether_fd's buffers and filter it */ +/* install packetfilter that rejects everything */ + if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { + perror("init_ether: nopf NIOCSETF failed:\n"); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#ifndef OS4 + EtherReadFds |= (1 << ether_fd); + if (fcntl(ether_fd, F_SETFL, + fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY)<0) + perror("Ether setup SETFLAGS fcntl"); + if( fcntl(ether_fd, F_SETOWN, getpid()) < 0) + perror("Ether setup SETOWN"); +#else /* OS4 */ + +/* then throw away everything that's currently buffered there; + this descriptor may have been open since ldeether ran, with + no filtering; a busy net will have stuffed it full */ + {int rfds = EtherReadFds; + while(select(32, &rfds, NULL, NULL, &EtherTimeout) > 0) + read(ether_fd, nit_buf, sizeof(nit_buf)); + } + + +/* put the address into the packetfilter structure */ +/* DANGER! Vulnerable to byte ordering! DANGER! */ + goodpf.Pf_Filter[8]= *((short *)ðer_host[0]); + goodpf.Pf_Filter[11]= *((short *)ðer_host[2]); + goodpf.Pf_Filter[14]= *((short *)ðer_host[4]); +/* and set up the packetfilter */ + if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { + perror("init_ether: NIOCSETF failed:\n"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } +/* clobber the flags */ + if(ioctl(ether_fd, NIOCSFLAGS, &snaplen) != 0) + { + perror("init_ether: NIOCSFLAGS failed:\n"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } + DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); + if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) + { + perror("init_ether: I_SETSIG failed:\n"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#endif /* OS4 */ + + if (EtherReadFds == 0) + error("EtherReadFds is zero, but enet opened??"); + LispReadFds |= EtherReadFds; + + DBPRINT(("init_ether: **** Ethernet starts ****\n")); + } +#endif /* NOETHER */ + + } + + + + +#define MASKWORD1 0xffff + + +/************************************************************************/ +/* */ +/* c h e c k _ s u m */ +/* */ +/* Implements the CHECKSUM opcode; compute the checksum for an */ +/* ethernet packet. */ +/* */ +/* args[0] LispPTR base; */ +/* args[1] LispPTR nwords; */ +/* args[2] LispPTR initsum; */ +/* */ +/* */ +/************************************************************************/ + +check_sum(args) + register LispPTR *args; + { + register LispPTR checksum; + register DLword *address; + register int nwords; + + address=(DLword*)Addr68k_from_LADDR(*args++); + nwords = *args ++; + + if( *args != NIL) checksum = (*args) & MASKWORD1; + else checksum = 0; + + for(;nwords > (S_POSITIVE); address++,nwords--) + { + checksum= checksum + GETWORD(address); + if(checksum > 0xffff) + checksum = (checksum & 0xffff) +1; /* add carry */ + + if(checksum >0x7fff) /* ROTATE LEFT 1 */ + checksum= ((checksum & 0x7fff)<<1) | 1 ; + else checksum = checksum << 1; + } + + if(checksum == MASKWORD1) return(S_POSITIVE);/* ret 0 */ + else return(S_POSITIVE|checksum); + + } /*check_sum */ diff --git a/src/oldeether.c b/src/oldeether.c new file mode 100755 index 0000000..f9f12e7 --- /dev/null +++ b/src/oldeether.c @@ -0,0 +1,195 @@ +/* $Id: oldeether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: oldeether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Copyright (C) Venue"; + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#ifdef NOETHER +main (argc, argv, argp) int argc; char **argv, **argp; +{ +} +#else + +#include +#include +#include +#include +#include +#ifdef OS4 +#include +#endif /* OS4 */ + +#include +#include +#include +#include +#include +#include +#ifdef OS4 +#include +#include +#include +#endif /* OS4 */ + +#include +#include +#include + +int ether_fd = -1; /* file descriptor for ether socket */ +unsigned char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address */ +char filetorun[30] = "lde"; + +main(argc, argv, envp) int argc; char **argv, **envp; +{ + char Earg[30], Ename[30], **newargv; + int i; + int flags; +/* Kickstart program for the Lisp Development Environment (LDE). + Run this as setuid root to open the LDE ether socket. + Passes all arguments through to LDE plus -E + to communicate open ether socket. + + looks like this: + ::::::: + + where is the number of the open + socket (decimal), and - are hex of the socket's + 48-bit Ethernet address, and is the name of the + Ethernet device as found by SIOCGIFCONF. +*/ + +if (!geteuid()){ +#ifndef OS4 + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { +#else /* OS4 */ + + if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { +#endif /* OS4 */ + + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; + +#ifdef OS4 + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ + + if(ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } +#endif /* OS4 */ + + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; +#ifndef OS4 + if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ + + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + (void) close(s); + } + if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); +#endif /* OS4 */ + + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + strcpy(Ename, if_data.ifc_req[0].ifr_name); + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + + +#ifdef DEBUG + printf("init_ether: **** Ethernet starts ****\n"); +#endif + } else { +I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + /* exit(); */ + } + seteuid(getuid()); + } + +/* OK, right here do other stuff like scan args */ +/* finally crank up LDE; first copy the original args */ + +newargv = (char **) malloc((argc + 1 + (ether_fd > 0)*2) * sizeof (char **)); +newargv[0] = filetorun; /* or whatever... */ +for(i=1; i 0) { + newargv[i++] = "-E"; + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, + ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); + newargv[i++] = Earg; +} +newargv[i] = 0; + +/* then execve the LDE executable */ +execvp(filetorun, newargv); +perror(filetorun); +exit(1); +} + +#endif /* NOETHER */ + diff --git a/src/optck.c b/src/optck.c new file mode 100755 index 0000000..629a9a9 --- /dev/null +++ b/src/optck.c @@ -0,0 +1,57 @@ +/* $Id: optck.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: optck.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright (C) Venue"; +/* optck.c + * + * This example is almost same as one shown in + * SunOS 4.1 Release Manual: 4.2. Known Problems With SunOS Release 4.1 Products. + * + * Compiling this file with -O or -O2 level and executing, if assembler optimizes + * incorrectly, "wrong" message is printed out to stdout. + * + */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +int boothowto = 1; + +int +main(void) +{ + int unit; + + if (boothowto & 1) { + retry: + unit = -1; + while (unit == -1) { + if (unit != -1) { + printf("wrong"); + exit(1); + } + unit = 0; + foo(&unit); + } + } else { + unit = 0; + goto retry; + } +} + +foo(int *unitp) +{ +} + diff --git a/src/osmsg.c b/src/osmsg.c new file mode 100755 index 0000000..560c785 --- /dev/null +++ b/src/osmsg.c @@ -0,0 +1,455 @@ +/* $Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* O S M E S S A G E . C */ +/* */ +/* Functions for handling the redirection of console and stan- */ +/* dard-error output so it appears in the prompt window. */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#ifndef DOS +#include + +#include +#ifdef ISC +#include +#endif /* ISC */ +#include +#include +#ifndef AIX +#include +#endif /* AIX */ +#include +#ifndef AIX +#ifndef APOLLO +#include +#endif /* APOLLO */ +#endif /* AIX */ +#ifndef SYSVONLY +#include +#endif /* SYSVONLY */ +#endif /* DOS */ + + +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "stream.h" +#include "lspglob.h" +#include "timeout.h" +#include "locfile.h" +#include "osmsg.h" +#include "dbprint.h" +#ifdef OS4 +#include +#endif + +#define MESSAGE_BUFFER_SIZE 1024 +int cons_tty; +int cons_pty; + +char logfile[100]; +int log_id; +int previous_size; +int logChanged; /* T if log file has changed since last READ */ + /* Set by flush_pty, to avoid the stat call */ +u_int LogFileFd; +extern u_int LispReadFds; + + + +/************************************************************************/ +/* */ +/* m e s s _ i n i t */ +/* */ +/* Initialize console-message handling. Console & Log msgs */ +/* are redirected to a pty; when messages appear, we get the */ +/* interrupt, and signal a Lisp interrupt to print each msg */ +/* in the prompt window. For historical reasons, the msgs */ +/* are saved on the file tmp/-log. */ +/* */ +/************************************************************************/ + +mess_init() + { +#ifndef XWINDOW +#ifndef DOS + int id; + struct passwd *pwd; + int ttyfd; + int ptyfd, ptynum; + char *ptyname, *ttyname; + int temp, flags; + int on = 1; + + ptyname = "/dev/ptypx"; + ttyname = "/dev/ttypx"; + +/* Get pty and tty */ + ptynum = 0; + +needpty: + while( ptynum<16 ) + { + ptyname[9] = "0123456789abcdef"[ptynum]; + if( (ptyfd=open(ptyname, 2)) >= 0 ) goto gotpty; + ptynum++; + } + return(NIL); +gotpty: + ttyname[9] = ptyname[9]; + if( (ttyfd=open(ttyname, 2)) < 0) + { + ptynum++; + close(ptyfd); + goto needpty; + } + + /* Set tty parameters same as stderr */ + + ioctl( 2, TIOCGETD, &temp); /* Line discipline */ + ioctl(ttyfd, TIOCSETD, &temp); + + ioctl( 2, TIOCGETP, &temp); /* TTY parameters */ + ioctl(ttyfd, TIOCSETP, &temp); + + ioctl( 2, TIOCLGET, &temp); + ioctl(ttyfd, TIOCLSET, &temp); + + ioctl( 2, TIOCGETC, &temp); /* Terminal characters */ + ioctl(ttyfd, TIOCSETC, &temp); + + ioctl( 2, TIOCGLTC, &temp); /* Local special characters */ + ioctl(ttyfd, TIOCSLTC, &temp); + +/* Get console IO */ + ioctl(ptyfd, FIOCLEX, 0); +#ifndef AIX + if( (ioctl(ttyfd, TIOCCONS, 0)) == -1) + { + OSMESSAGE_PRINT( printf("TIOCCONS error\n") ); + exit(-1); + } +#endif /* AIX */ + + cons_pty = ptyfd; + cons_tty = ttyfd; + +/* Initialize log file */ + pwd = getpwuid(getuid()); + sprintf(logfile,"/tmp/%s-lisp.log", pwd->pw_name); + if( unlink(logfile) == -1) + { /* delete old log file */ + if(errno != ENOENT) return(NIL); + } + + if( (log_id = open(logfile, (O_RDWR | O_CREAT), 0666)) < 0 ) + return(NIL); +#ifdef LOGINT + LogFileFd = 1 << cons_pty; + flags = fcntl(cons_pty, F_GETFL, 0); + flags = fcntl(cons_pty, F_SETFL, (flags | FASYNC | FNDELAY)); + if(fcntl(cons_pty, F_SETOWN, getpid()) == -1 ) + { +#ifdef DEBUG + perror("fcntl F_SETOWN of log PTY"); +#endif + }; + LispReadFds |= LogFileFd; + flush_pty(); +#endif + previous_size = 0; + DBPRINT(("Console logging started.\n")); +#endif /* DOS */ +#endif /* XWINDOW */ + + } + + + +/************************************************************************/ +/* */ +/* m e s s _ r e s e t */ +/* */ +/* Undo the redirection of console and standard-error outputs */ +/* presumably preparatory to shutting down lisp. Closes the */ +/* TTY/PTY pair used for logging the messages */ +/* */ +/************************************************************************/ + +mess_reset() + { +#ifndef DOS +#ifndef XWINDOW + int console_fd; + close(log_id); + close(cons_tty); + close(cons_pty); + /* Try to make /dev/console be the real console again */ +/*** This sequence sometimes cause SunOs panic on SunOS4.0(and 4.0.1). + TIOCCONS probelm ??? + if ((console_fd = open("/dev/console", 0)) >= 0) { + ioctl(console_fd, TIOCCONS, 0); + close(console_fd); + } +***/ +#endif /* XWINDOW */ +#endif /* DOS */ + + } + + + +/************************************************************************/ +/* */ +/* m e s s _ r e a d p */ +/* */ +/* Returns T if there are log/console messages waiting */ +/* to be printed. More accurately, if the logChanged flag */ +/* has been set by flush_pty(). */ +/* */ +/************************************************************************/ +#ifndef DOS +static struct timeval selecttimeout = {0, 0}; +#endif +mess_readp() + { +#ifndef DOS +#ifndef XWINDOW + int id; + struct stat sbuf; + int size; + int rval; + struct statfs fsbuf; + + /* polling pty nd flush os message to log file */ + flush_pty(); + +/* * * * * * * * * * * * COMMENTED OUT * * * * * * * * * + SETJMP(NIL); + TIMEOUT( rval=stat(logfile, &sbuf) ); + + if(rval != 0) + { + error("osmessage error: can not find a log file under /tmp"); + return(NIL); + } + if( previous_size < (int)(sbuf.st_size) ) return(ATOM_T); +* * * * * * * * * * * * * */ + + if (logChanged) return(ATOM_T); + return(NIL); +#endif /* XWINDOW */ +#endif /* DOS */ +} + + + +/************************************************************************/ +/* */ +/* m e s s _ r e a d */ +/* */ +/* Read up to 1024 chars of log and console message(s) */ +/* that are waiting to be printed, into a buffer supplied */ +/* by the caller. If all pending message text gets read in */ +/* this call, reset the logChanged flag; Otherwise, leave */ +/* it set, so Lisp knows there is more to read. */ +/* */ +/************************************************************************/ + +mess_read(args) + LispPTR *args; + /* args[0] buffer */ + { +#ifndef DOS +#ifndef XWINDOW + int id; + struct stat sbuf; + int size, save_size; + char *base; + LispPTR *naddress; + int i; + static char temp_buf[MESSAGE_BUFFER_SIZE]; + + SETJMP(NIL); + + /* Get buff address from LISP */ + naddress = (LispPTR *)(Addr68k_from_LADDR(args[0])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + + close(log_id); + TIMEOUT(log_id=open(logfile, O_RDONLY)); + if(log_id == -1)return(NIL); + TIMEOUT(i=fstat(log_id, &sbuf)); + if(i != 0) + { + OSMESSAGE_PRINT( printf("stat err\n") ); + return(NIL); + } + save_size = (int)(sbuf.st_size); + size = save_size - previous_size; + if(size > MESSAGE_BUFFER_SIZE) size = MESSAGE_BUFFER_SIZE; + else logChanged = 0; /* only reset msg-pending flg if we cleaned it out! */ + TIMEOUT(i=lseek(log_id, previous_size, L_SET)); + if(i == -1) + { + OSMESSAGE_PRINT( printf("seek err\n") ); + return(NIL); + } + + /* Now, read "console output" */ + TIMEOUT(size=read(log_id, temp_buf, size)); + if(size == -1) + { + OSMESSAGE_PRINT( printf("read err\n") ); + return(NIL); + } + TIMEOUT(i=lseek(log_id, save_size, L_SET)); + if(i == -1) + { + OSMESSAGE_PRINT( printf("seek err\n") ); + return(NIL); + } +/* + TIMEOUT( close(id) ); +*/ + previous_size += size; + + for(i=0;i= 0) && (rfds & (1 << cons_pty)) ) +#else /* LOGINT */ + + if ((cons_pty >= 0) && + ((size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE-1)) > 0)) +#endif + { /* There are messages to log in the file. */ + DBPRINT(("Log msgs being printed...\n")); + close(log_id); + TIMEOUT( log_id=open(logfile, O_WRONLY | O_APPEND, 0666) ); + if( log_id == -1)return(NIL); +#ifndef LOGINT + size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE-1); +#endif + if(size == -1) return(NIL); + + /* Check free space to avoid print System Error Mesage + to /dev/console */ + TIMEOUT( rval=statfs("/tmp", &fsbuf) ); + if( rval != 0) return(NIL); + + if(fsbuf.f_bavail <= (long)0) + { + /* No Free Space */ + error("osmessage error: No free space on file system (/tmp)."); + return(NIL); + } + logChanged = 1; /* Note the change, for READP */ + TIMEOUT( rval=write(log_id, buf, size) ); + if( rval == -1) + { + if(errno == ENOSPC) /* == 28 on Sun, ibm */ + { + /* No free space, but it's too late to avoid + print system Error Message. */ + error("osmessage error: No free space on file system (/tmp)."); + return(NIL); + } + else + { + error("osmessage error: cannot write to log file (/tmp)"); + return(NIL); + } + } + else + { +/** + close(id); +**/ + return(ATOM_T); + } + } +#endif /* XWINDOW */ +#endif /* DOS */ + } + + diff --git a/src/perrno.c b/src/perrno.c new file mode 100755 index 0000000..d7de6e4 --- /dev/null +++ b/src/perrno.c @@ -0,0 +1,79 @@ +/* $Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "osmsg.h" + + + +/************************************************************************/ +/* */ +/* p e r r o r n */ +/* */ +/* Print the error message to go with a given error number. */ +/* */ +/************************************************************************/ + +extern int errno; +int sys_nerr; +#ifndef LINUX +extern char *sys_errlist[]; +#endif /* LINUX */ + +perrorn(char *s, int n) +{ + if ( s != NULL && *s != '\0' ) { + fprintf(stderr, "%s: ",s); + } + if (n > 0 && n < sys_nerr) { + fprintf(stderr, "%s\n", sys_errlist[n]); + } else { + fprintf(stderr, "???\n"); + } +} + + + +/************************************************************************/ +/* */ +/* e r r _ m e s s */ +/* */ +/* Print an error message and call 'perror' to get the */ +/* canonical error explanation. Called by emulator I/O code. */ +/* */ +/************************************************************************/ + +err_mess(char *from, int no) +{ + int save_errno=errno; /* Save errno around OSMESSAGE_PRINT */ + + + OSMESSAGE_PRINT({fprintf(stderr, + "System call error: %s errno=%d ", + from, no); perror("");}); + + errno=save_errno; + + } diff --git a/src/picture.c b/src/picture.c new file mode 100755 index 0000000..ab8e074 --- /dev/null +++ b/src/picture.c @@ -0,0 +1,706 @@ +/* $Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include + +#include "lispemul.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "arith.h" +#include "adr68k.h" +#include "lspglob.h" + +#define FALSE 0 +#define TRUE !FALSE + +#include "picture.h" + +#define min(x,y) (((x) > (y)) ? (y) : (x)) +#define max(x,y) (((x) > (y)) ? (x) : (y)) + + +#define LStringToCString(Lisp, C, MaxLen ,Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int i; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ + Len = min(MaxLen, arrayp->totalsize); \ + \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0;ibase))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(i=0;itypenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(id=0;idfillpointer = Len; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(id=0;idfillpointer = Len; \ + break; \ + \ + default: \ + error("CStringToLString can not handle\n"); \ + } \ + } + +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + \ + base = (int *) Addr68k_from_LADDR((unsigned int)Lisp); \ + *base = C; \ + } + +#define PICT_CREATE 0 +#define PICT_FREE 1 +#define PICT_GETVALUE 2 +#define PICT_SETVALUE 3 +#define PICT_GET 4 +#define PICT_PUT 5 +#define PICT_BITBLT 6 +#define PICT_BLTSHADE 7 + +#define VIDEOFILE_OPEN 64 +#define VIDEOFILE_CLOSE 65 +#define VIDEOFILE_READ 66 +#define VIDEOFILE_WRITE 67 +#define VIDEOFILE_POSITION 68 + +extern DLword REPLACE_atom + , INVERT_atom + , PAINT_atom + , ERASE_atom; + +#ifdef VIDEO +extern int Video_OnOff_Flg; +#endif /* VIDEO */ + + +LispPTR +Picture_Op( args ) +LispPTR *args; +{ + int op; + LispPTR ret_value; + + op = (DLword)args[0]; + + switch( op ) { + case PICT_CREATE: + ret_value = (LispPTR) Picture_Create( args ); + break; + case PICT_FREE: + ret_value = Picture_Free( args ); + break; + case PICT_GETVALUE: + ret_value = Picture_GetValue( args ); + break; + case PICT_SETVALUE: + ret_value = Picture_SetValue( args ); + break; + case PICT_GET: + ret_value = Picture_Get( args ); + break; + case PICT_PUT: + ret_value = Picture_Put( args ); + break; + case PICT_BITBLT: + ret_value = Picture_Bitblt( args ); + break; + case PICT_BLTSHADE: + ret_value = Picture_Bltshade( args ); + break; + case VIDEOFILE_OPEN: + ret_value = VideoFile_Open( args ); + break; + case VIDEOFILE_CLOSE: + ret_value = VideoFile_Close( args ); + break; + case VIDEOFILE_READ: + ret_value = VideoFile_Read( args ); + break; + case VIDEOFILE_WRITE: + ret_value = VideoFile_Write( args ); + break; + case VIDEOFILE_POSITION: + ret_value = VideoFile_Position( args ); + break; + defaults: + ret_value = NIL; + break; + } /* end switch( op ) */ + + return( ret_value ); +} + +int +Picture_Create( args ) +LispPTR *args; +{ + int width + , height + , bitsperpixel; + Pixrect *storage; + unsigned int *cell; + + width = (DLword) args[1]; + height = (DLword) args[2]; + bitsperpixel = (DLword) args[3]; + + if( (bitsperpixel != 1) + && (bitsperpixel != 8) + && (bitsperpixel != 24) ) { + return( NULL ); + } /* end if( bitsperpixel ) */ + + if( bitsperpixel == 24 ) bitsperpixel = 32; + + storage = mem_create( width, height, bitsperpixel ); + /* if storage is NULL, memory pixrect could not allocated. */ + /* Checking error must be done in Lisp. */ + + /* Initial picture data is set. (may be white) */ + if( (bitsperpixel == 8) || (bitsperpixel == 24) ) { + pr_rop( storage, 0, 0, storage->pr_width, storage->pr_height + , PIX_SET, 0, 0, 0 ); + } /* end if( bitsprepixel ) */ + + cell = (unsigned int*)createcell68k( TYPE_FIXP ); + *cell = (unsigned int) storage; + return( LADDR_from_68k( cell ) ); + +} /* end Picture_Create */ + +extern Pixrect *TrueColorFb; + +int +Picture_Free( args ) +LispPTR *args; +{ + LispPicture *n_picture; + Pixrect *pict; + + n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); + pict = (Pixrect*)n_picture->storage; + + /* TrueColorFb should not be destory. */ + if( pict != TrueColorFb ) { + pr_destroy( pict ); + n_picture->storage = NULL; + } /* end if( pict ) */ + + return( T ); +} /* end Picture_Free */ + +int +Picture_GetValue( args ) +LispPTR *args; +{ + LispPTR picture; + int x + , y + , value; + LispPicture *n_picture; + Pixrect *pict; + unsigned int *cell; + + n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); + x = (DLword) args[2]; + y = (DLword) args[3]; + + pict = (Pixrect*)n_picture->storage; + value = pr_get( pict, x, y ); + + cell = (unsigned int*)createcell68k( TYPE_FIXP ); + *cell = (unsigned int) value; + return( LADDR_from_68k( cell ) ); + +} /* end Picture_GetValue */ + +int +Picture_SetValue( args ) +LispPTR *args; +{ + int x + , y + , value; + LispPicture *n_picture; + struct pixrect *pict; + + n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); + x = (DLword) args[2]; + y = (DLword) args[3]; + N_GETNUMBER( args[4], value, bad_arg ); + + pict = (Pixrect*)n_picture->storage; + pr_put( pict, x, y, value ); + return( T ); + +bad_arg: return( NIL ); + +} /* end Picture_SetValue */ + +#define MAX_NAME_LEN 512 +static char file_name[ MAX_NAME_LEN ]; + +int +Picture_Get( args ) +LispPTR *args; +{ + LispPicture *n_picture; + int length; + + n_picture = (LispPicture *)Addr68k_from_LADDR( args[1] ); + LStringToCString( args[2], file_name, MAX_NAME_LEN, length ); + + if( (n_picture->storage = (unsigned int)File_to_Pixrect( file_name )) != NULL ) { + n_picture->width = (DLword)(((Pixrect*)n_picture->storage)->pr_width); + n_picture->height = (DLword)(((Pixrect*)n_picture->storage)->pr_height); + n_picture->bitsperpixel = (DLword)(((Pixrect*)n_picture->storage)->pr_depth); + if( n_picture->bitsperpixel == 32 ) + n_picture->bitsperpixel = 24; + return( T ); + } else { + return( NIL ); + } /* end if */ +} /* end Picture_Get */ + +int +Picture_Put( args ) +LispPTR *args; +{ + LispPicture *n_picture; + char *name; + int length; + + n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); + LStringToCString( args[2], file_name, MAX_NAME_LEN, length ); + + Pixrect_to_File( (Pixrect*)n_picture->storage, file_name ); + + return( T ); +} /*end Picture_Put */ + +Picture_Bitblt( args ) +LispPTR *args; +{ + LispPicture *src + , *dst; + int src_left + , src_bottom + , dst_left + , dst_bottom + , top + , bottom + , left + , right + , width + , height + , stodx + , stody + , src_top + , dst_top; + int dty + , dlx + , sty + , slx; + int cl_src_left + , cl_src_bottom; + int video_flg; + LispPTR operation + , cl_region; + + src = (LispPicture*)Addr68k_from_LADDR( args[1] ); + dst = (LispPicture*)Addr68k_from_LADDR( args[4] ); + N_GETNUMBER( args[2], src_left, bad_arg ); + N_GETNUMBER( args[3], src_bottom, bad_arg ); + N_GETNUMBER( args[5], dst_left, bad_arg ); + N_GETNUMBER( args[6], dst_bottom, bad_arg ); + + if( args[9] == PAINT_atom ) + operation = PIX_SRC | PIX_DST; + else if( args[9] == ERASE_atom ) + operation = PIX_NOT(PIX_SRC) & PIX_DST; + else if( args[9] == INVERT_atom ) + operation = PIX_SRC ^ PIX_DST; + else + operation = PIX_SRC; + + cl_region = args[10]; + + N_GETNUMBER( args[11], cl_src_left, bad_arg ); + N_GETNUMBER( args[12], cl_src_bottom, bad_arg ); + + top = dst->height; + left = bottom = 0; + right = dst->width; + + if( cl_region != NIL_PTR ) { + LispPTR cl_value; + int tmp + , cl_left + , cl_bottom; + + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, cl_left, bad_arg ); + left = max( left, cl_left ); + + cl_region = cdr( cl_region ); + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, cl_bottom, bad_arg ); + bottom = max( bottom, cl_bottom ); + + cl_region = cdr( cl_region ); + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, tmp, bad_arg ); + right = min( right, cl_left+tmp ); + + cl_region = cdr( cl_region ); + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, tmp, bad_arg ); + top = min( top, cl_bottom+tmp); + } /* end if( cl_region ) */ + + left = max( left, dst_left ); + bottom = max( bottom, dst_bottom ); + + if( args[6] != NIL_PTR ) { + N_GETNUMBER( args[7], width, bad_arg ); + right = min( right, dst_left+width ); + } /* end if( args[6] ) */ + + if( args[7] != NIL_PTR ) { + N_GETNUMBER( args[8], height, bad_arg ); + top = min( top, dst_bottom+height ); + } /* end if( args[7] ) */ + + stodx = dst_left - src_left; + stody = dst_bottom - src_bottom; + + { + int tmp; + + left = max( cl_src_left, max( 0, left-stodx ) ); + bottom = max( cl_src_bottom, max( 0, bottom-stody ) ); + tmp = src->width; + right = min( cl_src_left+tmp, min( right-stodx, src_left+width )); + tmp = src->height; + top = min( cl_src_bottom+tmp, min( top-stody, src_bottom+height )); + } + + if( (right <= left) || (top <= bottom) ) return( NIL ); + + height = top - bottom; + width = right - left; + + dty = dst->height - ( top+stody ); + dlx = left + stodx; + sty = src->height - top; + slx = left; + +#ifdef VIDEO + if( (video_flg = Video_OnOff_Flg) ) Video_OnOff( FALSE ); +#endif /* VIDEO */ + + + pr_rop( (Pixrect*)dst->storage, dlx, dty, width, height + , operation, (Pixrect*)src->storage, slx, sty ); + +#ifdef VIDEO + if( video_flg ) Video_OnOff( TRUE ); +#endif /* VIDEO */ + + +bad_arg: + return( NIL ); + +} /* end Picture_Bitblt */ + +Picture_Bltshade( args ) +LispPTR *args; +{ + LispPicture *dst; + unsigned int texture; + LispPTR cl_region; + int dst_left + , dst_bottom + , left + , right + , bottom + , top + , width + , height + , operation + , video_flg; + + dst = (LispPicture*)Addr68k_from_LADDR( args[2] ); + N_GETNUMBER( args[1], texture, bad_arg ); + N_GETNUMBER( args[3], dst_left, bad_arg ); + N_GETNUMBER( args[4], dst_bottom, bad_arg ); + + if( args[7] == PAINT_atom ) + operation = PIX_SRC | PIX_DST; + else if( args[7] == ERASE_atom ) + operation = PIX_NOT(PIX_SRC) & PIX_DST; + else if( args[7] == INVERT_atom ) + operation = PIX_SRC ^ PIX_DST; + else + operation = PIX_SRC; + + cl_region = args[8]; + + switch( dst->bitsperpixel ) { + case 1: + texture &= 1; + break; + case 8: + texture &= 0xff; + break; + case 24: + texture &= POINTERMASK; + break; + defaulsts: + texture &= POINTERMASK; + break; + } /* end switch */ + + left = bottom = 0; + top = (int)(dst->height); + right = (int)(dst->width); + + if( cl_region != NIL_PTR ) { + LispPTR cl_value; + int tmp + , cl_left + , cl_bottom; + + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, cl_left, bad_arg ); + left = max( left, cl_left ); + + cl_region = cdr( cl_region ); + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, cl_bottom, bad_arg ); + bottom = max( bottom, cl_bottom ); + + cl_region = cdr( cl_region ); + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, tmp, bad_arg ); + right = min( right, cl_left+tmp ); + + cl_region = cdr( cl_region ); + cl_value = car( cl_region ); + N_GETNUMBER( cl_value, tmp, bad_arg ); + top = min( top, cl_bottom+tmp); + } /* end if( cl_region ) */ + + left = max( left, dst_left ); + bottom = max( bottom, dst_bottom ); + + if( args[5] != NIL_PTR ) { + N_GETNUMBER( args[5], width, bad_arg ); + right = min( right, dst_left+width ); + } /* end if( args[5] ) */ + + if( args[6] != NIL_PTR ) { + N_GETNUMBER( args[6], height, bad_arg ); + top = min( top, dst_bottom+height ); + } /* end if( args[6] ) */ + + if( (right <= left) || (top <= bottom) ) return( NIL ); + + height = top - bottom; + width = right - left; + +#ifdef VIDEO + if( (video_flg = Video_OnOff_Flg) ) Video_OnOff( FALSE ); +#endif /* VIDEO */ + + + pr_rop( (Pixrect*)dst->storage, left, (int)(dst->height) - top + , width, height + , operation | PIX_COLOR( texture ), 0, 0, 0 ); + +#ifdef VIDEO + if( video_flg ) Video_OnOff( TRUE ); +#endif /* VIDEO */ + + +bad_arg: + return( NIL ); + +} /* end Picture_Bltshade */ + +#define OPEN_FOR_READ 0 +#define OPEN_FOR_WRITE 1 + +VideoFile_Open( args ) +LispPTR *args; +{ + unsigned int *cell + , videofile; + int length + , access; + + LStringToCString( args[1], file_name, MAX_NAME_LEN, length ); + access = (DLword)args[2]; + + switch( access ) { + case OPEN_FOR_READ: + videofile = open_rasterfile( file_name ); + break; + case OPEN_FOR_WRITE: + videofile = create_rasterfile( file_name ); + break; + default: + videofile = 0; + break; + } /* end switch( access ) */ + + cell = (unsigned int*)createcell68k( TYPE_FIXP ); + *cell = videofile; + return( LADDR_from_68k( cell ) ); +} /* end VideoFile_Open */ + +int +VideoFile_Close( args ) +LispPTR *args; +{ + unsigned int videofile; + + N_GETNUMBER( args[1], videofile, bad_arg ); + + close_rasterfile( videofile ); + return( T ); +bad_arg: + return( NIL ); +} /* end VideoFile_Close */ + +int +VideoFile_Read( args ) +LispPTR *args; +{ + LispPicture *n_picture; + unsigned int *cell + , pix + , videofile; + + N_GETNUMBER( args[1], (unsigned int)videofile, bad_arg ); + n_picture = (LispPicture *)Addr68k_from_LADDR( args[2] ); + + if( (n_picture->storage = (unsigned int)read_rasterfile( videofile )) != NULL ) { + n_picture->width = (DLword)(((Pixrect*)n_picture->storage)->pr_width); + n_picture->height = (DLword)(((Pixrect*)n_picture->storage)->pr_height); + n_picture->bitsperpixel = (DLword)(((Pixrect*)n_picture->storage)->pr_depth); + if( n_picture->bitsperpixel == 32 ) + n_picture->bitsperpixel = 24; + + return( T ); /* normal return */ + } /* end if */ + +bad_arg: + return( NIL ); +} /* end VideoFile_Read */ + +int +VideoFile_Write( args ) +LispPTR *args; +{ + unsigned int videofile; + LispPicture *n_pict; + int status; + + N_GETNUMBER( args[1], videofile, bad_arg ); + n_pict = (LispPicture *)Addr68k_from_LADDR( args[2] ); + + if( (status = write_rasterfile( videofile, (Pixrect*)n_pict->storage )) ) { + return( T ); + } /* end if( status ) */ +bad_arg: + return( NIL ); +} /* end VideoFile_Write */ + +int +VideoFile_Position( args ) +LispPTR *args; +{ + unsigned int videofile; + int n + , status; + + N_GETNUMBER( args[1], videofile, bad_arg ); + n = (DLword) args[2]; + + if( (status = position_rasterfile( videofile, n )) ) { + return( T ); + } /* end if( status ) */ +bad_arg: + return( NIL ); + +} /* end VideoFile_Position */ + diff --git a/src/rawcolor.c b/src/rawcolor.c new file mode 100755 index 0000000..accf1b7 --- /dev/null +++ b/src/rawcolor.c @@ -0,0 +1,788 @@ +/* $Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* C O L O R B I T B L T / G R A P H I C S S U P P O R T */ +/* */ +/* */ +/* */ +/************************************************************************/ + + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "cell.h" +#include "adr68k.h" +#include "address.h" +#include "stream.h" +#include "dspdata.h" +#include "pilotbbt.h" +#include "debug.h" +#include "arith.h" +#include "bitblt.h" +#include "lldsp.h" + +#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) +#define IMAX(x,y) (((x) > (y)) ? (x) : (y)) + + /*******************************/ + /* A LISP Big-bitmap structure */ + /*******************************/ +typedef struct + { + LispPTR bigbmwidth; + LispPTR bigbmheight; + LispPTR bigbmlist; + } BIGBM; + + + +#define GetNewFragment(list,frag,type) \ + frag = (type)Addr68k_from_LADDR( car(list) ); \ + list = cdr( list ); + +LispPTR SLOWBLTCHAR_index; +#define SLOWBLTCHAR_argnum 2 +#define PUNT_TO_SLOWBLTCHAR {\ + if(SLOWBLTCHAR_index==0xffffffff)\ + SLOWBLTCHAR_index= get_package_atom("\\PUNT.SLOWBLTCHAR", \ + 17, "INTERLISP", 9, NIL);\ + if(SLOWBLTCHAR_index==0xffffffff)\ + {error("SLOWBLTCHAR install fail"); return;} \ + CurrentStackPTR +=(SLOWBLTCHAR_argnum-1)*DLWORDSPER_CELL; \ + ccfuncall(SLOWBLTCHAR_index,SLOWBLTCHAR_argnum,3);return;} + +/***********************************************************/ +/* + C_slowbltchar + + by Takeshi + June 6, 1989 +*/ +/***********************************************************/ + +/* I'll merge this macro with FGetNum later */ +#define SFGetNum(ptr, place) { \ + if(((ptr) & SEGMASK)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ + else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ + else {PUNT_TO_SLOWBLTCHAR;}} + + +/* place: native pointer + val: native value(should be smallp) + puntcase: punt descriptions */ +#define FReplaceSmallp(place,val,puntcase) {\ + if ((0 <= (val)) && ((val) <= MAX_SMALL)) \ + (LispPTR)(place) = (LispPTR)(S_POSITIVE | (val));\ + else if(MIN_SMALL <= val)\ + (LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val)));\ + else {puntcase;}} + +/* charcode should be pos. smallp */ +#define charcode (args[0] & 0xffff) +#define displaystream args[1] +#define Char8Code(x) ((u_char)((x) & 0xff)) +#define CharSet(x) ((x) >> 8) + +#define PSEUDO_BLACK 255 +#define PSEUDO_WHITE 0 + +LispPTR *SCREENBITMAPS68k; /* Initialized in initsout.c */ +LispPTR *COLORSCREEN68k; /* Initialized in initsout.c */ +LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */ + + + + +/************************************************************************/ +/* */ +/* C _ s l o w b l t c h a r */ +/* */ +/* args[0] charcode */ +/* args[1] displaystream */ +/* */ +/* */ +/************************************************************************/ + +C_slowbltchar(args) + register LispPTR *args; + { + Stream *n_dstream; + DISPLAYDATA *n_dd; + FONTDESC *n_fontd; + CHARSETINFO *n_csinfo; + BITMAP *n_destbitmap; + int dest_bpp; + LispPTR csinfo; + int curx,cury,newx,rmargin,lmargin,xoff,yoff; + DLword cl_left, cl_right, cl_bottom, cl_top; + DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h; + + + u_char forecolor,backcolor; + register int displayflg; + + + extern LispPTR *TOPWDS68k; + + n_dstream=(Stream*)Addr68k_from_LADDR(displaystream); + n_dd=(DISPLAYDATA*)Addr68k_from_LADDR(n_dstream->IMAGEDATA); + n_fontd=(FONTDESC*)Addr68k_from_LADDR(n_dd->ddfont); + n_destbitmap=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); + + if((n_fontd->ROTATION & 0xffff) == 0) + { + + if((csinfo= + *(((LispPTR*)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) + + CharSet(charcode) )) == NIL ) + PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */ + + n_csinfo =(CHARSETINFO*)Addr68k_from_LADDR(csinfo); + + SFGetNum(n_dd->ddxposition, curx); + SFGetNum(n_dd->ddyposition, cury); + SFGetNum(n_dd->ddrightmargin, rmargin); + SFGetNum(n_dd->ddleftmargin, lmargin); + SFGetNum(n_dd->ddxoffset, xoff); + SFGetNum(n_dd->ddyoffset, yoff); + cl_left = n_dd->ddclippingleft; + cl_right = n_dd->ddclippingright; + cl_bottom = n_dd->ddclippingbottom; + cl_top = n_dd->ddclippingtop; + + newx = curx + *(DLword*)Addr68k_from_LADDR(n_dd->ddwidthscache + + Char8Code(charcode)); + + if(newx > rmargin) + PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */ + + /* If we care about TOPW then it's too slow to create Menu etc. + But,if we don't,it causes some error **/ + { + WINDOW *window; + SCREEN *ColorScreenData; + if(COLORSCREEN_index==0xffffffff) + { /* Make sure COLOR lives? */ + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); + } + ColorScreenData=(SCREEN*)Addr68k_from_LADDR(*COLORSCREEN68k); + window = (WINDOW*)Addr68k_from_LADDR(ColorScreenData->SCTOPW); + if((displaystream != ColorScreenData->SCTOPW) && + (displaystream != window->DSP) && + (displaystream != *TOPWDS68k) && + ((fmemb(n_dd->dddestination,*SCREENBITMAPS68k)) != NIL)) + PUNT_TO_SLOWBLTCHAR; + } + + FReplaceSmallp( n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR); + + /* make curx abs coord */ + curx += xoff; + cury += yoff; + + { register PILOTBBT *pbt; + register BITMAP *n_destBM,*n_srcBM; + register BIGBM *n_destBIGBM; + register int destYOffset; + register int width,sourceBitOffset; + extern int ScreenLocked; + extern int displayheight; + + n_srcBM=(BITMAP*)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP); + src_h = n_srcBM->bmheight; + src_w = n_srcBM->bmwidth; + + src_x = *((DLword*)Addr68k_from_LADDR( n_dd->ddoffsetscache + + Char8Code(charcode))); + src_y = 0; + w = *(DLword*)Addr68k_from_LADDR(n_dd->ddcharimagewidths + + Char8Code(charcode)); + h = src_h; + + (short)dst_x = (short)curx; + (short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT; + + { /* clipping */ + short left,right,bottom,top; + short stodx,stody; + + left = (short)IMAX( (short)dst_x, (short)cl_left ); + right = (short)IMIN( (short)dst_x+w, (short)cl_right ); + bottom = (short)IMAX( (short)dst_y, (short)cl_bottom ); + top = (short)IMIN( (short)dst_y+h, (short)cl_top ); + stodx = (short)dst_x - (short)src_x; + stody = (short)dst_y - (short)src_y; + left = IMAX( (short)src_x, IMAX( left-stodx, 0 ) ); + bottom = IMAX( (short)src_y, IMAX( bottom-stody , 0 ) ); + right = IMIN( (short)src_w, IMIN( (short)(src_x+w), right-stodx ) ); + top = IMIN( (short)src_h, IMIN( (short)(src_y+h), top-stody ) ); + if ( (right<=left) || (top<=bottom) ) return; + w = (DLword)(right - left); + h = (DLword)(top - bottom); + dst_x = (DLword)(left + stodx); + dst_y = (DLword)(bottom + stody); + src_x = (DLword)left; + src_y = (DLword)bottom; + } + + /* forground and bacground color */ + + if(n_dd->ddcolor ==NIL_PTR) + { + forecolor = PSEUDO_BLACK; + backcolor = PSEUDO_WHITE; + } + else + { + backcolor = 0xff & cdr(n_dd->ddcolor); + forecolor = 0xff & car(n_dd->ddcolor); + } + + if(GetTypeNumber( n_dd->dddestination ) == TYPE_BITMAP) + { /* Bitap */ + n_destBM=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); + ScreenLocked=T; + /* xposition is shifted 3 Kludge for cursorin + in color(8bpp) ** x's meaning is different from + bitbltsub's. For now,I use this func with Kludge */ + displayflg=n_new_cursorin( + Addr68k_from_LADDR(n_destBM->bmbase),dst_x<<3, + /* Kludge:YCoordination upside down*/ + displayheight-cury,w,h); + if(displayflg) HideCursor; + + ColorizeFont8(n_srcBM, src_x, src_y + , n_destBM, dst_x, dst_y + , w, h + , backcolor,forecolor + , n_dd->ddsourcetype,n_dd->ddoperation); + + + if(displayflg) ShowCursor; + ScreenLocked=NIL; + + } + else + { /* BIGBM */ + ScreenLocked=T; + n_destBIGBM = (BIGBM*)n_destbitmap; + ColorizeFont8_BIGBM(n_srcBM, src_x, src_y + , n_destBIGBM, dst_x, dst_y + , w, h + , backcolor,forecolor + , n_dd->ddsourcetype,n_dd->ddoperation); + ScreenLocked=NIL; + } /* end if( TYPE_BITMAP ) */ + + + } + } + else + { + /* ROTATE case ,do-PUNT */ + PUNT_TO_SLOWBLTCHAR; + } + + } /* end C_slowbltchar */ + + + +/************************************************************************/ +/* */ +/* C o l o r i z e d F o n t 8 */ +/* */ +/* Expand a 1bpp font to 8bpp colorized font bitmap, using */ +/* col1 and col0 as the colors for 1 bits & 0 bits, respectively. */ +/* */ +/* dbm must be the output bitmap (not a bigbm), whose bpp is 8. */ +/* */ +/************************************************************************/ + +#define MAXFONTHEIGHT 48 +#define MAXFONTWIDTH 48 +#define BITSPERNIBBLE 4 +#define BITSPERDLWORD 16 +#define BPP 8 + +u_int ColorizedFont8CACHE[MAXFONTHEIGHT/BITSPERNIBBLE * + MAXFONTWIDTH/BITSPERNIBBLE]; + + +ColorizeFont8(sBM,sXOffset,sYOffset,dBM,dXOffset, + dYOffset,width,height,col0,col1,sourcetype,operation) + register BITMAP *sBM; + register DLword sXOffset,sYOffset, width, height; + register BITMAP *dBM; + DLword dYOffset,dXOffset; + u_char col0,col1; + LispPTR sourcetype; + LispPTR operation; + +{ + register DLword *nbase; + register u_char *dbase; + register int i; + + sYOffset = sBM->bmheight - (sYOffset+height); + dYOffset = dBM->bmheight - (dYOffset+height); + + nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) + + (sBM->bmrasterwidth * sYOffset); + (DLword*)dbase= (DLword*)Addr68k_from_LADDR(dBM->bmbase) + + (dBM->bmrasterwidth * dYOffset); + for(i=0, dbase += dXOffset;/* 8bpp */ + i < height; + i++,nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dBM->bmrasterwidth) + { + lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); + } /* for end */ + +} /* ColorizeFont8 end */ + + + + + +/************************************************************************/ +/* */ +/* C o l o r i z e d F o n t 8 _ B I G B M */ +/* */ +/* Expand a 1bpp font to 8bpp colorized font bitmap, using */ +/* col1 and col0 as the colors for 1 bits & 0 bits, respectively. */ +/* */ +/* dbm must be the output BIGBM (not a bitmap), whose bpp is 8. */ +/* */ +/************************************************************************/ + +ColorizeFont8_BIGBM(sBM,sXOffset,sYOffset,dBM,dXOffset,dYOffset,width,height,col0,col1,sourcetype,operation) +register BITMAP *sBM; +register DLword sXOffset,sYOffset,width,height; +register BIGBM *dBM; +DLword dXOffset, dYOffset; +u_char col0,col1; +LispPTR sourcetype; +LispPTR operation; + + +{ + register DLword *nbase; + register u_char *dbase; + register int i; + int dest_bottom + , dest_bigbmheight + , dest_fragtop + , dest_fragbottom + , dest_yoffset + , dest_h; + + LispPTR dest_bmlist; + BITMAP *dest_frag; + + SFGetNum( dBM->bigbmheight, dest_bigbmheight ); + + sYOffset = sBM->bmheight - ( sYOffset+height ); + dYOffset = dest_bigbmheight - ( dYOffset+height ); + + dest_bottom = dYOffset + height; + dest_bmlist = (LispPTR)dBM->bigbmlist; + GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); + dest_fragtop = 0; + dest_fragbottom = dest_frag->bmheight; + +/* search fragment of bitmaps including the desitnation top. */ + while( dest_fragbottom <= dYOffset ) { + GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); + if( dest_frag == (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) return; + dest_fragtop = dest_fragbottom; + dest_fragbottom += dest_frag->bmheight; + } /* end while */ + +/* y offset form bitmap top. */ + dest_yoffset = dYOffset - dest_fragtop; + +loop: +/* height of lineBlt8 */ + if( dest_fragbottom > dest_bottom ) { + /* this fragment inludes dest bottom. */ + dest_h = dest_bottom - (dest_fragtop + dest_yoffset); + } else { + /* remaining fragments include dest bottom. */ + dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset); + } /* end if */ + + dbase= (DLword*)Addr68k_from_LADDR(dest_frag->bmbase) + + (dest_frag->bmrasterwidth * dest_yoffset); + nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) + + (sBM->bmrasterwidth * sYOffset); + + sYOffset += (DLword)dest_h; /* next src yoffset */ + + for(i=0, dbase += dXOffset; + i < dest_h; + i++, nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dest_frag->bmrasterwidth) + { + lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); + } + +/* remaining height */ + height -= dest_h; + if( height > 0 ) { + GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); + if( dest_frag != (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) { + dest_fragtop = dest_fragbottom; + dest_fragbottom = dest_fragtop + dest_frag->bmheight; + dest_yoffset = 0; /* y offset must be zero. */ + nbase += sBM->bmrasterwidth; + goto loop; + } /* end if(dest_frag) */ + } /* end if(height) */ + +} /* end ColorizeFont8_BIGBM() */ + + + +/************************************************************************/ +/* */ +/* n e w C o l o r i z e F o n t 8 */ +/* */ +/* */ +/* */ +/************************************************************************/ + +newColorizeFont8(pbt,backcolor,forecolor,srctype,ope) + PILOTBBT *pbt; + u_char backcolor,forecolor; + LispPTR srctype,ope; +{ + register DLword *nbase; + register u_char *dbase; + register int i; + + nbase=(DLword*)Addr68k_from_LADDR + ((pbt->pbtsourcehi << 16 ) | (pbt->pbtsourcelo)) ; + (DLword*)dbase= (DLword*)Addr68k_from_LADDR( + (pbt->pbtdesthi << 16 ) | (pbt->pbtdestlo)) ; + dbase += pbt->pbtdestbit; + for(i=0; i < pbt->pbtheight; + i++,nbase += pbt->pbtsourcebpl/16 + , dbase += pbt->pbtdestbpl/8) + { + lineBlt8(nbase,pbt->pbtsourcebit,dbase,pbt->pbtwidth,backcolor,forecolor,srctype,ope); + } /* for end */ + + +} + + + +/************************************************************************/ +/* */ +/* U n c o l o r i z e _ B i t m a p */ +/* */ +/* Uncolorize bitmap from 8bpp to 1bpp. */ +/* */ +/************************************************************************/ + +Uncolorize_Bitmap( args ) +LispPTR args[]; +{ + BITMAP *s_bitmap + , *d_bitmap; + register DLword* OnOff; + + register u_char *s_base; + register DLword *d_base; + register int y; + int s_height + , s_width + , s_bitsperpixel + , s_rasterwidth + , d_rasterwidth; + + s_bitmap = (BITMAP*)Addr68k_from_LADDR( args[0] ); + d_bitmap = (BITMAP*)Addr68k_from_LADDR( args[1] ); + OnOff = (DLword*)Addr68k_from_LADDR( args[2] ); + + s_height = s_bitmap->bmheight; + s_width = s_bitmap->bmwidth; + s_bitsperpixel = s_bitmap->bmbitperpixel; + + if( s_bitsperpixel != 8 ) return; + + s_base = (u_char*)Addr68k_from_LADDR(s_bitmap->bmbase); + d_base = (DLword*)Addr68k_from_LADDR(d_bitmap->bmbase); + s_rasterwidth = s_bitmap->bmrasterwidth; + d_rasterwidth = d_bitmap->bmrasterwidth; + + for( y=0; ybmbase ) + + s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height)); + (DLword*)d_base = (DLword*)Addr68k_from_LADDR( d_bitmap->bmbase ) + + d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height)); + + for( i=0, d_base += d_left; ibmrasterwidth + , (DLword*)d_base += d_bitmap->bmrasterwidth ) { + + lineBlt8( s_base, s_left, d_base, width + , (u_char)color0, (u_char)color1 + , INPUT_atom, REPLACE_atom ); + + } /* end for(i) */ + + bad_arg: return( NIL ); + +} /* end Colorize_Bitmap() */ + + + +/************************************************************************/ +/* */ +/* D r a w _ 8 B p p C o l o r L i n e */ +/* */ +/* Draw a line in the 8-bpp display bitmap. */ +/* */ +/************************************************************************/ + +#define op_replace = +#define op_erase &= +#define op_invert ^= +#define op_paint |= + +#define draw8bpplinex(op) \ + while( (x0 <= xlimit) && ( y0 <= ylimit ) ) { \ + *(base++) op color; ++x0; cdl += dy; \ + if( dx <= cdl ) { \ + cdl -= dx; \ + base += yinc; ++y0; \ + } \ + } + +#define draw8bppliney(op) \ + while( (x0 <= xlimit) && (y0 <= ylimit ) ) { \ + *base op color; base += yinc; ++y0; cdl += dx; \ + if( dy <= cdl ) { \ + cdl -= dy; \ + ++ base; ++x0; \ + } \ + } + +Draw_8BppColorLine( args ) + register LispPTR *args; + { + extern DLword REPLACE_atom + , INVERT_atom + , PAINT_atom + , ERASE_atom; + extern int ScreenLocked; + + register u_char color; + register u_char *base; + register short x0 + , y0 + , xlimit + , ylimit + , dx + , dy + , cdl + , yinc + , raster_width; + int mode + , displayflg; + u_char *n_bmbase; + + x0 = (short)( args[0] &0xffff ); + y0 = (short)( args[1] &0xffff ); + xlimit = (short)( args[2] &0xffff ); + ylimit = (short)( args[3] &0xffff ); + dx = (short)( args[4] &0xffff ); + dy = (short)( args[5] &0xffff ); + cdl = (short)( args[6] &0xffff ); + yinc = (short)( args[7] &0xffff ); yinc *= 2; /* for byte addressing */ + + if ( args[8] == PAINT_atom ) mode = 3; + else if( args[8] == INVERT_atom ) mode = 2; + else if( args[8] == ERASE_atom ) mode = 1; + else mode = 0; /* REPLACE_atom */ + + n_bmbase = (u_char*)Addr68k_from_LADDR( args[9] ); + raster_width = (short) ( args[10] &0xffff ); + color = (u_char)( args[11] & 0xff ); + + if( yinc >= 0 ) + { + displayflg = n_new_cursorin( (DLword*)n_bmbase + , (int)(x0<<3), (int)y0, (int)(xlimit<<3), (int)ylimit ); + } + else + { + displayflg = + n_new_cursorin( (DLword*)n_bmbase, + (int)(x0<<3), (int)(y0-ylimit), + (int)(xlimit<<3), (int)ylimit ); + } + + base = n_bmbase + y0 * (raster_width << 1) + x0; + x0 = y0 = 0; + + if( displayflg ) + { + ScreenLocked = T; + HideCursor; + } + + if( dx >= dy ) + { /* .draw8bpplinex */ + switch( mode ) + { + case 0: draw8bpplinex( op_replace ); + break; + case 1: draw8bpplinex( op_erase ); + break; + case 2: draw8bpplinex( op_invert ); + break; + case 3: draw8bpplinex( op_paint ); + break; + } /* end switch */ + + } + else + { /* .draw8bppliney */ + switch( mode ) + { + case 0: draw8bppliney( op_replace ); + break; + case 1: draw8bppliney( op_erase ); + break; + case 2: draw8bppliney( op_invert ); + break; + case 3: draw8bppliney( op_paint ); + break; + } /* end switch */ + + } /* end if( dx >= dy ) */ + + if( displayflg ) + { + ShowCursor; + ScreenLocked = NIL; + } + + } /* end Draw_8BppColorLine */ diff --git a/src/rawrs232c.c b/src/rawrs232c.c new file mode 100755 index 0000000..89845fe --- /dev/null +++ b/src/rawrs232c.c @@ -0,0 +1,352 @@ +/* $Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "debug.h" +#include "rawrs232c.h" + +#define MIN_CHARS 256 +#define MIN_TIME 1 + + + +/************************************************************/ +/* + + raw232c.c + Access RS device from Lisp by using FD + This provides low-level access to RS device. + + Created: Feb.12 1991 + By Takeshi Shimizu + + CopyRight Fuji Xerox Co., LTD 1991 + + +*/ +/************************************************************/ + +raw_rs232c_open(portname) +LispPTR portname; +{ + ONED_ARRAY *head; + + char *lispname; + int fd; + + + if(GetTypeNumber(portname) != TYPE_ONED_ARRAY) + error("PORTNAME is not string"); + head = (ONED_ARRAY*)Addr68k_from_LADDR(portname); + lispname =(char*)Addr68k_from_LADDR(head->BASE); + + if((fd=open(lispname,O_RDWR)) < 0){ + perror("RS open fail: "); + return(NIL); + } + +return(S_POSITIVE | fd); + + +} /* raw_rs232c_open */ + +raw_rs232c_setparams(fd,data) +LispPTR fd; +LispPTR data; +{ +RawRSParam *ndata; +struct termios termdata; + +/* Get Current params */ + if (ioctl((fd & 0xffff), TCGETS ,&termdata) < 0) + { + perror("RS get params:"); + return(NIL); + } + + ndata =(RawRSParam*)Addr68k_from_LADDR(data); + +/* Input */ + termdata.c_iflag |= IXON|IXOFF; + termdata.c_iflag &= ~(INPCK); + + /*termdata.c_iflag &= ~IGNBRK;*/ + termdata.c_iflag &= ~IGNPAR; + termdata.c_iflag &= ~IUCLC; + if(ndata->InEOL ==RAW_RS_CR){ + termdata.c_iflag |= INLCR; + termdata.c_iflag &= ~ICRNL; + } + + else if(ndata->InEOL ==RAW_RS_LF){ + termdata.c_iflag &= ~INLCR; + termdata.c_iflag |= ICRNL; + } + else if (ndata->InEOL ==RAW_RS_CRLF){ + termdata.c_iflag &= ~INLCR; + termdata.c_iflag &= ~ICRNL; + } +/* Flow CNT */ + if((ndata->FlowCnt & 0xff) == RAW_RS_XON) + termdata.c_iflag |= IXON|IXOFF; + else { + termdata.c_iflag &= ~(IXON|IXOFF); + } + + termdata.c_iflag &= ~(ISTRIP); + + +/* Output */ + + termdata.c_oflag |= ~OPOST; + termdata.c_oflag &= ~OLCUC; + termdata.c_oflag &= ~OFILL; + termdata.c_oflag &= ~OFDEL; + termdata.c_oflag &= ~NLDLY; + termdata.c_oflag &= ~CRDLY; + termdata.c_oflag &= ~BSDLY; + termdata.c_oflag &= ~VTDLY; + termdata.c_oflag &= ~FFDLY; + + if(ndata->OutEOL == RAW_RS_CR){ + termdata.c_oflag |= ONLRET; + termdata.c_oflag &= ~OCRNL; + termdata.c_oflag &= ~ONLCR; + } + else if (ndata->OutEOL == RAW_RS_LF){ + termdata.c_oflag &= ~ONLRET; + termdata.c_oflag |= OCRNL; + termdata.c_oflag &= ~ONLCR; + } + else if (ndata->OutEOL == RAW_RS_CRLF){ + termdata.c_oflag &= ~ONLRET; + termdata.c_oflag &= ~OCRNL; + termdata.c_oflag |= ONLCR; + } + + +/* LOCAL */ + + termdata.c_lflag &= ~ISIG; + termdata.c_lflag &= ~ICANON; + termdata.c_lflag &= ~XCASE; + + if(ndata->Echo == ATOM_T) + termdata.c_lflag |= ECHO; + else termdata.c_lflag &= ~ECHO; + + termdata.c_lflag &= ~ECHOE; + termdata.c_lflag &= ~ECHOK; + termdata.c_lflag &= ~ECHONL; + termdata.c_lflag &= ~NOFLSH; + termdata.c_lflag &= ~TOSTOP; + termdata.c_lflag &= ~ECHOCTL; + termdata.c_lflag &= ~ECHOPRT; + termdata.c_lflag &= ~ECHOKE; + termdata.c_lflag &= ~FLUSHO; + termdata.c_lflag &= ~PENDIN; + + + /* Minimum and Timeout */ + termdata.c_cc[VMIN] = MIN_CHARS; + termdata.c_cc[VTIME] = MIN_TIME; + + /* Control */ + +termdata.c_cflag=( CREAD | HUPCL); + +/* Local or DialUP */ + +if(ndata->LocalLine == ATOM_T) + termdata.c_cflag |= CLOCAL; +else termdata.c_cflag &= ~CLOCAL; + +/* Bau Rate */ + + if (ndata->BauRate != NIL){ + switch(ndata->BauRate & 0xffff){ + case 1200: termdata.c_cflag |= B1200; + break; + + case 2400: termdata.c_cflag |= B2400; + break; + + case 4800: termdata.c_cflag |= B4800; + break; + + case 9600: termdata.c_cflag |= 96200; + break; + + default: termdata.c_cflag |= B1200; + } + } + +/* CTS/RTS */ + if((ndata->RTSCTSCnt & 0xff) == ATOM_T) + termdata.c_cflag |=CRTSCTS; + else termdata.c_cflag &= ~CRTSCTS; + + + +/* Character size */ + + if((ndata->BitsPerChar & 0xf)== 7) + termdata.c_cflag |= CS7; + else if((ndata->BitsPerChar & 0xf)== 8) + termdata.c_cflag |= CS8; + else {error("RS232:Not supported char size"); + return(NIL);} + +/* Parity */ + if((ndata->Parity & 0xf) == RAW_RS_NONE) + {termdata.c_iflag &= (~(INPCK)); + termdata.c_cflag &=( ~PARENB);} + else if((ndata->Parity & 0xf) == RAW_RS_EVEN) + termdata.c_cflag |= PARENB; + else if((ndata->Parity & 0xf) == RAW_RS_ODD) + termdata.c_cflag |= (PARENB | PARODD); + +/* Stop bits */ + if((ndata->NoOfStopBits & 0x2) == 2) + termdata.c_cflag |= CSTOPB; + else + termdata.c_cflag &= ~(CSTOPB); + + +/* Set parameters */ + +if(ioctl((fd & 0xffff), TCSETS, &termdata) < 0) + {perror("RS set params"); + return(NIL);} + +return(ATOM_T); + +} /* raw_rs232c_setparams */ + + +raw_rs232c_close(fd) + LispPTR fd; +{ + if(close(0xffff & fd) <0) { + perror("RS close : "); + return(NIL); + } + else return(ATOM_T); + +} + + +raw_rs232c_write(fd,baseptr,len) +LispPTR fd; +LispPTR baseptr; +LispPTR len; +{ + unsigned char *ptr; + + ptr = (unsigned char *)Addr68k_from_LADDR(baseptr); + + if(write((fd & 0xffff),ptr,(len & 0xffff)) <0){ + perror("RS-write :"); + return(NIL); + } + return(ATOM_T); +} + +/* Assume numbers are SMALLPOSP */ +struct timeval RS_TimeOut = {0,0}; +raw_rs232c_read(fd,buff,nbytes) +LispPTR fd; +LispPTR buff; +LispPTR nbytes; + +{ +unsigned char *buffptr; +int length; +u_int real_fd; +u_int readfds; + + + real_fd = fd & 0xffff ; + readfds = (1 << real_fd ); + + select(32,&readfds,NULL,NULL,&RS_TimeOut); + if(readfds & (1<nopush = T; + + + /* store PC */ + CURRENTFX->pc = (UNSIGNED)PC - (UNSIGNED)FuncObj + bytenum; + + /* TOS save */ + if(flags & 2){ + PushStack(fxnum); + CurrentStackPTR += 2; + } + else{ + PushCStack; + CurrentStackPTR += 2; + } + + CURRENTFX->nextblock=LOLOC(LADDR_from_68k(CurrentStackPTR)); + + /* FSB set */ + GETWORD(CurrentStackPTR)=STK_FSB_WORD; + GETWORD(CurrentStackPTR+1)= (((UNSIGNED)EndSTKP-(UNSIGNED)CurrentStackPTR)>>1); + if (0 == GETWORD(CurrentStackPTR+1)) error("creating 0-long free stack block."); +#ifdef STACKCHECK + if(EndSTKP < CurrentStackPTR) error("contextsw:Illegal ESP"); +#endif + + + Midpunt(fxnum); /* exchanging FX */ + +RTNX : + next68k = (DLword *)Addr68k_from_LADDR(STK_OFFSET | CURRENTFX->nextblock); + + if(GETWORD(next68k) != STK_FSB_WORD) error("contextsw(): MP9316"); + freeptr=next68k; + + /* Merging FSB area */ + while(GETWORD(freeptr) == STK_FSB_WORD) EndSTKP=freeptr=freeptr+ GETWORD(freeptr+1); + + + +#ifdef DEBUG + printf("contextsw:ESTKP set "); + laddr(EndSTKP); +#endif + + if(CURRENTFX->incall) + { + error("return to frame with incall bit "); + } + else + { + if (CURRENTFX->nopush) + { +#ifdef DEBUG + printf("context:after:nopush \n"); +#endif + + CURRENTFX->nopush =NIL; + CurrentStackPTR = next68k-2 ; + TopOfStack = *((LispPTR *)CurrentStackPTR) ; + CurrentStackPTR-=2; + + } + else + { +#ifdef DEBUG + printf("context:after:3 \n"); +#endif + CurrentStackPTR = next68k-2 /*-1*/ ; /* CHanged by Hayata */ + } + +#ifdef STACKCHECK + CHECKFX; + if( EndSTKP< CurrentStackPTR) + error("contextsw:Illegal ESP"); +#endif + FastRetCALL + return; + } + + } /* end contextsw */ + diff --git a/src/rpc.c b/src/rpc.c new file mode 100755 index 0000000..8ea63c9 --- /dev/null +++ b/src/rpc.c @@ -0,0 +1,229 @@ +/* $Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/************************************************************************/ +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifndef DOS +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* DOS */ +#include "lispemul.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "emlglob.h" +#include "adr68k.h" +#include "arith.h" +#include "locfile.h" + +#define MAX_HOSTNAME_LENGTH 100 +#define UDP_DATA_BLOCK_SIZE 1000 + +#ifdef OS5 +#define ToMem memmove +#else +#define ToMem memcpy +#endif /* OS5 */ + +rpc(args) + LispPTR *args; +{ +#ifndef DOS + /* Arguments are: + args[0]:Destination Address; hostname or internet address are both supported. + args[1]:Remote port for this program. + args[2]:Argument block pointer. + args[3]:Result Block pointer. + args[4]:Milliseconds before timeout + args[5]:Milliseconds between tries + args[6]:Argument block length + */ + char hostname[MAX_HOSTNAME_LENGTH]; + struct hostent *hp; + struct servent *sp; + struct sockaddr_in sin, sin1, from; + char *outbuf, *inbuf, *destaddr; + register int s, msec_until_timeout, msec_between_tries, out_length; + register int received, mask; + register int port; + int dontblock, dest, fromlen, read_descriptors; + + struct timeval pertry_timeout, total_timeout, time_waited; + + /* Set timeout */ + /* CONVERT FROM LISP TO C TYPES */ + dest = GetTypeNumber(args[0]); + + if ((dest == TYPE_FIXP) || (dest == TYPE_SMALLP)) { + N_GETNUMBER(args[0], dest, handle_error); + destaddr = (char *)&dest; + hp = gethostbyaddr(destaddr, sizeof(struct in_addr), AF_INET); + } + else { + /* Convert Hostname */ + LispStringToCString(args[0],hostname, MAX_HOSTNAME_LENGTH); + hp = gethostbyname(hostname); + } + + N_GETNUMBER(args[1], port, handle_error); + + /* Translate the buffer pointer into C pointers */ + outbuf = (char *)(Addr68k_from_LADDR(args[2])); + inbuf = (char *)(Addr68k_from_LADDR(args[3])); + + N_GETNUMBER(args[4], msec_until_timeout, handle_error); + + N_GETNUMBER(args[5], msec_between_tries, handle_error); + + N_GETNUMBER(args[6], out_length, handle_error); + + /* Convert to micro seconds */ + msec_until_timeout = msec_until_timeout * 1000; + msec_between_tries = msec_between_tries * 1000; + + /* Set up the timeouts */ + total_timeout.tv_sec = msec_until_timeout / 1000000; + total_timeout.tv_usec = msec_until_timeout % 1000000; + pertry_timeout.tv_sec = msec_between_tries / 1000000; + pertry_timeout.tv_usec = msec_between_tries % 1000000; + + /* SET UP THE SOCKET */ + + /* Open the socket; Might want to make this non-blocking */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + goto handle_error; + + dontblock = 1; + + /* The sockets that rpc controls don't block */ +#ifdef SYSVONLY +/* NEED TO FILL THIS IN PROPERLY */ +#else + (void)ioctl(s, FIONBIO, &dontblock); +#endif /* SYSVONLY */ + + + memset((char *)&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + bind(s, (struct sockaddr *)&sin, sizeof(sin)); + + /* Resolve the host address. */ + if (hp) { + sin1.sin_family = hp->h_addrtype; + ToMem((caddr_t) &sin1.sin_addr, hp->h_addr, hp->h_length); + } + else goto handle_error; + + /* Convert to network byte order */ + sin1.sin_port = htons((u_short)port); + + /* Send buffer out on the socket */ + if (sendto(s, outbuf, out_length, 0, (struct sockaddr *)&sin1, + sizeof(sin1)) != out_length) + goto handle_error; + + /* Set the select mask */ + mask = 1 << s; + + /* Set up the timers */ + time_waited.tv_sec = 0; + time_waited.tv_usec = 0; + + /* Start the waiting loop */ + receive: + + read_descriptors = mask; + + switch(select(32, (fd_set *)&read_descriptors, (fd_set *)NULL, (fd_set *)NULL, + &pertry_timeout)){ + + /* Per try timeout expired, Check the total timeout */ + case 0: + time_waited.tv_sec += pertry_timeout.tv_sec; + time_waited.tv_usec += pertry_timeout.tv_usec; + while(time_waited.tv_usec >= 1000000) { + time_waited.tv_sec++; + time_waited.tv_usec -= 1000000; + } + /* If the time waited is greater than the total + * timeout then there's an error + */ + if ((time_waited.tv_sec > total_timeout.tv_sec) || + ((time_waited.tv_sec == total_timeout.tv_sec) && + (time_waited.tv_usec >= total_timeout.tv_usec))) + goto handle_error; + else break; + + /* An error was generated, Unless it was a system error stop */ + case -1: + if (errno == EINTR) + goto receive; + else goto handle_error; + } + /* Did something arrive for this socket */ + if ((read_descriptors & mask) == 0) + goto receive; + + /* Something arrived; try to get it */ + + getbuf: + fromlen = sizeof(struct sockaddr); + received = recvfrom(s, inbuf, UDP_DATA_BLOCK_SIZE, 0, + (struct sockaddr *)&from, &fromlen); + if (received < 0) + switch(errno) { + case EINTR: + goto getbuf; + case EWOULDBLOCK: + goto receive; + default: + goto handle_error; + } + + /* close the socket */ + close(s); + + /* Return TRUE */ + return(ATOM_T); + + /* Return NIL; Eventually we will need to return something more informative, perhaps errno + * would be sufficient. + */ + handle_error: + return(NIL_PTR); +#endif /* DOS */ +} + diff --git a/src/rplcons.c b/src/rplcons.c new file mode 100755 index 0000000..27fdb06 --- /dev/null +++ b/src/rplcons.c @@ -0,0 +1,90 @@ +/* $Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyright (C) Venue"; + + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/***********************************************************************/ +/* + File Name : rplcons.c + + Desc : rplcons + + Including : rplcons + OP_rplcons + +*/ +/**********************************************************************/ + +#include "lispemul.h" +#include "emlglob.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "gc.h" +#include "cell.h" + +/***************************************************/ + +N_OP_rplcons(register LispPTR list, register LispPTR item) +{ + register struct conspage *conspage ; + register ConsCell *new_cell , *list68k; + + LispPTR register page; + + if(!Listp(list)) ERROR_EXIT(item); + + page = POINTER_PAGE(list); + list68k=(ConsCell *)Addr68k_from_LADDR(list); + + /* There are some rest Cell and "list" must be ONPAGE cdr_coded */ +#ifndef NEWCDRCODING + if((GetCONSCount(page) != 0) && (list68k->cdr_code > CDR_MAXINDIRECT)) + { + GCLOOKUP(item, ADDREF); + GCLOOKUP(cdr(list), DELREF); + + conspage = (struct conspage *)Addr68k_from_LPAGE(page); + new_cell =(ConsCell *)GetNewCell_68k(conspage); + + conspage->count--; + conspage->next_cell= ((freecons *)new_cell)->next_free; + + new_cell->car_field = item ; + new_cell->cdr_code = CDR_NIL ; + + ListpDTD->dtd_cnt0++; + + list68k->cdr_code = CDR_ONPAGE | ((LADDR_from_68k(new_cell) &0xff)>>1) ; + + return(LADDR_from_68k(new_cell)) ; + + + } + else +#endif /* ndef NEWCDRCODING */ + { + N_OP_rplacd(list, item = cons(item , NIL_PTR)); + return(item); + } + } + diff --git a/src/rs232c.c b/src/rs232c.c new file mode 100755 index 0000000..8536e13 --- /dev/null +++ b/src/rs232c.c @@ -0,0 +1,913 @@ +/* $Id: rs232c.c,v 1.2 1999/01/03 02:07:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: rs232c.c,v 1.2 1999/01/03 02:07:32 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "rs232c.h" + +/* + * Lisp Interface + */ +static DLRS232C_HDW_CONF *HardWareConfig; +static DLRS232C_IOP_GET_FLAG *RS232CGetFlag; +static DLRS232C_IOP_PUT_FLAG *RS232CPutFlag; +static DLRS232C_IOP_MISC_CMD *RS232CMiscCommand; +static DLRS232C_PARAMETER_OUTCOME *RS232CParameterOutcome; +static DLRS232C_DEVICE_STATUS *RS232CDeviceStatus; +static DLRS232C_PARAMETER_CSB *RS232CParameterCSB; +static DLword *RS232CGetCSB + , *RS232CPutCSB; + +/* + * File descriptor + */ +extern int LispReadFds; +static int RS232C_Fd; +int RS232CReadFds; + +int RS232C_remain_data; +static char *RS232C_Dev; +static struct termios RS232C_Mode; + +/* + * Following two signal handler vector is used to deal with SIGHUP signal + * which is sent if CLOCAL flag is not set and a modem disconnect + * is detected. + */ + +static struct sigvec rs_hup_sv; +static struct sigvec prev_hup_sv; + +void +rs232c_hup_handler() +{ + printf("Modem disconnect is detected.\n"); + fflush(stdout); + return; +} + +rs_install_hup_handler() +{ + rs_hup_sv.sv_handler = rs232c_hup_handler; + rs_hup_sv.sv_mask = rs_hup_sv.sv_flags = 0; + sigvec(SIGHUP, &rs_hup_sv, &prev_hup_sv); +} + +rs_restore_hup_handler() +{ + sigvec(SIGHUP, &prev_hup_sv, (struct sigvec *)NULL); +} + +/* + * Fatal Error, enter URAID + */ +rs_error(msg) + char *msg; +{ + error(msg); +} + +/* + * Continuable Error + */ +rs_cerror(msg) + char *msg; +{ + printf(msg); +} + +/* + * Invoked at boot time + */ +rs232c_init() +{ + RS232C_Dev = "/dev/ttyb"; /*Modify for target system */ + RS232C_Fd = -1; + + /* Pointer to IOPAGE */ + HardWareConfig = (DLRS232C_HDW_CONF *)&IOPage->dliophardwareconfig; + RS232CGetFlag = (DLRS232C_IOP_GET_FLAG *)&IOPage->dlrs232cgetflag; + RS232CPutFlag = (DLRS232C_IOP_PUT_FLAG *)&IOPage->dlrs232cputflag; + RS232CMiscCommand = (DLRS232C_IOP_MISC_CMD *)&IOPage->dlrs232cmisccommand; + RS232CParameterOutcome = (DLRS232C_PARAMETER_OUTCOME *) + &IOPage->dlrs232cparameteroutcome; + RS232CDeviceStatus = (DLRS232C_DEVICE_STATUS *)&IOPage->dlrs232cdevicestatus; + RS232CParameterCSB = (DLRS232C_PARAMETER_CSB *)&IOPage->dlrs232cparametercsblo_11; + RS232CGetCSB = (DLword *)&IOPage->dlrs232cgetcsblo; + RS232CPutCSB = (DLword *)&IOPage->dlrs232cputcsblo; + + HardWareConfig->rs232c_absent = 0; + RS232CMiscCommand->busy = 0; + +} /* rs232c_init end */ + +#define MIN_CHARS 256 +#define MIN_TIME 1 + +/* + * Default set up for the RS232C file descriptor + * The value of the other parameters not listed below can be changed by user. + */ +rs232_fd_init(fd) + register int fd; +{ + struct termios tio; + + if (ioctl(fd, TCGETS, &tio) < 0) { + rs_error("RS232C: rs232c_fd_init: cannot get status"); + return 0; + } else { + /* Input Mode */ + tio.c_iflag &= ~IGNBRK; + tio.c_iflag &= ~IGNPAR; + tio.c_iflag &= ~IUCLC; + + /* Output Mode */ + tio.c_oflag |= OPOST; + tio.c_oflag &= ~OLCUC; + tio.c_oflag &= ~OFILL; + tio.c_oflag &= ~OFDEL; + tio.c_oflag &= ~NLDLY; + tio.c_oflag &= ~CRDLY; + tio.c_oflag &= ~BSDLY; + tio.c_oflag &= ~VTDLY; + tio.c_oflag &= ~FFDLY; + + /* Control Mode */ + tio.c_cflag |= CREAD; + tio.c_cflag |= HUPCL; + tio.c_cflag &= ~CIBAUD; /* Input Baudrate == Output Baudrate*/ + + /* Local Modes */ + tio.c_lflag &= ~ISIG; + tio.c_lflag &= ~ICANON; + tio.c_lflag &= ~XCASE; + tio.c_lflag &= ~ECHO; + tio.c_lflag &= ~ECHOE; + tio.c_lflag &= ~ECHOK; + tio.c_lflag &= ~ECHONL; + tio.c_lflag &= ~NOFLSH; + tio.c_lflag &= ~TOSTOP; + tio.c_lflag &= ~ECHOCTL; + tio.c_lflag &= ~ECHOPRT; + tio.c_lflag &= ~ECHOKE; + tio.c_lflag &= ~FLUSHO; + tio.c_lflag &= ~PENDIN; + + /* Minimum and Timeout */ + tio.c_cc[VMIN] = MIN_CHARS; + tio.c_cc[VTIME] = MIN_TIME; + + RS232C_Mode = tio; + + if (ioctl(fd, TCSETS, &tio) < 0) + rs_error("RS232C: rs232c_fd_init: cannot set status"); + else + return 1; + } +} + +rs232c_open() +{ + if (RS232C_Fd < 0) { + + if ((RS232C_Fd = open(RS232C_Dev, O_RDWR)) < 0) + rs_error("RS232C: rs232c_open: cannot open"); + else { + rs232_fd_init(); + + /* Receive SIGIO on the descriptor */ + if (ioctl(RS232C_Fd, I_SETSIG, S_INPUT) < 0) + rs_error("RS232C: rs232c_open: cannot set signal"); + else { + rs_install_hup_handler(); + + LispReadFds |= (RS232CReadFds = 1 << RS232C_Fd); + RS232C_remain_data = 0; + } + } + } +} + +rs232c_close() +{ + if (RS232C_Fd >= 0) { + + rs232c_abortinput(); + rs232c_abortoutput(); + + rs_restore_hup_handler(); + + LispReadFds &= ~RS232CReadFds; + +/* + if (close(RS232C_Fd) < 0) + rs_error("RS232C: rs232c_close: cannot close"); +*/ + close(RS232C_Fd); + RS232C_Fd = -1; + } +} + +RS232C_readinit() +{ + if (RS232C_remain_data) { + /* + * There are other data which we have not read yet. + * Signaling SIGIO invokes rs232c_read. + */ + kill(getpid(), SIGIO); + } +} + +rs232c_lisp_is_ready() +{ + return(RS232CGetFlag->busy); +} + +static struct timeval sel_tv = {0, 0}; + +rs232c_read() +{ + register DLRS232C_IOCB *iocb; + register int count; + fd_set readfds; + + if (RS232C_Fd >= 0) { + if (RS232CGetFlag->busy) { + + iocb = (DLRS232C_IOCB*)Addr68k_from_LADDR + (((*(RS232CGetCSB+1) & 0xff)<<16) + *RS232CGetCSB ); + + if ((count = + read(RS232C_Fd, + (char*)Addr68k_from_LADDR + (((iocb->block_pointer_hi & 0xff)<<16) + + iocb->block_pointer_lo), + iocb->byte_count + )) < 0) { + ((DLRS232C_IOCB_TRANSFER_STATUS *) + (&iocb->transfer_status))->success = 0; + RS232CGetFlag->busy = 0; + return; + } + + ((DLRS232C_IOCB_TRANSFER_STATUS *) + (&(iocb->transfer_status)))->success = 1; + iocb->returned_byte_count = count; + RS232CGetFlag->busy = 0; + + /* + * We want to check if the some other data + * remaining or not. + */ + FD_ZERO(&readfds); + FD_SET(RS232C_Fd, &readfds); + if (select(RS232C_Fd + 1, &readfds, NULL, NULL, &sel_tv) > 0) { + if (FD_ISSET(RS232C_Fd, &readfds)) + RS232C_remain_data = 1; + else + RS232C_remain_data = 0; + } else { + RS232C_remain_data = 0; + } + } else { + /* + * SIGIO handler getsignaldata and the successive + * rs232c_read has been called before Lisp prepares + * the next buffer. Turn on RS232C_remain_data to + * specify to read the remaining data after. + */ + RS232C_remain_data = 1; + } + } +} + +#define MAX_WRITE_TRY 5 + +RS232C_write() +{ + register int size, count, trynum; + register char *buf; + register DLRS232C_IOCB *iocb; + + iocb = (DLRS232C_IOCB*) + Addr68k_from_LADDR(((*(RS232CPutCSB+1) & 0xff)<<16) + *RS232CPutCSB ); + + if (RS232CPutFlag->busy && RS232C_Fd >= 0) { + + if (iocb->put) { + for (size = iocb->byte_count, + buf = (char*) + Addr68k_from_LADDR(((iocb->block_pointer_hi & 0xff)<<16) + + iocb->block_pointer_lo); + size > 0; + size -= count, buf += count) { + + trynum = 0; + while (trynum < MAX_WRITE_TRY) { + count = write(RS232C_Fd, buf, size); + if (count >= 0) break; + trynum ++; + } + + if (count < 0) { + ((DLRS232C_IOCB_TRANSFER_STATUS *) + (&(iocb->transfer_status)))->success = 0; + RS232CPutFlag->busy =0; + return; + } + } + + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status))) + ->success = 1; + RS232CPutFlag->busy =0; + } else { + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status))) + ->success = 1; + RS232CPutFlag->busy =0; + } + } else { + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status))) + ->success = 1; + RS232CPutFlag->busy =0; + } +} + +RS232C_cmd() +{ + if (RS232CMiscCommand->busy) { + + switch (RS232CMiscCommand->command) { + case ON: + rs232c_open(); break; + case OFF: + rs232c_close(); break; + case BREAK_ON: + rs232c_breakon(); break; + case BREAK_OFF: + rs232c_breakoff(); break; + case ABORT_INPUT: + rs232c_abortinput(); break; + case ABORT_OUTPUT: + rs232c_abortoutput(); break; + case GET_STATUS: + rs232c_getstatus(); break; + case MAJOR_SET_PARAMETERS: + rs232c_majorparam(); break; + case MINOR_SET_PARAMETERS: + rs232c_minorparam(); break; + default: + rs_error( "RS232C : RS232C_cmd" ); + } + RS232CMiscCommand->busy = 0; + } else { + rs_cerror("RS232C : RS232C_cmd: device busy."); + } + +} + +rs232c_breakon() +{ + + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCSBRK, 0) < 0) + rs_cerror("RS232C: rs232c_breakon"); + } +} + +rs232c_breakoff() +{ + if (RS232C_Fd >= 0) { + if(ioctl(RS232C_Fd, TIOCCBRK, 0) < 0) + rs_cerror("RS232C: rs232c_breakoff"); + } +} + +rs232c_abortinput() +{ + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TCFLSH, 0) < 0) + rs_cerror("RS232C: rs232c_abortinput"); + else + RS232C_remain_data = 0; + } +} + +rs232c_abortoutput() +{ + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TCFLSH, 1) < 0) + rs_cerror("RS232C: rs232c_abortoutput"); + } +} + +rs232c_getstatus() +{ + int status; + + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCMGET, &status) < 0) + rs_error("rs232c_getstatus : cannot get status"); + else { + RS232CDeviceStatus->power_indication + = ((status & TIOCM_LE) == TIOCM_LE); + ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) + ->data_terminal_ready + = ((status & TIOCM_DTR) == TIOCM_DTR); + ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) + ->request_to_send + = ((status & TIOCM_RTS) == TIOCM_RTS); + RS232CDeviceStatus->clear_to_send + = ((status & TIOCM_CTS) == TIOCM_CTS); + RS232CDeviceStatus->carrier_detect + = ((status & TIOCM_CAR) == TIOCM_CAR); + RS232CDeviceStatus->ring_indicator + = ((status & TIOCM_RNG) == TIOCM_RNG); + RS232CDeviceStatus->data_set_ready + = ((status & TIOCM_DSR) == TIOCM_DSR); + } + } +} + +rs_baud(baud) + u_int baud; +{ + switch (baud) { + case 0: return B50; + case 1: return B75; + case 2: return B110; + case 3: return B134; + case 4: return B150; + case 5: return B200; + case 6: return B300; + case 7: return B600; + case 8: return B1200; + case 9: return B1800; + case 10: return B2400; + case 11: return B4800; + case 12: return B9600; + case 13: return B19200; + case 14: return B38400; + default: rs_error("rs_baud: illegal baud rate."); + } +} + +rs_csize(csize) + u_int csize; +{ + switch (csize) { + case 0: return CS5; + case 1: return CS6; + case 2: return CS7; + case 3: return CS8; + default: rs_error("rs_csize: illegal character size"); + } +} + +rs_sbit(sbit) + u_int sbit; +{ + switch (sbit) { + case 0: return 0; + case 1: return CSTOPB; + default: rs_error("rs_bit: illegal stop bit"); + } +} + +rs232c_majorparam() +{ + + register int baud, csize, sbit; + + if (RS232C_Fd >= 0) { + + baud = rs_baud((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->line_speed); + RS232C_Mode.c_cflag &= ~CBAUD; + RS232C_Mode.c_cflag |= baud; + + csize = rs_csize((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->char_length); + RS232C_Mode.c_cflag &= ~CSIZE; + RS232C_Mode.c_cflag |= csize; + if (csize == CS8) + RS232C_Mode.c_iflag &= ~ISTRIP; + else + RS232C_Mode.c_iflag |= ISTRIP; + + switch ((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->parity) { + case ODD: + RS232C_Mode.c_iflag |= INPCK; + RS232C_Mode.c_cflag |= PARENB; + RS232C_Mode.c_cflag |= PARODD; + break; + + case EVEN: + RS232C_Mode.c_iflag |= INPCK; + RS232C_Mode.c_cflag |= PARENB; + RS232C_Mode.c_cflag &= ~PARODD; + break; + + default: + RS232C_Mode.c_iflag &= ~INPCK; + RS232C_Mode.c_cflag &= ~PARENB; + } + + sbit = rs_sbit((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->stop_bits); + RS232C_Mode.c_cflag &= ~CSTOPB; + RS232C_Mode.c_cflag |= sbit; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->flowcontrol_on) { + RS232C_Mode.c_iflag |= IXON; + RS232C_Mode.c_iflag |= IXOFF; + RS232C_Mode.c_cc[VSTART] = (char)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) + ->flowcontrol_xon_char; + RS232C_Mode.c_cc[VSTOP] = (char)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) + ->flowcontrol_xoff_char; + } else { + RS232C_Mode.c_iflag &= ~IXON; + RS232C_Mode.c_iflag &= ~IXOFF; + } + + switch ((u_int) + ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->in_eol) { + case CR: + RS232C_Mode.c_iflag &= ~INLCR; + RS232C_Mode.c_iflag &= ~IGNCR; + RS232C_Mode.c_iflag &= ~ICRNL; + break; + + case LF: + RS232C_Mode.c_iflag |= INLCR; + RS232C_Mode.c_iflag &= ~IGNCR; + RS232C_Mode.c_iflag &= ~ICRNL; + break; + + case CRLF: + default: + RS232C_Mode.c_iflag |= INLCR; + RS232C_Mode.c_iflag |= IGNCR; + } + + switch ((u_int) + ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->out_eol) { + case LF: + RS232C_Mode.c_oflag &= ~ONLCR; + RS232C_Mode.c_oflag &= ~OCRNL; + RS232C_Mode.c_oflag &= ~ONOCR; + RS232C_Mode.c_oflag &= ~ONLRET; + break; + + case CRLF: + RS232C_Mode.c_oflag |= ONLCR; + RS232C_Mode.c_oflag &= ~OCRNL; + RS232C_Mode.c_oflag &= ~ONOCR; + RS232C_Mode.c_oflag &= ~ONLRET; + break; + + case CR: + default: + RS232C_Mode.c_oflag &= ~ONLCR; + RS232C_Mode.c_oflag &= ~OCRNL; + RS232C_Mode.c_oflag &= ~ONOCR; + RS232C_Mode.c_oflag |= ONLRET; + } + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->input_max_bell) + RS232C_Mode.c_iflag |= IMAXBEL; + else + RS232C_Mode.c_iflag &= ~IMAXBEL; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->tab_expand) + RS232C_Mode.c_oflag |= XTABS; + else + RS232C_Mode.c_oflag &= ~XTABS; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->modem_status_line) + RS232C_Mode.c_cflag &= ~CLOCAL; + else + RS232C_Mode.c_cflag |= CLOCAL; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->rts_cts_control) + RS232C_Mode.c_cflag |= CRTSCTS; + else + RS232C_Mode.c_cflag &= ~CRTSCTS; + + if (ioctl(RS232C_Fd, TCSETS, &RS232C_Mode) < 0) + rs_error("rs232c_majorparam: cannot set params"); + else + RS232CParameterOutcome->success = 1; + } +} + +rs232c_minorparam() +{ + + int status; + + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCMGET, &status) < 0) + rs_error("rs_minorparam: cannot get status"); + else { + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) + ->data_terminal_ready) + status |= TIOCM_DTR; + else + status &= ~TIOCM_DTR; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) + ->request_to_send) + status |= TIOCM_RTS; + else + status &= ~TIOCM_RTS; + + if (ioctl(RS232C_Fd, TIOCMSET, &status) < 0) + rs_error("rs_minorparam: cannot set status"); + else + RS232CParameterOutcome->success = 1; + } + } +} + +/* + * Following functions named as check_XXX are used for debug. + */ + +check_params(fd) + int fd; +{ + struct termios tos; + + if (ioctl(fd, TCGETS, &tos) < 0) { + perror("IOCTL"); + exit(1); + } + + check_brate(tos.c_cflag); + check_csize(tos.c_cflag); + check_sbit(tos.c_cflag); + check_parity(tos.c_cflag); + check_oflag(tos.c_oflag); + + check_cannon(&tos); +} + +check_brate(cf) + u_long cf; +{ + int b; + printf("Baud rate : "); + switch (cf & CBAUD) { + case B0: b = 0; break; + case B50: b = 50; break; + case B75: b = 75; break; + case B110: b = 110; break; + case B134: b = 134; break; + case B200: b = 200; break; + case B300: b = 300; break; + case B600: b = 600; break; + case B1200: b = 1200; break; + case B1800: b = 1800; break; + case B2400: b = 2400; break; + case B4800: b = 4800; break; + case B9600: b = 9600; break; + case B19200: b = 19200; break; + case B38400: b = 384000; break; + default: printf("Illeagal.\n"); + } + printf("%d bps.\n", b); +} + + +check_csize(cf) + u_long cf; +{ + int s; + printf("Char size : "); + switch(cf & CSIZE) { + case CS5: s = 5; break; + case CS6: s = 6; break; + case CS7: s = 7; break; + case CS8: s = 8; break; + default: printf("Illeagal.\n"); + } + printf("%d chars.\n", s); +} + +check_sbit(cf) + u_long cf; +{ + int s; + printf("Stop bit : "); + if (cf & CSTOPB) + printf("2 bits.\n"); + else + printf("1 bit.\n"); +} + +check_parity(cf) + u_long cf; +{ + if (cf & PARENB) { + printf("Parity Enabled : "); + if (cf &PARODD) + printf("Odd.\n"); + else + printf("Even.\n"); + } else { + printf("Parity Disabled.\n"); + } +} + +check_cannon(tos) + struct termios *tos; +{ + u_long lf; + + lf = tos->c_lflag; + + if (lf & ICANON) { + printf("Cannonical.\n"); + } else { + printf("Non-Cannonical.\n"); + printf("MIN : %d , TIME : %d\n", + (tos->c_cc)[VMIN], (tos->c_cc)[VTIME]); + } +} + +check_oflag(of) + u_long of; +{ + if ((OPOST & of) == OPOST) { + printf("OPOST : O\n"); + } else { + printf("OPOST : X\n"); + } + + if ((ONLCR & of) == ONLCR) { + printf("ONLCR : O\n"); + } else { + printf("ONLCR : X\n"); + } + if ((OCRNL & of) == OCRNL) { + printf("OCRNL : O\n"); + } else { + printf("OCRNL : X\n"); + } + + if ((ONOCR & of) == ONOCR) { + printf("ONOCR : O\n"); + } else { + printf("ONOCR : X\n"); + } + if ((ONLRET & of) == ONLRET) { + printf("ONLRET : O\n"); + } else { + printf("ONLRET : X\n"); + } + if ((OFILL & of) == OFILL) { + printf("OFILL : O\n"); + } else { + printf("OFILL : X\n"); + } + if ((OFDEL & of) == OFDEL) { + printf("OFDEL : O\n"); + } else { + printf("OFDEL : X\n"); + } + switch (NLDLY & of) { + case NL0: + printf("NL0 \n"); break; + case NL1: + printf("NL1\n"); break; + } + switch (CRDLY & of) { + case CR0: + printf("NL0 \n"); break; + case CR1: + printf("CR1\n"); break; + case CR2: + printf("CR2\n"); break; + case CR3: + printf("CR3\n"); break; + } + switch (TABDLY & of) { + case TAB0: + printf("NL0 \n"); break; + case TAB1: + printf("TAB1\n"); break; + case TAB2: + printf("TAB2\n"); break; + case XTABS: + printf("XTABS\n"); break; + } + switch (BSDLY & of) { + case BS0: + printf("NL0 \n"); break; + case BS1: + printf("BS1\n"); break; + } + switch (VTDLY & of) { + case VT0: + printf("NL0 \n"); break; + case VT1: + printf("VT1\n"); break; + } + switch (FFDLY & of) { + case FF0: + printf("NL0 \n"); break; + case FF1: + printf("FF1\n"); break; + } +} + +/* + * In dbx, "call rsc()". + */ +rsc() +{ + if (RS232C_Fd >= 0) + check_params(RS232C_Fd); +} + +/* Old debug function: not updated. + +rs232c_debug( name, sw ) + char *name; + int sw; +{ + struct sgttyb mode; + + + if ( sw == 1 ) { + + printf("DEBUG: %s\n",name); + + printf("DEBUG: \t\tRS232C_Dev = %s\n", RS232C_Dev); + printf("DEBUG: \t\tRS232C_Fd = %d\n", RS232C_Fd); + + if ( RS232C_Fd >= 0 ) { + ioctl( RS232C_Fd, TIOCGETP, &mode ); + + printf("DEBUG: \t\tRS232C_Mode.sg_ispeed = %#x\n", mode.sg_ispeed ); + printf("DEBUG: \t\tRS232C_Mode.sg_ospeed = %#x\n", mode.sg_ospeed ); + printf("DEBUG: \t\tRS232C_Mode.sg_erase = %#x\n", mode.sg_erase ); + printf("DEBUG: \t\tRS232C_Mode.sg_kill = %#x\n", mode.sg_kill ); + printf("DEBUG: \t\tRS232C_Mode.sg_flags = %#x\n", mode.sg_flags ); + + } /+ if(RS232C_Fd) end +/ + + } /+ if(sw) end +/ + + if ( sw == 2 ) { + + printf("DEBUG: %s\n",name); + + printf("DEBUG:\n"); + printf("DEBUG: \t\tSymbol Address Contents\n"); + printf("DEBUG: \t\tIOPAGE %#x\n",Addr68k_from_LADDR(IOPAGE_OFFSET)); + printf("DEBUG: \t\tHardWareConfig %#x %#x\n", HardWareConfig, *(DLword*) HardWareConfig); + printf("DEBUG: \t\tRS232CGetFlag %#x %#x\n", RS232CGetFlag, *(DLword*) RS232CGetFlag); + printf("DEBUG: \t\tRS232CPutFlag %#x %#x\n", RS232CPutFlag, *(DLword*) RS232CPutFlag); + printf("DEBUG: \t\tRS232CMiscCommand %#x %#x\n", RS232CMiscCommand, *(DLword*) RS232CMiscCommand); + printf("DEBUG: \t\tRS232CGetCSB %#x %#x\n", RS232CGetCSB, (LispPTR) (((*(RS232CGetCSB+1) & 0xff)<<16) + *RS232CGetCSB )); + printf("DEBUG: \t\tRS232CPutCSB %#x %#x\n", RS232CPutCSB, (LispPTR) (((*(RS232CPutCSB+1) & 0xff)<<16) + *RS232CPutCSB )); + printf("DEBUG: \t\tRS232CParameterCSB %#x %#x\n", RS232CParameterCSB, *(DLword*) RS232CParameterCSB); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+1)); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+2)); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+3)); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+4)); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+5)); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+6)); + printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+7)); + if( RS232C_WrIOCB != NULL ) + printf("DEBUG: \t\tRS232C_WrIOCB %#x %#x\n", RS232C_WrIOCB, *((LispPTR*)RS232C_WrIOCB)); + if( RS232C_RdIOCB != NULL ) + printf("DEBUG: \t\tRS232C_RdIOCB %#x %#x\n", RS232C_RdIOCB, *((LispPTR*)RS232C_RdIOCB)); + + /+ + if( RS232C_WrBufAddr != NULL ) + printf("DEBUG: \t\tRS232C_WrBufAddr %s\n" , RS232C_WrBufAddr); + if( RS232C_WrBufAddr != NULL ) + printf("DEBUG: \t\tRS232C_RdBufAddr %s\n" , RS232C_RdBufAddr); + +/ + + } /+ if(sw) end +/ + + } /+ rs232c_debug end +/ + +*/ diff --git a/src/setsout.c b/src/setsout.c new file mode 100755 index 0000000..b24b6cf --- /dev/null +++ b/src/setsout.c @@ -0,0 +1,121 @@ +/* $Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/* + * setsout.c + */ +/************************************************************************/ +/* */ +/* S E T S Y S O U T */ +/* */ +/* */ +/************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "adr68k.h" +#include "lispemul.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "lspglob.h" +#include "ifpage.h" +#include "dbprint.h" + +#define IFPAGE_ADDRESS 512 +#define MBYTE 0x100000 /* 1 Mbyte */ +extern int errno; + +/* JDS protoize char *valloc(size_t); */ + +main(int argc, char **argv) +{ + int version, res; + if (argc < 3) + { + printf("setsysout version sysout-name\n"); + return(-1); + } + if ((version = atoi(argv[1])) == 0) + { + printf("version must be an integer > 0.\n"); + return(-1); + } + set_sysout(version, argv[2]); + exit(0); + } + +set_sysout(int version, char *sysout_file_name) +{ + int sysout; /* SysoutFile descriptor */ + + IFPAGE ifpage; /* IFPAGE */ + + char errmsg [ 255 ]; + + /* + * first read the IFPAGE(InterfacePage) + */ + + /* open SysoutFile */ + sysout = open(sysout_file_name, O_RDWR, NULL); + if (sysout == -1) { + sprintf( errmsg, + "sysout_loader: can't open sysout file: %s", + sysout_file_name); + perror( errmsg ); + exit(-1); + } + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + /* reads IFPAGE into scratch_page */ + if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("sysout_loader: can't read IFPAGE"); + exit(-1); + } + +#ifdef BYTESWAP + word_swap_page(&ifpage, (3+sizeof(IFPAGE))/4); +#endif + + ifpage.lversion = version; + ifpage.minbversion = version; + + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + /* reads IFPAGE into scratch_page */ + if (write(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("Can't write IFPAGE"); + exit(-1); + } + + + close(sysout); + printf("%d", ifpage.minbversion); +} diff --git a/src/shift.c b/src/shift.c new file mode 100755 index 0000000..2e0d6c6 --- /dev/null +++ b/src/shift.c @@ -0,0 +1,111 @@ +/* $Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "emlglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "arith.h" + +#define LSH 0347 + +DLword *createcell68k(unsigned int type); + + +/************************************************************ +N_OP_llsh1 + entry LLSH1 OPCODE[0340] + return(a << 1) +************************************************************/ +N_OP_llsh1(int a) +{ + N_ARITH_BODY_1_UNSIGNED(a, 1, <<); +} + +/************************************************************ +N_OP_llsh8 + entry LLSH8 OPCODE[0341] + return(a << 8) +************************************************************/ +N_OP_llsh8(int a) +{ + N_ARITH_BODY_1_UNSIGNED(a, 8, <<); +} + +/************************************************************ +N_OP_lrsh1 + entry LRSH1 OPCODE[0342] + return(a >> 1) +************************************************************/ +N_OP_lrsh1(int a) +{ + N_ARITH_BODY_1_UNSIGNED(a, 1, >>); +} + +/************************************************************ +N_OP_lrsh8 + entry LRSH8 OPCODE[0343] + return(a >> 8) +************************************************************/ +N_OP_lrsh8(int a) +{ + N_ARITH_BODY_1_UNSIGNED(a, 8, >>); +} + +/************************************************************ +N_OP_lsh + entry LSH OPCODE[0347] + return(a b) +************************************************************/ +N_OP_lsh(int a, int b) +{ +register int arg,arg2; +register int size; +/*DLword *wordp;*/ + + N_GETNUMBER(b, size, do_ufn); + N_GETNUMBER(a, arg2, do_ufn); + + + if (size > 0) { + if (size > 31) goto do_ufn; + arg = arg2 << size; + if ((arg >> size) != arg2) goto do_ufn; + } else + if (size < 0) { + if (size < -31) goto do_ufn; + arg = arg2 >> -size; +/*** Commented out JDS 1/27/89: This punts if you shifted ***/ +/*** ANY 1 bits off the right edge. You CAN'T overflow ***/ +/*** in this direction!! ***/ +/* if ((arg << -size) != arg2) goto do_ufn; */ + } else return(a); + + + + N_ARITH_SWITCH(arg); + +do_ufn: ERROR_EXIT(b); +} + + diff --git a/src/socdvr.c b/src/socdvr.c new file mode 100755 index 0000000..d7b6cbc --- /dev/null +++ b/src/socdvr.c @@ -0,0 +1,322 @@ +/* $Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include +#include +#include +#include + +#include "lispemul.h" +#include "arith.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" + +#define min(x,y) (((x) > (y)) ? (y) : (x)) + + + + /***********************************************************/ + /* L S t r i n g T o C S t r i n g */ + /* */ + /* Convert a lisp string to a C string up to MaxLen long. */ + /***********************************************************/ + +#define LStringToCString(Lisp, C, MaxLen ,Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int i; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ + Len = min(MaxLen, arrayp->fillpointer); \ + \ + switch(arrayp->typenumber) \ + { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *) \ + (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ + + ((int)(arrayp->offset)); \ + for(i=0;ibase))) \ + + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for(i=0;i= 0 ) + { + + packet = (PACKET *) Addr68k_from_LADDR( args[0] ); + + if( (length = (int)(packet->length)-PACKET_DEFOFFSET) > 0 ) + { + buffer = &(packet->data[0]); + + if( (actlen = read( XServer_Fd, buffer, length )) > 0 ) + { + packet->length = (DLword)(actlen + PACKET_DEFOFFSET); + return(ATOM_T); + } /* end if(actlen) */ + if(actlen < 0) /* error !*/ + { + if ((errno != EWOULDBLOCK) & (errno != EINTR)) + perror("reading X connection"); + return(NIL); + } + + } /* end if(length) */ + + } /* end if( fd ) */ + + + return( NIL ); + + } /* end Read_Socket */ + + + +/************************************************************************/ +/* */ +/* W r i t e _ S o c k e t */ +/* */ +/* Write a packet of information to the X server's socket. */ +/* */ +/************************************************************************/ + +Write_Socket( args ) + LispPTR *args; + { + PACKET *packet; + char *buffer; + int length + , actlen; + +#ifdef TRACE + printf( "TRACE: Write_Socket()\n" ); +#endif + + if( XServer_Fd >= 0 ) + { + + packet = (PACKET *) Addr68k_from_LADDR( args[0] ); + + if( (length = (int)(packet->length)-PACKET_DEFOFFSET) > 0 ) + { + buffer = &(packet->data[0]); + + if( (actlen = write( XServer_Fd, buffer, length )) > 0 ) + { + packet->length = (DLword)(actlen + PACKET_DEFOFFSET); + return(ATOM_T); + + } /* end if( actlen ) */ + if(actlen < 0) /* error !*/ + { + if (errno != EINTR) perror("writing X connection"); + return(NIL); + } + + + } /* end if(length) */ + + } /* end if( fd ) */ + + packet->length = 0; + return(NIL); + + } /* end Write_Socket */ + + + + +/************************************************************************/ +/* */ +/* K b d _ T r a n s i t i o n */ +/* */ +/* Stuff a key transition into the C-level buffer from Lisp. */ +/* */ +/* args[0] - the key number (in lisps terms? Not sure) */ +/* args[1] - upflg -- is it an up or down-transition? */ +/* */ +/************************************************************************/ +extern int KBDEventFlg; + +Kbd_Transition( args ) + LispPTR *args; + /* args[0] is key-number */ + /* args[1] is up-flg */ + { + DLword key_number; + + key_number = (DLword)(args[0] & 0xffff); + if( args[1] ) kb_trans( key_number, 1 ); + else kb_trans( key_number, 0 ); + + DoRing(); + /* If there's something for lisp to do, ask for an interrupt: */ + if( (KBDEventFlg += 1) > 0 ) Irq_Stk_End = Irq_Stk_Check = 0; + + } /* end Kbd_Transition */ diff --git a/src/socket.c b/src/socket.c new file mode 100755 index 0000000..e59c04c --- /dev/null +++ b/src/socket.c @@ -0,0 +1,135 @@ +/* $Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ Copyright (C) Venue"; +/* Copyright Massachusetts Institute of Technology 1988 */ +/* + * THIS IS AN OS DEPENDENT FILE! It should work on 4.2BSD derived + * systems. VMS and System V should plan to have their own version. + * + * This code was cribbed from lib/X/XConnDis.c. + * Compile using + * % cc -c socket.c -DUNIXCONN + */ + +#include "version.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef hpux +#include +#endif + +extern int errno; /* Certain (broken) OS's don't have this */ + /* decl in errno.h */ + +#ifdef UNIXCONN +#include +#ifndef X_UNIX_PATH +#define X_UNIX_PATH "/tmp/.X11-unix/X" +#endif /* X_UNIX_PATH */ +#endif /* UNIXCONN */ +void bcopy(); + +/* + * Attempts to connect to server, given host and display. Returns file + * descriptor (network socket) or 0 if connection fails. + */ + +int connect_to_server (host, display) + char *host; + int display; +{ + struct sockaddr_in inaddr; /* INET socket address. */ + struct sockaddr *addr; /* address to connect to */ + struct hostent *host_ptr; + int addrlen; /* length of address */ +#ifdef UNIXCONN + struct sockaddr_un unaddr; /* UNIX socket address. */ +#endif + extern char *getenv(); + extern struct hostent *gethostbyname(); + int fd; /* Network socket */ + { +#ifdef UNIXCONN + if ((host[0] == '\0') || + (strcmp("unix", host) == 0)) { + /* Connect locally using Unix domain. */ + unaddr.sun_family = AF_UNIX; + (void) strcpy(unaddr.sun_path, X_UNIX_PATH); + sprintf(&unaddr.sun_path[strlen(unaddr.sun_path)], "%d", display); + addr = (struct sockaddr *) &unaddr; + addrlen = strlen(unaddr.sun_path) + 2; + /* + * Open the network connection. + */ + if ((fd = socket((int) addr->sa_family, SOCK_STREAM, 0)) < 0) + return(-1); /* errno set by system call. */ + } else +#endif + { + /* Get the statistics on the specified host. */ + if ((inaddr.sin_addr.s_addr = inet_addr(host)) == -1) + { + if ((host_ptr = gethostbyname(host)) == NULL) + { + /* No such host! */ + errno = EINVAL; + return(-1); + } + /* Check the address type for an internet host. */ + if (host_ptr->h_addrtype != AF_INET) + { + /* Not an Internet host! */ + errno = EPROTOTYPE; + return(-1); + } + /* Set up the socket data. */ + inaddr.sin_family = host_ptr->h_addrtype; + bcopy((char *)host_ptr->h_addr, + (char *)&inaddr.sin_addr, + sizeof(inaddr.sin_addr)); + } + else + { + inaddr.sin_family = AF_INET; + } + addr = (struct sockaddr *) &inaddr; + addrlen = sizeof (struct sockaddr_in); + inaddr.sin_port = display + X_TCP_PORT; + inaddr.sin_port = htons(inaddr.sin_port); + /* + * Open the network connection. + */ + if ((fd = socket((int) addr->sa_family, SOCK_STREAM, 0)) < 0){ + return(-1); /* errno set by system call. */} + /* make sure to turn off TCP coalescence */ +#ifdef TCP_NODELAY + { + int mi = 1; + setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (int)); + } +#endif + } + + /* + * Changed 9/89 to retry connection if system call was interrupted. This + * is necessary for multiprocessing implementations that use timers, + * since the timer results in a SIGALRM. -- jdi + */ + while (connect(fd, addr, addrlen) == -1) { + if (errno != EINTR) { + (void) close (fd); + return(-1); /* errno set by system call. */ + } + } + } + /* + * Return the id if the connection succeeded. + */ + return(fd); +} diff --git a/src/storage.c b/src/storage.c new file mode 100755 index 0000000..7424455 --- /dev/null +++ b/src/storage.c @@ -0,0 +1,452 @@ +/* $Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-94 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + +/*****************************************************************/ +/* + File Name : storage.c + +*/ +/*****************************************************************/ + +#include "hdw_conf.h" +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lispmap.h" +#include "stack.h" +#include "lspglob.h" +#include "cell.h" +#include "lsptypes.h" +#include "ifpage.h" +#include "gc.h" + + +#define MINARRAYBLOCKSIZE 4 +#define GUARDVMEMFULL 500 +#define IFPVALID_KEY 5603 + + + + +/*****************************************************************/ +/* + Func Name : checkfor_storagefull(npages) + + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : Oct. 12,1987 take + +*/ +/*****************************************************************/ + + +checkfor_storagefull(register unsigned int npages) +{ + register int pagesleft; + register INTSTAT *int_state; + DLword advance_storagestate(DLword flg); + +#ifdef BIGVM + pagesleft = (*Next_MDSpage_word ) - + (*Next_Array_word) - PAGESPER_MDSUNIT ; +#else + pagesleft = (*Next_MDSpage_word & 0xffff) - + (*Next_Array_word & 0xffff) - PAGESPER_MDSUNIT ; +#endif + + if((pagesleft < GUARDSTORAGEFULL) || (npages !=0)) + { + if (*STORAGEFULLSTATE_word == NIL) set_storage_state(); + + switch(*STORAGEFULLSTATE_word & 0xffff) + { + case SFS_NOTSWITCHABLE : + case SFS_FULLYSWITCHED : + if(pagesleft <0) + { + while(T) + { + error("MP9320:Storage completly full"); + } + } + else if ((pagesleft<=GUARD1STORAGEFULL) + && (*STORAGEFULL_word !=NIL)) + { + *STORAGEFULL_word = S_POSITIVE; + error("MP9325:Space getting VERY full.\ + Please save and reload a.s.a.p."); + } + else if (*STORAGEFULL_word == NIL) + { + *STORAGEFULL_word=ATOM_T; + int_state=(INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); + int_state->storagefull=T; + *PENDINGINTERRUPT_word =ATOM_T; + } +#ifdef DEBUG + printf("\n checkfor_storagefull:DORECLAIM.....\n"); +#endif + return(NIL); + + break; + + case SFS_SWITCHABLE : + if(npages==NIL) + { + if(pagesleft <= 0) + { + *LeastMDSPage_word= *Next_Array_word; + *Next_MDSpage_word= *SecondMDSPage_word; + advance_storagestate(SFS_FULLYSWITCHED); + return(advance_array_seg((*SecondArrayPage_word))); + } + } + else if (npages > pagesleft) + { + /* Have to switch array space over, + but leave MDS to fill the rest of the low pages */ + *LeastMDSPage_word= *Next_Array_word; + advance_storagestate(SFS_ARRAYSWITCHED); + return(advance_array_seg((*SecondArrayPage_word))); + } + break ; +#ifdef BIGVM + case SFS_ARRAYSWITCHED : if((*Next_MDSpage_word) < + (*LeastMDSPage_word)) +#else + case SFS_ARRAYSWITCHED : if((*Next_MDSpage_word & 0xffff) < + (*LeastMDSPage_word & 0xffff)) +#endif + { + *Next_MDSpage_word= *SecondMDSPage_word; + return(advance_storagestate + (SFS_FULLYSWITCHED)); + } + else if (npages != NIL) + if((npages + GUARDSTORAGEFULL) >= +#ifdef BIGVM + ((*SecondMDSPage_word)- + (*Next_Array_word))) +#else + ((*SecondMDSPage_word & 0xffff)- + (*Next_Array_word & 0xffff))) +#endif + return(NIL); + return(T); + /* break; */ + + default : error("checkfor_storagefull: Shouldn't <%d>",(*STORAGEFULLSTATE_word) & 0xffff); + break; + + } + } + else + return(NIL); +}/* checkfor_storagefull end */ + +/*****************************************************************/ +/* + Func Name : advance_array_seg(nxtpage) + + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : + +*/ +/*****************************************************************/ + +advance_array_seg(register unsigned int nxtpage) + /* rare page num */ +{ + + unsigned int ncellsleft; + LispPTR mergebackward(LispPTR base); + LispPTR makefreearrayblock(LispPTR block, DLword length); + + /* Called when 8Mb are exhausted,and we want to switch array space + into the extended area(Secondary space),starting with nextpage. + We MUST clean up old area first. */ + +#ifdef BIGVM + nxtpage &= 0xFFFFF; /* new VM, limit is 20 bits of page */ +#else + nxtpage &= 0xFFFF; /* for old VM size, limit is 16 bits of page */ +#endif + + ncellsleft = + (*Next_Array_word - POINTER_PAGE(*ArrayFrLst_word) -1)* CELLSPER_PAGE + + (CELLSPER_PAGE - (((*ArrayFrLst_word) & 0xff) >> 1) ); + + if(ncellsleft >= MINARRAYBLOCKSIZE) + { + mergebackward(makefreearrayblock(*ArrayFrLst_word , ncellsleft)); +#ifdef BIGVM + *ArrayFrLst2_word = (((*LeastMDSPage_word) ) << 8); +#else + *ArrayFrLst2_word = (((*LeastMDSPage_word) & 0xffff) << 8); +#endif + } +else + { + *ArrayFrLst2_word = *ArrayFrLst_word; + } +#ifdef BIGVM + *Next_Array_word = nxtpage ; +#else + *Next_Array_word = S_POSITIVE | nxtpage ; +#endif + *ArrayFrLst_word = nxtpage << 8 ; + *ArraySpace2_word = *ArrayFrLst_word; + + return(S_POSITIVE); + +} /* advance_array_seg end */ + +/*****************************************************************/ +/* + Func Name : advance_storagestate(flg) + + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : + +*/ +/*****************************************************************/ + +DLword +advance_storagestate(DLword flg) +{ + LispPTR dremove(LispPTR x, LispPTR l); +#ifdef DEBUG + printf("STORAGEFULLSTATE is now set to %d \n",flg); +#endif + + *STORAGEFULLSTATE_word = (S_POSITIVE | flg ); + InterfacePage->fullspaceused = 65535 ; + *SYSTEMCACHEVARS_word = dremove(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word); +} + +/*****************************************************************/ +/* + Func Name : set_storage_state() + + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : + +*/ +/*****************************************************************/ +set_storage_state(void) +{ + LispPTR cons(LispPTR cons_car, LispPTR cons_cdr); + + if((*MACHINETYPE_word & 0xffff)== KATANA) + { + if(InterfacePage->dl24bitaddressable !=0) + *STORAGEFULLSTATE_word = S_POSITIVE | SFS_SWITCHABLE ; + else + *STORAGEFULLSTATE_word = S_POSITIVE | SFS_NOTSWITCHABLE ; + + *SYSTEMCACHEVARS_word = + cons(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word); + + GCLOOKUP(*SYSTEMCACHEVARS_word, ADDREF); + +#ifdef DEBUG + printf("SETSTATE: set to %d \n",(*STORAGEFULLSTATE_word)& 0xffff); +#endif + } + else + { + error("set_storage_state: Sorry! We can work on only KATANA"); + } + +} /* set_storage_state() end */ + + + + + +LispPTR dremove(LispPTR x, LispPTR l) +{ + LispPTR z; + + if( Listp(l)==NIL) return(NIL); + else if (x == car(l)) + { + if(cdr(l)!=NIL) + { + rplaca(l,car(cdr(l))); + rplacd(l,cdr(cdr(l))); + return(dremove(x,l)); + } + } + else + { + z=l; + lp: if(Listp(cdr(l)) ==NIL) + return(z); + else if(x==car(cdr(l))) + rplacd(l , cdr(cdr(l))); + else + l=cdr(l); + goto lp; + } +} + + +/*****************************************************************/ +/* + Func Name : newpage(addr) + + Created : Oct. 12, 1987 Takeshi Shimizu + Changed : Oct. 13, 1987 take + OCt. 20, 1987 take + +*/ +/*****************************************************************/ +LispPTR newpage(LispPTR base) +{ +#ifdef BIGVM + register unsigned int vp; /* Virtual Page we're creating */ +#else + register DLword vp; /* (built from base) */ +#endif /* BIGVM */ + + register INTSTAT *int_state; + + extern LispPTR *LASTVMEMFILEPAGE_word; + extern LispPTR *VMEM_FULL_STATE_word; + unsigned int nactive; + + vp=base >>8; /* Compute virtual-page # from Lisp address of the page */ + +#ifdef DEBUG + /************************/ + if(vp == 0) error ("newpage: vp=0"); + printf("***newpage modify vmemsize %d ",InterfacePage->nactivepages); + /*************************/ +#endif + nactive = ++(InterfacePage->nactivepages); + + /* if nactive is a multiple of the # of FPTOVP entries */ + /* on a page, we need to create a new FPTOVP page. */ +#ifdef BIGVM + if ((nactive & 127) == 0) /* in BIGVM, they're cells */ +#else + if ((nactive & 0xff) == 0) /* in old way, they're words */ +#endif /* BIGVM */ + { /* need to add virtual page for fptovp first */ + unsigned int vp_of_fp, fp_of_fptovp; + + /* compute virtual page of new FPtoVP table page */ + /* i.e., the vp that holds the next FPtoVP entry */ + vp_of_fp = (LADDR_from_68k(FPtoVP+nactive) >> 8); + + /* compute file page where this entry has to be to ensure + that FPtoVP is contiguous on the file */ + + fp_of_fptovp = InterfacePage->fptovpstart + + (vp_of_fp - (LADDR_from_68k(FPtoVP) >> 8)); + + /* debugging check: make sure FPtoVP is contiguous */ + + if (GETFPTOVP(FPtoVP, fp_of_fptovp - 1) != vp_of_fp -1 ) + { + printf ("FPtoVP not contiguous\n"); + printf("vp_of_fp = 0x%x, fp = 0x%x\n", vp_of_fp, fp_of_fptovp); + printf("FPTOVP(fp-1) = 0x%x.\n", GETFPTOVP(FPtoVP,fp_of_fptovp-1)); + } + + /* move the file page for the previous VMEM page */ + GETFPTOVP(FPtoVP, nactive) = GETFPTOVP(FPtoVP, fp_of_fptovp); + + /* now, store virtual page of FPtoVP in FPtoVP table */ + + GETFPTOVP(FPtoVP, fp_of_fptovp) = (vp_of_fp); + + /* now we can make room for the new page we're adding */ + nactive = ++(InterfacePage->nactivepages); + } + GETFPTOVP(FPtoVP, nactive) = vp ; + +#ifdef DEBUG + /*************************/ + printf("to %d with VP:%d \n",InterfacePage->nactivepages,vp); + /************************/ +#endif + + if(InterfacePage->nactivepages > +#ifdef BIGVM + ( ((*LASTVMEMFILEPAGE_word)) - GUARDVMEMFULL ) ) +#else + ( ((*LASTVMEMFILEPAGE_word) & 0xffff) - GUARDVMEMFULL ) ) +#endif + { + /* set vmemfull state */ + if(*VMEM_FULL_STATE_word ==NIL) + { + int_state=(INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); + int_state->vmemfull=T; + *PENDINGINTERRUPT_word =ATOM_T; + } +#ifdef BIGVM + if(InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word) )) +#else + if(InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word) & 0xffff)) +#endif + { + *VMEM_FULL_STATE_word =S_POSITIVE ; /* set 0 */ + } + else if(InterfacePage->key == IFPVALID_KEY) + { + *VMEM_FULL_STATE_word = ATOM_T; + } + else *VMEM_FULL_STATE_word = make_atom("DIRTY",0,5,0); + } + + return(base); + + } /* newpage */ + + + + +/*****************************************************************/ +/* + Func Name : init_storage() + Description: + Set values which are referenced by + Lisp Storage handling funcs + + Created : Apr-23 1990 Takeshi Shimizu + Changed : +*/ +/*****************************************************************/ +init_storage(void) +{ + +#ifdef BIGVM + *SecondMDSPage_word = ( InterfacePage->dllastvmempage + - PAGESPER_MDSUNIT -1); +#else + *SecondMDSPage_word = S_POSITIVE |( InterfacePage->dllastvmempage + - PAGESPER_MDSUNIT -1); +#endif + } /* init_storage */ + diff --git a/src/subr.c b/src/subr.c new file mode 100755 index 0000000..e8d7255 --- /dev/null +++ b/src/subr.c @@ -0,0 +1,786 @@ +/* $Id: subr.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: subr.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + +/***********************************************************/ +/* + File Name : subr.c + Including : OP_subrcall + + Created : May 12, 1987 Takeshi Shimizu + Changed : May 15 87 take + Changed : Jun 2 87 NMitani + Jun. 5 87 take + Jun. 29 87 NMitani + Oct. 13 87 Hayata + Oct. 16 87 take + Nov. 18 87 Matsuda + Dec. 17 1987 Tomtom + 2/17/89 Sybalsky (Add SXHASH) + +*/ +/***********************************************************/ + +#include +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "lspglob.h" +#include "cell.h" +#include "stack.h" +#include "arith.h" +#include "subrs.h" +#include "profile.h" +#include "dbprint.h" + +extern LispPTR *PENDINGINTERRUPT68k; + + +/***********************************************************/ +/* + + Func Name : OP_subrcall + + Last Modify : 13-Oct 1987 take + +*/ +/***********************************************************/ + +#ifdef NATIVETRAN +extern int *c_ret_to_dispatch; +extern int *ret_to_dispatch; +#endif +extern LispPTR Uraid_mess; + +LispPTR subr_lisperror(); /* 0377 */ + +char *atom_to_str(LispPTR atom_index) +{ PNCell *pnptr; + char *pname_base; + + pnptr = (PNCell *) GetPnameCell(atom_index); + pname_base = (char *) Addr68k_from_LADDR(pnptr->pnamebase); + return(pname_base+1); +} /*atom_to_str*/ + +#define POP_SUBR_ARGS \ +{ args[0] = NIL_PTR; \ + if (( arg_num = (argnum/* = (Get_BYTE(PC+2))*/)) > 0) { \ + while(arg_num >0) \ + PopStackTo(args[--arg_num]); \ + } \ +} + +OP_subrcall(int subr_no, int argnum) +{ + static LispPTR args[30]; + int arg_num; + int i; + +PushCStack; /* save TOS in memory */ + +DBPRINT(("Subr call to subr 0%o.\n", subr_no)); + +switch(subr_no) + { + case sb_SHOWDISPLAY :POP_SUBR_ARGS; + DSP_showdisplay(args); + break;/* showdisplay */ + case sb_DSPBOUT : POP_SUBR_ARGS; + DSP_dspbout( args ); + break; /*dspbout */ + case sb_RAID : POP_SUBR_ARGS; + Uraid_mess= args[0]; + PC+= 3; /* for the case of hardreset */ + error("URAID Called:"); + Uraid_mess=NIL; + TopOfStack =NIL; + return; /* Direct return;avoid to increment PC */ + /* break; */ + /*************************/ + /* for Local File System */ + /*************************/ + case sb_COM_OPENFILE : POP_SUBR_ARGS; + TopOfStack = COM_openfile(args); + break; + case sb_COM_CLOSEFILE : POP_SUBR_ARGS; + TopOfStack = COM_closefile(args); + break; + case sb_UFS_GETFILENAME : POP_SUBR_ARGS; + TopOfStack = UFS_getfilename(args); + break; + case sb_UFS_DELETEFILE : POP_SUBR_ARGS; + TopOfStack = UFS_deletefile(args); + break; + case sb_UFS_RENAMEFILE : POP_SUBR_ARGS; + TopOfStack = UFS_renamefile(args); + break; + case sb_COM_READPAGES : POP_SUBR_ARGS; + TopOfStack = COM_readpage(args); + break; + case sb_COM_WRITEPAGES : POP_SUBR_ARGS; + TopOfStack = COM_writepage(args); + break; + case sb_COM_TRUNCATEFILE : POP_SUBR_ARGS; + TopOfStack = COM_truncatefile(args); + break; + case sb_COM_NEXT_FILE : POP_SUBR_ARGS; + TopOfStack = COM_next_file(args); + break; + case sb_COM_FINISH_FINFO : POP_SUBR_ARGS; + TopOfStack = COM_finish_finfo(args); + break; + case sb_COM_GEN_FILES : POP_SUBR_ARGS; + TopOfStack = COM_gen_files(args); + break; + case sb_UFS_DIRECTORYNAMEP : POP_SUBR_ARGS; + TopOfStack = UFS_directorynamep(args); + break; + case sb_COM_GETFILEINFO : POP_SUBR_ARGS; + TopOfStack = COM_getfileinfo(args); + break; + case sb_COM_CHANGEDIR : POP_SUBR_ARGS; + TopOfStack = COM_changedir(args); + break; + case sb_COM_GETFREEBLOCK: POP_SUBR_ARGS; + TopOfStack = COM_getfreeblock(args); + break; + case sb_COM_SETFILEINFO: POP_SUBR_ARGS; + TopOfStack = COM_setfileinfo(args); + break; + + /*************/ + /* for Timer */ + /*************/ + case sb_SETUNIXTIME : POP_SUBR_ARGS; + TopOfStack = subr_settime(args); + break; + case sb_GETUNIXTIME : POP_SUBR_ARGS; + TopOfStack = subr_gettime(args); + break; + case sb_COPYTIMESTATS : POP_SUBR_ARGS; + TopOfStack = subr_copytimestats(args); + break; + + /*************/ + /* for Ether */ + /*************/ + case sb_CHECK_SUM :POP_SUBR_ARGS; + TopOfStack = check_sum(args); + break; + + case sb_ETHER_SUSPEND : POP_SUBR_ARGS; + TopOfStack = ether_suspend(args); + break; + case sb_ETHER_RESUME : POP_SUBR_ARGS; + TopOfStack = ether_resume(args); + break; + case sb_ETHER_AVAILABLE : POP_SUBR_ARGS; + TopOfStack = ether_ctrlr(args); + break; + case sb_ETHER_RESET : POP_SUBR_ARGS; + TopOfStack = ether_reset(args); + break; + case sb_ETHER_GET : POP_SUBR_ARGS; + TopOfStack = ether_get(args); + break; + case sb_ETHER_SEND : POP_SUBR_ARGS; + TopOfStack = ether_send(args); + break; + case sb_ETHER_SETFILTER : POP_SUBR_ARGS; + TopOfStack = ether_setfilter(args); + break; + case sb_ETHER_CHECK: POP_SUBR_ARGS; + TopOfStack = check_ether(); + break; + + /***************/ + /* for Display */ + /***************/ + case sb_DSPCURSOR : POP_SUBR_ARGS; + DSP_Cursor(args, argnum); + break; + case sb_SETMOUSEXY : POP_SUBR_ARGS; + DSP_SetMousePos(args); + break; + case sb_DSP_VIDEOCOLOR : POP_SUBR_ARGS; + TopOfStack = DSP_VideoColor(args); + break; + case sb_DSP_SCREENWIDTH : POP_SUBR_ARGS; + TopOfStack = DSP_ScreenWidth(args); + break; + case sb_DSP_SCREENHEIGHT : POP_SUBR_ARGS; + TopOfStack = DSP_ScreenHight(args); + break; + + /*************************/ + /* for color experiments */ + /*************************/ +#ifdef COLOR + case sb_COLOR_INIT : POP_SUBR_ARGS; + TopOfStack=cgfour_init_color_display(args[0]); + break; + case sb_COLOR_SCREENMODE : POP_SUBR_ARGS; + TopOfStack=cgfour_change_screen_mode(args[0]); + break; + case sb_COLOR_MAP : POP_SUBR_ARGS; + TopOfStack=cgfour_set_colormap(args); + break; + case sb_COLOR_BASE : POP_SUBR_ARGS; + /* retun DLword offsetbetween LISPBASE and Lisp_world */ + TopOfStack=S_POSITIVE |(((int)Lisp_world >> 1) & 0xffff); + break; + + case sb_C_SlowBltChar : POP_SUBR_ARGS; + /* \\SLOWBLTCHAR for 8BITCOLOR */ + C_slowbltchar(args); + break; + case 0215 : POP_SUBR_ARGS; + Uncolorize_Bitmap(args); + break; + case 0216 : POP_SUBR_ARGS; + Colorize_Bitmap(args); + break; + case 0217 : POP_SUBR_ARGS; + Draw_8BppColorLine(args); + break; +#endif /* COLOR */ + + + /***************************/ + /*** bitbltsub, bltchar ***/ + /***************************/ + case sb_BITBLTSUB : POP_SUBR_ARGS; + bitbltsub(args); + break; + case sb_BLTCHAR : POP_SUBR_ARGS; /* argnum * DLwordsperCell*/ + bltchar(args); + break; + case sb_NEW_BLTCHAR : POP_SUBR_ARGS; + newbltchar(args); + break; + case sb_TEDIT_BLTCHAR : POP_SUBR_ARGS; + tedit_bltchar(args); + break; +/* case 209: JDS 4 may 91 - this is code for CHAR-FILLBUFFER?? */ + case sb_BITBLT_BITMAP: POP_SUBR_ARGS; /* BITBLT to a bitmap */ + { + TopOfStack = bitblt_bitmap(args); + break; + } + break; + case 0111/*sb_BITSHADE_BITMAP*/: POP_SUBR_ARGS; /* BITSHADE to a bitmap */ + { + TopOfStack = bitshade_bitmap(args); + break; + } + break; + + + /**************/ + /* For RS232C */ + /**************/ +#ifdef RS232 + case sb_RS232C_CMD: RS232C_cmd(); break; + case sb_RS232C_READ_INIT: RS232C_readinit(); break; + case sb_RS232C_WRITE: RS232C_write(); break; +#endif /* RS232 */ + + + /***********/ + /* for K/B */ + /***********/ + case sb_KEYBOARDBEEP : POP_SUBR_ARGS; + KB_beep(args); + break; + case sb_KEYBOARDMAP : POP_SUBR_ARGS; + KB_setmp(args); + break; + case sb_KEYBOARDSTATE : POP_SUBR_ARGS; + KB_enable(args); + break; + + case sb_VMEMSAVE: POP_SUBR_ARGS; + TopOfStack = vmem_save0(args); + break; + case sb_LISPFINISH: + case sb_LISP_FINISH : POP_SUBR_ARGS; + if((argnum>0)&&(args[0]==S_POSITIVE)) + /* 8/03/88 This branch impossible to take, subr has no args */ + {TopOfStack=suspend_lisp(args);} + else lisp_finish(); + break; + case sb_NEWPAGE : POP_SUBR_ARGS; + TopOfStack = newpage(args[0]); + break; + case sb_DORECLAIM : POP_SUBR_ARGS; + doreclaim(); /* top-level GC function */ + TopOfStack = NIL_PTR; + break; + + /* read & write a abs memory address */ + + case sb_NATIVE_MEMORY_REFERENCE : POP_SUBR_ARGS; + + switch (args[0] & 0xffff) { + case 00: + {register UNSIGNED iarg; + if (argnum != 2) goto ret_nil; + N_GETNUMBER(args[1], iarg, ret_nil); + ARITH_SWITCH(*((LispPTR *) iarg), TopOfStack); + break; + } + + case 01: + {register UNSIGNED iarg,iarg2; + if (argnum != 3) goto ret_nil; + N_GETNUMBER(args[1], iarg, ret_nil); + N_GETNUMBER(args[2], iarg2, ret_nil); + *((LispPTR *) iarg) = iarg2; + break; + } + +#ifdef NATIVETRAN + case 02: /* get an emulator address */ + {register UNSIGNED iarg; + if (argnum != 2) goto ret_nil; + switch (args[1] & 0xffff) { + case 00: iarg = (UNSIGNED) &c_ret_to_dispatch; + break; + case 01: iarg = (UNSIGNED) &ret_to_dispatch; + break; + } + ARITH_SWITCH(iarg, TopOfStack); + break; + } +#endif + } + break; + + ret_nil: TopOfStack = NIL_PTR; + break; + + +#ifdef NATIVETRAN + /* old load native (should be superceeded) */ + case sb_OLD_COMPILE_LOAD_NATIVE : POP_SUBR_ARGS; + { + + TopOfStack = do_system_call(args[0]); + break; + }; +#endif + case sb_DISABLEGC : POP_SUBR_ARGS; + disablegc1(NIL); + TopOfStack = NIL_PTR; + break; + + case sb_GET_NATIVE_ADDR_FROM_LISP_PTR: POP_SUBR_ARGS; + + {ARITH_SWITCH(Addr68k_from_LADDR(args[0]), TopOfStack); + break; + } + + case sb_GET_LISP_PTR_FROM_NATIVE_ADDR: POP_SUBR_ARGS; + + {register UNSIGNED iarg; + N_GETNUMBER(args[0], iarg, ret_nil); + ARITH_SWITCH(LADDR_from_68k(iarg), TopOfStack); + break; + }; + +#ifdef NATIVETRAN + case sb_LOAD_NATIVE_FILE: POP_SUBR_ARGS; + /* to become OBSOLETE */ + {TopOfStack = dynamic_load_code(args); + break; + } +#endif + + case sb_DSK_GETFILENAME : POP_SUBR_ARGS; + TopOfStack = DSK_getfilename(args); + break; + case sb_DSK_DELETEFILE : POP_SUBR_ARGS; + TopOfStack = DSK_deletefile(args); + break; + case sb_DSK_RENAMEFILE : POP_SUBR_ARGS; + TopOfStack = DSK_renamefile(args); + break; + case sb_DSK_DIRECTORYNAMEP : POP_SUBR_ARGS; + TopOfStack = DSK_directorynamep(args); + break; + +/* Communications with Unix Subprocess */ + + case sb_UNIX_HANDLECOMM: POP_SUBR_ARGS; +#ifndef DOS + TopOfStack = Unix_handlecomm(args); +#endif /* DOS */ + break; + +#ifdef OCR + case sb_OCR_COMM: POP_SUBR_ARGS; + TopOfStack = ocr_comm(args); + break; +#endif /* OCR */ + +/* + case 0166: POP_SUBR_ARGS; + error("called SUBR 0166, not defined!!"); + {register int temp; + N_GETNUMBER(TopOfStack, temp, badarg); + temp = (UNSIGNED) Addr68k_from_LADDR(temp); + ARITH_SWITCH(temp, TopOfStack); + break; + badarg: TopOfStack = NIL; + break; + } +*/ +/* OS message print routines */ + + case sb_MESSAGE_READP: POP_SUBR_ARGS; + TopOfStack = mess_readp(); + break; + case sb_MESSAGE_READ: POP_SUBR_ARGS; + TopOfStack = mess_read(args); + break; + + +/* RPC routines */ + + case sb_RPC_CALL: POP_SUBR_ARGS; + TopOfStack = rpc(args); + break; + + +/* Unix username/password utilities */ + + case sb_CHECKBCPLPASSWORD: POP_SUBR_ARGS; + /* Check Unix username/password */ + TopOfStack = check_unix_password(args); + break; + + case sb_UNIX_USERNAME: POP_SUBR_ARGS; + /* Get Unix username */ + TopOfStack = unix_username(args); + break; + + case sb_UNIX_FULLNAME: POP_SUBR_ARGS; + /* Get Unix person-name (GECOS field) */ + TopOfStack = unix_fullname(args); + break; + + case sb_UNIX_GETENV: POP_SUBR_ARGS; + /* get value of environment variable, or NIL */ + TopOfStack = unix_getenv(args); break; + + case sb_UNIX_GETPARM: POP_SUBR_ARGS; + /* get built in parameter */ + TopOfStack = unix_getparm(args); break; + + case sb_SUSPEND_LISP: POP_SUBR_ARGS; + /* Suspend Maiko */ + TopOfStack = suspend_lisp(args); + break; + case sb_MONITOR_CONTROL : POP_SUBR_ARGS; + /* MONITOR CONTROL STOP(0) or RESUME(1) */ +#ifdef PROFILE + moncontrol(args[0] & 1); +#endif /* PROFILE */ + + break; + + /*****************/ + /* Character I/O */ + /*****************/ + case sb_CHAR_OPENFILE: POP_SUBR_ARGS; /* Char-device openfile. */ + TopOfStack = CHAR_openfile(args); + break; + + case sb_CHAR_BIN: POP_SUBR_ARGS; /* Char-device bin. */ + { + TopOfStack = CHAR_bin(args[0], args[1]); + break; + } + break; + + case sb_CHAR_BOUT: POP_SUBR_ARGS; /* Char-device bout. */ + { + TopOfStack = CHAR_bout(args[0], args[1], args[2]); + break; + } + break; + + + case sb_CHAR_IOCTL: POP_SUBR_ARGS; /* Char-device IOCTL. */ + { + TopOfStack = CHAR_ioctl(args); + break; + } + break; + + case sb_CHAR_CLOSEFILE: POP_SUBR_ARGS; /* Char-device CLOSEFILE. */ + { + TopOfStack = CHAR_closefile(args); + break; + } + break; + + case sb_CHAR_BINS: POP_SUBR_ARGS; /* Char-device \BINS. */ + { + TopOfStack = CHAR_bins(args); + break; + } + break; + + case sb_CHAR_BOUTS: POP_SUBR_ARGS; /* Char-device \BOUTS. */ + { + TopOfStack = CHAR_bouts(args); + break; + } + break; + + + case sb_TCP_OP: POP_SUBR_ARGS; /* TCP operations */ + { + TopOfStack = subr_TCP_ops(args[0], args[1], args[2], + args[3], args[4], args[5]); + break; + } + break; + + +#ifdef TRUECOLOR + case sb_PICTURE_OP: { + POP_SUBR_ARGS; + TopOfStack = Picture_Op( args ); + } + break; + case sb_TRUE_COLOR_OP: { + POP_SUBR_ARGS; + TopOfStack = TrueColor_Op( args ); + } + break; +#ifdef VIDEO + case sb_VIDEO_OP: { + POP_SUBR_ARGS; + TopOfStack = Video_Op( args ); + } + break; +#endif /* VIDEO */ + +#endif /* TRUECOLOR */ + + + case sb_PUPLEVEL1STATE: POP_SUBR_ARGS; /* Do nothing with PUP on sun */ + break; + + case sb_WITH_SYMBOL: POP_SUBR_ARGS; /* Symbol lookup */ + { + TopOfStack = with_symbol(args[0], args[1], args[2], args[3], + args[4], args[5]); + break; + } + + case 0222: /* Cause an interrupt to occur. Used by */ + /* Lisp INTERRUPTED to re-set an interrupt */ + /* when it's uninterruptable. */ + { + POP_SUBR_ARGS; + Irq_Stk_Check = Irq_Stk_End=0; + *PENDINGINTERRUPT68k = ATOM_T; + TopOfStack = ATOM_T; + break; + } + /*******************/ + /* CLX Support ops */ + /*******************/ +#ifdef NEVER /* CLX */ + case sb_OPEN_SOCKET: { + POP_SUBR_ARGS; + TopOfStack = Open_Socket( args ); + break; + } + case sb_CLOSE_SOCKET: + { + TopOfStack = Close_Socket(); + break; + } + case sb_READ_SOCKET: + { + POP_SUBR_ARGS; + TopOfStack = Read_Socket( args ); + break; + } + case sb_WRITE_SOCKET: + { + POP_SUBR_ARGS; + TopOfStack = Write_Socket( args ); + break; + } + case 0244: /* KB_TRANSITION */ + { + POP_SUBR_ARGS; + TopOfStack = Kbd_Transition( args ); + break; + } +#endif /* CLX */ + + +#ifndef NOFORN + /*****************************************/ + /* foreign-function-call support subrs */ + /*****************************************/ + case sb_CALL_C_FN: + { + POP_SUBR_ARGS; + TopOfStack = call_c_fn( args ); /* args[0]=fnaddr, args[1]=fn type */ + break; + } + case sb_DLD_LINK: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_link( args ); + break; + } + case sb_DLD_UNLINK_BY_FILE: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_unlink_by_file( args ); + break; + } + case sb_DLD_UNLINK_BY_SYMBOL: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_unlink_by_symbol( args ); + break; + } + case sb_DLD_GET_SYMBOL: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_get_symbol( args ); + break; + } + case sb_DLD_GET_FUNC: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_get_func( args ); + break; + } + case sb_DLD_FUNCTION_EXECUTABLE_P: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_function_executable_p( args ); + break; + } + case sb_DLD_LIST_UNDEFINED_SYM: + { + POP_SUBR_ARGS; + TopOfStack = Mdld_list_undefined_sym( ); + break; + } + case sb_MALLOC: + { + POP_SUBR_ARGS; + TopOfStack = c_malloc( args ); + break; + } + case sb_FREE: + { + POP_SUBR_ARGS; + TopOfStack = c_free( args ); + break; + } + case sb_PUT_C_BASEBYTE: + { + POP_SUBR_ARGS; + TopOfStack = put_c_basebyte( args ); + break; + } + case sb_GET_C_BASEBYTE: + { + POP_SUBR_ARGS; + TopOfStack = get_c_basebyte( args ); + break; + } + case sb_SMASHING_APPLY: + { + POP_SUBR_ARGS; + TopOfStack = smashing_c_fn( args ); + break; + } +#endif /* NOFORN */ + +#ifdef MNW + case sb_FILL_IN: + { + POP_SUBR_ARGS; + TopOfStack = init_mnw_instance( args ); + break; + } + case sb_QUERY_WINDOWS: + { + break; + } + case sb_MNW_OP: + { + POP_SUBR_ARGS; + TopOfStack = dispatch_mnw_method( args ); + break; + } +#endif /* MNW */ + + +#ifdef LPSOLVE + /* Linear-programming solver interface from Lisp */ + case sb_LP_SETUP: + { + POP_SUBR_ARGS; + TopOfStack = lpsetup(args[0], args[1], args[2], args[3], args[4], + args[5], args[6], args[7], args[8], args[9], + args[10]); + break; + } + case sb_LP_RUN: + { + POP_SUBR_ARGS; + TopOfStack = lpmain(args[0]); + break; + } +#endif /* LPSOLVE */ + default : + { + char errtext[200]; + sprintf ( errtext, + "OP_subrcall: Invalid alpha byte 0%o", ((*(PC+1)) & 0xff)); + printf ( "%s\n", errtext ); + error(errtext); + break; + } + + }/* switch end */ + + PC += 3; /* Move PC forward to next opcode */ + + }/* OP_subrcall */ diff --git a/src/subr0374.c b/src/subr0374.c new file mode 100755 index 0000000..36bb8b6 --- /dev/null +++ b/src/subr0374.c @@ -0,0 +1,48 @@ +/* $Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/********************************************************/ +/* + subr_k_trace() + + subr----0130 for katana trace + first argument is base address of + error message in Lisp. + second argument is length of message. +*/ +/********************************************************/ + +#include +#include "lispemul.h" +#include "adr68k.h" +#include "lspglob.h" + +subr_k_trace(LispPTR *args) +{ + int len; + char *base; + + len = 0xFFFF & args[1]; + base = (char *)Addr68k_from_LADDR(args[0]); + while(len-- > 0) + putc(*base++ , stderr); + putc('\n', stderr); + return(0); +} + diff --git a/src/sxhash.c b/src/sxhash.c new file mode 100755 index 0000000..464fc93 --- /dev/null +++ b/src/sxhash.c @@ -0,0 +1,383 @@ +/* $Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include + + + +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "emlglob.h" +#include "adr68k.h" +#include "address.h" +#include "stack.h" +#include "cell.h" +#include "array.h" + +#include "arith.h" + + + +/** Follows definition in LLARRAYELT: **/ +#define EQHASHINGBITS(item) ( (((item)>>16)&0xFFFF) ^ ( (((item)&0x1FFF)<<3) ^ (((item)>>9)& 0x7f) ) ) + + + + +/****************************************************************/ +/* */ +/* SXHASH */ +/* */ +/* C-coded version of the hashing function SXHASH */ +/* */ +/****************************************************************/ +typedef + struct + { + LispPTR object; + } SXHASHARG; + +LispPTR SX_hash (register SXHASHARG *args) +{ + return(S_POSITIVE | ( 0xFFFF & (sxhash(args->object)))); + /* Smash the top of the stack to a 0xe, offset */ + } + +/*****************************************************************/ +/* sxhash */ +/* */ +/* Internal function, called from SXHASH, and used for recursive */ +/* calls, e.g., for hashing lists and compound objects. */ +/* Fails to handle ratios, complex's, bitvectors pathnames & odd */ +/* cases */ +/*****************************************************************/ +sxhash (LispPTR obj) +{ + /* unsigned short hashOffset; Not Used */ + unsigned int cell; + unsigned typen; + OneDArray* str; + switch (SEGMASK & obj) + { + case S_POSITIVE: + case S_NEGATIVE: return(obj & 0xFFFF); + default: switch (typen=GetTypeNumber(obj)) + { + case TYPE_FIXP: return((FIXP_VALUE(obj)) & 0xFFFF); + case TYPE_FLOATP: cell = (unsigned int) FIXP_VALUE(obj); + return((cell&0xFFFF)^(cell>>16)); +#ifdef BIGATOMS + case TYPE_NEWATOM: /* as for LITATOM... */ +#endif /* BIGATOMS */ + + case TYPE_LITATOM: return(EQHASHINGBITS(obj)); + case TYPE_LISTP: return(sxhash_list(obj)); + case TYPE_PATHNAME: return(sxhash_pathname(obj)); + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: str = (OneDArray *) + Addr68k_from_LADDR(obj); + if (str->stringp) + return(sxhash_string(str)); + if (str->bitp) + return(sxhash_bitvec(str)); + return(EQHASHINGBITS(obj)); + case TYPE_BIGNUM: + { + LispPTR contents; + contents = ((BIGNUM *)Addr68k_from_LADDR(obj)) + -> contents; + return ( (unsigned short) car(contents) + + ( ((unsigned short) car(cdr(contents))) <<12)); + } + + case TYPE_COMPLEX: { + COMPLEX *object; + object = (COMPLEX *) + Addr68k_from_LADDR(obj); + return (sxhash(object->real) + ^ sxhash(object->imaginary)); + } + case TYPE_RATIO: { + RATIO *object; + object = (RATIO *) + Addr68k_from_LADDR(obj); + return (sxhash(object->numerator) ^ + sxhash(object->denominator)); + } + + + default: return(EQHASHINGBITS(obj)); + } + } + } + + +#ifndef SUN3_OS3_OR_OS4_IL +/* Rotates the 16-bit work to the left 7 bits (or to the right 9 bits) */ +short unsigned +sxhash_rotate(short unsigned int value) +{ + return ((value<<7) | ((value>>9) & 0x7f)); + } + +#endif + + +sxhash_string(OneDArray *obj) +{ + unsigned i, len, offset; + register unsigned short hash = 0; + len = (unsigned)obj ->fillpointer; + if (len > 13) len = 13; + offset = (unsigned)obj -> offset; + switch (obj -> typenumber) + { + case THIN_CHAR_TYPENUMBER: { + register char *thin; + register unsigned i; + thin = ((char *) + (Addr68k_from_LADDR(obj->base))) + + offset; + for (i=0;ibase))) + + offset; + for (i=0;i fillpointer; + offset = (unsigned)obj -> offset; + base = ((unsigned short *)(Addr68k_from_LADDR(obj->base))) + (offset>>4); + if (offset == 0) + { + hash = (*base); + if (len<16) hash = hash >> (16-len); + } + else + { + bitoffset = offset & 15; + hash = (GETWORD(base++)<<(bitoffset)) | (GETWORD(base)>>(16-bitoffset)); + if ((len-offset) < 16) hash = hash >>(16-(len-offset)); + } + return(hash); + } + + +sxhash_list(LispPTR obj) +{ + unsigned short hash = 0; + int counter; + for (counter = 0; (counter<13)&&(GetTypeNumber(obj)==TYPE_LISTP); counter++) + { + hash = sxhash_rotate(hash^sxhash(car(obj))); + obj = cdr(obj); + } + return(hash); + } + +sxhash_pathname(LispPTR obj) +{ + unsigned short hash = 0; + PATHNAME *path; + path = (PATHNAME *)(Addr68k_from_LADDR(obj)); + hash = sxhash_rotate( sxhash(path->host) ^ sxhash(path->device)); + hash = sxhash_rotate(hash^sxhash(path->type)); + hash = sxhash_rotate(hash^sxhash(path->version)); + hash = sxhash_rotate(hash^sxhash(path->directory)); + hash = sxhash_rotate(hash^sxhash(path->name)); + return(hash); + } + +/****************************************************************/ +/* */ +/* STRING-EQUAL-HASHBITS */ +/* */ +/* C-coded version of the hashing function */ +/* STRING-EQUAL-HASHBITS in LLARRAYELT. */ +/* */ +/****************************************************************/ + + +LispPTR STRING_EQUAL_HASHBITS(SXHASHARG *args) +{ + return(S_POSITIVE | ( 0xFFFF & (stringequalhash(args->object)))); + } /* STRING_EQUAL_HASHBITS */ + +stringequalhash(LispPTR obj) +{ + unsigned i, len, offset, fatp, ind; + register unsigned short hash = 0; + PNCell *pnptr; + DLword *base; + PLCell *Prop; + OneDArray *str; + switch (GetTypeNumber(obj)) + { +#ifdef BIGATOMS + case TYPE_NEWATOM: /* as for LITATOM; it's all in the macros below. */ +#endif /* BIGATOMS */ + + case TYPE_LITATOM: ind = ((int)obj)&POINTERMASK; + pnptr = (PNCell *) GetPnameCell(ind); + base= (DLword *)Addr68k_from_LADDR(pnptr->pnamebase); + Prop = (PLCell *) GetPropCell(ind); + fatp = Prop->fatpnamep; + offset = 1; + len = GETBYTE((unsigned char *)base); + break; + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: str = (OneDArray *) + Addr68k_from_LADDR(obj); + if (str->stringp) + { + fatp=(str->typenumber) == FAT_CHAR_TYPENUMBER; + base = Addr68k_from_LADDR(str->base); + offset = str->offset; + len = str->fillpointer; + } + else return(EQHASHINGBITS(obj)); + break; + default: return(EQHASHINGBITS(obj)); + }; + + + if (fatp) + { + register unsigned short *fat; + register unsigned i; + fat = ((unsigned short *) base) + offset; + for (i=0;iobject)))); + } /* STRING_HASHBITS */ + +stringhash(LispPTR obj) +{ + unsigned i, len, offset, fatp, ind; + register unsigned short hash = 0; + PNCell *pnptr; + DLword *base; + PLCell *Prop; + OneDArray *str; + switch (GetTypeNumber(obj)) + { +#ifdef BIGATOMS + case TYPE_NEWATOM: /* as for LITATOM; it's all in the macros below. */ +#endif /* BIGATOMS */ + + case TYPE_LITATOM: ind = ((int)obj)&POINTERMASK; + pnptr = (PNCell *) GetPnameCell(ind); + base= (DLword *)Addr68k_from_LADDR(pnptr->pnamebase); + Prop = (PLCell *) GetPropCell(ind); + fatp = Prop->fatpnamep; + offset = 1; + len = GETBYTE((unsigned char *) base); + break; + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: str = (OneDArray *) + Addr68k_from_LADDR(obj); + if (str->stringp) + { + fatp=(str->typenumber) == FAT_CHAR_TYPENUMBER; + base = Addr68k_from_LADDR(str->base); + offset = str->offset; + len = str->fillpointer; + } + else return(EQHASHINGBITS(obj)); + break; + default: return(EQHASHINGBITS(obj)); + }; /* switch */ + + + if (fatp) + { + register unsigned short *fat; + register unsigned i; + fat = ((unsigned short *) base) + offset; + for (i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/************************************** +#include "lispemul.h" +#include "lispmap.h" +#include "address.h" +#include "adr68k.h" +#include "lspglob.h" +#include "emlglob.h" +#include "display.h" +#include "devconf.h" + +#include "bb.h" +#include "bitblt.h" +#include "pilotbbt.h" +#include "dbprint.h" ****/ + +struct screen LispScreen; +struct pixrect *CursorBitMap, *InvisibleCursorBitMap; +struct pixrect *SrcePixRect, *DestPixRect; + +int LispWindowFd; +int FrameBufferFd; +int KeyboardFd; + +int DisplayWidth, DisplayHeight, DisplayRasterWidth, DisplayType; +int DisplayByteSize; +short *DisplayRegion68k; /* 68k addr of #{}22,0 */ +struct cursor CurrentCursor, InvisibleCursor; +struct winlock DisplayLockArea; + +extern int errno; + +/************************************** +extern DLword *EmCursorBitMap68K; +extern IFPAGE *InterfacePage; + +int DebugDSP = T; +******************************************/ +/************** provide below so can skip the include files *******/ +#define BITSPER_DLWORD 16 +#define SUN2BW 1 +#define SUN4COLOR 2 +#define CURSORWIDTH 16 +#define CURSORHEIGHT 16 +#define DBPRINT(X) printf X +/************** provide above so can skip the include files *******/ + + + +/* ================================================================ */ + +init_display2(display_addr, display_max) + int display_addr, display_max; +{ + int mmapstat; + int ioctlresult; + char *texture_base, *malloc(); + struct fbtype my_screen; + char groups[PIXPG_OVERLAY+1]; + struct fbgattr FBattr; + struct pixrect *ColorFb; + int mask, kbtype; + + if( (LispWindowFd = win_screennew( &LispScreen )) == -1){ + perror("init_display: can't create LispWindow\n"); + exit( -1 ); + } + else { +#ifdef KBINT + int_io_open(LispWindowFd); +#endif + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); + } + + DisplayRegion68k = (short *) display_addr; + + if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1){ + perror("init_display: can't open FrameBuffer\n"); + exit( -1 ); + } + + if( (KeyboardFd = open( LispScreen.scr_kbdname, 2 )) == -1){ + perror("init_display: can't open Keyboard\n"); + exit( -1 ); + } + + DBPRINT(("LispScreen.scr_kbdname %s\n", LispScreen.scr_kbdname)); + DBPRINT(("LispScreen.scr_fbname %s\n", LispScreen.scr_fbname )); + + if ( ioctl ( KeyboardFd, KIOCTYPE, &kbtype ) != 0 ) { + perror ( "ioctl(KIOCTYPE,..) fails" ); + } + else { + DBPRINT(("ioctl(KIOCTYPE): %d\n", kbtype )); + } + + /* initialize Display parameters */ + if (ioctl(FrameBufferFd, FBIOGTYPE , &my_screen)== -1) { + perror("init_display: can't find screen parameters\n"); + exit( -1 ); + } + DisplayWidth = my_screen.fb_width; + DisplayHeight = my_screen.fb_height; + DisplayRasterWidth = DisplayWidth / BITSPER_DLWORD; + if ((DisplayWidth * DisplayHeight) > display_max){ + DisplayHeight = display_max / DisplayWidth; + } + + DBPRINT(("FBIOGTYPE w x h = %d x %d\n", DisplayWidth, DisplayHeight)); + DBPRINT((" type = %d\n", my_screen.fb_type )); + DBPRINT((" bpp = %d\n", my_screen.fb_depth )); + +/** now attempt to use the FBIOGATTR call for more information **/ + + ioctlresult = ioctl(FrameBufferFd, FBIOGATTR, &FBattr); + if(ioctlresult >= 0 ) { + DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type)); + DBPRINT((" (real) w x h = %d x %d\n", FBattr.fbtype.fb_width, + FBattr.fbtype.fb_height)); + DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type )); + DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth )); + DBPRINT((" emuls = %d %d %d %d %d\n", + FBattr.emu_types[0], + FBattr.emu_types[1], + FBattr.emu_types[2], + FBattr.emu_types[3], + FBattr.emu_types[4] )); + } + else { + DBPRINT(("ioctl(fd,FBIOGATTR,&FBattr) => %d\n", ioctlresult)); + } + + ColorFb = pr_open("/dev/fb"); + + DBPRINT(("pixrect w, h, depth = %d %d %d\n", + ColorFb->pr_size.x, + ColorFb->pr_size.y, ColorFb->pr_depth )); + + pr_getattributes( ColorFb, &mask ); + DBPRINT((" getattrmask = %d\n", mask )); + + groups[0]=0; groups[1]=0; groups[2]=0; groups[3]=0; groups[4]=0; + pr_available_plane_groups( ColorFb, sizeof(groups), groups); + DBPRINT(("plane groups = current: %d\n", groups[0] )); + DBPRINT((" mono : %d\n", groups[1] )); + DBPRINT((" 8bitcol: %d\n", groups[2] )); + DBPRINT((" ovrlyen: %d\n", groups[3] )); + DBPRINT((" ovrly : %d\n", groups[4] )); + + pr_available_plane_groups( ColorFb, sizeof(groups), groups); + + /* try to clear enable plane if it exists */ + + if (groups[PIXPG_OVERLAY] && + groups[PIXPG_OVERLAY_ENABLE] ){ + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, + ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + + { int currgroup; + currgroup = pr_get_plane_group( ColorFb ); + DBPRINT(("current planegroup: %d, unknown: %d\n", + currgroup, currgroup == PIXPG_CURRENT )); + } +/* ================================================================ */ +#ifdef NOTUSED + if (my_screen.fb_type == FBTYPE_SUN2BW){ + if ( ioctlresult ) >= 0) { + if (FBattr.real_type == FBTYPE_SUN4COLOR) { + /* must be color display cgfour */ + /* we've already gotten the plane groups from above */ + if (groups[PIXPG_OVERLAY] && + groups[PIXPG_OVERLAY_ENABLE] ){ + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, + ColorFb->pr_width, + ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + } + else { /* not cgfour */ + printf("initdisplay: Unsupported FBTYPE %d\n", + FBattr.real_type); + } + } /* if ioctlresult...... */ + }/* if ...FBTYPE_SUN2BW end */ +#endif +/* ================================================================ */ + + DisplayLockArea.wl_rect.r_width = DisplayWidth; + DisplayLockArea.wl_rect.r_height = DisplayHeight; + init_cursor(); + DisplayByteSize= ((DisplayWidth * DisplayHeight / 8 + (getpagesize()-1) ) + & -getpagesize()); + + DBPRINT(("Display Addr: 0x%x\n",DisplayRegion68k)); + DBPRINT(("length: 0x%x\n",DisplayByteSize)); + DBPRINT(("page size: 0x%x\n",getpagesize())); + + mmapstat = (int)mmap( DisplayRegion68k, + DisplayByteSize, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0 ); + + DBPRINT(("after mmap: 0x%x\n",mmapstat)); + + if(mmapstat == -1){ + perror("init_display: ERROR at mmap system call\n"); + exit( 0 ); + } + + DBPRINT(("before clear display()\n")); + + clear_display(); + + DBPRINT(("after clear_display()\n")); + + /* initialize pixrects used in pilotbitblt (internal will change) */ + SrcePixRect = mem_point( 0, 0, 1, NULL ); + DestPixRect = mem_point( 0, 0, 1, NULL ); + + DBPRINT(("before set_cursor\n")); +} + +/* ================================================================ */ + +init_cursor() + { + CursorBitMap = mem_create( CURSORWIDTH, CURSORHEIGHT, 1 ); + mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3;/* 2(byte) */ + CurrentCursor.cur_xhot = 0; + CurrentCursor.cur_yhot = 0; + CurrentCursor.cur_shape = CursorBitMap; + CurrentCursor.cur_function = PIX_SRC | PIX_DST; + + /* Invisible Cursor */ + InvisibleCursorBitMap = mem_create( 0, 0, 1 ); + InvisibleCursor.cur_xhot = 0; + InvisibleCursor.cur_yhot = 0; + InvisibleCursor.cur_shape = InvisibleCursorBitMap; + InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST; + + win_setcursor( LispWindowFd, &InvisibleCursor); + win_setmouseposition(LispWindowFd, 0, 0); + } + +/* ================================================================ */ + +display_before_exit() + { + clear_display(); + + win_screendestroy( LispWindowFd ); +#ifdef KBINT + int_io_close(LispWindowFd); +#endif + close( LispWindowFd ); + } + +/* ================================================================ */ + +clear_display() + { + register short *word; + register int w, h; + word = DisplayRegion68k; + for (h = DisplayHeight; (h--);) + { + for (w = DisplayRasterWidth; (w--);) {*word++ = 0;} + } + } + +/* ================================================================ */ + +paint_display() + { + register short *word; + register int w, h; + word = DisplayRegion68k; + for (h = DisplayHeight; (h--);) + { + for (w = DisplayRasterWidth; (w--);) {*word++ = w;} + } + } + +/* ================================================================ */ + +#define BYTESPER_PAGE 512 + +read_datum( lispworld ) + char *lispworld; + { + int srcefile; /* fd */ + int i, j, sysout_size; + int lispworld_offset; + struct stat stat_buf; + char *charptr; + int readresult; + char bigbuff [ BYTESPER_PAGE ]; + + srcefile = open("fake.sysout", O_RDONLY, NULL); + + /* get sysout file size in halfpage(256) */ + if (fstat( srcefile, &stat_buf) == -1) { + perror("read_datum: can't get srcefile size (fstat fails)"); + exit(-1); + } + sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2; + + DBPRINT(("file size = %d\n", stat_buf.st_size )); + DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2)); + + lispworld_offset = 0; + for (i = 0; i < (sysout_size / 2); i++) { + lispworld_offset += BYTESPER_PAGE; + charptr = (char *) lispworld + lispworld_offset; +#ifdef BUFFER + readresult = read(srcefile, bigbuff, BYTESPER_PAGE); + for ( j = 0; j < BYTESPER_PAGE; j++ ) { + *(charptr + j) = bigbuff [ j ]; + } +#else + readresult = read(srcefile, charptr, BYTESPER_PAGE); +#endif + if ( readresult == -1) { + printf("read_datum: can't read srcefile file at %d\n", i); + perror("read() error was"); + exit(-1); + }; + }; + DBPRINT(("srcefile is read completely\n")); + close(srcefile); + } + +/* ================================================================ */ + +int_io_open() {}; /* stubs for other parts of our prog. */ +int_io_close() {}; /* stubs for other parts of our prog. */ + + +main() + { + int maxdisplayregion; /* in what units? */ + int realaddr; + + realaddr = valloc( 5000000 ); + if ( realaddr == 0 ) { + printf ( "valloc returns 0\n" ); + } + else { + maxdisplayregion = 4000000; /* assume 4Mb display reg. */ + init_display2( realaddr, maxdisplayregion ); + paint_display(); + sleep ( 4 ); + + DBPRINT(("before read_datum\n")); + read_datum( realaddr ); + + sleep ( 4 ); + display_before_exit(); + } + } diff --git a/src/testtool.c b/src/testtool.c new file mode 100755 index 0000000..8b2f811 --- /dev/null +++ b/src/testtool.c @@ -0,0 +1,1342 @@ +/* $Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/***************************************************************/ +/* + file name : testtool.c + + For Debugging Aids + + Including : + dump_check_atoms() + print_atomname(index) + dump_dtd() + check_type_68k(type,ptr) + type_num(LISPPTR) + dump_conspage(base , linking ) + trace_listpDTD() + a68k( lispptr) + laddr(addr68k) + dump_fnobj(index) + dump_fnbody(lisp-codeaddr) + doko() + dumpl(laddr) + ptintPC() + all_stack_dump(start,end) + + date : 14 May 1987 takeshi + 15 May 1987 take + 1 June 1987 take + 21 June 1987 NMitani + 9 Sep. 1987 take + + +*/ +#include +#include +#ifdef AIX +#include +#endif /* AIX */ + +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "emlglob.h" +#include "cell.h" +#include "stack.h" +#include "ifpage.h" +#include "debug.h" +#include "dbprint.h" +#include "tosfns.h" + + + +#define URMAXFXNUM 100 +#define URSCAN_ALINK 0 +#define URSCAN_CLINK 1 +extern int URaid_scanlink; +extern int URaid_currentFX; +extern FX *URaid_FXarray[]; +extern int URaid_ArrMAXIndex; + +/************************************************************************/ +/* */ +/* P R I N T _ A T O M N A M E */ +/* */ +/* Given the Atom # for an atom, print the atom's name. */ +/* */ +/************************************************************************/ + +print_atomname(LispPTR index) + /* atomindex */ +{ + + char *pname; + DLword length; + PNCell *pnptr; + + pnptr =(PNCell *)GetPnameCell( index); + print_package_name(pnptr->pkg_index); + pname=(char *) Addr68k_from_LADDR(pnptr->pnamebase); + + length = (DLword) GETBYTE(pname++); + + while(length >0){ + putchar(GETBYTE(pname++)); + length--; + } + +} /* end print_atomname */ + + +/************************************************************************/ +/* */ +/* F I N D _ P A C K A G E _ F R O M _ N A M E */ +/* */ +/************************************************************************/ + +#define PACKAGES_LIMIT 255 +/** GET PACKAGE INDEX from PACKAGE FULL NAME */ +find_package_from_name(char *packname, int len) +{ + int index; + PACKAGE *package; + NEWSTRINGP *namestring; + DLword len2; + char *pname; + + for(index =1; index <= PACKAGES_LIMIT; index++) + { + package = (PACKAGE *)Addr68k_from_LADDR( + aref1(*Package_from_Index_word, index)); + namestring = (NEWSTRINGP*)Addr68k_from_LADDR(package->NAME); + pname = (char*)Addr68k_from_LADDR(namestring->base); + if(namestring->offset != 0) + { + pname += namestring->offset; + } + + len2 = (DLword)(namestring->fillpointer); + if(len == len2) + { + if(compare_chars(pname, packname, len)==T) + { + return(index); + } + } + } /* for end */ + return(-1); +} + + +/************************************************************************/ +/* */ +/* P R I N T _ P A C K A G E _ N A M E */ +/* */ +/************************************************************************/ + + +print_package_name(int index) +{ + PACKAGE *package; + NEWSTRINGP *namestring; + DLword len; + char *pname; + + if(index == 0) + { + printf("#:"); + return; + } + package = (PACKAGE *)Addr68k_from_LADDR( + aref1(*Package_from_Index_word, index)); + namestring = (NEWSTRINGP*)Addr68k_from_LADDR(package->NAME); + pname = (char*)Addr68k_from_LADDR(namestring->base); + if(namestring->offset != 0) + { + pname += namestring->offset; + printf("OFFSET:\n"); + } + len = (DLword)(namestring->fillpointer); + + if(compare_chars(pname , "INTERLISP", len) == T) + { + printf("IL:"); + return; + } + else if(compare_chars(pname , "LISP", len) == T) + { + printf("CL:"); + return; + } + else if(compare_chars(pname , "XEROX-COMMON-LISP", len) == T) + { + printf("XCL:"); + return; + } + else if(compare_chars(pname , "SYSTEM", len) == T) + { + printf("SI:"); + return; + } + else if(compare_chars(pname , "KEYWORD", len) == T) + { + printf(":"); + return; + } + else if(compare_chars(pname , "COMPILER", len) == T) + { + printf("XCLC:"); + return; + } + else + { + while(len >0) + { + putchar(GETBYTE(pname++)); + len--; + } + putchar(':'); + return; + } + + } /*print_package_name */ + + + +/************************************************************************/ +/* */ +/* d u m p _ d t d */ +/* */ +/* */ +/* */ +/************************************************************************/ + +dump_dtd(void) +{ + extern DLword *DTDspace; + struct dtd *dtdp; + DLword cnt; + + dtdp = (struct dtd *)DTDspace; + dtdp++; + + for (cnt = 0; cnt < INIT_TYPENUM; cnt ++) + { + printf("DTD[ %d ] for ",cnt+1); +#ifdef BIGVM + print_atomname(dtdp->dtd_name); +#else + print_atomname(dtdp->dtd_namelo + (dtdp->dtd_namehi << 16)); +#endif /* BIGVM */ + putchar('\n'); + +#ifdef BIGVM + printf(" dtd_name = %d\n",dtdp->dtd_name); +#else + printf(" dtd_name = %d\n",dtdp->dtd_namelo + + (dtdp->dtd_namehi << 16)); +#endif /* BIGVM */ + printf(" dtd_size = %d\n",dtdp->dtd_size); + printf(" dtd_free = %d\n",dtdp->dtd_free); + printf(" dtd_obsolate = %d\n",dtdp->dtd_obsolate); + printf(" dtd_finalizable = %d\n",dtdp->dtd_finalizable); + printf(" dtd_lockedp = %d\n",dtdp->dtd_lockedp); + printf(" dtd_hunkp = %d\n",dtdp->dtd_hunkp); + printf(" dtd_gctype = %d\n",dtdp->dtd_gctype); + printf(" dtd_descrs = %d\n",dtdp->dtd_descrs); + printf(" dtd_typespecs = %d\n",dtdp->dtd_typespecs); + printf(" dtd_ptrs = %d\n",dtdp->dtd_ptrs); + printf(" dtd_oldcnt = %d\n",dtdp->dtd_oldcnt); + printf(" dtd_cnt0 = %d\n",dtdp->dtd_cnt0); + printf(" dtd_nextpage = %d\n",dtdp->dtd_nextpage); + printf(" dtd_typeentry = 0x%x\n",dtdp->dtd_typeentry); + printf(" dtd_supertype = %d\n",dtdp->dtd_supertype); + + dtdp++; + } + + } /* end dump dtd */ + + + + +/************************************************************************/ +/* */ +/* c h e c k _ t y p e _ 6 8 k */ +/* */ +/* Check that the lisp pointer ptr is of type type, then */ +/* print a message showing the type number. */ +/* */ +/************************************************************************/ + +check_type_68k(int type, LispPTR *ptr) +{ + if (type != (GetTypeNumber(LADDR_from_68k(ptr)) ) ) + { + + printf("Mismatching occur !!! LispAddr 0x%x type %d\n",LADDR_from_68k(ptr) + ,type); + exit(-1); + } + + printf("LispPTR 0x%x is the datatype %d\n", LADDR_from_68k(ptr) + ,GetTypeNumber(LADDR_from_68k(ptr)) ); +} + + + +/************************************************************************/ +/* */ +/* t y p e _ n u m */ +/* */ +/* Given a lisp pointer, return its type number. */ +/* */ +/************************************************************************/ + +type_num(LispPTR lispptr) +{ + int type; + type = GetTypeNumber(lispptr); + + printf("LispPTR 0x%x is datatype %dth\n",lispptr,type); + return(type); +} + + + + +/************************************************************************/ +/* */ +/* d u m p _ c o n s p a g e */ +/* */ +/* Print information about a CONS page, and the cells in it. */ +/* */ +/************************************************************************/ + +dump_conspage(struct conspage *base, int linking) + /* target conspage address */ + /* look for chaiing conspage ? T/NIL */ + { + + ConsCell *cell; + int i; + +lp: + printf("conspage at 0x%x(lisp) has %d free cells , next available cell offset is %d ,and next page is 0x%x(lisp)\n", + LADDR_from_68k(base), (0xff & base->count), + (0xff & base->next_cell), base->next_page ); + + + for( i = 0 , cell = (ConsCell *)base+1; i <127; i++,cell++) + { + printf(" LADDR : %d = Cell[ %d ]## cdr_code= %d ,car = %d\n", + LADDR_from_68k(cell),i+1,cell->cdr_code,cell->car_field); + + } + + if ((linking==T) && (base->next_page != NIL_PTR)) + { + base =(struct conspage *) Addr68k_from_LPAGE(base->next_page); + goto lp; + } + + + } /* end dump_conspage */ + +/*********************************/ +/* trace the link in ListpDTD->dtd_nextpage */ + +trace_listpDTD(void) +{ +extern struct dtd *ListpDTD; + printf("Dump conspages from ListpDTD chain\n"); + dump_conspage((struct conspage *)Addr68k_from_LPAGE(ListpDTD->dtd_nextpage) , T); + +} + + + +/************************************************************************/ +/* */ +/* a 6 8 k */ +/* */ +/* Given a lisp pointer, print the corresponding native address. */ +/* */ +/************************************************************************/ + +a68k(LispPTR lispptr) +{ + DLword *val; + val = Addr68k_from_LADDR(lispptr); + printf("68k: 0x%x (%d)\n", val, val); + } + + + +/************************************************************************/ +/* */ +/* l a d d r */ +/* */ +/* Given a native address, print the corresponding lisp ptr. */ +/* */ +/************************************************************************/ + +laddr(DLword *addr68k) +{ + int val; + val = LADDR_from_68k(addr68k); + printf("LADDR : 0x%x (%d)\n", val, val); + } + + + +/************************************************************************/ +/* */ +/* d u m p _ f n o b j */ +/* */ +/* Given an atom number, dump that atom's definition. */ +/* */ +/************************************************************************/ + +#define DUMPSIZE 40 + +dump_fnobj(LispPTR index) + /* atom index */ + { + struct fnhead *fnobj; + DefCell *defcell68k; + LispPTR cell; + DLbyte *scratch; + int i; + + + defcell68k = (DefCell *)GetDEFCELL68k(index); + + dump_fnbody(*defcell68k); + + } /*dump_fnobj end */ + + + + + +/************************************************************************/ +/* */ +/* d u m p _ f n b o d y */ +/* */ +/* Given the (Lisp) address of a function header, dump the */ +/* function's definition. */ +/* */ +/************************************************************************/ + +dump_fnbody(LispPTR fnblockaddr) + /* atom index */ + { + struct fnhead *fnobj; + DefCell *defcell68k; + LispPTR cell; + DLbyte *scratch; + int i; + + + fnobj = (struct fnhead *)Addr68k_from_LADDR(fnblockaddr); + + + printf("***DUMP Func Obj << "); + printf("start at 0x%x lisp address(0x%x 68k)\n", + LADDR_from_68k(fnobj),fnobj); + + print(fnobj->framename); + putchar('\n'); + + printf("stkmin : %d\n",fnobj->stkmin); + printf("na : %d\n",fnobj->na); + printf("pv : %d\n",fnobj->pv); + printf("startpc : %d\n",fnobj->startpc); + printf("argtype : %d\n",fnobj->argtype); + printf("framename : %d\n",fnobj->framename); + printf("ntsize : %d\n",fnobj->ntsize); + printf("nlocals : %d\n",fnobj->nlocals); + printf("fvaroffset: %d\n",fnobj->fvaroffset); + + scratch= (DLbyte *)fnobj; + for (i= 20; i<(fnobj->startpc); i+=2) + { + int word; + word = (int)(0xffff & (GETWORD((DLword *)(scratch+i)))) ; + printf(" 0x%x(0x%x 68k): 0%6o 0x%4x\n", + LADDR_from_68k(scratch+i), scratch+i, + word, word); + } + + scratch= (DLbyte *)fnobj + (fnobj->startpc); + for (i= 0; i< 2000; i++) + { + int len = print_opcode(fnobj->startpc+i, scratch, fnobj); + if (len < 1) return; + scratch += len; + i += (len -1); + } + + +} /*dump_fnbody end */ + + + +/************************************************************************/ +/* */ +/* p r i n t _ o p c o d e */ +/* */ +/* Print a single opcode's worth of a function body. */ +/* */ +/************************************************************************/ + + /* Opcode names, by opcode */ +char * opcode_table[256] = + { "-X-", "CAR", "CDR", "LISTP", "NTYPX", "TYPEP", "DTEST", "UNWIND", + "FN0", "FN1", "FN2", "FN3", "FN4", "FNX", "APPLYFN", "CHECKAPPLY*", + "RETURN", "BIND", "UNBIND", "DUNBIND", "RPLPTR.N", "GCREF", "ASSOC", "GVAR_", + "RPLACA", "RPLACD", "CONS", "CMLASSOC", "FMEMB", "CMLMEMBER", "FINDKEY", "CREATECELL", + "BIN", "BOUT", "PROLOG", "RESTLIST", "MISCN", "<>", "RPLCONS", "LISTGET", + "ELT", "NTHCHC", "SETA", "RPLCHARCODE", "EVAL", "ENVCALL", "TYPECHECK.N", "STKSCAN", + "BUSBLT", "MISC8", "UBFLOAT3", "TYPEMASK.N", "PROLOG", "PROLOG", "PROLOG", "PROLOG", + "PSEUDOCOLOR", "<>", "EQL", "DRAWLINE", "STORE.N", "COPY.N", "RAID", "\\RETURN", + "IVAR0", "IVAR1", "IVAR2", "IVAR3", "IVAR4", "IVAR5", "IVAR6", "IVARX", + "PVAR0", "PVAR1", "PVAR2", "PVAR3", "PVAR4", "PVAR5", "PVAR6", "PVARX", + "FVAR0", "FVAR1", "FVAR2", "FVAR3", "FVAR4", "FVAR5", "FVAR6", "FVARX", + "PVAR_0", "PVAR_1", "PVAR_2", "PVAR_3", "PVAR_4", "PVAR_5", "PVAR_6", "PVAR_X", + "GVAR", "ARG0", "IVARX_", "FVARX_", "COPY", "MYARGCOUNT", "MYALINK", "ACONST", + "'NIL", "'T", "'0", "'1", "SIC", "SNIC", "SICX", "GCONST", + "ATOMNUMBER", "READFLAGS", "READRP", "WRITEMAP", "RPPORT", "WPRTPORT", "PILOTBBT", "RCLK", + "MISC1", "MISC2", "RECCELL", "GCSCAN1", "GCSCAN2", "SUBRCALL", "CONTEXT", "<>", + "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", + "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", + "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", + "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", + "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", + "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", + "JUMPX", "JUMPXX", "FJUMPX", "TJUMPX", "NFJUMPX", "NTJUMPX", "AREF1", "ASET1", + "PVAR_0^", "PVAR_1^", "PVAR_2^", "PVAR_3^", "PVAR_4^", "PVAR_5^", "PVAR_6^", "POP", + "POP.N", "ATOMCELL.N", "GETBASEBYTE", "INSTANCEP", "BLT", "MISC10", "<>", "PUTBASEBYTE", + "GETBASE.N", "GETBASEPTR.N", "GETBITS.N.FD", "<>", "CMLEQUAL", "PUTBASE.N", "PUTBASEPTR.N", "PUTBITS.N.FD", + "ADDBASE", "VAG2", "HILOC", "LOLOC", "PLUS2", "DIFFERENCE", "TIMES2", "QUOTIENT", + "IPLUS2", "IDIFFERENCE", "ITIMES2", "IQUOTIENT", "IREMAINDER", "IPLUS.N", "IDIFFERENCE.N", "<>", + "LLSH1", "LLSH8", "LRSH1", "LRSH8", "LOGOR2", "LOGAND2", "LOGXOR2", "LSH", + "FPLUS2", "FIDFFERENCE", "FTIMES2", "FQUOTIENT", "UBFLOAT2", "UBFLOAT1", "AREF2", "ASET2", + "EQ", "IGREATERP", "FGREATERP", "GREATERP", "EQUAL", "MAKENUMBER", "BOXIPLUS", "BOSIDIFFERENCE", + "FLOATBLT", "FFTSTEP", "MISC3", "MISC4", "UPCTRACE", "SWAP", "NOP", "CL=" + + }; + + +print_opcode(int pc, DLbyte *addr, struct fnhead *fnobj) +{ + /* Print the opcode at addr, including args, and return length */ + /* if this opcode is the last, return -1 */ + int op = (int) (0xFF & GETBYTE(addr)); + int i; + extern unsigned int oplength[256]; + int len =oplength[op]+1; + + printf(" 0%o (0x%x) ", pc, pc); + for (i=0; iframename); + putchar('\n'); + printf(" PC cnt = 0%o\n" ,tmp.pc=((UNSIGNED)(PC)- (UNSIGNED)FuncObj) ); + tmp.func= FuncObj->framename; + return(tmp); + } + + + +/**** dump specified area (in 32 bit width) ***/ +dumpl(LispPTR laddr) +{ + int i; + LispPTR *ptr; + + ptr = (LispPTR *)Addr68k_from_LADDR(laddr); + + + for(i=0; i< 40; i++,ptr++) + printf("LADDR 0x%x : %d\n", LADDR_from_68k(ptr), *ptr); + + } + +/**** dump specified area (in 16 bit width) ***/ + +dumps(LispPTR laddr) +{ + int i; + DLword *ptr; + + ptr = (DLword *)Addr68k_from_LADDR(laddr); + + + for(i=0; i< 40; i++,ptr++) + printf("LADDR 0x%x : %d\n", LADDR_from_68k(ptr), (GETWORD(ptr)& 0xffff)); + + } + + + +/***********************/ +printPC(void) +{ + unsigned short pc; + + pc =(UNSIGNED)PC - (UNSIGNED)FuncObj; + + printf("PC: O%o ",pc); + } + + +/***************************/ +countchar(char *string) +{ + int cnt=0; + + while(*string != '\0') { string++; cnt++;} + + return(cnt); + } + + +/***************************************************************/ +/* + Func Name : dump_stackframe + Desc : For Debugging Aids + Changed 8 JUN 1987 TAKE + +*/ +/***************************************************************/ +dump_stackframe(struct frameex1 *fx_addr68k) +{ + Bframe *bf; + if((fx_addr68k->alink & 1)==0) + { /* FAST */ + bf = (Bframe *)(((DLword *)fx_addr68k) - 2 ); + } + else + { /* SLOW */ + bf =(Bframe *) Addr68k_from_LADDR((fx_addr68k->blink+ STK_OFFSET)); + } + dump_bf(bf); + dump_fx((struct frameex1 *)fx_addr68k); + } + + + +dump_bf(Bframe *bf) +{ + DLword *ptr; + printf("\n*** Basic Frame"); + if (BFRAMEPTR(bf)->flags != 4) + { + printf("\nInvalid basic frame"); + return(0); + }; + + if (BFRAMEPTR(bf)->residual) {goto printflags;} + + ptr = Addr68k_from_LADDR( STK_OFFSET + bf->ivar); + if ( (((DLword*)bf - ptr) > 512) || (( (UNSIGNED)ptr & 1) != 0) ) + { + printf("\nInvalid basic frame"); + return(0); + } + while(ptr < (DLword *)bf) + { + printf("\n %x : %x %x", LADDR_from_68k(ptr), + GETWORD(ptr), GETWORD(ptr+1)); + print(*ptr); + ptr+=2; + } + +printflags: + printf("\n %x : %x %x ",LADDR_from_68k(bf),*bf, *(bf+1)); + putchar('['); + if (BFRAMEPTR(bf)->residual) printf("Residual, "); + if (BFRAMEPTR(bf)->padding) printf("Padded, "); + printf("usecnt=%d ] ",BFRAMEPTR(bf)->usecnt); + printf("ivar : 0x%x",BFRAMEPTR(bf)->ivar); + +} + +dump_fx(struct frameex1 *fx_addr68k) +{ + DLword *next68k; + DLword *ptr; + LispPTR atomindex; + + ptr = (DLword *)fx_addr68k; + + if(fx_addr68k->flags != 6) + { + printf("\nInvalid frame,NOT FX"); + return(0); + }; + + + atomindex = get_framename((struct frameex1 *)fx_addr68k); + printf("\n*** Frame Extension for "); + print(atomindex); + printf("\n %x : %x %x ",LADDR_from_68k(ptr),GETWORD(ptr), GETWORD(ptr+1)); + + putchar('['); + if(fx_addr68k->fast) printf("F,"); + if(fx_addr68k->incall) printf("incall, "); + if(fx_addr68k->validnametable) printf("V, "); + printf("usecnt = %d]; alink",fx_addr68k->usecount); + if(fx_addr68k->alink & 1) + printf("[SLOWP]"); + + + ptr+=2; + printf("\n %x : %x %x fnheadlo, fnheadhi\n", + LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr+1)); + + ptr+=2; + printf("\n %x : %x %x next, pc\n", + LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr+1)); + + ptr+=2; + printf("\n %x : %x %x LoNmTbl, HiNmTbl\n",LADDR_from_68k(ptr),GETWORD(ptr), GETWORD(ptr+1)); + + ptr+=2; + printf("\n %x : %x %x #blink, #clink\n",LADDR_from_68k(ptr),GETWORD(ptr), GETWORD(ptr+1)); + + + /* should pay attention to the name table like RAID does */ + + next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock+STK_OFFSET)); + if (fx_addr68k == CURRENTFX) {next68k = CurrentStackPTR + 2;} + + if ((next68k < ptr) || (((UNSIGNED)next68k & 1) != 0) ) + {printf ("\nNext block invalid"); return(0);} + + + while(next68k > ptr) + { + ptr+=2; + printf("\n %x : %x %x", + LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr+1)); + } + return (0); + + } /* end dump_fx */ + + +dump_CSTK(int before) +{ + DLword *ptr; + ptr= CurrentStackPTR - before; + while(ptr != CurrentStackPTR) + { + printf("\n%x : %x ",LADDR_from_68k(ptr),GETWORD(ptr)); + ptr++; + } + printf("\nCurrentSTKP : %x ",LADDR_from_68k(CurrentStackPTR)); + printf("\ncontents : %x ",*((LispPTR *)(CurrentStackPTR-1))); + }/* dump_CSTK end */ + + + +/******************************************/ +/* BTV */ + +btv(void) +{ + struct frameex1 *fx_addr68k; + LispPTR atomindex; + struct frameex1 *get_nextFX(FX *fx); + + fx_addr68k = CURRENTFX; + +loop: + dump_stackframe(fx_addr68k); + if( fx_addr68k->alink == 0 ) + {printf ("\n BTV end"); return(0);}; + + fx_addr68k= get_nextFX(fx_addr68k); + goto loop; + } /*end btv*/ + +get_framename(struct frameex1 *fx_addr68k) +{ + struct fnhead *fnheader; + LispPTR scratch; + + /* Get FNHEAD */ +#ifdef BIGVM + if(fx_addr68k->validnametable==0) + { + scratch = (unsigned int)(fx_addr68k->fnheader); + } + else + { + scratch = (unsigned int)(fx_addr68k->nametable); + } +#else + if(fx_addr68k->validnametable==0) + { + scratch = (unsigned int)(fx_addr68k->hi2fnheader << 16); + scratch |= (unsigned int)(fx_addr68k->lofnheader); + } + else + { + scratch = (unsigned int)(fx_addr68k->hi2nametable << 16); + scratch |= (unsigned int)(fx_addr68k->lonametable); + } +#endif /* BIGVM */ + fnheader = (struct fnhead *)Addr68k_from_LADDR( scratch ); + return(fnheader->framename); + }/* get_framename end */ + + +FX *get_nextFX(FX *fx) +{ + DLword *pv; + + if(URaid_scanlink==URSCAN_ALINK) + return((FX *)Addr68k_from_StkOffset(GETALINK(fx))); + else + return((FX *)Addr68k_from_StkOffset(GETCLINK(fx))); + + } /* get_nextFX end */ + + + +MAKEATOM(char *string) +{ + int length; + length = countchar(string); + return(make_atom(string,0,length,0)); + } + + + +/************************************************************************/ +/* */ +/* M a k e A t o m 6 8 k */ +/* */ +/* Given a LITATOM that exists before the package system was */ +/* turned on, return a pointer to that atom's value cell. */ +/* */ +/************************************************************************/ + +DLword *MakeAtom68k(char *string) +{ + int index; + index = make_atom(string, 0, countchar(string), 0); +#ifdef BIGVM + index = (ATOMS_HI << 16) + (index * 10) + NEWATOM_VALUE_OFFSET; +#else + index = VALS_OFFSET + (index << 1); +#endif /* BIGVM */ + return ( Addr68k_from_LADDR( index ) ); + } + + + + +/************************************************************************/ +/* */ +/* G E T T O P V A L */ +/* */ +/* Print the top-level value of a given atom; for use in dbx. */ +/* */ +/************************************************************************/ +GETTOPVAL(char *string) +{ + int index; + LispPTR *cell68k; + + index=MAKEATOM(string); + if (index != -1) /* Only print if there's such an atom */ + { + cell68k= (LispPTR *)GetVALCELL68k(index); + print(*cell68k); + } + else printf("'%s': no such symbol.\n", string); +} + + +/************************************************************************/ +/* */ +/* S _ T O P V A L */ +/* */ +/* Given a string that's an atom name minus the initial \, */ +/* print the atom's top-level value. This is here because */ +/* DBX won't put \'s in strings you type. */ +/* */ +/************************************************************************/ + +S_TOPVAL(char *string) +{ + int index; + LispPTR *cell68k; + int length; + char dummy[256]; + + dummy[0]='\\'; + for(length=1; *string != '\0'; length++,string++) + { + dummy[length] = *string; + } + + index=make_atom(dummy,0,length,0); + cell68k= (LispPTR *)GetVALCELL68k(index); + print(*cell68k); + } + + +/***************/ +S_MAKEATOM(char *string) +{ + int index=0; + int length; + char dummy[256]; + + dummy[0]='\\'; + for(length=1; *string != '\0'; length++,string++) + { dummy[length] = *string;} + + + index=make_atom(dummy,0,length,0); + printf("#Atomindex : %d\n",index); + return(index); +} + +/****************************************************************************/ +/* all_stack_dump(start,end) +*/ + +jmp_buf SD_jumpbuf; + +#define SDMAXLINE 30 +#define SD_morep if(++sdlines>SDMAXLINE){ int temp;\ + printf("\nPress Return:(to quit Esc and Ret):");\ + temp = getchar();fflush(stdin);\ + sdlines=0;if(temp==27)longjmp(SD_jumpbuf,1) ;} + + +#ifndef BYTESWAP +typedef struct stack_header + { + unsigned flags1 : 3; + unsigned flags2 : 5; + unsigned usecount : 8; + } STKH; + +#define STKHPTR(ptr) (ptr) + +#else +typedef struct stack_header + { + unsigned usecount : 8; + unsigned flags2 : 5; + unsigned flags1 : 3; + } STKH; + +#define STKHPTR(ptr) ((STKH *) (2^(UNSIGNED)(ptr))) + +#endif /* BYTESWAP */ + + + + +all_stack_dump(DLword start, DLword end, DLword silent) + /* Stack offset in DLword */ +{ + STKH *stkptr; + DLword *start68k,*end68k,*orig68k; + DLword size,dummy; + int sdlines=0; + extern IFPAGE *InterfacePage; + + if(start==0) start68k= Stackspace + InterfacePage->stackbase; + else start68k = Addr68k_from_LADDR(STK_OFFSET | start); + + if(end==0) end68k= Stackspace+ InterfacePage->endofstack; + else end68k = Addr68k_from_LADDR(STK_OFFSET | end); + + stkptr= (STKH *)start68k; + + + while(((DLword*)stkptr) < end68k ) + { + dummy = LADDR_from_68k(stkptr); + switch (STKHPTR(stkptr)->flags1 ) { + case STK_GUARD : + case STK_FSB : + if( (STKHPTR(stkptr)->flags2 !=0) || (STKHPTR(stkptr)->usecount!=0) ) + {goto badblock;}; + size = GETWORD(((DLword *)stkptr) +1); + if(STKHPTR(stkptr)->flags1 == STK_GUARD) + printf("\n0x%x GUARD, size : 0x%x", + LADDR_from_68k(stkptr),size ); + else printf("\n0x%x FSB, size : 0x%x", + LADDR_from_68k(stkptr),size); + + if(size <=0 || + size > ((DLword*)end68k-(DLword*)stkptr)) + {goto badblock;}; + + SD_morep; + size = GETWORD(((DLword *)stkptr) +1); + checksize: + if(size <=0 || size > ((DLword*)end68k-(DLword*)stkptr)) + {goto badblock;}; + stkptr = (STKH *) (((DLword *) stkptr) + size); + break; + + case STK_FX : + /*if((((FX *)stkptr)->pc < 24) || + (((FX *)stkptr)->alink==0) || + (STKHPTR(stkptr)->usecount > 31)) + {goto badblock;};*/ + if (silent) + { SD_morep; + printf("\n0x%x: FX for ",LADDR_from_68k(stkptr)); + print(get_framename((struct frameex1 *)stkptr)); + printf(" ["); + if(((FX *)stkptr)->fast) printf("fast,"); + if(((FX *)stkptr)->native) printf("native,"); + if(((FX *)stkptr)->incall) printf("incall,"); + if(((FX *)stkptr)->validnametable) printf("V,"); + if(((FX *)stkptr)->nopush) printf("nopush,"); + printf("]"); + } + else {dump_fx((struct frameex1 *)stkptr);} + + if((FX *)stkptr == CURRENTFX) { + printf(" <-***current***"); + size= EndSTKP - (DLword*)stkptr; + } + else { + size = Addr68k_from_LADDR(STK_OFFSET| ((FX *)stkptr)->nextblock) - (DLword*)stkptr; + + }; + goto checksize; + default : + orig68k =(DLword*) stkptr; + + while(STKHPTR(stkptr)->flags1 != STK_BF) { + if(STKHPTR(stkptr)->flags1!=STK_NOTFLG){goto badblock;}; + stkptr = (STKH *) (((DLword *)stkptr) + DLWORDSPER_CELL); + }; + + if((BFRAMEPTR(stkptr))->residual) + { if((DLword*) stkptr != orig68k) + { + printf("\n$$$Bad BF(res):0x%x",LADDR_from_68k(stkptr)); + goto incptr; + } + } + else + { + if(BFRAMEPTR(stkptr)->ivar + != StkOffset_from_68K(orig68k)) + { + printf("\n$$$BF doesn't point TopIVAR:0x%x\n",LADDR_from_68k(stkptr)); + goto incptr; + } + } + + + if(silent) + { SD_morep; + printf("\n0x%x BF, ",LADDR_from_68k(stkptr)); + putchar('['); + if (BFRAMEPTR(stkptr)->residual) printf("Res,"); + if (BFRAMEPTR(stkptr)->padding) printf("Pad,"); + printf("ivar : 0x%x]", BFRAMEPTR(stkptr)->ivar); + } else dump_bf((Bframe *)stkptr); + + stkptr = (STKH*) (((DLword *)stkptr) + 2); + break; + + badblock: SD_morep; + printf("\n0x%x: Invalid, %x %x",LADDR_from_68k(stkptr), GETWORD(stkptr), GETWORD(stkptr+1)); + incptr: stkptr = (STKH *) (((DLword *)stkptr) + 2); + break; + + } /* case end */ + + + } /* while end */ +printf("\n<< That's All , last stack :0x%x >>\n",InterfacePage->endofstack); + +} + + +/************************************************************/ +dtd_chain(DLword type) +{ + struct dtd *dtdp; + LispPTR next; + LispPTR *next68k; + + dtdp=(struct dtd *)GetDTD(type); + + next=dtdp->dtd_free; + next68k=(LispPTR *) Addr68k_from_LADDR(next); + + while((*next68k) != 0) + { + if(type != GetTypeNumber(next)) { + printf("BAD cell in next dtdfree\n"); + return; } + print(next); + putchar('\n'); + + next= *next68k; + next68k=(LispPTR *) Addr68k_from_LADDR(next); + } + printf("That's All !\n"); + + }/* dtd_chain end **/ + + + +#ifdef DTDDEBUG + +check_dtd_chain(type) + DLword type; + { + register LispPTR next, onext; + LispPTR before; + + onext = 0; + next = ((struct dtd *)GetDTD(type))->dtd_free; + next &= POINTERMASK; + + while (next != NIL) + { + + if (next & 1) + { + error("Free pointer is ODD!"); + return; + } + + if (next & 0x8000000) error("impossibly-big free pointer!"); + + if (type != GetTypeNumber(next)) + { + error("BAD cell in next dtdfree "); + return; + } + onext = next; + next = *((LispPTR *)Addr68k_from_LADDR(next)); + next &= POINTERMASK; + } + } + +#endif + + +/************************************************************************/ +/* */ +/* T R A C E _ F N C A L L */ +/* T R A C E _ A P P L Y */ +/* */ +/* Functions for tracing function call and apply. Trace_FNCall */ +/* takes 2 arguments: The # of args the fn is bing called with */ +/* and the atom index of the function's name. */ +/* */ +/* Trace_APPLY takes one argument: The atom number of the */ +/* atom being applied. */ +/* */ +/************************************************************************/ + +Trace_FNCall(int numargs, int atomindex, int arg1, LispPTR *tos) +{ + printf("Calling a %d-arg FN: ", numargs); + print_atomname(atomindex); + printf("("); + if (numargs > 1) + { + int i; + for (i = -(numargs-2); i<1; i++) + { prindatum(*(tos+i)); printf(", "); } + } + if(numargs) prindatum(arg1); + printf(").\n"); + fflush(stdout); + } + +Trace_APPLY(int atomindex) +{ + printf("APPLYing an atom: "); + print_atomname(atomindex); + printf(".\n"); + fflush(stdout); + } diff --git a/src/timeoday.c b/src/timeoday.c new file mode 100755 index 0000000..2de8626 --- /dev/null +++ b/src/timeoday.c @@ -0,0 +1,31 @@ +/* $Id: timeoday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: timeoday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include + +gettimeofday(time, ptr) + struct timeval *time; + int ptr; +{ + struct rusage stats; + getrusage(RUSAGE_SELF, &stats); + time->tv_sec = stats.ru_utime.tv_sec; + time->tv_usec = stats.ru_utime.tv_usec; +} diff --git a/src/timeofday.c b/src/timeofday.c new file mode 100755 index 0000000..9fc798a --- /dev/null +++ b/src/timeofday.c @@ -0,0 +1,31 @@ +/* $Id: timeofday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: timeofday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include + +gettimeofday(time, ptr) + struct timeval *time; + int ptr; +{ + struct rusage stats; + getrusage(RUSAGE_SELF, &stats); + time->tv_sec = stats.ru_utime.tv_sec; + time->tv_usec = stats.ru_utime.tv_usec; +} diff --git a/src/timer.c b/src/timer.c new file mode 100755 index 0000000..5b81304 --- /dev/null +++ b/src/timer.c @@ -0,0 +1,1310 @@ +/* $Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* t i m e r . c */ +/* */ +/* Timer handling routines, plus set-up for the other interrupts */ +/* Medley uses on Unix. */ +/* */ +/************************************************************************/ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#ifdef DOS +#include +#include +#include /* "#pragma interrupt" & '_chain_intr'*/ +#include /* defines REGS & other structs */ +#include /* define NULL */ +#include +#define SIGVTALRM SIGUSR1 +#define SIGIO SIGREAD +/****************************************************************************** +* Global variables +******************************************************************************/ +void (*prev_int_1c)(); /* keeps address of previous 1c handlr*/ + /* used for chaining & restore at exit*/ +#pragma interrupt(DOStimer) +void DOStimer(); + +unsigned long tick_count = 0; /* approx 18 ticks per sec */ +#define USETIMEFN + +#else +#include +#endif /* DOS */ +#include +#include +#include +#include + +#ifdef ISC +#include +#include +#include +#include +#define SIGIO SIGPOLL +#define USETIMEFN +#else +#ifndef DOS +#include +#endif /* DOS */ +#endif /* ISC */ + +#ifdef SYSVONLY +extern long timezone; /* seconds difference GMT to local */ +#endif + +#ifdef OS5 +#include +#include +/* JDS 991228 removed #define USETIMEFN */ +extern int ether_fd; +#endif + +#ifdef LINUX +#include +#endif + +#include + +#ifdef AIXPS2 +#include +#endif /* AIXPS2 */ + + +/* Apollo and Sun have different ideas about the name of this field */ +#ifdef APOLLO +#define sv_flags sv_onstack +#endif + + +#ifdef OSF1 + /* This is where FPE_FLTOVF & friends are defined */ +#include +#endif /* OSF1 */ + + + +#include "lispemul.h" +#include "emlglob.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "lispmap.h" +#include "stack.h" +#include "dbprint.h" + +#ifdef XWINDOW +#include "devif.h" +extern DspInterface currentdsp; +#endif /* XWINDOW */ + + +#define LISP_UNIX_TIME_DIFF 29969152 +#define LISP_ALTO_TIME_MASK 0x80000000 +#ifdef __STDC__ +#define UNIX_ALTO_TIME_DIFF 2177452800U +#else +#define UNIX_ALTO_TIME_DIFF 2177452800 +#endif /* __STDC__ */ + + +/* Interlisp time is signed; MIN.FIXP = "01-JAN-01 00:00:00 GMT" + * Interlisp 0 is at "19-Jan-69 12:14:08 PST" + * Unix begins at " 1-Jan-70 0:00:00 GMT" + * (CL:- (IL:IDATE " 1-Jan-70 0:00:00 GMT") + * (IL:IDATE "19-Jan-69 12:14:08 PST")) + * => 29969152, amount to add to Lisp time to get Unix time + * Alto time is unsigned; 0 = "01-JAN-01 00:00:00 GMT" + * UNIX_ALTO_TIME_DIFF is amount to add to Unix time + * to get Alto time. + */ + +int TIMEOUT_TIME; /* For file system timeout */ +char *getenv(); + +#ifdef XWINDOW +#define FALSE 0 +#define TRUE !FALSE +int Event_Req = FALSE; +#endif /* XWINDOW */ + + + +#define ERRCHK(expr, str) if (expr == -1) perror(str) + +#define SIGERRCHK(set, str) if (set == SIG_ERR) perror(str) + +/************************************************************************/ +/* */ +/* i n i t _ m i s c s t a t s */ +/* */ +/* Called at initialization time to set miscstats words. */ +/* ?? and to periodically update them ?? [JDS 11/22/89] */ +/* */ +/* */ +/************************************************************************/ + +init_miscstats() + { + MiscStats->starttime = gettime(0); + MiscStats->gctime = 0; + update_miscstats(); + } + + + +/************************************************************************/ +/* */ +/* u p d a t e _ m i s c s t a t s */ +/* */ +/* Updates counters and timers in the MISCSTATS "page". */ +/* */ +/* */ +/* */ +/************************************************************************/ + +update_miscstats() + { +#ifdef DOS + struct dostime_t dtm; /* holds DOS time, so we can get .01 secs */ + _dos_gettime(&dtm); + + MiscStats->totaltime = (time(0)*1000) + (10 * dtm.hsecond); + MiscStats->swapwaittime = 0; + MiscStats->pagefaults = 0; /* can't tell this on ISC */ + MiscStats->swapwrites = 0; + MiscStats->diskiotime = 0; /* ?? not available ?? */ + MiscStats->diskops = 0; + MiscStats->secondstmp = + MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); +#elif !defined(USETIMEFN) + struct timeval timev; + struct rusage ru; + + getrusage(RUSAGE_SELF, &ru); + + MiscStats->totaltime = ru.ru_utime.tv_sec * 1000 + + ru.ru_utime.tv_usec /1000; + MiscStats->swapwaittime = ru.ru_stime.tv_sec * 1000 + + ru.ru_stime.tv_usec /1000; + MiscStats->pagefaults = ru.ru_minflt + ru.ru_majflt; + MiscStats->swapwrites = ru.ru_majflt; + MiscStats->diskiotime = 0; /* ?? not available ?? */ + MiscStats->diskops = ru.ru_inblock + /* ?? this doesn't work ??? + + ru.ru_outblock */ + ; + gettimeofday(&timev, NULL); + MiscStats->secondstmp = + MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); +#else + struct tms ru; + + times(&ru); /* Get system time used */ + + MiscStats->totaltime = ru.tms_utime*10 + ru.tms_stime*10 + + ru.tms_cutime*10 + ru.tms_cstime*10; + MiscStats->swapwaittime = ru.tms_stime*10 + + ru.tms_cstime*10; + MiscStats->pagefaults = 0; /* can't tell this on ISC */ + MiscStats->swapwrites = 0; + MiscStats->diskiotime = 0; /* ?? not available ?? */ + MiscStats->diskops = 0; + MiscStats->secondstmp = + MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); + +#endif /* DOS */ + + } + + + +/************************************************************************/ +/* */ +/* s u b r _ g e t t i m e */ +/* */ +/* Handler for Lisps GETTIME subr call, dispatched thru */ +/* subr.c/miscn.c sub-dispatch. */ +/* */ +/* Calls gettime, and returns the result to Lisp as a SMALLP */ +/* or FIXP, as appropriate. */ +/* */ +/************************************************************************/ + +DLword *createcell68k(); + +LispPTR subr_gettime(args) + LispPTR args[]; + { + int result; + result = gettime(args[0] & 0xffff); + if (args[1]) + { + *((int*)Addr68k_from_LADDR(args[1]) ) = result; + return (args[1]); + } + else N_ARITH_SWITCH(result); +} + + + + +/************************************************************************/ +/* */ +/* g e t t i m e */ +/* */ +/* Get the value of one of the various time counters, as */ +/* specified by the argument casep. casep's values & meanings: */ +/* */ +/* 0 elapsed time, in milliseconds. */ +/* 1 start of elapsed-time period, in milliseconds */ +/* 2 this process's run time, in milliseconds */ +/* 3 total GC time, in milliseconds */ +/* 4 current time-of-day, in ALTO format */ +/* 5 current time-of-day, in Interlisp format */ +/* 6 start of daylight-savings, as day-in-year */ +/* 7 end of daylight-savings, as day-in-year */ +/* 8 time zone, as hours of offset from GMT (whole hours only) */ +/* */ +/************************************************************************/ + +int gettime(casep) + int casep; + { +#ifndef USETIMEFN + struct timeval timev; + struct timezone tz; +#elif DOS + struct dostime_t dtm; /* for hundredths of secs */ +#endif /* USETIMEFN */ + switch (casep) + { + + case 0: /* elapsed time in alto milliseconds */ +#ifdef USETIMEFN +#ifdef DOS + _dos_gettime(&dtm); + return ((time(0)+UNIX_ALTO_TIME_DIFF)*1000) + (10 * dtm.hsecond); +#else /* DOS */ + return ((time(0)+UNIX_ALTO_TIME_DIFF))*1000; +#endif /* DOS */ +#else /* USETIMEFN */ + gettimeofday(&timev, NULL); + return((timev.tv_sec + UNIX_ALTO_TIME_DIFF)*1000 + + timev.tv_usec/1000); +#endif /* USETIMEFN */ + + case 1: /* starting elapsed time in milliseconds */ + return(MiscStats->starttime); + + case 2: /* run time, this process, in milliseconds */ + update_miscstats(); + return(MiscStats->totaltime); + + case 3: /* total GC time in milliseconds */ + return(MiscStats->gctime); + + case 4: /* current time of day in Alto format */ +#ifdef USETIMEFN + return(time(0) + UNIX_ALTO_TIME_DIFF); +#else + gettimeofday(&timev, NULL); + return (timev.tv_sec + UNIX_ALTO_TIME_DIFF); +#endif + + case 5: /* current time of day in Interlisp format */ +#ifdef USETIMEFN + return(time(0) + LISP_UNIX_TIME_DIFF); +#else + gettimeofday(&timev, NULL); + return(timev.tv_sec + LISP_UNIX_TIME_DIFF); +#endif + + case 6: + return (98); /* this is wrong, only works in PST */ + + case 7: + return (305); /* this is wrong, only works in PST */ + + case 8: +#ifdef OS5 + return (timezone/3600); /* timezone, extern, is #secs diff GMT to local. */ + +#elif USETIMEFN + return (timezone/3600); /* timezone, extern, is #secs diff GMT to local. */ +#else + gettimeofday(&timev, &tz); + return (tz.tz_minuteswest/60); /* only integral timezones work */ +#endif + + default: return (0); + } + } + + +/************************************************************************/ +/* */ +/* s u b r _ s e t t i m e */ +/* */ +/* Converts its argument, a time in ALTO seconds, to the */ +/* UNIX time format, and sets the UNIX clock. You must be */ +/* the super-user for this to work. */ +/* */ +/* Implements the SETTIME subr call, sub-dispatched from subr.c */ +/* */ +/************************************************************************/ + +subr_settime(args) + LispPTR args[]; + { +#ifdef DOS + struct dostime_t dostime; + struct dosdate_t dosday; + struct tm uxtime; + + uxtime = *localtime((time_t *)(*((int*)Addr68k_from_LADDR(args[0])) + - UNIX_ALTO_TIME_DIFF)); + dostime.hsecond = 0; + dostime.second = uxtime.tm_sec; + dostime.minute = uxtime.tm_min; + dostime.hour = uxtime.tm_hour; + _dos_settime(&dostime); + + dosday.day = uxtime.tm_mday; + dosday.month = uxtime.tm_mon; + dosday.year = uxtime.tm_year; + dosday.dayofweek = uxtime.tm_wday; + _dos_setdate(&dosday); + +#elif defined(SYSVONLY) + time_t newTime = (time_t) (*((int*)Addr68k_from_LADDR(args[0])) + - UNIX_ALTO_TIME_DIFF); + stime(&newTime); +#else + struct timeval timev; + timev.tv_sec = *((int*)Addr68k_from_LADDR(args[0])) + - UNIX_ALTO_TIME_DIFF; + settimeofday(&timev, NULL); +#endif /* DOS */ + } /* end subr_settime */ + + + + + +/************************************************************************/ +/* */ +/* s u b r _ c o p y t i m e s t a t s */ +/* */ +/* Given source and destination MISCSTATS structure pointers, */ +/* copy the contents of the source structure into the dest. */ +/* */ +/* Also calls update_miscstats, to keep stats current. */ +/* */ +/************************************************************************/ + +subr_copytimestats(args) + LispPTR args[]; + { + MISCSTATS *source; + MISCSTATS *dest; + source = (MISCSTATS*) Addr68k_from_LADDR(args[0]); + dest = (MISCSTATS*) Addr68k_from_LADDR(args[1]); + update_miscstats(); + *dest = *source; + } + + + +/************************************************************************/ +/* */ +/* N _ O P _ r c l k */ +/* */ +/* Get the current time in UNIX format, convert it to micro- */ +/* seconds in ALTO format, and store the low 32 bits into */ +/* the FIXP cell passed in to us on the top of stack. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_rclk(tos) + register LispPTR tos; + { + unsigned int usec; +#ifdef DOS + struct dostime_t dtm; +#endif /* DOS */ + +#ifdef USETIMEFN +#ifdef DOS + _dos_gettime(&dtm); + usec = (time(0)*1000000) + (10000 * dtm.hsecond); +#else + usec = time(0)*1000000; +#endif /* DOS */ +#else + struct timeval timev; + + gettimeofday(&timev, NULL); + usec = (timev.tv_sec * 1000000) + timev.tv_usec; +#endif /* USETIMEFN */ + *((unsigned int *)(Addr68k_from_LADDR(tos))) = usec; + return(tos); + } /* end N_OP_rclk */ + + + +/**********************************************************************/ + /* update_timer called periodically */ + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +update_timer() + { +#ifdef USETIMEFN + MiscStats -> secondstmp = MiscStats->secondsclock + = time(0) + UNIX_ALTO_TIME_DIFF; +#else + struct timeval timev; + gettimeofday(&timev, NIL); + MiscStats->secondstmp = MiscStats->secondsclock + = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); +#endif /* USETIMEFN */ + } + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +/**********************************************************************/ +/* timer interrupt handling system + + int_init() should be called before first entering dispatch loop. + int_timer_init() is called by int_init() and arms the timer interrupt. + int_io_init() is called by int_init() and arms the I/O interrupt. + int_timer_service() catches the timer signal and sets + Irq_Stk_Check & Irq_Stk_End to 0 + so the rest of the system will see it and respond. + int_block() and int_unblock() block timer interrupts and release them. + int_io_open(fd) should be called whenever a file that should interrupt + us is opened; it enables the interrupt on that fd. + int_io_close(fd) should be called whenever a file that should interrupt + us is closed; it disables the interrupt on that fd. +*/ + +/* TIMER_INTERVAL usec ~ 20 per second. This should live in some + machine-configuration + file somewhere - it can be changed as the -t parameter to lisp*/ + +#ifdef sparc +int TIMER_INTERVAL = 100000; +#else +int TIMER_INTERVAL = 25000; +#endif + +int FileIOFlag = 0; +int TimerFlag = 0; +extern u_int LispWindowFd; + +/************************************************************************/ +/* */ +/* i n t _ t i m e r _ s e r v i c e */ +/* */ +/* Handle the virtual-time alarm signal VTALRM. If running in */ +/* HPUX, re-set the alarm ourselves, because the OS walks on */ +/* your timer if you let IT do the resetting. */ +/* */ +/* */ +/************************************************************************/ + +#ifndef SYSVSIGNALS +static struct sigvec timerv; +#endif /* SYSVSIGNALS */ + +#if (defined(OS4) || defined(SYSVONLY)) +void int_timer_service(sig, code, scp) +#else +int int_timer_service(sig, code, scp) +#endif /* OS4 | SYSVONLY */ + +int sig, code; +struct sigcontext *scp; +{ +/* this may have to do more in the future, like check for nested interrupts, + etc... */ + + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + TimerFlag = 1; + +#ifdef XWINDOW + Event_Req = TRUE; +#endif +#ifdef HPTIMERBUG + { +struct itimerval timert, tmpt; + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = 0; + timert.it_value.tv_usec = TIMER_INTERVAL; + setitimer(ITIMER_VIRTUAL, &timert, 0); + } +#endif /* HPTIMERBUG */ + +#ifdef SYSVSIGNALS +#ifndef ISC +/* sigset(SIGVTALRM, int_timer_service); */ +#endif /* ISC */ +#endif /* SYSVSIGNALS */ +} + + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +void int_timer_init() + +{ +#ifdef DOS +/****************************************************************************** +* All code and data touched during the processing of an interrupt should +* locked prior to receiving any interrupts. This prevents the Timer +* function from being swapped out during an interrupt. +******************************************************************************/ + _dpmi_lockregion((void *)TimerFlag, sizeof(TimerFlag)); + _dpmi_lockregion((void *)Irq_Stk_End, sizeof(Irq_Stk_End)); + _dpmi_lockregion((void *)Irq_Stk_Check, sizeof(Irq_Stk_Check)); + _dpmi_lockregion((void *)tick_count, sizeof(tick_count)); + _dpmi_lockregion((void *)&DOStimer, 4096); + _dpmi_lockregion((void *)prev_int_1c, sizeof(prev_int_1c)); + + /* Set up the DOS time handler. */ + prev_int_1c = _dos_getvect(0x1c); /* get addr of currnt 1c hndlr, */ + /* if any*/ + _dos_setvect(0x1c, DOStimer); /* hook our int handler to timer int */ + + +#elif SIGVTALRM +struct itimerval timert, tmpt; + +#ifdef SYSVSIGNALS + SIGERRCHK(sigset(SIGVTALRM, int_timer_service), "sigset vtalrm"); +#else +/* first set up the signal handler */ + timerv.sv_handler = int_timer_service; + timerv.sv_mask = timerv.sv_flags = 0; + sigvec(SIGVTALRM, &timerv, 0); +#endif /* SYSVSIGNALS */ + + +/* then attach a timer to it and turn it loose */ +#ifdef HPTIMERBUG + /* HPUX on the series 700 trashes the timer if you use */ + /* the auto-reset feature (interval != 0), so have to */ + /* move the reset into the timer handler (above). */ + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = 0; + timert.it_value.tv_usec = TIMER_INTERVAL; +#else + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = timert.it_value.tv_usec = TIMER_INTERVAL; +#endif /* HPTIMERBUG */ + + timerclear(&tmpt.it_value); + timerclear(&tmpt.it_interval); + setitimer(ITIMER_VIRTUAL, &timert, &tmpt); + getitimer(ITIMER_VIRTUAL, &tmpt); + + DBPRINT(("Timer interval set to %d usec\n", timert.it_value.tv_usec)); +#endif /* DOS or SIGVTALRM */ +} + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +void int_io_open(fd) +int fd; +{ +#ifdef DOS + /* would turn on DOS kbd signal handler here */ +#elif KBINT + + DBPRINT(("int_io_opening %d\n", fd)); + if(fcntl(fd, F_SETOWN, getpid()) == -1 ) { +#ifdef DEBUG + perror("fcntl F_SETOWN ERROR"); +#endif + }; + if(fcntl(fd, F_SETFL, fcntl (fd, F_GETFL, 0) | FASYNC) == -1) + perror("fcntl F_SETFL error"); +#endif +} + +void int_io_close(fd) +int fd; +{ +#ifdef DOS + /* Turn off signaller here */ +#elif KBINT + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~FASYNC); +#endif +} + + +/************************************************************************/ +/* */ +/* i n t _ i o _ i n i t */ +/* */ +/* Set up handling for the SIGIO and SIGPOLL signals, in */ +/* support of keyboard event handling and ethernet incoming- */ +/* packet handling. */ +/* */ +/* */ +/************************************************************************/ + +void int_io_init() + { +#ifndef SYSVSIGNALS + static struct sigvec timerv; + static struct sigvec poll_timerv; +#endif /* SYSVSIGNALS */ + extern void getsignaldata(); + + /* first set up the signal handler */ + +#ifndef SYSVSIGNALS +#ifdef KBINT + timerv.sv_handler = getsignaldata; + timerv.sv_mask = timerv.sv_flags = 0; + sigvec(SIGIO, &timerv, 0); + + DBPRINT(("I/O interrupts enabled\n")); +#endif /* KBINT */ +#else /* SYSVSIGNALS in effect... */ +#ifdef ISC + { + int res = sigset(SIGIO, getsignaldata); + if (res==SIG_ERR) perror("sigset for I/O polling"); + if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) perror("ioctl on X fd - SETSIG"); + } +#else +#ifndef DOS + SIGERRCHK(sigset(SIGIO, getsignaldata), "sigset io"); +#ifdef XWINDOW + if (ioctl(ConnectionNumber(currentdsp->display_id) , I_SETSIG, S_INPUT) < 0) perror("ioctl on X fd - SETSIG"); +#endif /* XWINDOW */ +#ifdef USE_DLPI + DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); + if (ether_fd > 0) if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) + { + perror("init_ether: I_SETSIG failed:\n"); + close(ether_fd); + ether_fd = -1; + return; + } +#endif /* USE_DLPI */ + +#endif /* DOS */ +#endif /* ISC */ +#endif /* SYSVSIGNALS */ + + +} + +int oldmask = 0; + + +/************************************************************************/ +/* */ +/* i n t _ b l o c k */ +/* */ +/* Temporarily turn off interrupts. */ +/* */ +/* NOTE that these interrupts must also be turned off in ldeboot's */ +/* forking code; if you change these, go fix that one too */ +/* */ +/************************************************************************/ + +void int_block() +{ +/* temporarily turn off interrupts */ +#ifdef DOS + _dos_setvect(0x1c, prev_int_1c); +#else /* DOS */ +#ifdef SYSVSIGNALS +#ifdef SIGVTALRM + sighold(SIGVTALRM); +#endif /* SIGVTALRM */ + sighold(SIGIO); + sighold(SIGALRM); +#ifdef SIGXFSZ + sighold(SIGXFSZ); +#endif /* SIGXFSZ */ +#else + oldmask= sigblock(sigmask(SIGVTALRM) | sigmask(SIGIO) + | sigmask(SIGALRM) +#ifndef HPUX + | sigmask(SIGXFSZ) +#endif /* HPUX */ + +#ifdef FLTINT + | sigmask(SIGFPE) +#endif +); +#endif /* SYSVSIGNALS */ +#endif /* DOS */ +} + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +void int_unblock() +{ +#ifdef DOS + _dos_setvect(0x1c, DOStimer); +#else /* DOS */ +#ifdef SYSVSIGNALS +#ifdef SIGVTALRM + ERRCHK(sigrelse(SIGVTALRM), "sigrelse vtalrm"); +#endif /* SIGVTALRM */ + ERRCHK(sigrelse(SIGIO), "sigrelse io"); + ERRCHK(sigrelse(SIGALRM), "sigrelse alrm"); +#ifdef SIGXFSZ + ERRCHK(sigrelse(SIGXFSZ), "sigrelse XFSZ"); +#endif /* SIGXFSZ */ +#else + sigsetmask(oldmask); +#endif /* SYSVSIGNALS */ +#endif /* DOS */ +} + +int_timer_on () {int_unblock();} +int_timer_off() {int_block ();} + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + + +#ifdef NEVER + +void int_timer_off() +{ +#ifdef SYSVSIGNALS +#ifndef ISC +sigignore(SIGVTALRM); +#endif /* ISC */ + +#else +struct sigvec tmpv, timeroffv; + +timeroffv.sv_handler = SIG_IGN; +timeroffv.sv_mask = timeroffv.sv_flags = 0; +sigvec(SIGVTALRM, &timeroffv, &tmpv); +#endif /* SYSVSIGNALS */ + +} + +void int_timer_on() +{ +#ifdef SYSVSIGNALS +#ifdef SIGVTALRM + SIGERRCHK(sigset(SIGVTALRM, int_timer_service), "sigset vtalrm"); +#endif /* SIGVTALRM */ + +#else +struct sigvec tmpv; + +sigvec(SIGVTALRM, &timerv, &tmpv); +#endif /* SYSVSIGNALS */ + + +} + +#endif /* NEVER */ + +#ifdef FLTINT +/************************************************************************/ +/* */ +/* F L O A T I N G - P O I N T I N T E R R U P T H A N D L I N G */ +/* */ +/* This is the handler for the SIGFPE signal, to catch floating- */ +/* point exceptions. Sets the global 'FP_error' to the error */ +/* code passed in by the signal; FP_error is checked by the */ +/* Lisp emulator FP code to make sure everything is OK. */ +/* */ +/************************************************************************/ + +/* The global used to signal floating-point errors */ +int FP_error = 0; + +void int_fp_service(sig, code, scp) + int sig, code; + struct sigcontext *scp; + { + switch(code) + { +#ifdef AIXPS2 + case FPM_DENORM: + case FPM_DIVIDE_0: + case FPM_UNDERFLOW: + case FPM_OVERFLOW: + case FPM_PRECISION: +#elif OSF1 + case FPE_FLTDIV: + case FPE_FLTOVF: + case FPE_FLTUND: + case FPE_FLTRES: + case FPE_FLTINV: + case FPE_FLTSUB: +#else +#ifndef ISC + case FPE_FLTDIV_TRAP: + case FPE_FLTUND_TRAP: + case FPE_FLTOVF_TRAP: + case FPE_FLTOPERR_TRAP: +#endif /* ISC */ +#endif /* AIXPS2 */ + + FP_error = code; + break; + default: + { +#ifdef DEBUG + char stuff[100]; + sprintf(stuff, "Unexpected FP error signal code: %d", code); + perror(stuff); +#else + FP_error = code; +#endif + } + } +#ifdef SYSVSIGNALS + sigset(SIGFPE, int_fp_service); +#endif /* SYSVSIGNALS */ + } + + + +int_fp_init() + { /* first set up the signal handler */ +#ifndef ISC +#ifdef AIXPS2 + if(sigset(SIGFPE, int_fp_service)) +#elif OS5 + if(sigset(SIGFPE, int_fp_service)) +#elif OSF1 + if(SIG_ERR == sigset(SIGFPE, int_fp_service)) +#else + if(ieee_handler("set", "all", int_fp_service)) +#endif /* AIXPS2 */ + + perror("Sigvec for FPE failed"); + DBPRINT(("FP interrupts enabled\n")); +#endif /* ISC */ + + } + +#endif /* FLTINT */ + + + + + +/************************************************************************/ +/* */ +/* t i m e o u t _ e r r o r */ +/* */ +/* Error handling routine for SIGALRM. Called when any */ +/* TIMEOUT(...) forms spend more than TIMEOUT_TIME (normally */ +/* 10 sec.) trying to do an I/O operation. */ +/* */ +/* */ +/************************************************************************/ + +jmp_buf jmpbuf; +void timeout_error() + { + /* + * Following printf changes the contents of jmpbuf! + * This would lead to horrible segmentation violation. + */ +/* printf("File access timed out.\n"); */ +#ifdef SYSVSIGNALS +#ifdef SIGALRM + sigset(SIGALRM, timeout_error); +#endif +#endif /* SYSVSIGNALS */ + + longjmp(jmpbuf, 1); + } + + + +/************************************************************************/ +/* */ +/* i n t _ f i l e _ i n i t */ +/* */ +/* Set up the signal handler for SIGALRM, to catch TIMEOUTs: */ +/* TIMEOUT(...) forms spend more than TIMEOUT_TIME (normally */ +/* 10 sec.) trying to do an I/O operation. */ +/* */ +/* */ +/************************************************************************/ + +void int_file_init() + { +#ifndef SYSVSIGNALS + static struct sigvec timerv; +#endif /* SYSVSIGNALS */ + + char *envtime; + int timeout_time; + + /* first set up the signal handler */ +#ifndef SYSVSIGNALS + timerv.sv_handler = timeout_error; + timerv.sv_mask = timerv.sv_flags = 0; + sigvec(SIGALRM, &timerv, 0); +#else +#ifdef SIGALRM +#ifdef ISC + sigset(SIGALRM, timeout_error); +#else + sigset(SIGALRM, timeout_error); +#endif /* ISC */ +#endif /* SIGALRM */ +#endif /* SYSVSIGNALS */ + + + /* Set Timeout period */ + if((envtime = getenv("LDEFILETIMEOUT")) == NULL) + { + TIMEOUT_TIME = 10; + } + else + { + if( (timeout_time = atoi(envtime)) > 0) TIMEOUT_TIME = timeout_time; + else TIMEOUT_TIME = 10; + } + DBPRINT(("File timeout interrupts enabled\n")); + } + + + +/************************************************************************/ +/* */ +/* p a n i c u r a i d */ +/* */ +/* Most of the unused process-killing interrupts end up here; you */ +/* can't do a whole lot safely here but dump your sysout for */ +/* post-mortem analysis, but you MIGHT be able to get a clue */ +/* about what killed you. */ +/* */ +/************************************************************************/ + +void panicuraid(sig, code, scp, addr) + int sig, code; + struct sigcontext *scp; + { + static char errormsg[200]; + static char *stdmsg = +"Please record the signal and code information\n\ +and do a 'v' before trying anything else."; + int i; + + for (i=0; i<200; i++) errormsg[i]=0; + + switch (sig) + { +#ifdef SIGBUS + case SIGBUS: sprintf(errormsg, + "BUS error (code %d) at address 0x%x.\n%s", + code, addr, stdmsg); + break; +#endif /* SIGBUS */ + case SIGSEGV: sprintf(errormsg, + "SEGV error (code %d) at address 0x%x.\n%s", + code, addr, stdmsg); + break; + case SIGILL: sprintf(errormsg, + "Illegal instruction (code %d) at address 0x%x.\n%s", + code, addr, stdmsg); + break; +#ifdef SIGPIPE + case SIGPIPE: sprintf(errormsg, + "Broken PIPE (code %d) at address 0x%x.\n%s", + code, addr, stdmsg); + break; +#endif /* SGPIPE */ +#ifdef SIGHUP + case SIGHUP: sprintf(errormsg, + "HANGUP signalled (code %d) at address 0x%x.\n%s", + code, addr, stdmsg); + /* Assume that a user tried to exit UNIX shell */ +#ifdef SYSVONLY + kill(0, SIGKILL); exit(0); +#else + killpg(getpgrp(0), SIGKILL);exit(0); +#endif /* SYSVONLY */ + break; +#endif /* SIGHUP */ + case SIGFPE: sprintf(errormsg, + "FP error (code %d) at address 0x%x.\n%s", + code, addr, stdmsg); + break; + default: sprintf(errormsg, "Uncaught SIGNAL %d (code %d).\n%s", + sig, code, stdmsg); + } + + error(errormsg); + + } + + + + +/************************************************************************/ +/* */ +/* i n t _ p a n i c _ i n i t */ +/* */ +/* A catch for all the deadly interupts (but KILL, of course) */ +/* Dumps you into uraid; you probably can't get back from it, */ +/* but there is hope that you will be able to poke around with */ +/* uraid and get a clue about why you're dying. */ +/* */ +/************************************************************************/ +void int_panic_init() + { +#ifdef SYSVSIGNALS +#ifdef ISC + sigset(SIGHUP, panicuraid); + sigset(SIGQUIT, panicuraid); + sigset(SIGILL, panicuraid); +#ifdef SIGEMT + sigset(SIGEMT, panicuraid); +#endif + sigset(SIGBUS, panicuraid); + sigset(SIGSEGV, panicuraid); +#ifdef SIGSYS + sigset(SIGSYS, panicuraid); +#endif + sigset(SIGTERM, panicuraid); +#elif DOS +#else + sigset(SIGHUP, panicuraid); + sigset(SIGQUIT, panicuraid); + sigset(SIGILL, panicuraid); +#ifdef SIGEMT + sigset(SIGEMT, panicuraid); +#endif + sigset(SIGBUS, panicuraid); + sigset(SIGSEGV, panicuraid); +#ifdef SIGSYS + sigset(SIGSYS, panicuraid); +#endif + sigset(SIGTERM, panicuraid); +#ifndef FLTINT +#ifdef OSF1 + sigignore(SIGFPE); +#endif /* OSF1 */ +#endif /* FLTINT */ +#endif +#else + static struct sigvec panicv; + static struct sigvec ignorev; + + /* first set up the signal handlers: */ + + panicv.sv_handler = panicuraid; + panicv.sv_mask = panicv.sv_flags = 0; + ignorev.sv_handler = SIG_IGN; + ignorev.sv_mask = ignorev.sv_flags = 0; + + /* Now arrange for signals to be handled properly: */ + + sigvec(SIGHUP, &panicv, 0); +/* sigvec(SIGINT, &panicv, 0); */ + sigvec(SIGQUIT, &panicv, 0); + sigvec(SIGILL, &panicv, 0); +/* sigvec(SIGTRAP, &panicv, 0); */ +#ifdef OS4 + sigvec(SIGABRT, &panicv, 0); +#endif /* OS4 */ +#ifdef SIGEMT + sigvec(SIGEMT, &panicv, 0); +#endif + sigvec(SIGBUS, &panicv, 0); + sigvec(SIGSEGV, &panicv, 0); +#ifdef SIGSYS + sigvec(SIGSYS, &panicv, 0); +#endif +/* sigvec(SIGPIPE, &panicv, 0); Caused trouble with TCP; now ignored: */ + sigvec(SIGPIPE, &ignorev, 0); + sigvec(SIGTERM, &panicv, 0); +#ifdef OS4 + sigvec(SIGXCPU, &panicv, 0); + sigvec(SIGLOST, &panicv, 0); +#endif /* OS4 */ + + sigvec(SIGUSR1, &panicv, 0); + sigvec(SIGUSR2, &panicv, 0); +#ifndef FLTINT +#ifdef OSF1 + sigignore(SIGFPE); +#endif /* OSF1 */ +#endif +#endif /* SYSVSIGNALS */ + + + DBPRINT(("Panic interrupts enabled\n")); + } + + + +/************************************************************************/ +/* */ +/* i n t _ i n i t */ +/* */ +/* Initialize all the interrupts for Lisp & the emulator. */ +/* */ +/************************************************************************/ + +void int_init() + { + int_timer_init(); /* periodic interrupt timer */ + int_io_init(); /* SIGIO and SIGPOLL async I/O handlers */ + int_file_init(); /* file-io TIMEOUT support */ + int_panic_init(); /* catch for all other dangerous interrupts */ + +#ifdef FLTINT + int_fp_init(); /* Floating-point exception handler */ +#else +#ifdef OSF1 + sigignore(SIGFPE); +#endif +#endif + + int_unblock(); /* Turn on interrupts */ +} + +#ifdef DOS +/****************************************************************************** +* DOStimer() +* +* The interrupt 0x1c handler. This routine must be declared using the +* '#pragma interrupt()' statement to ensure that all registers are preserved. +* It is also needed to ensure the proper functioning of '_chain_intr()'. +* +* The timer interrupt (normally) occurs 18.2 times per second. This routine +* waits one extra tick every 91 ticks (18.2*5). +* +* Before this interrupt was installed, 'prev_int_1c' was set to the current +* 0x1c interrupt. 'DOStimer()' chains to this interrupt using '_chain_intr()', +* rather than returning back to the caller. +* +* Note that as little as possible should be done within a timer interrupt, +* since further clock ticks are disabled until the interrupt returns. +******************************************************************************/ +void DOStimer() +{ + /* if (--tick_count == 0) { */ + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + TimerFlag = 1; + /* _dos_setvect(0x1c, prev_int_1c); + } else if (tick_count <= 0) { */ + /* I'm dead, uninstal me */ + /* _dos_setvect(0x1c, prev_int_1c); + tick_count = 0; + } */ + _chain_intr(prev_int_1c); /* call previous int 1c handlr, if any*/ + /* (pts to 'ret' if no prev installed)*/ +} + +void alarm( sec ) + unsigned long sec; +{ + /* tick_count = sec * 18; + _dos_setvect(0x1c, DOStimer); */ +} +#endif /* DOS */ + diff --git a/src/truecolor.c b/src/truecolor.c new file mode 100755 index 0000000..171452a --- /dev/null +++ b/src/truecolor.c @@ -0,0 +1,503 @@ +/* $Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include +#include + +#include "lispemul.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "lispmap.h" +#include "adr68k.h" +#include "arith.h" +#include "devconf.h" + +#include "picture.h" + +#define FALSE 0 +#define TRUE !FALSE + +#define COLOR_INIT 0 +#define COLOR_OVERLAYREGION 1 +#define COLOR_VIDEOREGION 2 +#define COLOR_VIDEOINIT 3 + +#define IntToFixp(C, Lisp) { \ + int *base; \ + base = (int *) Addr68k_from_LADDR((unsigned int)Lisp); \ + *base = C; \ +} + + +extern int displaywidth + , displayheight + , DisplayRasterWidth; +extern int ScreenLocked; +extern DLword *EmCursorX68K + , *EmCursorY68K; +extern Pixrect *TrueColorFb; +extern int FrameBufferFd; +extern int Inited_Video; + +int Inited_TrueColor = NIL; + +int +TrueColor_Op( args ) +LispPTR *args; +{ + int op + , ret_value = NIL; +/* + N_GETNUMBER( args[0], op, bad_arg ); +*/ + op = (DLword) args[0]; + + switch( op ) { + case COLOR_INIT: + ret_value = TrueColor_Initialize( args[1] ); + break; + case COLOR_VIDEOINIT: + ret_value = TrueColor_VideoInitialize( args[1] ); + break; + case COLOR_OVERLAYREGION: { + int left + , top + , bottom + , width + , height; + if( args[1] != NIL_PTR ) { + LispPTR region + , value; + int bottom; + /* get lisp region elements */ + region = args[1]; + value = car( region ); + N_GETNUMBER( value, left, bad_arg ); + region = cdr( region ); + value = car( region ); + N_GETNUMBER( value, bottom, bad_arg ); + region = cdr( region ); + value = car( region ); + N_GETNUMBER( value, width, bad_arg ); + region = cdr( region ); + value = car( region ); + N_GETNUMBER( value, height, bad_arg ); + top = displayheight - ( bottom + height ); + if( args[2] == ATOM_T ) { + Overlay_Region( left, top, width, height, TRUE ); + } else { + Overlay_Region( left, top, width, height, FALSE ); + } /* end if( args[2] ) */ + ret_value = T; + } /* end if( arg[1] ) */ + } /* end case */ + break; + case COLOR_VIDEOREGION: { + int left + , top + , bottom + , width + , height; + if( args[1] != NIL_PTR ) { + LispPTR region + , value; + int bottom; + /* get lisp region elements */ + region = args[1]; + value = car( region ); + N_GETNUMBER( value, left, bad_arg ); + region = cdr( region ); + value = car( region ); + N_GETNUMBER( value, bottom, bad_arg ); + region = cdr( region ); + value = car( region ); + N_GETNUMBER( value, width, bad_arg ); + region = cdr( region ); + value = car( region ); + N_GETNUMBER( value, height, bad_arg ); + top = displayheight - ( bottom + height ); + } else { + left = 0; + top = 0; + width = displaywidth; + height = displayheight; + } /* end if( arg[1] ) */ + + if( args[2] == NIL_PTR ) { /* video region clear */ + cgeight_video_region( left, top, width, height, FALSE ); + } else { /* video region set */ + cgeight_video_region( left, top, width, height, TRUE ); + } /* end if( args[2] ) */ + ret_value = T; + } /* end case */ + break; + defaults: + break; + } /* end switch( op ) */ + +bad_arg: + return( ret_value ); + +} /* end TrueColor_Op */ + +extern int Inited_Color; +extern int DisplayType; + +Pixrect *OverlayCursor + , *OverlaySave; +DLword *OverlayRegion68k; + +int +TrueColor_Initialize( overlay_bmbase ) +LispPTR overlay_bmbase; +{ + unsigned int pict + , *ret_value; + Pixrect *source; + int mmapstat + , size; + + + if( Inited_Color ) { + printf( "cgeight_init_color_display: 8 bits color display has already initialized.\n" ); + } /* end if( Inited_Color ) */ + + if( Inited_TrueColor ) { + printf( "cgeight_init_color_display: 24 bits color display has already initialized.\n"); + } /* end if( Inited_TrueColor ) */ + + if( DisplayType != SUNMEMCOLOR ) { + error( "cgeight_init_color_display: Unsupported FBreal_type %d\n", + DisplayType ); + } /* end if( DisplayType ) */ + + OverlayRegion68k = Addr68k_from_LADDR( overlay_bmbase ); + size = ( (displaywidth * displayheight/8 + (getpagesize()-1) ) + & -getpagesize() ); + + ScreenLocked = T; + taking_mouse_down(); + + pict = (unsigned int)cgeight_init_color_display(); + + source = mem_point( displaywidth, displayheight, 1 + , OverlayRegion68k ); + pr_set_plane_group( TrueColorFb, PIXPG_OVERLAY_ENABLE ); + pr_rop( TrueColorFb, 0, 0, displaywidth, displayheight + , PIX_SRC, source, 0, 0 ); + pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + + mmapstat = (int)mmap( OverlayRegion68k, + size, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x20000 ); + + if( mmapstat == -1 ) { + perror( "TrueColor_Initialize: ERROR at mmap system call\n" ); + exit( 0 ); + } /* end if( mmapstat ) */ + + OverlayCursor = mem_create( 16, 16, 32 ); + OverlaySave = mem_create( 16, 16, 32 ); + + Inited_TrueColor = TRUE; + + taking_mouse_up( *EmCursorX68K, *EmCursorY68K ); + overlay_mouse_up( *EmCursorX68K, *EmCursorY68K ); + ScreenLocked = NIL; + + ret_value = (unsigned int*)createcell68k(TYPE_FIXP); + *ret_value = pict; + return( LADDR_from_68k(ret_value) ); + +} /* end TrueColor_Initialize */ + +DLword *VideoEnableRegion68k; + +int +TrueColor_VideoInitialize( videoenable_bmbase ) +LispPTR videoenable_bmbase; +{ + Pixrect *source; + int mmapstat + , size; + + ScreenLocked = T; + + clear_video_region(); + Video_Initialize( FrameBufferFd ); + + VideoEnableRegion68k = Addr68k_from_LADDR( videoenable_bmbase ); + size = ( (displaywidth * displayheight/8 + (getpagesize()-1) ) + & -getpagesize() ); + + source = mem_point( displaywidth, displayheight, 1 + , VideoEnableRegion68k ); + pr_set_plane_group( TrueColorFb, PIXPG_VIDEO_ENABLE ); + pr_rop( TrueColorFb, 0, 0, displaywidth, displayheight + , PIX_SRC, source, 0, 0 ); + pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + + mmapstat = (int)mmap( VideoEnableRegion68k, + size, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x533000 ); + + if( mmapstat == -1 ) { + perror( "TrueColor_VideoInitialize: ERROR at mmap system call\n" ); + exit( 0 ); + } /* end if( mmapstat ) */ + + ScreenLocked = NIL; + return( T ); + +} /* TrueColor_VideoInitialize */ + +int +Overlay_Region( left, top, width, height, flg ) +int left + , top + , width + , height + , flg; +{ + ScreenLocked = T; + overlay_mouse_down(); + + cgeight_overlay_region( left, top, width, height + , (flg ? FALSE : TRUE) ); + + overlay_mouse_up( *EmCursorX68K, *EmCursorY68K ); + ScreenLocked = NIL; + +} /* end Overlay_Region */ + +#ifdef TRUECOLOR +#define TrackCursor(cx,cy) { \ + *CLastUserActionCell68k = MiscStats->secondstmp; \ + overlay_mouse_down(); \ + taking_mouse_down(); \ + taking_mouse_up(cx,cy); \ + overlay_mouse_up(cx,cy); \ + *EmCursorX68K= cx; \ + *EmCursorY68K= cy; \ + } +#endif /* TRUECOLOR */ + + +extern Pixrect *OverlaySave + , *OverlayCursor; + +overlay_mouse_up( newx, newy ) +int newx + , newy; +{ + pr_set_plane_group( TrueColorFb, PIXPG_OVERLAY_ENABLE ); + pr_rop( TrueColorFb, newx, newy, 16, 16, PIX_SRC + , OverlaySave, 0, 0 ); + pr_rop( TrueColorFb, 0, 0, 16, 16, PIX_SRC|PIX_DST + , OverlayCursor, newx, newy ); + pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + +} /* end overlay_mouse_up */ + +extern int LastCursorX + , LastCursorY; + +overlay_mouse_down() +{ + pr_set_plane_group( TrueColorFb, PIXPG_OVERLAY_ENABLE ); + pr_rop( OverlaySave, 0, 0, 16, 16, PIX_SRC + , TrueColorFb, LastCursorX, LastCursorY ); + pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + +}/* end overlay_mouse_down */ + +truecolor_before_exit() +{ + if( Inited_TrueColor ) { + { /* fill region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short*)OverlayRegion68k; + for( h = displayheight; (h--); ) { + for( w = DisplayRasterWidth; (w--); ) { + *(ptr++) = ~0; + } /* end for( w ) */ + } /* end for( h ) */ + } + + pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + pr_rop( TrueColorFb, 0, 0, displaywidth, displayheight + , PIX_SRC | PIX_COLOR( 0xffffff ), 0, 0, 0 ); + +#ifdef VIDEO + if( Inited_Video ) { + { /* clear video enable region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short*)VideoEnableRegion68k; + for( h = displayheight; (h--); ) { + for( w = DisplayRasterWidth; (w--); ) { + *(ptr++) = 0xffff; + } /* end for( w ) */ + } /* end for( h ) */ + } + + Video_Close(); + + } /* end if( Inited_Video ) */ +#endif /* VIDEO */ + + + pr_close( TrueColorFb ); + + } /* end if( Inited_TrueColor ) */ + +} /* truecolor_before_exit */ + +char *valloc(); +char *HideOverlayRegion; +#ifdef VIDEO +char *HideVideoEnableRegion; +extern int Video_OnOff_Flg; +static int video_onoff; +#endif /* VIDEO */ + + +truecolor_before_raid() +{ + int size; + + if( Inited_TrueColor ) { + size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) + & -getpagesize()); + + if( (HideOverlayRegion = valloc( size )) == 0 ) { + printf( "can't valloc hide space\n" ); + return( -1 ); + } /* end if( HideOverlayRegion ) */ + + copy_region( OverlayRegion68k, HideOverlayRegion + , DisplayRasterWidth, displayheight ); + + { /* fill region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short*)OverlayRegion68k; + for( h = displayheight; (h--); ) { + for( w = DisplayRasterWidth; (w--); ) { + *(ptr++) = 0xffff; + } /* end for( w ) */ + } /* end for( h ) */ + } + } /* end if( Inited_TrueColor ) */ + +#ifdef VIDEO + if( Inited_Video ) { + if( ( video_onoff = Video_OnOff_Flg) ) Video_OnOff( FALSE ); + if( (HideVideoEnableRegion = valloc( size )) == 0 ) { + printf( "can't valloc hide space\n" ); + return( -1 ); + } /* end if( HideVideoEnableRegion ) */ + + copy_region( VideoEnableRegion68k, HideVideoEnableRegion + , DisplayRasterWidth, displayheight ); + + { /* clear video enable region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short*)VideoEnableRegion68k; + for( h = displayheight; (h--); ) { + for( w = DisplayRasterWidth; (w--); ) { + *(ptr++) = 0xffff; + } /* end for( w ) */ + } /* end for( h ) */ + } + } /* end if( Inited_Video ) */ +#endif /* VIDEO */ + + +} /* end truecolor_before_raid */ + +truecolor_after_raid() +{ + int size + , mmapstat; + + if( Inited_TrueColor ) { + size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) + & -getpagesize()); + + + mmapstat = (int)mmap( OverlayRegion68k, + size, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x20000 ); + + if( mmapstat == -1 ) { + perror( "TrueColor_Initialize: ERROR at mmap system call\n" ); + exit( 0 ); + } /* end if( mmapstat ) */ + + copy_region( HideOverlayRegion, OverlayRegion68k + , DisplayRasterWidth, displayheight ); + free( HideOverlayRegion ); + } /* end if( Inited_TrueColor ) */ + +#ifdef VIDEO + if( Inited_Video ) { + mmapstat = (int)mmap( VideoEnableRegion68k, + size, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x533000 ); + + if( mmapstat == -1 ) { + perror( "TrueColor_VideoInitialize: ERROR at mmap system call\n" ); + exit( 0 ); + } /* end if( mmapstat ) */ + + copy_region( HideVideoEnableRegion, VideoEnableRegion68k + , DisplayRasterWidth, displayheight ); + free( HideVideoEnableRegion ); + if( video_onoff ) Video_OnOff( TRUE ); + + } /* end if( Inited_Video ) */ +#endif /* VIDEO */ + + +} /* end truecolor_after_raid */ diff --git a/src/tstsout.c b/src/tstsout.c new file mode 100755 index 0000000..82c965a --- /dev/null +++ b/src/tstsout.c @@ -0,0 +1,93 @@ +/* $Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; +/* + * tstsout.c + */ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include +#include +#include +#include +#include + +#include "adr68k.h" +#include "lispemul.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "lspglob.h" +#include "ifpage.h" +#include "dbprint.h" + +#define IFPAGE_ADDRESS 512 +#define MBYTE 0x100000 /* 1 Mbyte */ +extern int errno; + +/* JDS protoize char *valloc(size_t); */ + +main(int argc, char **argv) +{ + if (argc != 2) + { + printf("You forgot to supply a file name."); + return(-1); + } + check_sysout(argv[1]); + exit(0); + } + +check_sysout(char *sysout_file_name) +{ + int sysout; /* SysoutFile descriptor */ + + IFPAGE ifpage; /* IFPAGE */ + + char errmsg [ 255 ]; + + /* + * first read the IFPAGE(InterfacePage) + */ + + /* open SysoutFile */ + sysout = open(sysout_file_name, O_RDONLY, NULL); + if (sysout == -1) { + sprintf( errmsg, + "sysout_loader: can't open sysout file: %s", + sysout_file_name); + perror( errmsg ); + exit(-1); + } + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + /* reads IFPAGE into scratch_page */ + if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("sysout_loader: can't read IFPAGE"); + exit(-1); + } + +#ifdef BYTESWAP + word_swap_page(&ifpage, (3+sizeof(IFPAGE))/4); +#endif + close(sysout); + printf("%d", ifpage.minbversion); +} diff --git a/src/tty.c b/src/tty.c new file mode 100755 index 0000000..450bd52 --- /dev/null +++ b/src/tty.c @@ -0,0 +1,263 @@ +/* $Id: tty.c,v 1.2 1999/01/03 02:07:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: tty.c,v 1.2 1999/01/03 02:07:39 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "tty.h" + +DLTTY_OUT_COMMAND *DLTTYPortCmd; +DLTTY_IN_CSB *DLTTYIn; +DLTTY_OUT_CSB *DLTTYOut; + +char *TTY_Dev; +int TTY_Fd; +extern int LispReadFds; +struct sgttyb TTY_Mode; + +tty_init() +{ +#ifdef TRACE + printf( "TRACE: tty_init()\n" ); +#endif + + TTY_Dev = "/dev/ttyb"; /* Modify device name */ + TTY_Fd = (-1); + + DLTTYPortCmd = (DLTTY_OUT_COMMAND*) Addr68k_from_LADDR( IOPAGE_OFFSET+20 ); + DLTTYIn = (DLTTY_IN_CSB*) Addr68k_from_LADDR( IOPAGE_OFFSET+36 ); + DLTTYOut = (DLTTY_OUT_CSB*) Addr68k_from_LADDR( IOPAGE_OFFSET+34 ); +} /* tty_init end */ + +tty_open() +{ + int stat; + +#ifdef TRACE + printf( "TRACE: tty_open()\n" ); +#endif + + if ( TTY_Fd < 0 ) { + if (( TTY_Fd = open( TTY_Dev, O_RDWR )) >=0 ) { + + stat = ioctl( TTY_Fd, TIOCGETP, &TTY_Mode ); + TTY_Mode.sg_flags = RAW; + stat = ioctl( TTY_Fd, TIOCSETP, &TTY_Mode ); + + LispReadFds |= ( 1 << TTY_Fd ); +#ifdef TTYINT + int_io_open(TTY_Fd); +#endif + + } else { + error( "TTY: tty_open" ); + } + } +} /* tty_open end */ + + +tty_close() +{ + int stat; + +#ifdef TRACE + printf( "TRACE: tty_close()\n" ); +#endif + + if ( TTY_Fd >= 0 ) { + + LispReadFds &= ~( 1 << TTY_Fd ); + stat = close( TTY_Fd ); +#ifdef TTYINT + int_io_close(TTY_Fd); +#endif + TTY_Fd = (-1); + + } +} /* tty_close end */ + +TTY_get() +{ + char indata[256]; + int count; + +#ifdef TRACE + printf( "TRACE: tty_get()\n" ); +#endif + + if (( TTY_Fd >=0 ) && !DLTTYIn->state ) { + + DLTTYIn->in_data = '\0'; /* Clear Previous Data */ + + if (( count = read( TTY_Fd, indata, 1 )) == 1) { + DLTTYIn->in_data = indata[0]; + DLTTYIn->state = 1; + } else { + error( "TTY: tty_get" ); + } + + } +} /* TTY_get end */ + +tty_put() +{ + int count; + char c; + +#ifdef TRACE + printf( "TRACE: tty_put()\n" ); +#endif + + if ( TTY_Fd >= 0 ) { + + c = DLTTYPortCmd->outdata; + if (( count = write( TTY_Fd, &c, 1 )) != 1) { + error( "TTY: tty_put()" ); + } + } +} /* tty_put end */ + +tty_breakon() +{ + int stat; + +#ifdef TRACE + printf( "TRACE: tty_breakon()\n" ); +#endif + + if ( TTY_Fd >= 0 ) { + stat = ioctl( TTY_Fd, TIOCSBRK, 0 ); + } +} /* tty_breakon end */ + +tty_breakoff() +{ + int stat; + +#ifdef TRACE + printf( "TRACE: tty_breakoff()\n" ); +#endif + + if ( TTY_Fd >= 0 ) { + stat = ioctl( TTY_Fd, TIOCCBRK, 0 ); + } +} /* tty_breakoff end */ + +TTY_cmd() +{ +#ifdef TRACE + printf( "TRACE: tty_cmd()\n" ); +#endif + + if ( DLTTYPortCmd->command >= PUT_CHAR ) { + + if ( DLTTYPortCmd->command == PUT_CHAR ) tty_put(); + else if ( DLTTYPortCmd->command == SET_PARAM ) tty_setparam(); + else if ( DLTTYPortCmd->command == TTY_ON ) tty_open(); + else if ( DLTTYPortCmd->command == TTY_OFF ) tty_close(); + else if ( DLTTYPortCmd->command == TTY_BREAK_ON ) tty_breakon(); + else if ( DLTTYPortCmd->command == TTY_BREAK_OFF ) tty_breakoff(); + else + error( "TTY: tty_cmd"); + + DLTTYPortCmd->command &= ~PUT_CHAR; + } +} /* TTY_cmd end */ + +tty_setparam() +{ +#ifdef TRACE + printf( "TRACE: tty_setpram()\n" ); +#endif + + if ( DLTTYPortCmd->outdata & SET_BAUD_RATE ) tty_setbaudrate(); + +} /* tty_setpram end */ + +tty_setbaudrate() +{ + char baudrate; + int stat; + +#ifdef TRACE + printf( "TRACE: tty_setbaudrete()\n" ); +#endif + + if ( TTY_Fd >= 0 ) { + if (( baudrate = tty_baudtosymbol( DLTTYOut->line_speed )) != -1 ) { + TTY_Mode.sg_ispeed = baudrate; + TTY_Mode.sg_ospeed = baudrate; + stat = ioctl( TTY_Fd, TIOCSETP, &TTY_Mode ); + } else { + error( "TTY: tty_setbaudrate" ); + } + } +} /* tty_setbaudrate end */ + +tty_baudtosymbol(aBaud) + short aBaud; +{ + +#ifdef TRASE + printf("TRASE: tty_baudtosymbol(%x)\n",aBaud); +#endif + + if( aBaud== 0 ) return(B50); + if( aBaud== 1 ) return(B75); + if( aBaud== 2 ) return(B110); + if( aBaud== 3 ) return(B134); + if( aBaud== 4 ) return(B150); + if( aBaud== 5 ) return(B300); + if( aBaud== 6 ) return(B600); + if( aBaud== 7 ) return(B1200); + if( aBaud==10 ) return(B2400); + if( aBaud==12 ) return(B4800); + if( aBaud==14 ) return(B9600); + if( aBaud==15 ) return(EXTA); + return(-1); + +} /* tty_baudtosymbol */ + +tty_debug( name ) + char *name; +{ + int stat; + struct sgttyb mode; + + printf("DEBUG: %s\n",name); + printf("DEBUG: \t\tTTY_Dev = \"%s\"\n",TTY_Dev); + printf("DEBUG: \t\tTTY_Fd = %d\n",TTY_Fd); + + if ( TTY_Fd >= 0 ) { + stat = ioctl( TTY_Fd, TIOCGETP, &mode ); + printf("DEBUG: \t\tTTY_Mode.sg_ispeed = %#x\n",mode.sg_ispeed); + printf("DEBUG: \t\tTTY_Mode.sg_ospeed = %#x\n",mode.sg_ospeed); + printf("DEBUG: \t\tTTY_Mode.sg_erase = %#x\n",mode.sg_erase); + printf("DEBUG: \t\tTTY_Mode.sg_kill = %#x\n",mode.sg_kill); + printf("DEBUG: \t\tTTY_Mode.sg_flags = %#x\n",mode.sg_flags); + } + + printf("DEBUG:\n" ); + printf("DEBUG: \t\tSymbol Address Contents\n"); + printf("DEBUG: \t\tIOPAGE %#x\n",Addr68k_from_LADDR(IOPAGE_OFFSET)); + printf("DEBUG: \t\tDLTTYPortCmd %#x %#x\n",DLTTYPortCmd,*(DLword*) DLTTYPortCmd); + printf("DEBUG: \t\tDLTTYOut %#x %#x\n",DLTTYOut,*(DLword*) DLTTYOut); + printf("DEBUG: \t\t %#x\n",*(DLword*) (DLTTYOut+1)); + printf("DEBUG: \t\tDLTTYIn %#x %#x\n",DLTTYIn,*(DLword*) DLTTYIn); + printf("DEBUG: \t\t %#x\n",*(DLword*) (DLTTYIn+1)); + +} /* tty_debug end */ diff --git a/src/typeof.c b/src/typeof.c new file mode 100755 index 0000000..56ed6fe --- /dev/null +++ b/src/typeof.c @@ -0,0 +1,96 @@ +/* $Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + +/****************************************************************/ +/* LISTP(3Q),NTYPEX(4Q),TYPEP(5Q),DTEST(6Q) ,INSTANCEP(303Q) */ +/****************************************************************/ +/* + changed : Jan. 13 1987 take + changed : Feb. 05 1987 take + changed : Jul. 24 1987 take + +*/ + +#include "lispemul.h" +#include "lsptypes.h" +#include "cell.h" +#include "lispmap.h" +#include "lspglob.h" + + +/************************************************************************/ +/* */ +/* N _ O P _ d t e s t */ +/* */ +/* Check for type conformity, else error. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_dtest(register LispPTR tos, register int atom_index) +{ + register struct dtd *dtd68k ; + + for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(tos)); +#ifdef BIGVM + atom_index != dtd68k->dtd_name; +#else + atom_index != dtd68k->dtd_namelo+(dtd68k->dtd_namehi<<16) ; +#endif /* BIGVM */ + dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) + { + if( dtd68k->dtd_supertype == 0) ERROR_EXIT(tos); + } + return(tos); + } /* OP_DTEST END */ + + + + + +/************************************************************************/ +/* */ +/* N _ O P _ i n s t a n c e p */ +/* */ +/* Returns T if tos has type named by atom_index, else NIL. */ +/* */ +/************************************************************************/ + +LispPTR N_OP_instancep(register LispPTR tos, register int atom_index) +{ + register unsigned int type ; + register struct dtd *dtd68k ; + + for( dtd68k=(struct dtd *)GetDTD(GetTypeNumber(tos)); +#ifdef BIGVM + atom_index != dtd68k->dtd_name; +#else + atom_index != dtd68k->dtd_namelo+(dtd68k->dtd_namehi<<16) ; +#endif /* BIGVM */ + dtd68k=(struct dtd *)GetDTD(dtd68k->dtd_supertype) ) + { + if( dtd68k->dtd_supertype== 0) { return(NIL_PTR); } + } + return(ATOM_T); + + } /* N_OP_instancep END */ + diff --git a/src/ubf1.c b/src/ubf1.c new file mode 100755 index 0000000..6560be0 --- /dev/null +++ b/src/ubf1.c @@ -0,0 +1,94 @@ +/* $Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include +#include "lispemul.h" +#include "adr68k.h" +#include "lspglob.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "arith.h" +#include "medleyfp.h" +#include "my.h" +/************************************************************ + OP_ubfloat1 -- op 355 == UBFLOAT1 +355/0 BOX +355/1 UNBOX +355/2 ABS +355/3 NEGATE +355/4 UFIX +***********************************************************/ + +N_OP_ubfloat1(int arg, int alpha) +{ + switch (alpha) { + case 0: /* box */ + { + register DLword *wordp; + DLword *createcell68k(unsigned int type); + wordp = createcell68k(TYPE_FLOATP); + *((int *)wordp) = arg; + return(LADDR_from_68k(wordp)); + } + case 1: /* unbox */ + { + float dest; + int ret; + N_MakeFloat(arg, dest, arg); + ret = *(int *)&dest; + return(ret); + } + case 2: /* abs */ + return(0x7FFFFFFF & arg); + case 3: /* neg */ + return(0x80000000 ^ arg); + case 4: /* ufix */ + { + register float temp; + int val; + temp = *(float *)&arg; + if ( (temp > ((float) 0x7fffffff)) || + (temp < ((float) 0x80000000)) ) + ERROR_EXIT(arg); +#ifdef I386 + I386Reset; +#endif /* I386 */ + + val = (int)temp; +#ifdef I386 + I386Round; +#endif + N_ARITH_SWITCH(val); + } + default: ERROR_EXIT(arg); + }/* end switch */ +}/* end N_OP_ubfloat1() */ + + /* end module */ + + + + + + + + + diff --git a/src/ubf2.c b/src/ubf2.c new file mode 100755 index 0000000..716c109 --- /dev/null +++ b/src/ubf2.c @@ -0,0 +1,81 @@ +/* $Id: ubf2.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ubf2.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; +/* ubf2.c + */ + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include +#include +#include "lispemul.h" +#include "medleyfp.h" + +/************************************************************ + OP_ub2 -- op 354 == UBFLOAT2 +354/0 ADD +354/1 SUB +354/2 ISUB +354/3 MULT +354/4 DIV +354/5 GREAT +354/6 MAX +354/7 MIN +354/8 REM +354/9 AREF +***********************************************************/ +N_OP_ubfloat2(int a2, int a1, int alpha) +{ +REGISTER float arg1, arg2; +float ans; +int ret; + +/* Unboxed floating point args (a1, a2) look like float, but */ +/* can't be declared as such because all float args get passed */ +/* as double. (That can be avoided in ansi C.) Instead, they */ +/* are declared int and accessed as float through cast pointers. */ +/* The return value is handled similarly. */ + + + arg1 = *(float *)&a1; + arg2 = *(float *)&a2; + FPCLEAR; + switch (alpha) { + case 0: /* add */ ans = arg1 + arg2; break; + case 1: /* sub */ ans = arg2 - arg1; break; + case 2: /* isub */ ans = arg1 - arg2; break; + case 3: /* mul */ ans = arg1 * arg2; break; + case 4: /* div */ ans = arg2 / arg1; break; + case 5: /* gt */ if (arg2 > arg1) return(ATOM_T); else return(NIL_PTR); + case 6: /* max */ if (arg2 > arg1) return(a2); else return(a1); + case 7: /* min */ if (arg2 > arg1) return(a1); else return(a2); + case 8: /* rem */ ans = fmod(arg2,arg1); break; + default: ERROR_EXIT(a1); + }/* end switch */ + + ret = *(int *)&ans; /* Convert it back to int for 32 bit storage */ + if (FPTEST(ans)) ERROR_EXIT(a1); + return(ret); + + +}/* end N_OP_ub2() */ + + /* end module */ diff --git a/src/ubf3.c b/src/ubf3.c new file mode 100755 index 0000000..90d95e4 --- /dev/null +++ b/src/ubf3.c @@ -0,0 +1,60 @@ +/* $Id: ubf3.c,v 1.3 1999/05/31 23:35:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ubf3.c,v 1.3 1999/05/31 23:35:45 sybalsky Exp $ Copyright (C) Venue"; +/* ubf3.c + */ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lispmap.h" +#include "medleyfp.h" + +/************************************************************ + N_OP_ubfloat3 -- op 062 +062/0 POLY +***********************************************************/ + +N_OP_ubfloat3(int arg3, LispPTR arg2, LispPTR arg1, int alpha) +{ + REGISTER float val; + REGISTER float ans; + REGISTER float *fptr; + register int degree; + int ret; + float flot; + + val = *(float *)&arg3; /* why? */ + if (alpha) ERROR_EXIT(arg1); + FPCLEAR; + if ((arg1 & SEGMASK) != S_POSITIVE) ERROR_EXIT(arg1); + degree = 0xFFFF & arg1; + fptr = (float *)Addr68k_from_LADDR(arg2); + ans = *((float *)fptr); + while (degree--) ans = (ans * val) + *((float *)(++fptr)); + if (FPTEST(ans)) ERROR_EXIT(arg1); /* relies on contagion of inf, nan? */ + flot = ans; + ret = *(int *)&flot; /* why? */ + return(ret); + }/* end N_OP_ubfloat3() */ + + /* end module */ diff --git a/src/ufn.c b/src/ufn.c new file mode 100755 index 0000000..e7394cc --- /dev/null +++ b/src/ufn.c @@ -0,0 +1,227 @@ +/* $Id: ufn.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ufn.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright (C) Venue"; +/******************************************************************/ +/* + + File Name : ufn.c(for use with SYSOUT) + Including : ufn + + Created : jun 8, 1987 by T.Shimizu + + +*/ +/******************************************************************/ + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include "lispemul.h" +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "stack.h" +#include "emlglob.h" +#include "lspglob.h" +#include "initatms.h" +#include "cell.h" + +#ifdef C_ONLY + +#define GetUFNEntry(num) (((UFN *)UFNTable) + (num)) + + +/******************************************************************/ +/* + + Func Name : ufn + Desc : call Lisp UFN func + TopOfStack; + PC ; + + Created : May 29, 1987 by T.Shimizu + Changed : Jun 17 1987 take + Aug 25 1987 take + Sep 4 1987 NMitani + Oct 07 1987 take + Nov 13 1987 take +8 & Simple STKCHK + Nov 25 1987 take(tmp_fn) +*/ +/******************************************************************/ + +ufn(bytecode) +DLword bytecode ; +{ + register DefCell *defcell68k ; /* Definition Cell PTR */ + register int pv_num ; /* scratch for pv */ + register UFN *entry68k; + register struct fnhead *tmp_fn; + register unsigned int arg_num ; /* Num of args */ + register int rest ; /* use for arignments */ + + +#ifdef TRACE + printPC(); + print_atomname("TRACE : ufn() 0%o ",bytecode); +#endif + + PushCStack; + + entry68k = (UFN *)GetUFNEntry(bytecode); /*changing I/F 17-jun*/ + +#ifdef TRACE + if(entry68k->atom_name) + printf("Atom number: %d\n", 0xffff && entry68k->atom_name); + else + error("UNF not specified"); +#endif + + switch(entry68k->byte_num) + { + case 0 : break; + case 1 : /*PushStack(SPOS_HI | Get_BYTE(PC+1));*/ + CurrentStackPTR +=2; + GETWORD(CurrentStackPTR)=SPOS_HI; + GETWORD(CurrentStackPTR+1)=(DLword)Get_code_BYTE(PC+1); + /* I think we don't have to shift alpha byte eight bit before save it. */ +#ifdef DEBUG + printf("***ufn: case 1\n"); +#endif + break; + + case 2 : /*PushStack(S_POSITIVE |Get_DLword(PC+1));*/ + CurrentStackPTR +=2; + GETWORD(CurrentStackPTR) = SPOS_HI ; + GETWORD(CurrentStackPTR+1) = (DLword)((Get_code_BYTE(PC+1) << 8) | Get_code_BYTE(PC+2)); + +#ifdef DEBUG + printf("***ufn: case 2\n"); +#endif + break; + default : error("ufn : Bad UFN MP 9351 "); + break; + } + + /* Get Next Block offset form OPCODE byte */ + CURRENTFX->nextblock = (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) + - (entry68k->arg_num<<1) +2 /** +1 **/ ; + + /* Setup IVar */ + IVar = Addr68k_from_LADDR((((LispPTR)(CURRENTFX->nextblock)) | STK_OFFSET)) ; + +#ifdef LISPTRACE + print(entry68k->atom_name);printf(": "); + {int cnt; + for(cnt=0;cntpc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) + entry68k->byte_num +1; + + + + defcell68k =(DefCell *) GetDEFCELL68k(entry68k->atom_name) ; + + if( defcell68k->ccodep == 0 ) + { /* This LispFunc is NOT compiled object . We must use Interpreter*/ + printf("UFN: UFN func isn't compiled OBJ \n"); + defcell68k = (DefCell *)GetDEFCELL68k(ATOM_INTERPRETER); + PushStack(TopOfStack); /* Move AtomIndex to CSTK */ + + } + + + /* Nov 25 87 take */ + tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ) ; + +/* stack overflow check STK_SAFE is redundant?? */ + if ( (UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) >= (UNSIGNED)StkLimO ) + { + /**printf("#### STKOVER in UFN case\n");**/ + + DOSTACKOVERFLOW(entry68k->arg_num,entry68k->byte_num); /* After STKOVR, retry current OPCODE */ + + } + + FuncObj =tmp_fn ; + + if( FuncObj->na >= 0 ) + { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = entry68k->arg_num - FuncObj->na ; + + while(rest <0) { + PushStack(NIL_PTR) ; + rest++; + } + CurrentStackPTR -= (rest<<1) ; + } /* if end */ + + /* Set up BF */ + CurrentStackPTR +=2; + GETWORD(CurrentStackPTR) = BF_MARK ; + GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock ; + CurrentStackPTR +=2; +/* *(++CurrentStackPTR) = CURRENTFX->nextblock ; */ + + /* Set up FX */ + GETWORD(CurrentStackPTR) = FX_MARK; + + + ((struct frameex1 *)CurrentStackPTR)->alink = LADDR_from_68k(PVar); + PVar = (DLword *)CurrentStackPTR + FRAMESIZE ; +#ifdef BIGVM + ((struct frameex1 *)CurrentStackPTR)->fnheader = + (defcell68k->defpointer) ; +#else + ((struct frameex1 *)CurrentStackPTR)->lofnheader = + (defcell68k->defpointer) & 0x0ffff ; + ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = + ((defcell68k->defpointer) & SEGMASK) >> 16 ; +#endif /* BIGVM */ + + CurrentStackPTR = PVar ; + + /* Set up PVar area */ + pv_num = FuncObj->pv +1 ; + + while(pv_num > 0) { + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000 ; + CurrentStackPTR += DLWORDSPER_CELL ; + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000 ; + CurrentStackPTR += DLWORDSPER_CELL ; + pv_num--; + } + +/* CurrentStackPTR ++ ;*/ + + /* Set PC points New Function's first OPCODE */ + PC =(ByteCode *) ((UNSIGNED)FuncObj + FuncObj->startpc) ; + +/** TopOfStack = (FuncObj->startpc -1) >> 1;**/ + +} /* end ufn */ + + +#endif + diff --git a/src/ufs.c b/src/ufs.c new file mode 100755 index 0000000..1e000bb --- /dev/null +++ b/src/ufs.c @@ -0,0 +1,1425 @@ +/* $Id: ufs.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: ufs.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +#include +#ifndef DOS +#include +#ifndef SYSVONLY +#include +#else +#include +#endif /* SYSVONLY */ + +#include +#ifndef INDIGO + /* Indigo has this duplicated in dirent.h, sigh. */ +#ifndef OS5 +#ifndef HPUX +#include +#endif +#endif +#endif /* INDIGO */ + +#include +#include +#ifndef AIX +#ifndef APOLLO +#include +#endif /* APOLLO */ +#endif /* AIX */ + +#ifdef SYSVONLY +#include +#include +#endif /* SYSVONLY */ + +#include +#else /* DOS */ +#include +#include +#include +#include +#include + +#include /* "#pragma interrupt" & '_chain_intr'*/ +#include +#include +#include /* _XSTACK struct definition */ + +#define MAXPATHLEN _MAX_PATH +#define MAXNAMLEN _MAX_PATH +#define index strchr +#define rindex strrchr +#define alarm(x) 1 +#endif /* DOS */ + +#include +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "arith.h" +#include "stream.h" +#include "timeout.h" +#include "locfile.h" +#include "dbprint.h" + +int *Lisp_errno; +int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ + +/***********************************************/ +/* file-system-specific defns */ +/***********************************************/ +#ifdef DOS +#define DIRSEP '\\' +#define DIRSEPSTR "\\" +#else +#define DIRSEP '/' +#define DIRSEPSTR "/" +#endif +#define DRIVESEP ':' + + /* Used to limit DOS filenames to 8.3 format */ + +#ifdef DOS +#define NameValid extensionp ? (extlen < 3) : (namelen < 8) +#define CountNameChars { extensionp ? extlen++ : namelen++; } + +#else + /* Other file systems don't care */ +#define NameValid 1 +#define CountNameChars +#endif /* DOS */ + +#ifdef DOS + +void (*prev_int_24)(); /* keeps address of previous 24 handlr*/ +#pragma interrupt(Int24) + +/* + * Name: Int24 + * + * Description: Bypass the "Abort, Retry, Fail?" message that + * DOS issues. + * + */ +void Int24(void) +{ + unsigned deverr, errcode; + + union REGS regs; + _XSTACK *stk; + stk = (_XSTACK *)_get_stk_frame(); /* get ptr to the V86 _XSTACK frame */ + deverr = stk->eax; + + if ((deverr & 0x00008000) == 0) /* is a disk error */ + { + stk->eax = _HARDERR_FAIL; + stk->opts |= _STK_NOINT; /* set _STK_NOINT to prevent V86 call */ + _chain_intr(prev_int_24); /* call previous int 24 handlr, if any*/ + /* (pts to 'ret' if no prev installed)*/ + } +} + +/* + * Name: init_host_filesystem + * + * Description: Initialize the hosts filesystem by installing + * the "critical error handler". + */ +init_host_filesystem() +{ + prev_int_24 = _dos_getvect(0x24); /* get addr of current handler, if any */ + _dos_setvect(0x24, Int24); /* hook our int handler to interrupt */ + _dpmi_lockregion((void *)prev_int_24, sizeof(prev_int_24)); + _dpmi_lockregion((void *)&Int24, 4096); +} + +/* + * Name: exit_host_filesystem + * + * Description: Cleanup the filesystem specific patches. + * + */ +exit_host_filesystem() +{ + _dos_setvect(0x24, prev_int_24); /* unhook our handlr, install previous*/ + _dpmi_unlockregion((void *)prev_int_24, sizeof(prev_int_24)); + _dpmi_unlockregion((void *)&Int24, 4096); +} + +#endif /* DOS */ + + +/* + * Name: UFS_getfilename + * + * Argument: LispPTR *args args[0] + * Full file name in Lisp format. + * args[1] + * Rcoginition mode. See IRM. + * args[2] + * Name area where the recognized full file name + * will be stored. + * args[3] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp smallp which represents the length + * of the recognized full file name, otherwise Lisp NIL. + * + * Side Effect: If succeed, name area (args[2]) will be replaced with the + * recognized full file name. + * + * Description: + * + * The implementation of GETFILENAME FDEV method for UNIX device. Performs the + * recognition on the specified name. Does not check if OPENFILE actually + * can open the file with the specified mode or not. + */ + +UFS_getfilename(args) + register LispPTR *args; +{ + register char *base; + register int len, rval; + char lfname[MAXPATHLEN], file[MAXPATHLEN]; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], len, rval); + len += 1; /* Add 1 for tuminating NULL char. */ + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); + /* + * Convert a Lisp file name to UNIX one. This is a UNIX device method. + * Thus we don't need to convert a version field. Third argument for + * unixpathname specifies it. + */ +#ifdef DOS + if (unixpathname(lfname, file, 0, 0, 0, 0, 0) == 0) return(NIL); +#else + if (unixpathname(lfname, file, 0, 0) == 0) return(NIL); +#endif /* DOS */ + + switch (args[1]) { + + case RECOG_OLD: + case RECOG_OLDEST: + /* + * "Old" and "Oldest" means the "existing" file. All we have to do + * is to make sure it is an existing file or not. + */ + TIMEOUT(rval = access(file, F_OK)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + break; + + case RECOG_NEW: + case RECOG_OLD_NEW: + case RECOG_NON: + /* + * "New" file means the "not existing" file. UNIX device always + * recognizes a not existing file as if, the subsequent OPENFILE will + * find the truth. + * "Non" reognition is used to recognize a sysout file. + */ + break; + } + /* + * Now, we convert a file name back to Lisp format. The version field have not + * to be converted. The fourth argument for lisppathname specifies it. + */ + if (lisppathname(file, lfname, 0, 0) == 0) return(NIL); + + STRING_BASE(args[2], base); + len = strlen(lfname); + +#ifndef BYTESWAP + strncpy(base, lfname, len + 1); +#else + StrNCpyFromCToLisp(base, lfname, len + 1); +#endif /* BYTESWAP */ + + + return(GetSmallp(len)); +} + + + + +/* + * Name: UFS_deletefile + * + * Argument: LispPTR *args args[0] + * Full file name in Lisp format. + * args[1] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp symbol T, otherwise Lisp NIL. + * + * Side Effect: If succeed, the specified file is unlinked. + * + * Description: + * + * The implementation of DELETEFILE FDEV method for UNIX device. Try to delete + * a specified file. + */ + +UFS_deletefile(args) + register LispPTR *args; +{ + char file[MAXPATHLEN], fbuf[MAXPATHLEN]; + register int len, rval; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); + + LispStringLength(args[0], len, rval); + len += 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); + +#ifdef DOS + if (unixpathname(fbuf, file, 0, 0, 0, 0, 0) == 0) return(NIL); +#else + if (unixpathname(fbuf, file, 0, 0) == 0) return(NIL); +#endif /* DOS */ + + /* + * On UNIX device, all we have to do is just to unlink the file. + */ + TIMEOUT(rval = unlink(file)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + + return(ATOM_T); +} + + + + +/* + * Name: UFS_renamefile + * + * Argument: LispPTR *args args[0] + * Full file name in Lisp format. The file which + * is being renamed. + * args[1] + * Full file name in Lisp format. The file to which + * args[0] is being renamed. + * args[2] + * The place where the error number should be + * stored. + * + * Value: If succeed, returns the Lisp symbol T, otherwise Lisp NIL. + * + * Side Effect: If succeed, the specified file is unlinked. + * + * Description: + * + * The implementation of RENAMEFILE FDEV method for UNIX device. Try to rename + * a specified file. + */ + +UFS_renamefile(args) + register LispPTR *args; +{ + char fbuf[MAXPATHLEN], src[MAXPATHLEN], dst[MAXPATHLEN]; + int rval, len; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + + LispStringLength(args[0], len, rval); + len += 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringLength(args[1], len, rval); + len += 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); +#ifdef DOS + if (unixpathname(fbuf, src, 0, 0, 0, 0, 0) == 0) return(NIL); +#else + if (unixpathname(fbuf, src, 0, 0) == 0) return(NIL); +#endif /* DOS */ + LispStringToCString(args[1], fbuf, MAXPATHLEN); +#ifdef DOS + if (unixpathname(fbuf, dst, 0, 0, 0, 0, 0) == 0) return(NIL); +#else + if (unixpathname(fbuf, dst, 0, 0) == 0) return(NIL); +#endif /* DOS */ + + TIMEOUT(rval = rename(src, dst)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + + return(ATOM_T); +} + + + + +/* + * Name: UFS_directorynamep + * + * Argument: LispPTR *args args[0] + * Directory name in Lisp format. Both of the initial + * and trail directory delimiter are stripped by Lisp + * code. Only one exception is a "root directory". + * "Root directory is represented as ">". + * args[1] + * The place where the "true" name of the directory + * in Lisp format will be stored. + * args[2] + * The place where the error number should be stored. + * Not use in the current Lisp code implementation. + * + * Value: If succeed, returns the Lisp smallp which represents the length + * of the "true" name of the directory, otherwise Lisp NIL. + * + * Side Effect: If the directory is recognized as a valid directory representation, + * args[1] is replaced with the "true" directory name. + * + * Description: + * + * The implementation of the DIRECTORYNAMEP FDEV method for UNIX device. + * Performs the recoginition as well. Accepts the directory representation which + * obeys the Xerox Lisp file naming convention. The "true" name which is stored + * on the area specified with the second argument also follows the Xerox Lisp + * file naming convention, and it includes the initial and trail directory + * delimiter. Thus the Lisp code does not have to worry about the conversion of + * the directory name representation. + */ + +UFS_directorynamep(args) + register LispPTR *args; +{ + char dirname[MAXPATHLEN]; + char fullname[MAXPATHLEN]; + register int len, rval; + register char *base; + struct stat sbuf; + + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + + LispStringLength(args[0], len, rval); + len += 1; + /* -2 for the initial and trail directory delimitor. */ + if (len > MAXPATHLEN - 2) FileNameTooLong(NIL); + + LispStringToCString(args[0], dirname, MAXPATHLEN); + + /* Convert Xerox Lisp file naming convention to Unix one. */ +#ifdef DOS + if (unixpathname(dirname, fullname, 0, 0, 0, 0, 0) == 0) return(NIL); +#else + if (unixpathname(dirname, fullname, 0, 0) == 0) return(NIL); +#endif /* DOS */ + + TIMEOUT(rval = stat(fullname, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(NIL); + } + + if ((sbuf.st_mode & S_IFMT) != S_IFDIR) return(NIL); + + /* Convert Unix file naming convention to Xerox Lisp one. */ + if (lisppathname(fullname, dirname, 1, 0) == 0) return(NIL); + + len = strlen(dirname); + STRING_BASE(args[1], base); + +#ifndef BYTESWAP + strncpy(base, dirname, len + 1); +#else + StrNCpyFromCToLisp(base, dirname, len + 1); +#endif /* BYTESWAP */ + + + return(GetSmallp(len)); +} + + + + +/* + * Name: unixpathname + * + * Argument: char *src Xerox Lisp syntax pathname. + * The HOST name field is not included. + * The initial directory delimiter is not included and + * if the pathname is passed as a directory, the + * tail delimiter may be included. + * char *dst The buffer to which the converted pathname is stored. + * int versionp + * If 1, version field in src is converted to UNIX + * version form. {DSK} device invokes unixpathname + * with versionp. + * int genp If 1, it indicates unixpathname is called from + * directory enmumerateion routine. In this case, + * trail period which is used to specify an empty + * extension field is treated specially. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: None. + * + * Description: + * + * Converts the Xerox Lisp syntax pathname to Unix syntax pathname. + * Src pathname might start with the one of the meta characters. And it + * might include Xerox Lisp pathname quote notation. The characters + * must be quoted in the Xerox Lisp file naming convention are valid in the UNIX + * file naming convention. So only skipping the quote character would be + * sufficient. + * If the trail directory delimiter, '>', is included in src, dst will also include + * UNIX trail directory delimiter '/'. + * + */ +#ifdef DOS +unixpathname(src, dst, versionp, genp, drive, extlenptr, rawname) + char *drive; + int *extlenptr; + char *rawname; +#else +unixpathname(src, dst, versionp, genp) +#endif /* DOS */ + register char *src; + register char *dst; + register int versionp; + register int genp; +{ + register char *cp, *dp, *np, *rp; + register int newdirflg; + char name[64]; + char lfname[MAXPATHLEN], fbuf1[MAXPATHLEN], fbuf2[MAXPATHLEN]; + char ver1[VERSIONLEN], ver2[VERSIONLEN]; + struct passwd *pwd; + +#ifdef DOS + int namelen = 0, extlen = 0; /* lengths of name & extension */ + int extensionp = 0; /* T if we're in the extension */ + int version = 1; /* version # for this file */ +#endif /* DOS */ + + + /* If there's a drive letter, it and a colon come first */ +#ifdef DOS + if (drive && (*drive)) + { + *dst++ = *drive; + *dst++ = DRIVESEP; + } +#endif /* DOS */ + + /* + * The UNIX root directory is represented as "<" in Xerox Lisp generic + * file system code. + */ + if (strcmp(src, "<") == 0) { + strcpy(dst, DIRSEPSTR); + return(1); + } + + /* Copy src to protect it from destructive modification. */ + strcpy(lfname, src); + + /* + * If versionp is specified, we have to deal with the version field first, + * because the quotation mark which quotes the semicolon might be lost + * in the course of the following conversion. + */ +#ifdef DOS + if (versionp) LispVersionToUnixVersion(lfname, version) + else version = -1; +#else + if (versionp) LispVersionToUnixVersion(lfname); +#endif /* DOS */ + + cp = lfname; + dp = dst; + + /* + * We have to deal with the case in which the pathname is started with + * the meta character ('.', '~'). + */ + + switch (*cp) { + + case '.': + switch (*(cp + 1)) { + + case '.': + if (*(cp + 2) == '>' || *(cp +2) == '\0') { + /* + * "..>" or ".." means the parent directory of the + * user's current working directory. + */ + if (getwd(dst) == 0) return(0); +#ifdef DOS + dp = max(strrchr(dst,'/'),strrchr(dst,DIRSEP)); +#else + dp = strrchr(dst, '/'); +#endif /* DOS */ + + dp++; + if (*(cp + 2) == '\0') + cp += 2; + else + cp += 3; + } else { + /* Insert the initial directory delimiter. */ + *dp++ = DIRSEP; + } + break; +#ifdef DOS + case '/': + case DIRSEP: +#endif + case '>': + /* ".>" means the user's current working directory. */ + if (getwd(dst) == 0) return(0); + while (*dp != '\0') dp++; + + *dp++ = DIRSEP; + cp += 2; + break; + + case '\0': + /* "." also means the user's current working directory. */ + if (getwd(dst) == 0) return(0); + while (*dp != '\0') dp++; + + *dp++ = DIRSEP; + cp++; + break; + + default: + /* Insert the initial directory delimiter. */ + *dp++ = DIRSEP; + break; + } + break; +#ifndef DOS + case '~': + if (*(cp + 1) == '>' || *(cp + 1) == '\0') { + /* "~>" or "~" means the user's home directory. */ + TIMEOUT(pwd = getpwuid(getuid())); + if (pwd == NULL) return(0); + + strcpy(dst, pwd->pw_dir); + while (*dp != '\0') dp++; + if (*(dp -1) != DIRSEP) { + /* + * Usually system administrators specify the users' + * home directories in the /etc/passwd without + * the trail directory delimiter. + */ + *dp++ = DIRSEP; + } + if (*(cp + 1) == '\0') + cp++; + else + cp += 2; + } else { + /* + * In this case, we assume some user's home directory + * is specifed in the form "~username". + */ + for (++cp, np = name; *cp != '\0' && *cp != '>';) *np++ = *cp++ ; + *np = '\0'; + TIMEOUT(pwd = getpwnam(name)); + if (pwd == NULL) return(0); + + strcpy(dst, pwd->pw_dir); + while (*dp != '\0') dp++; + if (*(dp -1) != DIRSEP) { + /* + * Usually system administrators specify the users' + * home directories in the /etc/passwd without + * the trail directory delimiter. + */ + *dp++ = DIRSEP; + } + + if (*cp == '>') cp++; + } + break; + +#else + /* For DOS, ignore ~> or ~/ or ~ */ + case '~': + if (*(cp + 1) == '>' || *(cp + 1) == '\0') + { + /* "~>" or "~" means the user's home directory. */ + + *dp++ = DIRSEP; + if (*(cp + 1) == '\0') cp++; + else cp += 2; + } + else + { + /* + * In this case, we assume some user's home directory + * is specifed in the form "~username". + */ + for (++cp, np = name; *cp != '\0' && *cp != '>';) *np++ = *cp++ ; + *dp++ = DIRSEP; + + if (*cp == '>') cp++; + } + break; + +#endif /* DOS */ + default: + *dp++ = '/'; /* Insert the initial directory delimiter. */ + break; + } + + /* + * At this point, cp is placed at the point from which the source pathname + * will be scaned, and dp is placed at the point on dst from which the + * pathname will be copied. + */ + + newdirflg = 1; + while (*cp != '\0') { + if (newdirflg) { + /* + * The new directory component starts. We have to care about + * the meta characters again. This time, the tilde character + * has no special meaning. + */ + switch (*cp) { + + case '.': + switch (*(cp + 1)) { + + case '.': + /* "..>" or ".." */ + if (*(cp + 2) == '>' || *(cp + 2) == '\0') { + /* + * We have to check if we have already + * backed to the root directory or not. + */ + if ((dp - 1) != dst) { + /* + * We are not at the root + * directory. Back to the + * parent directory. + */ + for (dp -= 2; *dp != '/'; dp--) {} + dp++; + } + if (*(cp + 2) == '\0') + cp += 2; + else + cp += 3; + } else { + /* + * (IL:DIRECTORY "{DSK}.") is translated + * as (IL:DIRECTORY "{DSK}~>.;*"). + * The Lisp directory is translated as + * like "/users/akina/..~*~" by + * unixpathname. Although such + * file name representaion makes no sense, + * to avoid infinite loop, skip the + * first period here, as well as down + * a newdirflg. + */ + cp++; + newdirflg = 0; + } + break; + + case '>': + /* ".>" */ + cp += 2; + break; + + case '\0': + /* "." */ + cp++; + break; + + default: + *dp++ = *cp++; + newdirflg = 0; + break; + } + break; + + case '\'': + /* + * The first character of the new directory component + * is a quotation mark which is the quote character + * in the Xerox Lisp file naming convention. Copy the + * next character and skip the quoted character. + */ + *dp++ = *(cp + 1); + cp += 2; + newdirflg = 0; + break; + + default: + *dp++ = *cp++; + newdirflg = 0; + break; + } + } else { + switch (*cp) { +#ifdef DOS + case '/': /* in DOS, must xlate / also. */ +#endif /* DOS */ + case '>': + /* + * Xerox Lisp directory delimiter '>' is translated into + * UNIX one, '/'. + */ + *dp = DIRSEP; + dp++; + cp++; + newdirflg = 1; /* Turn on the new directory flag. */ +#ifdef DOS + namelen = extlen = 0; + rp = dp; /* remember where raw filename starts */ +#endif /* DOS */ + break; + + case '\'': + /* + * The special characters in the Xerox Lisp file naming + * convention are quoted with the quote character. + * They are all valid in the UNIX file naming convention. + * So only we have to do is to skip the quotation mark + * and copy the next character. + */ +#ifdef DOS + if (NameValid) *dp++ = *(cp + 1); + CountNameChars; +#endif /* DOS */ + cp += 2; + break; +#ifdef DOS + case '.': /* start of extension, if not already */ + if (!extensionp) *dp++ = *cp++; else cp++; + extensionp = 1; + break; +#endif /* DOS */ + default: + if (NameValid) *dp++ = *cp++; else cp++; + CountNameChars; + break; + } + } + } + *dp = '\0'; + if (!newdirflg && !genp) { + /* + * If the last chracter in dst is a period, it have to be handled + * specially, because it might be used to specify that src has no + * extension field. This case can be distinguish by examining the + * character just before the period. + * If the specified pathname is one like "~>..", the last meta character + * matches this case. Thus we check newdirflg first so as not to be + * confused by this case. + * + * Only case in which genp is 1 is unixpathname is used to convert + * a pattern which is used to enumerate directory. In this csae, + * for the convinience of the pattern matching routines, we don't + * care about the last period character. + */ + strcpy(fbuf1, lfname); + strcpy(fbuf2, dst); + separate_version(fbuf1, ver1, 1); + separate_version(fbuf2, ver2, 1); + for (cp = fbuf1; *cp; cp++) {} + for (dp = fbuf2; *dp; dp++) {} + if (*(cp - 1) == '.') { + if (*(cp - 2) != '\'' || + ((cp - 3) > fbuf1 && *(cp - 3) == '\'')) { + /* + * The last period is not been quoted. It is used + * to specify the no extension case. We have to + * omit this period. + */ + *(dp - 1) = '\0'; + } + } +#ifdef DOS + if (version >= 0) sprintf(ver2, "%d", version); + else *ver2 = '\0'; +#endif /* DOS */ + ConcNameAndVersion(fbuf2, ver2, dst); + } + return(1); +} + + + + +/* + * Name: lisppathname + * + * Argument: char *fullname UNIX full pathname. + * char *lispname The pathnaem following the Xerox + * Lisp naming convention. + * The first argument fullname is assumed + * the "true" name of lispname. + * The lispname is used to determine which + * charcter should be quoted in the result + * Xerox Lisp pathname representation. + * int dirp If 1, fullname is a directory. If 0, + * fullname is a file. + * int versionp If 1, version field is also converted + * to the Xerox Lisp version. {DSK} device + * invokes lisppathname with versionp but + * {UNIX} device without versionp. If + * versionp is 1, dirp must be 0. + * + * Value: If succeed, returns 1, otherwise 0. + * of the "true" name of the directory, otherwise Lisp NIL. + * + * Side Effect: If succeed, lispname is replaced with "true" name which follows + * the Xerox Lisp file naming convention. + * + * Description: + * + * Converts the UNIX file name to Xerox Lisp file name. The fields which might + * be included in the result filename are directory, name, extension, and version. + * The result file name can use the quotation mark to quote the chracters which + * are dealt with specially in the Xerox Lisp file naming convention. These + * characters include "<", ">", ";", ".", and "'" itself. Notice that "." must be + * quoted if it is used as a part of the extension field. Also notice that "<" + * is quoted only if it is used as a first character of the initial directory. + * + */ + +lisppathname(fullname, lispname, dirp, versionp) + register char *fullname; + register char *lispname; + register int dirp; + register int versionp; +{ + register char *cp, *dp, *lnamep, *cnamep; + char namebuf[MAXPATHLEN], fbuf[MAXPATHLEN], ver[VERSIONLEN], drive; + register int i, mask, extensionp; + + if (strcmp(fullname, DIRSEPSTR) == 0) { + strcpy(lispname, "<"); + return(1); + } + /* Split off the drive, if there is one. */ + if (fullname[1] == DRIVESEP) + { + *lispname++ = *fullname++; + *lispname++ = *fullname++; + } + + if (!dirp) { + /* + * The characters which are dealt with specialy (i.e. are quoted) + * in the Xerox Lisp file naming convention are all valid in UNIX + * file name convetion. So the conversion rule is almost + * straightforward except the "extension" field. Only glancing + * the UNIX file name, we cannot determine which period character + * should be quoted in the result Xerox Lisp file name when more + * than one period are included in the UNIX file name. In such + * case, we have to refer to the Xerox Lisp file name representation + * which is specified the user. Thus, at first, extract the + * name field from the original Lisp file name. + */ + cp = lispname; + lnamep = cp - 1; + while (*cp != '\0') { + switch (*cp) { + + case '>': + lnamep = cp + 1; + cp++; + break; + + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; + + default: + cp++; + break; + } + } + /* Name field in the UNIX file name representation. */ + cnamep = strrchr(fullname, DIRSEP) + 1; + } else { + cnamep = fullname + strlen(fullname); + } + + /* + * Convertion rule of file name from UNIX to Xerox Lisp. + * UNIX Lisp + * / < only if it is used as a root directory + * delimiter. + * / > if used as a directory delimiter for other + * directories than root directory. + * > '> + * ; '; + * ' '' + * . '. only if it is used as a part of the extension + * field. + * others as if + */ + + cp = fullname + 1; + dp = namebuf; + *dp++ = '<'; + + if (*cp == '<') { + /* + * If the first character of the initial directory is '<', + * it should be quoted in the result Lisp file name. + */ + *dp++ = '\''; + *dp++ = *cp++; + } + + while (cp < cnamep) { + switch (*cp) { + + case '>': + case ';': +#ifndef DOS + case '\'': +#endif /* DOS */ + *dp++ = '\''; + *dp++ = *cp++; + break; + +#ifdef DOS + case '/': +#endif + case DIRSEP: + *dp++ = '>'; + cp++; + break; + + default: + *dp++ = *cp++; + break; + } + } + + if (dirp) { + if (*(dp - 1) != '>' || *(dp - 2) == '\'') *dp++ = '>'; + *dp = '\0'; + strcpy(lispname, namebuf); + return(1); + } + + /* + * Be careful dealing with the extenstion field. If we encounter with the + * period mark which was quoted in the original Lisp file name, we have + * to quote it in the result file name. + * First we count the period mark included in the Lisp file name, and + * remember the position of the quoted period. Then when we met the + * period while we are converting the UNIX file name into Lisp one, + * examine it if it is a quoted one or not, then if so, we quote it. + */ + + mask = 0; + i = 1; + lnamep++; + + while (*lnamep) { + if (*lnamep == '.') { + if (lnamep != lispname && *(lnamep - 1) == '\'') mask |= i; + i <<= 1; + } + lnamep++; + } + + i = 1; + while (*cp) { + switch (*cp) { +#ifdef DOS + case DIRSEP: *dp++ = '/'; cp++; break; +#endif + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; + + case '.': + if ((i & mask) == i) { + /* This period should be quoted. */ + *dp++ = '\''; + *dp++ = *cp++; + } else { + *dp++ = *cp++; + } + i <<= 1; + break; + + default: + *dp++ = *cp++; + break; + } + } + + *dp = '\0'; + + /* + * exntensionp indicates whether exentsion field is included in a file name + * or not. If extenstion field is not included, we have to add a period + * to specify empty extension field. + */ + strcpy(fbuf, namebuf); + dp = cp = fbuf; + while (*cp) { + switch (*cp) { + + case '>': + dp = cp; + cp++; + break; + + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; + + default: + cp++; + break; + } + } + cp = dp + 1; + if (versionp) separate_version(fbuf, ver, 1); + extensionp = 0; + while (*cp && !extensionp) { + switch (*cp) { + + case '.': + extensionp = 1; + break; + + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; + + default: + cp++; + break; + } + } + if (!extensionp) { + *cp++ = '.'; + *cp = '\0'; + } + if (versionp && *ver != '\0') { + ConcNameAndVersion(fbuf, ver, namebuf); + } else { + strcpy(namebuf, fbuf); + } + + /* + * Now, it's time to convert the version field. + */ + if (!dirp && versionp) UnixVersionToLispVersion(namebuf, 0); + + strcpy(lispname, namebuf); + return(1); +} + + + + +/* + * Name: quote_fname + * + * Argument: char *file The root file name in UNIX format. "Root" + * file name contains the name, extenstion and + * version fields. A valid version field is in a + * form as ".~##~". + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: If succeed, file is replaced with the file name in Xerox Lisp format + * in which special characters are quoted. + * + * Description: + * + * Converts a UNIX root file name to Xerox Lisp one. This routine only quotes special + * characters in Xerox file naming convention, does not care about the "true" name + * which might be specified directly by the user as like lisppathname. Thus, this + * routine can be invoked when you don't know how to escape the period character. This + * is the case when you convert a file name in the course of the directory enumeration. + * + * This routine is used when file is a "FILE" name and being converted to {DSK} name. + * + * The special characters which is quoted include "<", ">", ";", and "'" itself. Notice + * again that "." is not quoted, because we don't know it is a extension separator in + * Lisp sense or not. + */ + +quote_fname(file) + register char *file; +{ + register char *cp, *dp; + register int extensionp; + char fbuf[MAXNAMLEN + 1], namebuf[MAXNAMLEN + 1], ver[VERSIONLEN]; + + cp = file; + dp = fbuf; + + while (*cp) { + switch (*cp) { + + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; + + default: + *dp++ = *cp++; + break; + } + } + *dp = '\0'; + + /* + * exntensionp indicates whether exentsion field is included in a file + * name or not. If extenstion field is not included, we have to add a + * period to specify empty extension field. + */ + separate_version(fbuf, ver, 1); + cp = fbuf; + extensionp = 0; + while (*cp && !extensionp) { + switch (*cp) { + + case '.': + if (*(cp + 1)) extensionp = 1; + cp++; + break; + + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; + + default: + cp++; + break; + } + } + if (!extensionp) { + if (*(cp - 1) == '.') { + *(cp - 1) = '\''; + *cp++ = '.'; + } + *cp++ = '.'; + *cp = '\0'; + } + if (*ver != '\0') { + ConcNameAndVersion(fbuf, ver, namebuf); + } else { + strcpy(namebuf, fbuf); + } + UnixVersionToLispVersion(namebuf, 1); + strcpy(file, namebuf); +} + + + + +/* + * Name: quote_fname_ufs + * + * Argument: char *file The root file name in UNIX format. "Root" + * file name contains the name, extenstion and + * version fields. A valid version field is in a + * form as ".~##~". + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: If succeed, file is replaced with the file name in Xerox Lisp format + * in which special characters are quoted. + * + * Description: + * + * Similar to quote_fname, but this routine is only used when file is a "FILE" name + * and being converted to {UNIX} name. + */ + +quote_fname_ufs(file) + register char *file; +{ + register char *cp, *dp; + register int extensionp; + char fbuf[MAXNAMLEN + 1]; + + cp = file; + dp = fbuf; + + while (*cp) { + switch (*cp) { + + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; + + default: + *dp++ = *cp++; + break; + } + } + *dp = '\0'; + + /* + * exntensionp indicates whether exentsion field is included in a file + * name or not. If extenstion field is not included, we have to add a + * period to specify empty extension field. + */ + cp = fbuf; + extensionp = 0; + while (*cp && !extensionp) { + switch (*cp) { + + case '.': + if (*(cp + 1)) extensionp = 1; + cp++; + break; + + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; + + default: + cp++; + break; + } + } + if (!extensionp) { + if (*(cp - 1) == '.') { + *(cp - 1) = '\''; + *cp++ = '.'; + } + *cp++ = '.'; + *cp = '\0'; + } + strcpy(file, fbuf); +} + + + + +/* + * Name: quote_dname + * + * Argument: char *dir The directory name in UNIX format. Does not + * include its parent name. + * + * Value: If succeed, returns 1, otherwise 0. + * + * Side Effect: If succeed, dir is replaced with the directory name in Xerox Lisp + * format in which special characters are quoted. + * + * Description: + * + * Similar to quote_fname, but this routine is only used when dir is a "DIRECTORY" + * name. Both {DSK} and {UNIX} uses this routine. + */ + +quote_dname(dir) + register char *dir; +{ + register char *cp, *dp; + char fbuf[MAXNAMLEN + 1]; + + cp = dir; + dp = fbuf; + + while (*cp) { + switch (*cp) { + + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; + + default: + *dp++ = *cp++; + break; + } + } + *dp = '\0'; + + if (*(dp - 1) == '.') { + /* Trail period should be quoted. */ + *(dp - 1) = '\''; + *dp++ = '.'; + } + + strcpy(dir, fbuf); +} diff --git a/src/unixcomm.c b/src/unixcomm.c new file mode 100755 index 0000000..abd2c23 --- /dev/null +++ b/src/unixcomm.c @@ -0,0 +1,1228 @@ +/* %Z% %M% Version %I% (%G%). copyright venue & Fuji Xerox */ +static char *id = "%Z% %M% %I% %G% (venue & Fuji Xerox)"; + + + +/* + +Unix Interface Communications + +*/ + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 by Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include "lispemul.h" +#ifndef DOS + + /* FULLSLAVENAME => use a full file name for slave PTY */ +#ifdef INDIGO +#define FULLSLAVENAME +#elif OS5 +#define FULLSLAVENAME +#endif /* INDIGO or OS5 */ + +/* JRB - timeout.h needs setjmp.h */ +#include +#include +#include "timeout.h" +#include +#ifdef OS4 +#include +#elif APOLLO +#include +#elif LINUX +#include +#else +#include +#endif /* OS4 */ + +#include +#include +#include +#include +#include +#include +#ifdef ISC +#include +/* Needed for window size setting ops: */ +#include +#else +#include +#include +#endif /* ISC */ + +#ifdef SYSVONLY +#include +#endif /* HPUX */ + + +#ifdef sun + /* to get S_IFIFO defn for creating fifos */ +#include +#endif /* sun */ + +#include "address.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "emlglob.h" +#include "lspglob.h" +#include "cell.h" +#include "stack.h" +#include "arith.h" +#include "dbprint.h" +#ifdef GCC386 +#include "inlinePS2.h" +#endif /* GCC386 */ + + +static __inline__ int +SAFEREAD(int f, char *b, int c) +{ + int res; + loop: + res = read(f, b, c); + if ( (res < 0) ) + { + if ( errno == EINTR || errno == EAGAIN ) goto loop; + perror("reading UnixPipeIn"); + } + return (res); +} + +#include "locfile.h" /* for LispStringToCString. */ + +/* JDS fixing protoypes char *malloc(size_t); */ + +int NPROCS = 100; + + +/* The following globals are used to communicate between Unix + subprocesses and LISP */ + + +/* One of these structures exists for every possible file descriptor */ +/* type field encodes kind of stream: */ + +#define UJUNUSED 0 /* Unused */ +#define UJSHELL -1 /* PTY shell */ +#define UJPROCESS -2 /* random process */ +#define UJSOCKET -3 /* socket open for connections */ +#define UJSOSTREAM -4 /* connection from a UJSOCKET */ + + /* These are indexed by WRITE socket# */ +struct unixjob { + char *pathname; /* used by Lisp direct socket access subr */ + int readsock; /* Socket to READ from for this job. */ + int PID; /* process ID associated with this slot */ + int status; /* status returned by subprocess (not shell) */ + int type; +}; + +struct unixjob *UJ; /* allocated at run time */ + +long StartTime; /* Time, for creating pipe filenames */ + +#define valid_slot(slot) ((slot) >= 0 && (slot) < NPROCS && UJ[slot].type) + +char shcom[2048]; /* Here because I'm suspicious of */ + /* large allocations on the stack */ + + + +/************************************************************************/ +/* */ +/* f i n d _ p r o c e s s _ s l o t */ +/* */ +/* Find the slot in UJ with process id 'pid'. */ +/* Returns the slot #, or -1 if pid isn't found */ +/* */ +/* */ +/************************************************************************/ + +int find_process_slot(register int pid) +/* Find a slot with the specified pid */ + + { + register int slot; + + for (slot = 0; slot < NPROCS; slot++) + if (UJ[slot].PID == pid) + { + DBPRINT(("find_process_slot = %d.\n", slot)); + return slot; + } + return -1; + } + + + +/************************************************************************/ +/* */ +/* w a i t _ f o r _ c o m m _ p r o c e s s e s */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +wait_for_comm_processes(void) +{ + int pid; + int slot; + int res; + unsigned char d[5]; + + d[0] = 'W'; + write(UnixPipeOut, d, 4); + SAFEREAD(UnixPipeIn, d, 4); + + pid = (d[0]<<8) | d[1]; + while ((pid != 0) && (pid != 65535)) + { + slot = find_process_slot(pid); + /* Ignore processes that we didn't start (shouldn't happen but + occasionally does) */ + if (slot >= 0) + { + if (d[2] == 0) + { + DBPRINT(("Process %d exited status %d\n", pid, d[3])); + UJ[slot].status = d[3]; + } + else + { + DBPRINT(("Process %d terminated with signal %d\n", pid, d[2])); + UJ[slot].status = (d[2] << 8); + } + } + /* Look for another stopped process. */ + d[0] = 'W'; + write(UnixPipeOut, d, 4); + SAFEREAD(UnixPipeIn, d,4); + + pid = (d[0]<<8) | d[1]; + } +} + +/************************************************************************/ +/* */ +/* b u i l d _ s o c k e t _ p a t h n a m e */ +/* */ +/* Returns a string which is the pathname associated with a */ +/* socket descriptor. Has ONE string buffer. */ +/************************************************************************/ +#ifndef ISC +char *build_socket_pathname(int desc) +{ + static char PathName[50]; + + sprintf(PathName, "/tmp/LPU%d-%d", StartTime, desc); + return(PathName); +} + +#else + +char *build_upward_socket_pathname(desc) +int desc; +{ + static char UpPathName[50]; + + sprintf(UpPathName, "/tmp/LPU%d-%d", StartTime, desc); + return(UpPathName); +} + +char *build_downward_socket_pathname(desc) +int desc; +{ + static char DownPathName[50]; + + sprintf(DownPathName, "/tmp/LPD%d-%d", StartTime, desc); + return(DownPathName); +} +#endif /* ISC */ + + +/************************************************************************/ +/* */ +/* c l o s e _ u n i x _ d e s c r i p t o r s */ +/* */ +/* Kill off forked PTY-shells and forked-command processes */ +/* Also close sockets */ +/* */ +/************************************************************************/ + + +close_unix_descriptors(void) /* Get ready to shut Maiko down */ +{ + int slot; + + for (slot = 0; slot < NPROCS; slot++) { + + /* If this slot has an active job */ + switch(UJ[slot].type) { + + case UJSHELL: + if (kill(UJ[slot].PID, SIGKILL)<0) perror("Killing shell"); + UJ[slot].PID = 0; + DBPRINT(("Kill 5 closing shell desc %d.\n", slot)); + close(slot); + break; + + case UJPROCESS: + if (kill(UJ[slot].PID, SIGKILL)<0) perror("Killing process"); + UJ[slot].PID = 0; + DBPRINT(("Kill 5 closing process desc %d.\n", slot)); + close(slot); + break; + + case UJSOCKET: + close(slot); + if(UJ[slot].pathname != NULL) { + /* socket created directly from Lisp; pathname is in .pathname */ + DBPRINT(("Closing socket %d bound to %s\n", slot, UJ[slot].pathname)); + unlink(UJ[slot].pathname); + free(UJ[slot].pathname); + UJ[slot].pathname = NULL; + } + break; + + case UJSOSTREAM: + close(slot); + break; + } + UJ[slot].type = UJUNUSED; + } + +/* make sure everyone's really dead before proceeding */ + wait_for_comm_processes(); +} + +/************************************************************************/ +/* */ +/* F i n d U n i x P i p e s */ +/* */ +/* Find the file descriptors of the UnixPipe{In,Out} pipes */ +/* and a few other important numbers that were set originally */ +/* before the unixcomm process was forked off; it stuck them in the */ +/* environment so we could find them after the original lde process */ +/* got overlaid with the real emulator */ +/* */ +/************************************************************************/ + +FindUnixPipes(void) +{ + char *envtmp, *getenv(const char *); + register int i; + struct unixjob cleareduj; + + DBPRINT(("Entering FindUnixPipes\n")); + UnixPipeIn = UnixPipeOut = StartTime = UnixPID = -1; + if(envtmp = getenv("LDEPIPEIN")) + UnixPipeIn = atoi(envtmp); + if(envtmp = getenv("LDEPIPEOUT")) + UnixPipeOut = atoi(envtmp); + if(envtmp = getenv("LDESTARTTIME")) + StartTime = atoi(envtmp); + if(envtmp = getenv("LDEUNIXPID")) + UnixPID = atoi(envtmp); + + /* This is a good place to initialize stuff like the UJ table */ +#ifdef SYSVONLY + NPROCS = sysconf(_SC_OPEN_MAX); +#else + NPROCS = getdtablesize(); +#endif /* SYSVONLY */ + + UJ = (struct unixjob *) malloc(NPROCS * sizeof(struct unixjob)); + cleareduj.status = -1; + cleareduj.pathname = NULL; + cleareduj.PID = 0; + cleareduj.readsock = 0; + cleareduj.type = UJUNUSED; + for(i=0; i< NPROCS; i++) UJ[i] = cleareduj; + + DBPRINT(("NPROCS is %d; leaving FindUnixPipes\n", NPROCS)); + return (UnixPipeIn == -1 + || UnixPipeOut == -1 + || StartTime == -1 + || UnixPID == -1); +} + + + + + +/************************************************************************/ +/* */ +/* F i n d A v a i l a b l e P t y */ +/* */ +/* Given strings Master and Slave, fill them with path names */ +/* of the forms: */ +/* */ +/* Master: /dev/ptyxx */ +/* Slave: /dev/ttyxx */ +/* */ +/* Which are the first available pty/tty pair for communicating */ +/* with a forked shell. */ +/* */ +/* Assumes that valid PTY names are [pqr][0-f]; if your system */ +/* is different, you'll need to change it. */ +/* */ +/************************************************************************/ + + +#define PTYLETTERS "pqr" +#define PTYNUMBERS "0123456789abcdef" + +/* Find the first PTY pair that is not in use */ + +FindAvailablePty(char *Master, char *Slave) +{ + int res, flags; + char *let, *num; +#ifdef INDIGO + + let = (char *) _getpty(&res, O_RDWR|O_NDELAY, 0600, 0); + strcpy(Slave, let); +#elif OS5 + + res = open("/dev/ptmx", O_RDWR); + if (res < 0) { perror("ptmx open"); return(-1); } + grantpt(res); + unlockpt(res); + strcpy(Slave, ptsname(res)); + DBPRINT(("slave pyt name is %s.\n", Slave)); +#else + + /* From p to r */ + for (let = PTYLETTERS; *let != 0; let++) + + /* and 0 to f */ + for (num = PTYNUMBERS; *num != 0; num++) { + + sprintf(Master, "/dev/pty%c%c", *let, *num); + sprintf(Slave, "%c%c", *let, *num); + DBPRINT(("Trying %s. ", Master)); + /* Try to open the Master side */ + res = open(Master, O_RDWR); +#endif + + if (res != -1) + { + flags = fcntl(res, F_GETFL, 0); +#ifdef ISC + flags |= O_NONBLOCK; +#else + flags |= FNDELAY; +#endif /* ISC */ + + flags = fcntl(res, F_SETFL, flags); + return(res); + } +#ifndef FULLSLAVENAME + } +#endif /* because we commented out the for above also... */ + return(-1); +} + + + + + + + +/************************************************************************/ +/* */ +/* U n i x _ h a n d l e c o m m */ +/* */ +/* LISP subr to talk to the forked "Unix process". */ +/* */ +/* The first argument (Arg[0]) is the command number. */ +/* Second argument (Arg[1]) is the Job # (except as indicated). */ +/* */ +/* Commands are: */ +/* */ +/* 0 Fork Pipe, Arg1 is a string for system(); */ +/* => Job # or NIL */ +/* 1 Write Byte, Arg2 is Byte; */ +/* => 1 (success), NIL (fail) */ +/* 2 Read Byte => Byte, NIL (no data), or T (EOF) */ +/* 3 Kill Job => Status or T */ +/* 4 Fork PTY to Shell (no args) => Job # or NIL */ +/* 5 Kill All (no args) => T */ +/* 6 Close (EOF) */ +/* 7 Job status => T or status */ +/* 8 => the largest supported command # (11 now) */ +/* 9 Read Buffer, Arg1 = vmempage (512 byte buffer) */ +/* => byte count (<= 512), NIL (no data), or T (EOF) */ +/* 10 Set Window Size, Arg2 = rows, Arg3 = columns */ +/* 11 Fork PTY to Shell (obsoletes command 4) */ +/* Arg1 = termtype, Arg2 = csh command string */ +/* => Job # or NIL */ +/* 12 Create Unix Socket */ +/* Arg1 = pathname to bind socket to (string) */ +/* => Socket # or NIL */ +/* 13 Try to accept on unix socket */ +/* => Accepted socket #, NIL (fail) or T (try again) */ +/* 14 Query job type */ +/* => type number or NIL if not a job */ +/* 15 Write Buffer, Arg1 = Job #, Arg2 = vmempage, */ +/* Arg3 = # of bytes to write from buffer */ +/* => # of bytes written or NIL (failed) */ +/* */ +/************************************************************************/ + + +Unix_handlecomm(LispPTR *args) +{ + int command,c, dest, PID, i, slot, sock, res; + LispPTR retval; + unsigned char d[4], b[1]; + unsigned char ch; + unsigned char buf[1]; + + + /* Get command */ + N_GETNUMBER(args[0], command, bad); + DBPRINT(("Unix_handlecomm: trying %d\n", command)); + + switch(command) + { + + case 0: /* Fork pipe process */ + { + char *UpPipeName, *DownPipeName, *PipeName; + int res, slot, PipeFD, sockFD; + +#ifndef ISC + /* First create the socket */ + struct sockaddr_un sock; + sockFD = socket(AF_UNIX, SOCK_STREAM, 0); + if (sockFD < 0) { perror("socket open"); return(NIL);} + + /* then bind it to a canonical pathname */ + PipeName = build_socket_pathname(sockFD); + sock.sun_family = AF_UNIX; + strcpy(sock.sun_path, PipeName); + if (bind(sockFD, (struct sockaddr *) &sock, + strlen(PipeName)+sizeof(sock.sun_family)) < 0) + { + close(sockFD); + perror("binding sockets"); + unlink(PipeName); + return(NIL); + } + + DBPRINT(("Socket %d bound to name %s.\n", sockFD, PipeName)); + + if(listen(sockFD, 1)<0) perror("Listen"); +#else + + sockFD = open("/tmp/dummyforlisp" , O_CREAT); + UpPipeName = build_upward_socket_pathname(sockFD); + DownPipeName = build_downward_socket_pathname(sockFD); + + DBPRINT(("Downward FIFO: %s\n", DownPipeName)); + DBPRINT(("Upward FIFO: %s\n", UpPipeName)); +#ifdef sun + if ((mknod(UpPipeName, 0777|S_IFIFO, 0) < 0) && (errno != EEXIST)) + { + perror("Making Upward FIFO"); + printf("(named %s).\n", UpPipeName); fflush(stdout); + } + if ((mknod(DownPipeName, 0777|S_IFIFO, 0)<0) && (errno != EEXIST)) + { + perror("Making Downward FIFO"); + printf("(named %s).\n", DownPipeName); fflush(stdout); + } +#else + if (mkfifo(UpPipeName, 0777) < 0) + { + perror("Making Upward FIFO"); + printf("(named %s).\n", UpPipeName); fflush(stdout); + } + if (mkfifo(DownPipeName, 0777) < 0) + { + perror("Making Downward FIFO"); + printf("(named %s).\n", DownPipeName); fflush(stdout); + } +#endif /* SUNs */ + + PipeFD= open(DownPipeName, O_WRONLY | O_NDELAY); + if (PipeFD < 0) + { + perror("Opening Down pipe from lisp"); + printf("(Name is %s.)\n",DownPipeName); fflush(stdout); + close(sockFD); + return(NIL); + } + dup2(PipeFD,sockFD); + unlink("/tmp/dummyforlisp"); + + PipeFD = open(UpPipeName, O_RDONLY | O_NDELAY); + if (PipeFD < 0) + { + perror("Opening Up pipe from lisp"); + printf("(Name is %s.)\n", UpPipeName); fflush(stdout); + close(sockFD); + return(NIL); + } +#endif /* ISC */ + + + d[0] = 'F'; + d[3] = sockFD; + write(UnixPipeOut, d, 4); + WriteLispStringToPipe(args[1]); + + DBPRINT(("Sending cmd string: %s\n", shcom)); + + /* Get status */ + SAFEREAD(UnixPipeIn, d, 4); + + /* If it worked, return job # */ + if (d[3] == 1) + { +#ifndef ISC + case0_lp: + TIMEOUT(PipeFD = accept(sockFD, (struct sockaddr *) 0, + (int *) 0)); + if (PipeFD < 0) + { + if (errno == EINTR) goto case0_lp; + perror("Accept."); + close(sockFD); + if (unlink(PipeName)<0) perror("Unlink"); + return(NIL); + } +#endif /* oldPIPEway */ + res = fcntl(PipeFD, F_GETFL, 0); +#ifdef ISC + res |= O_NONBLOCK; +#else + res |= FNDELAY; +#endif /* ISC */ + res = fcntl(PipeFD, F_SETFL, res); + if (res < 0) + { + perror("setting up fifo to nodelay"); + return(NIL); + } +#ifdef ISC + UJ[sockFD].type = UJPROCESS; + UJ[sockFD].status = -1; + UJ[sockFD].PID = (d[1]<<8) | d[2]; + UJ[sockFD].readsock = PipeFD; +#else + UJ[PipeFD].type = UJPROCESS; + UJ[PipeFD].status = -1; + UJ[PipeFD].PID = (d[1]<<8) | d[2]; + UJ[PipeFD].readsock = 0; + close(sockFD); + unlink(PipeName); +#endif /* ISC */ + + + /* unlink(UpPipeName); + unlink(DownPipeName); */ +#ifdef ISC + return(GetSmallp(sockFD)); +#else + return(GetSmallp(PipeFD)); +#endif /* ISC */ + } + else + { + DBPRINT(("Fork request failed.")); +#ifdef ISC + close(sockFD); close(PipeFD); + unlink(UpPipeName); + unlink(DownPipeName); +#else + close(sockFD); + unlink(PipeName); +#endif /* ISC */ + return(NIL); + } + break; + } + + case 1: /* Write byte */ + /* Get job #, Byte */ + N_GETNUMBER(args[1], slot, bad); + N_GETNUMBER(args[2], dest, bad); ch = dest; /* ch is a char */ + + if (valid_slot(slot) && (UJ[slot].status == -1)) + switch(UJ[slot].type) { + + case UJPROCESS: + case UJSHELL: + case UJSOSTREAM: + dest = write(slot, &ch, 1); + if (dest == 0) { + wait_for_comm_processes(); + return(NIL); + } + else return(GetSmallp(1)); + break; + + default: return(NIL); + } + break; + + case 2: /* Read byte */ + /**********************************************************/ + /* */ + /* NB that it is possible for the other end of the stream */ + /* to have terminated, and hence status != -1. */ + /* EVEN IF THERE ARE STILL CHARACTERS TO READ. */ + /* */ + /**********************************************************/ + + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + + if (!valid_slot(slot)) return(NIL); /* No fd open; punt the read */ + + if(UJ[slot].readsock) sock = UJ[slot].readsock; else sock = slot; + + switch(UJ[slot].type) { + + case UJPROCESS: + case UJSHELL: + case UJSOSTREAM: + TIMEOUT(dest = read(sock, buf, 1)); + if (dest > 0) return(GetSmallp(buf[0])); + /* Something's amiss; check our process status */ + wait_for_comm_processes(); + if ((dest == 0) && (UJ[slot].status == -1)) + { /* No available chars, but other guy still running */ + DBPRINT(("dest = 0, status still -1\n")); + return(ATOM_T); + } + if ((UJ[slot].status == -1) && + ((errno == EWOULDBLOCK) || (errno == EAGAIN)) ) + { /* No available chars, but other guy still running */ + DBPRINT((" dest<0, EWOULDBLOCK\n")); + return(ATOM_T); + } + /* At this point, we either got an I/O error, or there */ + /* were no chars available and the other end has terminated. */ + /* Either way, signal EOF. */ + DBPRINT(("Indicating EOF from PTY desc %d.\n", slot)); + return(NIL); + break; + + default: + return(NIL); + break; + } + break; + + + case 3: /* Kill process */ + /* Maiko uses this as CLOSEF, so "process" is a misnomer */ + + N_GETNUMBER(args[1], slot, bad); + + DBPRINT(("Killing process in slot %.\n", slot)); + + if (valid_slot(slot)) + switch(UJ[slot].type) + { + + case UJSHELL: + case UJPROCESS: + /* First check to see it hasn't already died */ + if (UJ[slot].status == -1) + { + int i; + /* Kill the job */ + kill(UJ[slot].PID, SIGKILL); + for (i = 0; i < 10; i++) + { + /* Waiting for the process to exit is possibly risky. + Sending SIGKILL is always supposed to kill + a process, but on very rare occurrences this doesn't + happen because of a Unix kernel bug, usually a user- + written device driver which hasn't been fully + debugged. So we time it out just be safe. */ + if (UJ[slot].status != -1) break; + wait_for_comm_processes(); + sleep(1); + } + } + break; + + } + else return(ATOM_T); + + switch(UJ[slot].type) { + + case UJSHELL: + DBPRINT(("Kill 3 closing shell desc %d.\n", slot)); + close(slot); + break; + + case UJPROCESS: + DBPRINT(("Kill 3 closing process desc %d.\n", slot)); + close(slot); if (UJ[slot].readsock) close(UJ[slot].readsock); + break; + + case UJSOSTREAM: + DBPRINT(("Kill 3 closing stream socket desc %d.\n", slot)); + close(slot); + break; + + case UJSOCKET: + DBPRINT(("Kill 3 closing raw socket desc %d.\n", slot)); + close(slot); + DBPRINT(("Unlinking %s\n", UJ[slot].pathname)); + if(UJ[slot].pathname) { + if(unlink(UJ[slot].pathname) < 0) + perror("Kill 3 unlink"); + free(UJ[slot].pathname); + UJ[slot].pathname = NULL; + } + break; + } + UJ[slot].type = UJUNUSED; + UJ[slot].readsock = UJ[slot].PID = 0; + UJ[slot].pathname = NULL; + + /* If status available, return it, otherwise T */ + return(GetSmallp(UJ[slot].status)); + break; + + + case 4: case 11: /* Fork PTY process */ + { + char MasterFD[20], SlavePTY[32]; + int Master, res, slot; + unsigned short len; + + Master = FindAvailablePty(MasterFD, SlavePTY); + slot = Master; + DBPRINT(("Fork Shell; Master PTY = %d. Slave=%c%c.\n", + Master, SlavePTY[0], SlavePTY[1])); + if (Master < 0) + { + printf("Open of lisp side of PTY failed.\n"); + fflush(stdout); + return(NIL); + } + + d[0] = (command == 4) ? 'S': 'P'; + d[1] = SlavePTY[0]; + d[2] = SlavePTY[1]; + d[3] = slot; + write(UnixPipeOut, d, 4); + +#ifdef FULLSLAVENAME + len = strlen(SlavePTY) + 1; + write(UnixPipeOut, &len, 2); + write(UnixPipeOut, SlavePTY, len); +#endif + + if (command != 4) + { /* New style has arg1 = termtype, arg2 = command */ + WriteLispStringToPipe (args[1]); + WriteLispStringToPipe (args[2]); + } + + /* Get status */ + SAFEREAD(UnixPipeIn, d, 4); + + /* If successful, return job # */ + DBPRINT(("Pipe/fork result = %d.\n", d[3])); + if (d[3] == 1) + { + /* Set up the IO not to block */ + res = fcntl(Master, F_GETFL, 0); +#ifdef ISC + res |= O_NONBLOCK; +#else + res |= FNDELAY; +#endif /* ISC */ + res = fcntl(Master, F_SETFL, res); + + UJ[slot].type = UJSHELL; /* so we can find them */ + UJ[slot].PID = (d[1]<<8) | d[2]; +printf("Shell job %d, PID = %d\n", slot, UJ[slot].PID); + UJ[slot].status = -1; + DBPRINT(("Forked pty in slot %d.\n", slot)); + return(GetSmallp(slot)); + } + else + { + printf("Fork failed.\n"); fflush(stdout); + printf("d = %d, %d, %d, %d\n",d[0],d[1],d[2],d[3]); + close(Master); + return(NIL); + } + break; + } + + case 5: /* Kill all the subprocesses */ + + close_unix_descriptors(); + return(ATOM_T); + + case 6: /* Kill this subprocess */ + d[0] = 'C'; + + /* Get job # */ + N_GETNUMBER(args[1], dest, bad); + d[1] = dest; + + d[3] = 1; + write(UnixPipeOut, d, 4); + + /* Get status */ + SAFEREAD(UnixPipeIn, d, 4); + + switch(UJ[dest].type) { + + case UJSHELL: + DBPRINT(("Kill 5 closing shell desc %d.\n", dest)); + close(dest); + break; + + case UJPROCESS: + DBPRINT(("Kill 5 closing process desc %d.\n", dest)); + close(dest); if(UJ[dest].readsock) close(UJ[dest].readsock); + UJ[dest].readsock=0; + break; + + case UJSOCKET: + /* close a socket; be sure and unlink the file handle */ + DBPRINT(("Kill 5 closing raw socket desc %d.\n", dest)); + close(dest); + if(UJ[dest].pathname != NULL) { + unlink(UJ[dest].pathname); + free(UJ[dest].pathname); + UJ[dest].pathname = NULL; + } /* else return an error somehow... */ + break; + + case UJSOSTREAM: + DBPRINT(("Kill 5 closing socket stream %d.\n", dest)); + close(dest); + break; + } + + UJ[dest].type = UJUNUSED; + UJ[dest].readsock = UJ[dest].PID = 0; + return(ATOM_T); + /* break; */ + + + case 7: /* Current job status */ + + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + wait_for_comm_processes(); /* Make sure we're up to date */ + + if (UJ[slot].status == -1) return (ATOM_T); + else return(GetSmallp(UJ[slot].status)); + break; + + case 8: /* Return largest supported command */ + + return(GetSmallp(15)); + + + case 9: /* Read buffer */ + /**********************************************************/ + /* */ + /* NB that it is possible for the other end of the stream */ + /* to have terminated, and hence ForkedStatus != -1. */ + /* EVEN IF THERE ARE STILL CHARACTERS TO READ. */ + /* */ + /**********************************************************/ + + { char *bufp; + int terno; /* holds errno thru sys calls after I/O fails */ + + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + if (!valid_slot(slot)) return(NIL); /* No fd open; punt the read */ + + if (UJ[slot].readsock) sock = UJ[slot].readsock; else sock = slot; + + bufp = (char*)(Addr68k_from_LADDR(args[2])); /* User buffer */ + DBPRINT(("Read buffer slot %d, type is %d\n", slot, UJ[slot].type)); + + switch(UJ[slot].type) { + case UJSHELL: + case UJPROCESS: + case UJSOSTREAM: + dest = read(sock, bufp, 512); +#ifdef BYTESWAP + word_swap_page(bufp, 128); +#endif /* BYTESWAP */ + + if (dest > 0) + { /* Got characters. If debugging, print len &c */ + /* printf("got %d chars\n", dest); */ + return(GetSmallp(dest)); + } + + /* Something's amiss; update process status */ + DBPRINT(("Problem: Got status %d from read, errno %d.\n", dest, errno)); +#ifndef ISC + wait_for_comm_processes(); /* make sure we're up to date */ + if (((dest == 0) || (errno == EINTR) || (errno == 0) || + (errno == EAGAIN) || + (errno == EWOULDBLOCK)) && (UJ[slot].status == -1)) + /* No available chars, but other guy still running */ + return(ATOM_T); +#else + if (dest == 0) wait_for_comm_processes(); /* make sure we're up to date, because dest==0 means no process is writing there. */ + if (((errno == EINTR) || (errno == 0) || + (errno == EAGAIN) || + (errno == EWOULDBLOCK)) && (dest == -1) && (UJ[slot].status == -1)) + /* No available chars, but other guy still running */ + return(ATOM_T); +#endif /* ISC */ + + /* At this point, we either got an I/O error, or there */ + /* were no chars available and the other end has terminated. */ + /* Either way, signal EOF. */ + DBPRINT(("read failed; dest = %d, errno = %d, status = %d\n", + dest, terno, UJ[slot].status)); + DBPRINT(("Indicating EOF from PTY desc %d.\n", slot)); + return(NIL); + + default: + return(NIL); + } + } + + case 10: /* Change window */ + { int rows, cols, pgrp, pty; +#if (!defined( HPUX) && !defined(RISCOS)) + struct winsize w; +#endif /* HPUX */ + + /* Get job #, rows, columns */ + N_GETNUMBER(args[1], slot, bad); + N_GETNUMBER(args[2], rows, bad); + N_GETNUMBER(args[3], cols, bad); + +#if (!defined(HPUX) && !defined(RISCOS)) + if (valid_slot(slot) + && (UJ[slot].type == UJSHELL) + && (UJ[slot].status == -1)) + { + w.ws_row = rows; + w.ws_col = cols; + w.ws_xpixel = 0; /* not used */ + w.ws_ypixel = 0; + pty = slot; + /* Change window size, then + notify process group of the change */ + if ((ioctl(pty, TIOCSWINSZ, &w) >= 0) && +#ifdef ISC + (tcgetpgrp(pty) >= 0) && +#else + (ioctl(pty, TIOCGPGRP, &pgrp) >= 0) && +#endif /* ISC */ + +#ifdef SYSVONLY + (kill(-pgrp, SIGWINCH) >= 0)) +#else + (killpg(pgrp, SIGWINCH) >= 0)) +#endif /* RISCOS */ + + return (ATOM_T); + return(GetSmallp(errno)); + } +#endif /* HPUX | RISCOS */ + + return(NIL); + } + +#ifndef ISC + case 12: /* create Unix socket */ + + { + int res, sockFD; + struct sockaddr_un sock; + + + /* First open the socket */ + sockFD = socket(AF_UNIX, SOCK_STREAM, 0); + if (sockFD < 0) + { perror("socket open"); + return(NIL);} + /* Then get a process slot and blit the pathname of the + socket into it */ + /* need to type-check the string here */ + LispStringToCString(args[1], shcom, 2048); + UJ[sockFD].pathname = malloc(strlen(shcom) + 1); + strcpy(UJ[sockFD].pathname, shcom); + /* Then bind it to the pathname, and get it listening properly */ + + sock.sun_family = AF_UNIX; + strcpy(sock.sun_path, shcom); + if (bind(sockFD, (struct sockaddr *) &sock, + strlen(shcom)+sizeof(sock.sun_family)) < 0) + { + close(sockFD); + free(UJ[sockFD].pathname); + UJ[sockFD].type = UJUNUSED; + perror("binding Lisp sockets"); + return(NIL); + } + DBPRINT(("Socket %d bound to name %s.\n", sockFD, shcom)); + if(listen(sockFD, 1)<0) perror("Listen"); + /* Set up the IO not to block */ + res = fcntl(sockFD, F_GETFL, 0); +#ifdef ISC + res |= O_NONBLOCK; +#else + res |= FNDELAY; +#endif /* ISC */ + res = fcntl(sockFD, F_SETFL, res); + + /* things seem sane, fill out the rest of the UJ slot and return */ + UJ[sockFD].status = -1; + UJ[sockFD].PID = -1; + UJ[sockFD].type = UJSOCKET; + + return(GetSmallp(sockFD)); + } + break; +#else + error("Socket creation not supported on ISC"); +#endif /* ISC */ + + + case 13: /* try to accept */ + { + /* returns file descriptor if successful, + -1 if no connection available, + NIL if failure */ + int sockFD, newFD; + + N_GETNUMBER(args[1], sockFD, bad); + if(UJ[sockFD].type == UJSOCKET && + UJ[sockFD].pathname != NULL) { + /* sockFD SHOULD be non-blocking; + but I'll time this out just in case */ + case13_lp: + TIMEOUT(newFD = accept(sockFD, (struct sockaddr *) 0, + (int *) 0)); + if (newFD < 0) + if (errno == EINTR) goto case13_lp; + else if (errno == EWOULDBLOCK) + return (GetSmallp(-1)); + else { + perror("Lisp socket accept"); + return (NIL); + } + else { + UJ[newFD].status = -1; + UJ[newFD].PID = -1; + UJ[newFD].type = UJSOSTREAM; + return(GetSmallp(newFD)); + } + } else return(NIL); + } + break; + + + case 14: /* return type of socket */ + { + int streamFD; + + N_GETNUMBER(args[1], streamFD, bad); + if(valid_slot(streamFD)) + return GetSmallp(UJ[streamFD].type); + else return NIL; + } + break; + + + + case 15: /* Write buffer */ + { char *bufp; + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + bufp = (char*)(Addr68k_from_LADDR(args[2])); /* User buffer */ + N_GETNUMBER(args[3], i, bad); /* # to write */ + DBPRINT(("Write buffer, type is %d\n", UJ[slot].type)); + + switch(UJ[slot].type) { + case UJSHELL: + case UJPROCESS: + case UJSOSTREAM: +#ifdef BYTESWAP + word_swap_page(bufp, (i+3)>>2); +#endif /* BYTESWAP */ + + dest = write(slot, bufp, i); +#ifdef BYTESWAP + word_swap_page(bufp, (i+3)>>2); +#endif /* BYTESWAP */ + + if (dest > 0) return(GetSmallp(dest)); + /* Something's amiss; update process status */ + wait_for_comm_processes(); /* make sure we're up to date */ + if (((dest == 0) || + (errno == EWOULDBLOCK)) && (UJ[slot].status == -1)) + /* No room to write, but other guy still running */ + return(ATOM_T); + /* At this point, we either got an I/O error, or there */ + /* were no chars available and the other end has terminated. */ + /* Either way, signal EOF. */ + DBPRINT(("Indicating write failure from PTY desc %d.\n", slot)); + return(NIL); + } + } + + default: return(NIL); + } + + bad: + DBPRINT(("Bad input value.")); + return(NIL); + } + + + + +/************************************************************************/ +/* */ +/* W r i t e L i s p S t r i n g T o P i p e */ +/* */ +/* Convert a lisp string to a C string (both format and byte- */ +/* order), write 2 bytes of length and the string */ +/* */ +/* */ +/************************************************************************/ + +WriteLispStringToPipe (LispPTR lispstr) +{ unsigned short len; + LispStringToCString(lispstr, shcom, 2048); + /* Write string length, then string */ + len = strlen(shcom) + 1; + write(UnixPipeOut, &len, 2); + write(UnixPipeOut, shcom, len); + } + +#endif /* DOS */ diff --git a/src/unixfork.c b/src/unixfork.c new file mode 100755 index 0000000..63db261 --- /dev/null +++ b/src/unixfork.c @@ -0,0 +1,729 @@ +/* $Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* Code to fork a subprocess for Unix communication */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1998 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + +#include + +#ifdef OS4 +#define USETERMIOS +#endif +#ifdef OS5 +#define USETERMIOS +#include +#define FULLSLAVENAME +#endif + +#ifdef INDIGO +#define USETERMIOS +#define TCSETS TCSETA +#define TCGETS TCGETA +#define FULLSLAVENAME +#endif + + +#include +#ifndef USETERMIOS +#include +#else +#ifdef INDIGO +#include +#else +#include +#endif /* INDIGO */ +#endif /* USETERMIOS */ + + +#ifdef OSF1 +#define _CLOCK_ID_T +typedef int clockid_t; +#include "time.h" +#include +#endif /* OSF1 */ + + +#ifdef HPUX +#include +#include +#endif /* HPUX */ + +#ifdef SYSVONLY +#include +#include +#endif /* SYSVONLY */ + +#include +#include +#include +#include +#include +#include +#include "dbprint.h" +#include + +#include + +#ifdef RISCOS +/* #include */ +#include +#endif /* RISCOS */ + +#ifdef INDIGO +/* #include */ +#include +#endif + + +static __inline__ int +#ifdef OS4 +SAFEREAD( f, b, c) +#else +SAFEREAD(int f, char *b, int c) +#endif +{ + int res; + loop: + res = read(f, b, c); + if ( (res < 0) ) + { + if ( errno == EINTR || errno == EAGAIN ) goto loop; + perror("reading UnixPipeIn"); + } + return (res); +} + +/* The following globals are used to communicate between Unix + subprocesses and LISP */ + + +long StartTime; /* Time, for creating pipe filenames */ + +char shcom[512]; /* Here because I'm suspicious of */ + /* large allocations on the stack */ + +/* fork_Unix is the secondary process spawned right after LISP is + started, to avoid having TWO 8 mbyte images sitting around. It listens + to the pipe LispToUnix waiting for requests, and responds on UnixToLisp. + The data passed through this pipe is in 4 byte packets, of the form: + + Byte 0: Command character, one of: + S: Fork PTY (shell) process. This is used for CHAT windows. + P: New version of S, takes 2 string args. + F: Fork piped shell, takes 1 string arg. + K: Kill process + E: Exit (kill all subprocesses) + C: Close stdin to subprocess + W: call WAIT3 & get one process's close info. + O: Fork OCR process. + Byte 1: Process number (0 to NPROCS - 1) + Not used for S, F, and E commands + [For S&P, pty letter] + [For F, process # for pipe naming] + Byte 2: Value, used as follows: + Only used for W command, contains byte to write + [For S&P, pty number] + Byte 3: Slot number. + +In the case of F & P commands, additional data follows the 4 byte packet. +This consists of 2 bytes representing the length of the shell command +string, and the string itself. + +fork_Unix will return another 4 byte packet. The bytes are the same as those +of the packet received except: + + F: Byte 2 is job number + Byte 3 is 1 if successful, 0 if not + S: Byte 2 is job number + Byte 3 is 1 if successful, 0 if not + R: Byte 2 is value of byte read from stdin, if any + Byte 3 is 1 if successful, 2 if EOF, 0 if nothing waiting + W: Bytes 0 & 1 are the Process ID of the terminated process + Bytes 2 & 3 are the high & low bytes of the exit status. + K: Bytes 1 and 2 are the high and low bytes of the exit status + of the process. + Byte 3 is 1 if an exit status was available. + E: Always the same + C: Always the same + O: Byte 3 is 1 if successful, 0 if not + Byte 1 and Byte 2 are the process ID of OCR process + +*/ + + + +fork_Unix() +{ + + int LispToUnix[2], /* Incoming pipe from LISP */ + UnixToLisp[2], /* Outgoing pipe to LISP */ + UnixPID, + LispPipeIn, LispPipeOut, res, slot; + pid_t pid; + + char IOBuf[4]; + unsigned short tmp; + char *cmdstring; + + /* Pipes between LISP subr and process */ + if (pipe(LispToUnix) == -1) { + perror("pipe"); + exit(-1); + } + if (pipe(UnixToLisp) == -1) { + perror("pipe"); + exit(-1); + } + + StartTime = time(0); /* Save the time, to create filenames with */ + StartTime &= 0xFFFFFF; /* as a positive number! */ + +/* interrupts need to be blocked here so subprocess won't see them */ +#ifdef SYSVSIGNALS + sighold(SIGVTALRM); + sighold(SIGIO); + sighold(SIGALRM); + sighold(SIGXFSZ); + sighold(SIGFPE); +#else + sigblock(sigmask(SIGVTALRM) | sigmask(SIGIO) + | sigmask(SIGALRM) +#ifndef HPUX + | sigmask(SIGXFSZ) +#endif /* HPUX */ + + | sigmask(SIGFPE) + ); +#endif /* SYSVSIGNALS */ + + + if ((UnixPID = fork()) == -1) { /* Fork off small version of the emulator */ + perror("fork"); + exit(-1); + } + + if (UnixPID != 0) { + /* JRB - fork_Unix is now called in ldeboot; leave UnixPipe{In,Out} open + and put their numbers in the environment so parent can find them */ + /* JDS - NB that sprintf doesn't always return a string! */ + + char* tempstring; + + tempstring = (char *) malloc(30); + sprintf(tempstring, "LDEPIPEIN=%d", UnixToLisp[0]); + putenv(tempstring); + + tempstring = (char *)malloc(30); + sprintf(tempstring, "LDEPIPEOUT=%d", LispToUnix[1]); + putenv(tempstring); + + tempstring = (char *)malloc(30); + sprintf(tempstring, "LDESTARTTIME=%d", StartTime); + putenv(tempstring); + + tempstring = (char *)malloc(30); + sprintf(tempstring, "LDEUNIXPID=%d", UnixPID); + putenv(tempstring); + + close(LispToUnix[0]); + close(UnixToLisp[1]); + return(1); + } + + LispPipeIn = LispToUnix[0]; + LispPipeOut = UnixToLisp[1]; + close(LispToUnix[1]); + close(UnixToLisp[0]); + + res = fcntl(LispPipeIn, F_GETFL, 0); + res &= (65535-FNDELAY); + res = fcntl(LispPipeIn, F_SETFL, res); + + while (1) { + int len; + len = 0; + while (len != 4) + { + if ((len = SAFEREAD(LispPipeIn, IOBuf, 4)) <0) + { /* Get packet */ + perror("Packet read by slave"); + /* kill_comm_processes(); */ + exit(0); + } + if (len != 4) + { + DBPRINT(("Input packet wrong length: %d.\n", len)); + exit(0); + } + } + slot = IOBuf[3]; + IOBuf[3] = 1; /* Start by signalling success in return-code */ + + switch(IOBuf[0]) { + + case 'S': case 'P': /* Fork PTY shell */ + if (slot >= 0) + { /* Found a free slot */ + char termtype[32]; +#ifdef FULLSLAVENAME + char slavepty[32]; /* For slave pty name */ + + if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading slave pty len"); + if (SAFEREAD(LispPipeIn, slavepty, tmp) < 0) perror("Slave reading slave pty id"); +#endif /* INDIGO */ + + if (IOBuf[0] == 'P') + { /* The new style, which takes term type & command to csh */ + if(SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); + if(SAFEREAD(LispPipeIn, termtype, tmp) < 0) perror("Slave reading termtype"); + if(SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); + if (tmp > 510) cmdstring = (char *)malloc(tmp+5); + else cmdstring = shcom; + + if(SAFEREAD(LispPipeIn, cmdstring, tmp) < 0) perror("Slave reading shcom"); + } + else /* old style, no args */ + { termtype[0] = 0; cmdstring[0] = 0; } + + /* Alloc a PTY and fork */ +#ifdef FULLSLAVENAME + pid = ForkUnixShell(slot, slavepty, termtype, cmdstring); +#else + pid = ForkUnixShell(slot, IOBuf[1], IOBuf[2], termtype, cmdstring); +#endif + + if (pid == -1) + { + printf("Impossible failure from ForkUnixShell??\n"); + fflush(stdout); + IOBuf[3] = 0; + } + else + { + /* ForkUnixShell sets the pid and standard in/out variables */ + IOBuf[1] = (pid >> 8)& 0xFF; + IOBuf[2] = pid & 0xFF; + } + } + else + { + printf("Can't get process slot for PTY shell.\n"); + fflush(stdout); + IOBuf[3] = 0; + } + break; + + case 'F': /* Fork pipe command */ + if (slot >= 0) + { + + /* Read in the length of the shell command, and then the command */ + if(SAFEREAD(LispPipeIn, (char *)&tmp, 2)<0) perror("Slave reading cmd length"); + if (tmp > 510) cmdstring = (char *)malloc(tmp+5); + else cmdstring = shcom; + if(SAFEREAD(LispPipeIn, cmdstring, tmp)<0) perror("Slave reading cmd"); + DBPRINT(("Cmd len = %d.\n", tmp)); + DBPRINT(("Rev'd cmd string: %s\n", cmdstring)); + pid = fork(); /* Fork */ + + if (pid == 0) + { + int i; + int status, sock; +#ifndef ISC + struct sockaddr_un addr; + char PipeName[40]; + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) {perror("slave socket"); exit(0);} + sprintf(PipeName, "/tmp/LPU%d-%d", StartTime, slot); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, PipeName); + status = connect(sock, (struct sockaddr *)&addr, + strlen(PipeName)+sizeof(addr.sun_family)); + if(status<0) + { + perror("slave connect"); + printf("Name = %s.\n", PipeName); fflush(stdout); + exit(0); + } + else + { + DBPRINT(("Slave connected on %s.\n", PipeName)); + } + + /* Copy the pipes onto stdin, stdout, and stderr */ + dup2(sock,0); + dup2(sock,1); + dup2(sock,2); +#else + /* New, FIFO-based communication regime */ + int down, up; /* fifo fds */ + char DownFIFO[48], UpFIFO[48]; + + sprintf(DownFIFO, "/tmp/LPD%d-%d", StartTime, slot); + sprintf(UpFIFO, "/tmp/LPU%d-%d", StartTime, slot); + + if ((down = open(DownFIFO, O_RDONLY | O_NDELAY)) < 0) + { + perror("slave opening down fifo"); + exit(0); + } + if ((up = open(UpFIFO, O_WRONLY | O_NDELAY)) < 0) + { + perror("slave opening up fifo"); + exit(0); + } + + /* Copy the fifos onto stdin, stdout, and stderr */ + dup2(down,0); + dup2(up,1); + dup2(up,2); + + /* unlink(DownFIFO); + unlink(UpFIFO); */ + +#endif /* oldPIPEway */ + + +#ifdef SYSVONLY + /* Make sure everything else is closed POSIX has no getdtab... */ + for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) + close(i); +#else + /* Make sure everything else is closed */ + for (i = 3; i < getdtablesize(); i++) + close(i); +#endif /* HPUX */ + + + /* Run the shell command and get the result */ + status = system(cmdstring); + if (cmdstring != shcom) free(cmdstring); + /* Comment out to fix USAR 11302 (FXAR 320) + unlink(PipeName); + */ + _exit((status & ~0xff) ? (status >> 8) : status); + } + + /* Check for error doing the fork */ + if (pid == (pid_t)-1) + { + perror("unixcomm: fork"); + IOBuf[3] = 0; + } + else + { + IOBuf[1] = (pid >> 8)& 0xFF; + IOBuf[2] = pid & 0xFF; + + } + } else + { + printf("No process slots available.\n"); + IOBuf[3] = 0; /* Couldn't get a process slot */ + } + break; + + + case 'W': /* Wait for a process to die. */ + { + int pid; +#ifdef SYSVONLY + int status; +#else + union wait status; +#endif /* SYSVONLY */ + + int slot; + +#ifdef SYSVONLY + status = 0; +#else + status.w_status = 0; +#endif /* SYSVONLY */ + + IOBuf[0] = 0; IOBuf[1] = 0; + DBPRINT(("About to wait for processes.\n")); +#ifdef SYSVONLY + retry1: + pid = waitpid(-1, &status, WNOHANG); + if (pid == -1 && errno == EINTR) goto retry1; +#else + pid = wait3(&status, WNOHANG, 0); +#endif /* SYSVONLY */ + if (pid > 0) + + { + /* Ignore processes which are suspended but haven't exited + (this shouldn't happen) */ +#ifdef SYSVONLY + if (WIFSTOPPED(status )) break; + IOBuf[3] = status >>8; + IOBuf[2] = status & 0xFF; +#else + if (status.w_stopval == WSTOPPED) break; + IOBuf[3] = status.w_T.w_Retcode; + IOBuf[2] = status.w_T.w_Termsig; +#endif /* SYSVONLY */ + + IOBuf[1] = pid & 0xFF; + IOBuf[0] = (pid>>8) & 0xFF; + } + DBPRINT(("wait3 returned pid = %d.\n", pid)); + } + + break; + + case 'C': /* Close stdin to subprocess */ + + break; + + + case 'K': /* Kill subprocess */ + + break; + + +#ifdef OCR + case 'w': /* Wait paticular process to die */ + { + int pid, res, status; + + pid = IOBuf[1] << 8 | IOBuf[2]; + + retry: + res = waitpid(pid, &status, WNOHANG); + if (res == -1 && errno == EINTR) goto retry; + + if (res == pid) { + IOBuf[0] = res >> 24 & 0xFF; + IOBuf[1] = res >> 16 & 0xFF; + IOBuf[2] = res >> 8 & 0xFF; + IOBuf[3] = res & 0xFF; + } else { + IOBuf[0] = IOBuf[1] = IOBuf[2] = IOBuf[3] = 0; + } + } + break; + + case 'O': /* Fork OCR process */ + if (slot >= 0) { + pid_t ppid; + ppid = getppid(); + pid = fork(); + if (pid == 0) { + int i; + int status, len; + struct sockaddr_un addr; + char PipeName[40]; + extern int OCR_sv; + + OCR_sv = socket(AF_UNIX, SOCK_STREAM, 0); + if (OCR_sv < 0) { + perror("slave socket"); + exit(0); + } + sprintf(PipeName, "/tmp/LispPipe%d-%d", StartTime, slot); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, PipeName); + len = strlen(PipeName)+sizeof(addr.sun_family); + status = connect(OCR_sv, &addr, len); + if(status<0) { + perror("OCR slave connect"); + OCR_sv = -1; + exit(0); + } + + (void)ocr_proc(ppid); + OCR_sv = -1; + exit(1); + } + + if (pid == -1) { + perror("unixcomm: fork OCR"); + IOBuf[3] = 0; + } else { + IOBuf[1] = (pid >> 8)& 0xFF; + IOBuf[2] = pid & 0xFF; + } + } else IOBuf[3] = 0; + break; +#endif /* OCR */ + + + } /* End of switch */ + + /* Return the status/data packet */ + write(LispPipeOut, IOBuf, 4); + } +} + + + + +/************************************************************************/ +/* */ +/* F o r k U n i x S h e l l */ +/* */ +/* Fork a PTY connection to a C-shell process. */ +/* Returns PID of process, or -1 if something failed */ +/* */ +/* */ +/************************************************************************/ + + +/* Creates a PTY connection to a csh */ + +#ifdef FULLSLAVENAME +ForkUnixShell(slot, PtySlave, termtype, shellarg) +#else +ForkUnixShell(slot, ltr, numb, termtype, shellarg) +#endif + int slot; +#ifdef FULLSLAVENAME + char * PtySlave; +#else + char ltr, numb; +#endif + char *termtype, *shellarg; + + { +#ifdef FULLSLAVENAME + char buf[1]; +#else + char PtySlave[20], buf[1]; +#endif + int res, PID, MasterFD, SlaveFD; +#ifdef USETERMIOS + struct termios tio; +#else + struct sgttyb tio; +#endif /* USETERMIOS */ + + + PID = fork(); + + if (PID == 0) + { + char envstring[64]; + char *argvec[4]; + +#ifndef SYSVONLY + /* Divorce ourselves from /dev/tty */ + res = open("/dev/tty", O_RDWR); + if (res >= 0) + { + (void) ioctl(res, TIOCNOTTY, (char *)0); + (void) close(res); + } + else + { + perror("Slave TTY"); + exit(0); + } +#else + if( 0 > setsid()) /* create us a new session for tty purposes */ + perror("setsid"); +#endif + + /* Open the slave side */ +#ifndef FULLSLAVENAME + sprintf(PtySlave, "/dev/tty%c%c", ltr, numb); +#endif + SlaveFD = open(PtySlave, O_RDWR); + if (SlaveFD == -1) + { + perror("Slave Open"); + perror(PtySlave); + exit(0); + } + +#ifdef OS5 + ioctl(SlaveFD, I_PUSH, "ptem"); + ioctl(SlaveFD, I_PUSH, "ldterm"); +#endif /* OS5 */ + +#ifndef USETERMIOS +/* This is the old way we set up terminal (OS 3), using an + obsolete ioctl and wrong flags for a display. */ + ioctl(SlaveFD, TIOCGETP, (char *)&tio); + tio.sg_flags |= CRMOD; + tio.sg_flags |= ECHO; + ioctl(SlaveFD, TIOCSETP, (char *)&tio); +#else + /* Set up as basic display terminal: canonical erase, + kill processing, echo, backspace to erase, echo ctrl + chars as ^x, kill line by backspacing */ + + ioctl(SlaveFD, TCGETS, (char *)&tio); +#ifdef INDIGO + tio.c_lflag |= ICANON | ECHO | ECHOE; +#else + tio.c_lflag |= ICANON | ECHO | ECHOE | ECHOCTL | ECHOKE; +#endif /* INDIGO */ + ioctl(SlaveFD, TCSETS, (char *)&tio); +#endif /* USETERMIOS */ + + (void) dup2(SlaveFD, 0); + (void) dup2(SlaveFD, 1); + (void) dup2(SlaveFD, 2); + (void) close(SlaveFD); + + /* set the LDESHELL variable so the underlying .cshrc can see it and + configure the shell appropriately, though this may not be so important any more */ + putenv("LDESHELL=YES"); + + if ((termtype[0] != 0) && (strlen(termtype) < 59)) + { /* set the TERM environment var */ + sprintf(envstring, "TERM=%s", termtype); + putenv(envstring); + } + /* Start up csh */ + argvec[0] = "csh"; + if (shellarg[0] != 0) + { /* setup to run command */ + argvec[1] = "-c"; /* read commands from next arg */ + argvec[2] = shellarg; + argvec[3] = (char *) 0; + } + else argvec[1] = (char *) 0; + + execv("/bin/csh", argvec); + + /* Should never get here */ + perror("execv"); + exit(0); + } + else + { /* not the forked process. */ + if (shellarg != shcom) free(shellarg); + } + + /* Set the process group so all the kids get the bullet too + if (setpgrp(PID, PID) != 0) + perror("setpgrp"); */ + + return(PID); + } + diff --git a/src/unwind.c b/src/unwind.c new file mode 100755 index 0000000..6b5e2ca --- /dev/null +++ b/src/unwind.c @@ -0,0 +1,234 @@ +/* $Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/******************************************************************/ +/* + + File Name : unwind.c + + Created : jul 17, 1987 by T.Shimizu + Changed : Sept 21 1988 BK + +*/ +/******************************************************************/ + +#include "lispemul.h" +#include "emlglob.h" +#include "stack.h" +#include "lspglob.h" + + +UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep) +{ register int num ; /* number of UNBOUND slot */ + register LispPTR *endptr; /* unwind limit */ + register LispPTR *lastpvar; /* points PVar slot that is unbounded. */ + + +/* Slots: + ----------------- + | | <- PVar + ----------------- + | . | + | . | + ----------------- + | | ALL OF THE FOLLOWING LOCATIONS SCANNED: + ----------------------------------------------------------------- + | tos if keep | <- endptr (PVar[n]) <- Result (no keep) | + ----------------- | + | | <- Result (keep) | + ----------------- | + | | | + ----------------- | + | . | | + | . | | + ----------------- | + | tos pushed | <- Start CSTKPTR | + ----------------------------------------------------------------- + | | <- CSTKPTR temporarily bumped pushing tos + ----------------- + + NOTE: upon return the emulator does a POP to get the new tos value + +*/ + + +endptr = (LispPTR *) PVar + n; /* set unwind limit */ + +if (endptr > cstkptr) { + CurrentStackPTR = (DLword *) cstkptr; + ERROR_EXIT(tos); + } +*cstkptr++ = tos; + + /* UNBOUND MARK loop */ + +while (cstkptr > endptr) + { + /* Look for the Next BIND marker */ + + if( (num = (int) *--cstkptr) < 0 ) + { + + /* Now UNBIND the PVARS indicated by the BIND marker */ + + lastpvar = (LispPTR *) (2 + PVar + (unsigned short) num) ; + num = ~(num >> 16) + 1; + for(; --num > 0; ) + { *--lastpvar = 0xffffffff ; /* Mark as UNBOUND */ } + }; + }; + + +/* endptr = cstkptr */ + + if(keep) + { + *(cstkptr++) = tos; + } + return((UNSIGNED) cstkptr); + +} /* N_OP_unwind */ + +#ifdef CATCH + +/******************************************************************/ +/* + SUBR: FIND_THE_BLIP + + find the blip down in the stack. Similar to the LISP + SI::UNWIND-TO-BLIP, except the target is returned instead + of doing the unwinding. Note that the unwider parameter + must already be properly set by the caller (i.e. to the + alink if necessary). +*/ +/******************************************************************/ +#define SMALLP(x) (((unsigned int)x >> 16) == (S_POSITIVE >> 16)) + +LispPTR find_the_blip(blip, throwp, unwinder) + register LispPTR blip; + register LispPTR throwp; + FX *unwinder; + +{ register LispPTR target; + register FX *target_addr; + register LispPTR pc = NIL_PTR; + +LispPTR CATCH_RETURN_PC_ATOM = parse_atomstring("SI::*CATCH-RETURN-PC*"); +LispPTR CHATCH_RETURN_TO_ATOM = parse_atomstring("SI::*CATCH-RETURN-TO*"); +LispPTR CATCH_RETURN_FROM_ATOM = parse_atomstring("SI::*CATCH-RETURN-FROM*"); + + for (target = (LispPTR) unwinder; + FX_INVALIDP(target); + GETCLINK(target_addr)) { + target_addr = (FX *) Addr68k_from_StkOffset(target); + if (blip == *target_addr) { + register LispPTR var_name_in_frame = + variable_name_in_frame(target_addr, (FVPVAR << 8) + 1); + if (var_name_in_frame == CHATCH_RETURN_TO_ATOM) { + if (throwp) { + pc = pvar_value_in_frame(target_addr, CATCH_RETURN_PC_ATOM); + if !(SMALLP(pc)) + error("Catch return-to frame lacks PC"); + } + goto cons_result; + } else + if (var_name_in_frame == CATCH_RETURN_FROM_ATOM) { + if (throwp) {target = GETCLINK(target_addr); }; + goto cons_result; + } + } /* if blip */ + }; /* for */ + + +no_result: + return(NIL_PTR); +cons_result: + return(cons(StkOffset_from_68K(target), pc)); +} + + + + +LispPTR variable_name_in_frame(fx_addr, code) + FX *fx_addr; + register LispPTR code; +{ + register DLword *name_ptr; + register DLword *name_bind_ptr; + register DLword *name_table_base; + register DLword value; + + name_table_base = Addr68k_from_LADDR(GETNAMETABLE(fx_addr)); + name_ptr = name_table_base + FNHEADSIZE; + name_table_base = name_ptr + ((FNHEAD *) name_table_base)->ntsize; + + while (value = GETWORD(name_ptr++)) do { + if (code == GETWORD(name_bind_ptr++)) {return(value) } ; + }; /* while */ + return(NIL_PTR); +}; /* variable_name_in_frame */ + + + + +/******************************************************************/ +/* + pvar_value_in_frame searches through the name table for + frame_addr looking for the binding of atom_index. It + returns the PVAR value of the binding if the PVAR is found + & it is bound. +*/ +/******************************************************************/ + +LispPTR pvar_value_in_frame(frame_addr, atom_index) + register FX *frame_addr; + register LispPTR atom_index; + +{ + register DLword *name_ptr; + register DLword *name_bind_ptr; + register DLword *name_table_base; + register DLword value; + + name_table_base = Addr68k_from_LADDR(GETNAMETABLE(frame_addr)); + name_ptr = name_table_base + FNHEADSIZE; + name_table_base = name_ptr + ((FNHEAD *) name_table_base)->ntsize; + + while (value = GETWORD(name_ptr++)) do { + if (value == atom_index) { + register DLword bind_info = GETWORD(name_bind_ptr); + if ((bind_info >> 8) == FVPVAR) { + register LispPTR slot_value = + *((LispPTR *) (FRAMESIZE + (DLword *) frame_addr) + + (bind_info - (FVPVAR << 8))) + if (slot_value > 0) { return(slot_value & POINTERMASK); }; + }; + }; + name_bind_ptr++; + }; /* while */ + return(NIL_PTR); + +}; /* pvar_value_in_frame */ + + +#endif diff --git a/src/uraid.c b/src/uraid.c new file mode 100755 index 0000000..6d9a5f7 --- /dev/null +++ b/src/uraid.c @@ -0,0 +1,1537 @@ +/* @(#) uraid.c Version 1.52 (4/23/92). copyright Venue & Fuji Xerox */ +static char *id = "@(#) uraid.c 1.52 4/23/92 (Venue & Fuji Xerox)"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/************************************************************************/ +/* */ +/* U R A I D . C */ +/* */ +/* URAID is the low-level debugger for Medley. */ +/* */ +/************************************************************************/ +/************************************************************************/ + + +#include + +#ifdef ISC +#include +#define vfork fork +#endif /* ISC */ + + +#ifdef INDIGO +#define vfork fork +#endif /* INDIGO */ + +#include +#ifndef DOS +#include +#include +#include +#include +#endif /* DOS */ +#include +#ifndef XWINDOW +#ifdef SUNDISPLAY +#include +#include +#endif /* SUNDISPLAY */ +#include +#ifndef NOPIXRECT +#include +#include +#include +#include +#include +#include +#ifdef SUNDISPLAY +extern int Win_security_p; +#endif /* SUNDISPLAY */ + +#endif /* NOPIXRECT */ +#endif /* XWINDOW */ + +#ifdef OS5 +#include +#endif /* OS5 */ + + +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "emlglob.h" +#include "cell.h" +#include "stack.h" +#include "ifpage.h" +#include "debug.h" +#include "devconf.h" + +#include "display.h" +#include "bitblt.h" + +#ifdef DOS +#define vfork() printf("No forking around here.\n") +#endif /* DOS */ + +#if defined(DOS) || defined(XWINDOW) +#include "devif.h" +extern DspInterface currentdsp; +#endif /* DOS || XWINDOW */ + +#ifdef DOS +extern MouseInterface currentmouse; +extern KbdInterface currentkbd; +#endif /* DOS */ + +#ifdef COLOR +extern int MonoOrColor; +extern int Dispcolorsize; +extern DLword *ColorDisplayRegion68k; +#endif /* COLOR */ + + + + +/***********************************************************************/ +/* + File name : uraid.c + + Written by : Takeshi Shimizu(Take) + Date: 6-May-1988 + + This File Supports the following commands: + +**URAID command summary** +<> +c Checks all user stack contents +f number Displays frame extension for the number(decimal) +k type Changes the type of stack link following.(a|c) +l [type] Back trace for specified type stack.(k|m|r|g|p|u) + Display next frame. +<> +a litatom Displays the top-level value of the litatom +d litatom Displays the definition cell for the litatom +M Displays TOS,CSP,PVAR,IVAR,PC +m func1 func2 MOVED func1 to func2 +t Xaddress Displays the type of this object +p litatom Displays the property list of the litatom +w Displays the current function-name and PC +x Xaddress [xnum] Hex-Dump xnum word(16-bits) starting at Xaddress +@ litatom val Sets TOPVAL of litatom to Decimal-val +< Xaddress val Sets the word(16-bits) at the address to val +<> +e Exit to UNIX / DOS +h Context switch to HARDRESET +q Returns from URAID with NO-change +<> +s Invoke Shell +v filename Save the virtual memory on the filename(Not Bootable) +( [num] Sets Print level +! Prints the error message passed from the emulator +? Display this summary + +*/ +/************************************************************************/ +#ifndef NOPIXRECT + extern int black, white; + extern struct pixrect *ColorDisplayPixrect, + *DisplayRegionPixrect; +#endif /* NOPIXRECT */ + +extern int DisplayRasterWidth; +extern unsigned int LispReadFds,LispWindowFd,LispKbdFd; +#ifndef NOPIXRECT +extern struct pixrect *CursorBitMap,*InvisibleCursorBitMap; +#endif /* NOPIXRECT */ +extern struct cursor CurrentCursor, InvisibleCursor; +extern struct screen LispScreen; +extern int displaywidth,displayheight; +extern DLword *DisplayRegion68k; +extern int FrameBufferFd,ether_fd,RS232C_Fd; +extern u_int EtherReadFds; + +LispPTR RadiAtomIndex; +LispPTR RaidPackageIndex; +char *HideDisp68k; + +#ifdef COLOR +char *HideColorDisp68k; +extern int Inited_Color; +#endif /* COLOR */ + + +#ifdef DOS +char *URaid_summary1 = "<>\n\ +c\t\t\tChecks all user stack contents\n\ +f number\t\tDisplays stack frame for that frame number (decimal)\n\ +k type\t\t\tChanges the type of stack link following. (a|c)\n\ +l [type]\t\tBack Trace for specified type stack. (k|m|r|g|p|u|)\n\ +\t\t\tDisplay next frame.\n"; + +char *URaid_summary2 = "<>\n\ +a litatom\t\tDisplays the top-level value of the litatom\n\ +B Xaddress\t\tPrint the contents of the arrayblock at that address.\n\ +d litatom\t\tDisplays the definition cell for the litatom\n\ +M\t\t\tDisplays TOS,CSP,PVAR,IVAR,PC\n\ +m func1 func2\t\tMOVD func1 to func2\n\ +O Xaddress\t\tDisplays the object with that address\n\ +t Xaddress\t\tDisplays the type of this object\n\ +p litatom\t\tDisplays the property list of the litatom\n\ +w\t\t\tDisplays the current function-name and PC\n\ +x Xaddress [xnum]\tHex-Dump xnum (16-bit) words starting at Xaddress\n\ +@ litatom val\t\tSets TOPVAL of litatom to Decimal-val\n\ +< Xaddress Xval\t\tSets the (16-bit) word at the address to Xval\n"; + +char *URaid_summary3 = "<>\n\ +e\t\t\tExit to DOS\n\ +h\t\t\tDo a HARDRESET\n\ +q\t\t\tReturns from URAID with NO change\n\ +<>\ns\t\t\tInvoke Shell\n\ +v filename\t\tSave the virtual memory on the filename(Not Bootable)\n\ +( [num]\t\t\tSets Print level\n\ +!\t\t\tPrints the error message passed from the emulator\n\ +?\t\t\tDisplay this summary"; +#else +char *URaid_summary = "---URAID command summary---\n\ +<>\n\ +c\t\t\tChecks all user stack contents\n\ +f number\t\tDisplays stack frame for that frame number (decimal)\n\ +k type\t\t\tChanges the type of stack link following. (a|c)\n\ +l [type]\t\tBack Trace for specified type stack. (k|m|r|g|p|u|)\n\ +\t\t\tDisplay next frame.\n<>\n\ +a litatom\t\tDisplays the top-level value of the litatom\n\ +B Xaddress\t\tPrint the contents of the arrayblock at that address.\n\ +d litatom\t\tDisplays the definition cell for the litatom\n\ +M\t\t\tDisplays TOS,CSP,PVAR,IVAR,PC\n\ +m func1 func2\t\tMOVD func1 to func2\n\ +O Xaddress\t\tDisplays the object with that address\n\ +t Xaddress\t\tDisplays the type of this object\n\ +p litatom\t\tDisplays the property list of the litatom\n\ +w\t\t\tDisplays the current function-name and PC\n\ +x Xaddress [xnum]\tHex-Dump xnum (16-bit) words starting at Xaddress\n\ +@ litatom val\t\tSets TOPVAL of litatom to Decimal-val\n\ +< Xaddress Xval\t\tSets the (16-bit) word at the address to Xval\n\ +<>\n\ +e\t\t\tExit to UNIX\n\ +h\t\t\tDo a HARDRESET\n\ +q\t\t\tReturns from URAID with NO change\n\ +<>\ns\t\t\tInvoke Shell\n\ +v filename\t\tSave the virtual memory on the filename(Not Bootable)\n\ +( [num]\t\t\tSets Print level\n\ +!\t\t\tPrints the error message passed from the emulator\n\ +?\t\t\tDisplay this summary"; +#endif /* DOS */ + +#define ADD_RANGEP(address) if((address < 0) || (POINTERMASK < address)) \ + { \ + printf("Address out of range.\n"); \ + return(T); \ + } +extern int get_package_atom(); + +#define URMAXCOMM 512 +#define URMAXFXNUM 2000 +#define URSCAN_ALINK 0 +#define URSCAN_CLINK 1 + +/*** URaid G vals ***/ + int URaid_scanlink= URSCAN_ALINK; + int URaid_currentFX=URMAXFXNUM +1; + FX *URaid_FXarray[URMAXFXNUM]; + int URaid_ArrMAXIndex; + + char URaid_inputstring[URMAXCOMM]; + char URaid_comm; + char URaid_arg1[URMAXCOMM/2]; + char URaid_arg2[URMAXCOMM/2]; + int URaid_argnum; + char *URaid_errmess; + + extern int PrintMaxLevel; /* for print level */ + + + +/***********************************************************************/ +/* + func name : parse_atomstring(string) + Written by : Takeshi Shimizu + Date: 6-May-1988 + Pass the atomstring(e.g. "XCL:EVAL") + Then Returns atomindex . + If fail to find, return -1 + + If there is no package prefix,it will be treated as IL: +*/ +/***********************************************************************/ + +LispPTR make_atom(); + LispPTR parse_atomstring(string) + char *string; + { + char *start,*packageptr,*nameptr; + int flag=0; + int packagelen=0; + int namelen=0; + int cnt; + LispPTR aindex; + + for(cnt=0,start=string; *string != '\0' ; string++,cnt++) + { + if(*string ==':') + { + packagelen= cnt; + packageptr=start; + nameptr=string+1; + cnt=0; + *string=0; + } + } + if(packagelen==0) + { /* treat as IL: */ + nameptr=start; + namelen = cnt; + } + else namelen = cnt -1; + + if((packagelen == 0) || (strncmp(packageptr, "IL",packagelen ) == 0)) + {/* default IL: */ + aindex=make_atom(nameptr,0,namelen,T); + if(aindex == 0xffffffff) + { printf("trying IL:\n"); + aindex = get_package_atom(nameptr,namelen,"INTERLISP",9,0); + } + } + else aindex = get_package_atom(nameptr,namelen,packageptr,packagelen,0); + + if(aindex== 0xffffffff) return(0xffffffff); + printf("INDEX : %d\n",aindex& 0xffff); + return(aindex & 0xffff); + } + + + +/***********************************************************************/ +/* + func name : uraid_commclear() + Written by : Takeshi Shimizu + Date: 6-May-1988 + + Clear Command buffer + +*/ +/***********************************************************************/ + +uraid_commclear() +{ + memset(URaid_inputstring, 0, URMAXCOMM); + memset(URaid_arg1, 0, URMAXCOMM/2); + memset(URaid_arg2, 0, URMAXCOMM/2); + + URaid_comm=0; + URaid_argnum=0; +} + + + + +copy_region ( src, dst, width, h ) +register short *src, *dst; +int width; +register int h; + { + register int w; + + for (; (h--);) { + for ( w = width; (w--);) { + GETWORD(dst++ )= GETWORD(src++); + } + } + } + + +/***********************************************************************/ +/* + func name : uraid_commands() + Written by : Takeshi Shimizu + Date: 6-May-1988 + + Execute URaid commands + To continue, return T + To exit, return NIL +*/ +/***********************************************************************/ + +uraid_commands() +{ + int num,address,val,tmp; + LispPTR index; + DefCell *defcell68k; +#ifndef DOS +#ifdef SYSVONLY +int status; +#else + union wait status; +#endif /* SYSVONLY */ + +#endif /* DOS */ + + if(URaid_argnum == -1){ + /* disp next FX */ + if(URaid_currentFX > URaid_ArrMAXIndex) + { + printf("There is no more stack.\n"); + return(T); + } + else + { + sf(URaid_FXarray[URaid_currentFX++]); + return(T); + } + } + switch(URaid_comm) + { + + /*** Displaying STACK stuff */ +#ifdef DOS + case '1' : printf("%s\n", URaid_summary1); + break; + case '2' : printf("%s\n", URaid_summary2); + break; + case '3' : printf("%s\n", URaid_summary3); + break; +#endif /* DOS */ + case 'c' : stack_check(0); + break; + case 'C' : all_stack_dump(0,0,T); + break; + case 'f' : /**if((URaid_arg1[0] < '0') || (URaid_arg1[0] > '9')){ + printf("Illegal argument, not a number\n"); + return(T); + }**/ + if(URaid_argnum==1) /* f comm only */ + { + printf("DUMP-STACK: f decimal-FXnumber\n"); + return(T); + } + if( sscanf(URaid_arg1,"%d",&num) <= 0) + { /* com read fails */ + printf("Illegal argument, not decimal number\n"); + return(T); + } + if((num > URaid_ArrMAXIndex) || (num < 0)) + { + printf("Frame number doesn't exist.\n"); + return(T); + } + sf(URaid_FXarray[num]); + URaid_currentFX = num+1; + break; + case 'k' : if((URaid_arg1[0] == 'A')||(URaid_arg1[0] == 'a')) + URaid_scanlink =URSCAN_ALINK; + else if((URaid_arg1[0] == 'C')||(URaid_arg1[0] == 'c')) + URaid_scanlink = URSCAN_CLINK; + else + printf("Link type should be A or C\n"); + break; + case 'l' : if(URaid_argnum ==1) + { + bt(); /* default case CURRENTFX */ + return(T); + } + switch(URaid_arg1[0]) + { + case 'k' : printf("IFP->KBDFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->kbdfxp)); + break; + case 'm' : printf("IFP->MISCFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->miscfxp)); + break; + case 'r' : printf("IFP->RESETFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->resetfxp)); + break; + case 'g' : printf("IFP->GCFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->gcfxp)); + + break; + case 'p' : printf("IFP->FAULTFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->faultfxp)); + + break; + case 'u' : bt(); + break; + default : printf("2nd argument should be k,m,r,g,p,u or null.\n"); + break; + } /* switch end */ + break; + + /* Displaying the memory contents stuff */ + case 'a' : /* GETTOPVAL */ + if(URaid_argnum != 2) + { + printf("GETTOPVAL: a litatom\n"); + return(T); + } + if((index = parse_atomstring(URaid_arg1))== + 0xffffffff ){ + printf("No such atom.\n"); + return(T); + } + print(*((LispPTR*)GetVALCELL68k(index))); + break; + case 'd' : /* DEFCELL */ + if(URaid_argnum != 2){ + printf("GETD: d litatom\n"); + return(T); + } + if((index = parse_atomstring(URaid_arg1))== + 0xffffffff){ + printf("No such atom.\n"); + return(T); + } + defcell68k= (DefCell*)GetDEFCELL68k(index); + if(defcell68k->ccodep) { + printf("{CCODEP}0x%x\n",defcell68k->defpointer); + return(T); + } + else{ + print(defcell68k->defpointer); + return(T); + } + break; + + case 'M' : /* Machine States */ + printf("TOS : 0x%x\n",TopOfStack); + printf("CSTKP : 0x%x\n",LADDR_from_68k(CurrentStackPTR)); + printf("PVAR : 0x%x\n",LADDR_from_68k(PVar)); + printf("IVAR : 0x%x\n",LADDR_from_68k(IVar)); + printPC(); putchar('\n'); + break; + case 'm' : /* MOVD */ + if(URaid_argnum != 3) + { + printf("MOVD: m \n"); + return(T); + } + { DefCell *fromfunc,*tofunc; + LispPTR fromindex,toindex; + if((fromindex = parse_atomstring(URaid_arg1))==0xffffffff){ + printf("No such function (from)\n"); + return(T); + } + if((toindex = parse_atomstring(URaid_arg2))==0xffffffff){ + printf("No such function (to)\n"); + return(T); + } + + fromfunc= (DefCell*)GetDEFCELL68k(fromindex); + tofunc= (DefCell*)GetDEFCELL68k(toindex); + tofunc->defpointer = fromfunc->defpointer; + print(toindex); + printf(" is smashed with "); + print(fromindex);putchar('\n'); + + } + + break; + case 'O' : { /* print instance from Laddr. Not documented */ + int objaddr; + if(URaid_argnum ==1) + { + printf("PRINT-INSTANCE: O HEX-LispAddress\n"); + return(T); + } + if(sscanf(URaid_arg1,"%x",&objaddr) + <=0) { + printf("Arg not HEX number\n"); + return(T); + } + print(objaddr); + } + break; + case 't' : /* Object TYPE */ + if(URaid_argnum != 2){ + printf("PRINTTYPENAME: t Xaddress\n"); + return(T); + } + + /**HEXNUMP(URaid_arg1,"Not Address");**/ + if(sscanf(URaid_arg1,"%x",&address)<=0) + { + printf("Arg not HEX number\n"); + return(T); + } + ADD_RANGEP(address); + + switch(address >> 16) { + case ATOM_HI : printf("{ATOM}"); + printf("0x%x\n",address); + break; + case STK_HI : printf("{STK}"); + printf("0x%x\n",address); + break; + case PLIS_HI : printf("{PLIST}"); + printf("0x%x\n",address); + break; + case FPTOVP_HI : printf("{FPTOVP}"); + printf("0x%x\n",address); + break; + case PNP_HI : printf("{PNP}"); + printf("0x%x\n",address); + break; + case DEFS_HI : printf("{DEF}"); + printf("0x%x\n",address); + break; + case VALS_HI : printf("{VAL}"); + printf("0x%x\n",address); + break; + case DISPLAY_HI : + case DISPLAY_HI+1 :printf("{DISPLAY}"); + printf("0x%x\n",address); + break; + default: + num= GetTypeNumber(address); + putchar('{'); + print_atomname((DLword *)GetDTD(num)); + putchar('}'); + break; + } /* switch end */ + + break; +#define GetPROPCELL68k(index) ((LispPTR *)Plistspace + (index) ) + + case 'p' : /* property list */ + if(URaid_argnum != 2){ + printf("GETPROPLIST : p litatom\n"); + return(T); + } + if((index = parse_atomstring(URaid_arg1)) == + 0xffffffff){ + printf("No such atom\n"); + return(T); + } + print(*(GetPROPCELL68k(index)) & POINTERMASK ); + break; + + case 'w' : /* Disp CurrentFunc name & PC */ + doko(); + break; + +#define XDUMPW 8 + case 'x' : /* HEX dump "x Xaddress Xnum" */ + /* Obsolete + HEXNUMP(URaid_arg1,"Not Address"); + HEXNUMP(URaid_arg2,"Not number"); + ***/ + if(URaid_argnum==1) + { /* for help */ + printf("HEX-DUMP: x Xaddress [Xnum]\n"); + return(T); + } + if(sscanf(URaid_arg1,"%x",&address)<=0) + { /* arg1 not HEX */ + printf("Arg(Xaddress) not Xaddress\n"); + return(T); + } + switch(sscanf(URaid_arg2,"%x",&num)) + { + case -1 : /* Use defaultval for word-num */ + num = XDUMPW; + break; + case 0 : /* Illegal number */ + printf("Arg(Xnum) not Xnum\n"); + return(T); + /* break; */ + default : break; + } + if(num < 0) + { + printf("Dump words num should be positive\n"); + return(T); + } + /* Address range check */ + ADD_RANGEP(address); + ADD_RANGEP(address+num); + + { int i; + DLword *ptr,*endptr; + ptr=(DLword*)Addr68k_from_LADDR(address); + endptr=ptr+num; + + while(ptr < endptr) + { + printf("0x%x : ",LADDR_from_68k(ptr)); + + for(i=0; + ((ptr =0) + val |= S_POSITIVE; + else { val = val & 0xffff; + val |= S_NEGATIVE; + } + } + + } + printf("Old value is "); + print(*((LispPTR*)GetVALCELL68k(index))); + putchar('\n'); + *((LispPTR*)GetVALCELL68k(index)) =(LispPTR) val; + print(val); + break; + + + case '<' : if(URaid_argnum != 3){ + printf("Mem modify: < Xaddre Xval\n"); + return(T); + } + /* Assignment */ + /* OBSOLETE + HEXNUMP(URaid_arg1,"Not Address"); + HEXNUMP(URaid_arg2,"Not Proper Value"); + ***/ + + if(sscanf(URaid_arg1,"%x",&address) <=0) + { + printf("Arg(Xaddress) not Xaddress\n"); + return(T); + } + if(sscanf(URaid_arg2,"%x",&val) <=0) + { + printf("Arg(Xval) not Xaddress\n"); + return(T); + } + + ADD_RANGEP(address); + if(val <0 || val > 0xffff){ + printf("Xval invalid (16 bit range exceeded).\n"); + return(T); + } + + { DLword *ptr; + ptr =(DLword*)Addr68k_from_LADDR(address); + *ptr=val; + printf("0x%x : 0x%x\n",address,*ptr); + } + break; + +/****MISC ****/ + case 'q' : /* return with do Nothing */ + printf("Return to Lisp?[confirm](Y or N)<"); + {int c; + c= getchar(); + if((c=='Y')||(c=='y')) { + /*TopOfStack = NIL;*/ + return(NIL); + } + } + fflush(stdin); + URaid_currentFX=URMAXFXNUM +1; + return(T); + /* break; */ + case 'h' : /* HARDRESET */ + printf("HARDRESET?[confirm](Y or N)<"); + { int c; + c= getchar(); + if((c=='Y')||(c=='y')) + { + /*PC+= 3; for currentfx->pc ajust:MOve to subr */ + contextsw(ResetFXP,2,0); + /*PC -= 3; in subr.c it increments by 3 */ + fflush(stdin); + return(NIL); /* return to dispatch */ + } + + } + fflush(stdin); + break; + case 'e' : /* exit to UNIX */ +#ifdef DOS + printf("Exit to DOS?[confirm](Y or N)<"); +#else /* DOS */ + printf("Exit to UNIX?[confirm](Y or N)<"); +#endif /* DOS */ + { int c; + c= getchar(); + if((c=='Y')||(c=='y')) + exit(0); + } + fflush(stdin); + URaid_currentFX=URMAXFXNUM +1; + break; + case 's' : /* SHELL */ + switch (vfork()) { + case -1: + (void)fprintf(stderr, "uraid: Fork failed.\n"); + exit(1); + + case 0: + (void)execl("/bin/sh", "sh", "-i", 0); + exit(1); + + default: + break; + } +#ifndef DOS + (void)wait(&status); + /* system("/bin/sh -i"); */ +#endif /* DOS */ + return(T); + /* break; */ + case 'v' : if(URaid_argnum != 2){ + printf("VMEMSAVE: v filename (it's NOT bootable)\n"); + return(T); + } +#ifndef DISPLAYBUFFER + copy_region ( HideDisp68k, + DisplayRegion68k, + DisplayRasterWidth, + displayheight ); +#endif /* DISPLAYBUFFER */ + + if(vmem_save(URaid_arg1) != NIL){ +#ifndef DISPLAYBUFFER + clear_display(); +#endif /* DISPLAYBUFFER */ + + printf("VMEMSAVE fails\n"); + } + else { + clear_display(); + printf("VMEMSAVE finished, but it's not bootable\n"); + } + break; + case '(' : if(URaid_argnum==1) num = 2; + + else if((URaid_arg1[0] < '0') || (URaid_arg1[0] > '9')){ + printf("Illegal argument, not number\n"); + return(T); + } + else + sscanf(URaid_arg1,"%d",&num); + + PrintMaxLevel = num; + printf("PrintLevel is set to %d.",num); + break; + case '?' : +#ifdef DOS + printf(" 1: <>\n 2: <>\n 3: <>\n"); +#else + printf("%s\n",URaid_summary); +#endif /* DOS */ + break; + case '!' : printf("Error message is: %s\n",URaid_errmess); + break; + + default : printf("Unsupported command.\n"); + break; + + } /* switch end */ +return(T); +} + + + + +/************************************************************************/ +/* */ +/* device_before_raid() */ +/* */ +/* Written by : Takeshi Shimizu */ +/* Date: 6-May-1988 */ +/* */ +/* */ +/* Do whatever cleanup is necessary before leaving Lisp */ +/* for URAID or for SUSPEND-LISP: Cache the display buffer, */ +/* close the frame buffer, and any buffering pixrects. */ +/* */ +/************************************************************************/ + +#ifdef DISPLAYBUFFER +extern struct pixrect *ColorDisplayPixrect,*DisplayRegionPixrect; +#endif + +#ifdef SUNDISPLAY +#define SV_ACQUIRE "/bin/sunview1/sv_acquire" +#define SV_RELEASE "/bin/sunview1/sv_release" +#endif /* SUNDISPLAY */ + + +device_before_raid() + { + int keytrans; + int size; + int munmapstat; + struct pixrect *fb; + extern char *alloc_hideDISP(); +#ifdef SUNDISPLAY + union wait status; +#endif /* SUNDISPLAY */ + + char *malloc(); + + int_timer_off(); + +#if (defined(XWINDOW) && defined(SYSVSIGNALS) && defined(SIGIO)) + sigrelse(SIGIO); /* So X events still get recognized. */ +#endif /* XWINDOW + SYSVSIGNALS + SIGIO */ + +#ifdef SUNDISPLAY + win_setcursor(LispWindowFd, &InvisibleCursor); +#ifdef KBINT + int_io_close(LispWindowFd); +#endif +#endif /* SUNDISPLAY */ + +#ifdef NOETHER +#else +#ifdef ETHERINT + if(ether_fd > 0) /* check ether is used or not */ + int_io_close(ether_fd); +#endif +#endif /* NOETHER */ + +#ifdef RS232INT + int_io_close(RS232C_Fd); +#endif + +#ifdef SUNDISPLAY + mess_reset(); /* turn off console-msg handling */ + +#ifdef FX_AR_124 + /* For AR 124. Type4 driver bug?? by m.matsuda */ + { long i; for( i=0; i<900000; i++ ); } +#endif /* FX_AR_124 */ + + + if( (LispKbdFd = open( LispScreen.scr_kbdname , O_RDWR)) == -1) + { + fprintf( stderr, "can't open %s\n", LispScreen.scr_kbdname); + return( -1 ); + } + + keytrans = TR_EVENT; /* keyboard encodes key */ + if(ioctl( LispKbdFd, KIOCTRANS, &keytrans)== -1) + { + fprintf( stderr, "Error at ioctl errno =%d\n", errno); + return( -1 ); + } + close( LispKbdFd ); + close( LispWindowFd ); + +#ifdef TRUECOLOR + truecolor_before_raid(); +#endif /* TRUECOLOR */ + + +#ifndef DISPLAYBUFFER + size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) + & -getpagesize()); + + if((HideDisp68k= malloc(size)) == 0) + { + printf("can't malloc hide space\n"); + return(-1); + } + + copy_region ( DisplayRegion68k, + HideDisp68k, + DisplayRasterWidth, + displayheight ); +#endif /* DISPLAYBUFFER */ + + +#ifdef COLOR + save_colormap(); + +#ifndef DISPLAYBUFFER + if( Inited_Color ) { +#else + if( MonoOrColor == COLOR_SCREEN ) { +#endif /* DISPLAYBUFFER */ + + /* save color image */ + size = ((displaywidth * displayheight + (getpagesize()-1) ) + & -getpagesize()); /* 8 bit depth */ + if((HideColorDisp68k= malloc(size)) == 0){ + printf("can't malloc hide space\n"); + return(-1); + } + copy_region( ColorDisplayRegion68k, + HideColorDisp68k, + DisplayRasterWidth * 8, + displayheight ); + } /* end if(MonoOrColor) */ +#endif /* COLOR */ + + + + clear_display(); + +#ifdef DISPLAYBUFFER + pr_close(ColorDisplayPixrect); + close(FrameBufferFd); +#endif + + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ + (void)fprintf(stderr, "display_before_exit: Fork failed.\n"); + exit(1); + + case 0: /* Child */ + (void)execl(SV_RELEASE, "sv_release", 0); + /* should not return */ + (void)fprintf(stderr, + "display_before_exit: exec for sv_release failed\n"); + exit(1); + + default: /* Parent */ + /* do nothing */ + break; + } + (void)wait(&status); /* child dies after changing 16 */ + + if (status.w_retcode != 0) { + (void)fprintf(stderr, + "device_before_raid: failed to set ownership of win devices\n"); + exit(1); + } + } + +#endif /* SUNDISPLAY */ + +#if defined(XWINDOW) || defined(DOS) + (currentdsp->cleardisplay)(currentdsp); + (currentdsp->device.before_raid)(currentdsp); +#ifdef DOS + (currentmouse->device.before_raid)(currentmouse); + (currentkbd->device.before_raid)(currentkbd); +#endif /* DOS */ +#endif /* XWINDOW || DOS */ + + return(0); + } + + +/** +char *alloc_hideDISP(size) +int size; +{ + char *retaddr; + switch(*STORAGEFULLSTATE_word & 0xffff) + { + case SFS_NOTSWITCHABLE : + if((retaddr =malloc(size)) ==0){ + fprintf(stderr,"can't alloc hide space\n"); + } + break; + case 0 : + case SFS_SWITCHABLE : + retaddr = + (char*)Addr68k_from_LADDR((*ArraySpace2_word) & POINTERMASK); + printf("Hidespace inside Lisp(2)\n"); + + break; + case SFS_ARRAYSWITCHED : + retaddr=(char*)Addr68k_from_LADDR(*Next_Array_word & 0xffff); +; + printf("Hidespace inside Lisp(3)\n"); + + break; + case SFS_FULLYSWITCHED : + if((UNSIGNED)Addr68k_from_LADDR(*Next_MDSpage_word & 0xffff) + - (UNSIGNED)Addr68k_from_LADDR(*Next_Array_word & 0xffff) + >size) { + retaddr= (char*)Addr68k_from_LADDR(*Next_Array_word & 0xffff); + printf("Hidespace inside Lisp(4)\n"); + } + else if((retaddr=malloc(size)) ==0){ + fprintf(stderr,"can't alloc hide disp\n"); + } + printf("Hidespace new\n"); + break; + + default : printf("Illegal data in STORAGEFULLSTATE\n"); + retaddr=0; + break; + } + return(retaddr); +} +****/ + + +/***********************************************************************/ +/* + func name : device_after_raid() + Written by : Takeshi Shimizu + Date: 6-May-1988 + + This should be called when returning LISP. + +*/ +/***********************************************************************/ +#define KB_ALLUP 0xffff + +device_after_raid() + { + extern DLword *EmMouseX68K, *EmMouseY68K, + *EmKbdAd068K, *EmRealUtilin68K; + extern DLword *EmKbdAd168K,*EmKbdAd268K,*EmKbdAd368K, + *EmKbdAd468K,*EmKbdAd568K; + LispReadFds = 0; + if(re_init_display(DISPLAY_OFFSET,65536 * 16 *2)== -1) + return(-1); + set_cursor(); + init_keyboard(1); + +#ifdef TRUECOLOR + truecolor_after_raid(); +#endif /* TRUECOLOR */ + + +#ifdef NOETHER +#else + init_ether(); +#ifdef USE_DLPI + if (ether_fd > 0) if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) + { + perror("after-uraid: I_SETSIG for ether failed:\n"); + close(ether_fd); + ether_fd = -1; + return(NIL); + } +#endif /* USE_DLPI */ +#endif /* NOETHER */ + +#ifdef XWINDOW +#ifdef I_SETSIG + if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) perror("SETSIG on X fd failed"); +#endif /* I_SETSIG */ +#endif /* XWINDOW */ + + int_init(); + +#ifdef SUNDISPLAY + LispReadFds |= (1 << LispWindowFd) ; +#endif /* SUNDISPLAY */ + +#ifdef NOETHER +#else + LispReadFds |= EtherReadFds; +#endif /* NOETHER */ + +#ifdef XWINDOW + (currentdsp->device.after_raid)(currentdsp); + LispReadFds |= (1 << ConnectionNumber(currentdsp->display_id)); + flush_display_buffer(); +#elif DOS + (currentdsp->device.after_raid)(currentdsp); + (currentmouse->device.after_raid)(currentmouse, currentdsp); + (currentkbd->device.after_raid)(currentkbd); + flush_display_buffer(); +#endif /* XWINDOW | DOS */ + + int_timer_on(); + *EmKbdAd068K= *EmRealUtilin68K= *EmKbdAd168K= + *EmKbdAd268K= *EmKbdAd368K= + *EmKbdAd468K= *EmKbdAd568K=KB_ALLUP ; + return(0); + } /* device_after_raid */ + + + +/***********************************************************************/ +/* + func name :re_init_display(lisp_display_addr, display_max) + int lisp_display_addr, display_max; + + Written by : Takeshi Shimizu + Date: 6-May-1988 + + This should be called when returning LISP. + Only called by device_after_raid + +*/ +/***********************************************************************/ +#ifndef COLOR + +re_init_display(lisp_display_addr, display_max) + int lisp_display_addr, display_max; + { + int mmapstat, size; + struct pixrect *ColorFb; + extern struct pixrect *ColorDisplayPixrect,*DisplayRegionPixrect; + extern int DisplayType; + +#ifdef SUNDISPLAY + + union wait status; + + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ + (void)fprintf(stderr, "re_init_display: Fork failed.\n"); + exit(1); + + case 0: /* Child */ + (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); + /* should not return */ + (void)fprintf(stderr, "re_init_display: exec for sv_acquire failed\n"); + exit(1); + + default: /* Parent */ + /* do nothing */ + break; + } + (void)wait(&status); /* child dies after changing 6 */ + + if (status.w_retcode != 0) { + (void)fprintf(stderr, + "re_init_display: failed to set ownership of win devices\n"); + exit(1); + } + } + + mess_init(); + if( (LispWindowFd = win_screennew( &LispScreen )) == -1) + { + fprintf( stderr, "init_display: can't create LispWindow\n"); + return( -1 ); + } + else + { +#ifdef KBINT + int_io_open(LispWindowFd); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); + +#ifdef FX_AR_124 + /* For AR 124. Type4 driver bug?? by m.matsuda */ + { long i; for( i=0 ; i<900000 ; i++ ) ; } +#endif /* FX_AR_124 */ + +#endif + } + +#ifndef DISPLAYBUFFER +/* for CGFOUR dev */ + if(DisplayType == SUN4COLOR) + { + ColorFb = pr_open("/dev/fb"); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, + PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } +#else /* DISPLAYBUFFER is T */ +/* ColorDisplayPixrect = pr_open("/dev/fb"); + pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); + pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, + (1<pr_depth)-1, 1, + &black, &black, &black); +***/ +#endif /* DISPLAYBUFFER */ + + + init_cursor(); + +#ifndef DISPLAYBUFFER + size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) + & -getpagesize()); + mmapstat = (int) + mmap( DisplayRegion68k, + size, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif /* OS4 */ + + MAP_SHARED, + FrameBufferFd, 0 ); + + if(mmapstat == -1) + { + fprintf( stderr, "re_init_display: ERROR at mmap system call\n"); + fprintf( stderr, "errno = %d\n\n", errno ); + return( 0 ); + } + + copy_region ( HideDisp68k, + DisplayRegion68k, + DisplayRasterWidth, + displayheight ); + + free(HideDisp68k); +#endif /* DISPLAYBUFFER */ + + +#ifdef DISPLAYBUFFER + ColorDisplayPixrect = pr_open("/dev/fb"); + flush_display_buffer(); +/* refresh_CG6; */ + +#endif /* DISPLAYBUFFER */ + +#endif /* SUNDISPLAY */ + + + return(0); + } + +#else /* COLOR */ + +re_init_display(lisp_display_addr, display_max) + int lisp_display_addr, display_max; + { + int mmapstat, size; + struct pixrect *ColorFb; +/* + extern struct pixrect *color_source; +*/ + struct pixrect *color_source; + extern int DisplayType; + +#ifdef SUNDISPLAY + union wait status; + + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ + (void)fprintf(stderr, "re_init_display: Fork failed.\n"); + exit(1); + + case 0: /* Child */ + (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); + /* should not return */ + (void)fprintf(stderr, "re_init_display: exec for sv_acquire failed\n"); + exit(1); + + default: /* Parent */ + /* do nothing */ + break; + } + (void)wait(&status); /* child dies after changing 6 */ + + if (status.w_retcode != 0) { + (void)fprintf(stderr, + "re_init_display: failed to set ownership of win devices\n"); + exit(1); + } + } + + mess_init(); + if( (LispWindowFd = win_screennew( &LispScreen )) == -1) + { + fprintf( stderr, "init_display: can't create LispWindow\n"); + return( -1 ); + } + else + { +#ifdef KBINT + int_io_open(LispWindowFd); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); +#endif + } + +#ifdef DISPLAYBUFFER + if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1){ + perror("init_display: can't open FrameBuffer\n"); + exit( -1 ); + } +#endif /* DISPLAYBUFFER */ + + + restore_colormap(); + + if( MonoOrColor == MONO_SCREEN ) { +#ifndef DISPLAYBUFFER + /* for CGFOUR dev */ + if(DisplayType == SUN4COLOR) { + ColorFb = pr_open("/dev/fb"); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, + PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } +#else /* DISPLAYBUFFER is T */ + /* ColorDisplayPixrect = pr_open("/dev/fb"); + pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); + pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, + (1<pr_depth)-1, 1, + &black, &black, &black); +***/ +#endif /* DISPLAYBUFFER */ + + + init_cursor(); + +#ifndef DISPLAYBUFFER + size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) + & -getpagesize()); + + mmapstat = (int) + mmap( DisplayRegion68k, + size, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif /* OS4 */ + + MAP_SHARED, + FrameBufferFd, 0 ); + if( Inited_Color ) + mmapstat = (int) + mmap( ColorDisplayRegion68k, + Dispcolorsize, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif /* OS4 */ + + MAP_SHARED, + FrameBufferFd, 0x40000 ); + + if(mmapstat == -1) + { + fprintf( stderr, "re_init_display: ERROR at mmap system call\n"); + fprintf( stderr, "errno = %d\n\n", errno ); + return( 0 ); + } + /* restore mono image */ + copy_region ( HideDisp68k, + DisplayRegion68k, + DisplayRasterWidth, + displayheight ); + + free(HideDisp68k); + + if( Inited_Color ) { /* restore color image */ + copy_region( HideColorDisp68k + , ColorDisplayRegion68k + , DisplayRasterWidth * 8 + , displayheight ); + free(HideColorDisp68k); + } /* end if( Inited_Color ) */ +#endif /* DISPLAYBUFFER */ + + +#ifdef DISPLAYBUFFER + ColorDisplayPixrect = pr_open("/dev/fb"); + flush_display_buffer(); + /* refresh_CG6; */ +#endif /* DISPLAYBUFFER */ + + + } else { /* MonoOrColor is COLOR_SCREEN */ + ColorFb = pr_open("/dev/fb"); +#ifdef DISPLAYBUFFER + ColorDisplayPixrect = ColorFb; +#endif /* DISPLAYBUFFER */ + + color_source = mem_point(displaywidth,displayheight,8,ColorDisplayRegion68k); + pr_rop(ColorFb,0,0,displaywidth,displayheight,PIX_SRC,color_source,0,0); +#ifndef DISPLAYBUFFER + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb,0,0,ColorFb->pr_width, ColorFb->pr_height, + PIX_CLR, 0, 0, 0); +#endif /* DISPLAYBUFFER */ + + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); + init_cursor(); + mmapstat = (int)mmap(ColorDisplayRegion68k , + Dispcolorsize, + PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x40000 ); + if(mmapstat == -1){ + perror("cgfour_init_color_display: ERROR at mmap system call\n"); + error("cgfour_init_color_display: ERROR at mmap system call\n You may be able to continue by typing 'q'"); +/* printf("MMAP FAIL:BMBASE=0x%x\nNATIVE:= 0x%x\nLISPBASEN:= 0x%x\n", + color_bitmapbase,ColorDisplayRegion68k,Lisp_world); +*/ + return(NIL); + } /* end if(mmapstat) */ + +#ifndef DISPLAYBUFFER + /* restore mono image */ + copy_region ( HideDisp68k, + DisplayRegion68k, + DisplayRasterWidth, + displayheight ); + + free(HideDisp68k); +#endif /* DISPLAYBUFFER */ + + + /* restore coloe image */ + copy_region ( HideColorDisp68k, + ColorDisplayRegion68k, + DisplayRasterWidth * 8, + displayheight ); + + free(HideColorDisp68k); + } /* end if(MonoOrColor) */ +#endif /* SUNDISPLAY */ + + + return(0); + } + +#endif /* COLOR */ + diff --git a/src/usrsubr.c b/src/usrsubr.c new file mode 100755 index 0000000..c579a6e --- /dev/null +++ b/src/usrsubr.c @@ -0,0 +1,49 @@ +/* $Id: usrsubr.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: usrsubr.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyright (C) Venue"; + + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/** User defined subrs here. Do NOT attempt to use this unless you FULLY + understand the dependencies of the LDE architecture. **/ + +#define DO_UFN {return(-1);} + +UserSubr(int user_subr_index, int num_args, int *args) +{ +int result = 0; + +/* *** remove the printf when finished debugging your user subr *** */ + + printf("debug: case: 0x%x, args: 0x%x\n",user_subr_index, num_args); + {int i; + for (i = 0; i < num_args; i++) printf("debug: arg[%d]: 0x%x\n",i,args[i]); + }; + + + switch (user_subr_index) { + + case 0: printf("sample UFN\n"); result = args[0]; break; + default: DO_UFN; + } + + return(result); +} + diff --git a/src/uutils.c b/src/uutils.c new file mode 100755 index 0000000..62efef6 --- /dev/null +++ b/src/uutils.c @@ -0,0 +1,501 @@ +/* $Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +/************************************************************************/ +/* */ +/* U U T I L S . C */ +/* */ +/* Utility subrs for dealing with the host OS. */ +/* */ +/************************************************************************/ + + +#ifndef DOS +#include +#endif +#include +#ifdef DOS +#include +#else +#include +#endif +#ifndef SYSVONLY +#ifdef DOS +#include +#else +#include +#endif /* DOS */ +#endif /* SYSVONLY */ + +#include +#include "lispemul.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "osmsg.h" +#include "keyboard.h" + +#ifdef OS5 +#define gethostid() 0 +#endif /* OS5 */ + + + +/************************************************************************/ +/* */ +/* l i s p _ s t r i n g _ t o _ c _ s t r i n g */ +/* */ +/* converts lisp string up to maximum length; returns 0 if it */ +/* succeeds, -1 if error (not a simple string, or too long, or */ +/* contains NS characters outside charset 0). */ +/* */ +/************************************************************************/ + +int lisp_string_to_c_string(LispPTR Lisp, char *C, int length) +{ + register OneDArray *arrayp; + register char *base; + + if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) {return (-1);} + + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); + if (arrayp->fillpointer >= length) {return(-1);} /* too long */ + + switch(arrayp->typenumber){ + case THIN_CHAR_TYPENUMBER: + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) + + ((int)(arrayp->offset)); +#ifndef BYTESWAP + strncpy(C, base, arrayp->fillpointer); +#else + { register int i,length ; + register char *dp; + for(i=0,dp=C, length = arrayp->fillpointer; + ifillpointer] = '\0'; + return 0; + default: + return -1; + } +} + + + +/************************************************************************/ +/* */ +/* c _ s t r i n g _ t o _ l i s p _ s t r i n g */ +/* */ +/* copies a C string into an existing Lisp string (it does not */ +/* create a new Lisp string). Returns 0 if succeeds, -1 if */ +/* error (Lisp string is not a simple string, or not long enough, */ +/* or is FATP). The string will end with a null, which the */ +/* length must include. */ +/* */ +/************************************************************************/ + +int c_string_to_lisp_string(char *C, LispPTR Lisp) +{ + register OneDArray *arrayp; + char *base; + register int length; + + length = strlen(C); + if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) {return (-1);} + + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); + if (arrayp->totalsize < length+1) {return(-1);} + /* too short for C string */ + + switch(arrayp->typenumber){ + case THIN_CHAR_TYPENUMBER: + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) + + ((int)(arrayp->offset)); +#ifndef BYTESWAP + strcpy(base, C); +#else + { register int i; + register char *dp; + for(i=0,dp = C;i <= length + 1;i++) + { + int ch = *dp++; +#ifdef DOS + if (ch == '\\') dp++; /* skip 2nd \ in \\ in C strings */ +#endif /* DOS */ + GETBYTE(base++) = ch; + } + } +#endif /* BYTESWAP */ + + return 0; + default: + return -1; + } +} + + + +/************************************************************************/ +/* */ +/* c h e c k _ u n i x _ p a s s w o r d */ +/* */ +/* Check this guy's password against what he gave us. */ +/* */ +/************************************************************************/ + +check_unix_password(LispPTR *args) +{ +#ifndef DOS + struct passwd *pwd; + char *password, *getpass(const char *); +#ifndef OS5 + char *crypt(const char *, const char *); +#endif /* OS5 */ + char salt[3]; + char name[100], pass[100]; + + if (lisp_string_to_c_string(args[0], name, sizeof name)) {return NIL;} + if (lisp_string_to_c_string(args[1], pass, sizeof pass)) {return NIL;} + + if ((pwd = getpwnam(name)) == 0) { + return(NIL); /* can't find entry for name */ + } + salt[0] = pwd->pw_passwd[0]; + salt[1] = pwd->pw_passwd[1]; + salt[2] = '\0'; + if (strcmp((char *)crypt(pass, salt), pwd->pw_passwd) == 0) + return(ATOM_T); + else + return(NIL); +#else + return ATOM_T; +#endif /* DOS */ +} + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +unix_username(LispPTR *args) +{ +#ifndef DOS + struct passwd *pwd; + + if ((pwd = getpwuid(getuid())) == NULL) + return NIL; + if (c_string_to_lisp_string(pwd->pw_name, args[0])) + return NIL; +#endif /* DOS */ + return ATOM_T; +} + + + +/************************************************************************/ +/* */ +/* u n i x _ g e t p a r m */ +/* */ +/* Given a string name for a configuration parameter, return */ +/* a string with the value for that parameter. */ +/* */ +/* PARAMETER MEANING/VALUES */ +/* */ +/* MACH What kind of processor we're running on */ +/* (sparc, mc68020, or i386 possible) */ +/* */ +/* ARCH The kind of machine we're running on */ +/* (sun4, sun386, sun3 possible) */ +/* */ +/* DISPLAY What kind of display we're running with */ +/* (X, BUFFERED, DIRECT possible) */ +/* */ +/* HOSTNAME Name of the machine we're running on. */ +/* */ +/* LOGNAME Login ID of the user running Lisp. */ +/* */ +/* FULLUSERNAME ?? */ +/* */ +/* HOSTID Machine serial# or Ether ID. */ +/* */ +/* */ +/************************************************************************/ + +char* getenv(const char *); + +unix_getparm(LispPTR *args) +{ + char envname[20], result[128], *envvalue; + if (lisp_string_to_c_string(args[0], envname, sizeof envname)) + return NIL; + if (strcmp(envname, "MACH") == 0) + { +#if defined(sparc) + envvalue = "sparc"; +#else +#if defined(I386) + envvalue = "i386"; +#else +#ifdef RS6000 + envvalue = "rs/6000"; +#else +#ifdef HP9000 + envvalue = "hp9000"; +#else +#ifdef ISC + envvalue = "i386"; +#else +#ifdef INDIGO + envvalue = "mips"; +#else +#ifdef RISCOS + envvalue = "mips"; +#else +#ifdef DOS + envvalue = "386"; +#else + envvalue = "mc68020"; +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif + } + else if (strcmp(envname, "ARCH") == 0) + { +#if defined(sparc) + envvalue = "sun4"; +#else +#if defined(I386) + envvalue = "sun386"; +#else +#ifdef RS6000 + envvalue = "rs/6000"; +#else +#ifdef HP9000 + envvalue = "hp9000"; +#else +#ifdef ISC + envvalue = "i386"; +#else +#ifdef INDIGO + envvalue = "mips"; +#else +#ifdef RISCOS + envvalue = "mips"; +#else +#ifdef DOS + envvalue = "dos"; +#else + envvalue = "sun3"; +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif + } + else if (strcmp(envname, "DISPLAY") == 0) + { +#if defined(XWINDOW) + envvalue = "X"; +#else +#if defined(DISPLAYBUFFER) + envvalue = "BUFFERED"; +#else + envvalue = "DIRECT"; +#endif /* DISPLAYBUFFER */ + +#endif /* XWINDOW */ + + + } +#ifndef DOS + else if (strcmp(envname, "HOSTNAME") == 0) + { + if (gethostname(result, sizeof result)) return NIL; + envvalue = result; + } + else if (strcmp(envname, "LOGNAME") == 0) + { + struct passwd *pwd; + if ((pwd = getpwuid(getuid())) == NULL) return NIL; + envvalue = pwd->pw_name; + } + else if (strcmp(envname, "FULLUSERNAME") == 0) + { + struct passwd *pwd; + if ((pwd = getpwuid(getuid())) == NULL) return NIL; + envvalue = pwd->pw_gecos; + } + else if (strcmp(envname, "HOSTID") == 0) + { + sprintf(result, "%x", gethostid()); + envvalue = result; + } +#endif /* DOS */ + else return NIL; + + if (c_string_to_lisp_string(envvalue, args[1])) return NIL; + return ATOM_T; + } + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +unix_getenv(LispPTR *args) +{ + char envname[20], *envvalue; + if (lisp_string_to_c_string(args[0], envname, sizeof envname)) + return NIL; + envvalue = getenv(envname); + if (!envvalue) + return NIL; + if (c_string_to_lisp_string(envvalue, args[1])) + return NIL; + return ATOM_T; +} + + + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +unix_fullname(LispPTR *args) +{ +#ifndef DOS + struct passwd *pwd; + + if ((pwd = getpwuid(getuid())) == NULL) + return NIL; + if (c_string_to_lisp_string(pwd->pw_gecos, args[0])) + return NIL; +#endif /* DOS */ + return ATOM_T; +} + + + + +/************************************************************************/ +/* */ +/* s u s p e n d _ l i s p */ +/* */ +/* Suspend execution, ala ^Z from the shell. */ +/* */ +/************************************************************************/ + +extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, + *EmRealUtilin68K,*EmUtilin68K; +extern DLword *EmKbdAd168K,*EmKbdAd268K,*EmKbdAd368K, + *EmKbdAd468K,*EmKbdAd568K; + +suspend_lisp(LispPTR *args) +{ +#ifndef DOS + extern DLword *CTopKeyevent; + extern LispPTR *KEYBUFFERING68k; + + DLword w, r; + KBEVENT *kbevent; + + + if(device_before_raid() < 0) + { + OSMESSAGE_PRINT( printf("Can't suspend\n") ); + return NIL; + } + + OSMESSAGE_PRINT( printf("suspending...\n") ); + + /* Send a terminal-stop signal to the whole process-group, not + just this process, so that if we are running as part of a + C-shell file the shell will be suspended too. */ +#ifdef SYSVONLY + kill(0, SIGTSTP); +#else + killpg(getpgrp(0), SIGTSTP); +#endif /* SYSVONLY */ + + + + OSMESSAGE_PRINT( printf("resuming\n") ); + device_after_raid(); + + r=RING_READ(CTopKeyevent); + w=RING_WRITE(CTopKeyevent); + + /*NO CARE about event queue FULL */ + + GETWORD(EmKbdAd068K)= KB_ALLUP; + GETWORD(EmKbdAd168K)= KB_ALLUP; + GETWORD(EmKbdAd268K)= KB_ALLUP; + GETWORD(EmKbdAd368K)= KB_ALLUP; + GETWORD(EmKbdAd468K)= KB_ALLUP; + GETWORD(EmKbdAd568K)= KB_ALLUP; + GETWORD(EmRealUtilin68K)= KB_ALLUP; + + kbevent=(KBEVENT*)(CTopKeyevent+ w); + +/* RCLK(kbevent->time); */ + + kbevent->W0= GETWORD(EmKbdAd068K); + kbevent->W1= GETWORD(EmKbdAd168K); + kbevent->W2= GETWORD(EmKbdAd268K); + kbevent->W3= GETWORD(EmKbdAd368K); + kbevent->W4= GETWORD(EmKbdAd468K); + kbevent->W5= GETWORD(EmKbdAd568K); + kbevent->WU= GETWORD(EmRealUtilin68K); + + if(r==0) /* Queue was empty */ + ((RING*)CTopKeyevent)->read=w; + + if(w >= MAXKEYEVENT) + ((RING*)CTopKeyevent)->write = MINKEYEVENT; + else + ((RING*)CTopKeyevent)->write = w + KEYEVENTSIZE; +#endif /* DOS, which doesn't support suspend-lisp */ + return ATOM_T; + } diff --git a/src/vars3.c b/src/vars3.c new file mode 100755 index 0000000..ecc9ab9 --- /dev/null +++ b/src/vars3.c @@ -0,0 +1,194 @@ +/* $Id: vars3.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: vars3.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "adr68k.h" +#include "emlglob.h" +#include "cell.h" +#include "lsptypes.h" +#include "stack.h" + +/* def. of car_cell moved to cell.h */ + +struct cadr_cell cadr(LispPTR cell_adr); + +/******************************************* +cadr + + common routine. + used by OP_assoc, OP_fmemb + + +*******************************************/ +struct cadr_cell +cadr(LispPTR cell_adr) + /* address of cell */ + /* Lisp address (word addressing) */ +{ +ConsCell *pcons; +struct cadr_cell cadr1; /* return value */ +short offset; + + + if( Listp(cell_adr) == NIL) + if(cell_adr == NIL){ + cadr1.car_cell = 0; + cadr1.cdr_cell = 0; + return(cadr1); + } else { + cadr1.car_cell = car(cell_adr); + cadr1.cdr_cell = cdr(cell_adr); + return(cadr1); + } + + pcons = (ConsCell *)Addr68k_from_LADDR(cell_adr); + while( pcons->cdr_code == CDR_INDIRECT ){ + /* CDR indirect */ + cell_adr = pcons->car_field; + pcons = (ConsCell *)Addr68k_from_LADDR(pcons->car_field); + }/* skip CDR_INDIRECT cell */ + + cadr1.car_cell = pcons->car_field; + + if( pcons->cdr_code == CDR_NIL ){ + /* CDR nil */ + cadr1.cdr_cell = NIL_PTR; + return(cadr1); + } +#ifdef NEWCDRCODING + offset = (0x7 & pcons->cdr_code) << 1; + if(pcons->cdr_code > CDR_NIL){ + /* CDR on page */ + cadr1.cdr_cell = cell_adr + offset; + }else{ + /* CDR different page */ + pcons = (ConsCell *)Addr68k_from_LADDR( (cell_adr) + offset) ; + cadr1.cdr_cell = pcons->car_field; + } +#else + offset = (0x7F & pcons->cdr_code) << 1; + if(pcons->cdr_code > CDR_NIL){ + /* CDR on page */ + cadr1.cdr_cell = (mPAGEMASK & cell_adr) | offset; + }else{ + /* CDR different page */ + pcons = (ConsCell *)Addr68k_from_LADDR( ((mPAGEMASK & cell_adr) | offset) ); + cadr1.cdr_cell = pcons->car_field; + } +#endif /* NEWCDRCODING */ + + return(cadr1); +} + + + +/*********************************************************** +N_OP_arg0 + + Entry: ARG0 opcode[0141] + + + TopOfStack : slot number of IVAR area + + return : the contents of the slot. + + No effect to CurrentStack. + + +************************************************************/ + +LispPTR N_OP_arg0(register LispPTR tos) +{ +register int num; +register DLword *bf; /* index of Basic frame */ +register int nargs; + + + if( (SEGMASK & tos ) != S_POSITIVE){ + /* error("OP_arg0: Bad TopOfStack\n"); */ + ERROR_EXIT(tos); + }else + num = 0xFFFF & tos; + if(CURRENTFX->alink & 0x1){ + /* slow */ + bf = Stackspace + CURRENTFX->blink; + }else{ + /* fast */ + bf = ((DLword *)CURRENTFX) - BFSIZE; + /* bf : pointer to 1st word of BasicFramePointer */ + } + nargs = ((UNSIGNED)bf - (UNSIGNED)IVar)>>2; + /* nargs : number of IVAR slots */ + if((num ==0) || (num > nargs)){ + /* error("OP_arg0: Bad argument number\n"); */ + ERROR_EXIT(tos); + } + return(*((int *)IVar + num - 1)); +} + + +/******************************************* +N_OP_assoc + + Entry: ASSOC opcode[026] + + TopOfStack -- A-list (cons cell of Lisp address) + *(int *)(CurrentStackPTR) -- Key (cons cell of Lisp address) + + + +*******************************************/ + + +LispPTR N_OP_assoc(register LispPTR key, register LispPTR list) +{ +REGISTER struct cadr_cell cadr1; +register LispPTR cdr; /* address of (cdr A-list); Lisp address */ + + + if (list == NIL_PTR) { return(NIL_PTR); } + + if (!Listp( list )) { return(NIL_PTR); } + + S_N_CHECKANDCADR(list, cadr1, list); + + do{ + cdr = cadr1.cdr_cell; /* the rest of A-list */ + if(Listp(cadr1.car_cell) && key == car(cadr1.car_cell)){ + /* cons data found */ + return(cadr1.car_cell); + } + /* search the rest of A-list */ + if(Listp(cdr)) + cadr1 = cadr(cdr); + else cdr = NIL; + /* check for interrupts and punt to handle one safely */ + if (!Irq_Stk_End) { + TopOfStack = cdr; /* for next execution */ + TIMER_EXIT(cdr); + } + }while(cdr != NIL_PTR); + + return(NIL_PTR); +} + diff --git a/src/vesafns.asm b/src/vesafns.asm new file mode 100755 index 0000000..766d56c --- /dev/null +++ b/src/vesafns.asm @@ -0,0 +1,831 @@ +;; # @(#) vesafns.asm Version 1.1 (12/29/94). Copyright Venue # + + + + +;************************************************************************/ +;* */ +;* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +;* All Rights Reserved. */ +;* Manufactured in the United States of America. */ +;* */ +;* The contents of this file are proprietary information */ +;* belonging to Venue, and are provided to you under license. */ +;* They may not be further distributed or disclosed to third */ +;* parties without the specific permission of Venue. */ +;* */ +;************************************************************************/ + +.386P +DATA SEGMENT USE32 + +;;; ****************************** +;;; DevRec is the ``SuperClass'' of devices. +;;; It is included at the top of all the device record. +;;; **IT IS IMPORTANT THAT YOU KEEP THIS RECORD IN SYNC +;;; WITH THE DspInterfaceRec DEFINED IN devif.h +;;; ****************************** + DevRec STRUC + active DD ? + locked DD ? + deventer DD ? + devexit DD ? + before_raid DD ? + after_raid DD ? + sync_device DD ? + DevRec ENDS + +;;; ****************************** +;;; MRegion is the generic region record. It is used for geometry +;;; calculations. +;;; ****************************** + MRegion STRUC + x DD ? + y DD ? + RegWidth DD ? + RegHeight DD ? + MRegion ENDS + +;;; ****************************** +;;; DspInterfaceRec is the record that represents the +;;; display interface. +;;; **IT IS IMPORTANT THAT YOU KEEP THIS RECORD IN SYNC +;;; WITH THE DspInterfaceRec DEFINED IN devif.h +;;; ****************************** + DspInterfaceRec STRUC + device DevRec <> + drawline DD ? + + cleardisplay DD ? + + get_color_map_entry DD ? + set_color_map_entry DD ? + available_colors DD ? + possible_colors DD ? + +;; get_color_map DD ? +;; set_color_map DD ? +;; make_color_map DD ? + + medley_to_native_bm DD ? + native_to_mdley_bm DD ? + + bitblit_to_screen DD ? + bitblit_from_screen DD ? + scroll_region DD ? + + mouse_invissible DD ? + mouse_vissible DD ? + + Disp MRegion <> + bitsperpixel DD ? + colors DD ? + oldstate DD ? + graphicsstate DD ? + numberofbanks DD ? + + BytesPerLine DD ? + DisplayStartAddr DD ? + DisplaySegSize DD ? + DisplaySegMagnitude DD ? + LinesPerBank DD ? + SwitchBank DD ? + DspInterfaceRec ENDS + +;;; ****************************** +;;; IOPAGE good old iopage from medley... +;;; **IT IS IMPORTANT THAT YOU KEEP THIS RECORD IN SYNC +;;; WITH THE DspInterfaceRec DEFINED IN C. +;;; ****************************** + + IOPAGE STRUC + dummy0 DW 22o DUP (?) + dlfloppycmd DW ? + dlmaintpanel DW ? + dlprocessorcmd DW ? + dlttyportcmd DW ? + dlbeepcmd DW ? + newmousestate DW ? + dlrs232cputflag DW ? + dlrs232cmisccommand DW ? + dummy1b DW ? + dlrs232cgetflag DW ? + dummy1 DW 4o DUP (?) + dlfloppy DW ? + dummy1a DW ? + dummy2 DW ? + dlttyout DW ? + dummy3 DW ? + dlttyin DW ? + dlprocessor1 DW ? + dlprocessor2 DW ? + newmousex DW ? + dlprocessor0 DW ? + dlbeepfreq DW ? + newmousey DW ? + dlrs232cparametercsbhi DW ? + dlrs232cparametercsblo DW ? + dlrs232csetrs366status DW 2o DUP (?) + dlrs232cputcsblo DW ? + dlrs232csetrs366statusa DW ? + dlrs232cgetcsblo DW ? + dlrs232cputcsbhi DW ? + dlrs232cdevicestatus DW ? + dlrs232cgetcsbhi DW ? + dltodvalid DW ? + dlrs232cparameteroutcome DW ? + dltodhi DW ? + dltodlo DW ? + dlmousex DW ? + dltodlo2 DW ? + dlutilin DW ? + dlmousey DW ? + dlkbdad1 DW ? + dlkbdad0 DW ? + dlkbdad3 DW ? + dlkbdad2 DW ? + dlkbdad5 DW ? + dlkbdad4 DW ? + dllsepimagecsb DW 40o DUP (?) + dummy4a DW ? + dliophardwareconfig DW ? + dummy4 DW 12o DUP (?) + dlrs232cparametercsbhi_11 DW ? + dlrs232cparametercsblo_11 DW ? + dlrs232csetrs366status_11 DW 16o DUP (?) + dummy5 DW 74o DUP (?) + dlmagtape DW 4o DUP (?) + dlethernet DW 14o DUP (?) + dummy6 DW 36o DUP (?) + dldispinterrupt DW ? + dummy6a DW ? + dldispborder DW ? + dldispcontrol DW ? + dlcursory DW ? + dlcursorx DW ? + dlcursorbitmap DW 20o DUP (?) + IOPAGE ENDS + +DATA ENDS + +CODE SEGMENT USE32 +ASSUME DS:DATA +ASSUME CS:CODE + +DOBANK MACRO NUMBER + push eax + mov ax, NUMBER + mov dx, 3cdh + out dx, ax + pop eax + ENDM + +RET2C MACRO VALUE + mov eax,VALUE + leave + ret + ENDM + +;; ************************************************** +;; D o s c l e a r b a n k s +;; arg1: dsp (pointer to dsp struct) +;; +;; Fill banks with 0. +;; ************************************************** +dsp = 8 +bank = -8 +PUBLIC Dosclearbanks +Dosclearbanks PROC NEAR + enter 16,0 + push edx + push ecx + push edi + mov DWORD PTR bank[ebp], 0 + mov edx, dsp[ebp] + mov ecx, [edx.numberofbanks] + +clrbnk: push ecx + DOBANK bank[ebp] + add DWORD PTR bank[ebp], 1 + mov eax, 0 + mov edi, [edx.DisplayStartAddr] + mov ecx, [edx.DisplaySegSize] + rep stosd + + pop ecx + loop clrbnk + pop edi + pop ecx + pop edx + RET2C 0 +Dosclearbanks ENDP + + + +;; ************************************************** +;; D O S C u r s o r V i s s i b l e +;; arg1: dsp (pointer to dsp struct) +;; arg2: iop (pointer to IOPAGE struct +;; Medley's cursor has no meaningfull mask. The mask +;; is just the invers of the map (sigh...). The function +;; f(bg, map, curs) = bg*mask + (not mask)*curs thus +;; collapses to bg*(not curs) + curs. Since the medley +;; bitmaps have the invers meaning of the vesa bitmaps +;; (ie. they are pre inverted for your convenience!) +;; the expression turns out to be: +;; bg*curs + (not curs) +;; +;; The general idea here is that we blit the cursor +;; directly to the screen instead of to the displayregion. +;; this saves a whole bunch of time since takeing the +;; mouse down is just a matter of updateing the screen. +;; since this operation has to be done every charblt +;; we save bunches of time. /jarl +;; +;; Assumption: we can straddle at most two banks +;; ************************************************** +dsp = 8 +iop = 12 +PUBLIC DOSCursorVissible +DOSCursorVissible PROC NEAR + enter 32,0 + + push edx + push esi + push edi + push ebx + push ecx + mov edx, dsp[ebp] + mov esi, iop[ebp] + + ;; find the destiniation byte index + movzx eax, [esi.dlcursory] + imul eax, [edx.BytesPerLine] + movzx ebx, [esi.dlcursorx] + sar ebx, 3 ; Make it a byte address + add eax, ebx + mov edi, eax + ;; make the dest index be an address within bounds + and edi, [edx.DisplaySegSize] + or edi, [edx.DisplayStartAddr] + +setbnk: mov dx, 3cdh ; Set the bank + mov ax, 0 + out dx, ax + + add esi, dlcursorbitmap + mov ecx, 16 ; The curs height + +bltcur: lodsw ; cursorbitmap to ax + mov ax, 1010101010101010b + stosw + add edi, [edx.BytesPerLine] + + loop bltcur + + pop ecx + pop ebx + pop edi + pop esi + pop edx + + RET2C 0 +DOSCursorVissible ENDP + + +;; ************************************************** +;; ************************************************** +;; D o s b b t 1 +;; arg1: dsp (pointer to a dsp struct) +;; arg2: buffer (pointer to array of word) +;; arg3: left (dword) (in pixels) +;; arg4: top (dword) (in pixels) +;; arg5: swidth (dword) (in pixels) +;; arg6: height (dword) (in pixels) +;; +;; Bitblits the image stored in buffer to the display +;; buffer. Assumption: buffer and the displaybuffer +;; are equaly large and thus left, top etc. pertains +;; to the same offsets. +;; +;; +;; C-CALL: void Dosbbt1( ... ); +;; RETURN: 0 in eax. should be ignored... +;; ************************************************** +dsp = 8 +buffer = 12 +left = 16 +top = 20 +swidth = 24 +height = 28 + +left32 = -8 +width32 = -12 +endptr = -16 +desttop = -20 +dstincr = -24 +srcincr = -28 + + +PUBLIC Dosbbt1 +Dosbbt1 PROC NEAR + ;;; ***************************** + ;;; Save the volatile environment + ;;; ***************************** + enter 32,0 + push ebx + push ecx + push edx + push esi + push edi + + mov edx, dsp[ebp] + + ;; Adjust the arguments to fit inside the display + ;; if left > displaywidth then exit + mov eax, [edx.Disp.RegWidth] + cmp left[ebp], eax + jg alldone + + ;; if 0 > (width + left) then exit + mov eax, left[ebp] + add eax, swidth[ebp] + cmp eax, 0 + jl alldone + + ;; if top > displayheight then exit + mov eax, [edx.Disp.RegHeight] + cmp top[ebp], eax + jg alldone + + ;; if 0 > (top + height) then exit + mov eax, top[ebp] + add eax, height[ebp] + cmp eax, 0 + jl alldone + + ;; if 0 > left then clipleft + mov eax, left[ebp] + cmp eax, 0 + jl clipleft + +tstwdt: ;; if (left + swidth) > displaywidth then clipwidth + mov eax, left[ebp] + add eax, swidth[ebp] + cmp eax, [edx.Disp.RegWidth] + jg clipwidth + +tsttop: ;; if 0 > top then cliptop + mov eax, top[ebp] + cmp eax, 0 + jl cliptop + +tsthit: ;; if (top + height) > displayheight then clipbottom + mov eax, top[ebp] + add eax, height[ebp] + cmp eax, [edx.Disp.RegHeight] + jg clipbtm + jmp startpoint + +clipleft: + mov DWORD PTR left[ebp], 0 + jmp tstwdt + +clipwidth: + mov eax, [edx.Disp.RegWidth] + sub eax, left[ebp] + mov swidth[ebp], eax + jmp tsttop + +cliptop: + mov DWORD PTR top[ebp], 0 + jmp tsthit + +clipbtm: + mov eax, [edx.Disp.RegHeight] + sub eax, top[ebp] + mov height[ebp], eax + + ;; Calculate byte offset into bitmap +startpoint: + mov eax, [edx.Disp.RegWidth] + imul eax, top[ebp] + add eax, left[ebp] + sar eax, 5 ; Make it a byte address on dword boundrys. + sal eax, 2 + + ;; Set dst and src start + mov edi, eax + mov esi, eax + add edi, [edx.DisplayStartAddr] + add esi, buffer[ebp] + + ;; Set dst and src incr + mov eax, left[ebp] + add eax, swidth[ebp] + add eax, 1fh + sar eax, 5 + mov ebx, left[ebp] + sar ebx, 5 + sub eax, ebx + mov width32[ebp], eax ; width32 is width in dwords + sal eax, 2 ; Make width32 a byteadr on dword boundrys. + mov ebx, [edx.Disp.RegWidth] + sar ebx, 3 + sub ebx, eax + + ;; {dst,src}incr is what to add to {esi,edi} to get to the new line + mov dstincr[ebp], ebx + mov srcincr[ebp], ebx + + ;;; ****************************** +Newline1: + mov ecx, width32[ebp] ; swidth into ecx + +Dumpline1: + lodsd ; Load eax and increment esi + xchg ah,al ; Swap low byte + rol eax,10h ; Get the high byte into position + xchg ah,al ; Swap again + not eax ; In medley 1=black 0=white, Hence invert. + stosd ; Store eax and increment edi + loop Dumpline1 + + ;; calc vals for src and dest for the next line. + add edi, dstincr[ebp] + add esi, srcincr[ebp] + + dec DWORD PTR height[ebp] + jg Newline1 + +alldone: + pop edi + pop esi + pop edx + pop ecx + pop ebx + + RET2C 0 +Dosbbt1 ENDP + + +;; ************************************************** +;; ************************************************** +;; D o s b b t 2 +;; arg1: dsp (pointer to a dsp struct) +;; arg2: buffer (pointer to array of word) +;; arg3: left (dword) (in pixels) +;; arg4: top (dword) (in pixels) +;; arg5: swidth (dword) (in pixels) +;; arg6: height (dword) (in pixels) +;; +;; FUNCTION: Monocrome bbt to a 4-plane displaybuffer. +;; +;; Bitblits the image stored in buffer to the display +;; buffer. ASSUMPTION: buffer and the displaybuffer +;; are equaly large and thus left, top etc. pertains +;; to the same offsets. +;; +;; Medley has a packed bitmap structure. Dosbbt2 assumes +;; that we are operating in 4-plane mode. The medley +;; bitmap is blitted to the first plane of the display. +;; Thus the bitmap appears black and white. +;; +;; +;; C-CALL: void Dosbbt2( ... ); +;; RETURN: 0 in eax. should be ignored... +;; ************************************************** +dsp = 8 +buffer = 12 +left = 16 +top = 20 +swidth = 24 +height = 28 + +left32 = -8 +width32 = -12 +endptr = -16 +desttop = -20 +dstincr = -24 +srcincr = -28 +tmpheight = -32 +switchr = -36 + +PUBLIC Dosbbt2 +Dosbbt2 PROC NEAR + ;;; ***************************** + ;;; Save the volatile environment + ;;; ***************************** + enter 36,0 + push ebx + push ecx + push edx + push esi + push edi + + mov edx, dsp[ebp] + + ;; Adjust the arguments to fit inside the display + ;; if left > displaywidth then exit + mov eax, [edx.Disp.RegWidth] + cmp left[ebp], eax + jg allbye + + ;; if 0 > (width + left) then exit + mov eax, left[ebp] + add eax, swidth[ebp] + cmp eax, 0 + jl allbye + + ;; if top > displayheight then exit + mov eax, [edx.Disp.RegHeight] + cmp top[ebp], eax + jg allbye + + ;; if 0 > (top + height) then exit + mov eax, top[ebp] + add eax, height[ebp] + cmp eax, 0 + jl allbye + + ;; if 0 > left then clipleft + mov eax, left[ebp] + cmp eax, 0 + jl clipleft2 + +tstwdt2: ;; if (left + swidth) > displaywidth then clipwidth + mov eax, left[ebp] + add eax, swidth[ebp] + cmp eax, [edx.Disp.RegWidth] + jg clipwidth2 + +tsttop2: ;; if 0 > top then cliptop + mov eax, top[ebp] + cmp eax, 0 + jl cliptop2 + +tsthit2: ;; if (top + height) > displayheight then clipbottom + mov eax, top[ebp] + add eax, height[ebp] + cmp eax, [edx.Disp.RegHeight] + jg clipbtm2 + jmp startpt + +clipleft2: + mov DWORD PTR left[ebp], 0 + jmp tstwdt2 + +clipwidth2: + mov eax, [edx.Disp.RegWidth] + sub eax, left[ebp] + mov swidth[ebp], eax + jmp tsttop2 + +cliptop2: + mov DWORD PTR top[ebp], 0 + jmp tsthit2 + +clipbtm2: + mov eax, [edx.Disp.RegHeight] + sub eax, top[ebp] + mov height[ebp], eax + + ;; Calculate byte offset into bitmap +startpt: + mov eax, [edx.Disp.RegWidth] + imul eax, top[ebp] + add eax, left[ebp] + sar eax, 5 ; Make it a byte address on dword boundrys. + sal eax, 2 + + ;; Calculate which bank to start in. + push eax + push ecx + mov ecx, [edx.DisplaySegMagnitude] + sar eax, cl + mov DWORD PTR bank[ebp], eax + pop ecx + pop eax + + ;; Set dst and src start + mov edi, eax + mov esi, eax + add esi, buffer[ebp] + + ;; Set dst and src incr + mov eax, left[ebp] + add eax, swidth[ebp] + add eax, 1fh + sar eax, 5 + mov ebx, left[ebp] + sar ebx, 5 + sub eax, ebx + mov width32[ebp], eax ; width32 is width in dwords + sal eax, 2 ; Make width32 a byteadr on dword boundrys. + mov ebx, [edx.Disp.RegWidth] + sar ebx, 3 + sub ebx, eax + + ;; {dst,src}incr is what to add to {esi,edi} to get to the new line + mov dstincr[ebp], ebx + mov srcincr[ebp], ebx + + ;; Adjust top to be inside the startbank + push eax + mov eax, [edx.LinesPerBank] + dec eax + and DWORD PTR top[ebp], eax + pop eax + +Newbank2: + ;; Set the bank + ;; Use VESA int procedure to do this. + mov edx, DWORD PTR bank[ebp] + mov bx, 0 + mov ax,4f05h + int 10h + mov edx, dsp[ebp] ;Restore edx. + + + ;; Adjust dst to be within axxxxh + push eax + mov eax, [edx.DisplaySegSize] + dec eax + and edi, eax + add edi, [edx.DisplayStartAddr] + pop eax + + ;; XX + mov ebx, height[ebp] + mov eax, top[ebp] + add eax, ebx + cmp eax, [edx.LinesPerBank] + jle doit + + mov ebx, [edx.LinesPerBank] + sub ebx, top[ebp] + +doit: + mov DWORD PTR top[ebp], 0 + mov tmpheight[ebp], ebx + sub height[ebp], ebx + +Newline2: + mov ecx, width32[ebp] ; swidth into ecx + +Dumpline2: + lodsd ; Load eax and increment esi + xchg ah,al ; Swap low byte + rol eax,10h ; Get the high byte into position + xchg ah,al ; Swap again + not eax ; In medley 1=black 0=white, Hence invert. + stosd ; Store eax and increment edi + loop Dumpline2 + + ;; calc vals for src and dest for the next line. + add edi, dstincr[ebp] + add esi, srcincr[ebp] + dec DWORD PTR tmpheight[ebp] + jg Newline2 + + inc DWORD PTR bank[ebp] + + cmp DWORD PTR height[ebp], 0 + jg Newbank2 + +allbye: + pop edi + pop esi + pop edx + pop ecx + pop ebx + RET2C 0 +Dosbbt2 ENDP + +;; ************************************************** +;; ************************************************** +;; D o s b b t 3 +;; arg1: dsp (pointer to a dsp struct) +;; arg2: buffer (pointer to array of word) +;; arg3: left (dword) (in pixels) +;; arg4: top (dword) (in pixels) +;; arg5: swidth (dword) (in pixels) +;; arg6: height (dword) (in pixels) +;; +;; Bitblits the image stored in buffer to the display +;; buffer. ASSUMPTION: buffer and the displaybuffer +;; are equaly large and thus left, top etc. pertains +;; to the same offsets. +;; +;; Medley has a packed bitmap structure. Dosbbt3 assumes +;; that we are operating in 4-plane mode. The medley +;; bitmap is blitted to the first plane of the display. +;; Thus the bitmap appears black and white. +;; +;; +;; C-CALL: void Dosbbt3( ... ); +;; RETURN: 0 in eax. should be ignored... +;; ************************************************** +dsp = 8 +buffer = 12 +left = 16 +top = 20 +swidth = 24 +height = 28 + +srcend = -8 + +PUBLIC Dosbbt3 +Dosbbt3 PROC NEAR + ;;; ***************************** + ;;; Save the volatile environment + ;;; ***************************** + enter 32,0 + push ebx + push ecx + push edx + push esi + push edi + + ;;; Set up the dsp in edx + mov edx, dsp[ebp] + + ;;; Adjust left to be a byte offset at a dword boundry + ;;; - Not needed. We shovle bytes at byte boundrys + + ;;; Adjust width to be a byte offset at a dword boundry + ;;; - Not needed. We shovle bytes at byte boundrys + + ;;; Calculate start index for src + mov eax, top[ebp] + imul eax, [edx.BytesPerLine] + add eax, left[ebp] + mov esi, eax + + ;;; Calculate start index for dst. + mov edi, eax + + ;;; Calculate end address for src + mov eax, top[ebp] + add eax, height[ebp] + imul eax, [edx.BytesPerLine] + add eax, buffer[ebp] + mov srcend[ebp], eax + + ;;; Calculate the dstincr, ie. what to add to dst to + ;;; get to the next line + mov eax, [edx.BytesPerLine] + sub eax, swidth[ebp] + mov dstincr[ebp], eax + + ;;; Calculate the srcincr, ie. what to add to src to + ;;; get to the next line + mov srcincr[ebp], eax + + ;;; Calculate the start address for the src + ;; We already know the byte index. Easy calculat'n + add esi, buffer[ebp] ;esi now points to src + +Newbank3: + ;; Set the bank + mov eax, esi ; 1. Calculate the index. + sub eax, buffer[ebp] + sar eax, 10h ; 2. Divide by "bytes-per-buffer" + ; WARNING! this implies buffersize. + mov dx, 3cdh + out dx, ax ; 3. Set the port. + mov edx, dsp[ebp] ; Reinstate edx + + ;; Adjust dst to be within the bank. + and edi, [edx.DisplaySegSize] + or edi, [edx.DisplayStartAddr] + +Newline3: + mov ecx, swidth[ebp] ; width into ecx + rep movsb ; Dump a line to the display + + ;; calc vals for src and dest for the next line. + add edi, dstincr[ebp] + add esi, srcincr[ebp] + + ;; End of block? + cmp esi, srcend[ebp] + jge QuitThis ; Yes, scram. + + ;; End of bank ? + cmp ax, 0 + jge Newline3 ; No. Blitt a new line. + mov edi, esi ; Yes. Reload edi, + jmp Newbank3 ; and blitt a new line. + +QuitThis: + pop edi + pop esi + pop edx + pop ecx + pop ebx + RET2C 0 +Dosbbt3 ENDP + +CODE ENDS +END diff --git a/src/vesainit.c b/src/vesainit.c new file mode 100755 index 0000000..d9b1aa6 --- /dev/null +++ b/src/vesainit.c @@ -0,0 +1,503 @@ +/* $Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ Copyright (C) Venue"; + + +/************************************************************************/ +/* */ +/* (C) Copyright 1992, 1993, 1994, 1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + +/************************************************************************/ +/* */ +/* V E S A I N I T . C */ +/* */ +/* Using VESA calls, initialize the (S)VGA for Medley's use. */ +/* */ +/************************************************************************/ + +#include /* #pragma interrupt & _get_stk_frame */ +#include +#include /* _XSTACK struct definition */ +#include +#include +#include +#include + +#include "dbprint.h" +#include "lispemul.h" +#include "devif.h" + +#define VESA 0x4f +#define SUCESS 0x00 + /* VESA functions */ +#define _DESCRIBEMODE 0x1 +#define _SETMODE 0x2 +#define _GETCURRENTMODE 0x3 + + /* VESA modevector indexes */ +#define _DISPLAYWIDTH 0x12 +#define _DISPLAYHEIGHT 0x14 +#define _COLORPLANES 0x18 +#define _BITSPERPIXEL 0x19 + +#define VESA_MODE_SUPPORTED_P(vector) ((((short *)vector)[0] & 1)? TRUE : FALSE) +#define VESA_OPT_INFO_P(vector) ((((short *)vector)[0] & 2)? TRUE : FALSE) +#define VESA_COLOR_MODE_P(vector) ((((short *)vector)[0] & 4)? TRUE : FALSE) +#define VESA_GRAPHICS_MODE_P(vector) ((((short *)vector)[0] & 8)? TRUE : FALSE) +#define VESA_SWITCH_BANK(vector) ((PFV)(((long *)vector)[3])) +#define VESA_DSP_SEGSIZE(vector) ((long)( 0xffff & ((short *)vector)[3])) +#define VESA_DSP_STARTSEG_A(vector) ((long)( 0xffff & ((short *)vector)[4])) +#define VESA_DSP_WIDTH(vector) ((long)(((short *)vector)[9])) +#define VESA_DSP_HEIGHT(vector) ((long)(((short *)vector)[10])) +#define VESA_DSP_COLORS(vector) ((long)( 1 << (((char *)vector)[0x19]))) +#define VESA_DSP_BPP(vector) ((long)(((char *)vector)[0x19])) +#define VESA_DSP_NUM_OF_BANKS(vector) ((long)(((char *)vector)[0x1a])) +#define VESA_DSP_BANK_SIZE(vector) ((long)(((char *)vector)[0x1c])) + + +#define MAKE_SEG(low_flat) ((FP_OFF(low_flat) & 0xfffffff0) >> 4) +#define MAKE_OFF(low_flat) (FP_OFF(low_flat & 0x0000000f)) + +#pragma interrupt(VESA_Intrpt_Hndlr) /* int 0x10 intercept */ + +extern DLword *DisplayRegion68k; +extern DLword *DisplayRegion68k_end_addr; +extern DspInterface currentdsp; +extern void docopy(); + +extern PFUL GenericReturnT(); +extern void GenericPanic(); +extern unsigned long VGA_not_color(); +extern void VGA_exit(); +extern unsigned long Dosbbt1(); +extern unsigned long Dosbbt2(); +extern unsigned long Dosbbt3(); +extern void Dosclearbanks(); +extern long DOSCursorVissible(); +extern long dos_cursor_invissible(); +extern int dostaking_mouse_down(); +extern int dostaking_mouse_up(); + +void VESA_Intrpt_Hndlr(void); +void *VESA_prev_hndlr; /* addr of previous 0x10 intercept */ + +extern int dosdisplaymode; + +/**************************************************************/ +/* V E S A _ c a l l */ +/* General utility function for doing a BIOS call to the VESA */ +/* bios. */ +/**************************************************************/ +VESA_call(class, subfunc) + int class, subfunc; +{ + union REGS inregs, outregs; + + inregs.h.ah = VESA; + inregs.h.al = class; + inregs.x.bx = subfunc; + int86( 0x10, &inregs, &outregs ); + return( (outregs.h.al == VESA) && (outregs.h.ah == SUCESS)); +} + +unsigned long set_DAC_color(args) + LispPTR args[]; +{ + union REGS inregs, outregs; + + inregs.x.ax = 0x1010; + inregs.x.bx = (unsigned char) (args[0] & 0xff); + inregs.h.dh = (unsigned char) (args[1] & 0xff); + inregs.h.ch = (unsigned char) (args[2] & 0xff); + inregs.h.cl = (unsigned char) (args[3] & 0xff); + int86( 0x10, &inregs, &outregs ); +} + + +/**************************************************************/ +/* V E S A _ c u r r e n t m o d e */ +/* Returns the current VESA mode for the display. */ +/* Modes defined to date are: */ +/* 0x100 640x400 & 256 colors (Not tested yet) */ +/* 0x101 640x480 & 256 colors */ + +/* 0x102 800x600 & 16 colors */ +/* 0x103 800x600 & 256 colors (Not tested yet) */ + +/* 0x104 1024x768 & 16 colors */ +/* 0x105 1024x768 & 256 colors (Not tested yet) */ + +/* 0x106 1280x1024 & 16 colors (Not tested yet) */ +/* 0x107 1280x1024 & 256 colors (Not tested yet) */ +/* */ +/**************************************************************/ +int VESA_currentmode() +{ + union REGS inregs, outregs; + + inregs.h.ah = VESA; + inregs.h.al = _GETCURRENTMODE; + inregs.x.bx = 0; + int86( 0x10, &inregs, &outregs ); + if ( (outregs.h.al == VESA) && (outregs.h.ah == SUCESS)) { + return (outregs.x.bx); + } else { + return ( FALSE ); + } +} + +int VESA_setmode( mode, clearscreen) + int mode, clearscreen; +{ + union REGS inregs, outregs; + + inregs.h.ah = VESA; + inregs.h.al = _SETMODE | ((clearscreen) ? 0x8000 : 0); + inregs.x.bx = mode; + int86( 0x10, &inregs, &outregs ); + return ( (outregs.h.al == VESA) && (outregs.h.ah == SUCESS) ); +} + +#define VESABUFLEN 256 +char VESAmodevector[VESABUFLEN]; +char *VESAmodebytes = VESAmodevector; + +/* VESA_describemode */ +int VESA_describemode( mode ) + int mode; +{ + union REGS inregs, outregs; + int i; + unsigned buf; + + TPRINT(("Enter VESA_describemode\n")); + VESA_prev_hndlr = _dos_getvect(0x10); /* get current 10 intercept, if any */ + _dos_setvect(0x10, VESA_Intrpt_Hndlr); /* install our int 10 intercept */ + + if ( _dos_allocmem( VESABUFLEN, &buf ) != 0 ) return( -1 ); + + inregs.w.eax = 0x4f01; + inregs.w.ebx = buf; + inregs.w.ecx = mode; + int86( 0x10, &inregs, &outregs ); + + if (outregs.x.ax == VESA) { + for (i = 0; i < VESABUFLEN; i++) { + VESAmodebytes[i] = ((char *)buf)[i]; + } + } else { + return ( -1 ); + } + + _dos_freemem( buf ); /* release the buffer */ + _dos_setvect(0x10, VESA_prev_hndlr); /* re-install previous 10 intercept */ + TPRINT(("Exit VESA_describemode\n")); + return( 0 ); +} + +void VESA_Intrpt_Hndlr(void) +{ + int inbuffer, func; + _XSTACK *stk_ptr; + + /* get ptr to _XSTACK - regs, etc */ + stk_ptr = (_XSTACK *)_get_stk_frame(); + + func = (unsigned short)stk_ptr->eax; /* get function */ + + if (((stk_ptr->flg & _FLAG_VM) == 0) /* process only if NOT virtual mode*/ + && (func == 0x4f01)) { /* AND only if func 4f */ + inbuffer = stk_ptr->ebx; /* get ebx as passed (flat addr) */ + stk_ptr->edi = MAKE_OFF(inbuffer); /* convert to seg:off form */ + stk_ptr->es = MAKE_SEG(inbuffer); /* service requires it in es:di */ + + ((PFV)VESA_prev_hndlr)(); /* call VESA getmode */ + } else { + _chain_intr(VESA_prev_hndlr); /* always best to chain to prev int*/ + } +} + +void VESA_beforeraid( dsp ) + DspInterface dsp; +{ + TPRINT(("Enter VESA_beforeraid\n")); + _setvideomode( _DEFAULTMODE ); + _clearscreen( _GCLEARSCREEN ); + TPRINT(("Exit VESA_beforeraid\n")); +} + +void VESA_afterraid( dsp ) + DspInterface dsp; +{ + TPRINT(("Enter VESA_afterraid\n")); + VESA_setmode( dsp->graphicsmode , TRUE); + TPRINT(("Exit VESA_afterraid\n")); +} + +void VESA_enter( dsp ) + DspInterface dsp; +{ + union REGS regs; + + TPRINT(("Enter VESA_enter\n")); + VESA_setmode( dsp->graphicsmode , TRUE); + if (!((VESA_describemode( dsp->graphicsmode ) == 0))){ + _setvideomode( _DEFAULTMODE ); + _clearscreen( _GCLEARSCREEN ); + fprintf( stderr, "Can't set VESA mode %o.\n", dsp->graphicsmode ); + exit(0); + } + /* Get the segaddr. An addr. is a seg shifted 4 bits! */ + dsp->DisplayStartAddr = VESA_DSP_STARTSEG_A(VESAmodebytes) << 4; + /* Get the size. */ + dsp->DisplaySegSize = (VESA_DSP_SEGSIZE(VESAmodebytes) << 10); + + /* How many bits in the segment addr. */ + switch(VESA_DSP_SEGSIZE(VESAmodebytes)){ + case 64: + dsp->DisplaySegMagnitude = 0x10; + break; + case 128: + dsp->DisplaySegMagnitude = 0x11; + break; + case 256: + dsp->DisplaySegMagnitude = 0x12; + break; + } + + dsp->SwitchBank = NULL; + + if(VESA_OPT_INFO_P(VESAmodebytes)){ + dsp->Display.width = VESA_DSP_WIDTH(VESAmodebytes); + dsp->Display.height = VESA_DSP_HEIGHT(VESAmodebytes); + } + else { /* Drat! No optional info. Hardcode. */ + switch(dsp->graphicsmode){ + case 0x100: + dsp->Display.width = 640; + dsp->Display.height = 400; + break; + case 0x101: + dsp->Display.width = 640; + dsp->Display.height = 480; + break; + case 0x102: + case 0x103: + dsp->Display.width = 800; + dsp->Display.height = 600; + break; + case 0x104: + case 0x105: + dsp->Display.width = 1024; + dsp->Display.height = 768; + break; + case 0x106: + case 0x107: + dsp->Display.width = 1280; + dsp->Display.height = 1024; + break; + } + } + dsp->colors = VESA_DSP_COLORS(VESAmodebytes); + dsp->bitsperpixel = VESA_DSP_BPP(VESAmodebytes); + dsp->numberofbanks = VESA_DSP_NUM_OF_BANKS(VESAmodebytes); + + /* Assumption: 8 bits per pixel */ + dsp->LinesPerBank = 8 * (dsp->DisplaySegSize / dsp->Display.width); + + _dpmi_lockregion(¤tdsp, sizeof(currentdsp)); + _dpmi_lockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); + _dpmi_lockregion(DisplayRegion68k, 1600*1208/8); + + /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ + _dpmi_lockregion(dsp, sizeof(*dsp)); + _dpmi_lockregion(dsp->bitblt_to_screen, 0x2000); + _dpmi_lockregion(dsp->mouse_invissible, 0x2000); + _dpmi_lockregion(dsp->mouse_vissible, 0x2000); + _dpmi_lockregion((void *)&docopy, 0x2000); + + TPRINT(("Exit VESA_enter\n")); +} + +void VESA_exit( dsp ) + DspInterface dsp; +{ + TPRINT(("Enter VESA_exit\n")); + /* Unlock the following to avoid waste of mainmem. */ + _dpmi_unlockregion(¤tdsp, sizeof(currentdsp)); + _dpmi_unlockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); + _dpmi_unlockregion(DisplayRegion68k, 1600*1208/8); + + _dpmi_unlockregion(dsp->bitblt_to_screen, 0x2000); + _dpmi_unlockregion(dsp->mouse_invissible, 0x2000); + _dpmi_unlockregion(dsp->mouse_vissible, 0x2000); + _dpmi_unlockregion((void *)&docopy, 0x2000); + _dpmi_unlockregion(dsp, sizeof(*dsp)); + + _setvideomode( _DEFAULTMODE ); + _clearscreen( _GCLEARSCREEN ); + TPRINT(("Exit VESA_exit\n")); +} + +VESA_errorexit( s, errno ) + char *s; + int errno; +{ + _setvideomode( _DEFAULTMODE ); + _clearscreen( _GCLEARSCREEN ); + fprintf( stderr, s ); + fflush(stderr); + exit(errno); +} + +void tmpclearbanks(dsp) + DspInterface dsp; +{ + TPRINT(("Enter tmpclearbanks\n")); +/* Dosclearbanks(dsp); */ + TPRINT(("Exit tmpclearbanks\n")); +} + +unsigned long tmpbbt(dsp, buffer, left, top, swidth, height) + DspInterface dsp; + char *buffer; + long left, top, swidth, height; +{ + TPRINT(("Enter tmpbbt\n")); + TPRINT(("Mode display is: %d\n", dsp->graphicsmode)); + TPRINT(("dsp->Display.width = %d\n", dsp->Display.width)); + TPRINT(("dsp->Display.height = %d\n", dsp->Display.height)); + TPRINT(("left = %d, top = %d, swidth = %d, height = %d\n", left, top, swidth, height)); + (Dosbbt3)(dsp, buffer, left, top, swidth, height); + TPRINT(("Exit tmpbbt\n")); +} + +VESA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) + DspInterface dsp; + char *lispbitmap; + int width_hint, height_hint, depth_hint; +{ + TPRINT(("Enter VESA_init\n")); + /* Kludge. going away soon. */ + dsp->graphicsmode = dosdisplaymode; + + /* A graphics mode is requested. Test its validity */ + if ( dsp->graphicsmode == 0 ) { + /* No mode requested. Find a suitable mode from hints. */ + switch ( depth_hint ) { + case 0: + case 1: + if ((VESA_describemode( 0x104 ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector ))) + dsp->graphicsmode = 0x104; + else if ((VESA_describemode( 0x102 ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector ))) + dsp->graphicsmode = 0x102; + else VESA_errorexit("Displaymode not supported", -1); + break; + case 8: + if ((VESA_describemode( 0x105 ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ + dsp->graphicsmode = 0x105; + } + else if ((VESA_describemode( 0x103 ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ + dsp->graphicsmode = 0x103; + } + else if ((VESA_describemode( 0x101 ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ + dsp->graphicsmode = 0x101; + } + else if ((VESA_describemode( 0x100 ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ + dsp->graphicsmode = 0x100; + } + else VESA_errorexit("Displaymode not supported", -1); + break; + default: + VESA_errorexit("Requested display depth not supported", -1); + } + } + else if (!((VESA_describemode( dsp->graphicsmode ) == 0) && + (VESA_MODE_SUPPORTED_P( VESAmodevector )))){ + VESA_errorexit("Can't find suitable VESA mode.\n", -1); + } + + switch ( dsp->graphicsmode ) { + case 0x100: + case 0x101: + dsp->BytesPerLine = 640; + dsp->bitblt_to_screen = &tmpbbt; + break; + case 0x102: + dsp->BytesPerLine = 100; + dsp->bitblt_to_screen = &Dosbbt1; + break; + case 0x103: + dsp->BytesPerLine = 800; + dsp->bitblt_to_screen = &tmpbbt; + break; + case 0x104: + dsp->BytesPerLine = 128; + dsp->bitblt_to_screen = &Dosbbt2; + break; + case 0x105: + dsp->BytesPerLine = 1024; + dsp->bitblt_to_screen = &tmpbbt; + break; + case 0x106: + dsp->BytesPerLine = 160; + dsp->bitblt_to_screen = &Dosbbt2; + break; + case 0x107: + dsp->BytesPerLine = 1280; + dsp->bitblt_to_screen = &tmpbbt; + break; + default: + VESA_errorexit("Displaymode not supported", -1); + } + + TPRINT(("Mode display is: %d\n", dsp->graphicsmode)); + + dsp->device.locked = FALSE; + dsp->device.active = FALSE; + + dsp->device.enter = &VESA_enter; + dsp->device.exit = &VESA_exit; + + dsp->device.before_raid = &VESA_beforeraid; + dsp->device.after_raid = &VESA_afterraid; + + dsp->drawline = &GenericPanic; + + dsp->cleardisplay = &tmpclearbanks; + + dsp->get_color_map_entry = &VGA_not_color; + dsp->set_color_map_entry = &set_DAC_color; + dsp->available_colors = &VGA_not_color; + dsp->possible_colors = &VGA_not_color; + + dsp->medley_to_native_bm = (PFUL)&GenericPanic; + dsp->native_to_medley_bm = (PFUL)&GenericPanic; + + dsp->bitblt_from_screen = (PFUL)&GenericPanic; + dsp->scroll_region = (PFUL)&GenericPanic; + + dsp->mouse_invissible = (PFV)&dostaking_mouse_down; + dsp->mouse_vissible = (PFV)&dostaking_mouse_up; + + TPRINT(("Exit VESA_init\n")); + +} diff --git a/src/vgainit.c b/src/vgainit.c new file mode 100755 index 0000000..caf863a --- /dev/null +++ b/src/vgainit.c @@ -0,0 +1,183 @@ +/* $Id: vgainit.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: vgainit.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + +#include +#include +#include "lispemul.h" +#include "devif.h" + +extern unsigned long Dosbbt1(); +extern unsigned long Dosbbt2(); +extern int dostaking_mouse_down(); +extern int dostaking_mouse_up(); + +extern DLword *DisplayRegion68k; +extern DLword *DisplayRegion68k_end_addr; +extern DspInterface currentdsp; +extern void docopy(); + +extern void GenericPanic(); + +void VGA_setmax( dsp ) + DspInterface dsp; +{ + struct videoconfig vc; + + if( !_setvideomode( _MAXRESMODE ) ) { + fprintf ( stderr, "Can't set graphics mode.\n" ); + exit( 1 ); + } + _getvideoconfig( &vc ); + dsp->Display.width = vc.numxpixels; + dsp->Display.height = vc.numypixels; + dsp->bitsperpixel = vc.bitsperpixel; + dsp->colors = vc.numcolors; + + /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ + _dpmi_lockregion(¤tdsp, sizeof(currentdsp)); + _dpmi_lockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); + _dpmi_lockregion(DisplayRegion68k, 1600*1208/8); + + /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ + _dpmi_lockregion(dsp, sizeof(*dsp)); + _dpmi_lockregion(dsp->bitblt_to_screen, 0x2000); + _dpmi_lockregion(dsp->mouse_invissible, 0x2000); + _dpmi_lockregion(dsp->mouse_vissible, 0x2000); + _dpmi_lockregion((void *)&docopy, 0x2000); +} + +void VGA_exit( dsp ) + DspInterface dsp; +{ + /* Unlock the following to avoid waste of mainmem. */ + _dpmi_unlockregion(¤tdsp, sizeof(currentdsp)); + _dpmi_unlockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); + _dpmi_unlockregion(DisplayRegion68k, 1600*1208/8); + + /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ + _dpmi_unlockregion(dsp, sizeof(*dsp)); + _dpmi_unlockregion(dsp->bitblt_to_screen, 0x2000); + _dpmi_unlockregion(dsp->mouse_invissible, 0x2000); + _dpmi_unlockregion(dsp->mouse_vissible, 0x2000); + _dpmi_unlockregion((void *)&docopy, 0x2000); + + _setvideomode( _DEFAULTMODE ); + _clearscreen( _GCLEARSCREEN ); +} + +unsigned long VGA_not_color( dsp ) + DspInterface dsp; +{ + printf( "Colormode not set!\n"); + fflush(stdout); + return(0); +} + +unsigned long VGA_colornum( dsp ) + DspInterface dsp; +{ /* Return the number of available colors */ + return(1 << dsp->bitsperpixel); +} + +unsigned long VGA_possiblecolors( dsp ) + DspInterface dsp; +{ + return(dsp->colors); +} + +void VGA_mono_drawline( dsp, startX, startY, width, height, function, color, + thickness, butt, clipX, clipY, clipWidth, clipHeight, dashing) + DspInterface dsp; + unsigned long startX, startY, width, height; + int function; + unsigned long color, thickness; + int butt; + unsigned long clipX, clipY, clipWidth, clipHeight; + LispPTR *dashing; + +{ + _moveto_w( startX, startY ); + _lineto_w( width, height ); +} + +void VGA_color_drawline ( dsp, startX, startY, width, height, function, color, + thickness, butt, clipX, clipY, clipWidth, clipHeight, dashing) + DspInterface dsp; + unsigned long startX, startY, width, height; + int function; + unsigned long color, thickness; + int butt; + unsigned long clipX, clipY, clipWidth, clipHeight; + LispPTR *dashing; + +{ + +} + +void VGA_cleardisplay ( dsp ) + DspInterface dsp; +{ + _clearscreen(_GCLEARSCREEN); +} + +VGA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) + DspInterface dsp; + char *lispbitmap; + int width_hint, height_hint, depth_hint; +{ + struct videoconfig vc; + + dsp->device.enter = (PFV)&VGA_setmax; + dsp->device.exit = (PFV)&VGA_exit; + + dsp->device.before_raid = (PFV)&VGA_exit; + dsp->device.after_raid = (PFV)&VGA_setmax; + + dsp->drawline = (PFV)&VGA_mono_drawline; + + dsp->cleardisplay = (PFV)&VGA_cleardisplay; + + dsp->get_color_map_entry = (PFUL)&VGA_not_color; + dsp->set_color_map_entry = (PFUL)&VGA_not_color; + dsp->available_colors = (PFUL)&VGA_not_color; + dsp->possible_colors = (PFUL)&VGA_not_color; + + dsp->medley_to_native_bm = (PFUL)&GenericPanic; + dsp->native_to_medley_bm = (PFUL)&GenericPanic; + + dsp->bitblt_to_screen = (PFUL)&Dosbbt1; + dsp->bitblt_from_screen = (PFUL)&GenericPanic; + dsp->scroll_region = (PFUL)&GenericPanic; + + dsp->DisplayStartAddr = 0xa0000; + dsp->DisplaySegSize = 0x10000; /* 64K segments */ + dsp->DisplaySegMagnitude = 0x10; /* How many bits in the addr. */ + dsp->BytesPerLine = 80; + dsp->LinesPerBank = 512; + + dsp->mouse_invissible = (PFV)&dostaking_mouse_down; + dsp->mouse_vissible = (PFV)&dostaking_mouse_up; + + dsp->device.locked = FALSE; + dsp->device.active = FALSE; +} diff --git a/src/vmemsave.c b/src/vmemsave.c new file mode 100755 index 0000000..08c0b26 --- /dev/null +++ b/src/vmemsave.c @@ -0,0 +1,667 @@ +/* $Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + +/* +* vmemsave.c +* +* +*/ + +#include +#include +#ifndef DOS +#include +#endif /* DOS */ +#include +#ifndef DOS +#include +#ifndef AIX +#include +#endif /* AIX */ + +#include +#endif /* DOS */ +#include +#include +#include + +#ifdef SYSVONLY +#include +#include +#include +#include +#elif DOS +#include +#include +#include +#define MAXPATHLEN _MAX_PATH +#define MAXNAMLEN _MAX_PATH +#define alarm(x) 1 +#else +#include +#endif /* SYSVONLY, DOS */ + +#ifndef NOPIXRECT +#include +#endif /* NOPIXRECT */ + +#include "hdw_conf.h" +#include "lispemul.h" +#include "lispmap.h" +#include "lspglob.h" +#include "ifpage.h" +#include "vmemsave.h" +#include "timeout.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "locfile.h" +#include "dbprint.h" +#include "devif.h" + +#ifdef GCC386 +#include "inlnPS2.h" +#endif + +/* Error return values from VMEMSAVE */ +#define COMPLETESYSOUT NIL +#define BADFILENAME S_POSITIVE | 1 +#define NOFILESPACE S_POSITIVE | 2 +#define FILECANNOTOPEN S_POSITIVE | 3 +#define FILECANNOTSEEK S_POSITIVE | 4 +#define FILECANNOTWRITE S_POSITIVE | 5 +#define FILETIMEOUT S_POSITIVE | 6 + +struct stat DEBUG_stat; + +extern int LispWindowFd; +extern struct pixrect *CursorBitMap, *InvisibleCursorBitMap; +extern struct cursor CurrentCursor, InvisibleCursor; +extern IFPAGE *InterfacePage; +#ifdef DOS +extern IOPAGE *IOPage68K; +extern DspInterface currentdsp; +#endif /* DOS */ + +#undef roundup +#define roundup( a, b) ((((unsigned)(a)+(b)-1)/(b))*(b)) + +extern int *Lisp_errno; +extern int Dummy_errno; /* Used if errno cell isn't provided by Lisp.*/ +extern int please_fork; + + +/************************************************************************/ +/* */ +/* l i s p s t r i n g p */ +/* */ +/* Predicate: Is the argument (which must be a Lisp 1-d array) */ +/* a lisp string? i.e., are its elements char's? */ +/* */ +/************************************************************************/ + +lispstringP(Lisp) + LispPTR Lisp; + { + switch( ((OneDArray *)(Addr68k_from_LADDR(Lisp)))->typenumber ) + { + case THIN_CHAR_TYPENUMBER: + case FAT_CHAR_TYPENUMBER: return(1); + + default: return(0); + } + } + + + +/************************************************************************/ +/* */ +/* v m e m _ s a v e 0 */ +/* */ +/* Implements the VMEMSAVE subr. Write out the current lisp */ +/* lisp image to the specified file. If the sysout file-name */ +/* is explicitly specified, the directory on which the file */ +/* resides is exactly (?) an existing directory. This is */ +/* guaranteed by the Lisp code, \MAIKO.CHECKFREEPAGE in LLFAULT. */ +/* */ +/* If the file argument is nill, the default sysout-file name, */ +/* "~/lisp.virtualmem", is used, subject to override by the */ +/* LDEDESTSYSOUT UNIX-environment variable. */ +/* */ +/* */ +/* */ +/* */ +/* Argument: LispPTR *args args[0] */ +/* The file name in Lisp format specifying a */ +/* file to which the current Lisp image should */ +/* be flushed or Lisp NIL. */ +/* */ +/* Value: If succeed, returns NIL, otherwise one of the */ +/* following Lisp integers, indicating the reason. */ +/* */ +/* 1 BADFILENAME */ +/* 2 NOFILESPACE */ +/* 3 FILECANNOTOPEN */ +/* 4 FILECANNOTSEEK */ +/* 5 FILECANNOTWRITE */ +/* 6 FILETIMEOUT */ +/* */ +/* Side Effect: None. */ +/* */ +/************************************************************************/ + +vmem_save0(args) + register LispPTR *args; + { + register char *def; + char pathname[MAXPATHLEN], sysout[MAXPATHLEN], host[MAXNAMLEN]; +#ifdef DOS + char pwd[MAXNAMLEN]; + char drive[1]; +#else + struct passwd *pwd; +#endif /* DOS */ + char *getenv(); + + Lisp_errno = &Dummy_errno; + +#ifdef DEMO + return FILECANNOTOPEN; +#else + + if((args[0] != NIL) && lispstringP(args[0])) + { + /* Check of lispstringP is safer for LispStringToCString */ + LispStringToCString(args[0], pathname, MAXPATHLEN); + separate_host(pathname, host); +#ifdef DOS + if (!unixpathname(pathname, sysout, 0, 0, drive, 0, 0)) return(BADFILENAME); +#else + if (!unixpathname(pathname, sysout, 0, 0)) return(BADFILENAME); +#endif /* DOS */ + return(vmem_save(sysout)); + } + else + { + if((def = getenv("LDEDESTSYSOUT")) == 0) + { +#ifdef DOS + if(getcwd(pwd,MAXNAMLEN) == NULL) return(FILETIMEOUT); + strcpy(sysout,pwd); + strcat(sysout, "/lisp.vm"); +#else + pwd = getpwuid(getuid()); /* NEED TIMEOUT */ + if (pwd == (struct passwd *)NULL) return(FILETIMEOUT); + strcpy(sysout, pwd->pw_dir); + strcat(sysout, "/lisp.virtualmem"); +#endif /* DOS */ + } + else + { + if (*def == '~' && + (*(def + 1) == '/' || *(def + 1) == '\0')) + { +#ifdef DOS + if(getcwd(pwd,MAXNAMLEN) == NULL) return(FILETIMEOUT); + strcpy(sysout,pwd); +#else + pwd = getpwuid(getuid()); /* NEED TIMEOUT */ + if (pwd == (struct passwd *)NULL) return(FILETIMEOUT); + strcpy(sysout, pwd->pw_dir); +#endif /* DOS */ + strcat(sysout, def + 1); + } + else + { + strcpy(sysout, def); + } + } + return(vmem_save(sysout)); + } +#endif /* DEMO */ + } + + + +/************************************************************************/ +/* */ +/* v m e m _ s a v e */ +/* */ +/* */ +/* */ +/************************************************************************/ + +/* + * Argument: char *sysout_file_name + * The file name in UNIX format specifying a file to which + * the current Lisp image should be flushed. + * + * Value: If succeed, returns Lisp NIL, otherwise one of the following Lisp integer + * indicating the reason of failure. + * + * 1 BADFILENAME + * 2 NOFILESPACE + * 3 FILECANNOTOPEN + * 4 FILECANNOTSEEK + * 5 FILECANNOTWRITE + * 6 FILETIMEOUT + * + * Side Effect: None. + * + * Description: + * + * Flush out the current Lisp image to the specified file. + */ + +/* diagnostic flag value to limit the size of write() s */ +int maxpages = 65536; + +vmem_save(sysout_file_name) + register char *sysout_file_name; + { + int sysout; /* SysoutFile descriptor */ +#ifdef BIGVM + register unsigned int *fptovp; +#else + register DLword *fptovp; /* FPTOVP */ +#endif /* BIGVM */ + int vmemsize; /* VMEMSIZE */ + register int i; + char tempname[MAXPATHLEN]; + /* * * struct statfs fsbuf; * * */ + char *cp; + register int rval; + DLword *bmptr; + int tot_pages = 0; +#ifndef DOS + extern int ScreenLocked; + extern DLword *EmCursorX68K; + extern DLword *EmCursorY68K; + extern DLword NullCursor[]; + extern DLword *EmCursorBitMap68K; +#endif /* DOS */ + + /* remove cursor image from screen */ + +#ifdef SUNDISPLAY +#ifdef OLD_CURSOR + win_setcursor( LispWindowFd, &InvisibleCursor); +#else + ScreenLocked=T; + taking_mouse_down(); +/* bmptr = EmCursorBitMap68K; + EmCursorBitMap68K= NullCursor;*/ +#endif /* OLD_CURSOR */ + +#elif DOS + /* For DOS, must also take the mouse cursor away (it's */ + /* written into the display-region bitmap). */ + currentdsp->device.locked++; + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); +#endif /* SUNDISPLAY || DOS */ + + + /* set FPTOVP */ + fptovp = FPtoVP + 1; + + /* set VMEMSIZE */ + vmemsize = InterfacePage->nactivepages; + +/* [HH:6-Jan-89] + Sequnce of save image + (1) Sysout image is saved to a temporary file, tempname. + (2) if a specified file, sysout_file_name, is exist, the file is removed. + (3) the temporary file is renamed to the specified file. +*/ + + SETJMP(FILETIMEOUT); +#ifdef DOS + /* Bloddy 8 char filenames in dos ... /jarl */ + make_old_version(tempname, sysout_file_name); +#else /* DOS */ + sprintf(tempname, "%s-temp", sysout_file_name); +#endif /* DOS */ + + /* Confirm protection of specified file by open/close */ + + TIMEOUT(sysout=open(sysout_file_name, O_WRONLY, 0666)); + if (sysout == -1) + { + /* No file error skip return. */ + if(errno != 2) return(FILECANNOTOPEN); /* No such file error.*/ + } + else TIMEOUT( rval = close(sysout) ); + + /* open temp file */ + TIMEOUT(sysout=open(tempname, O_WRONLY | O_CREAT | O_TRUNC, 0666)); + if (sysout == -1) + { + err_mess("open", errno); + return(FILECANNOTOPEN); + } + + + InterfacePage->machinetype = KATANA; + + +#ifdef NEW_STORAGE + /* Restore storagefull state */ + if(((*STORAGEFULLSTATE_word) & 0xffff)== SFS_NOTSWITCHABLE) + { + /* This sysout uses only 8 Mbyte lisp space. + It may be able to use this SYSOUT which has more than + 8 Mbyte lisp space. + To enable to expand lisp space, \\STORAGEFULLSTATE + should be NIL. + */ + *STORAGEFULLSTATE_word = NIL; + InterfacePage->storagefullstate=NIL; + } + else + { + /* Otherwise, just restore storagefullstate in IFPAGE */ + InterfacePage->storagefullstate = (*STORAGEFULLSTATE_word) & 0xffff ; + } +#endif /* NEW_STORAGE */ + + + + /* First, sort fptovp table, trying to get pages contiguous */ +#ifndef BIGVM +#ifndef BYTESWAP + /* Byte-swapped machines don't sort the table right. */ + sort_fptovp(fptovp, vmemsize); +#endif +#endif + + /* store vmem to sysoutfile */ + + for (i = 0; i < vmemsize; i++) + { + if (GETPAGEOK(fptovp,i) != 0177777) + { + int oldfptovp = GETFPTOVP(fptovp, i); + int contig_pages = 0; +#ifdef BYTESWAP + int pc; +#endif /* BYTESWAP */ + + register char *base_addr; + + TIMEOUT( rval=lseek(sysout, i * BYTESPER_PAGE, 0) ); + if (rval == -1) + { + err_mess("lseek", errno); + return(FILECANNOTSEEK); + } + base_addr = (char *)(Lisp_world + (GETFPTOVP(fptovp,i) * DLWORDSPER_PAGE)); + + /* Now, let's see how many pages we can dump */ + while(GETFPTOVP(fptovp,i) == oldfptovp + && i < vmemsize) { + contig_pages++, oldfptovp++, i++; + } + i--; /* Previous loop always overbumps i */ + DBPRINT(("%4d: writing %d pages from %x\n", + i, contig_pages, base_addr - (char*)Lisp_world)); + +#ifdef BYTESWAP + word_swap_page(base_addr, + contig_pages*BYTESPER_PAGE/4); +#endif /* BYTESWAP */ + + if(contig_pages > maxpages) { + char *ba = base_addr; + int pc = contig_pages; + while (pc > maxpages) { + TIMEOUT(rval = write(sysout, ba, maxpages * BYTESPER_PAGE)); + if (rval == -1) { + err_mess("write", errno); + return(FILECANNOTWRITE); + } + ba += maxpages * BYTESPER_PAGE; + pc -= maxpages; + } + if(pc > 0) + TIMEOUT(rval = write(sysout, ba, pc * BYTESPER_PAGE)); + } else { int oldTT = TIMEOUT_TIME; + /* As we can spend longer than TIMEOUT_TIME doing a big + write, we adjust the timeout temporarily here */ + TIMEOUT_TIME += contig_pages>>3; + TIMEOUT( rval=write(sysout, + base_addr, + contig_pages * BYTESPER_PAGE) ); + TIMEOUT_TIME = oldTT; + } +#ifdef BYTESWAP + word_swap_page(base_addr, + contig_pages*BYTESPER_PAGE/4); +#endif /* BYTESWAP */ + + if (rval == -1) + { + err_mess("write", errno); + return(FILECANNOTWRITE); + } + } + } + + + + /* seek to IFPAGE */ + TIMEOUT(rval=lseek(sysout, (long)FP_IFPAGE, 0)); + if (rval == -1) + { + err_mess("lseek", errno); + return(FILECANNOTSEEK); + } +#ifdef BYTESWAP + word_swap_page((char *) InterfacePage, + BYTESPER_PAGE/4); +#endif /* BYTESWAP */ + + TIMEOUT(rval=write(sysout, (char *) InterfacePage, BYTESPER_PAGE) ); +#ifdef BYTESWAP + word_swap_page((char *) InterfacePage, + BYTESPER_PAGE/4); +#endif /* BYTESWAP */ + + if (rval == -1) + { + err_mess("write", errno); + return(FILECANNOTWRITE); + } + +#ifdef OS5 + /* Seems to write all pages at close, so timeout + is WAY to short, no matter how big. JDS 960925 */ + rval = close(sysout); +#else + TIMEOUT( rval = close(sysout) ); +#endif /* OS5 */ + if(rval == -1) + { + return(FILECANNOTWRITE); + } + + TIMEOUT(rval = unlink(sysout_file_name)); + if (rval == -1) + { + /* No file error skip return. */ + if(errno != 2) /* No such file error.*/ return(FILECANNOTOPEN); + } + + TIMEOUT( rval=rename(tempname, sysout_file_name) ); + if( rval== -1) + { + fprintf(stderr,"sysout is saved to temp file, %s.", tempname); + return(FILECANNOTWRITE); + } + + /* restore cursor image to screen */ +#ifdef SUNDISPLAY +#ifdef OLD_CURSOR + win_setcursor( LispWindowFd, &CurrentCursor); +#else + ScreenLocked=T; + /*EmCursorBitMap68K = bmptr ;*/ + taking_mouse_up(*EmCursorX68K,*EmCursorY68K); + ScreenLocked=NIL; +#endif /* OLD_CURSOR */ + +#elif DOS + /* Must also put the mouse back. */ + (currentdsp->mouse_vissible)( IOPage68K->dlmousex, IOPage68K->dlmousey ); + currentdsp->device.locked--; + +#endif /* SUNDISPLAY */ + + + /*printf("vmem is saved completely.\n");*/ + return(COMPLETESYSOUT); + } + + + + +/************************************************************************/ +/* */ +/* l i s p _ f i n i s h */ +/* */ +/* Kill all forked sub-processes before exiting. */ +/* */ +/************************************************************************/ + +extern int UnixPID; + +/* Make sure that we kill off any Unix subprocesses before we go away */ + +lisp_finish() + { + char d[4]; + + DBPRINT(("finish lisp_finish\n")); + + if( please_fork ) + { /* if lde runs with -NF(No fork), */ + /* following 5 lines don't work well. */ + d[0] = 'E'; + d[3] = 1; + /* These only happen if the fork really succeeded: + /* if (UnixPipeOut >= 0) write(UnixPipeOut, d, 4); */ + /* if (UnixPipeIn >= 0 read(UnixPipeIn, d, 4);*/ /* Make sure it's finished */ + /* if (UnixPID >= 0) kill(UnixPID, SIGKILL);*/ /* Then kill fork_Unix itself */ + } + device_before_exit(); +#ifdef DOS + exit_host_filesystem(); +#endif /* DOS */ + exit(1); + + } + + + + +/************************************************************************/ +/* */ +/* s o r t _ f p t o v p */ +/* */ +/* Sort the entries in the file-page-to-virtual-page table, */ +/* to try to make a sysout file that has contiguous runs of */ +/* virtual pages in it, for speed. */ +/* */ +/************************************************************************/ + +int twowords(i,j) /* the difference between two DLwords. */ + DLword *i, *j; + { + return(*i - *j); + } + + +#define FPTOVP_ENTRY (FPTOVP_OFFSET >> 8) + +sort_fptovp(fptovp, size) + DLword *fptovp; + int size; + { + int oldloc, newloc, oldsize, i; + DLword *fptr; + + for(fptr = fptovp, i=0; + GETWORD(fptr) != FPTOVP_ENTRY && i < size; + fptr++, i++); + + if(GETWORD(fptr) != FPTOVP_ENTRY) + { + DBPRINT((stderr, "Couldn't find FPTOVP_ENTRY; not munging\n")); + return; + } + oldloc = fptr - fptovp; + + /* Found old fptovp table location, now sort the table */ + qsort(fptovp, size, sizeof(DLword), twowords); + +ONE_MORE_TIME: /* Tacky, but why repeat code? */ + + /* Look up FPTOVP_ENTRY again; if it's moved, need to shuffle stuff */ + for(fptr = fptovp, i=0; + GETWORD(fptr) != FPTOVP_ENTRY && i < size; + fptr++, i++); + + if(GETWORD(fptr) != FPTOVP_ENTRY) error("Couldn't find FPTOVP_ENTRY second time!\n"); + newloc = fptr - fptovp; + + /* Supposedly all we have to do is adjust the fptovpstart and nactivepages + the ifpage */ + InterfacePage->fptovpstart += (newloc - oldloc); + oldsize = size; + for(fptr = fptovp + (size-1); GETWORD(fptr) == 0xffff; + fptr--, InterfacePage->nactivepages--, size--); + + if(size != oldsize) + DBPRINT(("Found %d holes in fptovp table\n", oldsize - size)); + + /* Sanity check; it's just possible there are duplicate entries... */ + { + int dupcount = 0; + for(fptr = fptovp, i=1; + i + +#include +#include + +#include "lispemul.h" +#include "xdefs.h" +#include "devif.h" + +extern DspInterface currentdsp; + + + +/************************************************************************/ +/* */ +/* c l i p p i n g _ X b i t b l t */ +/* */ +/* BITBLT from the display region to the X server's display, */ +/* clipping to fit the window we're in on the server. */ +/* */ +/* dummy is the placeholder for the bitmap to be blitted */ +/* */ +/************************************************************************/ +unsigned long +clipping_Xbitblt(dsp, dummy, x, y, w, h) + DspInterface dsp; + int dummy, x, y, w, h; +{ + int temp_x, temp_y, LowerRightX, LowerRightY; + + LowerRightX = dsp->Vissible.x + dsp->Vissible.width; + LowerRightY = dsp->Vissible.y + dsp->Vissible.height; + + temp_x = x + w - 1; + temp_y = y + h - 1; + + if ( (temp_x < dsp->Vissible.x) + || (x > LowerRightX) + || (temp_y < dsp->Vissible.y) + || (y > LowerRightY)) return(0); + + if ( ( x >= dsp->Vissible.x ) + && ( temp_x <= LowerRightX ) + && ( y >= dsp->Vissible.y ) + && ( temp_y <= LowerRightY ) ) + { + XLOCK; + XPutImage( dsp->display_id, + dsp->DisplayWindow, + dsp->Copy_GC, + &dsp->ScreenBitmap, + x , y, x - dsp->Vissible.x, + y - dsp->Vissible.y, w, h ); + XFlush(dsp->display_id); + XUNLOCK; + return(0); + } + + if ( x < dsp->Vissible.x ) + { + w -= dsp->Vissible.x - x; + x = dsp->Vissible.x; + } + + if ( temp_x > LowerRightX ) w -= temp_x - LowerRightX; + + if ( y < dsp->Vissible.y ) + { + h -= dsp->Vissible.y - y; + y = dsp->Vissible.y; + } + + if ( temp_y > LowerRightY ) h -= temp_y - LowerRightY; + + if ((w>0) && (h>0)) + { + XLOCK; + XPutImage( dsp->display_id, + dsp->DisplayWindow, + dsp->Copy_GC, + &dsp->ScreenBitmap, + x , y, x - dsp->Vissible.x, + y - dsp->Vissible.y, w, h ); + XFlush(dsp->display_id); + XUNLOCK; + return(0); + } + +} /* end clipping_Xbitblt */ diff --git a/src/xc.c b/src/xc.c new file mode 100755 index 0000000..b0a998f --- /dev/null +++ b/src/xc.c @@ -0,0 +1,1857 @@ +/* $Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/************************************************************************/ +/* */ +/* M A I N D I S P A T C H L O O P */ +/* */ +/* This file contains the main dispatch loop for the emulator. */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifdef OSF1 +#include "time.h" +#endif + +#include +#ifdef DOS +#include /* Defines "#pragma interrupt" */ +#include /* _XSTACK struct definition */ +#include /* Defines REGS & other structs */ +#else /* DOS */ +#include +#endif /* DOS */ +#include + + +#include "lispemul.h" +#include "emlglob.h" +#include "address.h" +#include "adr68k.h" +#include "stack.h" +#include "dbprint.h" + +#include "lspglob.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "cell.h" +#include "initatms.h" +#include "gc.h" +#include "arith.h" +#include "stream.h" + +#include "tos1defs.h" +#include "tosret.h" +#include "tosfns.h" +#include "inlineC.h" + +#ifdef DOS +#include "iopage.h" +extern IOPAGE *IOPage68K; +#include "devif.h" +extern KbdInterface currentkbd; +extern DspInterface currentdsp; +extern MouseInterface currentmouse; +#endif /* DOS */ + +#ifdef SUN3_OS3_OR_OS4_IL +#include "inln68k.h" +#ifdef UNSAFE +#include "fastinln68k.h" +#endif +#endif + +typedef struct conspage ConsPage; +typedef ByteCode *InstPtr; + + +#ifdef GCC386 + register InstPtr pccache asm("si"); + register LispPTR *cspcache asm("di"); + register LispPTR tscache asm("bx"); +#include "inlnPS2.h" +#elif (DOS && OPDISP) +#include "inlndos.h" + register InstPtr pccache asm("si"); + register LispPTR *cspcache asm("di"); + register LispPTR tscache asm("bx"); +#endif /* DOS */ + + + /* Used to just be ifdef sparc, but want to be able to turn */ + /* off the inline code even on sparc machines. */ +#ifdef SPARCDISP +#include "inlnSPARC.h" +#endif /* SPARCDISP */ + + +#ifdef I386 +#include "inln386i.h" +#endif + +#include "fast_dsp.h" +#include "profile.h" + +/* trick now is that pccache points one ahead... */ +#define PCMAC (pccache-1) +#define PCMACL pccache +#define CSTKPTR ((LispPTR *) cspcache) +#define PVAR ((LispPTR *) PVar) +#define IVAR ((LispPTR *) IVar) +#define BCE_CURRENTFX ((struct frameex2 *)((DLword *) PVAR - FRAMESIZE)) + +#define CSTKPTRL (cspcache) +#define PVARL PVar +#define IVARL IVar + +extern DLword *createcell68k(unsigned int type); + +#ifdef DOS +extern unsigned char inchar; +extern unsigned short kn; +#endif + +#ifdef XWINDOW +extern int Event_Req; /* != 0 when it's time to check X events + on machines that don't get them reliably + (e.g. Suns running OpenWindows) */ +#endif /* XWINDOW */ + +#ifndef ISC +#ifndef DOS +#ifdef OPDISP +InstPtr optable[512]; +#endif /* OPDISP */ +#endif /* DOS */ +#endif /* ISC */ + + + +#ifdef PCTRACE + /* For keeping a trace table (ring buffer) of 100 last PCs */ +int pc_table[100], /* The PC */ + op_table[100]; /* The opcode at that PC */ +LispPTR fn_table[100]; /* The code block the PC is in (Lisp ptr) */ +int pccounter = 0; /* ring-buffer counter */ +#endif /* PCTRACE */ + +int dbgflag = 0; + +int extended_frame; /*indicates if soft stack overflow */ + + +int n_mask_array[16] = { 1, 3, 7, 0xf, + 0x1f, 0x3f, 0x7f, 0xff, + 0x1ff, 0x3ff, 0x7ff, 0xfff, + 0x1fff, 0x3fff, 0x7fff, 0xffff}; + +extern int TIMER_INTERVAL; + + +dispatch(void) +{ + register InstPtr pccache; + +#ifdef I386 + InstPtr *table; +#elif DOS + InstPtr * table; +#else +#if defined(OPDISP) || defined(SPARCDISP) +#ifdef ISC + InstPtr *table; +#else +register InstPtr *table; +#endif +#endif /* OPDISP */ +#endif /* I386 */ + +#ifdef ISC +#elif (DOS && OPDISP) +#else + register LispPTR *cspcache; + register LispPTR tscache; +#endif /* ISC */ + +#ifdef sparc + register struct state *stateptrcache = MState; +#undef MState +#define MState stateptrcache +#endif + +#if (defined(I386) || defined(ISC)) + int SaveD6; +#else +#ifdef OPDISP +#ifndef DOS + register int SaveD6; +#endif +#endif +#endif + +#ifdef UNSAFE + register int Save_D5_shift_amount; +#endif + +/* OP_FN_COMMON arguments */ + + DefCell *fn_defcell; + LispPTR fn_atom_index; + int fn_opcode_size; + int fn_num_args; + int fn_apply; + LispPTR fn_loc_defcell; + + RET; + CLR_IRQ; + +#ifndef ISC +#ifndef DOS +#ifdef OPDISP + table = optable; +#endif +#endif +#endif /* ISC */ + + +#ifdef SPARCDISP + table = (InstPtr *) compute_dispatch_table(); +#endif + +#ifdef UNSAFE + Save_D5_shift_amount = 15; +#endif + +#ifdef I386 + goto setup_table; +#else +#ifdef OPDISP +#ifdef ISC + asm(" leal optable,%%eax \n\ + movl %%eax,%0" : "=g" (table) : "0" (table)); + goto nextopcode; +#elif (DOS && OPDISP) + asm(" lea eax,optable \n\ + mov %0,%%eax" : "=g" (table) : "0" (table)); + asm volatile("fldcw WORD PTR CODE32:FP_noint"); /* Turn off FP interrupts */ + goto nextopcode; +#else + SaveD6 = 0; + goto setup_table; +#endif /* ISC */ + +#else + goto nextopcode; +#endif /* OPDISP */ + +#endif /* I386 */ + + + + +/* INLINE OPCODE FAIL ENTRY POINTS, CALL EXTERNAL ROUTINES HERE */ + OPCODEFAIL; +/* OPCODE FAIL ENTRY POINTS, CALL UFNS HERE */ + + UFN_CALLS; + +op_ufn: +{ +#ifdef ISC + UFN *entry68k; +#else + register UFN *entry68k; +#endif + entry68k = (UFN *)GetUFNEntry(Get_BYTE_PCMAC0); + fn_num_args = entry68k->arg_num; + fn_opcode_size = entry68k->byte_num+1; + fn_atom_index = entry68k->atom_name; + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); + fn_apply = 2 + entry68k->byte_num; /* code for UFN entry */ + goto op_fn_common; +}; + +/* FUNCTION CALL TAIL ROUTINE */ + + OP_FN_COMMON; + +/* DISPATCH "LOOP" */ + +nextopcode : +#ifdef MYOPTRACE + if ((struct fnhead *)Addr68k_from_LADDR(0x2ed600) == FuncObj) + { + quick_stack_check(); +#endif /* MYOPTRACE */ + + OPTPRINT(("Dispatch, PC = 0x%x, op = 0%o. TOS = 0x%x.\n", (int)PCMAC, Get_BYTE_PCMAC0, TOPOFSTACK)); +#ifdef MYOPTRACE + } +#endif /* MYOPTRACE */ + + +#ifdef PCTRACE + /* Tracing PC/Function/Opcode in a ring buffer */ + pc_table[pccounter] = (int)PCMAC - (int)FuncObj; + fn_table[pccounter] = (LispPTR) LADDR_from_68k(FuncObj); + op_table[pccounter] = Get_BYTE_PCMAC0; + if (99 == pccounter++) pccounter = 0; +#endif /* PCTRACE */ + +/* quick_stack_check();*/ /* JDS 2/12/98 */ + + +switch (Get_BYTE_PCMAC0) { + + case 000 : CASE000: { goto op_ufn; } /* unused */ + case 001 : CASE001: OPCAR; + case 002 : CASE002: OPCDR; + case 003 : CASE003: LISTP; + case 004 : CASE004: NTYPEX; + case 005 : CASE005: TYPEP(Get_BYTE_PCMAC1); + case 056 : CASE056: + case 006 : CASE006: DTEST(Get_AtomNo_PCMAC1); + case 007 : CASE007: UNWIND(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); +#ifdef NATIVETRAN + ret_to_fn0: asm("_ret_to_fn0:"); + asm(" .globl _ret_to_fn0"); + RET_FROM_NATIVE; +#endif + case 010 : CASE010: FN0; +#ifdef NATIVETRAN + ret_to_fn1: asm("_ret_to_fn1:"); + asm(" .globl _ret_to_fn1"); + RET_FROM_NATIVE; +#endif + case 011 : CASE011: FN1; +#ifdef NATIVETRAN + ret_to_fn2: asm("_ret_to_fn2:"); + asm(" .globl _ret_to_fn2"); + RET_FROM_NATIVE; +#endif + case 012 : CASE012: FN2; +#ifdef NATIVETRAN + ret_to_fn3: asm("_ret_to_fn3:"); + asm(" .globl _ret_to_fn3"); + RET_FROM_NATIVE; +#endif + case 013 : CASE013: FN3; +#ifdef NATIVETRAN + ret_to_fn4: asm("_ret_to_fn4:"); + asm(" .globl _ret_to_fn4"); + RET_FROM_NATIVE; +#endif + case 014 : CASE014: FN4; +#ifdef NATIVETRAN + ret_to_fnx: asm("_ret_to_fnx:"); + asm(" .globl _ret_to_fnx"); + RET_FROM_NATIVE; +#endif + case 015 : CASE015: FNX; +#ifdef NATIVETRAN + ret_to_apply: asm("_ret_to_apply:"); + asm(" .globl _ret_to_apply"); + RET_FROM_NATIVE; +#endif + case 016 : CASE016: APPLY; + + case 017 : CASE017: CHECKAPPLY; + case 020 : CASE020: RETURN; + + case 021 : CASE021: BIND; + case 022 : CASE022: UNBIND; + case 023 : CASE023: DUNBIND; + case 024 : CASE024: RPLPTR(Get_BYTE_PCMAC1); + case 025 : CASE025: GCREF(Get_BYTE_PCMAC1); + case 026 : CASE026: ASSOC; + case 027 : CASE027: + GVAR_(Get_AtomNo_PCMAC1); + case 030 : CASE030: RPLACA; + case 031 : CASE031: RPLACD; + case 032 : CASE032: CONS; + case 033 : CASE033: CLASSOC; + case 034 : CASE034: FMEMB; + case 035 : CASE035: CLFMEMB; + case 036 : CASE036: FINDKEY(Get_BYTE_PCMAC1); + case 037 : CASE037: CREATECELL; + case 040 : CASE040: BIN; + case 041 : CASE041: { goto op_ufn; } /* BOUT */ + case 042 : CASE042: { goto op_ufn; } /* POPDISP - prolog only */ + case 043 : CASE043: RESTLIST(Get_BYTE_PCMAC1); + case 044 : CASE044: MISCN(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 045 : CASE045: { goto op_ufn; } /* unused */ + case 046 : CASE046: RPLCONS; + case 047 : CASE047: LISTGET; + case 050 : CASE050: { goto op_ufn; } /* unused */ + case 051 : CASE051: { goto op_ufn; } /* unused */ + case 052 : CASE052: { goto op_ufn; } /* unused */ + case 053 : CASE053: { goto op_ufn; } /* unused */ + case 054 : CASE054: EVAL; +#ifdef NATIVETRAN + ret_to_envcall: asm("_ret_to_envcall:"); + asm(" .globl _ret_to_envcall"); + RET_FROM_NATIVE; +#endif + case 055 : CASE055: ENVCALL; + +/* case 056 : CASE056: @ 006 */ + case 057 : CASE057: STKSCAN; + case 060 : CASE060: { goto op_ufn; } /* BUSBLT - DLion only */ + case 061 : CASE061: { goto op_ufn; } /* MISC8 - no longer used */ + case 062 : CASE062: UBFLOAT3(Get_BYTE_PCMAC1); + case 063 : CASE063: TYPEMASK(Get_BYTE_PCMAC1); + case 064 : CASE064: { goto op_ufn; } /* rdprologptr */ + case 065 : CASE065: { goto op_ufn; } /* rdprologtag */ + case 066 : CASE066: { goto op_ufn; } /* writeptr&tag */ + case 067 : CASE067: { goto op_ufn; } /* writeptr&0tag */ + case 070 : CASE070: MISC7(Get_BYTE_PCMAC1); /* misc7 (pseudocolor, fbitmapbit) */ + case 071 : CASE071: { goto op_ufn; } /* dovemisc - dove only */ + case 072 : CASE072: EQLOP; + case 073 : CASE073: DRAWLINE; + case 074 : CASE074: STOREN(Get_BYTE_PCMAC1); + case 075 : CASE075: COPYN(Get_BYTE_PCMAC1); + case 076 : CASE076: { goto op_ufn; } /* RAID */ + case 077 : CASE077: { goto op_ufn; } /* \RETURN */ + + + + case 0100 : CASE100: IVARMACRO (0); + case 0101 : CASE101: IVARMACRO (1); + case 0102 : CASE102: IVARMACRO (2); + case 0103 : CASE103: IVARMACRO (3); + case 0104 : CASE104: IVARMACRO (4); + case 0105 : CASE105: IVARMACRO (5); + case 0106 : CASE106: IVARMACRO (6); + case 0107 : CASE107: IVARX (Get_BYTE_PCMAC1); + + case 0110 : CASE110: PVARMACRO (0); + case 0111 : CASE111: PVARMACRO (1); + case 0112 : CASE112: PVARMACRO (2); + case 0113 : CASE113: PVARMACRO (3); + case 0114 : CASE114: PVARMACRO (4); + case 0115 : CASE115: PVARMACRO (5); + case 0116 : CASE116: PVARMACRO (6); + + case 0117 : CASE117: PVARX(Get_BYTE_PCMAC1); + + case 0120 : CASE120: FVAR(0); + case 0121 : CASE121: FVAR(2); + case 0122 : CASE122: FVAR(4); + case 0123 : CASE123: FVAR(6); + case 0124 : CASE124: FVAR(8); + case 0125 : CASE125: FVAR(10); + case 0126 : CASE126: FVAR(12); + case 0127 : CASE127: FVARX(Get_BYTE_PCMAC1); + + case 0130 : CASE130: PVARSETMACRO (0); + case 0131 : CASE131: PVARSETMACRO (1); + case 0132 : CASE132: PVARSETMACRO (2); + case 0133 : CASE133: PVARSETMACRO (3); + case 0134 : CASE134: PVARSETMACRO (4); + case 0135 : CASE135: PVARSETMACRO (5); + case 0136 : CASE136: PVARSETMACRO (6); + + case 0137 : CASE137: PVARX_(Get_BYTE_PCMAC1); + + case 0140 : CASE140: GVAR(Get_AtomNo_PCMAC1); + case 0141 : CASE141: ARG0; + case 0142 : CASE142: IVARX_(Get_BYTE_PCMAC1); + case 0143 : CASE143: FVARX_(Get_BYTE_PCMAC1); + case 0144 : CASE144: COPY; + case 0145 : CASE145: MYARGCOUNT; + case 0146 : CASE146: MYALINK; + +/******** Aconst ********/ + case 0147 : CASE147: { PUSH(Get_AtomNo_PCMAC1); nextop_atom;} + case 0150 : CASE150: { PUSHATOM(NIL_PTR ); } + case 0151 : CASE151: { PUSHATOM(ATOM_T ); } + case 0152 : CASE152: { PUSHATOM(S_POSITIVE ); } /* '0 */ + case 0153 : CASE153: { PUSHATOM(0xE0001 ); } /* '1 */ + +/********* SIC ********/ + case 0154 : CASE154: { + PUSH(S_POSITIVE | Get_BYTE_PCMAC1); + nextop2; + } + +/********* SNIC ********/ + case 0155 : CASE155: { + PUSH(S_NEGATIVE | 0xff00 | Get_BYTE_PCMAC1); + nextop2; + } + +/********* SICX ********/ + case 0156 : CASE156:{ + PUSH(S_POSITIVE | Get_DLword_PCMAC1); + nextop3; + } + +/********* GCONST ********/ + case 0157 : CASE157: { + PUSH(Get_Pointer_PCMAC1); + nextop_ptr; + } + + case 0160 : CASE160: { goto op_ufn; } /* unused */ + case 0161 : CASE161: { goto op_ufn; } /* readflags */ + case 0162 : CASE162: { goto op_ufn; } /* readrp */ + case 0163 : CASE163: { goto op_ufn; } /* writemap */ + case 0164 : CASE164: { goto op_ufn; } /* readprinterport */ + case 0165 : CASE165: { goto op_ufn; } /* writeprinterport */ + + case 0166 : CASE166: PILOTBITBLT; + case 0167 : CASE167: RCLK; + case 0170 : CASE170: { goto op_ufn; } /* MISC1, dorado only */ + case 0171 : CASE171: { goto op_ufn; } /* MISC2, dorado only */ + case 0172 : CASE172: RECLAIMCELL; + case 0173 : CASE173: GCSCAN1; + case 0174 : CASE174: GCSCAN2; + case 0175 : CASE175: { EXT; OP_subrcall(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); RET; NATIVE_NEXTOP0; }; + case 0176 : CASE176: { CONTEXTSWITCH; } + case 0177 : CASE177: { goto op_ufn; } /* RETCALL */ + +/* JUMP */ + + case 0200 : CASE200: { JUMPMACRO(2); } + case 0201 : CASE201: { JUMPMACRO(3); } + case 0202 : CASE202: { JUMPMACRO(4); } + case 0203 : CASE203: { JUMPMACRO(5); } + case 0204 : CASE204: { JUMPMACRO(6); } + case 0205 : CASE205: { JUMPMACRO(7); } + case 0206 : CASE206: { JUMPMACRO(8); } + case 0207 : CASE207: { JUMPMACRO(9); } + case 0210 : CASE210: { JUMPMACRO(10); } + case 0211 : CASE211: { JUMPMACRO(11); } + case 0212 : CASE212: { JUMPMACRO(12); } + case 0213 : CASE213: { JUMPMACRO(13); } + case 0214 : CASE214: { JUMPMACRO(14); } + case 0215 : CASE215: { JUMPMACRO(15); } + case 0216 : CASE216: { JUMPMACRO(16); } + case 0217 : CASE217: { JUMPMACRO(17); } + + +/* FJUMP */ + + case 0220 : CASE220: { FJUMPMACRO(2); } + case 0221 : CASE221: { FJUMPMACRO(3); } + case 0222 : CASE222: { FJUMPMACRO(4); } + case 0223 : CASE223: { FJUMPMACRO(5); } + case 0224 : CASE224: { FJUMPMACRO(6); } + case 0225 : CASE225: { FJUMPMACRO(7); } + case 0226 : CASE226: { FJUMPMACRO(8); } + case 0227 : CASE227: { FJUMPMACRO(9); } + case 0230 : CASE230: { FJUMPMACRO(10); } + case 0231 : CASE231: { FJUMPMACRO(11); } + case 0232 : CASE232: { FJUMPMACRO(12); } + case 0233 : CASE233: { FJUMPMACRO(13); } + case 0234 : CASE234: { FJUMPMACRO(14); } + case 0235 : CASE235: { FJUMPMACRO(15); } + case 0236 : CASE236: { FJUMPMACRO(16); } + case 0237 : CASE237: { FJUMPMACRO(17); } + +/* TJUMP */ + + case 0240 : CASE240: { TJUMPMACRO(2); } + case 0241 : CASE241: { TJUMPMACRO(3); } + case 0242 : CASE242: { TJUMPMACRO(4); } + case 0243 : CASE243: { TJUMPMACRO(5); } + case 0244 : CASE244: { TJUMPMACRO(6); } + case 0245 : CASE245: { TJUMPMACRO(7); } + case 0246 : CASE246: { TJUMPMACRO(8); } + case 0247 : CASE247: { TJUMPMACRO(9); } + case 0250 : CASE250: { TJUMPMACRO(10); } + case 0251 : CASE251: { TJUMPMACRO(11); } + case 0252 : CASE252: { TJUMPMACRO(12); } + case 0253 : CASE253: { TJUMPMACRO(13); } + case 0254 : CASE254: { TJUMPMACRO(14); } + case 0255 : CASE255: { TJUMPMACRO(15); } + case 0256 : CASE256: { TJUMPMACRO(16); } + case 0257 : CASE257: { TJUMPMACRO(17); } + +/******* JUMPX ********/ + case 0260 : CASE260: { + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; nextop0; + } + +/******* JUMPXX ********/ + case 0261 : CASE261: { + CHECK_INTERRUPT; + PCMACL += (Get_SBYTE_PCMAC1<<8) | Get_BYTE_PCMAC2; nextop0; + } + +/******* FJumpx *******/ + case 0262 : CASE262: { + if(TOPOFSTACK != 0) {goto PopNextop2;} + CHECK_INTERRUPT; + POP; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + +/******* TJumpx *******/ + + case 0263 : CASE263: { + if(TOPOFSTACK == 0) {goto PopNextop2;} + CHECK_INTERRUPT; + POP; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + +/******* NFJumpx *******/ + + case 0264 : CASE264: { + if(TOPOFSTACK != 0) {goto PopNextop2;} + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + +/******* NTJumpx *******/ + + case 0265 : CASE265: { + if(TOPOFSTACK == 0) {goto PopNextop2;} + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + + case 0266 : CASE266: AREF1; + case 0267 : CASE267: ASET1; + + case 0270 : CASE270: PVARSETPOPMACRO(0); + case 0271 : CASE271: PVARSETPOPMACRO(1); + case 0272 : CASE272: PVARSETPOPMACRO(2); + case 0273 : CASE273: PVARSETPOPMACRO(3); + case 0274 : CASE274: PVARSETPOPMACRO(4); + case 0275 : CASE275: PVARSETPOPMACRO(5); + case 0276 : CASE276: PVARSETPOPMACRO(6); + + case 0277 : CASE277: { POP; nextop1; } + + case 0300 : CASE300: POPN(Get_BYTE_PCMAC1); + case 0301 : CASE301: ATOMCELL_N(Get_BYTE_PCMAC1); + case 0302 : CASE302: GETBASEBYTE; + case 0303 : CASE303: INSTANCEP(Get_AtomNo_PCMAC1); + case 0304 : CASE304: BLT; + case 0305 : CASE305: {goto op_ufn; } /* MISC10 */ + case 0306 : CASE306: {goto op_ufn; } /* P-MISC2 ??? */ + case 0307 : CASE307: PUTBASEBYTE; + case 0310 : CASE310: GETBASE_N(Get_BYTE_PCMAC1); + case 0311 : CASE311: GETBASEPTR_N(Get_BYTE_PCMAC1); + case 0312 : CASE312: GETBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 0313 : CASE313: {goto op_ufn; } /* unused */ + case 0314 : CASE314: CLEQUAL; + case 0315 : CASE315: PUTBASE_N(Get_BYTE_PCMAC1); + case 0316 : CASE316: PUTBASEPTR_N(Get_BYTE_PCMAC1); + case 0317 : CASE317: PUTBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + + case 0320 : CASE320: N_OP_ADDBASE; + case 0321 : CASE321: N_OP_VAG2; + case 0322 : CASE322: N_OP_HILOC; + case 0323 : CASE323: N_OP_LOLOC; + case 0324 : CASE324: PLUS2; /* PLUS */ + case 0325 : CASE325: DIFFERENCE; /* DIFFERENCE */ + case 0326 : CASE326: TIMES2; /* TIMES2 */ + case 0327 : CASE327: QUOTIENT /* QUOTIENT */ + case 0330 : CASE330: IPLUS2; /* IPLUS2 only while PLUS has no float */ + case 0331 : CASE331: IDIFFERENCE; /* IDIFFERENCE only while no float */ + case 0332 : CASE332: ITIMES2; /* ITIMES2 only while no float */ + case 0333 : CASE333: IQUOTIENT; /* IQUOTIENT */ + case 0334 : CASE334: IREMAINDER; + case 0335 : CASE335: IPLUS_N(Get_BYTE_PCMAC1); + case 0336 : CASE336: IDIFFERENCE_N(Get_BYTE_PCMAC1); + case 0337 : CASE337: { goto op_ufn; } /* BASE-< */ + case 0340 : CASE340: LLSH1; + case 0341 : CASE341: LLSH8; + case 0342 : CASE342: LRSH1; + case 0343 : CASE343: LRSH8; + case 0344 : CASE344: LOGOR; + case 0345 : CASE345: LOGAND; + case 0346 : CASE346: LOGXOR; + case 0347 : CASE347: LSH; + case 0350 : CASE350: FPLUS2; + case 0351 : CASE351: FDIFFERENCE; + case 0352 : CASE352: FTIMES2; + case 0353 : CASE353: FQUOTIENT; + case 0354 : CASE354: UBFLOAT2(Get_BYTE_PCMAC1); + case 0355 : CASE355: UBFLOAT1(Get_BYTE_PCMAC1); + case 0356 : CASE356: AREF2; + case 0357 : CASE357: ASET2; + + case 0360 : CASE360: { + if(TOPOFSTACK == POP_TOS_1) + TOPOFSTACK = ATOM_T; + else TOPOFSTACK = NIL_PTR; + nextop1; + } + + case 0361 : CASE361: IGREATERP; /* IGREATERP if no float */ + case 0362 : CASE362: FGREATERP; + case 0363 : CASE363: GREATERP; + case 0364 : CASE364: ILEQUAL; + case 0365 : CASE365: MAKENUMBER; + case 0366 : CASE366: BOXIPLUS; + case 0367 : CASE367: BOXIDIFFERENCE; + case 0370 : CASE370: { goto op_ufn; } /* FLOATBLT */ + case 0371 : CASE371: { goto op_ufn; } /* FFTSTEP */ + case 0372 : CASE372: MISC3(Get_BYTE_PCMAC1); + case 0373 : CASE373: MISC4(Get_BYTE_PCMAC1); + case 0374 : CASE374: { goto op_ufn; } /* upctrace */ + case 0375 : CASE375: SWAP; + case 0376 : CASE376: NOP; + case 0377 : CASE377: CLARITHEQUAL; +#ifdef OPDISP +#ifdef ISC +case 0400 : goto setup_table; /* to defeat optimizer, so optable exists */ +#elif (DOS && OPDISP) +case 0400: goto setup_table; +#endif /* ISC */ + +#endif /* OPDISP */ + + + +#ifdef I386 + /* to defeat the damn optimizer, make it look like */ + /* we might branch to the error labels. */ + case 0400 : goto plus_err; + case 0401 : goto iplus_err; + case 0402 : goto iplusn_err; + case 0403 : goto idiff_err; + case 0404 : goto diff_err; + case 0405 : goto idiffn_err; + case 0406 : goto greaterp_err; + case 0411 : goto igreaterp_err; + case 0407 : goto llsh8_err; + case 0410 : goto lrsh1_err; + case 0414 : goto lrsh8_err; + case 0417 : goto llsh1_err; + case 0413 : goto logor_err; + case 0412 : goto logand_err; + case 0416 : goto logxor_err; + case 0415 : goto addbase_err; +#endif + + default: error("should not default"); + + } /* switch */ + +#ifdef NATIVETRAN +/************************************************************************/ +/* NATIVE CODE INTERFACE */ +/************************************************************************/ + + +/* FORIEGN -> DISPATCH */ +/* Return to current frame ext */ + +c_ret_to_dispatch: + asm(" .globl _c_ret_to_dispatch"); + asm("_c_ret_to_dispatch:"); + PCMACL = (ByteCode *) FuncObj + BCE_CURRENTFX->pc; + goto ret_to_dispatch; /* assume optimizer will remove */ + +/* NATIVE -> DISPATCH */ +/* Return to current frame ext */ + +ret_to_dispatch: + asm(" .globl _ret_to_dispatch"); + asm("_ret_to_dispatch:"); + RET_FROM_NATIVE; + nextop0; + +/* NATIVE -> DISPATCH */ +/* Execute opcode in current frame ext */ + +ret_to_unimpl: + asm(" .globl _ret_to_unimpl"); + asm("_ret_to_unimpl:"); + SaveD6 = 0x100; + /* HACK. Reg. d6 is set to dispatch to native_check */ + /* so need to do switch instead of dispatch! */ + RET_FROM_NATIVE; + goto nextopcode; + +/* NATIVE -> UFN(PC) */ + +ret_to_ufn: + asm(" .globl _ret_to_ufn"); + asm("_ret_to_ufn:"); + RET_FROM_NATIVE; + goto op_ufn; + +/* DISPATCH -> NATIVE? */ +/* Return to current frame ext? */ + +native_check: + SaveD6 = 0; + NATIVE_NEXTOP0; + +/* NATIVE -> TIMER */ +/* Return to Execute timer interrupt */ + +ret_to_timer: + asm("_ret_to_timer:"); + asm(" .globl _ret_to_timer"); + SaveD6 = 0x100; + RET_FROM_NATIVE; + goto check_interrupt; /* assume optimizer will remove */ + +#else + +native_check: + +#ifndef DOS +#ifdef OPDISP + SaveD6 = 0x000; +#endif +#endif /* DOS */ + goto nextopcode; +#endif + +/************************************************************************/ +/* TIMER INTERRUPT CHECK ROUTINE */ +/************************************************************************/ +check_interrupt: +#if (defined(NATIVETRAN) || defined(SUN3_OS3_OR_OS4_IL) || defined(I386) || defined(ISC)) + asm_label_check_interrupt(); +#endif + + if ( (UNSIGNED)CSTKPTR > (UNSIGNED)EndSTKP ) + {EXT; + error("Unrecoverable Stack Overflow"); + RET; + } + + /* Check for an IRQ request */ + +{register int need_irq; + static int period_cnt=60; +extern int KBDEventFlg; +extern int ETHEREventCount; +extern LispPTR DOBUFFEREDTRANSITION_index; +extern LispPTR INTERRUPTFRAME_index; +extern LispPTR *KEYBUFFERING68k; +extern LispPTR *PENDINGINTERRUPT68k; +extern LispPTR ATOM_STARTED; +extern LispPTR *PERIODIC_INTERRUPT68k; +extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; +extern LispPTR PERIODIC_INTERRUPTFRAME_index; +extern LispPTR *Reclaim_cnt_word; +extern LispPTR DORECLAIM_index; +extern int URaid_req; + + /* Check for an Stack Overflow */ +/* JDS 22 May 96 -- >= below used to be just >, changed because we got + stack oflows with last frame right at end of stack, leading to loops, + odd bugs, ... */ +/**** Changed back to > 31 July 97 ****/ +re_check_stack: + need_irq = 0; + if ( ((UNSIGNED)(CSTKPTR+1) > Irq_Stk_Check) && + (Irq_Stk_End > 0) && + (Irq_Stk_Check > 0) ) + { + HARD_PUSH(TOPOFSTACK); + EXT; + extended_frame = NIL; + if (do_stackoverflow(NIL)) { +stackoverflow_help: + period_cnt=60; need_irq = T; + error("Stack Overflow, MUST HARDRESET!"); + RET; TOPOFSTACK = NIL_PTR; + } + else { RET; POP; } + Irq_Stk_Check = (UNSIGNED)EndSTKP-STK_MIN(FuncObj); + need_irq = (Irq_Stk_End == 0) || extended_frame; + *PENDINGINTERRUPT68k |= extended_frame; + Irq_Stk_End = (UNSIGNED) EndSTKP; + } + + /* Check for an IRQ request */ + + if ((Irq_Stk_End <= 0) || (Irq_Stk_Check <= 0) || need_irq) { + if (StkOffset_from_68K(CSTKPTR) > InterfacePage->stackbase) { + + /* Interrupts not Disabled */ +#ifndef KBINT + getsignaldata(); +#endif +#ifdef OS4 + getsignaldata(); +#endif + EXT; + update_timer(); + + /*** If SPY is running, check to see if it ***/ + /*** needs an interrupt; give it one, if so. ***/ + if(*PERIODIC_INTERRUPT68k!=NIL) + { + if(period_cnt>0) period_cnt--; + else + { + cause_interruptcall(PERIODIC_INTERRUPTFRAME_index); + if(*PERIODIC_INTERRUPT_FREQUENCY68k==NIL) + period_cnt=0; + else + period_cnt=(*PERIODIC_INTERRUPT_FREQUENCY68k & 0xffff) + *(1000000/60) /TIMER_INTERVAL; + /* number of 1/60 second periods between interrupts. + TIMER_INTERVAL is the number of microseconds between + timer interrupts. The calculation here avoids some + overflow errors although there is some roundoff + if the interrupt frequency number is too low, + it will bottom out and just set period_cnt to 0 */ + } + } + + +#ifdef DOS + if(currentkbd->URaid == TRUE){ + currentkbd->URaid = NIL; + (currentkbd->device.exit)(currentkbd); /* Install the original handler */ + error("Call URaid by User Interrupt"); + } + else if(currentmouse->Cursor.Moved){ + union REGS regs; + + currentdsp->device.locked++; + + /* Remove the mouse from the old place on the screen */ + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); + + /* Find the new delta */ + regs.w.eax = 0x000B; /* Function 0xB = get delta mickeys */ + int86(0x33, ®s, ®s); + currentmouse->Cursor.New.x += (short)regs.w.ecx; + currentmouse->Cursor.New.y += (short)regs.w.edx; + + if(currentmouse->Cursor.New.x < 0) + currentmouse->Cursor.New.x = 0; + else if(currentmouse->Cursor.New.x > (currentdsp->Display.width - 1)) + currentmouse->Cursor.New.x = currentdsp->Display.width - 1; + + if(currentmouse->Cursor.New.y < 0) + currentmouse->Cursor.New.y = 0; + else if(currentmouse->Cursor.New.y > (currentdsp->Display.height - 1)) + currentmouse->Cursor.New.y = currentdsp->Display.height - 1; + + IOPage68K->dlmousex = + IOPage68K->dlcursorx = + currentmouse->Cursor.New.x; + IOPage68K->dlmousey = + IOPage68K->dlcursory = + currentmouse->Cursor.New.y; + + /* Paint the mouse back up on the screen on the new place */ + (currentdsp->mouse_vissible)( currentmouse->Cursor.New.x, + currentmouse->Cursor.New.y); + currentmouse->Cursor.Moved = FALSE; + currentdsp->device.locked--; + } + +#else + if(URaid_req ==T){ + URaid_req=NIL; + error("Call URaid by User Interrupt"); + } +#endif /* DOS */ + else if((KBDEventFlg>0)&&(*KEYBUFFERING68k==ATOM_T)) { + *KEYBUFFERING68k= ATOM_STARTED; + cause_interruptcall(DOBUFFEREDTRANSITION_index); + KBDEventFlg --; + } + else if(*Reclaim_cnt_word == S_POSITIVE) { + *Reclaim_cnt_word=NIL; + cause_interruptcall(DORECLAIM_index); + } + else if (*PENDINGINTERRUPT68k!=NIL) + { INTSTAT2 * intstate = ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + unsigned char newints = (intstate->pendingmask) & ~(intstate->handledmask); + /* if (newints) */ + { + intstate->handledmask |= intstate->pendingmask; + *PENDINGINTERRUPT68k=NIL; + cause_interruptcall(INTERRUPTFRAME_index); + } + } + else if (ETHEREventCount>0) + { INTSTAT * intstate = ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + if (!(intstate->ETHERInterrupt) && + !(((INTSTAT2 *)intstate)->handledmask & 0x40)) + { + intstate->ETHERInterrupt=1; + ((INTSTAT2 *)intstate)->handledmask |= + ((INTSTAT2 *)intstate)->pendingmask; + cause_interruptcall(INTERRUPTFRAME_index); + ETHEREventCount--; + } + else *PENDINGINTERRUPT68k = ATOM_T; + } + RET; + CLR_IRQ; + } /* Interrupts not Disabled */ + else { + /* Clear out IRQ (loses pending interrupt request + if interrupts are disabled) */ + CLR_IRQ; + goto re_check_stack; + } + } + +} + + nextop0; + + +/************************************************************************/ +/* Common Jump Tails (they have to jump anyway, so use common Tail) */ +/************************************************************************/ +PopNextop1: + POP; + nextop1; + +PopNextop2: + POP; + nextop2; + +/************************************************************************/ +/* */ +/* Set up the dispatch table for use when we do assembler */ +/* optimization of the dispatch-jump sequence. */ +/* */ +/* */ +/************************************************************************/ + +#ifdef OPDISP + setup_table: +#ifndef ISC + SaveD6 = 0; + +#ifdef UNSAFE + Save_D5_shift_amount = 15; +#endif + + + {int i; for (i = 0; i < 256; i++) { table[i] = (InstPtr) op_ufn; };} + {int i; for (i = 256; i < 512; i++) + { table[i] = (InstPtr) native_check; }; + } + table[001] = (InstPtr) case001; + table[002] = (InstPtr) case002; + table[003] = (InstPtr) case003; + table[004] = (InstPtr) case004; + table[005] = (InstPtr) case005; + table[006] = (InstPtr) case006; + table[007] = (InstPtr) case007; + table[010] = (InstPtr) case010; + table[011] = (InstPtr) case011; + table[012] = (InstPtr) case012; + table[013] = (InstPtr) case013; + table[014] = (InstPtr) case014; + table[015] = (InstPtr) case015; + table[016] = (InstPtr) case016; + table[017] = (InstPtr) case017; + table[020] = (InstPtr) case020; + table[021] = (InstPtr) case021; + table[022] = (InstPtr) case022; + table[023] = (InstPtr) case023; + table[024] = (InstPtr) case024; + table[025] = (InstPtr) case025; + table[026] = (InstPtr) case026; + table[027] = (InstPtr) case027; + table[030] = (InstPtr) case030; + table[031] = (InstPtr) case031; + table[032] = (InstPtr) case032; + table[033] = (InstPtr) case033; + table[034] = (InstPtr) case034; + table[035] = (InstPtr) case035; + table[036] = (InstPtr) case036; + table[037] = (InstPtr) case037; + table[040] = (InstPtr) case040; + table[041] = (InstPtr) case041; + table[042] = (InstPtr) case042; + table[043] = (InstPtr) case043; + table[044] = (InstPtr) case044; + table[045] = (InstPtr) case045; + table[046] = (InstPtr) case046; + table[047] = (InstPtr) case047; + + table[054] = (InstPtr) case054; + table[055] = (InstPtr) case055; + table[056] = (InstPtr) case056; + table[057] = (InstPtr) case057; + + table[062] = (InstPtr) case062; + table[063] = (InstPtr) case063; + + table[070] = (InstPtr) case070; + + table[072] = (InstPtr) case072; + table[073] = (InstPtr) case073; + table[074] = (InstPtr) case074; + table[075] = (InstPtr) case075; + + table[0100] = (InstPtr) case100; + table[0101] = (InstPtr) case101; + table[0102] = (InstPtr) case102; + table[0103] = (InstPtr) case103; + table[0104] = (InstPtr) case104; + table[0105] = (InstPtr) case105; + table[0106] = (InstPtr) case106; + table[0107] = (InstPtr) case107; + table[0110] = (InstPtr) case110; + table[0111] = (InstPtr) case111; + table[0112] = (InstPtr) case112; + table[0113] = (InstPtr) case113; + table[0114] = (InstPtr) case114; + table[0115] = (InstPtr) case115; + table[0116] = (InstPtr) case116; + table[0117] = (InstPtr) case117; + table[0120] = (InstPtr) case120; + table[0121] = (InstPtr) case121; + table[0122] = (InstPtr) case122; + table[0123] = (InstPtr) case123; + table[0124] = (InstPtr) case124; + table[0125] = (InstPtr) case125; + table[0126] = (InstPtr) case126; + table[0127] = (InstPtr) case127; + table[0130] = (InstPtr) case130; + table[0131] = (InstPtr) case131; + table[0132] = (InstPtr) case132; + table[0133] = (InstPtr) case133; + table[0134] = (InstPtr) case134; + table[0135] = (InstPtr) case135; + table[0136] = (InstPtr) case136; + table[0137] = (InstPtr) case137; + table[0140] = (InstPtr) case140; + table[0141] = (InstPtr) case141; + table[0142] = (InstPtr) case142; + table[0143] = (InstPtr) case143; + table[0144] = (InstPtr) case144; + table[0145] = (InstPtr) case145; + table[0146] = (InstPtr) case146; + table[0147] = (InstPtr) case147; + table[0150] = (InstPtr) case150; + table[0151] = (InstPtr) case151; + table[0152] = (InstPtr) case152; + table[0153] = (InstPtr) case153; + table[0154] = (InstPtr) case154; + table[0155] = (InstPtr) case155; + table[0156] = (InstPtr) case156; + table[0157] = (InstPtr) case157; + table[0160] = (InstPtr) case160; + table[0161] = (InstPtr) case161; + table[0162] = (InstPtr) case162; + table[0163] = (InstPtr) case163; + table[0164] = (InstPtr) case164; + table[0165] = (InstPtr) case165; + table[0166] = (InstPtr) case166; + table[0167] = (InstPtr) case167; + table[0170] = (InstPtr) case170; + table[0171] = (InstPtr) case171; + table[0172] = (InstPtr) case172; + table[0173] = (InstPtr) case173; + table[0174] = (InstPtr) case174; + table[0175] = (InstPtr) case175; + table[0176] = (InstPtr) case176; + table[0177] = (InstPtr) case177; + table[0200] = (InstPtr) case200; + table[0201] = (InstPtr) case201; + table[0202] = (InstPtr) case202; + table[0203] = (InstPtr) case203; + table[0204] = (InstPtr) case204; + table[0205] = (InstPtr) case205; + table[0206] = (InstPtr) case206; + table[0207] = (InstPtr) case207; + table[0210] = (InstPtr) case210; + table[0211] = (InstPtr) case211; + table[0212] = (InstPtr) case212; + table[0213] = (InstPtr) case213; + table[0214] = (InstPtr) case214; + table[0215] = (InstPtr) case215; + table[0216] = (InstPtr) case216; + table[0217] = (InstPtr) case217; + table[0220] = (InstPtr) case220; + table[0221] = (InstPtr) case221; + table[0222] = (InstPtr) case222; + table[0223] = (InstPtr) case223; + table[0224] = (InstPtr) case224; + table[0225] = (InstPtr) case225; + table[0226] = (InstPtr) case226; + table[0227] = (InstPtr) case227; + table[0230] = (InstPtr) case230; + table[0231] = (InstPtr) case231; + table[0232] = (InstPtr) case232; + table[0233] = (InstPtr) case233; + table[0234] = (InstPtr) case234; + table[0235] = (InstPtr) case235; + table[0236] = (InstPtr) case236; + table[0237] = (InstPtr) case237; + table[0240] = (InstPtr) case240; + table[0241] = (InstPtr) case241; + table[0242] = (InstPtr) case242; + table[0243] = (InstPtr) case243; + table[0244] = (InstPtr) case244; + table[0245] = (InstPtr) case245; + table[0246] = (InstPtr) case246; + table[0247] = (InstPtr) case247; + table[0250] = (InstPtr) case250; + table[0251] = (InstPtr) case251; + table[0252] = (InstPtr) case252; + table[0253] = (InstPtr) case253; + table[0254] = (InstPtr) case254; + table[0255] = (InstPtr) case255; + table[0256] = (InstPtr) case256; + table[0257] = (InstPtr) case257; + table[0260] = (InstPtr) case260; + table[0261] = (InstPtr) case261; + table[0262] = (InstPtr) case262; + table[0263] = (InstPtr) case263; + table[0264] = (InstPtr) case264; + table[0265] = (InstPtr) case265; + table[0266] = (InstPtr) case266; + table[0267] = (InstPtr) case267; + table[0270] = (InstPtr) case270; + table[0271] = (InstPtr) case271; + table[0272] = (InstPtr) case272; + table[0273] = (InstPtr) case273; + table[0274] = (InstPtr) case274; + table[0275] = (InstPtr) case275; + table[0276] = (InstPtr) case276; + table[0277] = (InstPtr) case277; + table[0300] = (InstPtr) case300; + table[0301] = (InstPtr) case301; + table[0302] = (InstPtr) case302; + table[0303] = (InstPtr) case303; + table[0304] = (InstPtr) case304; + table[0305] = (InstPtr) case305; + table[0306] = (InstPtr) case306; + table[0307] = (InstPtr) case307; + table[0310] = (InstPtr) case310; + table[0311] = (InstPtr) case311; + table[0312] = (InstPtr) case312; + table[0313] = (InstPtr) case313; + table[0314] = (InstPtr) case314; + table[0315] = (InstPtr) case315; + table[0316] = (InstPtr) case316; + table[0317] = (InstPtr) case317; + table[0320] = (InstPtr) case320; + table[0321] = (InstPtr) case321; + table[0322] = (InstPtr) case322; + table[0323] = (InstPtr) case323; + table[0324] = (InstPtr) case324; + table[0325] = (InstPtr) case325; + table[0326] = (InstPtr) case326; + table[0327] = (InstPtr) case327; + table[0330] = (InstPtr) case330; + table[0331] = (InstPtr) case331; + table[0332] = (InstPtr) case332; + table[0333] = (InstPtr) case333; + table[0334] = (InstPtr) case334; + table[0335] = (InstPtr) case335; + table[0336] = (InstPtr) case336; + table[0337] = (InstPtr) case337; + table[0340] = (InstPtr) case340; + table[0341] = (InstPtr) case341; + table[0342] = (InstPtr) case342; + table[0343] = (InstPtr) case343; + table[0344] = (InstPtr) case344; + table[0345] = (InstPtr) case345; + table[0346] = (InstPtr) case346; + table[0347] = (InstPtr) case347; + table[0350] = (InstPtr) case350; + table[0351] = (InstPtr) case351; + table[0352] = (InstPtr) case352; + table[0353] = (InstPtr) case353; + table[0354] = (InstPtr) case354; + table[0355] = (InstPtr) case355; + table[0356] = (InstPtr) case356; + table[0357] = (InstPtr) case357; + table[0360] = (InstPtr) case360; + table[0361] = (InstPtr) case361; + table[0362] = (InstPtr) case362; + table[0363] = (InstPtr) case363; + table[0364] = (InstPtr) case364; + table[0365] = (InstPtr) case365; + table[0366] = (InstPtr) case366; + table[0367] = (InstPtr) case367; + table[0370] = (InstPtr) case370; + table[0371] = (InstPtr) case371; + table[0372] = (InstPtr) case372; + table[0373] = (InstPtr) case373; + table[0374] = (InstPtr) case374; + table[0375] = (InstPtr) case375; + table[0376] = (InstPtr) case376; + table[0377] = (InstPtr) case377; + goto nextopcode; +#elif GCC385 + /* This is the optable for 386's under gcc */ + +asm volatile(" .data \n\ + .align 4"); +asm volatile("optable: \n\ + .long _op000 \n\ + .long _op001 \n\ + .long _op002 \n\ + .long _op003 \n\ + .long _op004 \n\ + .long _op005 \n\ + .long _op006 \n\ + .long _op007 \n\ + .long _op010 \n\ + .long _op011 \n\ + .long _op012 \n\ + .long _op013 \n\ + .long _op014 \n\ + .long _op015 \n\ + .long _op016 \n\ + .long _op017 \n\ + .long _op020 \n\ + .long _op021 \n\ + .long _op022 \n\ + .long _op023 \n\ + .long _op024 \n\ + .long _op025 \n\ + .long _op026 \n\ + .long _op027 \n\ + .long _op030 \n\ + .long _op031 \n\ + .long _op032 \n\ + .long _op033 \n\ +"); + +asm volatile("\n\ + .long _op034 \n\ + .long _op035 \n\ + .long _op036 \n\ + .long _op037 \n\ + .long _op040 \n\ + .long _op041 \n\ + .long _op042 \n\ + .long _op043 \n\ + .long _op044 \n\ + .long _op045 \n\ + .long _op046 \n\ + .long _op047 \n\ + .long _op050 \n\ + .long _op051 \n\ + .long _op052 \n\ + .long _op053 \n\ + .long _op054 \n\ + .long _op055 \n\ + .long _op056 \n\ + .long _op057 \n\ + .long _op060 \n\ + .long _op061 \n\ + .long _op062 \n\ + .long _op063 \n\ + .long _op064 \n\ + .long _op065 \n\ + .long _op066 \n\ + .long _op067 \n\ + .long _op070 \n\ + .long _op071 \n\ + .long _op072 \n\ + .long _op073 \n\ + .long _op074 \n\ + .long _op075 \n\ + .long _op076 \n\ + .long _op077 \n\ + .long _op100 \n\ + .long _op101 \n\ + .long _op102 \n\ + .long _op103 \n\ + .long _op104 \n\ + .long _op105 \n\ + .long _op106 \n\ + .long _op107 \n\ + .long _op110 \n\ + .long _op111 \n\ + .long _op112 \n\ + .long _op113 \n\ + .long _op114 \n\ + .long _op115 \n\ + .long _op116 \n\ + .long _op117 \n\ + .long _op120 \n\ + .long _op121 \n\ + .long _op122 \n\ + .long _op123 \n\ + .long _op124 \n\ + .long _op125 \n\ + .long _op126 \n\ + .long _op127 \n\ + .long _op130 \n\ + .long _op131 \n\ + .long _op132 \n\ + .long _op133 \n\ + .long _op134 \n\ + .long _op135 \n\ + .long _op136 \n\ + .long _op137 \n\ + .long _op140 \n\ + .long _op141 \n\ + .long _op142 \n\ + .long _op143 \n\ + .long _op144 \n\ + .long _op145 \n\ + .long _op146 \n\ + .long _op147 \n\ + .long _op150 \n\ + .long _op151 \n\ + .long _op152 \n\ + .long _op153 \n\ + .long _op154 \n\ + .long _op155 \n\ + .long _op156 \n\ + .long _op157 \n\ + .long _op160 \n\ + .long _op161 \n\ + .long _op162 \n\ + .long _op163 \n\ + .long _op164 \n\ + .long _op165 \n\ + .long _op166 \n\ + .long _op167 \n\ + .long _op170 \n\ + .long _op171 \n\ + .long _op172 \n\ + .long _op173 \n\ + .long _op174 \n\ + .long _op175 \n\ + .long _op176 \n\ + .long _op177 \n\ + .long _op200 \n\ + .long _op201 \n\ + .long _op202 \n\ + .long _op203 \n\ + .long _op204 \n\ + .long _op205 \n\ + .long _op206 \n\ + .long _op207 \n\ + .long _op210 \n\ + .long _op211 \n\ + .long _op212 \n\ + .long _op213 \n\ + .long _op214 \n\ + .long _op215 \n\ + .long _op216 \n\ + .long _op217 \n\ + .long _op220 \n\ + .long _op221 \n\ + .long _op222 \n\ + .long _op223 \n\ + .long _op224 \n\ + .long _op225 \n\ + .long _op226 \n\ + .long _op227 \n\ + .long _op230 \n\ + .long _op231 \n\ + .long _op232 \n\ + .long _op233 \n\ + .long _op234 \n\ + .long _op235 \n\ + .long _op236 \n\ + .long _op237 \n\ + .long _op240 \n\ + .long _op241 \n\ + .long _op242 \n\ + .long _op243 \n\ + .long _op244 \n\ + .long _op245 \n\ + .long _op246 \n\ + .long _op247 \n\ + .long _op250 \n\ + .long _op251 \n\ + .long _op252 \n\ + .long _op253 \n\ + .long _op254 \n\ + .long _op255 \n\ + .long _op256 \n\ + .long _op257 \n\ + .long _op260 \n\ + .long _op261 \n\ + .long _op262 \n\ + .long _op263 \n\ + .long _op264 \n\ + .long _op265 \n\ + .long _op266 \n\ + .long _op267 \n\ + .long _op270 \n\ + .long _op271 \n\ + .long _op272 \n\ + .long _op273 \n\ + .long _op274 \n\ + .long _op275 \n\ + .long _op276 \n\ + .long _op277 \n\ + .long _op300 \n\ + .long _op301 \n\ + .long _op302 \n\ + .long _op303 \n\ + .long _op304 \n\ + .long _op305 \n\ + .long _op306 \n\ + .long _op307 \n\ + .long _op310 \n\ + .long _op311 \n\ + .long _op312 \n\ + .long _op313 \n\ + .long _op314 \n\ + .long _op315 \n\ + .long _op316 \n\ + .long _op317 \n\ + .long _op320 \n\ + .long _op321 \n\ + .long _op322 \n\ + .long _op323 \n\ + .long _op324 \n\ + .long _op325 \n\ + .long _op326 \n\ + .long _op327 \n\ + .long _op330 \n\ + .long _op331 \n\ + .long _op332 \n\ + .long _op333 \n\ + .long _op334 \n\ + .long _op335 \n\ + .long _op336 \n\ + .long _op337 \n\ + .long _op340 \n\ + .long _op341 \n\ + .long _op342 \n\ + .long _op343 \n\ + .long _op344 \n\ + .long _op345 \n\ + .long _op346 \n\ + .long _op347 \n\ + .long _op350 \n\ + .long _op351 \n\ + .long _op352 \n\ + .long _op353 \n\ + .long _op354 \n\ + .long _op355 \n\ + .long _op356 \n\ + .long _op357 \n\ + .long _op360 \n\ + .long _op361 \n\ + .long _op362 \n\ + .long _op363 \n\ + .long _op364 \n\ + .long _op365 \n\ + .long _op366 \n\ + .long _op367 \n\ + .long _op370 \n\ + .long _op371 \n\ + .long _op372 \n\ + .long _op373 \n\ + .long _op374 \n\ + .long _op375 \n\ + .long _op376 \n\ + .long _op377 \n\ + .text"); + +#elif (DOS && OPDISP) + /* This is the optable for 386's under gcc & Turbo Assembler */ + +asm volatile(" align 4"); +asm volatile("optable: \n\ + DD _op000 \n\ + DD _op001 \n\ + DD _op002 \n\ + DD _op003 \n\ + DD _op004 \n\ + DD _op005 \n\ + DD _op006 \n\ + DD _op007 \n\ + DD _op010 \n\ + DD _op011 \n\ + DD _op012 \n\ + DD _op013 \n\ + DD _op014 \n\ + DD _op015 \n\ + DD _op016 \n\ + DD _op017 \n\ + DD _op020 \n\ + DD _op021 \n\ + DD _op022 \n\ + DD _op023 \n\ + DD _op024 \n\ + DD _op025 \n\ + DD _op026 \n\ + DD _op027 \n\ + DD _op030 \n\ + DD _op031 \n\ + DD _op032 \n\ + DD _op033 \n\ +"); + +asm volatile("\n\ + DD _op034 \n\ + DD _op035 \n\ + DD _op036 \n\ + DD _op037 \n\ + DD _op040 \n\ + DD _op041 \n\ + DD _op042 \n\ + DD _op043 \n\ + DD _op044 \n\ + DD _op045 \n\ + DD _op046 \n\ + DD _op047 \n\ + DD _op050 \n\ + DD _op051 \n\ + DD _op052 \n\ + DD _op053 \n\ + DD _op054 \n\ + DD _op055 \n\ + DD _op056 \n\ + DD _op057 \n\ + DD _op060 \n\ + DD _op061 \n\ + DD _op062 \n\ + DD _op063 \n\ + DD _op064 \n\ + DD _op065 \n\ + DD _op066 \n\ + DD _op067 \n\ + DD _op070 \n\ + DD _op071 \n\ + DD _op072 \n\ + DD _op073 \n\ + DD _op074 \n\ + DD _op075 \n\ + DD _op076 \n\ + DD _op077 \n\ + DD _op100 \n\ + DD _op101 \n\ + DD _op102 \n\ + DD _op103 \n\ + DD _op104 \n\ + DD _op105 \n\ + DD _op106 \n\ + DD _op107 \n\ + DD _op110 \n\ + DD _op111 \n\ + DD _op112 \n\ + DD _op113 \n\ + DD _op114 \n\ + DD _op115 \n\ + DD _op116 \n\ + DD _op117 \n\ + DD _op120 \n\ + DD _op121 \n\ + DD _op122 \n\ + DD _op123 \n\ + DD _op124 \n\ + DD _op125 \n\ + DD _op126 \n\ + DD _op127 \n\ + DD _op130 \n\ + DD _op131 \n\ + DD _op132 \n\ + DD _op133 \n\ + DD _op134 \n\ + DD _op135 \n\ + DD _op136 \n\ + DD _op137 \n\ + DD _op140 \n\ + DD _op141 \n\ + DD _op142 \n\ + DD _op143 \n\ + DD _op144 \n\ + DD _op145 \n\ + DD _op146 \n\ + DD _op147 \n\ + DD _op150 \n\ + DD _op151 \n\ + DD _op152 \n\ + DD _op153 \n\ + DD _op154 \n\ + DD _op155 \n\ + DD _op156 \n\ + DD _op157 \n\ + DD _op160 \n\ + DD _op161 \n\ + DD _op162 \n\ + DD _op163 \n\ + DD _op164 \n\ + DD _op165 \n\ + DD _op166 \n\ + DD _op167 \n\ + DD _op170 \n\ + DD _op171 \n\ + DD _op172 \n\ + DD _op173 \n\ + DD _op174 \n\ + DD _op175 \n\ + DD _op176 \n\ + DD _op177 \n\ + DD _op200 \n\ + DD _op201 \n\ + DD _op202 \n\ + DD _op203 \n\ + DD _op204 \n\ + DD _op205 \n\ + DD _op206 \n\ + DD _op207 \n\ + DD _op210 \n\ + DD _op211 \n\ + DD _op212 \n\ + DD _op213 \n\ + DD _op214 \n\ + DD _op215 \n\ + DD _op216 \n\ + DD _op217 \n\ + DD _op220 \n\ + DD _op221 \n\ + DD _op222 \n\ + DD _op223 \n\ + DD _op224 \n\ + DD _op225 \n\ + DD _op226 \n\ + DD _op227 \n\ + DD _op230 \n\ + DD _op231 \n\ + DD _op232 \n\ + DD _op233 \n\ + DD _op234 \n\ + DD _op235 \n\ + DD _op236 \n\ + DD _op237 \n\ + DD _op240 \n\ + DD _op241 \n\ + DD _op242 \n\ + DD _op243 \n\ + DD _op244 \n\ + DD _op245 \n\ + DD _op246 \n\ + DD _op247 \n\ + DD _op250 \n\ + DD _op251 \n\ + DD _op252 \n\ + DD _op253 \n\ + DD _op254 \n\ + DD _op255 \n\ + DD _op256 \n\ + DD _op257 \n\ + DD _op260 \n\ + DD _op261 \n\ + DD _op262 \n\ + DD _op263 \n\ + DD _op264 \n\ + DD _op265 \n\ + DD _op266 \n\ + DD _op267 \n\ + DD _op270 \n\ + DD _op271 \n\ + DD _op272 \n\ + DD _op273 \n\ + DD _op274 \n\ + DD _op275 \n\ + DD _op276 \n\ + DD _op277 \n\ + DD _op300 \n\ + DD _op301 \n\ + DD _op302 \n\ + DD _op303 \n\ + DD _op304 \n\ + DD _op305 \n\ + DD _op306 \n\ + DD _op307 \n\ + DD _op310 \n\ + DD _op311 \n\ + DD _op312 \n\ + DD _op313 \n\ + DD _op314 \n\ + DD _op315 \n\ + DD _op316 \n\ + DD _op317 \n\ + DD _op320 \n\ + DD _op321 \n\ + DD _op322 \n\ + DD _op323 \n\ + DD _op324 \n\ + DD _op325 \n\ + DD _op326 \n\ + DD _op327 \n\ + DD _op330 \n\ + DD _op331 \n\ + DD _op332 \n\ + DD _op333 \n\ + DD _op334 \n\ + DD _op335 \n\ + DD _op336 \n\ + DD _op337 \n\ + DD _op340 \n\ + DD _op341 \n\ + DD _op342 \n\ + DD _op343 \n\ + DD _op344 \n\ + DD _op345 \n\ + DD _op346 \n\ + DD _op347 \n\ + DD _op350 \n\ + DD _op351 \n\ + DD _op352 \n\ + DD _op353 \n\ + DD _op354 \n\ + DD _op355 \n\ + DD _op356 \n\ + DD _op357 \n\ + DD _op360 \n\ + DD _op361 \n\ + DD _op362 \n\ + DD _op363 \n\ + DD _op364 \n\ + DD _op365 \n\ + DD _op366 \n\ + DD _op367 \n\ + DD _op370 \n\ + DD _op371 \n\ + DD _op372 \n\ + DD _op373 \n\ + DD _op374 \n\ + DD _op375 \n\ + DD _op376 \n\ + DD _op377"); + asm volatile("\n\ +FP_noint: DW 003fh ;; No interrupts, round to closest, 24bit precision"); + + +#endif /* ISC */ + + +#endif /* OPDISP */ + + + } + + +int retfun(void) {return(0);} +do_brk(void) {} + diff --git a/src/xc.c.orig b/src/xc.c.orig new file mode 100755 index 0000000..f45825a --- /dev/null +++ b/src/xc.c.orig @@ -0,0 +1,1854 @@ +/* $Id: xc.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xc.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright (C) Venue"; + + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +/************************************************************************/ +/* */ +/* M A I N D I S P A T C H L O O P */ +/* */ +/* This file contains the main dispatch loop for the emulator. */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +#ifdef OSF1 +#include "time.h" +#endif + +#include +#ifdef DOS +#include /* Defines "#pragma interrupt" */ +#include /* _XSTACK struct definition */ +#include /* Defines REGS & other structs */ +#else /* DOS */ +#include +#endif /* DOS */ +#include + + +#include "lispemul.h" +#include "emlglob.h" +#include "address.h" +#include "adr68k.h" +#include "stack.h" +#include "dbprint.h" + +#include "lspglob.h" +#include "lsptypes.h" +#include "lispmap.h" +#include "cell.h" +#include "initatms.h" +#include "gc.h" +#include "arith.h" +#include "stream.h" + +#include "tos1defs.h" +#include "tosret.h" +#include "tosfns.h" +#include "inlineC.h" + +#ifdef DOS +#include "iopage.h" +extern IOPAGE *IOPage68K; +#include "devif.h" +extern KbdInterface currentkbd; +extern DspInterface currentdsp; +extern MouseInterface currentmouse; +#endif /* DOS */ + +#ifdef SUN3_OS3_OR_OS4_IL +#include "inln68k.h" +#ifdef UNSAFE +#include "fastinln68k.h" +#endif +#endif + +typedef struct conspage ConsPage; +typedef ByteCode *InstPtr; + + +#ifdef GCC386 + register InstPtr pccache asm("si"); + register LispPTR *cspcache asm("di"); + register LispPTR tscache asm("bx"); +#include "inlnPS2.h" +#elif (DOS && OPDISP) +#include "inlndos.h" + register InstPtr pccache asm("si"); + register LispPTR *cspcache asm("di"); + register LispPTR tscache asm("bx"); +#endif /* DOS */ + + + /* Used to just be ifdef sparc, but want to be able to turn */ + /* off the inline code even on sparc machines. */ +#ifdef SPARCDISP +#include "inlnSPARC.h" +#endif /* SPARCDISP */ + + +#ifdef I386 +#include "inln386i.h" +#endif + +#include "fast_dsp.h" +#include "profile.h" + +/* trick now is that pccache points one ahead... */ +#define PCMAC (pccache-1) +#define PCMACL pccache +#define CSTKPTR ((LispPTR *) cspcache) +#define PVAR ((LispPTR *) PVar) +#define IVAR ((LispPTR *) IVar) +#define BCE_CURRENTFX ((struct frameex2 *)((DLword *) PVAR - FRAMESIZE)) + +#define CSTKPTRL (cspcache) +#define PVARL PVar +#define IVARL IVar + +extern DLword *createcell68k(unsigned int type); + +#ifdef DOS +extern unsigned char inchar; +extern unsigned short kn; +#endif + +#ifdef XWINDOW +extern int Event_Req; /* != 0 when it's time to check X events + on machines that don't get them reliably + (e.g. Suns running OpenWindows) */ +#endif /* XWINDOW */ + +#ifndef ISC +#ifndef DOS +#ifdef OPDISP +InstPtr optable[512]; +#endif /* OPDISP */ +#endif /* DOS */ +#endif /* ISC */ + + + +#ifdef PCTRACE + /* For keeping a trace table (ring buffer) of 100 last PCs */ +int pc_table[100], /* The PC */ + op_table[100]; /* The opcode at that PC */ +LispPTR fn_table[100]; /* The code block the PC is in (Lisp ptr) */ +int pccounter = 0; /* ring-buffer counter */ +#endif /* PCTRACE */ + +int dbgflag = 0; + +int extended_frame; /*indicates if soft stack overflow */ + + +int n_mask_array[16] = { 1, 3, 7, 0xf, + 0x1f, 0x3f, 0x7f, 0xff, + 0x1ff, 0x3ff, 0x7ff, 0xfff, + 0x1fff, 0x3fff, 0x7fff, 0xffff}; + +extern int TIMER_INTERVAL; + + +dispatch(void) +{ + register InstPtr pccache; + +#ifdef I386 + InstPtr *table; +#elif DOS + InstPtr * table; +#else +#if defined(OPDISP) || defined(SPARCDISP) +#ifdef ISC + InstPtr *table; +#else +register InstPtr *table; +#endif +#endif /* OPDISP */ +#endif /* I386 */ + +#ifdef ISC +#elif (DOS && OPDISP) +#else + register LispPTR *cspcache; + register LispPTR tscache; +#endif /* ISC */ + +#ifdef sparc + register struct state *stateptrcache = MState; +#undef MState +#define MState stateptrcache +#endif + +#if (defined(I386) || defined(ISC)) + int SaveD6; +#else +#ifdef OPDISP +#ifndef DOS + register int SaveD6; +#endif +#endif +#endif + +#ifdef UNSAFE + register int Save_D5_shift_amount; +#endif + +/* OP_FN_COMMON arguments */ + + DefCell *fn_defcell; + LispPTR fn_atom_index; + int fn_opcode_size; + int fn_num_args; + int fn_apply; + LispPTR fn_loc_defcell; + + RET; + CLR_IRQ; + +#ifndef ISC +#ifndef DOS +#ifdef OPDISP + table = optable; +#endif +#endif +#endif /* ISC */ + + +#ifdef SPARCDISP + table = (InstPtr *) compute_dispatch_table(); +#endif + +#ifdef UNSAFE + Save_D5_shift_amount = 15; +#endif + +#ifdef I386 + goto setup_table; +#else +#ifdef OPDISP +#ifdef ISC + asm(" leal optable,%%eax \n\ + movl %%eax,%0" : "=g" (table) : "0" (table)); + goto nextopcode; +#elif (DOS && OPDISP) + asm(" lea eax,optable \n\ + mov %0,%%eax" : "=g" (table) : "0" (table)); + asm volatile("fldcw WORD PTR CODE32:FP_noint"); /* Turn off FP interrupts */ + goto nextopcode; +#else + SaveD6 = 0; + goto setup_table; +#endif /* ISC */ + +#else + goto nextopcode; +#endif /* OPDISP */ + +#endif /* I386 */ + + + + +/* INLINE OPCODE FAIL ENTRY POINTS, CALL EXTERNAL ROUTINES HERE */ + OPCODEFAIL; +/* OPCODE FAIL ENTRY POINTS, CALL UFNS HERE */ + + UFN_CALLS; + +op_ufn: +{ +#ifdef ISC + UFN *entry68k; +#else + register UFN *entry68k; +#endif + entry68k = (UFN *)GetUFNEntry(Get_BYTE_PCMAC0); + fn_num_args = entry68k->arg_num; + fn_opcode_size = entry68k->byte_num+1; + fn_atom_index = entry68k->atom_name; + fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); + fn_apply = 2 + entry68k->byte_num; /* code for UFN entry */ + goto op_fn_common; +}; + +/* FUNCTION CALL TAIL ROUTINE */ + + OP_FN_COMMON; + +/* DISPATCH "LOOP" */ + +nextopcode : +#ifdef MYOPTRACE + if ((struct fnhead *)Addr68k_from_LADDR(0x2ed600) == FuncObj) + { + quick_stack_check(); +#endif /* MYOPTRACE */ + + OPTPRINT(("Dispatch, PC = 0x%x, op = 0%o. TOS = 0x%x.\n", (int)PCMAC, Get_BYTE_PCMAC0, TOPOFSTACK)); +#ifdef MYOPTRACE + } +#endif /* MYOPTRACE */ + + +#ifdef PCTRACE + /* Tracing PC/Function/Opcode in a ring buffer */ + pc_table[pccounter] = (int)PCMAC - (int)FuncObj; + fn_table[pccounter] = (LispPTR) LADDR_from_68k(FuncObj); + op_table[pccounter] = Get_BYTE_PCMAC0; + if (99 == pccounter++) pccounter = 0; +#endif /* PCTRACE */ + +/* quick_stack_check();*/ /* JDS 2/12/98 */ + + +switch (Get_BYTE_PCMAC0) { + + case 000 : CASE000: { goto op_ufn; } /* unused */ + case 001 : CASE001: OPCAR; + case 002 : CASE002: OPCDR; + case 003 : CASE003: LISTP; + case 004 : CASE004: NTYPEX; + case 005 : CASE005: TYPEP(Get_BYTE_PCMAC1); + case 056 : CASE056: + case 006 : CASE006: DTEST(Get_AtomNo_PCMAC1); + case 007 : CASE007: UNWIND(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); +#ifdef NATIVETRAN + ret_to_fn0: asm("_ret_to_fn0:"); + asm(" .globl _ret_to_fn0"); + RET_FROM_NATIVE; +#endif + case 010 : CASE010: FN0; +#ifdef NATIVETRAN + ret_to_fn1: asm("_ret_to_fn1:"); + asm(" .globl _ret_to_fn1"); + RET_FROM_NATIVE; +#endif + case 011 : CASE011: FN1; +#ifdef NATIVETRAN + ret_to_fn2: asm("_ret_to_fn2:"); + asm(" .globl _ret_to_fn2"); + RET_FROM_NATIVE; +#endif + case 012 : CASE012: FN2; +#ifdef NATIVETRAN + ret_to_fn3: asm("_ret_to_fn3:"); + asm(" .globl _ret_to_fn3"); + RET_FROM_NATIVE; +#endif + case 013 : CASE013: FN3; +#ifdef NATIVETRAN + ret_to_fn4: asm("_ret_to_fn4:"); + asm(" .globl _ret_to_fn4"); + RET_FROM_NATIVE; +#endif + case 014 : CASE014: FN4; +#ifdef NATIVETRAN + ret_to_fnx: asm("_ret_to_fnx:"); + asm(" .globl _ret_to_fnx"); + RET_FROM_NATIVE; +#endif + case 015 : CASE015: FNX; +#ifdef NATIVETRAN + ret_to_apply: asm("_ret_to_apply:"); + asm(" .globl _ret_to_apply"); + RET_FROM_NATIVE; +#endif + case 016 : CASE016: APPLY; + + case 017 : CASE017: CHECKAPPLY; + case 020 : CASE020: RETURN; + + case 021 : CASE021: BIND; + case 022 : CASE022: UNBIND; + case 023 : CASE023: DUNBIND; + case 024 : CASE024: RPLPTR(Get_BYTE_PCMAC1); + case 025 : CASE025: GCREF(Get_BYTE_PCMAC1); + case 026 : CASE026: ASSOC; + case 027 : CASE027: + GVAR_(Get_AtomNo_PCMAC1); + case 030 : CASE030: RPLACA; + case 031 : CASE031: RPLACD; + case 032 : CASE032: CONS; + case 033 : CASE033: CLASSOC; + case 034 : CASE034: FMEMB; + case 035 : CASE035: CLFMEMB; + case 036 : CASE036: FINDKEY(Get_BYTE_PCMAC1); + case 037 : CASE037: CREATECELL; + case 040 : CASE040: BIN; + case 041 : CASE041: { goto op_ufn; } /* BOUT */ + case 042 : CASE042: { goto op_ufn; } /* POPDISP - prolog only */ + case 043 : CASE043: RESTLIST(Get_BYTE_PCMAC1); + case 044 : CASE044: MISCN(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 045 : CASE045: { goto op_ufn; } /* unused */ + case 046 : CASE046: RPLCONS; + case 047 : CASE047: LISTGET; + case 050 : CASE050: { goto op_ufn; } /* unused */ + case 051 : CASE051: { goto op_ufn; } /* unused */ + case 052 : CASE052: { goto op_ufn; } /* unused */ + case 053 : CASE053: { goto op_ufn; } /* unused */ + case 054 : CASE054: EVAL; +#ifdef NATIVETRAN + ret_to_envcall: asm("_ret_to_envcall:"); + asm(" .globl _ret_to_envcall"); + RET_FROM_NATIVE; +#endif + case 055 : CASE055: ENVCALL; + +/* case 056 : CASE056: @ 006 */ + case 057 : CASE057: STKSCAN; + case 060 : CASE060: { goto op_ufn; } /* BUSBLT - DLion only */ + case 061 : CASE061: { goto op_ufn; } /* MISC8 - no longer used */ + case 062 : CASE062: UBFLOAT3(Get_BYTE_PCMAC1); + case 063 : CASE063: TYPEMASK(Get_BYTE_PCMAC1); + case 064 : CASE064: { goto op_ufn; } /* rdprologptr */ + case 065 : CASE065: { goto op_ufn; } /* rdprologtag */ + case 066 : CASE066: { goto op_ufn; } /* writeptr&tag */ + case 067 : CASE067: { goto op_ufn; } /* writeptr&0tag */ + case 070 : CASE070: MISC7(Get_BYTE_PCMAC1); /* misc7 (pseudocolor, fbitmapbit) */ + case 071 : CASE071: { goto op_ufn; } /* dovemisc - dove only */ + case 072 : CASE072: EQLOP; + case 073 : CASE073: DRAWLINE; + case 074 : CASE074: STOREN(Get_BYTE_PCMAC1); + case 075 : CASE075: COPYN(Get_BYTE_PCMAC1); + case 076 : CASE076: { goto op_ufn; } /* RAID */ + case 077 : CASE077: { goto op_ufn; } /* \RETURN */ + + + + case 0100 : CASE100: IVARMACRO (0); + case 0101 : CASE101: IVARMACRO (1); + case 0102 : CASE102: IVARMACRO (2); + case 0103 : CASE103: IVARMACRO (3); + case 0104 : CASE104: IVARMACRO (4); + case 0105 : CASE105: IVARMACRO (5); + case 0106 : CASE106: IVARMACRO (6); + case 0107 : CASE107: IVARX (Get_BYTE_PCMAC1); + + case 0110 : CASE110: PVARMACRO (0); + case 0111 : CASE111: PVARMACRO (1); + case 0112 : CASE112: PVARMACRO (2); + case 0113 : CASE113: PVARMACRO (3); + case 0114 : CASE114: PVARMACRO (4); + case 0115 : CASE115: PVARMACRO (5); + case 0116 : CASE116: PVARMACRO (6); + + case 0117 : CASE117: PVARX(Get_BYTE_PCMAC1); + + case 0120 : CASE120: FVAR(0); + case 0121 : CASE121: FVAR(2); + case 0122 : CASE122: FVAR(4); + case 0123 : CASE123: FVAR(6); + case 0124 : CASE124: FVAR(8); + case 0125 : CASE125: FVAR(10); + case 0126 : CASE126: FVAR(12); + case 0127 : CASE127: FVARX(Get_BYTE_PCMAC1); + + case 0130 : CASE130: PVARSETMACRO (0); + case 0131 : CASE131: PVARSETMACRO (1); + case 0132 : CASE132: PVARSETMACRO (2); + case 0133 : CASE133: PVARSETMACRO (3); + case 0134 : CASE134: PVARSETMACRO (4); + case 0135 : CASE135: PVARSETMACRO (5); + case 0136 : CASE136: PVARSETMACRO (6); + + case 0137 : CASE137: PVARX_(Get_BYTE_PCMAC1); + + case 0140 : CASE140: GVAR(Get_AtomNo_PCMAC1); + case 0141 : CASE141: ARG0; + case 0142 : CASE142: IVARX_(Get_BYTE_PCMAC1); + case 0143 : CASE143: FVARX_(Get_BYTE_PCMAC1); + case 0144 : CASE144: COPY; + case 0145 : CASE145: MYARGCOUNT; + case 0146 : CASE146: MYALINK; + +/******** Aconst ********/ + case 0147 : CASE147: { PUSH(Get_AtomNo_PCMAC1); nextop_atom;} + case 0150 : CASE150: { PUSHATOM(NIL_PTR ); } + case 0151 : CASE151: { PUSHATOM(ATOM_T ); } + case 0152 : CASE152: { PUSHATOM(S_POSITIVE ); } /* '0 */ + case 0153 : CASE153: { PUSHATOM(0xE0001 ); } /* '1 */ + +/********* SIC ********/ + case 0154 : CASE154: { + PUSH(S_POSITIVE | Get_BYTE_PCMAC1); + nextop2; + } + +/********* SNIC ********/ + case 0155 : CASE155: { + PUSH(S_NEGATIVE | 0xff00 | Get_BYTE_PCMAC1); + nextop2; + } + +/********* SICX ********/ + case 0156 : CASE156:{ + PUSH(S_POSITIVE | Get_DLword_PCMAC1); + nextop3; + } + +/********* GCONST ********/ + case 0157 : CASE157: { + PUSH(Get_Pointer_PCMAC1); + nextop_ptr; + } + + case 0160 : CASE160: { goto op_ufn; } /* unused */ + case 0161 : CASE161: { goto op_ufn; } /* readflags */ + case 0162 : CASE162: { goto op_ufn; } /* readrp */ + case 0163 : CASE163: { goto op_ufn; } /* writemap */ + case 0164 : CASE164: { goto op_ufn; } /* readprinterport */ + case 0165 : CASE165: { goto op_ufn; } /* writeprinterport */ + + case 0166 : CASE166: PILOTBITBLT; + case 0167 : CASE167: RCLK; + case 0170 : CASE170: { goto op_ufn; } /* MISC1, dorado only */ + case 0171 : CASE171: { goto op_ufn; } /* MISC2, dorado only */ + case 0172 : CASE172: RECLAIMCELL; + case 0173 : CASE173: GCSCAN1; + case 0174 : CASE174: GCSCAN2; + case 0175 : CASE175: { EXT; OP_subrcall(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); RET; NATIVE_NEXTOP0; }; + case 0176 : CASE176: { CONTEXTSWITCH; } + case 0177 : CASE177: { goto op_ufn; } /* RETCALL */ + +/* JUMP */ + + case 0200 : CASE200: { JUMPMACRO(2); } + case 0201 : CASE201: { JUMPMACRO(3); } + case 0202 : CASE202: { JUMPMACRO(4); } + case 0203 : CASE203: { JUMPMACRO(5); } + case 0204 : CASE204: { JUMPMACRO(6); } + case 0205 : CASE205: { JUMPMACRO(7); } + case 0206 : CASE206: { JUMPMACRO(8); } + case 0207 : CASE207: { JUMPMACRO(9); } + case 0210 : CASE210: { JUMPMACRO(10); } + case 0211 : CASE211: { JUMPMACRO(11); } + case 0212 : CASE212: { JUMPMACRO(12); } + case 0213 : CASE213: { JUMPMACRO(13); } + case 0214 : CASE214: { JUMPMACRO(14); } + case 0215 : CASE215: { JUMPMACRO(15); } + case 0216 : CASE216: { JUMPMACRO(16); } + case 0217 : CASE217: { JUMPMACRO(17); } + + +/* FJUMP */ + + case 0220 : CASE220: { FJUMPMACRO(2); } + case 0221 : CASE221: { FJUMPMACRO(3); } + case 0222 : CASE222: { FJUMPMACRO(4); } + case 0223 : CASE223: { FJUMPMACRO(5); } + case 0224 : CASE224: { FJUMPMACRO(6); } + case 0225 : CASE225: { FJUMPMACRO(7); } + case 0226 : CASE226: { FJUMPMACRO(8); } + case 0227 : CASE227: { FJUMPMACRO(9); } + case 0230 : CASE230: { FJUMPMACRO(10); } + case 0231 : CASE231: { FJUMPMACRO(11); } + case 0232 : CASE232: { FJUMPMACRO(12); } + case 0233 : CASE233: { FJUMPMACRO(13); } + case 0234 : CASE234: { FJUMPMACRO(14); } + case 0235 : CASE235: { FJUMPMACRO(15); } + case 0236 : CASE236: { FJUMPMACRO(16); } + case 0237 : CASE237: { FJUMPMACRO(17); } + +/* TJUMP */ + + case 0240 : CASE240: { TJUMPMACRO(2); } + case 0241 : CASE241: { TJUMPMACRO(3); } + case 0242 : CASE242: { TJUMPMACRO(4); } + case 0243 : CASE243: { TJUMPMACRO(5); } + case 0244 : CASE244: { TJUMPMACRO(6); } + case 0245 : CASE245: { TJUMPMACRO(7); } + case 0246 : CASE246: { TJUMPMACRO(8); } + case 0247 : CASE247: { TJUMPMACRO(9); } + case 0250 : CASE250: { TJUMPMACRO(10); } + case 0251 : CASE251: { TJUMPMACRO(11); } + case 0252 : CASE252: { TJUMPMACRO(12); } + case 0253 : CASE253: { TJUMPMACRO(13); } + case 0254 : CASE254: { TJUMPMACRO(14); } + case 0255 : CASE255: { TJUMPMACRO(15); } + case 0256 : CASE256: { TJUMPMACRO(16); } + case 0257 : CASE257: { TJUMPMACRO(17); } + +/******* JUMPX ********/ + case 0260 : CASE260: { + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; nextop0; + } + +/******* JUMPXX ********/ + case 0261 : CASE261: { + CHECK_INTERRUPT; + PCMACL += (Get_SBYTE_PCMAC1<<8) | Get_BYTE_PCMAC2; nextop0; + } + +/******* FJumpx *******/ + case 0262 : CASE262: { + if(TOPOFSTACK != 0) {goto PopNextop2;} + CHECK_INTERRUPT; + POP; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + +/******* TJumpx *******/ + + case 0263 : CASE263: { + if(TOPOFSTACK == 0) {goto PopNextop2;} + CHECK_INTERRUPT; + POP; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + +/******* NFJumpx *******/ + + case 0264 : CASE264: { + if(TOPOFSTACK != 0) {goto PopNextop2;} + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + +/******* NTJumpx *******/ + + case 0265 : CASE265: { + if(TOPOFSTACK == 0) {goto PopNextop2;} + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } + + case 0266 : CASE266: AREF1; + case 0267 : CASE267: ASET1; + + case 0270 : CASE270: PVARSETPOPMACRO(0); + case 0271 : CASE271: PVARSETPOPMACRO(1); + case 0272 : CASE272: PVARSETPOPMACRO(2); + case 0273 : CASE273: PVARSETPOPMACRO(3); + case 0274 : CASE274: PVARSETPOPMACRO(4); + case 0275 : CASE275: PVARSETPOPMACRO(5); + case 0276 : CASE276: PVARSETPOPMACRO(6); + + case 0277 : CASE277: { POP; nextop1; } + + case 0300 : CASE300: POPN(Get_BYTE_PCMAC1); + case 0301 : CASE301: ATOMCELL_N(Get_BYTE_PCMAC1); + case 0302 : CASE302: GETBASEBYTE; + case 0303 : CASE303: INSTANCEP(Get_AtomNo_PCMAC1); + case 0304 : CASE304: BLT; + case 0305 : CASE305: {goto op_ufn; } /* MISC10 */ + case 0306 : CASE306: {goto op_ufn; } /* P-MISC2 ??? */ + case 0307 : CASE307: PUTBASEBYTE; + case 0310 : CASE310: GETBASE_N(Get_BYTE_PCMAC1); + case 0311 : CASE311: GETBASEPTR_N(Get_BYTE_PCMAC1); + case 0312 : CASE312: GETBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 0313 : CASE313: {goto op_ufn; } /* unused */ + case 0314 : CASE314: CLEQUAL; + case 0315 : CASE315: PUTBASE_N(Get_BYTE_PCMAC1); + case 0316 : CASE316: PUTBASEPTR_N(Get_BYTE_PCMAC1); + case 0317 : CASE317: PUTBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + + case 0320 : CASE320: N_OP_ADDBASE; + case 0321 : CASE321: N_OP_VAG2; + case 0322 : CASE322: N_OP_HILOC; + case 0323 : CASE323: N_OP_LOLOC; + case 0324 : CASE324: PLUS2; /* PLUS */ + case 0325 : CASE325: DIFFERENCE; /* DIFFERENCE */ + case 0326 : CASE326: TIMES2; /* TIMES2 */ + case 0327 : CASE327: QUOTIENT /* QUOTIENT */ + case 0330 : CASE330: IPLUS2; /* IPLUS2 only while PLUS has no float */ + case 0331 : CASE331: IDIFFERENCE; /* IDIFFERENCE only while no float */ + case 0332 : CASE332: ITIMES2; /* ITIMES2 only while no float */ + case 0333 : CASE333: IQUOTIENT; /* IQUOTIENT */ + case 0334 : CASE334: IREMAINDER; + case 0335 : CASE335: IPLUS_N(Get_BYTE_PCMAC1); + case 0336 : CASE336: IDIFFERENCE_N(Get_BYTE_PCMAC1); + case 0337 : CASE337: { goto op_ufn; } /* BASE-< */ + case 0340 : CASE340: LLSH1; + case 0341 : CASE341: LLSH8; + case 0342 : CASE342: LRSH1; + case 0343 : CASE343: LRSH8; + case 0344 : CASE344: LOGOR; + case 0345 : CASE345: LOGAND; + case 0346 : CASE346: LOGXOR; + case 0347 : CASE347: LSH; + case 0350 : CASE350: FPLUS2; + case 0351 : CASE351: FDIFFERENCE; + case 0352 : CASE352: FTIMES2; + case 0353 : CASE353: FQUOTIENT; + case 0354 : CASE354: UBFLOAT2(Get_BYTE_PCMAC1); + case 0355 : CASE355: UBFLOAT1(Get_BYTE_PCMAC1); + case 0356 : CASE356: AREF2; + case 0357 : CASE357: ASET2; + + case 0360 : CASE360: { + if(TOPOFSTACK == POP_TOS_1) + TOPOFSTACK = ATOM_T; + else TOPOFSTACK = NIL_PTR; + nextop1; + } + + case 0361 : CASE361: IGREATERP; /* IGREATERP if no float */ + case 0362 : CASE362: FGREATERP; + case 0363 : CASE363: GREATERP; + case 0364 : CASE364: ILEQUAL; + case 0365 : CASE365: MAKENUMBER; + case 0366 : CASE366: BOXIPLUS; + case 0367 : CASE367: BOXIDIFFERENCE; + case 0370 : CASE370: { goto op_ufn; } /* FLOATBLT */ + case 0371 : CASE371: { goto op_ufn; } /* FFTSTEP */ + case 0372 : CASE372: MISC3(Get_BYTE_PCMAC1); + case 0373 : CASE373: MISC4(Get_BYTE_PCMAC1); + case 0374 : CASE374: { goto op_ufn; } /* upctrace */ + case 0375 : CASE375: SWAP; + case 0376 : CASE376: NOP; + case 0377 : CASE377: CLARITHEQUAL; +#ifdef OPDISP +#ifdef ISC +case 0400 : goto setup_table; /* to defeat optimizer, so optable exists */ +#elif (DOS && OPDISP) +case 0400: goto setup_table; +#endif /* ISC */ + +#endif /* OPDISP */ + + + +#ifdef I386 + /* to defeat the damn optimizer, make it look like */ + /* we might branch to the error labels. */ + case 0400 : goto plus_err; + case 0401 : goto iplus_err; + case 0402 : goto iplusn_err; + case 0403 : goto idiff_err; + case 0404 : goto diff_err; + case 0405 : goto idiffn_err; + case 0406 : goto greaterp_err; + case 0411 : goto igreaterp_err; + case 0407 : goto llsh8_err; + case 0410 : goto lrsh1_err; + case 0414 : goto lrsh8_err; + case 0417 : goto llsh1_err; + case 0413 : goto logor_err; + case 0412 : goto logand_err; + case 0416 : goto logxor_err; + case 0415 : goto addbase_err; +#endif + + default: error("should not default"); + + } /* switch */ + +#ifdef NATIVETRAN +/************************************************************************/ +/* NATIVE CODE INTERFACE */ +/************************************************************************/ + + +/* FORIEGN -> DISPATCH */ +/* Return to current frame ext */ + +c_ret_to_dispatch: + asm(" .globl _c_ret_to_dispatch"); + asm("_c_ret_to_dispatch:"); + PCMACL = (ByteCode *) FuncObj + BCE_CURRENTFX->pc; + goto ret_to_dispatch; /* assume optimizer will remove */ + +/* NATIVE -> DISPATCH */ +/* Return to current frame ext */ + +ret_to_dispatch: + asm(" .globl _ret_to_dispatch"); + asm("_ret_to_dispatch:"); + RET_FROM_NATIVE; + nextop0; + +/* NATIVE -> DISPATCH */ +/* Execute opcode in current frame ext */ + +ret_to_unimpl: + asm(" .globl _ret_to_unimpl"); + asm("_ret_to_unimpl:"); + SaveD6 = 0x100; + /* HACK. Reg. d6 is set to dispatch to native_check */ + /* so need to do switch instead of dispatch! */ + RET_FROM_NATIVE; + goto nextopcode; + +/* NATIVE -> UFN(PC) */ + +ret_to_ufn: + asm(" .globl _ret_to_ufn"); + asm("_ret_to_ufn:"); + RET_FROM_NATIVE; + goto op_ufn; + +/* DISPATCH -> NATIVE? */ +/* Return to current frame ext? */ + +native_check: + SaveD6 = 0; + NATIVE_NEXTOP0; + +/* NATIVE -> TIMER */ +/* Return to Execute timer interrupt */ + +ret_to_timer: + asm("_ret_to_timer:"); + asm(" .globl _ret_to_timer"); + SaveD6 = 0x100; + RET_FROM_NATIVE; + goto check_interrupt; /* assume optimizer will remove */ + +#else + +native_check: + +#ifndef DOS +#ifdef OPDISP + SaveD6 = 0x000; +#endif +#endif /* DOS */ + goto nextopcode; +#endif + +/************************************************************************/ +/* TIMER INTERRUPT CHECK ROUTINE */ +/************************************************************************/ +check_interrupt: +#if (defined(NATIVETRAN) || defined(SUN3_OS3_OR_OS4_IL) || defined(I386) || defined(ISC)) + asm_label_check_interrupt(); +#endif + + if ( (UNSIGNED)CSTKPTR > (UNSIGNED)EndSTKP ) + {EXT; + error("Unrecoverable Stack Overflow"); + RET; + } + + /* Check for an IRQ request */ + +{register int need_irq; + static int period_cnt=60; +extern int KBDEventFlg; +extern int ETHEREventCount; +extern LispPTR DOBUFFEREDTRANSITION_index; +extern LispPTR INTERRUPTFRAME_index; +extern LispPTR *KEYBUFFERING68k; +extern LispPTR *PENDINGINTERRUPT68k; +extern LispPTR ATOM_STARTED; +extern LispPTR *PERIODIC_INTERRUPT68k; +extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; +extern LispPTR PERIODIC_INTERRUPTFRAME_index; +extern LispPTR *Reclaim_cnt_word; +extern LispPTR DORECLAIM_index; +extern int URaid_req; + + /* Check for an Stack Overflow */ +/* JDS 22 May 96 -- >= below used to be just >, changed because we got + stack oflows with last frame right at end of stack, leading to loops, + odd bugs, ... */ +/**** Changed back to > 31 July 97 ****/ +re_check_stack: + need_irq = 0; + if ( ((UNSIGNED)(CSTKPTR+1) > Irq_Stk_Check) && + (Irq_Stk_End > 0) && + (Irq_Stk_Check > 0) ) + { + HARD_PUSH(TOPOFSTACK); + EXT; + extended_frame = NIL; + if (do_stackoverflow(NIL)) { +stackoverflow_help: + period_cnt=60; need_irq = T; + error("Stack Overflow, MUST HARDRESET!"); + RET; TOPOFSTACK = NIL_PTR; + } + else { RET; POP; } + Irq_Stk_Check = (UNSIGNED)EndSTKP-STK_MIN(FuncObj); + need_irq = (Irq_Stk_End == 0) || extended_frame; + *PENDINGINTERRUPT68k |= extended_frame; + Irq_Stk_End = (UNSIGNED) EndSTKP; + } + + /* Check for an IRQ request */ + + if ((Irq_Stk_End <= 0) || (Irq_Stk_Check <= 0) || need_irq) { + if (StkOffset_from_68K(CSTKPTR) > InterfacePage->stackbase) { + + /* Interrupts not Disabled */ +#ifndef KBINT + getsignaldata(); +#endif + EXT; + update_timer(); + + /*** If SPY is running, check to see if it ***/ + /*** needs an interrupt; give it one, if so. ***/ + if(*PERIODIC_INTERRUPT68k!=NIL) + { + if(period_cnt>0) period_cnt--; + else + { + cause_interruptcall(PERIODIC_INTERRUPTFRAME_index); + if(*PERIODIC_INTERRUPT_FREQUENCY68k==NIL) + period_cnt=0; + else + period_cnt=(*PERIODIC_INTERRUPT_FREQUENCY68k & 0xffff) + *(1000000/60) /TIMER_INTERVAL; + /* number of 1/60 second periods between interrupts. + TIMER_INTERVAL is the number of microseconds between + timer interrupts. The calculation here avoids some + overflow errors although there is some roundoff + if the interrupt frequency number is too low, + it will bottom out and just set period_cnt to 0 */ + } + } + + +#ifdef DOS + if(currentkbd->URaid == TRUE){ + currentkbd->URaid = NIL; + (currentkbd->device.exit)(currentkbd); /* Install the original handler */ + error("Call URaid by User Interrupt"); + } + else if(currentmouse->Cursor.Moved){ + union REGS regs; + + currentdsp->device.locked++; + + /* Remove the mouse from the old place on the screen */ + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); + + /* Find the new delta */ + regs.w.eax = 0x000B; /* Function 0xB = get delta mickeys */ + int86(0x33, ®s, ®s); + currentmouse->Cursor.New.x += (short)regs.w.ecx; + currentmouse->Cursor.New.y += (short)regs.w.edx; + + if(currentmouse->Cursor.New.x < 0) + currentmouse->Cursor.New.x = 0; + else if(currentmouse->Cursor.New.x > (currentdsp->Display.width - 1)) + currentmouse->Cursor.New.x = currentdsp->Display.width - 1; + + if(currentmouse->Cursor.New.y < 0) + currentmouse->Cursor.New.y = 0; + else if(currentmouse->Cursor.New.y > (currentdsp->Display.height - 1)) + currentmouse->Cursor.New.y = currentdsp->Display.height - 1; + + IOPage68K->dlmousex = + IOPage68K->dlcursorx = + currentmouse->Cursor.New.x; + IOPage68K->dlmousey = + IOPage68K->dlcursory = + currentmouse->Cursor.New.y; + + /* Paint the mouse back up on the screen on the new place */ + (currentdsp->mouse_vissible)( currentmouse->Cursor.New.x, + currentmouse->Cursor.New.y); + currentmouse->Cursor.Moved = FALSE; + currentdsp->device.locked--; + } + +#else + if(URaid_req ==T){ + URaid_req=NIL; + error("Call URaid by User Interrupt"); + } +#endif /* DOS */ + else if((KBDEventFlg>0)&&(*KEYBUFFERING68k==ATOM_T)) { + *KEYBUFFERING68k= ATOM_STARTED; + cause_interruptcall(DOBUFFEREDTRANSITION_index); + KBDEventFlg --; + } + else if(*Reclaim_cnt_word == S_POSITIVE) { + *Reclaim_cnt_word=NIL; + cause_interruptcall(DORECLAIM_index); + } + else if (*PENDINGINTERRUPT68k!=NIL) + { INTSTAT2 * intstate = ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + unsigned char newints = (intstate->pendingmask) & ~(intstate->handledmask); + /* if (newints) */ + { + intstate->handledmask |= intstate->pendingmask; + *PENDINGINTERRUPT68k=NIL; + cause_interruptcall(INTERRUPTFRAME_index); + } + } + else if (ETHEREventCount>0) + { INTSTAT * intstate = ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + if (!(intstate->ETHERInterrupt) && + !(((INTSTAT2 *)intstate)->handledmask & 0x40)) + { + intstate->ETHERInterrupt=1; + ((INTSTAT2 *)intstate)->handledmask |= + ((INTSTAT2 *)intstate)->pendingmask; + cause_interruptcall(INTERRUPTFRAME_index); + ETHEREventCount--; + } + else *PENDINGINTERRUPT68k = ATOM_T; + } + RET; + CLR_IRQ; + } /* Interrupts not Disabled */ + else { + /* Clear out IRQ (loses pending interrupt request + if interrupts are disabled) */ + CLR_IRQ; + goto re_check_stack; + } + } + +} + + nextop0; + + +/************************************************************************/ +/* Common Jump Tails (they have to jump anyway, so use common Tail) */ +/************************************************************************/ +PopNextop1: + POP; + nextop1; + +PopNextop2: + POP; + nextop2; + +/************************************************************************/ +/* */ +/* Set up the dispatch table for use when we do assembler */ +/* optimization of the dispatch-jump sequence. */ +/* */ +/* */ +/************************************************************************/ + +#ifdef OPDISP + setup_table: +#ifndef ISC + SaveD6 = 0; + +#ifdef UNSAFE + Save_D5_shift_amount = 15; +#endif + + + {int i; for (i = 0; i < 256; i++) { table[i] = (InstPtr) op_ufn; };} + {int i; for (i = 256; i < 512; i++) + { table[i] = (InstPtr) native_check; }; + } + table[001] = (InstPtr) case001; + table[002] = (InstPtr) case002; + table[003] = (InstPtr) case003; + table[004] = (InstPtr) case004; + table[005] = (InstPtr) case005; + table[006] = (InstPtr) case006; + table[007] = (InstPtr) case007; + table[010] = (InstPtr) case010; + table[011] = (InstPtr) case011; + table[012] = (InstPtr) case012; + table[013] = (InstPtr) case013; + table[014] = (InstPtr) case014; + table[015] = (InstPtr) case015; + table[016] = (InstPtr) case016; + table[017] = (InstPtr) case017; + table[020] = (InstPtr) case020; + table[021] = (InstPtr) case021; + table[022] = (InstPtr) case022; + table[023] = (InstPtr) case023; + table[024] = (InstPtr) case024; + table[025] = (InstPtr) case025; + table[026] = (InstPtr) case026; + table[027] = (InstPtr) case027; + table[030] = (InstPtr) case030; + table[031] = (InstPtr) case031; + table[032] = (InstPtr) case032; + table[033] = (InstPtr) case033; + table[034] = (InstPtr) case034; + table[035] = (InstPtr) case035; + table[036] = (InstPtr) case036; + table[037] = (InstPtr) case037; + table[040] = (InstPtr) case040; + table[041] = (InstPtr) case041; + table[042] = (InstPtr) case042; + table[043] = (InstPtr) case043; + table[044] = (InstPtr) case044; + table[045] = (InstPtr) case045; + table[046] = (InstPtr) case046; + table[047] = (InstPtr) case047; + + table[054] = (InstPtr) case054; + table[055] = (InstPtr) case055; + table[056] = (InstPtr) case056; + table[057] = (InstPtr) case057; + + table[062] = (InstPtr) case062; + table[063] = (InstPtr) case063; + + table[070] = (InstPtr) case070; + + table[072] = (InstPtr) case072; + table[073] = (InstPtr) case073; + table[074] = (InstPtr) case074; + table[075] = (InstPtr) case075; + + table[0100] = (InstPtr) case100; + table[0101] = (InstPtr) case101; + table[0102] = (InstPtr) case102; + table[0103] = (InstPtr) case103; + table[0104] = (InstPtr) case104; + table[0105] = (InstPtr) case105; + table[0106] = (InstPtr) case106; + table[0107] = (InstPtr) case107; + table[0110] = (InstPtr) case110; + table[0111] = (InstPtr) case111; + table[0112] = (InstPtr) case112; + table[0113] = (InstPtr) case113; + table[0114] = (InstPtr) case114; + table[0115] = (InstPtr) case115; + table[0116] = (InstPtr) case116; + table[0117] = (InstPtr) case117; + table[0120] = (InstPtr) case120; + table[0121] = (InstPtr) case121; + table[0122] = (InstPtr) case122; + table[0123] = (InstPtr) case123; + table[0124] = (InstPtr) case124; + table[0125] = (InstPtr) case125; + table[0126] = (InstPtr) case126; + table[0127] = (InstPtr) case127; + table[0130] = (InstPtr) case130; + table[0131] = (InstPtr) case131; + table[0132] = (InstPtr) case132; + table[0133] = (InstPtr) case133; + table[0134] = (InstPtr) case134; + table[0135] = (InstPtr) case135; + table[0136] = (InstPtr) case136; + table[0137] = (InstPtr) case137; + table[0140] = (InstPtr) case140; + table[0141] = (InstPtr) case141; + table[0142] = (InstPtr) case142; + table[0143] = (InstPtr) case143; + table[0144] = (InstPtr) case144; + table[0145] = (InstPtr) case145; + table[0146] = (InstPtr) case146; + table[0147] = (InstPtr) case147; + table[0150] = (InstPtr) case150; + table[0151] = (InstPtr) case151; + table[0152] = (InstPtr) case152; + table[0153] = (InstPtr) case153; + table[0154] = (InstPtr) case154; + table[0155] = (InstPtr) case155; + table[0156] = (InstPtr) case156; + table[0157] = (InstPtr) case157; + table[0160] = (InstPtr) case160; + table[0161] = (InstPtr) case161; + table[0162] = (InstPtr) case162; + table[0163] = (InstPtr) case163; + table[0164] = (InstPtr) case164; + table[0165] = (InstPtr) case165; + table[0166] = (InstPtr) case166; + table[0167] = (InstPtr) case167; + table[0170] = (InstPtr) case170; + table[0171] = (InstPtr) case171; + table[0172] = (InstPtr) case172; + table[0173] = (InstPtr) case173; + table[0174] = (InstPtr) case174; + table[0175] = (InstPtr) case175; + table[0176] = (InstPtr) case176; + table[0177] = (InstPtr) case177; + table[0200] = (InstPtr) case200; + table[0201] = (InstPtr) case201; + table[0202] = (InstPtr) case202; + table[0203] = (InstPtr) case203; + table[0204] = (InstPtr) case204; + table[0205] = (InstPtr) case205; + table[0206] = (InstPtr) case206; + table[0207] = (InstPtr) case207; + table[0210] = (InstPtr) case210; + table[0211] = (InstPtr) case211; + table[0212] = (InstPtr) case212; + table[0213] = (InstPtr) case213; + table[0214] = (InstPtr) case214; + table[0215] = (InstPtr) case215; + table[0216] = (InstPtr) case216; + table[0217] = (InstPtr) case217; + table[0220] = (InstPtr) case220; + table[0221] = (InstPtr) case221; + table[0222] = (InstPtr) case222; + table[0223] = (InstPtr) case223; + table[0224] = (InstPtr) case224; + table[0225] = (InstPtr) case225; + table[0226] = (InstPtr) case226; + table[0227] = (InstPtr) case227; + table[0230] = (InstPtr) case230; + table[0231] = (InstPtr) case231; + table[0232] = (InstPtr) case232; + table[0233] = (InstPtr) case233; + table[0234] = (InstPtr) case234; + table[0235] = (InstPtr) case235; + table[0236] = (InstPtr) case236; + table[0237] = (InstPtr) case237; + table[0240] = (InstPtr) case240; + table[0241] = (InstPtr) case241; + table[0242] = (InstPtr) case242; + table[0243] = (InstPtr) case243; + table[0244] = (InstPtr) case244; + table[0245] = (InstPtr) case245; + table[0246] = (InstPtr) case246; + table[0247] = (InstPtr) case247; + table[0250] = (InstPtr) case250; + table[0251] = (InstPtr) case251; + table[0252] = (InstPtr) case252; + table[0253] = (InstPtr) case253; + table[0254] = (InstPtr) case254; + table[0255] = (InstPtr) case255; + table[0256] = (InstPtr) case256; + table[0257] = (InstPtr) case257; + table[0260] = (InstPtr) case260; + table[0261] = (InstPtr) case261; + table[0262] = (InstPtr) case262; + table[0263] = (InstPtr) case263; + table[0264] = (InstPtr) case264; + table[0265] = (InstPtr) case265; + table[0266] = (InstPtr) case266; + table[0267] = (InstPtr) case267; + table[0270] = (InstPtr) case270; + table[0271] = (InstPtr) case271; + table[0272] = (InstPtr) case272; + table[0273] = (InstPtr) case273; + table[0274] = (InstPtr) case274; + table[0275] = (InstPtr) case275; + table[0276] = (InstPtr) case276; + table[0277] = (InstPtr) case277; + table[0300] = (InstPtr) case300; + table[0301] = (InstPtr) case301; + table[0302] = (InstPtr) case302; + table[0303] = (InstPtr) case303; + table[0304] = (InstPtr) case304; + table[0305] = (InstPtr) case305; + table[0306] = (InstPtr) case306; + table[0307] = (InstPtr) case307; + table[0310] = (InstPtr) case310; + table[0311] = (InstPtr) case311; + table[0312] = (InstPtr) case312; + table[0313] = (InstPtr) case313; + table[0314] = (InstPtr) case314; + table[0315] = (InstPtr) case315; + table[0316] = (InstPtr) case316; + table[0317] = (InstPtr) case317; + table[0320] = (InstPtr) case320; + table[0321] = (InstPtr) case321; + table[0322] = (InstPtr) case322; + table[0323] = (InstPtr) case323; + table[0324] = (InstPtr) case324; + table[0325] = (InstPtr) case325; + table[0326] = (InstPtr) case326; + table[0327] = (InstPtr) case327; + table[0330] = (InstPtr) case330; + table[0331] = (InstPtr) case331; + table[0332] = (InstPtr) case332; + table[0333] = (InstPtr) case333; + table[0334] = (InstPtr) case334; + table[0335] = (InstPtr) case335; + table[0336] = (InstPtr) case336; + table[0337] = (InstPtr) case337; + table[0340] = (InstPtr) case340; + table[0341] = (InstPtr) case341; + table[0342] = (InstPtr) case342; + table[0343] = (InstPtr) case343; + table[0344] = (InstPtr) case344; + table[0345] = (InstPtr) case345; + table[0346] = (InstPtr) case346; + table[0347] = (InstPtr) case347; + table[0350] = (InstPtr) case350; + table[0351] = (InstPtr) case351; + table[0352] = (InstPtr) case352; + table[0353] = (InstPtr) case353; + table[0354] = (InstPtr) case354; + table[0355] = (InstPtr) case355; + table[0356] = (InstPtr) case356; + table[0357] = (InstPtr) case357; + table[0360] = (InstPtr) case360; + table[0361] = (InstPtr) case361; + table[0362] = (InstPtr) case362; + table[0363] = (InstPtr) case363; + table[0364] = (InstPtr) case364; + table[0365] = (InstPtr) case365; + table[0366] = (InstPtr) case366; + table[0367] = (InstPtr) case367; + table[0370] = (InstPtr) case370; + table[0371] = (InstPtr) case371; + table[0372] = (InstPtr) case372; + table[0373] = (InstPtr) case373; + table[0374] = (InstPtr) case374; + table[0375] = (InstPtr) case375; + table[0376] = (InstPtr) case376; + table[0377] = (InstPtr) case377; + goto nextopcode; +#elif GCC385 + /* This is the optable for 386's under gcc */ + +asm volatile(" .data \n\ + .align 4"); +asm volatile("optable: \n\ + .long _op000 \n\ + .long _op001 \n\ + .long _op002 \n\ + .long _op003 \n\ + .long _op004 \n\ + .long _op005 \n\ + .long _op006 \n\ + .long _op007 \n\ + .long _op010 \n\ + .long _op011 \n\ + .long _op012 \n\ + .long _op013 \n\ + .long _op014 \n\ + .long _op015 \n\ + .long _op016 \n\ + .long _op017 \n\ + .long _op020 \n\ + .long _op021 \n\ + .long _op022 \n\ + .long _op023 \n\ + .long _op024 \n\ + .long _op025 \n\ + .long _op026 \n\ + .long _op027 \n\ + .long _op030 \n\ + .long _op031 \n\ + .long _op032 \n\ + .long _op033 \n\ +"); + +asm volatile("\n\ + .long _op034 \n\ + .long _op035 \n\ + .long _op036 \n\ + .long _op037 \n\ + .long _op040 \n\ + .long _op041 \n\ + .long _op042 \n\ + .long _op043 \n\ + .long _op044 \n\ + .long _op045 \n\ + .long _op046 \n\ + .long _op047 \n\ + .long _op050 \n\ + .long _op051 \n\ + .long _op052 \n\ + .long _op053 \n\ + .long _op054 \n\ + .long _op055 \n\ + .long _op056 \n\ + .long _op057 \n\ + .long _op060 \n\ + .long _op061 \n\ + .long _op062 \n\ + .long _op063 \n\ + .long _op064 \n\ + .long _op065 \n\ + .long _op066 \n\ + .long _op067 \n\ + .long _op070 \n\ + .long _op071 \n\ + .long _op072 \n\ + .long _op073 \n\ + .long _op074 \n\ + .long _op075 \n\ + .long _op076 \n\ + .long _op077 \n\ + .long _op100 \n\ + .long _op101 \n\ + .long _op102 \n\ + .long _op103 \n\ + .long _op104 \n\ + .long _op105 \n\ + .long _op106 \n\ + .long _op107 \n\ + .long _op110 \n\ + .long _op111 \n\ + .long _op112 \n\ + .long _op113 \n\ + .long _op114 \n\ + .long _op115 \n\ + .long _op116 \n\ + .long _op117 \n\ + .long _op120 \n\ + .long _op121 \n\ + .long _op122 \n\ + .long _op123 \n\ + .long _op124 \n\ + .long _op125 \n\ + .long _op126 \n\ + .long _op127 \n\ + .long _op130 \n\ + .long _op131 \n\ + .long _op132 \n\ + .long _op133 \n\ + .long _op134 \n\ + .long _op135 \n\ + .long _op136 \n\ + .long _op137 \n\ + .long _op140 \n\ + .long _op141 \n\ + .long _op142 \n\ + .long _op143 \n\ + .long _op144 \n\ + .long _op145 \n\ + .long _op146 \n\ + .long _op147 \n\ + .long _op150 \n\ + .long _op151 \n\ + .long _op152 \n\ + .long _op153 \n\ + .long _op154 \n\ + .long _op155 \n\ + .long _op156 \n\ + .long _op157 \n\ + .long _op160 \n\ + .long _op161 \n\ + .long _op162 \n\ + .long _op163 \n\ + .long _op164 \n\ + .long _op165 \n\ + .long _op166 \n\ + .long _op167 \n\ + .long _op170 \n\ + .long _op171 \n\ + .long _op172 \n\ + .long _op173 \n\ + .long _op174 \n\ + .long _op175 \n\ + .long _op176 \n\ + .long _op177 \n\ + .long _op200 \n\ + .long _op201 \n\ + .long _op202 \n\ + .long _op203 \n\ + .long _op204 \n\ + .long _op205 \n\ + .long _op206 \n\ + .long _op207 \n\ + .long _op210 \n\ + .long _op211 \n\ + .long _op212 \n\ + .long _op213 \n\ + .long _op214 \n\ + .long _op215 \n\ + .long _op216 \n\ + .long _op217 \n\ + .long _op220 \n\ + .long _op221 \n\ + .long _op222 \n\ + .long _op223 \n\ + .long _op224 \n\ + .long _op225 \n\ + .long _op226 \n\ + .long _op227 \n\ + .long _op230 \n\ + .long _op231 \n\ + .long _op232 \n\ + .long _op233 \n\ + .long _op234 \n\ + .long _op235 \n\ + .long _op236 \n\ + .long _op237 \n\ + .long _op240 \n\ + .long _op241 \n\ + .long _op242 \n\ + .long _op243 \n\ + .long _op244 \n\ + .long _op245 \n\ + .long _op246 \n\ + .long _op247 \n\ + .long _op250 \n\ + .long _op251 \n\ + .long _op252 \n\ + .long _op253 \n\ + .long _op254 \n\ + .long _op255 \n\ + .long _op256 \n\ + .long _op257 \n\ + .long _op260 \n\ + .long _op261 \n\ + .long _op262 \n\ + .long _op263 \n\ + .long _op264 \n\ + .long _op265 \n\ + .long _op266 \n\ + .long _op267 \n\ + .long _op270 \n\ + .long _op271 \n\ + .long _op272 \n\ + .long _op273 \n\ + .long _op274 \n\ + .long _op275 \n\ + .long _op276 \n\ + .long _op277 \n\ + .long _op300 \n\ + .long _op301 \n\ + .long _op302 \n\ + .long _op303 \n\ + .long _op304 \n\ + .long _op305 \n\ + .long _op306 \n\ + .long _op307 \n\ + .long _op310 \n\ + .long _op311 \n\ + .long _op312 \n\ + .long _op313 \n\ + .long _op314 \n\ + .long _op315 \n\ + .long _op316 \n\ + .long _op317 \n\ + .long _op320 \n\ + .long _op321 \n\ + .long _op322 \n\ + .long _op323 \n\ + .long _op324 \n\ + .long _op325 \n\ + .long _op326 \n\ + .long _op327 \n\ + .long _op330 \n\ + .long _op331 \n\ + .long _op332 \n\ + .long _op333 \n\ + .long _op334 \n\ + .long _op335 \n\ + .long _op336 \n\ + .long _op337 \n\ + .long _op340 \n\ + .long _op341 \n\ + .long _op342 \n\ + .long _op343 \n\ + .long _op344 \n\ + .long _op345 \n\ + .long _op346 \n\ + .long _op347 \n\ + .long _op350 \n\ + .long _op351 \n\ + .long _op352 \n\ + .long _op353 \n\ + .long _op354 \n\ + .long _op355 \n\ + .long _op356 \n\ + .long _op357 \n\ + .long _op360 \n\ + .long _op361 \n\ + .long _op362 \n\ + .long _op363 \n\ + .long _op364 \n\ + .long _op365 \n\ + .long _op366 \n\ + .long _op367 \n\ + .long _op370 \n\ + .long _op371 \n\ + .long _op372 \n\ + .long _op373 \n\ + .long _op374 \n\ + .long _op375 \n\ + .long _op376 \n\ + .long _op377 \n\ + .text"); + +#elif (DOS && OPDISP) + /* This is the optable for 386's under gcc & Turbo Assembler */ + +asm volatile(" align 4"); +asm volatile("optable: \n\ + DD _op000 \n\ + DD _op001 \n\ + DD _op002 \n\ + DD _op003 \n\ + DD _op004 \n\ + DD _op005 \n\ + DD _op006 \n\ + DD _op007 \n\ + DD _op010 \n\ + DD _op011 \n\ + DD _op012 \n\ + DD _op013 \n\ + DD _op014 \n\ + DD _op015 \n\ + DD _op016 \n\ + DD _op017 \n\ + DD _op020 \n\ + DD _op021 \n\ + DD _op022 \n\ + DD _op023 \n\ + DD _op024 \n\ + DD _op025 \n\ + DD _op026 \n\ + DD _op027 \n\ + DD _op030 \n\ + DD _op031 \n\ + DD _op032 \n\ + DD _op033 \n\ +"); + +asm volatile("\n\ + DD _op034 \n\ + DD _op035 \n\ + DD _op036 \n\ + DD _op037 \n\ + DD _op040 \n\ + DD _op041 \n\ + DD _op042 \n\ + DD _op043 \n\ + DD _op044 \n\ + DD _op045 \n\ + DD _op046 \n\ + DD _op047 \n\ + DD _op050 \n\ + DD _op051 \n\ + DD _op052 \n\ + DD _op053 \n\ + DD _op054 \n\ + DD _op055 \n\ + DD _op056 \n\ + DD _op057 \n\ + DD _op060 \n\ + DD _op061 \n\ + DD _op062 \n\ + DD _op063 \n\ + DD _op064 \n\ + DD _op065 \n\ + DD _op066 \n\ + DD _op067 \n\ + DD _op070 \n\ + DD _op071 \n\ + DD _op072 \n\ + DD _op073 \n\ + DD _op074 \n\ + DD _op075 \n\ + DD _op076 \n\ + DD _op077 \n\ + DD _op100 \n\ + DD _op101 \n\ + DD _op102 \n\ + DD _op103 \n\ + DD _op104 \n\ + DD _op105 \n\ + DD _op106 \n\ + DD _op107 \n\ + DD _op110 \n\ + DD _op111 \n\ + DD _op112 \n\ + DD _op113 \n\ + DD _op114 \n\ + DD _op115 \n\ + DD _op116 \n\ + DD _op117 \n\ + DD _op120 \n\ + DD _op121 \n\ + DD _op122 \n\ + DD _op123 \n\ + DD _op124 \n\ + DD _op125 \n\ + DD _op126 \n\ + DD _op127 \n\ + DD _op130 \n\ + DD _op131 \n\ + DD _op132 \n\ + DD _op133 \n\ + DD _op134 \n\ + DD _op135 \n\ + DD _op136 \n\ + DD _op137 \n\ + DD _op140 \n\ + DD _op141 \n\ + DD _op142 \n\ + DD _op143 \n\ + DD _op144 \n\ + DD _op145 \n\ + DD _op146 \n\ + DD _op147 \n\ + DD _op150 \n\ + DD _op151 \n\ + DD _op152 \n\ + DD _op153 \n\ + DD _op154 \n\ + DD _op155 \n\ + DD _op156 \n\ + DD _op157 \n\ + DD _op160 \n\ + DD _op161 \n\ + DD _op162 \n\ + DD _op163 \n\ + DD _op164 \n\ + DD _op165 \n\ + DD _op166 \n\ + DD _op167 \n\ + DD _op170 \n\ + DD _op171 \n\ + DD _op172 \n\ + DD _op173 \n\ + DD _op174 \n\ + DD _op175 \n\ + DD _op176 \n\ + DD _op177 \n\ + DD _op200 \n\ + DD _op201 \n\ + DD _op202 \n\ + DD _op203 \n\ + DD _op204 \n\ + DD _op205 \n\ + DD _op206 \n\ + DD _op207 \n\ + DD _op210 \n\ + DD _op211 \n\ + DD _op212 \n\ + DD _op213 \n\ + DD _op214 \n\ + DD _op215 \n\ + DD _op216 \n\ + DD _op217 \n\ + DD _op220 \n\ + DD _op221 \n\ + DD _op222 \n\ + DD _op223 \n\ + DD _op224 \n\ + DD _op225 \n\ + DD _op226 \n\ + DD _op227 \n\ + DD _op230 \n\ + DD _op231 \n\ + DD _op232 \n\ + DD _op233 \n\ + DD _op234 \n\ + DD _op235 \n\ + DD _op236 \n\ + DD _op237 \n\ + DD _op240 \n\ + DD _op241 \n\ + DD _op242 \n\ + DD _op243 \n\ + DD _op244 \n\ + DD _op245 \n\ + DD _op246 \n\ + DD _op247 \n\ + DD _op250 \n\ + DD _op251 \n\ + DD _op252 \n\ + DD _op253 \n\ + DD _op254 \n\ + DD _op255 \n\ + DD _op256 \n\ + DD _op257 \n\ + DD _op260 \n\ + DD _op261 \n\ + DD _op262 \n\ + DD _op263 \n\ + DD _op264 \n\ + DD _op265 \n\ + DD _op266 \n\ + DD _op267 \n\ + DD _op270 \n\ + DD _op271 \n\ + DD _op272 \n\ + DD _op273 \n\ + DD _op274 \n\ + DD _op275 \n\ + DD _op276 \n\ + DD _op277 \n\ + DD _op300 \n\ + DD _op301 \n\ + DD _op302 \n\ + DD _op303 \n\ + DD _op304 \n\ + DD _op305 \n\ + DD _op306 \n\ + DD _op307 \n\ + DD _op310 \n\ + DD _op311 \n\ + DD _op312 \n\ + DD _op313 \n\ + DD _op314 \n\ + DD _op315 \n\ + DD _op316 \n\ + DD _op317 \n\ + DD _op320 \n\ + DD _op321 \n\ + DD _op322 \n\ + DD _op323 \n\ + DD _op324 \n\ + DD _op325 \n\ + DD _op326 \n\ + DD _op327 \n\ + DD _op330 \n\ + DD _op331 \n\ + DD _op332 \n\ + DD _op333 \n\ + DD _op334 \n\ + DD _op335 \n\ + DD _op336 \n\ + DD _op337 \n\ + DD _op340 \n\ + DD _op341 \n\ + DD _op342 \n\ + DD _op343 \n\ + DD _op344 \n\ + DD _op345 \n\ + DD _op346 \n\ + DD _op347 \n\ + DD _op350 \n\ + DD _op351 \n\ + DD _op352 \n\ + DD _op353 \n\ + DD _op354 \n\ + DD _op355 \n\ + DD _op356 \n\ + DD _op357 \n\ + DD _op360 \n\ + DD _op361 \n\ + DD _op362 \n\ + DD _op363 \n\ + DD _op364 \n\ + DD _op365 \n\ + DD _op366 \n\ + DD _op367 \n\ + DD _op370 \n\ + DD _op371 \n\ + DD _op372 \n\ + DD _op373 \n\ + DD _op374 \n\ + DD _op375 \n\ + DD _op376 \n\ + DD _op377"); + asm volatile("\n\ +FP_noint: DW 003fh ;; No interrupts, round to closest, 24bit precision"); + + +#endif /* ISC */ + + +#endif /* OPDISP */ + + + } + + +int retfun(void) {return(0);} +do_brk(void) {} + diff --git a/src/xcursor.c b/src/xcursor.c new file mode 100755 index 0000000..b7dd117 --- /dev/null +++ b/src/xcursor.c @@ -0,0 +1,299 @@ +/* $Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-1995, 2000 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include + +#include +#include +#include "xdefs.h" + +#include "lispemul.h" +#include "iopage.h" +#include "display.h" +#include "dbprint.h" +#include "devif.h" + +extern IOPAGE *IOPage; + +extern XGCValues gcv; +extern int Lisp_Xinitialized + , Bitmap_Pad + , Default_Depth; + +XImage CursorImage; +Pixmap CursorPixmap_source + , CursorPixmap_mask; +GC cursor_source_gc + , cursor_mask_gc; +XColor cursor_fore_xcsd + , cursor_back_xcsd + , xced; +extern Colormap Colors; + +extern DspInterface currentdsp; +/* a simple linked list to remember X cursors */ +struct MXCURSOR { + struct MXCURSOR *next; + DLword bitmap[CURSORHEIGHT]; + Cursor Xid; +} *cursorlist = NULL; + +/* +Cursor LispCursor[2]; +int cursor_sw; +*/ + +/* Hotspot X and Y values for current cursor. SUBTRACT these from */ +/* mouse positions before reporting them upward to the sysout, and */ +/* ADD these to the positions we get in SetMouseXY calls. This */ +/* way, X and lisp agree where the mouse is */ + +int Current_Hot_X = 0, + Current_Hot_Y = 0; + + +/************************************************************************/ +/* */ +/* I n i t _ X C u r s o r */ +/* */ +/* Initial setup for X cursor handling--create an initial */ +/* cursor, and get it displayed. */ +/* */ +/************************************************************************/ + +Init_XCursor() +{ + int i; + DLword *newbm = (DLword *) (IOPage->dlcursorbitmap); + + TPRINT(( "TRACE: Init_DisplayCursor()\n" )); + /* this is guaranteed to be our first cursor, isn't it? */ + cursorlist = (struct MXCURSOR *) malloc(sizeof(struct MXCURSOR)); + cursorlist->next = NULL; + for(i=0; ibitmap[i] = newbm[i]; + set_Xcursor( currentdsp, newbm, 0, 0, &(cursorlist->Xid), 1); + DefineCursor(currentdsp->display_id, + currentdsp->DisplayWindow, + &(cursorlist->Xid)); +} /* end Init_XCursor */ + + + + + + +/************************************************************************/ +/* */ +/* S e t _ X C u r s o r */ +/* */ +/* Set the X cursor from the Lisp bitmap, with hot spot at x,y */ +/* */ +/* WARNING: If you call this function inside the C code to change */ +/* the cursor or flip a cursor bar, DON'T just use */ +/* Current_Hot_Y as the 2nd arg. Instead use */ +/* "15-Current_Hot_Y", because this function SETS C_H_Y */ +/* to 15-its 2nd arg. This has led to cursor-alignment */ +/* bugs in the past. */ +/* */ +/************************************************************************/ + +Set_XCursor( x, y ) + int x, y; +{ + /* compare cursor in IOPage memory with cursors we've seen before */ + register struct MXCURSOR *clp, *clbp; + register DLword *newbm = ((DLword *) (IOPage->dlcursorbitmap)); + register int i; + + + XLOCK; /* No signals while setting the cursor */ + for(clp = cursorlist; clp != NULL; clbp = clp, clp = clp->next) { + for(i=0; i< CURSORHEIGHT; i++) + if(clp->bitmap[i] != newbm[i]) break; + if(i == CURSORHEIGHT) break; + } + + if(clp == NULL) { /* it isn't there, push on a new one */ + clp = (struct MXCURSOR *) malloc(sizeof (struct MXCURSOR)); + /* and fill it up with the current new cursor */ + for(i=0; i< CURSORHEIGHT; i++) + clp->bitmap[i] = newbm[i]; +#ifdef NEWXCURSOR + /* JDS 000521 Added "15-" to fix cursor troubles at window edge */ + set_Xcursor( currentdsp, newbm, x, 15-y, &(clp->Xid), 1); +#else + set_Xcursor( currentdsp, newbm, 0, 0, &(clp->Xid), 1); +#endif /* NEWXCURSOR */ + clp->next = cursorlist; + cursorlist = clp; + } + else + /* found it, move it to the front of the list + (this should reduce search time on the average by keeping + the popular cursors near the front of the list) + */ + if(clp != cursorlist) { /* don't move if it's already there */ + clbp->next = clp->next; + clp->next = cursorlist; + cursorlist = clp; + } + DefineCursor(currentdsp->display_id, + currentdsp->DisplayWindow, + &(clp->Xid)); + XUNLOCK; /* Signals OK now */ + +#ifdef NEWXCURSOR + /* Save the hotspot for later position reporting/setting */ + + Current_Hot_X = x; + Current_Hot_Y = 15-y; /* Added 15- to fix window-edge trouble */ +#endif /* NEWXCURSOR */ + +} /* end Set_XCursor */ + + + + +/************************************************************************/ +/* */ +/* i n i t _ X c u r s o r */ +/* */ +/* Initialization code for X-windows cursors. */ +/* */ +/************************************************************************/ + +init_Xcursor(display, window) + Display *display; +{ + + TPRINT(( "TRACE: init_Xcursor()\n" )); + + XLOCK; /* Take no X signals during this activity (ISC 386) */ + + CursorImage.width = CURSORWIDTH; + CursorImage.height = CURSORHEIGHT; + CursorImage.xoffset = 0; + CursorImage.format = XYBitmap; +#if (defined (XV11R1) || defined(BYTESWAP)) + CursorImage.byte_order = LSBFirst; +#else /* XV11R1 | BYTESWAP */ + CursorImage.byte_order = MSBFirst; +#endif /* XV11R1 | BYTESWAP */ + + CursorImage.bitmap_unit = BITSPER_DLWORD; +#ifdef AIX + CursorImage.bitmap_pad = 32; +#else + CursorImage.bitmap_pad = Bitmap_Pad; +#endif /* AIX */ + CursorImage.depth = 1; + CursorImage.bytes_per_line = BITSPER_DLWORD/8; + CursorImage.bitmap_bit_order = MSBFirst; + + CursorPixmap_source = XCreatePixmap( display, window , CURSORWIDTH, CURSORHEIGHT, 1); + CursorPixmap_mask = XCreatePixmap( display, window , CURSORWIDTH, CURSORHEIGHT, 1); + + gcv.function = GXcopy; + gcv.foreground = BlackPixelOfScreen( ScreenOfDisplay( display, DefaultScreen(display))); + gcv.background = WhitePixelOfScreen( ScreenOfDisplay( display, DefaultScreen(display))); +#ifdef AIX + gcv.plane_mask = 1; +#endif /* AIX */ + + cursor_source_gc = XCreateGC( display, window + , GCForeground|GCBackground|GCFunction +#ifdef AIX + |GCPlaneMask +#endif /* AIX */ + , &gcv ); + cursor_mask_gc = XCreateGC( display, window + , GCForeground|GCBackground|GCFunction +#ifdef AIX + |GCPlaneMask +#endif /* AIX */ + , &gcv ); + + XAllocNamedColor( display, Colors, "black" + , &cursor_fore_xcsd, &xced ); + XAllocNamedColor( display, Colors, "white" + , &cursor_back_xcsd, &xced ); + + XUNLOCK; /* OK to take signals again */ + + } /* end init_Xcursor */ + + + +/************************************************************************/ +/* */ +/* s e t _ X c u r s o r */ +/* */ +/* */ +/* */ +/************************************************************************/ + +set_Xcursor( dsp, bitmap, hotspot_x, hotspot_y, return_cursor, from_lisp ) + DspInterface dsp; + unsigned char *bitmap; + int hotspot_x + , hotspot_y + , from_lisp; + Cursor *return_cursor; +{ + extern unsigned char reversedbits[]; + unsigned char image[32]; + int i; + Pixmap Cursor_src, Cursor_msk; + Screen *screen; + +#ifdef BYTESWAP + if (from_lisp) for (i=0; i<32; i++) image[i] = reversedbits[bitmap[i^3]]; + else for ( i=0; i<32; i++) image[i] = reversedbits[bitmap[i]]; +#else + for ( i=0; i<32; i++) image[i] = reversedbits[bitmap[i]]; +#endif /* BYTESWAP */ + + XLOCK; + screen = ScreenOfDisplay( dsp->display_id, DefaultScreen( dsp->display_id )); + Cursor_src = XCreatePixmapFromBitmapData(dsp->display_id, + dsp->DisplayWindow, + image, 16, 16, 1, 0, + 1); /* Has to have a depth of 1! */ + Cursor_msk = XCreatePixmapFromBitmapData(dsp->display_id, + dsp->DisplayWindow, + image, 16, 16, 1, 0, + 1); /* Has to have a depth of 1! */ + *return_cursor = XCreatePixmapCursor( dsp->display_id + , Cursor_src, Cursor_msk + , &cursor_fore_xcsd, &cursor_back_xcsd + , hotspot_x, hotspot_y ); + + /* Should free these now (doc says server may not copy them) */ + XFreePixmap(dsp->display_id, Cursor_src); + XFreePixmap(dsp->display_id, Cursor_msk); + + XFlush( dsp->display_id ); + XUNLOCK; + +} /* end set_Xcursor */ diff --git a/src/xinit.c b/src/xinit.c new file mode 100755 index 0000000..f78b566 --- /dev/null +++ b/src/xinit.c @@ -0,0 +1,393 @@ +/* $Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include +#include +#include +#include +#include + +#include "lispemul.h" +#include "dbprint.h" + +#include "xdefs.h" +#include "devif.h" + +#include "adr68k.h" + +#ifdef HPUX +#define FASYNC O_NONBLOCK +#endif /* HPUX */ + +#include +#include + +#ifndef APOLLO +#ifndef HPUX +#ifndef ULTRIX +#ifndef LINUX +#include +#endif /* LINUX */ +#endif /* ULTRIX */ +#endif /* HPUX */ +#endif /* APOLLO */ + +#ifdef ISC +#define FASYNC O_NONBLOCK +#define SIGIO SIGPOLL +#endif /* ISC */ + +#define FALSE 0 +#define TRUE !FALSE +#define PERCENT_OF_SCREEN 95 +#define DISPLAY_MAX 65536*16*2 /* same magic number is */ + /* in loadsysout.c */ +extern DLword *Lisp_world; +extern int Lisp_Xinitialized; +extern char Display_Name[128]; +extern DLword *DisplayRegion68k; +int xsync = False; + +int Byte_Order + , Bitmap_Bit_Order + , Bitmap_Pad + , Default_Depth + , Display_Height + , Display_Width; + +int LispWindowRequestedX = 0; +int LispWindowRequestedY = 0; +int LispWindowRequestedWidth = DEF_WIN_WIDTH; +int LispWindowRequestedHeight = DEF_WIN_HEIGHT; + +int LispDisplayRequestedX, + LispDisplayRequestedY, + LispDisplayRequestedWidth, + LispDisplayRequestedHeight; + +Colormap Colors; + +int XLocked = 0; /* non-zero while doing X ops, to avoid signals */ +extern int LispReadFds; +extern PFUL GenericReturnT(); +extern PFUL clipping_Xbitblt(); + +/************************************************************************/ +/* */ +/* i n i t _ X e v e n t */ +/* */ +/* Turn on the X window we've been using for display. */ +/* */ +/************************************************************************/ +void init_Xevent(dsp) + DspInterface dsp; +{ + int GravMask, BarMask, LispMask, DisplayMask; + + GravMask = ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; + BarMask = GravMask; + DisplayMask = GravMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask; + LispMask = StructureNotifyMask; + + + XSelectInput(dsp->display_id, dsp->LispWindow, dsp->EnableEventMask); + XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask); + XSelectInput(dsp->display_id, dsp->HorScrollBar, BarMask); + XSelectInput(dsp->display_id, dsp->VerScrollBar, BarMask); + XSelectInput(dsp->display_id, dsp->HorScrollButton, NoEventMask); + XSelectInput(dsp->display_id, dsp->VerScrollButton, NoEventMask); + XSelectInput(dsp->display_id, dsp->NEGrav, GravMask); + XSelectInput(dsp->display_id, dsp->SEGrav, GravMask); + XSelectInput(dsp->display_id, dsp->SWGrav, GravMask); + XSelectInput(dsp->display_id, dsp->NWGrav, GravMask); + +#ifdef SYSVONLY +#ifndef LINUX + ioctl(ConnectionNumber(dsp->display_id) + , I_SETSIG, S_INPUT); /* so we see X events fast */ +#endif +#endif /* SYSVONLY */ +} /*end init_Xevent */ + +/************************************************************************/ +/* */ +/* l i s p _ X e x i t */ +/* */ +/* Turn off the X window we've been using for display. */ +/* */ +/************************************************************************/ +void lisp_Xexit(dsp) + DspInterface dsp; + { +#ifdef SYSVONLY +#ifndef LINUX + ioctl(ConnectionNumber(dsp->display_id) + , I_SETSIG, 0); /* so no interrupts happen during */ +#endif +#endif /* SYSVONLY */ + + XDestroySubwindows( dsp->display_id, dsp->LispWindow ); + XDestroyWindow( dsp->display_id, dsp->LispWindow ); + XCloseDisplay( dsp->display_id ); + + Lisp_Xinitialized = FALSE; + } /* end lisp_Xexit */ + + +/************************************************************************/ +/* */ +/* X e v e n t _ b e f o r e _ r a i d */ +/* */ +/* Called before Medley enters URAID, to turn off events in */ +/* the X windows we use for Medley's display. */ +/* */ +/************************************************************************/ +void Xevent_before_raid(dsp) + DspInterface dsp; + { + TPRINT(( "TRACE: Xevent_before_raid()\n" )); + + XSelectInput( dsp->display_id, dsp->LispWindow, NoEventMask ); + XSelectInput( dsp->display_id, dsp->DisplayWindow, NoEventMask ); + XSelectInput( dsp->display_id, dsp->VerScrollBar, NoEventMask ); + XSelectInput( dsp->display_id, dsp->HorScrollBar, NoEventMask ); + XSelectInput( dsp->display_id, dsp->NEGrav, NoEventMask); + XSelectInput( dsp->display_id, dsp->SEGrav, NoEventMask); + XSelectInput( dsp->display_id, dsp->SWGrav, NoEventMask); + XSelectInput (dsp->display_id, dsp->NWGrav, NoEventMask); + + XLOCK; + XFlush( dsp->display_id ); + XUNLOCK; + } /* end Xevent_before_raid */ + + + +/************************************************************************/ +/* */ +/* X e v e n t _ a f t e r _ r a i d */ +/* */ +/* Called after Medley returns from URAID, to re-enable events */ +/* from the X server in the windows we use for the display. */ +/* */ +/************************************************************************/ +void Xevent_after_raid(dsp) + DspInterface dsp; +{ + init_Xevent( dsp ); + (dsp->bitblt_to_screen)( dsp, 0, + dsp->Vissible.x, + dsp->Vissible.y, + dsp->Vissible.width, + dsp->Vissible.height ); + XLOCK; + XFlush( dsp->display_id ); + XUNLOCK; + + } /* end Xevent_after_raid */ + +/************************************************************************/ +/* */ +/* O p e n _ D i s p l a y */ +/* */ +/* Open the connection to the X client/window manager display, */ +/* gather information from it that we'll need (pixel depth, etc), */ +/* and initialize the lisp display-bank size to fit the screen. */ +/* */ +/* */ +/************************************************************************/ +void Open_Display( dsp ) + DspInterface dsp; +{ + + LispReadFds |= (1 << ConnectionNumber(dsp->display_id)); +#ifndef ISC +#ifndef HPUX + fcntl(ConnectionNumber(dsp->display_id), F_SETOWN, getpid()); +#endif /* HPUX */ +#endif /* ISC */ + + + /****************************************************/ + /* If debugging, set the X connection so that */ + /* we run synchronized--so a debugger can */ + /* 'stop in _XError' and know EXACTLY where */ + /* an error got caused. */ + /****************************************************/ + XSynchronize(dsp->display_id, xsync); + + Colors = DefaultColormapOfScreen ( ScreenOfDisplay( dsp->display_id, + DefaultScreen( dsp->display_id ) ) ); + + /* When we make the initial screen we haven't yet read in the */ + /* displayregion bitmap. Fix this now. */ + if (dsp->ScreenBitmap.data == NULL) + dsp->ScreenBitmap.data = (char *)DisplayRegion68k; + + Create_LispWindow(dsp); /* Make the main window */ + Lisp_Xinitialized = TRUE; + init_Xevent( dsp ); /* Turn on the intrpts. */ +} /* end OpenDisplay */ + + +/*********************************************************************/ +/* */ +/* X _ i n i t */ +/* dsp: a display structure to be filled with all the neccessary */ +/* information. */ +/* */ +/* lispbitmap: The bitmapdata that is to be dumped to the screen. */ +/* width_hint and height_hint: The requested size of the screen. The */ +/* width and height hints will be obeyed as close as possible */ +/* with respect to the physicalk limitations. This makes it */ +/* possible to get a screen that is larger (or smaller) than */ +/* the physical screen. 0 will give you some default value */ +/* depth_hint: The requested depth in bits. depth 1 can allways be */ +/* granted. Any value of 1 or less will yeild depth 1. */ +/* */ +/* Return value: the lispbitmap or 1 if all is ok. else FALSE is */ +/* returned */ +/* */ +/* This is the init function for X displays. To create a new display */ +/* you call this function. If you want to know what you got you will */ +/* have to read the individual fields of the dsp structure. */ +/* */ +/*********************************************************************/ + +DspInterface X_init( DspInterface dsp, + char *lispbitmap, + int width_hint, + int height_hint, + int depth_hint ) +{ + Screen *Xscreen; + + dsp->identifier = Display_Name; /* This is a hack. The display name */ + /* has to dealt with in a more */ + /* gracefull way. */ + + /* Try to open the X display. If this isn't possible, we just */ + /* return FALSE. */ + if( (dsp->display_id = XOpenDisplay( dsp->identifier )) == NULL ) + return(NULL); + /* Load the dsp structure */ + + Xscreen = ScreenOfDisplay( dsp->display_id, DefaultScreen( dsp->display_id ) ); + + /* Set the scrollbar and border widths */ + dsp->ScrollBarWidth = SCROLL_WIDTH; + dsp->InternalBorderWidth = DEF_BDRWIDE; + + dsp->Vissible.x = LispDisplayRequestedX; + dsp->Vissible.y = LispDisplayRequestedY; + + /* Set the width and height of the display. */ + if ( height_hint == 0 ){ + dsp->Display.height = HeightOfScreen( Xscreen ) - + OUTER_SB_WIDTH(dsp); /* In the default case, + adjust for scroll gadgets*/ + } + else dsp->Display.height = bound(WIN_MIN_HEIGHT, + height_hint, + WIN_MAX_HEIGHT); + + if ( width_hint == 0 ){ + dsp->Display.width = WidthOfScreen( Xscreen ) - + OUTER_SB_WIDTH(dsp); /* In the default case, + adjust for scroll gadgets*/ + } + else dsp->Display.width = bound(WIN_MIN_WIDTH, + width_hint, + WIN_MAX_WIDTH); + + /************************************************************/ + /* Set the size of ScreenBitMap */ + /* The display's width is rounded to a 32-bit multiple, */ + /* so that little-Endian machines can display right. */ + /************************************************************/ + dsp->Display.width = ((dsp->Display.width+31) >> 5) << 5; + + dsp->device.enter = (PFV)Open_Display; + dsp->device.exit = (PFV)lisp_Xexit; + + dsp->bitblt_to_screen = (PFUL)clipping_Xbitblt; + + dsp->device.before_raid = (PFV)Xevent_before_raid; + dsp->device.after_raid = (PFV)Xevent_after_raid; + + dsp->BitGravity = NorthWestGravity; + + dsp->cleardisplay = (PFV)GenericReturnT; + dsp->set_color_map_entry = (PFUL)GenericReturnT; + + /* Set the geometry of the Vissible (Lisp) window. */ + dsp->Vissible.width = bound(OUTER_SB_WIDTH(dsp), + LispWindowRequestedWidth, + min(dsp->Display.width, + (WidthOfScreen( Xscreen ) - + OUTER_SB_WIDTH(dsp)))); + dsp->Vissible.height = bound(OUTER_SB_WIDTH(dsp), + LispWindowRequestedHeight, + min(dsp->Display.height, + (HeightOfScreen( Xscreen ) - + OUTER_SB_WIDTH(dsp)))); + + /* Initialize the screen image structure. */ + dsp->ScreenBitmap.width = dsp->Display.width; + dsp->ScreenBitmap.height = dsp->Display.height; + dsp->ScreenBitmap.xoffset = 0; + dsp->bitsperpixel = DefaultDepthOfScreen( ScreenOfDisplay( dsp->display_id, + DefaultScreen( dsp->display_id ) ) ); +#if (defined(BYTESWAP)) + dsp->ScreenBitmap.byte_order = LSBFirst; +#else /* BYTESWAP */ + dsp->ScreenBitmap.byte_order = MSBFirst; +#endif /* BYTESWAP */ + + dsp->ScreenBitmap.data = (char *)(lispbitmap?Addr68k_from_LADDR((LispPTR)lispbitmap):0); + + switch(depth_hint){ + case 8: /* Color Screen */ + dsp->ScreenBitmap.format = ZPixmap; + dsp->ScreenBitmap.bitmap_unit = BitmapUnit( dsp->display_id ); + dsp->ScreenBitmap.bitmap_bit_order = MSBFirst; + dsp->ScreenBitmap.bitmap_pad = 32; + dsp->ScreenBitmap.depth = 8; + dsp->ScreenBitmap.bits_per_pixel = 8; + dsp->ScreenBitmap.bytes_per_line = (dsp->Display.width); + dsp->ScreenBitmap.red_mask = 7; + dsp->ScreenBitmap.green_mask = 7; + dsp->ScreenBitmap.blue_mask = 3; + break; + default: /* B/W Screen */ + dsp->ScreenBitmap.format = XYBitmap; + dsp->ScreenBitmap.bitmap_unit = BitmapUnit( dsp->display_id ); + dsp->ScreenBitmap.bitmap_bit_order = MSBFirst; + dsp->ScreenBitmap.bitmap_pad = 32; + dsp->ScreenBitmap.depth = 1; + dsp->ScreenBitmap.bytes_per_line = ((dsp->Display.width+(BITSPER_DLWORD-1)) + /BITSPER_DLWORD) * (BITSPER_DLWORD/8); + break; + } + return( dsp ); +} diff --git a/src/xlspwin.c b/src/xlspwin.c new file mode 100755 index 0000000..91cebb0 --- /dev/null +++ b/src/xlspwin.c @@ -0,0 +1,545 @@ +/* $Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, */ +/* 1994, 1995, 1999, 2000, 2001 Venue. */ +/* All Rights Reserved. */ +/* */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include +#include +#include + +#include "lispemul.h" + +#include "xdefs.h" +#include "xbitmaps.h" + +#include "keyboard.h" +#include "devif.h" +#include "dbprint.h" + +extern DLword *EmKbdAd068K + , *EmKbdAd168K + , *EmKbdAd268K + , *EmKbdAd368K + , *EmKbdAd468K + , *EmKbdAd568K + , *EmRealUtilin68K; +extern DLword *CTopKeyevent; +extern LispPTR *KEYBUFFERING68k; +extern int URaid_req + , KBDEventFlg; + +extern DLword *DisplayRegion68k; + +extern int Current_Hot_X, Current_Hot_Y; /* X Cursor hotspots */ + +extern char Window_Title[255]; +extern char Icon_Title[255]; + +extern int save_argc; +extern char **save_argv; + +extern DspInterface currentdsp; + +Pixmap IconPixmap; +GC CopyInvert_GC; +extern GC cursor_source_gc; +XGCValues gcv; +XEvent report; + +Cursor WaitCursor, + DefaultCursor, + VertScrollCursor, + VertThumbCursor, + ScrollUpCursor, + ScrollDownCursor, + HorizScrollCursor, + HorizThumbCursor, + ScrollLeftCursor, + ScrollRightCursor; + +extern int LispWindowRequestedX, + LispWindowRequestedY, + LispWindowRequestedWidht, + LispWindowRequestedHeight; + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +Create_LispWindow(dsp) + DspInterface dsp; +{ + XSizeHints szhint; + XWMHints Lisp_WMhints; + XClassHint xclasshint; + XTextProperty IconText, WindowNameText; + XSetWindowAttributes Lisp_SetWinAttributes; + + Screen *screen; + + Window lspwinRoot; + int lspwinX, lspwinY, Col2, Row2, Col3, Row3, GravSize; + unsigned int lspwinHeight , lspwinWidth, lspwinBorder, lspwinDepth; + char *WT, *IT; + + WT = Window_Title; + IT = Icon_Title; + + GravSize = (int)(dsp->ScrollBarWidth/2) - (dsp->InternalBorderWidth); + Col2 = dsp->Vissible.width; + Row2 = dsp->Vissible.height; + Col3 = dsp->Vissible.width + (int)(OUTER_SB_WIDTH(dsp)/2); + Row3 = dsp->Vissible.height + (int)(OUTER_SB_WIDTH(dsp)/2); + + screen = ScreenOfDisplay( dsp->display_id, DefaultScreen( dsp->display_id )); + dsp->LispWindow = XCreateSimpleWindow( dsp->display_id, + RootWindowOfScreen( screen ), + LispWindowRequestedX, /* Default upper left */ + LispWindowRequestedY, /* Default upper left */ + dsp->Vissible.width + OUTER_SB_WIDTH( dsp ), /* Default width */ + dsp->Vissible.height + OUTER_SB_WIDTH( dsp ), /* Default height */ + 0, /* Default border */ + BlackPixelOfScreen( screen ), + WhitePixelOfScreen( screen ) ); + + Lisp_SetWinAttributes.bit_gravity = dsp->BitGravity; + Lisp_SetWinAttributes.override_redirect = False; + Lisp_SetWinAttributes.backing_store = DoesBackingStore( screen ); + + XChangeWindowAttributes( dsp->display_id + , dsp->LispWindow + , CWBitGravity | CWOverrideRedirect + , &Lisp_SetWinAttributes ); + + dsp->DisableEventMask = NoEventMask; + dsp->EnableEventMask = ButtonPressMask | + ButtonReleaseMask | + EnterWindowMask | + LeaveWindowMask | + StructureNotifyMask | + PointerMotionMask | + ExposureMask | + KeyPressMask | + KeyReleaseMask; + + /* Have to make the GC before we make the icon. */ + gcv.function = GXcopy; + gcv.foreground = BlackPixelOfScreen( ScreenOfDisplay( dsp->display_id, + DefaultScreen( dsp->display_id ))); + gcv.background = WhitePixelOfScreen( ScreenOfDisplay( dsp->display_id, + DefaultScreen( dsp->display_id ))); + dsp->Copy_GC = XCreateGC( dsp->display_id, dsp->LispWindow + , GCForeground | GCBackground | GCFunction + , &gcv ); + + szhint.max_width = dsp->Display.width + OUTER_SB_WIDTH( dsp ); + szhint.max_height = dsp->Display.height + OUTER_SB_WIDTH( dsp ); + szhint.min_width = OUTER_SB_WIDTH( dsp ); + szhint.min_height = OUTER_SB_WIDTH( dsp ); + szhint.win_gravity = dsp->BitGravity; + szhint.flags = PMaxSize | PWinGravity | PSize | PPosition; + + Lisp_WMhints.icon_pixmap = make_Xicon(dsp); + Lisp_WMhints.input = True; + Lisp_WMhints.flags = IconPixmapHint | InputHint; + + xclasshint.res_name = *save_argv; + xclasshint.res_class = *save_argv; + + XStringListToTextProperty(&WT , 1, &WindowNameText); + XStringListToTextProperty(&IT, 1, &IconText); + + XSetWMProperties( dsp->display_id, + dsp->LispWindow, + &WindowNameText, + &IconText, + save_argv, + save_argc, + &szhint, + &Lisp_WMhints, + &xclasshint); + + XSelectInput( dsp->display_id, dsp->LispWindow, dsp->EnableEventMask ); + init_Xcursor(dsp->display_id, dsp->LispWindow); + + dsp->DisplayWindow = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + 0, 0, dsp->Vissible.width, dsp->Vissible.height, 0, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XChangeWindowAttributes( dsp->display_id + , dsp->DisplayWindow + , CWBitGravity | CWOverrideRedirect | CWBackingStore + , &Lisp_SetWinAttributes ); + XSelectInput( dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask ); + XMapWindow( dsp->display_id, dsp->DisplayWindow ); + + /*********************************************************************/ + /* Create all the vanilla pixmaps and cursors for the display window */ + /*********************************************************************/ + + dsp->ScrollBarPixmap = + XCreatePixmapFromBitmapData( dsp->display_id, + dsp->LispWindow, + check_bits, + check_width, + check_height, + BlackPixelOfScreen( screen ), + WhitePixelOfScreen( screen ), + DefaultDepthOfScreen( screen )); + dsp->GravityOnPixmap = + XCreatePixmapFromBitmapData(dsp->display_id, + dsp->LispWindow, + check_bits, + 16, 16, + BlackPixelOfScreen( screen ), + WhitePixelOfScreen( screen ), + DefaultDepthOfScreen( screen )); + + dsp->GravityOffPixmap = + XCreatePixmapFromBitmapData(dsp->display_id, + dsp->LispWindow, + plain_bits, + 16, 16, + BlackPixelOfScreen( screen ), + WhitePixelOfScreen( screen ), + DefaultDepthOfScreen( screen )); + + set_Xcursor( dsp + , (char*) default_cursor.cuimage + , (int) default_cursor.cuhotspotx + , (int) (15 - default_cursor.cuhotspoty) + , &DefaultCursor, 0 ); + set_Xcursor( dsp + , (char*) wait_cursor.cuimage + , (int) wait_cursor.cuhotspotx + , (int) (15 - wait_cursor.cuhotspoty) + , &WaitCursor, 0 ); + set_Xcursor( dsp + , (char*)scrolldown_cursor.cuimage + , (int) scrolldown_cursor.cuhotspotx + , (int) (15 - scrolldown_cursor.cuhotspoty) + , &ScrollDownCursor, 0 ); + set_Xcursor( dsp + , (char*)scrollleft_cursor.cuimage + , (int) scrollleft_cursor.cuhotspotx + , (int) (15 - scrollleft_cursor.cuhotspoty) + , &ScrollLeftCursor , 0); + set_Xcursor( dsp + , (char*)vertscroll_cursor.cuimage + , (int) vertscroll_cursor.cuhotspotx + , (int) (15 - vertscroll_cursor.cuhotspoty) + , &VertScrollCursor, 0 ); + set_Xcursor( dsp + , (char*)vertthumb_cursor.cuimage + , (int) vertthumb_cursor.cuhotspotx + , (int) (15 - vertthumb_cursor.cuhotspoty) + , &VertThumbCursor, 0 ); + set_Xcursor( dsp + , (char*)horizscroll_cursor.cuimage + , (int) horizscroll_cursor.cuhotspotx + , (int) (15 - horizscroll_cursor.cuhotspoty) + , &HorizScrollCursor, 0 ); + set_Xcursor( dsp + , (char*)horizthumb_cursor.cuimage + , (int) horizthumb_cursor.cuhotspotx + , (int) (15 - horizthumb_cursor.cuhotspoty) + , &HorizThumbCursor, 0 ); + set_Xcursor( dsp + , (char*)scrollright_cursor.cuimage + , (int) scrollright_cursor.cuhotspotx + , (int) (15 - scrollright_cursor.cuhotspoty) + , &ScrollRightCursor, 0 ); + set_Xcursor( dsp + , (char*)scrollup_cursor.cuimage + , (int) scrollup_cursor.cuhotspotx + , (int) (15 - scrollup_cursor.cuhotspoty) + , &ScrollUpCursor, 0 ); + + /********************************/ + /* Make all the toolkit windows */ + /********************************/ + dsp->VerScrollBar = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + Col2, + 0-dsp->InternalBorderWidth, /* y */ + dsp->ScrollBarWidth, /* width */ + dsp->Vissible.height, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + DefineCursor( dsp->display_id, dsp->VerScrollBar, &VertScrollCursor ); + XMapWindow( dsp->display_id, dsp->VerScrollBar ); + + dsp->HorScrollBar = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + 0-dsp->InternalBorderWidth, + Row2, /* y */ + dsp->Vissible.width, /* width */ + dsp->ScrollBarWidth, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + DefineCursor( dsp->display_id, dsp->HorScrollBar, &HorizScrollCursor ); + XChangeWindowAttributes( dsp->display_id + , dsp->HorScrollBar + , CWOverrideRedirect + , &Lisp_SetWinAttributes ); + XMapWindow( dsp->display_id, dsp->HorScrollBar ); + + dsp->VerScrollButton = XCreateSimpleWindow( dsp->display_id, + dsp->VerScrollBar, + 0-dsp->InternalBorderWidth, /* x */ + (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height), /* y */ + dsp->ScrollBarWidth, /* width */ + (int)((dsp->Vissible.height*dsp->Vissible.height) / dsp->Display.height) + 1, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XChangeWindowAttributes( dsp->display_id + , dsp->VerScrollButton + , CWOverrideRedirect + , &Lisp_SetWinAttributes ); + XSetWindowBackgroundPixmap( dsp->display_id, + dsp->VerScrollButton, + dsp->ScrollBarPixmap ); + XClearWindow( dsp->display_id, dsp->VerScrollButton ); + XMapWindow( dsp->display_id, dsp->VerScrollButton ); + + dsp->HorScrollButton = XCreateSimpleWindow( dsp->display_id, + dsp->HorScrollBar, + (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width), + 0-dsp->InternalBorderWidth, /* y */ + (int)((dsp->Vissible.width*dsp->Vissible.width)/ dsp->Display.width) + 1, + dsp->ScrollBarWidth, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XChangeWindowAttributes( dsp->display_id + , dsp->HorScrollButton + , CWOverrideRedirect + , &Lisp_SetWinAttributes ); + XSetWindowBackgroundPixmap( dsp->display_id, + dsp->HorScrollButton, + dsp->ScrollBarPixmap ); + XClearWindow( dsp->display_id, dsp->HorScrollButton ); + XMapWindow( dsp->display_id, dsp->HorScrollButton ); + + dsp->NWGrav = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + Col2, Row2, GravSize, GravSize, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap( dsp->display_id + , dsp->NWGrav + , dsp->GravityOnPixmap ); + DefineCursor( dsp->display_id, dsp->NWGrav, &DefaultCursor ); + XChangeWindowAttributes( dsp->display_id + , dsp->NWGrav + , CWOverrideRedirect + , &Lisp_SetWinAttributes ); + XClearWindow( dsp->display_id, dsp->NWGrav ); + XMapWindow( dsp->display_id, dsp->NWGrav ); + + dsp->SEGrav = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + Col3, Row3, GravSize, GravSize, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap( dsp->display_id + , dsp->SEGrav + , dsp->GravityOffPixmap ); + DefineCursor( dsp->display_id, dsp->SEGrav, &DefaultCursor ); + XChangeWindowAttributes( dsp->display_id + , dsp->SEGrav + , CWOverrideRedirect + , &Lisp_SetWinAttributes ); + XClearWindow( dsp->display_id, dsp->NWGrav ); + XMapWindow( dsp->display_id, dsp->SEGrav ); + + dsp->SWGrav = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + Col2, Row3, GravSize, GravSize, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap( dsp->display_id + , dsp->SWGrav + , dsp->GravityOffPixmap ); + DefineCursor( dsp->display_id, dsp->SWGrav, &DefaultCursor ); + XClearWindow( dsp->display_id, dsp->NWGrav ); + XMapWindow( dsp->display_id, dsp->SWGrav ); + + dsp->NEGrav = XCreateSimpleWindow( dsp->display_id, + dsp->LispWindow, + Col3, Row2, GravSize, GravSize, + dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap( dsp->display_id + , dsp->NEGrav + , dsp->GravityOffPixmap ); + DefineCursor( dsp->display_id, dsp->NEGrav, &DefaultCursor ); + XClearWindow( dsp->display_id, dsp->NWGrav ); + XMapWindow( dsp->display_id, dsp->NEGrav ); + + /* DefineCursor( dsp->display_id, dsp->DisplayWindow, &WaitCursor ); */ + + XLOCK; + XMapWindow( dsp->display_id, dsp->LispWindow ); + XFlush(dsp->display_id); + XUNLOCK; +} + + +lisp_Xvideocolor( flag ) +int flag; +{ + XLOCK; + XCopyArea( currentdsp->display_id + , currentdsp->DisplayWindow + , currentdsp->DisplayWindow + , currentdsp->Copy_GC + , 0, 0 + , currentdsp->Vissible.width + , currentdsp->Vissible.height + , 0, 0 ); + + /* Cursor */ + gcv.function = GXcopy; + XChangeGC( currentdsp->display_id, cursor_source_gc , GCFunction , &gcv ); + /* JDS 011213: Remember set_xcursor does 15-y val, so do it here! */ + Set_XCursor( Current_Hot_X, 15-Current_Hot_Y ); + + XFlush(currentdsp->display_id); + XUNLOCK; + +} /* end lisp_Xvideocolor */ + + + + +extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ + +set_Xmouseposition( x, y ) + int x + , y; +{ + int dest_x + , dest_y; + + TPRINT(( "set_Xmouseposition(%d,%d)\n", x, y )); + + dest_x = (x&0xFFFF) + Current_Hot_X - currentdsp->Vissible.x; + dest_y = (y&0xFFFF) + Current_Hot_Y - currentdsp->Vissible.y; + + if( (dest_x>=0) && (dest_x<= currentdsp->Vissible.width) + && (dest_y>=0) && (dest_y<=currentdsp->Vissible.height) ) { + XLOCK; + XWarpPointer( currentdsp->display_id, (Window)NULL, currentdsp->DisplayWindow + , 0, 0 + , 0, 0 + , dest_x, dest_y ); + XFlush( currentdsp->display_id ); + XUNLOCK; + } +} /* end set_Xmouseposition */ + + +/************************************************************************/ +/* */ +/* D o R i n g */ +/* */ +/* Take keyboard events and turn them into Lisp event info */ +/* (when running under X) */ +/* */ +/************************************************************************/ + +DoRing() + { + DLword w + , r; + KBEVENT *kbevent; + + TPRINT(( "TRACE: DoRing()\n" )); + + +do_ring: + if(((*EmKbdAd268K) & 2113) == 0) + { /*Ctrl-shift-NEXT*/ + error("****** EMERGENCY Interrupt ******"); + *EmKbdAd268K=KB_ALLUP; /*reset*/ + ((RING*)CTopKeyevent)->read=0; /* reset queue */ + ((RING*)CTopKeyevent)->write=MINKEYEVENT; + /*return(0);*/ + } + else if(((*EmKbdAd268K) & 2114) == 0) + { /* Ctrl-Shift-DEL */ + *EmKbdAd268K=KB_ALLUP; /*reset*/ + URaid_req=T; + ((RING*)CTopKeyevent)->read=0; /* reset queue */ + ((RING*)CTopKeyevent)->write=MINKEYEVENT; + /*return(0);*/ + } + +#ifdef OS4_TYPE4BUG + else if(((*EmKbdAd268K) & 2120) == 0) + { /* Ctrl-Shift-Return */ + *EmKbdAd268K=KB_ALLUP; /*reset*/ + URaid_req=T; + ((RING*)CTopKeyevent)->read=0; /* reset queue */ + ((RING*)CTopKeyevent)->write=MINKEYEVENT; + } +#endif + + r=RING_READ(CTopKeyevent); + w=RING_WRITE(CTopKeyevent); + + if(r==w) /* event queqe FULL */ + goto KBnext; + + kbevent=(KBEVENT*)(CTopKeyevent+ w); +/* RCLK(kbevent->time); */ + kbevent->W0= *EmKbdAd068K; + kbevent->W1= *EmKbdAd168K; + kbevent->W2= *EmKbdAd268K; + kbevent->W3= *EmKbdAd368K; + kbevent->W4= *EmKbdAd468K; + kbevent->W5= *EmKbdAd568K; + kbevent->WU= *EmRealUtilin68K; + + if(r==0) /* Queue was empty */ + ((RING*)CTopKeyevent)->read=w; + if(w >= MAXKEYEVENT) ((RING*)CTopKeyevent)->write = MINKEYEVENT; + else ((RING*)CTopKeyevent)->write = w + KEYEVENTSIZE; + + KBnext: + if(*KEYBUFFERING68k ==NIL) *KEYBUFFERING68k=ATOM_T; + + } diff --git a/src/xmkicon.c b/src/xmkicon.c new file mode 100755 index 0000000..daa9932 --- /dev/null +++ b/src/xmkicon.c @@ -0,0 +1,106 @@ +/* $Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + +#include + +#include +#include +#include "lispemul.h" +#include "dbprint.h" + +#include "xdefs.h" +#include "devif.h" + +XImage IconImage; + +extern int Bitmap_Pad , Default_Depth, Lisp_icon_width, Lisp_icon_height; +extern char Lisp_icon[]; + +extern Pixmap IconPixmap; +extern char iconpixmapfile[1024]; + + + + +/************************************************************************/ +/* */ +/* m a k e _ X i c o n */ +/* */ +/* Make the icon for the shrunken Medley window. */ +/* */ +/************************************************************************/ + +make_Xicon( dsp ) + DspInterface dsp; + { + unsigned int width, height; + int value, x_hot, y_hot; + char *getenv(); + +#ifdef TRACE + printf( "In make_Xicon().\n" ); +#endif + value = XReadBitmapFile(dsp->display_id, + RootWindow(dsp->display_id, 0), + iconpixmapfile, + &width, &height, + &IconPixmap, + &x_hot, &y_hot); + if (value == BitmapOpenFailed) { + IconImage.width = Lisp_icon_width; + IconImage.height = Lisp_icon_height; + IconImage.xoffset = 0; + IconImage.format = XYBitmap; + IconImage.data = (char*) Lisp_icon; +#if defined(BYTESWAP) + IconImage.byte_order = LSBFirst; +#else /* BYTESWAP */ + IconImage.byte_order = MSBFirst; +#endif /* BYTESWAP */ + IconImage.bitmap_unit = 8; + IconImage.bitmap_pad = Bitmap_Pad; + IconImage.depth = 1; + IconImage.bytes_per_line = Lisp_icon_width/8; +#if defined(X_ICON_IN_X_BITMAP_FORMAT) + IconImage.bitmap_bit_order = LSBFirst; +#else + IconImage.bitmap_bit_order = MSBFirst; +#endif + + IconPixmap = XCreatePixmap( dsp->display_id, dsp->LispWindow + , Lisp_icon_width , Lisp_icon_height + , DefaultDepthOfScreen( ScreenOfDisplay( dsp->display_id, + DefaultScreen( dsp->display_id ) ) ) ); + + XPutImage( dsp->display_id, IconPixmap, dsp->Copy_GC, &IconImage + , 0, 0, 0, 0 + , Lisp_icon_width, Lisp_icon_height ); + + } + else if (value == BitmapFileInvalid) + fprintf(stderr, "Iconpixmapfile %s contains invalid bitmap data\n", iconpixmapfile); + else if (value == BitmapNoMemory) + fprintf(stderr, "Not enough memory to allocate icon pixmap\n"); + return( IconPixmap ); + } /* end make_Xicon */ diff --git a/src/xrdopt.c b/src/xrdopt.c new file mode 100755 index 0000000..ccd8f5b --- /dev/null +++ b/src/xrdopt.c @@ -0,0 +1,442 @@ +/* $Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + + + + +#include +#include +#include +#include +#ifndef NOETHER +#ifndef USE_DLPI +#include /* needed for Ethernet stuff below */ +#endif /* USE_DLPI */ +#endif /* NOETHER */ +#ifdef SYSVONLY +#include +#endif /* SYSVONLY */ +#include +#include +#include + +#ifdef __STDC__ +#include +#endif /* __STDC__ */ + +#include "xdefs.h" +#include "dbprint.h" + +XrmDatabase commandlineDB, applicationDB, serverDB, homeDB, rDB; +int opTableEntries = 33; +extern int LispWindowRequestedX, + LispWindowRequestedY, + LispWindowRequestedWidth, + LispWindowRequestedHeight; + +extern int LispDisplayRequestedX, + LispDisplayRequestedY, + LispDisplayRequestedWidth, + LispDisplayRequestedHeight; + +extern int xsync; + +XrmOptionDescRec opTable[] = { + {"-help", "*help", XrmoptionIsArg, (caddr_t) NULL}, + {"-h", "*help", XrmoptionIsArg, (caddr_t) NULL}, + {"-sysout", "*sysout", XrmoptionSepArg, (caddr_t) NULL}, + {"-display", "*display", XrmoptionSepArg, (caddr_t) NULL}, + {"-d", "*display", XrmoptionSepArg, (caddr_t) NULL}, + {"-borderWidth", "*borderWidth", XrmoptionSepArg, (caddr_t) NULL}, + {"-bw", "*borderWidth", XrmoptionSepArg, (caddr_t) NULL}, + {"-screen", "*screen", XrmoptionSepArg, (caddr_t) NULL}, + {"-sc", "*screen", XrmoptionSepArg, (caddr_t) NULL}, + {"-geometry", "*geometry", XrmoptionSepArg, (caddr_t) NULL}, + {"-g", "*geometry", XrmoptionSepArg, (caddr_t) NULL}, + {"-foreground", "*foreground", XrmoptionSepArg, (caddr_t) NULL}, + {"-fg", "*foreground", XrmoptionSepArg, (caddr_t) NULL}, + {"-background", "*background", XrmoptionSepArg, (caddr_t) NULL}, + {"-bg", "*background", XrmoptionSepArg, (caddr_t) NULL}, + {"-title", "*title", XrmoptionSepArg, (caddr_t) NULL}, + {"-t", "*title", XrmoptionSepArg, (caddr_t) NULL}, + {"-icontitle", "*icontitle", XrmoptionSepArg, (caddr_t) NULL}, + {"-it", "*icontitle", XrmoptionSepArg, (caddr_t) NULL}, + {"-iconbitmap", "*iconbitmap", XrmoptionSepArg, (caddr_t) NULL}, + {"-ibm", "*iconbitmap", XrmoptionSepArg, (caddr_t) NULL}, + {"-key", "*key", XrmoptionSepArg, (caddr_t) NULL}, + {"-k", "*key", XrmoptionSepArg, (caddr_t) NULL}, + {"-timer", "*timer", XrmoptionSepArg, (caddr_t) NULL}, + {"-xpages", "*maxpages", XrmoptionSepArg, (caddr_t) NULL}, + {"-m", "*memory", XrmoptionSepArg, (caddr_t) NULL}, + {"-NF", "*NoFork", XrmoptionIsArg, (caddr_t) NULL}, + {"-NoFork", "*NoFork", XrmoptionIsArg, (caddr_t) NULL}, + {"-INIT", "*Init", XrmoptionIsArg, (caddr_t) NULL}, + {"-EtherNet", "*EtherNet", XrmoptionSepArg, (caddr_t) NULL}, + {"-E", "*EtherNet", XrmoptionSepArg, (caddr_t) NULL}, + {"-autorepeat", "*autorepeat", XrmoptionSepArg, (caddr_t) NULL}, + {"-xsync", "*xsync", XrmoptionIsArg, (caddr_t) NULL}, + }; + /* autorepeat is a global setting for X, not anything that + Medley has to be concerned with. Item kept for historical + reasons /jarl + */ + +char Display_Name[128]; +char iconpixmapfile[1024]; +char Window_Title[255]; +char Icon_Title[255]; + +extern char sysout_name[], keystring[]; +extern int sysout_size, for_makeinit, please_fork, Scroll_Border; + /* diagnostic flag for sysout dumping */ +/* extern int maxpages; */ + +extern char keystring[]; + +int Lisp_Border = 2; + +/*** Ethernet stuff (JRB) **/ +#ifndef NOETHER +extern int ether_fd; +extern u_char ether_host[6]; +#ifndef USE_DLPI +extern struct sockaddr_nit snit; +#endif /* USE_DLPI */ +#endif /* NOETHER */ + + +/************************************************************************/ +/* */ +/* r e a d _ X o p t i o n */ +/* */ +/* Parse command-line options related to X windows. */ +/* */ +/************************************************************************/ + +void read_Xoption( argc, argv ) + int *argc; + char **argv; +{ + int bitmask; + XrmValue value; + char *str_type[30], tmp[1024], *envname; + Display *xdisplay; + int i; + + /**********************************************/ + /* */ + /* Take care of -help & -info flags, which */ + /* aren't handled correctly by the X code. */ + /* */ + /**********************************************/ + + for (i = 1; i < *argc; i++) + { + if (argv[i] && ((strcmp(argv[i], "-info") == 0) || + (strcmp(argv[i], "-INFO") == 0))) { + print_info_lines(); + } + + if (argv[i] && + ((strcmp(argv[i], "-help") == 0) || + (strcmp(argv[i], "-HELP") == 0))) + { + print_Xusage( argv[0] ); + exit(0); + } + } + + + /* Now let X handle the parsing. */ + + (void)XrmInitialize(); + /* If the first argv lacks '-' in front it is the sysout. */ +#ifdef NEVEFR +/* JDS 12/20/01: app name should always be "ldex", not what's in argv?? */ + XrmParseCommand(&commandlineDB, opTable, opTableEntries, argv[0], argc, argv); +#endif + XrmParseCommand(&commandlineDB, opTable, opTableEntries, "ldex", argc, argv); + + if (XrmGetResource(commandlineDB, "ldex.help", "Ldex.Help", + str_type, &value) == True) { + print_Xusage( argv[0] ); + } + + if(*argc == 2) /* There was probably a sysoutarg */ + { + sysout_name[0] = '\0'; + (void)strcat(sysout_name, argv[1]); + } + else if ((envname = (char *)getenv("LDESRCESYSOUT")) != NULL) + { + strcpy(sysout_name, envname); + } + else if ((envname = (char *)getenv("LDESOURCESYSOUT")) != NULL) + strcpy(sysout_name, envname); + else { + envname = (char *)getenv("HOME"); + (void)strcat(sysout_name, envname); + (void)strcat(sysout_name, "/lisp.virtualmem"); + + if( access(sysout_name, R_OK) != 0) + { + (void)strcat(sysout_name, ""); + } + } + + /* In order to access other DB's we have to open the main display now */ + /* This is just temporary. We'll need this display struct to open the */ + /* main databases for medley. After it is used the display will be */ + /* closed and the opening of the other displays will follow the standard */ + /* protocoll. */ + + if (XrmGetResource(commandlineDB, + "ldex.display", "Ldex.Display", + str_type, &value) == True) { + (void) strncpy(Display_Name, value.addr, (int)value.size); + } + else if (getenv("DISPLAY") == (char *)NULL){ + fprintf( stderr, "Can't find a display. Either set the shell\n"); + fprintf( stderr, "variabel DISPLAY to an appropriate display\n"); + fprintf( stderr, "or provide a -display argument.\n"); + print_Xusage( argv[0] ); + } + else { + envname = (char *)getenv("DISPLAY"); + (void)strcpy(Display_Name, envname); + } + if( (xdisplay = XOpenDisplay( Display_Name )) != NULL ) + { + /* read the other databases */ + /* Start with app-defaults/medley */ + (void)strcpy(tmp, "/usr/lib/X11/app-defaults/"); + (void)strcat(tmp, "medley"); + applicationDB = XrmGetFileDatabase(tmp); + if (applicationDB != NULL){ + (void)XrmMergeDatabases(applicationDB, &rDB); + } + /* Then try the displays defaults */ + if (XResourceManagerString(xdisplay) != NULL) { + serverDB = XrmGetStringDatabase(XResourceManagerString(xdisplay)); + if (serverDB != NULL){ + (void)XrmMergeDatabases(serverDB, &rDB); + } + } + XCloseDisplay(xdisplay); + } else { + fprintf( stderr, "Open_Display: cannot connect to display %s." + ,XDisplayName(Display_Name)); + exit(-1); + } + + envname = (char *)getenv("HOME"); + (void)strcat(tmp, envname); + (void)strcat(tmp, "/.Xdefaults"); + if( access(tmp, R_OK) != 0) { + serverDB = XrmGetFileDatabase(tmp); + if (serverDB != NULL){ + (void)XrmMergeDatabases(serverDB, &rDB); + } + } + + /* Now for the commandline */ + (void)XrmMergeDatabases(commandlineDB, &rDB); + + if (XrmGetResource(rDB, + "ldex.sysout", + "Ldex.Sysout", + str_type, &value) == True) { + /* Get Sysout */ + (void)strncpy(sysout_name, value.addr, (int)value.size); + } + if (sysout_name == NULL) { + fprintf(stderr, "Coudn't find a sysout to run;\n"); + print_Xusage( argv[0] ); + } + + if (XrmGetResource(rDB, + "ldex.title", + "Ldex.Title", + str_type, &value) == True) { + (void)strncpy(Window_Title, value.addr, (int)value.size); + } else { + (void)strcpy(Window_Title, + WINDOW_NAME); + } + if (XrmGetResource(rDB, + "ldex.icontitle", + "Ldex.icontitle", + str_type, &value) == True) { + (void)strncpy(Icon_Title, value.addr, (int)value.size); + } else { + (void)strcpy(Icon_Title, "Medley"); + } + + if (XrmGetResource(rDB, + "ldex.iconbitmap", + "Ldex.Iconbitmap", + str_type, &value) == True) { + (void)strncpy(iconpixmapfile, value.addr, (int)value.size); + } + + /* Old style geometry definition. */ + if (XrmGetResource(rDB, + "ldex.geometry", + "Ldex.geometry", + str_type, &value) == True) { + /* Get Geometry */ + (void)strncpy(tmp, value.addr, (int)value.size); + bitmask = XParseGeometry(tmp , &LispWindowRequestedX, &LispWindowRequestedY + , &LispWindowRequestedWidth, &LispWindowRequestedHeight ); } + if (XrmGetResource(rDB, + "ldex.screen", + "Ldex.screen", + str_type, &value) == True) { + /* Get Geometry */ + (void)strncpy(tmp, value.addr, (int)value.size); + bitmask = XParseGeometry(tmp , &LispDisplayRequestedX, &LispDisplayRequestedY + , &LispDisplayRequestedWidth, &LispDisplayRequestedHeight ); + } + + (void)strcpy(tmp, ""); /* Clear the string */ + + if (XrmGetResource(rDB, + "ldex.NoFork", + "Ldex.NoFork", + str_type, &value) == True) { + please_fork = 0; + } + +/* if (XrmGetResource(rDB, + "ldex.maxpages", + "Ldex.maxpages", + str_type, &value) == True) { + (void)strncpy(tmp, value.addr, (int)value.size); + maxpages = atoi(tmp); + } +*/ + if (XrmGetResource(rDB, + "ldex.memory", + "Ldex.memory", + str_type, &value) == True) { + (void)strncpy(tmp, value.addr, (int)value.size); + sysout_size = atoi(tmp); + } + + if (XrmGetResource(rDB, + "ldex.Init", + "Ldex.Init", + str_type, &value) == True) { + for_makeinit = 1; + } + + if (XrmGetResource(rDB, + "ldex.key", + "Ldex.key", + str_type, &value) == True) { + (void)strncpy(keystring, value.addr, (int)value.size); + } + if (XrmGetResource(rDB, + "ldex.xsync", + "Ldex.xsync", + str_type, &value) == True) { + xsync = True; + } +#ifdef NOETHER +#else + if (XrmGetResource(rDB, + "ldex.EtherNet", + "Ldex.EtherNet", + str_type, &value) == True) { + int b0, b1, b2, b3, b4, b5; + (void)strncpy(tmp, value.addr, (int)value.size); +#ifdef USE_DLPI + if (sscanf(tmp,"%d:%x:%x:%x:%x:%x:%x",ðer_fd, + &b0, &b1, &b2, &b3, &b4, &b5) == 7) +#else + if (sscanf(tmp,"%d:%x:%x:%x:%x:%x:%x:%s",ðer_fd, + &b0, &b1, &b2, &b3, &b4, &b5, snit.snit_ifname) == 8) +#endif /* USE_DLPI */ + { + ether_host[0] = b0; ether_host[1] = b1; + ether_host[2] = b2; ether_host[3] = b3; + ether_host[4] = b4; ether_host[5] = b5; + } else { + fprintf(stderr, "Missing or bogus -E argument\n"); + ether_fd = -1; + exit(1); + } + } +#endif /* NOETHER */ +} /* end readXoption */ + + + +/************************************************************************/ +/* */ +/* p r i n t _ l i s p u s a g e */ +/* */ +/* Print out command-line usage info if user enters wrong stuff. */ +/* */ +/************************************************************************/ + +print_lispusage( prog ) + char *prog; + { + TPRINT(( "TRACE: print_lisp_usage()\n" )); + + /* Lisp Option */ + fprintf(stderr,"lde[ether] [sysout] [-k access-key]"); + fprintf(stderr," [-E ]"); + fprintf(stderr,"\n"); + + } /* end print_lisp_usage() */ + + + + +/************************************************************************/ +/* */ +/* p r i n t _ X u s a g e */ +/* */ +/* Print out command-line options for X, to help user. */ +/* */ +/************************************************************************/ + +print_Xusage( prog ) + char *prog; + { + fprintf(stderr, " %s options:\n", prog); + fprintf(stderr, " [-sysout] [] -path to the Medley image\n"); + fprintf(stderr, " -k[ey] -see manual for details\n"); + fprintf(stderr, " -h[elp] -prints this text\n"); + fprintf(stderr, " -d[isplay] :.\n"); + fprintf(stderr, " -g[eometry] -size & placement for the medley window on your X screen\n"); + fprintf(stderr, " -sc[reen] -size & placement for the medley display\n"); + fprintf(stderr, " -t[itle] -titlebar text for the window manager\n"); + fprintf(stderr, " -icontitle | -it -text for the medley icon\n"); + fprintf(stderr, " -iconbitmap | -ibm -bitmap for the medley icon\n"); + fprintf(stderr, " -xsync -turn XSyncronize on. (default is off)\n\n"); + fprintf(stderr, "If you have any further questions, please refer to the manual or\n"); + fprintf(stderr, "call our tech support at (800)228-5325 or (510)763-0516.\n\n"); + exit(0); + } /* end print_Xusage() */ diff --git a/src/xscroll.c b/src/xscroll.c new file mode 100755 index 0000000..77479dc --- /dev/null +++ b/src/xscroll.c @@ -0,0 +1,89 @@ +/* $Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + +#include + +#include +#include + +#include "lispemul.h" +#include "xdefs.h" +#include "devif.h" + +int ScrollPitch = SCROLL_PITCH; + +JumpScrollVer( dsp, y ) + DspInterface dsp; +{ + Scroll( dsp, dsp->Vissible.x, (int)((dsp->Display.width *y) / dsp->Vissible.height)); +} + +JumpScrollHor( dsp, x ) + DspInterface dsp; +{ + Scroll( dsp, (int)((dsp->Display.width *x) / dsp->Vissible.width), dsp->Vissible.y); +} + +ScrollLeft( dsp ) + DspInterface dsp; +{ + Scroll( dsp, dsp->Vissible.x - ScrollPitch, dsp->Vissible.y); +} + +ScrollRight( dsp ) + DspInterface dsp; +{ + Scroll( dsp, dsp->Vissible.x + ScrollPitch, dsp->Vissible.y); +} + +ScrollUp( dsp ) + DspInterface dsp; +{ + Scroll( dsp, dsp->Vissible.x, dsp->Vissible.y - ScrollPitch); +} + +ScrollDown( dsp ) + DspInterface dsp; +{ + Scroll( dsp, dsp->Vissible.x, dsp->Vissible.y + ScrollPitch); +} + + +/* Move the DisplayWindow and the ScrollButtons to a new */ +/* position. newX, newY refers to the uppre left corner */ +/* of the LispDisplay */ +Scroll( dsp, newX, newY) + DspInterface dsp; + int newX, newY; +{ + /* Limit the newX and newY values. */ + dsp->Vissible.x = bound(0, newX, dsp->Display.width - dsp->Vissible.width); + dsp->Vissible.y = bound(0, newY, dsp->Display.height - dsp->Vissible.height); + + newX = (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width); + newY = (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height); + + XMoveWindow( dsp->display_id, dsp->HorScrollButton, newX, -dsp->InternalBorderWidth); + XMoveWindow( dsp->display_id, dsp->VerScrollButton, -dsp->InternalBorderWidth, newY ); + + (dsp->bitblt_to_screen)( dsp, 0, dsp->Vissible.x, dsp->Vissible.y, + dsp->Vissible.width, dsp->Vissible.height); +}/* end Scroll */ diff --git a/src/xwinman.c b/src/xwinman.c new file mode 100755 index 0000000..95ee745 --- /dev/null +++ b/src/xwinman.c @@ -0,0 +1,420 @@ +/* $Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ Copyright (C) Venue"; + + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 2000 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + + +#include "version.h" + + + + +#include + +#include +#include + +#ifdef ISC +#include +#endif /* ISC */ + +#include "lispemul.h" +#include "devif.h" +#include "xdefs.h" + +int Mouse_Included = FALSE; + +extern Cursor WaitCursor, + DefaultCursor, + VertScrollCursor, + VertThumbCursor, + ScrollUpCursor, + ScrollDownCursor, + HorizScrollCursor, + HorizThumbCursor, + ScrollLeftCursor, + ScrollRightCursor; + +extern DspInterface currentdsp, colordsp; + +extern DLword *EmCursorX68K + , *EmCursorY68K; +extern DLword *EmMouseX68K + , *EmMouseY68K + , *EmKbdAd068K + , *EmRealUtilin68K; +extern LispPTR *CLastUserActionCell68k; +extern MISCSTATS *MiscStats; +extern int KBDEventFlg; +extern u_char *SUNLispKeyMap; +#define KEYCODE_OFFSET 7 /* Sun Keycode offset */ + +#define MOUSE_LEFT 13 +#define MOUSE_MIDDLE 15 +#define MOUSE_RIGHT 14 + + + + +/* bound: return b if it is between a and c otherwise it returns a or c */ +int bound( a, b, c) + int a, b, c; +{ + if (b <= a) return( a ); + else if ( b >= c ) return( c ); + else return( b ); +} + + + + + +Set_BitGravity( event, dsp, window, grav ) + XButtonEvent *event; + DspInterface dsp; + Window window; + int grav; +{ + XSetWindowAttributes Lisp_SetWinAttributes; + Window OldWindow; + + /* Change Background Pixmap of Gravity Window */ + XLOCK; + switch( dsp->BitGravity ) { + case NorthWestGravity: OldWindow = dsp->NWGrav; + break; + case NorthEastGravity: OldWindow = dsp->NEGrav; + break; + case SouthWestGravity: OldWindow = dsp->SWGrav; + break; + case SouthEastGravity: OldWindow = dsp->SEGrav; + break; + }; + + dsp->BitGravity = grav; + + XSetWindowBackgroundPixmap( event->display , OldWindow + , dsp->GravityOffPixmap ); + XClearWindow( event->display, OldWindow ); + + XSetWindowBackgroundPixmap( event->display , window + , dsp->GravityOnPixmap ); + XClearWindow( event->display, window ); + XUNLOCK; +} /* end Set_BitGravity */ + + +lisp_Xconfigure( dsp, x, y, lspWinWidth, lspWinHeight ) + DspInterface dsp; + int x, y, lspWinWidth, lspWinHeight; +{ + int GravSize, Col2, Row2, Col3, Row3; + + /* The Vissible width and height changes when */ + /* we configure the window. Make them */ + /* stay within bounds. */ + dsp->Vissible.width = bound(OUTER_SB_WIDTH(dsp)+2, + lspWinWidth, + dsp->Display.width + OUTER_SB_WIDTH(dsp)) - OUTER_SB_WIDTH(dsp); + dsp->Vissible.height = bound(OUTER_SB_WIDTH(dsp)+2, + lspWinHeight, + dsp->Display.height + OUTER_SB_WIDTH(dsp)) - OUTER_SB_WIDTH(dsp); + + GravSize = (int)(dsp->ScrollBarWidth/2) - (dsp->InternalBorderWidth); + Col2 = dsp->Vissible.width; + Row2 = dsp->Vissible.height; + Col3 = dsp->Vissible.width + (int)(OUTER_SB_WIDTH(dsp)/2); + Row3 = dsp->Vissible.height + (int)(OUTER_SB_WIDTH(dsp)/2); + + XLOCK; + XMoveResizeWindow( dsp->display_id, dsp->DisplayWindow, 0, 0, dsp->Vissible.width, dsp->Vissible.height); + /* Scroll bars */ + XMoveResizeWindow( dsp->display_id, dsp->VerScrollBar, + Col2, 0-dsp->InternalBorderWidth, /* y */ + dsp->ScrollBarWidth, /* width */ + dsp->Vissible.height); /* height */ + XMoveResizeWindow( dsp->display_id, + dsp->HorScrollBar, + 0-dsp->InternalBorderWidth, Row2, /* y */ + dsp->Vissible.width, /* width */ + dsp->ScrollBarWidth); /* height */ + + /* Scroll buttons */ + XMoveResizeWindow( dsp->display_id, + dsp->HorScrollButton, + (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width), /* x */ + 0-dsp->InternalBorderWidth, /* y */ + (int)((dsp->Vissible.width*dsp->Vissible.width)/ dsp->Display.width) + 1, /* width */ + dsp->ScrollBarWidth); /* height */ + XMoveResizeWindow( dsp->display_id, + dsp->VerScrollButton, + 0-dsp->InternalBorderWidth, /* x */ + (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height), /* y */ + dsp->ScrollBarWidth, /* width */ + (int)((dsp->Vissible.height*dsp->Vissible.height) / dsp->Display.height) + 1); /* height */ + + /* Gravity windows */ + XMoveResizeWindow( dsp->display_id, dsp->NWGrav, Col2, Row2, GravSize, GravSize); + XMoveResizeWindow( dsp->display_id, dsp->NEGrav, Col3, Row2, GravSize, GravSize); + XMoveResizeWindow( dsp->display_id, dsp->SEGrav, Col3, Row3, GravSize, GravSize); + XMoveResizeWindow( dsp->display_id, dsp->SWGrav, Col2, Row3, GravSize, GravSize); + Scroll( dsp, dsp->Vissible.x, dsp->Vissible.y ); + XFlush(dsp->display_id); + XUNLOCK; +} /* end lisp_Xconfigure */ + + + + +/************************************************************************/ +/* */ +/* g e t X s i g n a l d a t a */ +/* */ +/* Take X key/mouse events and turn them into Lisp events */ +/* */ +/************************************************************************/ + +extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ + +void +getXsignaldata(dsp) + DspInterface dsp; + { + XEvent report; + + while( XPending( dsp->display_id ) ) + { + XNextEvent( dsp->display_id, &report ); + if( report.xany.window == dsp->DisplayWindow ) /* Try the most important window first. */ + switch(report.type) { + case MotionNotify : + *CLastUserActionCell68k = MiscStats->secondstmp; + *EmCursorX68K = (*((DLword *)EmMouseX68K)) = (short) ((report.xmotion.x + dsp->Vissible.x)&0xFFFF) - Current_Hot_X; + *EmCursorY68K = (*((DLword *)EmMouseY68K)) = (short) ((report.xmotion.y + dsp->Vissible.y)&0xFFFF) - Current_Hot_Y; + DoRing(); + if(( KBDEventFlg ) > 0) Irq_Stk_End=Irq_Stk_Check=0; + break; + case KeyPress : + kb_trans( SUNLispKeyMap[(report.xkey.keycode)-KEYCODE_OFFSET], FALSE ); + DoRing(); + if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; + break; + case KeyRelease : + kb_trans( SUNLispKeyMap[(report.xkey.keycode)-KEYCODE_OFFSET], TRUE ); + DoRing(); + if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; + break; + case ButtonPress : + switch (report.xbutton.button) { + case Button1: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_LEFT, FALSE ); + break; + case Button2: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_MIDDLE, FALSE ); + break; + case Button3: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_RIGHT, FALSE ); + break; + default: + break; + } + DoRing(); + if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; + break; + case ButtonRelease : + switch (report.xbutton.button) { + case Button1: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_LEFT, TRUE ); + break; + case Button2: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_MIDDLE, TRUE); + break; + case Button3: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_RIGHT, TRUE ); + break; + default: + break; + } + DoRing(); + if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; + break; + case EnterNotify : + Mouse_Included = TRUE; + break; + case LeaveNotify : + Mouse_Included = FALSE; + break; + case Expose : + XLOCK; + (dsp->bitblt_to_screen)( dsp, 0, + report.xexpose.x+dsp->Vissible.x, + report.xexpose.y+dsp->Vissible.y, + report.xexpose.width, + report.xexpose.height ); + XUNLOCK; + break; + default: + break; + } + else if( report.xany.window == dsp->LispWindow ) + switch(report.xany.type) { + case ConfigureNotify : + lisp_Xconfigure(dsp, report.xconfigure.x, report.xconfigure.y, + report.xconfigure.width, report.xconfigure.height); + break; + case EnterNotify : + enable_Xkeyboard( currentdsp ); + break; + case LeaveNotify : + break; + case MapNotify : + /* Turn the blitting to the screen on */ + break; + case UnmapNotify : + /* Turn the blitting to the screen off */ + break; + default: + break; + } + else if ( report.xany.window == dsp->HorScrollBar ) + switch(report.type) { + case ButtonPress : + switch( report.xbutton.button ) { + case Button1: + DefineCursor( dsp->display_id, dsp->HorScrollBar, &ScrollLeftCursor ); + ScrollLeft( dsp, report ); + break; + case Button2: + DefineCursor( dsp->display_id, dsp->HorScrollBar, &HorizThumbCursor ); + break; + case Button3: + DefineCursor( dsp->display_id, dsp->HorScrollBar, &ScrollRightCursor ); + ScrollRight( dsp, report ); + break; + default: + break; + } /* end switch */ + break; + case ButtonRelease : + switch( report.xbutton.button ) { + case Button1: + DefineCursor( dsp->display_id, report.xany.window, &HorizScrollCursor ); + break; + case Button2: + JumpScrollHor( dsp, report.xbutton.x ); + DefineCursor( dsp->display_id, report.xany.window, &HorizScrollCursor ); + break; + case Button3: + DefineCursor( dsp->display_id, report.xany.window, &HorizScrollCursor ); + break; + default: + break; + } /* end switch */ + default: + break; + } + else if ( report.xany.window == dsp->VerScrollBar ) + switch(report.type) { + case ButtonPress : + switch( report.xbutton.button ) { + case Button1: + DefineCursor( dsp->display_id, report.xany.window, &ScrollUpCursor ); + ScrollUp( dsp ); + break; + case Button2: + DefineCursor( dsp->display_id, report.xany.window, &VertThumbCursor ); + break; + case Button3: + DefineCursor( dsp->display_id, report.xany.window, &ScrollDownCursor ); + ScrollDown( dsp ); + break; + default: + break; + } /* end switch */ + break; + case ButtonRelease : + switch( report.xbutton.button ) { + case Button1: + DefineCursor( dsp->display_id, report.xany.window, &VertScrollCursor ); + break; + case Button3: + DefineCursor( dsp->display_id, report.xany.window, &VertScrollCursor ); + break; + case Button2: + JumpScrollVer( dsp, report.xbutton.y ); + DefineCursor( dsp->display_id, report.xany.window, &VertScrollCursor ); + break; + default: + break; + } /* end switch */ + break; + default: + break; + } + else if (( report.xany.window == dsp->NEGrav ) && + ( report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(report, dsp, dsp->NEGrav, NorthEastGravity); + else if (( report.xany.window == dsp->SEGrav ) && + ( report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(report, dsp, dsp->SEGrav, SouthEastGravity); + else if (( report.xany.window == dsp->SWGrav ) && + ( report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(report, dsp, dsp->SWGrav, SouthWestGravity); + else if (( report.xany.window == dsp->NWGrav ) && + ( report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(report, dsp, dsp->NWGrav, NorthWestGravity); + XFlush(dsp->display_id); + } /* end while */ + } /* end getXsignaldata() */ + + +enable_Xkeyboard( dsp ) + DspInterface dsp; +{ + XLOCK; + XSelectInput( dsp->display_id, + dsp->DisplayWindow, + dsp->EnableEventMask ); + XFlush( dsp->display_id ); + XUNLOCK; +} + + + +disable_Xkeyboard( dsp ) + DspInterface dsp; +{ + XLOCK; + XSelectInput( dsp->display_id, + dsp->DisplayWindow, + dsp->DisableEventMask ); + XFlush( dsp->display_id ); + XUNLOCK; +} + +beep_Xkeyboard( dsp ) + DspInterface dsp; +{ +#ifdef TRACE + printf( "TRACE: beep_Xkeyboard()\n" ); +#endif + + XLOCK; + XBell( dsp->display_id, (int) 50 ); + XFlush( dsp->display_id ); + XUNLOCK; + + +} /* end beep_Xkeyboard */ + diff --git a/src/z2.c b/src/z2.c new file mode 100755 index 0000000..8ae0da1 --- /dev/null +++ b/src/z2.c @@ -0,0 +1,182 @@ +/* $Id: z2.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: z2.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright (C) Venue"; +/* + * Author : don charnley + */ +/***********************************************************************/ +/* + File Name : z2.c + + Including : N_OP_clfmemb -- op 035 + N_OP_classoc -- op 033 + N_OP_restlist -- op 043 + +*/ +/**********************************************************************/ + + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + + + +#include +#include "lispemul.h" +#include "emlglob.h" +#include "lspglob.h" +#include "lispmap.h" +#include "lsptypes.h" +#include "address.h" +#include "adr68k.h" +#include "cell.h" +#include "stack.h" +#include "gc.h" +#include "my.h" + +struct cadr_cell cadr(LispPTR cell_adr); + +/* N_OP_classoc() OP 33Q */ +N_OP_classoc(LispPTR key, LispPTR list) +{ +REGISTER struct cadr_cell cadr1; +register LispPTR cdrcell; /* address of (cdr A-list); Lisp address */ + + + switch (key & SEGMASK) { + case S_POSITIVE: break; + case S_NEGATIVE: break; + case S_CHARACTER: break; + case ATOM_OFFSET: break; + default: ERROR_EXIT(list); + } + /* JRB - Don Charnley claims the code below should be identical to the + code in IL:ASSOC, so I copied my new and exciting version over */ + + if (list == NIL_PTR) { return(NIL_PTR); } + + if (GetTypeNumber( list ) != TYPE_LISTP) { return(NIL_PTR); } + + + S_N_CHECKANDCADR(list, cadr1, list); + + do{ + cdrcell = cadr1.cdr_cell; /* the rest of A-list */ + if(Listp(cadr1.car_cell) && key == car(cadr1.car_cell)){ + /* cons data found */ + return(cadr1.car_cell); + } + /* search the rest of A-list */ + if(Listp(cdrcell)) + cadr1 = cadr(cdrcell); + else cdrcell = NIL; + /* check for interrupts and punt to handle one safely */ + if (!Irq_Stk_End) { + TopOfStack = cdrcell; /* for continuation */ + TIMER_EXIT(cdrcell); + } + }while(cdrcell != NIL_PTR); + + return(NIL_PTR); +} /* end N_OP_classoc() */ + +/* (CL:FMEMB item list) OP 35Q */ +N_OP_clfmemb(register LispPTR item, register LispPTR list) +{ /* OP 35Q */ + + + switch (item & SEGMASK) { + case S_POSITIVE: break; + case S_NEGATIVE: break; + case S_CHARACTER: break; + case ATOM_OFFSET: break; + default: ERROR_EXIT(list); + } + /* JRB - Don Charnley claims the code below should be identical to IL:FMEMB, + so I copied it */ + + while(Listp(list)) { + if(item == car(list)) + return list; + list = cdr(list); + /* if we get an interrupt, punt so we can handle it safely */ + if(!Irq_Stk_End) { + TopOfStack = list; /* for continuation */ + TIMER_EXIT(list); + } + } + if(list) ERROR_EXIT( list); + return list; + +} /* end N_OP_clfmemb() */ + + +/************************************************************ + 43 RESTLIST + + alpha = skip -- number of args to skip + tos = last -- last arg# + tos-1 = tail + + IF tail = NIL THEN + page _ NEXTCONSPAGE + GOTO make + ELSE + AddRef tail + page _ CONSPAGE[tail] + GOTO make + make: + get [cnt,,next] from page + make1: + tail _ CONSCELL (CAR = IVar(last), CDR = tail) + AddRef IVar(last) + IF skip = last THEN GOTO fin + last _ last - 1 + GOTO make1 + noroomonconspage: + fin: + store updated [cnt,,next] + update ListpDTD:COUNTER + DelRef tail + IF noroomonconspage THEN UFN + ELSEIF ListpDTD:COUNTER overflow then GCPUNT + ELSEIF overflow entries then GCHANDLEOVERFLOW + ELSE NEXTOPCODE + + alpha = skip -- number of args to skip + tos = last -- last arg# + tos-1 = tail + + AddRef tail +make1: tail , cons(IVar(last), tail) + AddRef IVar(last) + IF skip = last THEN GOTO fin + last _ last - 1 + GOTO make1 + +fin: DelRef tail + +***********************************************************/ + +N_OP_restlist(register LispPTR tail, register int last, register int skip) +{ + + last &= 0xFFFF; + while (skip <= last) { + tail = cons(GetLongWord(IVar + (--last << 1)), tail); + } + return(tail); +}/* end N_OP_restlist() */ + + /* end module */