usim

Check-in [569f1e1a5a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Clean up indentation slightly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 569f1e1a5a6fc4ba6c252dca6162d40580f22209c2b933a6e6094c44b3373ff3
User & Date: ams 2024-06-26 10:36:32
Context
2024-06-26
15:42
Makefile (CFLAGS): Add -I/opt/local/include for OS X users. check-in: 3c3c94e444 user: ams tags: trunk
10:36
Clean up indentation slightly. check-in: 569f1e1a5a user: ams tags: trunk
08:47
Merge ams/sdl to trunk. check-in: 4121b8f3e7 user: ams tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to cadet.c.

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
static void
cadet_process_shift(int scc, int keydown)
{
	int shift;
	DEBUG(TRACE_KBD, "cadet_process_shift(scc = 0%o, keydown = %d)\n", scc, keydown);
	switch (scc) {
	case CADET_LEFT_GREEK: case CADET_RIGHT_GREEK: shift = (1 << CADET_IX_GREEK); break;
	case CADET_LEFT_TOP:   case CADET_RIGHT_TOP:   shift = (1 << CADET_IX_TOP); break;
	case CADET_LEFT_SHIFT: case CADET_RIGHT_SHIFT: shift = (1 << CADET_IX_SHIFT); break;
	default: return;
	}
	if (keydown) {
		cadet_shifts |= shift;
	} else {
		cadet_shifts &= ~shift;
	}
}

void
cadet_process_key(int keysym,	/* keysym, acts as index into kbd_map */
    int bi,			/* bucky, acts as index into modifier_map */
    int keydown,		/* if key is down or up */
    bool (*allup_key)(void)
    )
{
	int lmchar;		/* Lisp Machine charachter to insert */
	int scc;		/* Space Cadet scancode. */
	int wantshift;		/* Index into second column in cadet_kbd_map. */
	int shkey;		/* Shift key being pressed. */
	int oshift;








|















|







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
static void
cadet_process_shift(int scc, int keydown)
{
	int shift;
	DEBUG(TRACE_KBD, "cadet_process_shift(scc = 0%o, keydown = %d)\n", scc, keydown);
	switch (scc) {
	case CADET_LEFT_GREEK: case CADET_RIGHT_GREEK: shift = (1 << CADET_IX_GREEK); break;
	case CADET_LEFT_TOP:   case CADET_RIGHT_TOP:   shift = (1 << CADET_IX_TOP);   break;
	case CADET_LEFT_SHIFT: case CADET_RIGHT_SHIFT: shift = (1 << CADET_IX_SHIFT); break;
	default: return;
	}
	if (keydown) {
		cadet_shifts |= shift;
	} else {
		cadet_shifts &= ~shift;
	}
}

void
cadet_process_key(int keysym,	/* keysym, acts as index into kbd_map */
    int bi,			/* bucky, acts as index into modifier_map */
    int keydown,		/* if key is down or up */
    bool (*allup_key)(void)
	)
{
	int lmchar;		/* Lisp Machine charachter to insert */
	int scc;		/* Space Cadet scancode. */
	int wantshift;		/* Index into second column in cadet_kbd_map. */
	int shkey;		/* Shift key being pressed. */
	int oshift;

Changes to idle.c.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "tv.h"
#include "ucode.h"
#include "usim.h"

static int working;
static size_t last_work;
static size_t last_cycle;
static int reported_idle;		/*debug */
static int drl;
static int disk_run_light;
size_t idle_cycles;
size_t idle_quantum;
size_t idle_timeout;
static idle_change_handler change_handler;








|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "tv.h"
#include "ucode.h"
#include "usim.h"

static int working;
static size_t last_work;
static size_t last_cycle;
static int reported_idle;	/*debug */
static int drl;
static int disk_run_light;
size_t idle_cycles;
size_t idle_quantum;
size_t idle_timeout;
static idle_change_handler change_handler;

Changes to misc.c.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "misc.h"

ssize_t
xgetline(char **l, size_t *n, FILE *f)
{
	int old_errno = errno;
	size_t ret;
	
	old_errno = errno;
	errno = 0;
	ret = getline (l, n, f);
	if (!feof (f) && ferror (f)) {
		perror("getline failed");
		exit(EXIT_FAILURE);
	}
	errno = old_errno;
	return ret;
}








|


|
|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "misc.h"

ssize_t
xgetline(char **l, size_t *n, FILE *f)
{
	int old_errno = errno;
	size_t ret;

	old_errno = errno;
	errno = 0;
	ret = getline(l, n, f);
	if (!feof(f) && ferror(f)) {
		perror("getline failed");
		exit(EXIT_FAILURE);
	}
	errno = old_errno;
	return ret;
}


Changes to sdl1.c.

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
		int bucky;

		if (state[i] != 1)
			continue;
		bucky = -1;
		// This needs to be cleaned up -- translates scancode to bucky xk/index
		switch (i) {
		case SDLK_LSHIFT: case SDLK_RSHIFT: bucky = kbd_modifier_map[ShiftMapIndex]; break;
		case SDLK_LCTRL: case SDLK_RCTRL: bucky = kbd_modifier_map[ControlMapIndex]; break;
		case SDLK_LALT: case SDLK_RALT: bucky = kbd_modifier_map[Mod1MapIndex]; break;
//		case SDLK_LGUI: case SDLK_RGUI:  bucky = kbd_modifier_map[Mod4MapIndex]; break;
//		case SDLK_LSUPER: case SDLK_RSUPER: 
//		case SDLK_MODE: bucky = kbd_modifier_map[Mod5MapIndex]; break;
//		case SDLK_MENU: bucky = kbd_modifier_map[KBD_NoSymbol]; break;
//		case SDLK_COMPOSE: bucky = kbd_modifier_map[]; break;
		case SDLK_CAPSLOCK:bucky = kbd_modifier_map[LockMapIndex]; break;
		}
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		cadet_press_bucky(bucky, &mods, &shifts);
	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;







|
|
|
|
|
|
|
|
|







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
		int bucky;

		if (state[i] != 1)
			continue;
		bucky = -1;
		// This needs to be cleaned up -- translates scancode to bucky xk/index
		switch (i) {
		case SDLK_LSHIFT: case SDLK_RSHIFT: bucky = kbd_modifier_map[ShiftMapIndex];   break;
		case SDLK_LCTRL:  case SDLK_RCTRL:  bucky = kbd_modifier_map[ControlMapIndex]; break;
		case SDLK_LALT:   case SDLK_RALT:   bucky = kbd_modifier_map[Mod1MapIndex];    break;
//              case SDLK_LGUI: case SDLK_RGUI:  bucky = kbd_modifier_map[Mod4MapIndex]; break;
//              case SDLK_LSUPER: case SDLK_RSUPER: 
//              case SDLK_MODE: bucky = kbd_modifier_map[Mod5MapIndex]; break;
//              case SDLK_MENU: bucky = kbd_modifier_map[KBD_NoSymbol]; break;
//              case SDLK_COMPOSE: bucky = kbd_modifier_map[]; break;
		case SDLK_CAPSLOCK: bucky = kbd_modifier_map[LockMapIndex]; break;
		}
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		cadet_press_bucky(bucky, &mods, &shifts);
	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
		cadet_process_key(keysym /* xk_keysym */ , bi, keydown, &cadet_allup_key);
	}
}

void
update(int u_minh, int u_minv, int hs, int vs)
{
		SDL_UpdateRect(screen, u_minh, u_minv, hs, vs);
}

void
sdl1_event(void)
{
	SDL_Event ev;








|







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
		cadet_process_key(keysym /* xk_keysym */ , bi, keydown, &cadet_allup_key);
	}
}

