Skip to content

Commit

Permalink
added warm boot key
Browse files Browse the repository at this point in the history
  • Loading branch information
lisper committed Sep 13, 2005
1 parent 3b19edb commit 74a8998
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 31 deletions.
27 changes: 27 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,30 @@ diskmaker - program to make CADR disk images from .mcr files and
.lod files
lod - utiltity to pick apart load bands and show their insides


Standing on the Shoulders of Giants
-----------------------------------

I would like to thanks the following people for helping me on this, er,
project:

Tom Knight
Howard Shrobe
Richard Greenblatt
Danial Weinreb
Al Kossow
George Carrette
Steve Krueger
Alastair Bridgewater
John Wroclawski

Without their support or encouragement I would probably not have done
this. Certainly if Al had not sent me the prom images I would never
have started. And without Dan's box-of-tapes I could never have
succeeded. RG offered good explainations when I was confused. TK and
Howie were extremely supportive at the just right moment (and answered
a lot of email). George offered many good suggestions and answered
lots of qustions. Steve helped me locate missing pages from "memo
528". Alastair did some amazing work on several explorer emulators.
And John's office is where I first saw a 3600 console and said,
"what's that?".
99 changes: 85 additions & 14 deletions chaos.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sys/un.h>
#include <netinet/in.h>
#include <sys/poll.h>
#include <sys/uio.h>

#include "ucode.h"

Expand All @@ -25,6 +26,7 @@ int chaos_xmit_buffer_ptr;
unsigned short chaos_rcv_buffer[1600/2];
int chaos_rcv_buffer_ptr;
int chaos_rcv_buffer_size;
int chaos_rcv_buffer_empty;

int chaos_fd;

Expand Down Expand Up @@ -80,6 +82,13 @@ chaos_rx_pkt(void)
assert_unibus_interrupt(0404);
}

void
char_xmit_done_intr(void)
{
chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
assert_unibus_interrupt(0400);
}

void
chaos_xmit_pkt(void)
{
Expand All @@ -101,18 +110,18 @@ chaos_xmit_pkt(void)
printf("\n");

chaos_xmit_buffer_size = chaos_xmit_buffer_ptr;

chaos_xmit_buffer_ptr = 0;
chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
assert_unibus_interrupt(0400);

chaos_xmit_buffer[chaos_xmit_buffer_size++] = 0; /* source */
chaos_xmit_buffer[chaos_xmit_buffer_size++] = 0; /* checksum */
chaos_xmit_buffer[chaos_xmit_buffer_size++] = chaos_addr; /* source */
chaos_xmit_buffer[chaos_xmit_buffer_size++] = 0; /* checksum */

char_xmit_done_intr();

chaos_sent_to_chaosd((char *)chaos_xmit_buffer,
chaos_xmit_buffer_size*2);

#if 0
/* set back to ourselves - only for testing */
chaos_rcv_buffer_size = chaos_xmit_buffer_size + 2;
memcpy(chaos_rcv_buffer, chaos_xmit_buffer, chaos_xmit_buffer_size*2);

Expand Down Expand Up @@ -168,6 +177,10 @@ chaos_get_rcv_buffer(void)
int v = 0;
if (chaos_rcv_buffer_ptr < chaos_rcv_buffer_size) {
v = chaos_rcv_buffer[chaos_rcv_buffer_ptr++];

if (chaos_rcv_buffer_ptr == chaos_rcv_buffer_size)
chaos_rcv_buffer_empty = 1;

}
chaos_csr &= ~CHAOS_CSR_RECEIVE_DONE;
return v;
Expand Down Expand Up @@ -205,7 +218,7 @@ chaos_get_addr(void)
int
chaos_set_csr(int v)
{
int mask;
int mask, old_csr;
int send_fake;

v &= 0xffff;
Expand All @@ -215,6 +228,8 @@ chaos_set_csr(int v)
CHAOS_CSR_CRC_ERROR |
CHAOS_CSR_RECEIVE_DONE;

old_csr = chaos_csr;

chaos_csr = (chaos_csr & mask) | (v & ~mask);

send_fake = 0;
Expand All @@ -227,16 +242,20 @@ chaos_set_csr(int v)
}
if (chaos_csr & CHAOS_CSR_RECEIVE_ENABLE) {
printf("rx-enable ");
// send_fake = 1;
chaos_rcv_buffer_ptr = 0;
chaos_rcv_buffer_size = 0;

if (chaos_rcv_buffer_empty) {
// send_fake = 1;
chaos_rcv_buffer_ptr = 0;
chaos_rcv_buffer_size = 0;
#if 1
chaos_poll_from_chaosd();
chaos_poll_from_chaosd();
}
#endif
}
if (chaos_csr & CHAOS_CSR_TRANSMIT_ENABLE) {
printf("tx-enable ");
// chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
chaos_csr |= CHAOS_CSR_TRANSMIT_DONE;
char_xmit_done_intr();
} else {
chaos_csr &= ~CHAOS_CSR_TRANSMIT_DONE;
}
Expand Down Expand Up @@ -275,15 +294,47 @@ chaos_poll_from_chaosd(void)
return -1;

if (ret > 0) {
ret = read(chaos_fd, (char *)chaos_rcv_buffer, 4096);
u_char lenbytes[4];
int len;

ret = read(chaos_fd, lenbytes, 4);
if (ret <= 0) {
perror("chaos read");
return -1;
}

len = (lenbytes[0] << 8) | lenbytes[1];

ret = read(chaos_fd, (char *)chaos_rcv_buffer, len);
if (ret < 0) {
perror("read");
perror("chaos read");
return -1;
}

if (ret != len) {
printf("chaos read; length error\n");
return -1;
}

printf("polling; got chaosd packet %d\n", ret);

chaos_rcv_buffer_size = (ret+1)/2;
chaos_rcv_buffer_empty = 0;

#if 0
printf("rx to %o, my %o\n",
chaos_rcv_buffer[chaos_rcv_buffer_size-3], chaos_addr);
printf(" from %o, crc %o\n",
chaos_rcv_buffer[chaos_rcv_buffer_size-2],
chaos_rcv_buffer[chaos_rcv_buffer_size-1]);
#endif

if (chaos_rcv_buffer[chaos_rcv_buffer_size-3] != chaos_addr) {
chaos_rcv_buffer_size = 0;
chaos_rcv_buffer_empty = 1;
return 0;
}

chaos_rx_pkt();
}

Expand All @@ -295,7 +346,25 @@ chaos_sent_to_chaosd(char *buffer, int size)
{
int ret;
if (chaos_fd) {
ret = write(chaos_fd, buffer, size);
struct iovec iov[2];
unsigned char lenbytes[4];

lenbytes[0] = size >> 8;
lenbytes[1] = size;
lenbytes[2] = 0;
lenbytes[3] = 0;

iov[0].iov_base = lenbytes;
iov[0].iov_len = 4;

iov[1].iov_base = buffer;
iov[1].iov_len = size;

ret = writev(chaos_fd, iov, 2);
if (ret < 0) {
perror("chaos write");
return -1;
}
}
return 0;
}
Expand Down Expand Up @@ -364,6 +433,8 @@ chaos_init(void)
return -1;
}

