annotate lcdpoll/main.c @ 10:ad0d9f7c06e9 default tip

README: update for the present situation
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 29 Dec 2019 23:01:26 +0000
parents 45c81216d964
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This is the main module for fc-lcdpoll.
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdlib.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/etm.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <rvinterf/localtypes.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <rvinterf/exitcodes.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern char *socket_pathname;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u32 framebuffer_base_addr;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 emit_lcd_string(row, col, buf)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned row, col;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 u_char *buf;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 unsigned pos;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 printf("%u %u ", row, col);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 for (pos = 0; pos < 176; pos += 2)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 printf("%02X%02X", buf[pos+1] ^ 0xFF, buf[pos] ^ 0xFF);
5
45c81216d964 fc-lcdpoll: works after minor fix
Mychaela Falconia <falcon@freecalypso.org>
parents: 3
diff changeset
29 putchar('\n');
3
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 fb_poll()
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 unsigned row;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 u_char buf[176];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 int rc;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (row = 0; row < 220; row++) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 rc = do_memory_read_32(framebuffer_base_addr + row * 356,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 buf, 44);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (rc)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 exit(rc);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 emit_lcd_string(row, 0, buf);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 rc = do_memory_read_32(framebuffer_base_addr + row * 356 + 176,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 buf, 44);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (rc)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 exit(rc);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 emit_lcd_string(row, 88, buf);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 fflush(stdout);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 main(argc, argv)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 char **argv;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 extern int optind;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 extern char *optarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 int c, sopt = 0;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 switch (c) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 case 'B':
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 rvinterf_Bopt = optarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 continue;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 case 'l':
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 rvinterf_lopt = optarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 continue;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 case 'p':
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 rvinterf_ttyport = optarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 continue;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 case 's':
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 socket_pathname = optarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 sopt++;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 continue;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 case 'w':
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 rvinterf_wopt = optarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 continue;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 case '?':
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 default:
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 /* error msg already printed */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 exit(ERROR_USAGE);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (rvinterf_ttyport) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 if (sopt) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 fprintf(stderr,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 "%s error: -p and -s options are mutually exclusive\n",
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 argv[0]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 exit(ERROR_USAGE);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 launch_rvinterf();
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 } else {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 fprintf(stderr,
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 argv[0]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 exit(ERROR_USAGE);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 connect_local_socket();
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 if (argc != optind + 1) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 fprintf(stderr, "usage: %s [options] framebuffer_base_addr\n",
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 argv[0]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 exit(ERROR_USAGE);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 framebuffer_base_addr = strtoul(argv[optind], 0, 16);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 for (;;)
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 fb_poll();
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 }