https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7fdf0781345eeb6fded67a...
commit 7fdf0781345eeb6fded67a02a8e6a5a8f79724b3 Author: Hervé Poussineau hpoussin@reactos.org AuthorDate: Sun Oct 3 19:13:19 2021 +0200 Commit: Hervé Poussineau hpoussin@reactos.org CommitDate: Sun Oct 3 23:09:55 2021 +0200
[UNIATA] Better split of model name between Vendor and Product
UNIATA is converting IDE identify data into SCSI identify data. However, IDE model is described with a unique field of 20 chars, while SCSI model is described with 2 fields of 16 + 8 chars. When displaying SCSI model, a space is added between vendor and product fields.
Try to split model into vendor and product on a space if possible.
CORE-17400 --- drivers/storage/ide/uniata/id_ata.cpp | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/drivers/storage/ide/uniata/id_ata.cpp b/drivers/storage/ide/uniata/id_ata.cpp index 7068beda353..6957956b88e 100644 --- a/drivers/storage/ide/uniata/id_ata.cpp +++ b/drivers/storage/ide/uniata/id_ata.cpp @@ -570,6 +570,52 @@ AtapiSuckPortBuffer2( return i; } // AtapiSuckPortBuffer2()
+#ifdef __REACTOS__ +VOID +DDKFASTAPI +FillDeviceIdentificationString( + IN OUT PINQUIRYDATA InquiryData, + IN PIDENTIFY_DATA2 IdentifyData) +{ + ULONG i; + ULONG IdentifierLen, FirstWordLen; + + /* We need to copy a field which is 20 chars long to two fields which are 8+16 bytes long (VendorId + ProductId) + * Note that a space will be added between those fields when displaying them. + * => Try to split identifier on space char. + */ + +#define IDENTIFIER_LETTER(Identifier, i) (((PUCHAR)Identifier)[(i) ^ 1]) + + for (IdentifierLen = 20; IdentifierLen > 0 && IDENTIFIER_LETTER(IdentifyData->ModelNumber, IdentifierLen - 1) == ' '; IdentifierLen--) + ; + + /* Strategy 1: copy first word to VendorId if len <= 8. Copy other chars to ProductId */ + for (FirstWordLen = 0; IDENTIFIER_LETTER(IdentifyData->ModelNumber, FirstWordLen) != ' ' && FirstWordLen < IdentifierLen; FirstWordLen++) + ; + if (FirstWordLen <= 8) + { + for (i = 0; i < FirstWordLen; i++) + InquiryData->VendorId[i] = IDENTIFIER_LETTER(IdentifyData->ModelNumber, i); + for (i = FirstWordLen + 1; i < IdentifierLen; i++) + InquiryData->ProductId[i - FirstWordLen - 1] = IDENTIFIER_LETTER(IdentifyData->ModelNumber, i); + return; + } + + /* Strategy 2: copy everything to ProductId */ + if (IdentifierLen <= 16) + { + for (i = 0; i < IdentifierLen; i++) + InquiryData->ProductId[i] = IDENTIFIER_LETTER(IdentifyData->ModelNumber, i); + return; + } + + /* Strategy 3: copy first to VendorId, then to ProductId */ + for (i = 0; i < 24; i += 2) + MOV_DW_SWP(InquiryData->DeviceIdentificationString[i], ((PUCHAR)IdentifyData->ModelNumber)[i]); +} +#endif + UCHAR DDKFASTAPI SelectDrive( @@ -8354,9 +8400,13 @@ default_no_prep: inquiryData->CommandQueue = 1;
// Fill in vendor identification fields. +#ifdef __REACTOS__ + FillDeviceIdentificationString(inquiryData, identifyData); +#else for (i = 0; i < 24; i += 2) { MOV_DW_SWP(inquiryData->DeviceIdentificationString[i], ((PUCHAR)identifyData->ModelNumber)[i]); } +#endif /* // Initialize unused portion of product id. for (i = 0; i < 4; i++) { @@ -9560,9 +9610,13 @@ reject_srb: inquiryData->CommandQueue = 1;
// Fill in vendor identification fields. +#ifdef __REACTOS__ + FillDeviceIdentificationString(inquiryData, identifyData); +#else for (i = 0; i < 24; i += 2) { MOV_DW_SWP(inquiryData->DeviceIdentificationString[i], ((PUCHAR)identifyData->ModelNumber)[i]); } +#endif
// Move firmware revision from IDENTIFY data to // product revision in INQUIRY data.