On Sun, May 01, 2016 at 11:21:18PM +0200, Mark Kettenis wrote:
> Diff below provides a bit more meaningful information in the SCSI
> INQUIRY emulation. It decodes the JDEC manufacturer ID code and
> provides the product string and revision number as read from the card.
>
> For example:
>
> scsibus1 at sdmmc2: 2 targets, initiator 0
> sd0 at scsibus1 targ 1 lun 0: <Sandisk, SA04G, 0006> SCSI2 0/direct fixed
> sd0: 3768MB, 512 bytes/sector, 7716864 sectors
> scsibus2 at sdmmc0: 2 targets, initiator 0
> sd1 at scsibus2 targ 1 lun 0: <Kingston, S10032, 0000> SCSI2 0/direct fixed
> sd1: 29184MB, 512 bytes/sector, 59768832 sectors
>
> where sd0 is an SD card and sd1 is the eMMC soldered onto the board of
> the machine.
>
> Note that the strncpy here is safe. The strings in the scsi inquiry
> page don't have to be nul-terminated.
>
> ok?
Sounds good to me though you don't seem to have mids for
any of the cards I have, only one of the emmc devices.
I wonder if it is worth skipping the product if it is
all '0'/' '
0x03 SanDisk
0x1b Samsung
0x28 Lexar (Micron)
0x45 SanDisk
element 14 bbb rev C:
=> mmc info
Device: OMAP SD/MMC
Manufacturer ID: 70
OEM: 100
Name: MMC04
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.5
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 4 MiB
User Capacity: 3.6 GiB
Boot Capacity: 2 MiB ENH
RPMB Capacity: 128 KiB ENH
samsung 8GB uSD
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 1b
OEM: 534d
Name: 00000
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.5 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
lexar 16GB uSD
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 28
OEM: 4245
Name:
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.9 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
sandisk 4GB uSD
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 3
OEM: 5344
Name: SU04G
Tran Speed: 50000000
Rd Block Len: 512
SD version 2.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
sandisk 4GB SD
unknown MID 0x3
sd1 at scsibus2 targ 1 lun 0: <SD/MMC, SD04G, 0080> SCSI2 0/direct fixed
sd1: 3781MB, 512 bytes/sector, 7744512 sectors
100s emmc
sdhc0 at acpi0: SDHA addr 0x9091d000/0x1000 irq 44
sdhc0: 200 MHz base clock
sdmmc0 at sdhc0: 8-bit, sd high-speed, mmc high-speed, dma
sdhc1 at acpi0: SDHB addr 0x90901000/0x1000 irq 46
sdhc1: 100 MHz base clock
sdmmc1 at sdhc1: 4-bit, sd high-speed, mmc high-speed, dma
sdhc2 at acpi0: SDHD addr 0x90903000/0x1000 irq 47, gpio
sdhc2: 100 MHz base clock
sdmmc2 at sdhc2: 4-bit, sd high-speed, mmc high-speed, dma
...
scsibus1 at sdmmc0: 2 targets, initiator 0
unknown MID 0x45
sd0 at scsibus1 targ 1 lun 0: <SD/MMC, DB4032, 0000> SCSI2 0/direct fixed
sd0: 29820MB, 512 bytes/sector, 61071360 sectors
Windows identifies this as "SanDisk DB4032"
>
>
> Index: sdmmc_scsi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/sdmmc/sdmmc_scsi.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 sdmmc_scsi.c
> --- sdmmc_scsi.c 14 Mar 2015 03:38:49 -0000 1.35
> +++ sdmmc_scsi.c 1 May 2016 21:20:05 -0000
> @@ -376,8 +376,12 @@ void
> sdmmc_inquiry(struct scsi_xfer *xs)
> {
> struct scsi_link *link = xs->sc_link;
> + struct sdmmc_softc *sc = link->adapter_softc;
> + struct sdmmc_scsi_softc *scbus = sc->sc_scsibus;
> + struct sdmmc_scsi_target *tgt = &scbus->sc_tgt[link->target];
> struct scsi_inquiry_data inq;
> struct scsi_inquiry *cdb = (struct scsi_inquiry *)xs->cmd;
> + char revision[5];
>
> if (xs->cmdlen != sizeof(*cdb)) {
> xs->error = XS_DRIVER_STUFFUP;
> @@ -394,10 +398,29 @@ sdmmc_inquiry(struct scsi_xfer *xs)
> inq.version = 2;
> inq.response_format = 2;
> inq.additional_length = 32;
> - strlcpy(inq.vendor, "SD/MMC ", sizeof(inq.vendor));
> - snprintf(inq.product, sizeof(inq.product),
> - "Drive #%02d", link->target);
> - strlcpy(inq.revision, " ", sizeof(inq.revision));
> + switch (tgt->card->cid.mid) {
> + case 0x02:
> + strncpy(inq.vendor, "Sandisk", sizeof(inq.vendor));
> + break;
> + case 0x11:
> + strncpy(inq.vendor, "Toshiba", sizeof(inq.vendor));
> + break;
> + case 0x13:
> + strncpy(inq.vendor, "Micron", sizeof(inq.vendor));
> + break;
> + case 0x15:
> + strncpy(inq.vendor, "Samsung", sizeof(inq.vendor));
> + break;
> + case 0x70:
> + strncpy(inq.vendor, "Kingston", sizeof(inq.vendor));
> + break;
> + default:
> + strncpy(inq.vendor, "SD/MMC", sizeof(inq.vendor));
> + break;
> + }
> + strncpy(inq.product, tgt->card->cid.pnm, sizeof(inq.product));
> + snprintf(revision, sizeof(revision), "%04X", tgt->card->cid.rev);
> + strncpy(inq.revision, revision, sizeof(inq.revision));
>
> bcopy(&inq, xs->data, MIN(xs->datalen, sizeof(inq)));
>
>