1
0
mirror of https://github.com/aap/pdp6.git synced 2026-01-11 23:53:31 +00:00

emu: implemented moby memory; changed attach cmd to mount

This commit is contained in:
aap 2019-03-12 10:00:45 +01:00
parent b705b0fc4b
commit 68037c9d95
12 changed files with 4464 additions and 2161 deletions

View File

@ -3,7 +3,8 @@ H=pdp6.h ../tools/pdp6common.h threading.h
# clang
#CFLAGS= -Wno-shift-op-parentheses -Wno-logical-op-parentheses \
# -Wno-bitwise-op-parentheses
CFLAGS= -g -Wall -Wno-parentheses -fno-diagnostics-show-caret
CFLAGS= -O3 -Wall -Wno-parentheses -fno-diagnostics-show-caret
#CFLAGS= -g -Wall -Wno-parentheses -fno-diagnostics-show-caret
SDLFLAGS=`sdl2-config --cflags` `pkg-config SDL2_image --cflags`
LIBS=`sdl2-config --libs` `pkg-config SDL2_image --libs` -lpthread

View File

@ -220,6 +220,13 @@ EXDEPSREGS
return 1;
}
static Device aprproto = {
nil, nil, "",
nil, nil,
nil,
ex_apr, dep_apr
};
Device*
makeapr(int argc, char *argv[])
{
@ -229,10 +236,8 @@ makeapr(int argc, char *argv[])
apr = malloc(sizeof(Apr));
memset(apr, 0, sizeof(Apr));
apr->dev = aprproto;
apr->dev.type = apr_ident;
apr->dev.name = "";
apr->dev.examine = ex_apr;
apr->dev.deposit = dep_apr;
apr->iobus.dev[CPA] = (Busdev){ apr, wake_cpa, 0 };
apr->iobus.dev[PI] = (Busdev){ apr, wake_pi, 0 };
@ -1021,20 +1026,20 @@ wake_pi(void *dev)
return;
// 8-4, 8-5
if(IOB_STATUS){
trace("PI STATUS %llo\n", bus->c12);
trace("PI STATUS %012lo\n", bus->c12);
if(apr->pi_active) bus->c12 |= F28;
bus->c12 |= apr->pio;
}
// 8-4, 8-3
if(IOB_CONO_CLEAR){
trace("PI CONO CLEAR %llo\n", bus->c12);
trace("PI CONO CLEAR %012lo\n", bus->c12);
if(bus->c12 & F23)
// can call directly
pi_reset_p(apr);
}
if(IOB_CONO_SET){
trace("PI CONO SET %llo\n", bus->c12);
trace("PI CONO SET %012lo\n", bus->c12);
if(bus->c12 & F24) PIR_FM_IOB1;
if(bus->c12 & F25) PIO_FM_IOB1;
if(bus->c12 & F26) PIO0_FM_IOB1;
@ -1233,8 +1238,8 @@ defpulse(sct2)
defpulse(sct1)
{
word ar0_shl_inp, ar0_shr_inp, ar35_shl_inp;
word mq0_shl_inp, mq0_shr_inp, mq1_shr_inp, mq35_shl_inp;
word ar0_shl_inp, ar0_shr_inp = 0, ar35_shl_inp = 0;
word mq0_shl_inp, mq0_shr_inp, mq1_shr_inp, mq35_shl_inp = 0;
SC_INC; // 6-16
@ -1679,7 +1684,7 @@ defpulse(dst17)
defpulse(dst16)
{
word ar0_shr_inp;
word ar0_shr_inp = 0;
// 6-7
if(IR_FDV)
@ -3307,11 +3312,13 @@ defpulse_(kt4)
if(apr->run && (apr->key_ex_st || apr->key_dep_st))
pulse(apr, &key_go, 0); // 5-2
rpt.c = apr->rptchan;
rpt.interval = ranges[apr->speed_range];
/* TODO: is this just a multiplier */
rpt.interval *= 1 + apr->speed_set/100.0f*14.0f;
chansend(rtcchan, &rpt);
if(apr->sw_repeat){
rpt.c = apr->rptchan;
rpt.interval = ranges[apr->speed_range];
/* TODO: is this just a multiplier */
rpt.interval *= 1 + apr->speed_set/100.0f*14.0f;
chansend(rtcchan, &rpt);
}
}
defpulse(kt3)

View File

@ -222,7 +222,8 @@ struct DevDef
};
DevDef definitions[] = {
{ FMEM_IDENT, makefmem },
{ CMEM_IDENT, makecmem },
{ CMEM_IDENT, make16kmem },
{ MMEM_IDENT, make256kmem },
{ APR_IDENT, makeapr },
{ TTY_IDENT, maketty },
{ PTR_IDENT, makeptr },
@ -257,7 +258,7 @@ found:
}
static void
c_attach(int argc, char *argv[])
c_mount(int argc, char *argv[])
{
Device *dev;
@ -270,15 +271,15 @@ c_attach(int argc, char *argv[])
printf("No device: %s\n", argv[1]);
return;
}
if(dev->attach == nil){
printf("No attach for device type %s\n", dev->type);
if(dev->mount == nil){
printf("No mount for device type %s\n", dev->type);
return;
}
dev->attach(dev, argv[2]);
dev->mount(dev, argv[2]);
}
static void
c_detach(int argc, char *argv[])
c_unmount(int argc, char *argv[])
{
Device *dev;
@ -291,11 +292,11 @@ c_detach(int argc, char *argv[])
printf("No device: %s\n", argv[1]);
return;
}
if(dev->detach == nil){
printf("No detach for device type %s\n", dev->type);
if(dev->unmount == nil){
printf("No unmount for device type %s\n", dev->type);
return;
}
dev->detach(dev);
dev->unmount(dev);
}
/* ioconnect dev busdev */
@ -651,10 +652,10 @@ struct {
} cmdtab[] = {
{ "mkdev", c_mkdev,
"make a device: mkdev name type [args]" },
{ "attach", c_attach,
"attach a file to a device: attach name filename" },
{ "detach", c_detach,
"detach a file from a device: detach name" },
{ "mount", c_mount,
"mount a file on a device: mount name filename" },
{ "unmount", c_unmount,
"unmount a file from a device: unmount name" },
{ "connectio", c_ioconnect,
"connect device to IO bus: connectio devname procname" },
{ "connectmem", c_memconnect,

View File

@ -1,9 +1,9 @@
mkdev name type
creates a device and gives it a name
attach name path
attaches a file to a device
detach name
detach a file from a device
mount name path
mounts a file on a device
unmount name
unmounts a file from a device
connectio name busdevname
connects a device to the IO bus of a processor
connectmem name procnum busdevname addr

View File

@ -51,7 +51,7 @@ dxmove(Dx555 *dx)
}
static void
dxdetach(Device *dev)
dxunmount(Device *dev)
{
Dx555 *dx;
@ -67,12 +67,12 @@ dxdetach(Device *dev)
}
static void
dxattach(Device *dev, const char *path)
dxmount(Device *dev, const char *path)
{
Dx555 *dx;
dx = (Dx555*)dev;
dxdetach(dev);
dxunmount(dev);
memset(dx->start, 0, dx->size);
// TODO: resize
dx->fd = open(path, O_RDWR | O_CREAT, 0666);
@ -91,6 +91,13 @@ dxconn(Dt551 *dt, Dx555 *dx, int n)
dx->unit = n;
}
static Device dxproto = {
nil, nil, "",
dxmount, dxunmount,
nil,
nil, nil
};
Device*
makedx(int argc, char *argv[])
{
@ -99,10 +106,8 @@ makedx(int argc, char *argv[])
dx = malloc(sizeof(Dx555));
memset(dx, 0, sizeof(Dx555));
dx->dev = dxproto;
dx->dev.type = dx_ident;
dx->dev.name = "";
dx->dev.attach = dxattach;
dx->dev.detach = dxdetach;
dx->fd = -1;
dx->size = DTSIZE;
@ -750,6 +755,16 @@ dtconn(Dc136 *dc, Dt551 *dt)
dc->devp[DEVNO] = dt;
}
word
dtex(Device *dev, const char *reg)
{
Dt551 *dt;
dt = (Dt551*)dev;
if(strcmp(reg, "btm_wr") == 0) return dt->ut_btm_switch;
return ~0;
}
int
dtdep(Device *dev, const char *reg, word data)
{
@ -762,15 +777,12 @@ dtdep(Device *dev, const char *reg, word data)
return 0;
}
word
dtex(Device *dev, const char *reg)
{
Dt551 *dt;
dt = (Dt551*)dev;
if(strcmp(reg, "btm_wr") == 0) return dt->ut_btm_switch;
return ~0;
}
static Device dtproto = {
nil, nil, "",
nil, nil,
dtioconnect,
dtex, dtdep
};
Device*
makedt(int argc, char *argv[])
@ -781,11 +793,8 @@ makedt(int argc, char *argv[])
dt = malloc(sizeof(Dt551));
memset(dt, 0, sizeof(Dt551));
dt->dev = dtproto;
dt->dev.type = dt_ident;
dt->dev.name = "";
dt->dev.ioconnect = dtioconnect;
dt->dev.deposit = dtdep;
dt->dev.examine = dtex;
// should have 30000 cycles per second, so one every 33μs
// APR at 1 has an approximate cycle time of 200-300ns

View File

@ -133,8 +133,8 @@ quit(int code)
/* Detach all files */
for(dev = devlist; dev; dev = dev->next)
if(dev->detach)
dev->detach(dev);
if(dev->unmount)
dev->unmount(dev);
/* Sync memory to disk */
for(dev = devlist; dev; dev = dev->next){

View File

@ -7,10 +7,11 @@ mkdev dc dc136
mkdev dt0 dt551
mkdev dx0 dx555
mkdev fmem fmem162 0
mkdev cmem0 cmem161C mem_0
mkdev cmem1 cmem161C mem_1
mkdev cmem2 cmem161C mem_2
mkdev cmem3 cmem161C mem_3
mkdev mem0 moby
#mkdev cmem0 cmem161C mem_0
#mkdev cmem1 cmem161C mem_1
#mkdev cmem2 cmem161C mem_2
#mkdev cmem3 cmem161C mem_3
#mkdev netmem netmem its.pdp10.se 10006
#mkdev netmem netmem localhost 10006
#mkdev netmem netmem maya.papnet.eu 10006
@ -23,19 +24,20 @@ connectio ptp apr
connectio dc apr
connectio dt0 apr
connectmem fmem 0 apr -1
connectmem cmem0 0 apr 0
connectmem cmem1 0 apr 1
connectmem cmem2 0 apr 2
connectmem cmem3 0 apr 3
connectmem mem0 0 apr 0
#connectmem cmem0 0 apr 0
#connectmem cmem1 0 apr 1
#connectmem cmem2 0 apr 2
#connectmem cmem3 0 apr 3
attach tty /tmp/6tty
attach ptr ../code/test.rim
#attach ptr ../code/sysgen.rim
#attach ptr ../lars_sysgen/sysgen.pt
attach ptp ../code/ptp.out
#attach dx0 ../test/out.dt6
#attach dx0 ../test/test.dt6
attach dx0 ../test/ddt.dtr
mount tty /tmp/6tty
mount ptr ../code/test.rim
#mount ptr ../code/sysgen.rim
#mount ptr ../lars_sysgen/sysgen.pt
mount ptp ../code/ptp.out
#mount dx0 ../test/out.dt6
#mount dx0 ../test/test.dt6
mount dx0 ../test/foo.dtr
#load -b ../maint/pdp6.part1

View File

@ -2,6 +2,7 @@
char *fmem_ident = FMEM_IDENT;
char *cmem_ident = CMEM_IDENT;
char *mmem_ident = MMEM_IDENT;
Membus memterm;
@ -24,8 +25,10 @@ readmem(const char *file, word *mem, word size)
if(*s == ':'){
a = w;
s++;
}else
}else if(a < size)
mem[a++] = w;
else
fprintf(stderr, "Address out of range: %o\n", a++);
}else
s++;
}
@ -60,7 +63,7 @@ synccore(Mem *mem)
{
CMem *core;
core = mem->module;
writemem(core->filename, core->core, 040000);
writemem(core->filename, core->core, core->size);
}
/* Both functions below are very confusing. I'm sorry.
@ -69,7 +72,7 @@ synccore(Mem *mem)
/* This is based on the 161C memory */
static int
wakecore(Mem *mem, Membus *bus)
wakecore(Mem *mem, int sel, Membus *bus)
{
bool p2, p3;
CMem *core;
@ -123,6 +126,8 @@ wakecore(Mem *mem, Membus *bus)
/* strobe address and send acknowledge */
core->cma |= bus->c12>>4 & 037777;
core->cma |= sel<<14;
core->cma &= core->mask;
core->cma_rd_rq |= !!(bus->c12 & MEMBUS_RD_RQ);
core->cma_wr_rq |= !!(bus->c12 & MEMBUS_WR_RQ);
//trace(" sending ADDR ACK\n");
@ -168,7 +173,7 @@ powercore(Mem *mem)
printf("[powercore]\n");
core = mem->module;
readmem(core->filename, core->core, 040000);
readmem(core->filename, core->core, core->size);
core->cmc_aw_rq = 1;
core->cmc_p_act = -1;
core->cmc_last_proc = 2; /* not reset by the hardware :/ */
@ -176,7 +181,7 @@ powercore(Mem *mem)
/* This is based on the 162 memory */
static int
wakeff(Mem *mem, Membus *bus)
wakeff(Mem *mem, int sel, Membus *bus)
{
FMem *ff;
hword fma;
@ -245,7 +250,7 @@ wakemem(Membus *bus)
int nxm;
if(bus->c12 & MEMBUS_MA_FMC_SEL1){
nxm = bus->fmem->wake(bus->fmem, bus);
nxm = bus->fmem->wake(bus->fmem, 0, bus);
if(nxm)
goto core;
}else{
@ -256,17 +261,17 @@ wakemem(Membus *bus)
if(bus->c12 & MEMBUS_MA19_1) sel |= 004;
if(bus->c12 & MEMBUS_MA18_1) sel |= 010;
if(bus->cmem[sel])
nxm = bus->cmem[sel]->wake(bus->cmem[sel], bus);
nxm = bus->cmem[sel]->wake(bus->cmem[sel], sel, bus);
else
nxm = 1;
}
/* TODO: do something when memory didn't respond */
}
/* Allocate a 16k core memory module and
/* Allocate a core memory module and
* a memory bus attachment. */
Mem*
makecoremem(const char *file)
makecoremem(const char *file, int size)
{
CMem *core;
Mem *mem;
@ -274,6 +279,16 @@ makecoremem(const char *file)
core = malloc(sizeof(CMem));
memset(core, 0, sizeof(CMem));
core->filename = strdup(file);
core->size = size;
core->mask = size-1;
if((core->size & core->mask) != 0){
fprintf(stderr, "%d not a power of 2\n", core->size);
free(core->filename);
free(core);
return nil;
}
core->core = malloc(core->size*sizeof(word));
memset(core->core, 0, core->size*sizeof(word));
mem = malloc(sizeof(Mem));
memset(mem, 0, sizeof(Mem));
mem->dev.type = cmem_ident;
@ -334,7 +349,7 @@ makefmem(int argc, char *argv[])
}
Device*
makecmem(int argc, char *argv[])
make16kmem(int argc, char *argv[])
{
Mem *m;
char *path;
@ -342,7 +357,21 @@ makecmem(int argc, char *argv[])
path = argv[0];
else
path = "/dev/null";
m = makecoremem(path);
m = makecoremem(path, 16*1024);
m->poweron(m);
return &m->dev;
}
Device*
make256kmem(int argc, char *argv[])
{
Mem *m;
char *path;
if(argc > 0)
path = argv[0];
else
path = "/dev/null";
m = makecoremem(path, 256*1024);
m->dev.type = mmem_ident;
m->poweron(m);
return &m->dev;
}
@ -353,10 +382,16 @@ makecmem(int argc, char *argv[])
void
attachmem(Mem *mem, int p, Membus *bus, int n)
{
CMem *core;
int i;
if(n < 0)
bus->fmem = mem;
else
bus->cmem[n] = mem;
else if(mem->dev.type == cmem_ident || mem->dev.type == mmem_ident){
core = mem->module;
for(i = 0; i < core->size/040000; i++)
bus->cmem[i+n] = mem;
}
mem->bus[p] = bus;
}
@ -390,7 +425,7 @@ getmemref(Membus *bus, hword addr, int fastmem)
}
if(bus->cmem[addr>>14]){
core = bus->cmem[addr>>14]->module;
return &core->core[addr & 037777];
return &core->core[addr & core->mask];
}
return nil;
}

