Skip to content

Commit 4130d59

Browse files
committed
PDP10: Talk to the host interface of an IMP emulator.
1 parent f7a4d63 commit 4130d59

File tree

8 files changed

+170
-18
lines changed

8 files changed

+170
-18
lines changed

PDP10/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ if (HAVE_UNITY_FRAMEWORK AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/CMak
1414
add_subdirectory(unit-tests)
1515
endif ()
1616

17+
18+
set(IMPUDP
19+
${H316D}/h316_udp.c)
20+
21+
1722
add_simulator(pdp10-ka
1823
SOURCES
1924
${KA10D}/kx10_cpu.c
@@ -60,10 +65,13 @@ add_simulator(pdp10-ka
6065
${KA10D}/kx10_ddc.c
6166
ka10_dd.c
6267
${DISPLAY340}
68+
${IMPUDP}
6369
INCLUDES
6470
${KA10D}
71+
${H316D}
6572
DEFINES
6673
KA=1
74+
VM_IMPTIP
6775
FEATURE_INT64
6876
FEATURE_VIDEO
6977
FEATURE_DISPLAY
@@ -103,10 +111,12 @@ add_simulator(pdp10-ki
103111
${KI10D}/kx10_ddc.c
104112
${KI10D}/kx10_tym.c
105113
${DISPLAY340}
114+
${IMPUDP}
106115
INCLUDES
107116
${KI10D}
108117
DEFINES
109118
KI=1
119+
VM_IMPTIP
110120
FEATURE_INT64
111121
FEATURE_VIDEO
112122
FEATURE_DISPLAY
@@ -138,10 +148,12 @@ add_simulator(pdp10-kl
138148
${KL10D}/kl10_nia.c
139149
${KL10D}/kx10_disk.c
140150
${KL10D}/kl10_dn.c
151+
${IMPUDP}
141152
INCLUDES
142153
${KL10D}
143154
DEFINES
144155
KL=1
156+
VM_IMPTIP
145157
FEATURE_INT64
146158
LABEL PDP10
147159
PKG_FAMILY pdp10_family
@@ -164,10 +176,12 @@ add_simulator(pdp10-ks
164176
${KS10D}/ks10_kmc.c
165177
${KS10D}/ks10_dup.c
166178
${KS10D}/kx10_imp.c
179+
${IMPUDP}
167180
INCLUDES
168181
${KS10D}
169182
DEFINES
170183
KS=1
184+
VM_IMPTIP
171185
FEATURE_INT64
172186
LABEL PDP10
173187
PKG_FAMILY pdp10_family

PDP10/kx10_imp.c

Lines changed: 123 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#define UNIT_M_DTYPE 3
4141
#define UNIT_DTYPE (UNIT_M_DTYPE << UNIT_V_DTYPE)
4242
#define GET_DTYPE(x) (((x) >> UNIT_V_DTYPE) & UNIT_M_DTYPE)
43+
#define UNIT_V_NCP (UNIT_V_UF + 3) /* NCP flag */
44+
#define UNIT_NCP (1 << UNIT_V_NCP)
4345

4446
#define TYPE_MIT 0 /* MIT Style KAIMP ITS */
4547
#define TYPE_BBN 1 /* BBN style interface TENEX */
@@ -475,13 +477,15 @@ struct imp_device {
475477
struct imp_stats stats;
476478
uint8 sbuffer[ETH_FRAME_SIZE]; /* Temp send buffer */
477479
uint8 rbuffer[ETH_FRAME_SIZE]; /* Temp receive buffer */
480+
int rpos;
478481
ETH_DEV etherface;
479482
ETH_QUE ReadQ;
480483
int imp_error;
481484
int host_error;
482485
int rfnm_count; /* Number of pending RFNM packets */
483486
int pia; /* PIA channels */
484487
struct arp_entry arp_table[IMP_ARPTAB_SIZE];
488+
int32 link; /* Link for UDP. */
485489
} imp_data;
486490

487491
extern int32 tmxr_poll;
@@ -541,6 +545,16 @@ const char *imp_description (DEVICE *dptr);
541545
static char *ipv4_inet_ntoa(struct in_addr ip);
542546
static int ipv4_inet_aton(const char *str, struct in_addr *inp);
543547

548+
#define MAXDATA 16348
549+
extern t_stat udp_create (DEVICE *dptr, const char *premote, int32 *pln);
550+
extern t_stat udp_release (DEVICE *dptr, int32 link);
551+
extern t_stat udp_send (DEVICE *dptr, int32 link, uint16 *pdata, uint16 count);
552+
extern int32 udp_receive (DEVICE *dptr, int32 link, uint16 *pdata, uint16 maxbuf);
553+
// Last-IMP-Bit is implemented as an out-of-band flag in UDP_PACKET
554+
#define PFLG_FINAL 00001
555+
// Host or IMP Ready bit.
556+
#define PFLG_READY 00002
557+
544558
#if KS
545559
uint16 imp_icsr;
546560
uint16 imp_idb;
@@ -595,6 +609,10 @@ MTAB imp_mod[] = {
595609
"Use DHCP to set IP address"},
596610
{ MTAB_XTD|MTAB_VDV, 0, "DHCPIP", NULL,
597611
NULL, &imp_show_dhcpip, NULL, "DHCP info" },
612+
{ UNIT_NCP, 0, "TCP", "TCP", NULL, NULL, NULL,
613+
"Use TCP/IP protocol"},
614+
{ UNIT_NCP, UNIT_NCP, "NCP", "NCP", NULL, NULL, NULL,
615+
"Use NCP protocol"},
598616
#if KS
599617
{ UNIT_DTYPE, (TYPE_UNI << UNIT_V_DTYPE), "UNI", "UNI", NULL, NULL, NULL,
600618
"Standard Unibus transfers"},
@@ -860,6 +878,13 @@ static void check_interrupts (UNIT *uptr)
860878
set_interrupt_mpx(DEVNUM, imp_data.pia >> 3, imp_mpx_lvl + 1);
861879
}
862880

881+
static void imp_send_host_ready(DEVICE *dptr, struct imp_device *imp)
882+
{
883+
t_stat r;
884+
uint16 data = PFLG_READY;
885+
r = udp_send (dptr, imp->link, &data, 1);
886+
}
887+
863888
t_stat imp_devio(uint32 dev, uint64 *data)
864889
{
865890
DEVICE *dptr = &imp_dev;
@@ -893,8 +918,12 @@ t_stat imp_devio(uint32 dev, uint64 *data)
893918
}
894919
if (*data & IMPHEC) { /* Clear host error. */
895920
/* Only if there has been a CONI lately. */
896-
if (last_coni - sim_gtime() < CONI_TIMEOUT)
921+
if (last_coni - sim_gtime() < CONI_TIMEOUT) {
897922
uptr->STATUS &= ~IMPHER;
923+
uptr->STATUS |= IMPHR;
924+
if (uptr->flags & UNIT_NCP)
925+
imp_send_host_ready(dptr, &imp_data);
926+
}
898927
}
899928
if (*data & IMIIHE) /* Inhibit interrupt on host error. */
900929
uptr->STATUS |= IMPIHE;
@@ -1380,6 +1409,35 @@ t_stat imp_tim_srv(UNIT * uptr)
13801409
return SCPE_OK;
13811410
}
13821411

1412+
void
1413+
imp_receive_udp (DEVICE *dev, struct imp_device *imp)
1414+
{
1415+
static uint16 data[MAXDATA];
1416+
int i;
1417+
int32 count;
1418+
1419+
count = udp_receive(dev, imp->link, data, MAXDATA);
1420+
if (count == 0)
1421+
return;
1422+
if (data[0] & PFLG_READY)
1423+
imp_unit[0].STATUS |= IMPR;
1424+
else
1425+
imp_unit[0].STATUS &= IMPR;
1426+
for (i = 1; i < count; i++) {
1427+
imp->rbuffer[imp->rpos++] = data[i] >> 8;
1428+
imp->rbuffer[imp->rpos++] = data[i] & 0xFF;
1429+
}
1430+
if ((data[0] & PFLG_FINAL) == 0 || imp->rpos == 0)
1431+
return;
1432+
imp_unit[0].STATUS |= IMPIB;
1433+
imp_unit[0].IPOS = 0;
1434+
imp_unit[0].ILEN = 8*imp->rpos;
1435+
imp->rpos = 0;
1436+
if (!sim_is_active(&imp_unit[0]))
1437+
sim_activate(&imp_unit[0], 100);
1438+
return;
1439+
}
1440+
13831441
void
13841442
imp_packet_in(struct imp_device *imp)
13851443
{
@@ -1389,6 +1447,11 @@ imp_packet_in(struct imp_device *imp)
13891447
int n;
13901448
int pad;
13911449

1450+
if (imp_unit[0].flags & UNIT_NCP) {
1451+
imp_receive_udp (&imp_dev, imp);
1452+
return;
1453+
}
1454+
13921455
if (eth_read (&imp_data.etherface, &read_buffer, NULL) <= 0) {
13931456
/* Any pending packet notifications? */
13941457
if (imp->rfnm_count != 0) {
@@ -1608,6 +1671,24 @@ imp_packet_in(struct imp_device *imp)
16081671
}
16091672
}
16101673

1674+
void
1675+
imp_send_udp (struct imp_device *imp, int len)
1676+
{
1677+
static uint16 data[MAXDATA];
1678+
t_stat r;
1679+
int i, j;
1680+
1681+
data[0] = PFLG_FINAL;
1682+
if ((imp_unit[0].STATUS & IMPHER) == 0)
1683+
data[0] |= PFLG_READY;
1684+
1685+
for (i = 0, j = 0; i < len/2; i++, j+=2)
1686+
data[i+1] = (imp->sbuffer[j] << 8) + imp->sbuffer[j+1];
1687+
if (len&1)
1688+
data[i+1] = imp->sbuffer[j] << 8;
1689+
r = udp_send (&imp_dev, imp->link, data, ((uint16)len+3)/2);
1690+
}
1691+
16111692
void
16121693
imp_send_packet (struct imp_device *imp, int len)
16131694
{
@@ -1619,6 +1700,12 @@ imp_send_packet (struct imp_device *imp, int len)
16191700
int lk;
16201701
int mt;
16211702

1703+
if (imp_unit[0].flags & UNIT_NCP) {
1704+
imp_send_udp(imp, len);
1705+
sim_activate(uptr, tmxr_poll);
1706+
return;
1707+
}
1708+
16221709
lk = 0;
16231710
n = len;
16241711
switch (imp->sbuffer[0] & 0xF) {
@@ -3132,6 +3219,16 @@ t_stat imp_attach(UNIT* uptr, CONST char* cptr)
31323219
char* tptr;
31333220
char buf[32];
31343221

3222+
if (cptr == NULL || *cptr == 0)
3223+
return SCPE_ARG;
3224+
3225+
if (uptr->flags & UNIT_NCP) {
3226+
status = udp_create (&imp_dev, cptr, &imp_data.link);
3227+
if (status != SCPE_OK)
3228+
return status;
3229+
imp_data.rpos = 0;
3230+
}
3231+
31353232
#if !KS
31363233
/* Set to correct device number */
31373234
switch(GET_DTYPE(imp_unit[0].flags)) {
@@ -3146,6 +3243,16 @@ t_stat imp_attach(UNIT* uptr, CONST char* cptr)
31463243
break;
31473244
}
31483245
#endif
3246+
3247+
/* Start out in a "host not ready" state. */
3248+
uptr->STATUS &= ~IMPHR;
3249+
3250+
if (uptr->flags & UNIT_NCP) {
3251+
/* Don't do the Ethernet stuff below. */
3252+
uptr->flags |= UNIT_ATT;
3253+
return SCPE_OK;
3254+
}
3255+
31493256
if (!(uptr->flags & UNIT_DHCP) && imp_data.ip == 0)
31503257
return sim_messagef (SCPE_NOATT, "%s: An IP Address must be specified when DHCP is disabled\n",
31513258
imp_dev.name);
@@ -3227,17 +3334,20 @@ t_stat imp_attach(UNIT* uptr, CONST char* cptr)
32273334

32283335
t_stat imp_detach(UNIT* uptr)
32293336
{
3230-
32313337
if (uptr->flags & UNIT_ATT) {
3338+
if (uptr->flags & UNIT_NCP)
3339+
udp_release (&imp_dev, imp_data.link);
32323340
/* If DHCP, release our IP address */
3233-
if (uptr->flags & UNIT_DHCP) {
3341+
else if (uptr->flags & UNIT_DHCP) {
32343342
imp_dhcp_release(&imp_data);
32353343
}
32363344
sim_cancel (uptr+1); /* stop the packet timing services */
32373345
sim_cancel (uptr+2); /* stop the clock timer services */
3238-
eth_close (&imp_data.etherface);
3239-
free(uptr->filename);
3240-
uptr->filename = NULL;
3346+
if (!(uptr->flags & UNIT_NCP)) {
3347+
eth_close (&imp_data.etherface);
3348+
free(uptr->filename);
3349+
uptr->filename = NULL;
3350+
}
32413351
uptr->flags &= ~UNIT_ATT;
32423352
}
32433353
return SCPE_OK;
@@ -3260,6 +3370,13 @@ fprintf (st, "GW points to the default\nrouter. If DHCP is enabled these ");
32603370
fprintf (st, "will be set from DHCP when the IMP is attached.\nIf IP is set ");
32613371
fprintf (st, "and DHCP is enabled, when the IMP is attached it will inform\n");
32623372
fprintf (st, "the local DHCP server of it's address.\n\n");
3373+
fprintf (st, "There is a second way to interact with a network.\n");
3374+
fprintf (st, "If the NCP modifier is enabled, you must ATTACH\n");
3375+
fprintf (st, "the IMP device to <local port>:<host>:<remote port>\n");
3376+
fprintf (st, "It is expected that there is an IMP emulator at <host>\n");
3377+
fprintf (st, "listening to <remote port> and talking to the PDP-10\n");
3378+
fprintf (st, "at <local port>. This network will only accept the NCP\n");
3379+
fprintf (st, "protocol that existed before TCP/IP.\n");
32633380
fprint_set_help (st, dptr);
32643381
fprint_show_help (st, dptr);
32653382
eth_attach_help(st, dptr, uptr, flag, cptr);

Visual Studio Projects/PDP10-KA.vcproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Name="VCCLCompilerTool"
4242
Optimization="0"
4343
AdditionalIncludeDirectories="../PDP10/;../PDP11/;../VAX/;./;../;../slirp;../slirp_glue;../slirp_glue/qemu;../slirp_glue/qemu/win32/include;../../windows-build/include;;../../windows-build/include/SDL2"
44-
PreprocessorDefinitions="USE_INT64;USE_SIM_CARD;KA=1;USE_DISPLAY;USE_SIM_VIDEO;HAVE_LIBSDL;HAVE_LIBPNG;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;PTW32_STATIC_LIB;USE_READER_THREAD;SIM_ASYNCH_IO"
44+
PreprocessorDefinitions="USE_INT64;USE_SIM_CARD;KA=1;USE_DISPLAY;USE_SIM_VIDEO;HAVE_LIBSDL;HAVE_LIBPNG;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;PTW32_STATIC_LIB;USE_READER_THREAD;SIM_ASYNCH_IO;VM_IMPTIP"
4545
KeepComments="false"
4646
BasicRuntimeChecks="0"
4747
RuntimeLibrary="1"
@@ -309,6 +309,10 @@
309309
RelativePath="..\PDP10\kx10_imp.c"
310310
>
311311
</File>
312+
<File
313+
RelativePath="..\H316\h316_udp.c"
314+
>
315+
</File>
312316
<File
313317
RelativePath="..\PDP10\kx10_lp.c"
314318
>

Visual Studio Projects/PDP10-KI.vcproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Name="VCCLCompilerTool"
4242
Optimization="0"
4343
AdditionalIncludeDirectories="../PDP10/;../PDP11/;../VAX/;./;../;../slirp;../slirp_glue;../slirp_glue/qemu;../slirp_glue/qemu/win32/include;../../windows-build/include;;../../windows-build/include/SDL2"
44-
PreprocessorDefinitions="USE_INT64;USE_SIM_CARD;KI=1;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;USE_DISPLAY;DISPLAY_TYPE=DIS_TYPE30;PIX_SCALE=RES_HALF;USE_SIM_VIDEO;HAVE_LIBSDL;HAVE_LIBPNG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC"
44+
PreprocessorDefinitions="USE_INT64;USE_SIM_CARD;KI=1;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;USE_DISPLAY;DISPLAY_TYPE=DIS_TYPE30;PIX_SCALE=RES_HALF;USE_SIM_VIDEO;HAVE_LIBSDL;HAVE_LIBPNG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;VM_IMPTIP"
4545
KeepComments="false"
4646
BasicRuntimeChecks="0"
4747
RuntimeLibrary="1"
@@ -245,6 +245,10 @@
245245
RelativePath="..\PDP10\kx10_imp.c"
246246
>
247247
</File>
248+
<File
249+
RelativePath="..\H316\h316_udp.c"
250+
>
251+
</File>
248252
<File
249253
RelativePath="..\PDP10\kx10_lp.c"
250254
>

Visual Studio Projects/PDP10-KL.vcproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Name="VCCLCompilerTool"
4242
Optimization="0"
4343
AdditionalIncludeDirectories="../PDP10;.;..;../slirp;../slirp_glue;../slirp_glue/qemu;../slirp_glue/qemu/win32/include;../../windows-build/include;;../../windows-build/include/SDL2"
44-
PreprocessorDefinitions="USE_INT64;USE_SIM_CARD;KL=1;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;PTW32_STATIC_LIB;USE_READER_THREAD;SIM_ASYNCH_IO"
44+
PreprocessorDefinitions="USE_INT64;USE_SIM_CARD;KL=1;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;PTW32_STATIC_LIB;USE_READER_THREAD;SIM_ASYNCH_IO;VM_IMPTIP"
4545
KeepComments="false"
4646
BasicRuntimeChecks="0"
4747
RuntimeLibrary="1"
@@ -249,6 +249,10 @@
249249
RelativePath="..\PDP10\kx10_imp.c"
250250
>
251251
</File>
252+
<File
253+
RelativePath="..\H316\h316_udp.c"
254+
>
255+
</File>
252256
<File
253257
RelativePath="..\PDP10\kx10_lp.c"
254258
>

Visual Studio Projects/PDP10-KS.vcproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Name="VCCLCompilerTool"
4242
Optimization="0"
4343
AdditionalIncludeDirectories="../PDP10/;../PDP11/;../VAX/;./;../;../slirp;../slirp_glue;../slirp_glue/qemu;../slirp_glue/qemu/win32/include;../../windows-build/include;;../../windows-build/include/SDL2"
44-
PreprocessorDefinitions="USE_INT64;KS=1;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;PTW32_STATIC_LIB;USE_READER_THREAD;SIM_ASYNCH_IO"
44+
PreprocessorDefinitions="USE_INT64;KS=1;USE_SHARED;HAVE_SLIRP_NETWORK;USE_SIMH_SLIRP_DEBUG;SIM_BUILD_TOOL=simh-Visual-Studio-Project;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;HAVE_PCRE_H;PCRE_STATIC;PTW32_STATIC_LIB;USE_READER_THREAD;SIM_ASYNCH_IO;VM_IMPTIP"
4545
KeepComments="false"
4646
BasicRuntimeChecks="0"
4747
RuntimeLibrary="1"
@@ -237,6 +237,10 @@
237237
RelativePath="..\PDP10\kx10_imp.c"
238238
>
239239
</File>
240+
<File
241+
RelativePath="..\H316\h316_udp.c"
242+
>
243+
</File>
240244
<File
241245
RelativePath="..\PDP10\kx10_rh.c"
242246
>

cmake/simh-simulators.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
##
1010
## ------------------------------------------------------------
1111
set(B5500D "${CMAKE_SOURCE_DIR}/B5500")
12+
set(H316D "${CMAKE_SOURCE_DIR}/H316")
1213
set(I7000D "${CMAKE_SOURCE_DIR}/I7000")
1314
set(I7010D "${CMAKE_SOURCE_DIR}/I7000")
1415
set(IBM360D "${CMAKE_SOURCE_DIR}/IBM360")

0 commit comments

Comments
 (0)