Skip to content

Commit

Permalink
mac: Add emulated DaynaPORT SCSI/Link-3 ethernet device
Browse files Browse the repository at this point in the history
Currently only works on OpenBSD and requires read/write access to
the tap device (/dev/tap0 by default).  A helper script is run after
bringing up the device to do things as root like assign an IP (for
NAT) or configure bridging (for ethernet).

SCSI protocol information was gleaned from the DaynaPORT driver in
RASCSI and my real DaynaPORT device.
  • Loading branch information
jcs committed Feb 5, 2023
1 parent 371414f commit e73c215
Show file tree
Hide file tree
Showing 6 changed files with 544 additions and 102 deletions.
2 changes: 2 additions & 0 deletions src/arch/macplus/Makefile.inc
Expand Up @@ -51,6 +51,7 @@ PCE_MACPLUS_BAS := \
msg \
rtc \
scsi \
scsi_tap \
serial \
sony \
sound \
Expand Down Expand Up @@ -125,6 +126,7 @@ $(rel)/mem.o: $(rel)/mem.c
$(rel)/msg.o: $(rel)/msg.c
$(rel)/rtc.o: $(rel)/rtc.c
$(rel)/scsi.o: $(rel)/scsi.c
$(rel)/scsi_tap.o: $(rel)/scsi_tap.c
$(rel)/serial.o: $(rel)/serial.c
$(rel)/sony.o: $(rel)/sony.c
$(rel)/sound.o: $(rel)/sound.c
Expand Down
40 changes: 29 additions & 11 deletions src/arch/macplus/macplus.c
Expand Up @@ -1070,8 +1070,8 @@ void mac_setup_scsi (macplus_t *sim, ini_sct_t *ini)
ini_sct_t *sct, *sctdev;
mem_blk_t *blk;
unsigned long addr, size;
unsigned id, drive;
const char *vendor, *product;
unsigned id, drive, ethernet;
const char *vendor, *product, *mac_addr, *tap_dev, *tap_cmd;

sct = ini_next_sct (ini, NULL, "scsi");

Expand Down Expand Up @@ -1108,17 +1108,35 @@ void mac_setup_scsi (macplus_t *sim, ini_sct_t *ini)
while (sctdev != NULL) {
ini_get_uint16 (sctdev, "id", &id, 0);
ini_get_uint16 (sctdev, "drive", &drive, 0);
ini_get_string (sctdev, "vendor", &vendor, "PCE");
ini_get_string (sctdev, "product", &product, "PCEDISK");
ini_get_uint16 (sctdev, "ethernet", &ethernet, 0);

pce_log_tag (MSG_INF,
"SCSI:", "id=%u drive=%u vendor=\"%s\" product=\"%s\"\n",
id, drive, vendor, product
);
if (drive) {
ini_get_string (sctdev, "vendor", &vendor, "PCE");
ini_get_string (sctdev, "product", &product, "PCEDISK");

pce_log_tag (MSG_INF,
"SCSI:",
"id=%u drive=%u vendor=\"%s\" product=\"%s\"\n",
id, drive, vendor, product
);

mac_scsi_set_drive (&sim->scsi, id, drive);
mac_scsi_set_drive_vendor (&sim->scsi, id, vendor);
mac_scsi_set_drive_product (&sim->scsi, id, product);
mac_scsi_set_drive (&sim->scsi, id, drive);
mac_scsi_set_drive_vendor (&sim->scsi, id, vendor);
mac_scsi_set_drive_product (&sim->scsi, id, product);
}
else if (ethernet) {
ini_get_string (sctdev, "tap", &tap_dev, "/dev/tap0");
ini_get_string (sctdev, "tap_cmd", &tap_cmd, "");
ini_get_string (sctdev, "mac_addr", &mac_addr, "00:80:19:c0:ff:ee");

pce_log_tag (MSG_INF,
"SCSI:",
"id=%u ethernet=%u tap=%s cmd=%s mac_addr=%s\n",
id, ethernet, tap_dev, tap_cmd, mac_addr
);

mac_scsi_set_ethernet (&sim->scsi, id, tap_dev, tap_cmd, mac_addr);
}

sctdev = ini_next_sct (sct, sctdev, "device");
}
Expand Down
17 changes: 17 additions & 0 deletions src/arch/macplus/pce-macplus.cfg.in
Expand Up @@ -280,6 +280,23 @@ scsi {
id = 2
drive = 130
}

# DaynaPORT SCSI/Link device emulation on SCSI id 3.
# Requires read/write access on the "tap" device listed here.
#device {
# id = 3
# ethernet = 1
# tap = "/dev/tap0" # OpenBSD
# tap = "/dev/net/tun" # Linux
# mac_addr = "00:80:19:c0:ff:ee"
#
# # This command will be run after initializing the tap device
# # and will have the tap device and MAC address passed as
# # arguments. It should probably assign an IP to this tap
# # device if using NAT (required on WiFi), or setup bridging
# # if using ethernet.
# tap_cmd = "sh /etc/pce/tap-setup.sh"
#}
}


Expand Down

0 comments on commit e73c215

Please sign in to comment.