6302
emu/mem_0

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,7 @@ typedef struct Mem Mem;
typedef struct Membus Membus;
typedef struct FMem FMem;
typedef struct CMem CMem;
typedef struct MobyMem MobyMem;
typedef struct Busdev Busdev;
typedef struct IOBus IOBus;
typedef struct Apr Apr;
@ -116,9 +117,9 @@ struct Device
Device *next;
char *type;
char *name;
/* attach file to device */
void (*attach)(Device *dev, const char *path);
void (*detach)(Device *dev);
/* mount file on device */
void (*mount)(Device *dev, const char *path);
void (*unmount)(Device *dev);
/* connect device to iobus */
void (*ioconnect)(Device *dev, IOBus *bus);
/* manipulate device registers */
@ -165,7 +166,7 @@ struct Mem
Device dev;
void *module; /* CMem, FMem */
Membus *bus[4];
int (*wake)(Mem *mem, Membus *bus);
int (*wake)(Mem *mem, int sel, Membus *bus);
void (*poweron)(Mem *mem);
void (*sync)(Mem *mem); /* sync file to disk */
};
@ -197,12 +198,15 @@ extern char *fmem_ident;
Mem *makefastmem(int p);
Device *makefmem(int argc, char *argv[]);
/* Core memory 161C, 16k words */
/* Core memory 161C, normally 16k words.
* Can be used for other sizes too. */
struct CMem
{
const char *filename;
char *filename;
int size;
int mask;
word core[040000];
word *core;
word cmb;
hword cma;
bool cma_rd_rq, cma_wr_rq;
@ -212,9 +216,12 @@ struct CMem
bool cmc_pse_sync;
};
#define CMEM_IDENT "cmem161C"
#define MMEM_IDENT "moby"
extern char *cmem_ident;
Mem *makecoremem(const char *file);
Device *makecmem(int argc, char *argv[]);
extern char *mmem_ident;
Mem *makecoremem(const char *file, int size);
Device *make16kmem(int argc, char *argv[]);
Device *make256kmem(int argc, char *argv[]);
void attachmem(Mem *mem, int p, Membus *bus, int n);
void readmem(const char *file, word *mem, word size);

