1 /*******************************************************************************
2 * NVMeBuildIdentify
3 *
4 * @brief Convert the NVMe ID data to the ATA Identify Structure
5 *
6 * @param pDevExt - Pointer to hardware device extension.
7 * @param pSrb - Pointer to SRB
8 *
9 * @return VOID
10 ******************************************************************************/
11 VOID NVMeBuildIdentify(
12 PSENDCMDOUTPARAMS pCmdOutParameters,
13 PNVME_DEVICE_EXTENSION pDevExt
14 )
15 {
16 PIDENTIFY_DEVICE_DATA id_data =
17 (PIDENTIFY_DEVICE_DATA)(pCmdOutParameters->bBuffer);
18 UINT8 checksum = 0;
19 UINT32 cs_i = 0;
20
21 /*
22 * ToDo - Fill out all the entire Identify Structure
23 */
24
25 id_data->CommandSetSupport.SmartCommands = TRUE;
26 id_data->CommandSetActive.SmartCommands = TRUE;
27
28 /* Copy Serial Number */
29 StorPortCopyMemory(
30 id_data->SerialNumber,
31 pDevExt->controllerIdentifyData.SN,
32 20);
33
34 /* Copy Model Number */
35 StorPortCopyMemory(
36 id_data->ModelNumber,
37 pDevExt->controllerIdentifyData.MN,
38 40);
39
40 /* Copy Firmware Version */
41 StorPortCopyMemory(id_data->FirmwareRevision,
42 pDevExt->controllerIdentifyData.FR,
43 8);
44
45 /* Generate 8-bit Checksum */
46 for (cs_i = 0; cs_i < IDENTIFY_BUFFER_SIZE; cs_i++)
47 {
48 checksum += ((PUINT8)id_data)[cs_i];
49 }
50 id_data->CheckSum = checksum;
51 } /* NVMeBuildIdentify */
52
1 /*******************************************************************************
2 * NVMeASCIIStringToATAString
3 *
4 * @brief Convert the ASCII string to an ATA string
5 *
6 * @param dest - Pointer to destination buffer
7 * @param src - Pointer to source buffer
8 * @param count - Length
9 *
10 * @return VOID
11 ******************************************************************************/
12 VOID NVMeASCIIStringToATAString(PUCHAR dest, PUCHAR src, int count)
13 {
14 int i;
15
16 // Only works for even byte strings
17 ASSERT((count&0x01)==0);
18
19 // Convert from ASCII string to ATA string
20 for ( i=0; i<count; i++ )
21 {
22 dest[i] = src[i + ((i&0x01) ? -1:1)];
23 }
24 }
25
26 /*******************************************************************************
27 * NVMeBuildIdentify
28 *
29 * @brief Convert the NVMe ID data to the ATA Identify Structure
30 *
31 * @param pDevExt - Pointer to hardware device extension.
32 * @param pSrb - Pointer to SRB
33 *
34 * @return VOID
35 ******************************************************************************/
36 VOID NVMeBuildIdentify(
37 PSENDCMDOUTPARAMS pCmdOutParameters,
38 PNVME_DEVICE_EXTENSION pDevExt
39 )
40 {
41 PIDENTIFY_DEVICE_DATA id_data =
42 (PIDENTIFY_DEVICE_DATA)(pCmdOutParameters->bBuffer);
43 UINT8 checksum = 0;
44 UINT32 cs_i = 0;
45
46 /*
47 * ToDo - Fill out all the entire Identify Structure
48 */
49
50 id_data->CommandSetSupport.SmartCommands = TRUE;
51 id_data->CommandSetActive.SmartCommands = TRUE;
52
53 /* Copy Serial Number */
54 NVMeASCIIStringToATAString(
55 id_data->SerialNumber,
56 pDevExt->controllerIdentifyData.SN,
57 20);
58
59 /* Copy Model Number */
60 NVMeASCIIStringToATAString(
61 id_data->ModelNumber,
62 pDevExt->controllerIdentifyData.MN,
63 40);
64
65 /* Copy Firmware Version */
66 NVMeASCIIStringToATAString(id_data->FirmwareRevision,
67 pDevExt->controllerIdentifyData.FR,
68 8);
69
70 // Fill in the Checksum Validity Indicator
71 id_data->Signature = 0xA5;
72
73 /* Generate 8-bit Checksum */
74 for (cs_i = 0; cs_i < IDENTIFY_BUFFER_SIZE-1; cs_i++)
75 {
76 checksum += ((PUINT8)id_data)[cs_i];
77 }
78 id_data->CheckSum = (0-checksum);
79 } /* NVMeBuildIdentify */
80
Legend:
Added(28,3)
Deleted(0,1)
Changed(5)
Changed in changed(4)