comparison target-utils/simtest/poll.c @ 454:daaab2701761

target-utils: simtest program started
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Feb 2019 07:55:50 +0000
parents
children d96ea6ae6aa5
comparison
equal deleted inserted replaced
453:6228d27738d1 454:daaab2701761
1 #include <sys/types.h>
2 #include <strings.h>
3 #include "types.h"
4 #include "simregs.h"
5
6 extern int serial_in_poll();
7
8 int enable_poll;
9
10 void
11 poll_sim_rx()
12 {
13 u32 drx;
14
15 if (SIMREGS.stat & 3)
16 return;
17 drx = SIMREGS.drx & 0xFF;
18 printf("%02X ", drx);
19 }
20
21 int
22 mygetchar()
23 {
24 register int c;
25
26 do {
27 if (enable_poll)
28 poll_sim_rx();
29 c = serial_in_poll();
30 }
31 while (c < 0);
32 return c;
33 }
34
35 void
36 cmd_poll(argbulk)
37 char *argbulk;
38 {
39 char *argv[2];
40
41 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
42 return;
43 if (!strcmp(argv[0], "on"))
44 enable_poll = 1;
45 else if (!strcmp(argv[0], "off"))
46 enable_poll = 0;
47 else
48 printf("ERROR: \"on\" or \"off\" argument expected\n");
49 }