void
update(int u_minh, int u_minv, int hs, int vs)
{
	SDL_UpdateRect(screen, u_minh, u_minv, hs, vs);
}

void
sdl1_event(void)
{
	SDL_Event ev;

Changes to sdl1.h.

1
2
3
4
5
6
7
8
9
10
#pragma once

#include <SDL.h>

extern void sdl1_init(void);
extern void sdl1_event(void);

SDL_Surface *screen; 		/* hack */

extern void sdl1_beep(int);







|


1
2
3
4
5
6
7
8
9
10
#pragma once

#include <SDL.h>

extern void sdl1_init(void);
extern void sdl1_event(void);

SDL_Surface *screen;		/* hack */

extern void sdl1_beep(int);

Changes to sdl2.c.

149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	shifts = 0;

	state = SDL_GetKeyboardState(&statesize);
	for (int i = 0; allup && i < statesize; i++) {
		int bucky;

		if (state[i] != 1)
			continue; /* bucky not pressed */
		bucky = -1;
		// This needs to be cleaned up -- translates scancode to bucky xk/index
		switch (SDL_GetKeyFromScancode(i)) {
		case SDLK_LSHIFT: case SDLK_RSHIFT: bucky = kbd_modifier_map[ShiftMapIndex]; break;
		case SDLK_LCTRL: case SDLK_RCTRL: bucky = kbd_modifier_map[ControlMapIndex]; break;
		case SDLK_LALT: case SDLK_RALT: bucky = kbd_modifier_map[Mod1MapIndex]; break;
		case SDLK_LGUI: case SDLK_RGUI:  bucky = kbd_modifier_map[Mod4MapIndex]; break;
//		case SDLK_LSUPER: case SDLK_RSUPER: 
//		case SDLK_MODE: bucky = kbd_modifier_map[Mod5MapIndex]; break;
//		case SDLK_MENU: bucky = kbd_modifier_map[KBD_NoSymbol]; break;
//		case SDLK_COMPOSE: bucky = kbd_modifier_map[]; break;
		case SDLK_CAPSLOCK:bucky = kbd_modifier_map[LockMapIndex]; break;
		}
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		cadet_press_bucky(bucky, &mods, &shifts);
	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;







|



|
|
|
|
|
|
|
|
|







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	shifts = 0;

	state = SDL_GetKeyboardState(&statesize);
	for (int i = 0; allup && i < statesize; i++) {
		int bucky;

		if (state[i] != 1)
			continue;	/* bucky not pressed */
		bucky = -1;
		// This needs to be cleaned up -- translates scancode to bucky xk/index
		switch (SDL_GetKeyFromScancode(i)) {
		case SDLK_LSHIFT: case SDLK_RSHIFT: bucky = kbd_modifier_map[ShiftMapIndex];   break;
		case SDLK_LCTRL:  case SDLK_RCTRL:  bucky = kbd_modifier_map[ControlMapIndex]; break;
		case SDLK_LALT:   case SDLK_RALT:   bucky = kbd_modifier_map[Mod1MapIndex];    break;
		case SDLK_LGUI:   case SDLK_RGUI:   bucky = kbd_modifier_map[Mod4MapIndex];    break;
//              case SDLK_LSUPER: case SDLK_RSUPER: 
//              case SDLK_MODE: bucky = kbd_modifier_map[Mod5MapIndex]; break;
//              case SDLK_MENU: bucky = kbd_modifier_map[KBD_NoSymbol]; break;
//              case SDLK_COMPOSE: bucky = kbd_modifier_map[]; break;
		case SDLK_CAPSLOCK: bucky = kbd_modifier_map[LockMapIndex]; break;
		}
		DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
		cadet_press_bucky(bucky, &mods, &shifts);
	}
	if (allup == true) {
		DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
		cadet_shifts = shifts;

Changes to tv.c.

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	if (v < u_minv)
		u_minv = v;
	if (v + vs > u_maxv)
		u_maxv = v + vs;
}

void
tv_update_screen(void (*fn)(int, int , int , int))
{
	int hs;
	int vs;

	hs = u_maxh - u_minh;
	vs = u_maxv - u_minv;
	if (u_minh != 0x7fffffff && u_minv != 0x7fffffff && u_maxh && u_maxv) {







|







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	if (v < u_minv)
		u_minv = v;
	if (v + vs > u_maxv)
		u_maxv = v + vs;
}

void
tv_update_screen(void (*fn)(int, int, int, int))
{
	int hs;
	int vs;

	hs = u_maxh - u_minh;
	vs = u_maxv - u_minv;
	if (u_minh != 0x7fffffff && u_minv != 0x7fffffff && u_maxh && u_maxv) {

Changes to tv.h.

13
14
15
16
17
18
19
20
extern void tv_init(void);
extern void tv_poll(void);
extern void tv_write(uint32_t, uint32_t);
extern void tv_read(uint32_t, uint32_t *);
extern void tv_xbus_read(uint32_t, uint32_t *);
extern void tv_xbus_write(uint32_t, uint32_t);
extern void tv_screenshot(char *);
extern void tv_update_screen(void (*fn)(int, int , int , int));







|
13
14
15
16
17
18
19
20
extern void tv_init(void);
extern void tv_poll(void);
extern void tv_write(uint32_t, uint32_t);
extern void tv_read(uint32_t, uint32_t *);
extern void tv_xbus_read(uint32_t, uint32_t *);
extern void tv_xbus_write(uint32_t, uint32_t);
extern void tv_screenshot(char *);
extern void tv_update_screen(void (*fn)(int, int, int, int));

Changes to uch11-chaosd.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
/* Connect to a chaos daemon via a Unix socket.
 */

#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
 
#include <netinet/in.h>
 
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
 
#include <err.h>
#include <pthread.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
 
#include "uch11.h"
#include "uch11-backend.h"
#include "chaosd.h"
#include "hosttab.h"
#include "misc.h"
#include "ucfg.h"
#include "ucode.h"










|

|




|









|







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
/* Connect to a chaos daemon via a Unix socket.
 */

#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>

#include <netinet/in.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>

#include <err.h>
#include <pthread.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "uch11.h"
#include "uch11-backend.h"
#include "chaosd.h"
#include "hosttab.h"
#include "misc.h"
#include "ucfg.h"
#include "ucode.h"

Changes to uch11-local.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
/* Local Chaos -- this should go into chlib.c
 */

#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
 
#include <netinet/in.h>
 
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
 
#include <err.h>
#include <pthread.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
 
#include "uch11.h"
#include "uch11-backend.h"
#include "chaosd.h"
#include "hosttab.h"
#include "misc.h"
#include "ucfg.h"
#include "ucode.h"










|

|




|









|







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
/* Local Chaos -- this should go into chlib.c
 */

#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>

#include <netinet/in.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>

#include <err.h>
#include <pthread.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include "uch11.h"
#include "uch11-backend.h"
#include "chaosd.h"
#include "hosttab.h"
#include "misc.h"
#include "ucfg.h"
#include "ucode.h"

Changes to uch11.c.

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
extern void uch11_reconnect(void);

extern void settreeroot(const char *, const char *prefix);

pthread_mutex_t recvqueue;
pthread_mutex_t recvqueue;
struct queue_head queuehead = TAILQ_HEAD_INITIALIZER(queuehead);


// udp

int chudpopen(void);
int chaos_send_to_udp(char *buffer, int size);
int chaos_poll_udp(void);








<







63
64
65
66
67
68
69

70
71
72
73
74
75
76
extern void uch11_reconnect(void);

extern void settreeroot(const char *, const char *prefix);

pthread_mutex_t recvqueue;
pthread_mutex_t recvqueue;
struct queue_head queuehead = TAILQ_HEAD_INITIALIZER(queuehead);


// udp

int chudpopen(void);
int chaos_send_to_udp(char *buffer, int size);
int chaos_poll_udp(void);

Changes to uexec.c.

219
220
221
222
223
224
225

226
227
228
229
230
231
232
233
		return res;
	case 6:
		return opc;
	case 7:
		return q;
	case 010:
		return mfmem[020];

	case 011: {		/* MEMORY-MAP-DATA */
		uint32_t l2_data;
		uint32_t l1_data;

		l1_data = 0;
		l2_data = 0;

		l2_data = map_vtop(mfmem[030], (int *) &l1_data, (int *) 0);







>
|







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
		return res;
	case 6:
		return opc;
	case 7:
		return q;
	case 010:
		return mfmem[020];
	case 011:
	{			/* MEMORY-MAP-DATA */
		uint32_t l2_data;
		uint32_t l1_data;

		l1_data = 0;
		l2_data = 0;

		l2_data = map_vtop(mfmem[030], (int *) &l1_data, (int *) 0);