forked from unya/usim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlashup.c
109 lines (99 loc) · 1.96 KB
/
lashup.c
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
int fd;
void
lashup_init(char *port)
{
int err;
struct termios oldtio;
struct termios newtio;
fd = open(port, O_RDWR | O_NONBLOCK);
if (fd < 0) {
perror(port);
exit (1);
}
// Get current port settings.
err = tcgetattr(fd, &oldtio);
if (err) {
perror("tcgetattr");
exit(1);
}
newtio = oldtio;
cfmakeraw(&newtio);
// Set new port settings for canonical input processing.
cfsetspeed(&newtio, B115200);
newtio.c_cflag |= CS8 | CLOCAL | CREAD;
newtio.c_iflag |= IGNPAR;
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
tcflush(fd, TCIFLUSH);
err = tcsetattr(fd, TCSANOW, &newtio);
if (err) {
perror("tcsetattr");
exit(1);
}
}
void
lashup_unibus_read(int offset, unsigned int *pv)
{
switch (offset) {
case 0100:
printf("lashup: reading from debugee\n");
break;
case 0114:
printf("lashup: reading from write only address (debugee address)\n");
break;
case 0110:
printf("lashup: reading from write only address (modifier bits)\n");
break;
case 0104:
printf("lashup: bus cycle)\n");
break;
default:
printf("lashup: read: unknown offset\n");
break;
}
}
void
lashup_unibus_write(int offset, unsigned int v)
{
switch (offset) {
case 0100:
printf("lashup: writing to debugee\n");
break;
case 0114:
printf("lashup: unibus debugee 1-16 bits\n");
break;
case 0110: {
int bits = v;
printf("lashup: writing modifier bits\n");
switch (bits) {
case 01:
printf("\tbit 17 of debugee unibus address\n");
break;
case 02:
printf("\treset debugee bus interface\n");
break;
case 04:
printf("\ttimeout inhibit\n");
break;
default:
printf("\tunknown modifier bit: %o; v %o\n", bits, v);
break;
}
break;
}
case 0104:
printf("lashup: writing to read-only address (bus cycle)\n");
break;
default:
printf("lashup: write: unknown offset\n");
break;
}
}