os_darwin: Fix NVMe log support, cleanup

git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@5073 4ea69e1a-61f1-4043-bf83-b5c94c648137
pull/58/head
samm-git 2 years ago
parent 0e06a903b0
commit dc8ab84518
  1. 6
      smartmontools/ChangeLog
  2. 13
      smartmontools/os_darwin.cpp
  3. 77
      smartmontools/os_darwin.h

@ -1,5 +1,11 @@
$Id$
2020-06-24 Alex Samorukov <samm@os2.kiev.ua>
os_darwin.cpp: Fix NVMe log support, handle error codes,
remove SMARTReadData call
os_darwin.h: Cleanup, remove all private functions
2020-06-23 Harry Mallon <hjmallon@gmail.com>
os_darwin.cpp, os_darwin.h: Add support for NVMe logs.

@ -560,16 +560,19 @@ bool darwin_nvme_device::nvme_pass_through(const nvme_cmd_in & in, nvme_cmd_out
if (! ifp)
return false;
smartIfNVMe = *ifp;
// currently only GetIdentifyData and SMARTReadData are supported
// currently only GetIdentifyData and GetLogPage are supported
switch (in.opcode) {
case smartmontools::nvme_admin_identify:
err = smartIfNVMe->GetIdentifyData(ifp, (struct nvme_id_ctrl *) in.buffer, in.nsid);
if (err)
return set_err(ENOSYS, "GetIdentifyData failed: system=0x%x, sub=0x%x, code=%d",
err_get_system(err), err_get_sub(err), err_get_code(err));
break;
case smartmontools::nvme_admin_get_log_page:
if(page == 0x02)
err = smartIfNVMe->SMARTReadData(ifp, (struct nvme_smart_log *) in.buffer);
else
err = smartIfNVMe->GetLogPage(ifp, in.buffer, page, in.size / 4);
err = smartIfNVMe->GetLogPage(ifp, in.buffer, page, in.size / 4 - 1);
if (err)
return set_err(ENOSYS, "GetLogPage failed: system=0x%x, sub=0x%x, code=%d",
err_get_system(err), err_get_sub(err), err_get_code(err));
break;
default:
return set_err(ENOSYS, "NVMe admin command 0x%02x is not supported", in.opcode);

@ -21,7 +21,7 @@
#define kIOPropertySMARTCapableKey "SMART Capable"
#endif
// NVMe definitions (see NVMeSMARTLibExternal.h)
// NVMe definitions based on Xcode SDK, see NVMeSMARTLibExternal.h
#define kIOPropertyNVMeSMARTCapableKey "NVMe SMART Capable"
// Constant to init driver
@ -34,7 +34,6 @@
0xcc, 0xd1, 0xdb, 0x19, 0xfd, 0x9a, 0x4d, 0xaf, 0xbf, 0x95, \
0x12, 0x45, 0x4b, 0x23, 0xa, 0xb6)
// interface structure, obtained using lldb, could be incomplete or wrong
typedef struct IONVMeSMARTInterface
{
IUNKNOWN_C_GUTS;
@ -50,63 +49,31 @@ typedef struct IONVMeSMARTInterface
IOReturn ( *GetIdentifyData )( void * interface,
struct nvme_id_ctrl * NVMeIdentifyControllerStruct,
unsigned int ns );
UInt64 reserved0;
UInt64 reserved1;
// Always getting kIOReturnDeviceError
IOReturn ( *GetFieldCounters )( void * interface,
char * FieldCounters );
// Returns 0
IOReturn ( *ScheduleBGRefresh )( void * interface);
// NumDWords Number of dwords for log page data, zero based.
IOReturn ( *GetLogPage )( void * interface, void * data, unsigned int logPageId, unsigned int numDWords);
UInt64 reserved2;
UInt64 reserved3;
UInt64 reserved4;
UInt64 reserved5;
UInt64 reserved6;
UInt64 reserved7;
UInt64 reserved8;
UInt64 reserved9;
UInt64 reserved10;
UInt64 reserved11;
UInt64 reserved12;
UInt64 reserved13;
UInt64 reserved14;
UInt64 reserved15;
UInt64 reserved16;
UInt64 reserved17;
UInt64 reserved18;
UInt64 reserved19;
/* GetSystemCounters Looks like a table with an attributes. Sample result:
0x101022200: 0x01 0x00 0x08 0x00 0x00 0x00 0x00 0x00
0x101022208: 0x00 0x00 0x00 0x00 0x02 0x00 0x08 0x00
0x101022210: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x101022218: 0x03 0x00 0x08 0x00 0xf1 0x74 0x26 0x01
0x101022220: 0x00 0x00 0x00 0x00 0x04 0x00 0x08 0x00
0x101022228: 0x0a 0x91 0xb1 0x00 0x00 0x00 0x00 0x00
0x101022230: 0x05 0x00 0x08 0x00 0x24 0x9f 0xfe 0x02
0x101022238: 0x00 0x00 0x00 0x00 0x06 0x00 0x08 0x00
0x101022240: 0x9b 0x42 0x38 0x02 0x00 0x00 0x00 0x00
0x101022248: 0x07 0x00 0x08 0x00 0xdd 0x08 0x00 0x00
0x101022250: 0x00 0x00 0x00 0x00 0x08 0x00 0x08 0x00
0x101022258: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x101022260: 0x09 0x00 0x08 0x00 0x00 0x00 0x00 0x00
0x101022268: 0x00 0x00 0x00 0x00 0x0a 0x00 0x04 0x00
.........
0x101022488: 0x74 0x00 0x08 0x00 0x00 0x00 0x00 0x00
0x101022490: 0x00 0x00 0x00 0x00 0x75 0x00 0x40 0x02
0x101022498: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
*/
IOReturn ( *GetSystemCounters )( void * interface, char *, unsigned int *);
/* GetAlgorithmCounters returns mostly 0
0x102004000: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004008: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004010: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004018: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004020: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004028: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004038: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004040: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004048: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004050: 0x00 0x00 0x00 0x00 0x80 0x00 0x00 0x00
0x102004058: 0x80 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004060: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004068: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004070: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004078: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004080: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004088: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x102004090: 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0x00
0x102004098: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
*/
IOReturn ( *GetAlgorithmCounters )( void * interface, char *, unsigned int *);
} IONVMeSMARTInterface;

Loading…
Cancel
Save