2 * io.c -- all the code to make GCC and the libraries run on
10 #include "hppa-defs.h"
12 extern char *_end
; /* _end is set in the linker command file */
14 /* just in case, most boards have at least some memory */
16 # define RAMSIZE (char *)0x100000
33 char *BufPtr
= Buffer
;
36 for (Count
= 7 ; Count
>= 0 ; Count
--) {
37 Digit
= (Num
>> (Count
* 4)) & 0xf;
40 *BufPtr
++ = (char) ('0' + Digit
);
42 *BufPtr
++ = (char) ('a' - 10 + Digit
);
60 * strobe -- do a zylons thing, toggling each led in sequence forever...
71 * strobe -- toggle each led in sequence up and back once.
76 static unsigned char curled
= 1;
77 static unsigned char dir
= 0;
98 * iodc_io_call -- this makes a call into the IODC routine
101 iodc_io_call(ep_address
,arg0
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
,arg7
,arg8
,arg9
,arg10
,arg11
)
102 int ep_address
, arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
, arg7
, arg8
, arg9
, arg10
, arg11
;
104 int (*iodc_entry_point
)();
106 iodc_entry_point
= (int (*)())ep_address
;
108 return ((*iodc_entry_point
)(arg0
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
,arg7
,arg8
,arg9
,arg10
,arg11
));
112 * pdc_call -- this makes a call into the PDC routine
115 pdc_call(arg0
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
,arg7
,arg8
,arg9
,arg10
,arg11
)
116 int arg0
, arg1
, arg2
, arg3
, arg4
, arg5
;
117 int arg6
, arg7
, arg9
, arg10
, arg11
;
119 return ( CALL_PDC(arg0
,arg1
,arg2
,arg3
,arg4
,arg5
,arg6
,arg7
,arg8
,arg9
,arg10
,arg11
));
123 * put_led -- put a bit pattern on the LED's.
129 return (pdc_call(OPT_PDC_CHASSIS
,0,byte
));
134 * outbyte -- shove a byte out the serial port
142 struct _dev
*console
= (struct _dev
*)PGZ_CONSOLE_STRUCT
;
144 status
= iodc_io_call(console
->iodc_io
, console
->hpa
, IO_CONSOLE_OUTPUT
, console
->spa
,
145 console
->layer
[0], R_addr
, 0, &byte
, 1, 0);
150 default: return (-1);
155 * inbyte -- get a byte from the serial port
163 struct _dev
*console
= (struct _dev
*)PGZ_CONSOLE_STRUCT
;
165 while (status
== 0) {
166 status
= iodc_io_call(console
->iodc_io
, console
->hpa
, IO_CONSOLE_INPUT
, console
->spa
,
167 console
->layer
[0], R_addr
, 0, &inbuf
, 1, 0);
171 case 2: /* recoverable error */
172 if (R_addr
[0] != 0) { /* found a character */
176 break; /* error, no character */
177 default: /* error, no character */
184 * read -- read bytes from the serial port. Ignore fd, since
185 * we only have stdin.
188 read(fd
, buf
, nbytes
)
195 for (i
= 0; i
< nbytes
; i
++) {
196 *(buf
+ i
) = inbyte();
197 if ((*(buf
+ i
) == '\n') || (*(buf
+ i
) == '\r')) {
206 * write -- write bytes to the serial port. Ignore fd, since
207 * stdout and stderr are the same. Since we have no filesystem,
208 * open will only return an error.
211 write(fd
, buf
, nbytes
)
218 for (i
= 0; i
< nbytes
; i
++) {
219 if (*(buf
+ i
) == '\n') {
222 outbyte (*(buf
+ i
));
228 * open -- open a file descriptor. We don't have a filesystem, so
229 * we return an error.
232 open(buf
, flags
, mode
)
242 * close -- close a file descriptor. We don't need
243 * to do anything, but pretend we did.
253 * sbrk -- changes heap size size. Get nbytes more
254 * RAM. We just increment a pointer in what's
255 * left of memory on the board.
261 static char * heap_ptr
= NULL
;
264 if (heap_ptr
== NULL
) {
265 heap_ptr
= (char *)&_end
;
268 if ((RAMSIZE
- heap_ptr
) >= 0) {
279 * isatty -- returns 1 if connected to a terminal device,
280 * returns 0 if not. Since we're hooked up to a
281 * serial port, we'll say yes return a 1.
291 * lseek -- move read/write pointer. Since a serial port
292 * is non-seekable, we return an error.
295 lseek(fd
, offset
, whence
)
305 * fstat -- get status of a file. Since we have no file
306 * system, we just return an error.
318 * getpid -- only one process, so just return 1.
328 * kill -- assume mvme.S, and go out via exit...