chaos_rcv_buffer_empty = 1;

return 0;
}

15 changes: 10 additions & 5 deletions decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ read_prom_files(void)

printf("%s\n", name);
fd = open(name, O_RDONLY);
if (fd) {
ret = read(fd, prom[i], 512);
close(fd);
if (fd < 0) {
perror(name);
exit(1);
}

ret = read(fd, prom[i], 512);
close(fd);

if (ret != 512)
return -1;
if (ret != 512) {
fprintf(stderr, "read_prom_files: short read\n");
exit(1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ disk_init(char *filename)
if (disk_fd < 0) {
disk_fd = 0;
perror(filename);
return -1;
exit(1);
}

_disk_read(0, label);
Expand Down
6 changes: 6 additions & 0 deletions iob.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ iob_sdl_key_event(int code, int extra)
assert_unibus_interrupt(0260);
}

void
iob_warm_boot_key()
{
iob_sdl_key_event(SDLK_RETURN, 0);
}

void
iob_sdl_mouse_event(int x, int y, int dx, int dy, int buttons)
{
Expand Down
13 changes: 9 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "config.h"

int show_video_flag;
extern unsigned long cycles;
extern int run_ucode_flag;

struct timeval tv1;

Expand Down Expand Up @@ -96,11 +94,11 @@ main(int argc, char *argv[])
{
int c;

printf("CADR emulator v0.2\n");
printf("CADR emulator v0.3\n");

show_video_flag = 1;

while ((c = getopt(argc, argv, "b:c:C:l:np:q:tT:s")) != -1) {
while ((c = getopt(argc, argv, "b:c:C:l:np:q:tT:sw")) != -1) {
switch (c) {
case 'n':
show_video_flag = 0;
Expand Down Expand Up @@ -140,6 +138,9 @@ main(int argc, char *argv[])
case 's':
stop_after_prom_flag = 1;
break;
case 'w':
warm_boot_flag = 1;
break;
default:
usage();
}
Expand All @@ -166,6 +167,10 @@ main(int argc, char *argv[])

signal_init();

if (warm_boot_flag) {
iob_warm_boot_key();
}

run();

signal_shutdown();
Expand Down
1 change: 1 addition & 0 deletions sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ int
display_init(void)
{
sdl_display_init();
return 0;
}

void
Expand Down
Loading

0 comments on commit 74a8998

Please sign in to comment.