View File

@ -185,34 +185,48 @@ ptr_setmotor(Ptr *ptr, int m)
}
static void
ptpattach(Device *dev, const char *path)
ptpunmount(Device *dev)
{
Ptp *ptp;
int fd;
ptp = (Ptp*)dev;
fd = ptp->fd;
if(fd >= 0){
if(ptp->fd >= 0){
close(ptp->fd);
ptp->fd = -1;
close(fd);
}
}
static void
ptpmount(Device *dev, const char *path)
{
Ptp *ptp;
ptp = (Ptp*)dev;
ptpunmount(dev);
ptp->fd = open(path, O_WRONLY | O_CREAT, 0666);
if(ptp->fd < 0)
fprintf(stderr, "couldn't open file %s\n", path);
}
static void
ptrattach(Device *dev, const char *path)
ptrunmount(Device *dev)
{
Ptr *ptr;
int fd;
ptr = (Ptr*)dev;
fd = ptr->fd;
if(fd >= 0){
if(ptr->fd >= 0){
close(ptr->fd);
ptr->fd = -1;
close(fd);
}
}
static void
ptrmount(Device *dev, const char *path)
{
Ptr *ptr;
ptr = (Ptr*)dev;
ptrunmount(dev);
ptr->fd = open(path, O_RDONLY);
if(ptr->fd < 0)
fprintf(stderr, "couldn't open file %s\n", path);
@ -236,6 +250,21 @@ ptpioconnect(Device *dev, IOBus *bus)
bus->dev[PTP] = (Busdev){ ptp, wake_ptp, 0 };
}
static Device ptpproto = {
nil, nil, "",
ptpmount, ptpunmount,
ptpioconnect,
nil, nil
};
static Device ptrproto = {
nil, nil, "",
ptrmount, ptrunmount,
ptrioconnect,
nil, nil
};
Device*
makeptp(int argc, char *argv[])
{
@ -245,10 +274,8 @@ makeptp(int argc, char *argv[])
ptp = malloc(sizeof(Ptp));
memset(ptp, 0, sizeof(Ptp));
ptp->dev = ptpproto;
ptp->dev.type = ptp_ident;
ptp->dev.name = "";
ptp->dev.attach = ptpattach;
ptp->dev.ioconnect = ptpioconnect;
ptp->fd = -1;
t = (Task){ nil, ptpcycle, ptp, 1000, 0 };
@ -265,10 +292,8 @@ makeptr(int argc, char *argv[])
ptr = malloc(sizeof(Ptr));
memset(ptr, 0, sizeof(Ptr));
ptr->dev = ptrproto;
ptr->dev.type = ptr_ident;
ptr->dev.name = "";
ptr->dev.attach = ptrattach;
ptr->dev.ioconnect = ptrioconnect;
ptr->fd = -1;
t = (Task){ nil, ptrcycle, ptr, 1000, 0 };

View File

@ -97,29 +97,27 @@ static void
ttyattach(Device *dev, const char *path)
{
Tty *tty;
int fd;
struct termios tio;
tty = (Tty*)dev;
fd = tty->fd;
if(fd >= 0){
if(tty->fd >= 0){
close(tty->fd);
tty->fd = -1;
close(fd);
}
fd = open(path, O_RDWR);
if(fd < 0)
tty->fd = open(path, O_RDWR);
if(tty->fd < 0)
goto fail;
if(tcgetattr(fd, &tio) < 0)
if(tcgetattr(tty->fd, &tio) < 0)
goto fail;
cfmakeraw(&tio);
// cfsetspeed(&tio, B300);
if(tcsetattr(fd, TCSAFLUSH, &tio) < 0)
if(tcsetattr(tty->fd, TCSAFLUSH, &tio) < 0)
goto fail;
tty->fd = fd;
return;
fail:
if(fd >= 0) close(fd);
if(tty->fd >= 0) close(tty->fd);
tty->fd = -1;
fprintf(stderr, "couldn't open file %s\n", path);
}
@ -143,7 +141,7 @@ maketty(int argc, char *argv[])
tty->dev.type = tty_ident;
tty->dev.name = "";
tty->dev.attach = ttyattach;
tty->dev.mount = ttyattach;
tty->dev.ioconnect = ttyioconnect;
tty->fd = -1;