AmendHub

Download:

jcs

/

wifi_da

/

amendments

/

9

scsi: Check for BlueSCSI by doing a wifi info request

The firmware no longer has its product include "/Blue".

jcs made amendment 9 11 months ago
--- scsi.c Fri Sep 22 09:36:09 2023 +++ scsi.c Fri Oct 20 19:54:26 2023 @@ -40,17 +40,17 @@ enum { SCSI_WRITE }; -unsigned char scsi_data[2000]; +unsigned char scsi_data[2048]; struct SCSIInstr tib[2]; -short stat, msg, err; -short scsi_io(unsigned short scsi_id, unsigned char *cdb, unsigned long cdb_len, - short io_type, unsigned long len); +short scsi_io(unsigned short scsi_id, unsigned char *cdb, + unsigned long cdb_len, short io_type, unsigned long len); short scsi_find_wifi(void) { struct scsi_inquiry inq; + short scsi_stat, scsi_msg; unsigned char cdb[16] = { 0 }; short i, scsi_id; @@ -75,14 +75,14 @@ scsi_find_wifi(void) break; if (SCSICmd((Ptr)&cdb, 6) != noErr) { - SCSIComplete(&stat, &msg, 300); + SCSIComplete(&scsi_stat, &scsi_msg, 300); goto scan_failed; } memset(&inq, 0, sizeof(inq)); if (SCSIRead((Ptr)&tib) != noErr) { - SCSIComplete(&stat, &msg, 300); + SCSIComplete(&scsi_stat, &scsi_msg, 300); goto scan_failed; } @@ -91,12 +91,27 @@ scsi_find_wifi(void) tib[0].scParam2 += inq.additionalLength; } - if (SCSIComplete(&stat, &msg, 300) != noErr) + if (SCSIComplete(&scsi_stat, &scsi_msg, 300) != noErr) goto scan_failed; - if (memcmp(inq.vendorID, "Dayna", 5) == 0 && - memcmp(inq.productID, "SCSI/Link/Blue", 14) == 0) + if (i == 0) + /* re-inquire with full length */ + continue; + + inq.vendorID[sizeof(inq.vendorID) - 1] = '\0'; + inq.productID[sizeof(inq.productID) - 1] = '\0'; + DEBUG_LOG(("scsi[%d]: v \"%s\", p \"%s\"", scsi_id, + inq.vendorID, inq.productID)); + + if (memcmp(inq.vendorID, "Dayna", 5) != 0 || + memcmp(inq.productID, "SCSI/Link", 9) != 0) + break; + + if (scsi_wifi_info(scsi_id, NULL)) return scsi_id; + + DEBUG_LOG(("scsi[%d]: matched vendor/product but no info", + scsi_id)); } } @@ -115,7 +130,9 @@ scsi_wifi_scan(short scsi_id) cdb[0] = BLUESCSI_NETWORK_WIFI_CMD; cdb[1] = BLUESCSI_NETWORK_WIFI_CMD_SCAN; cdb[4] = 0x01; - + + wifi_scan_started = Time; + return (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, 1) != -1); } @@ -184,9 +201,11 @@ scsi_wifi_info(short scsi_id, struct wifi_network_entr if (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, size) == -1) return false; - memset(resp, 0, sizeof(struct wifi_network_entry)); - /* skip returned size */ - memcpy(resp, scsi_data + 2, sizeof(struct wifi_network_entry)); + if (resp != NULL) { + memset(resp, 0, sizeof(struct wifi_network_entry)); + /* skip returned size */ + memcpy(resp, scsi_data + 2, sizeof(struct wifi_network_entry)); + } return true; } @@ -215,7 +234,8 @@ short scsi_io(unsigned short scsi_id, unsigned char *cdb, unsigned long cdb_len, short io_type, unsigned long len) { - short ret, ioret, stat; + short scsi_stat, scsi_msg; + short ret, ioret; if (SCSIGet() != noErr) { warn("SCSIGet failed"); @@ -228,7 +248,7 @@ scsi_io(unsigned short scsi_id, unsigned char *cdb, un } if (SCSICmd((Ptr)cdb, cdb_len) != noErr) { - SCSIComplete(&stat, &msg, 300); + SCSIComplete(&scsi_stat, &scsi_msg, 300); warn("SCSICmd failed"); return -1; } @@ -267,7 +287,7 @@ scsi_io(unsigned short scsi_id, unsigned char *cdb, un } /* complete and free the bus before responding to the read/write */ - if ((ret = SCSIComplete(&stat, &msg, 300 /* 1/60 ticks */)) != noErr) { + if (SCSIComplete(&scsi_stat, &scsi_msg, 300 /* 1/60 ticks */) != noErr) { warn("SCSIComplete failed"); return -1; } @@ -275,7 +295,7 @@ scsi_io(unsigned short scsi_id, unsigned char *cdb, un if (ioret != noErr && ioret != scPhaseErr) warn("SCSIRead/Write failed"); - if (stat != noErr) + if (scsi_stat != noErr) warn("SCSIComplete bad status"); return len;