1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%
3% File:         PXK:IO.SL
4% Description:  Minimal I/O for the kernel.
5% Author:       Brian Beach, Hewlett-Packard CRC
6% Created:      16-Feb-84
7% Modified:     29-Jun-84 12:26:04 (RAM)
8% Mode:         Lisp
9% Package:
10% Status:       Experimental (Do Not Distribute)
11%
12% (c) Copyright 1984, Hewlett-Packard Company, all rights reserved.
13%
14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15%
16% Revisions:
17%
18% 29-Jun-84 12:22:21 (RAM)
19%  Changed console-print-string to make one call to unixputs rather than
20%  multiple calls to unixputc.
21%  Removed definition of unixputn (it was only there for debugging).
22%  Changed binaryopenread to call unixopen rather than fopen.  Unixopen
23%  can be extended to expand $names properly, etc, eliminating the need
24%  for the HPUX-PATH stuff.
25%
26%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28(on fast-integers)
29
30%(fluid '(onewordbuffer))
31
32(de console-print-string (string)
33 (unixputs (strbase (strinf string))))
34
35%  (let ((upper-bound (strlen (strinf string))))
36%  ` (for (from i 0 upper-bound)
37%         (do (unixputc (strbyt (strinf string) i)))
38%         )))
39
40(de console-print-number (num)
41  (unixputn (wshift num -32) (wshift (wshift num 32) -32)))
42
43(de console-newline ()
44  (unixputc (char lf))
45  )
46
47(de binaryopenread (filename)
48  (let ((f (unixopen (strbase (strinf filename)) (strbase (strinf "r")))))
49        (if (weq f 0)
50            (kernel-fatal-error
51		(kernelstring2string "Couldn't open binary file for input"))
52            f)))
53
54(de binaryread (filepointer)            % Read one word, 32 bits.
55  (xgetw filepointer)
56  )
57
58(de binaryreadblock (filepointer blockbase blocksize)
59  (fread blockbase 8 blocksize filepointer)
60  )
61
62(de binaryclose (filepointer)
63  (fclose filepointer)
64  )
65
66(off fast-integers)
67
68
69
70