ホーム › Storage.Nvme › NVME_OCP_DEVICE_TCG_HISTORY_LOG
NVME_OCP_DEVICE_TCG_HISTORY_LOG
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| LID | BYTE | 1 | +0 | +0 | このログページのログ識別子。 |
| Reserved0 | BYTE | 3 | +1 | +1 | 予約領域。将来拡張用で0とする。 |
| HistoryEntryCount | DWORD | 4 | +4 | +4 | TCG履歴エントリの個数。 |
| HistoryEntries | TCG_HISTORY_ENTRY | 4032 | +8 | +8 | TCG履歴エントリの配列。 |
| Reserved1 | BYTE | 38 | +4040 | +4040 | 予約領域。将来拡張用で0とする。 |
| LogPageVersionNumber | WORD | 2 | +4078 | +4078 | このログページの版数。 |
| LogPageGUID | GUID | 16 | +4080 | +4080 | ログページを識別する16バイトGUID。 |
各言語での定義
#include <windows.h>
// TCG_HISTORY_ENTRY (x64 48 / x86 48 バイト)
#pragma pack(push, 1)
typedef struct TCG_HISTORY_ENTRY {
BYTE VersionNumber;
BYTE EntryLength;
WORD PowerCycleCount;
DWORD TcgCommandCount;
ULONGLONG TcgCommandCompletionTS;
ULONGLONG InvokingId;
ULONGLONG MethodId;
WORD ComId;
BYTE ProtocolId;
BYTE TcgStatus;
WORD ProcessTime;
BYTE CommandSpecific[10];
} TCG_HISTORY_ENTRY;
#pragma pack(pop)
// NVME_OCP_DEVICE_TCG_HISTORY_LOG (x64 4096 / x86 4096 バイト)
#pragma pack(push, 1)
typedef struct NVME_OCP_DEVICE_TCG_HISTORY_LOG {
BYTE LID;
BYTE Reserved0[3];
DWORD HistoryEntryCount;
TCG_HISTORY_ENTRY HistoryEntries[84];
BYTE Reserved1[38];
WORD LogPageVersionNumber;
GUID LogPageGUID;
} NVME_OCP_DEVICE_TCG_HISTORY_LOG;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct TCG_HISTORY_ENTRY
{
public byte VersionNumber;
public byte EntryLength;
public ushort PowerCycleCount;
public uint TcgCommandCount;
public ulong TcgCommandCompletionTS;
public ulong InvokingId;
public ulong MethodId;
public ushort ComId;
public byte ProtocolId;
public byte TcgStatus;
public ushort ProcessTime;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public byte[] CommandSpecific;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct NVME_OCP_DEVICE_TCG_HISTORY_LOG
{
public byte LID;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] Reserved0;
public uint HistoryEntryCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 84)] public TCG_HISTORY_ENTRY[] HistoryEntries;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)] public byte[] Reserved1;
public ushort LogPageVersionNumber;
public Guid LogPageGUID;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure TCG_HISTORY_ENTRY
Public VersionNumber As Byte
Public EntryLength As Byte
Public PowerCycleCount As UShort
Public TcgCommandCount As UInteger
Public TcgCommandCompletionTS As ULong
Public InvokingId As ULong
Public MethodId As ULong
Public ComId As UShort
Public ProtocolId As Byte
Public TcgStatus As Byte
Public ProcessTime As UShort
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=10)> Public CommandSpecific() As Byte
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure NVME_OCP_DEVICE_TCG_HISTORY_LOG
Public LID As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved0() As Byte
Public HistoryEntryCount As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=84)> Public HistoryEntries() As TCG_HISTORY_ENTRY
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=38)> Public Reserved1() As Byte
Public LogPageVersionNumber As UShort
Public LogPageGUID As Guid
End Structureimport ctypes
from ctypes import wintypes
class TCG_HISTORY_ENTRY(ctypes.Structure):
_pack_ = 1
_fields_ = [
("VersionNumber", ctypes.c_ubyte),
("EntryLength", ctypes.c_ubyte),
("PowerCycleCount", ctypes.c_ushort),
("TcgCommandCount", wintypes.DWORD),
("TcgCommandCompletionTS", ctypes.c_ulonglong),
("InvokingId", ctypes.c_ulonglong),
("MethodId", ctypes.c_ulonglong),
("ComId", ctypes.c_ushort),
("ProtocolId", ctypes.c_ubyte),
("TcgStatus", ctypes.c_ubyte),
("ProcessTime", ctypes.c_ushort),
("CommandSpecific", ctypes.c_ubyte * 10),
]
class NVME_OCP_DEVICE_TCG_HISTORY_LOG(ctypes.Structure):
_pack_ = 1
_fields_ = [
("LID", ctypes.c_ubyte),
("Reserved0", ctypes.c_ubyte * 3),
("HistoryEntryCount", wintypes.DWORD),
("HistoryEntries", TCG_HISTORY_ENTRY * 84),
("Reserved1", ctypes.c_ubyte * 38),
("LogPageVersionNumber", ctypes.c_ushort),
("LogPageGUID", GUID),
]#[repr(C, packed(1))]
pub struct TCG_HISTORY_ENTRY {
pub VersionNumber: u8,
pub EntryLength: u8,
pub PowerCycleCount: u16,
pub TcgCommandCount: u32,
pub TcgCommandCompletionTS: u64,
pub InvokingId: u64,
pub MethodId: u64,
pub ComId: u16,
pub ProtocolId: u8,
pub TcgStatus: u8,
pub ProcessTime: u16,
pub CommandSpecific: [u8; 10],
}
#[repr(C, packed(1))]
pub struct NVME_OCP_DEVICE_TCG_HISTORY_LOG {
pub LID: u8,
pub Reserved0: [u8; 3],
pub HistoryEntryCount: u32,
pub HistoryEntries: [TCG_HISTORY_ENTRY; 84],
pub Reserved1: [u8; 38],
pub LogPageVersionNumber: u16,
pub LogPageGUID: GUID,
}import "golang.org/x/sys/windows"
type TCG_HISTORY_ENTRY struct {
VersionNumber byte
EntryLength byte
PowerCycleCount uint16
TcgCommandCount uint32
TcgCommandCompletionTS uint64
InvokingId uint64
MethodId uint64
ComId uint16
ProtocolId byte
TcgStatus byte
ProcessTime uint16
CommandSpecific [10]byte
}
type NVME_OCP_DEVICE_TCG_HISTORY_LOG struct {
LID byte
Reserved0 [3]byte
HistoryEntryCount uint32
HistoryEntries [84]TCG_HISTORY_ENTRY
Reserved1 [38]byte
LogPageVersionNumber uint16
LogPageGUID windows.GUID
}type
TCG_HISTORY_ENTRY = packed record
VersionNumber: Byte;
EntryLength: Byte;
PowerCycleCount: Word;
TcgCommandCount: DWORD;
TcgCommandCompletionTS: UInt64;
InvokingId: UInt64;
MethodId: UInt64;
ComId: Word;
ProtocolId: Byte;
TcgStatus: Byte;
ProcessTime: Word;
CommandSpecific: array[0..9] of Byte;
end;
NVME_OCP_DEVICE_TCG_HISTORY_LOG = packed record
LID: Byte;
Reserved0: array[0..2] of Byte;
HistoryEntryCount: DWORD;
HistoryEntries: array[0..83] of TCG_HISTORY_ENTRY;
Reserved1: array[0..37] of Byte;
LogPageVersionNumber: Word;
LogPageGUID: TGUID;
end;const TCG_HISTORY_ENTRY = extern struct {
VersionNumber: u8,
EntryLength: u8,
PowerCycleCount: u16,
TcgCommandCount: u32,
TcgCommandCompletionTS: u64,
InvokingId: u64,
MethodId: u64,
ComId: u16,
ProtocolId: u8,
TcgStatus: u8,
ProcessTime: u16,
CommandSpecific: [10]u8,
};
const NVME_OCP_DEVICE_TCG_HISTORY_LOG = extern struct {
LID: u8,
Reserved0: [3]u8,
HistoryEntryCount: u32,
HistoryEntries: [84]TCG_HISTORY_ENTRY,
Reserved1: [38]u8,
LogPageVersionNumber: u16,
LogPageGUID: GUID,
};type
TCG_HISTORY_ENTRY {.packed.} = object
VersionNumber: uint8
EntryLength: uint8
PowerCycleCount: uint16
TcgCommandCount: uint32
TcgCommandCompletionTS: uint64
InvokingId: uint64
MethodId: uint64
ComId: uint16
ProtocolId: uint8
TcgStatus: uint8
ProcessTime: uint16
CommandSpecific: array[10, uint8]
NVME_OCP_DEVICE_TCG_HISTORY_LOG {.packed.} = object
LID: uint8
Reserved0: array[3, uint8]
HistoryEntryCount: uint32
HistoryEntries: array[84, TCG_HISTORY_ENTRY]
Reserved1: array[38, uint8]
LogPageVersionNumber: uint16
LogPageGUID: GUIDalign(1)
struct TCG_HISTORY_ENTRY
{
ubyte VersionNumber;
ubyte EntryLength;
ushort PowerCycleCount;
uint TcgCommandCount;
ulong TcgCommandCompletionTS;
ulong InvokingId;
ulong MethodId;
ushort ComId;
ubyte ProtocolId;
ubyte TcgStatus;
ushort ProcessTime;
ubyte[10] CommandSpecific;
}
align(1)
struct NVME_OCP_DEVICE_TCG_HISTORY_LOG
{
ubyte LID;
ubyte[3] Reserved0;
uint HistoryEntryCount;
TCG_HISTORY_ENTRY[84] HistoryEntries;
ubyte[38] Reserved1;
ushort LogPageVersionNumber;
GUID LogPageGUID;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_OCP_DEVICE_TCG_HISTORY_LOG サイズ: 4096 バイト(x64)
dim st, 1024 ; 4byte整数×1024(構造体サイズ 4096 / 4 切り上げ)
; LID : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; Reserved0 : BYTE (+1, 3byte) varptr(st)+1 を基点に操作(3byte:入れ子/配列)
; HistoryEntryCount : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; HistoryEntries : TCG_HISTORY_ENTRY (+8, 4032byte) varptr(st)+8 を基点に操作(4032byte:入れ子/配列)
; Reserved1 : BYTE (+4040, 38byte) varptr(st)+4040 を基点に操作(38byte:入れ子/配列)
; LogPageVersionNumber : WORD (+4078, 2byte) wpoke st,4078,値 / 値 = wpeek(st,4078)
; LogPageGUID : GUID (+4080, 16byte) varptr(st)+4080 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global TCG_HISTORY_ENTRY, pack=1
#field byte VersionNumber
#field byte EntryLength
#field short PowerCycleCount
#field int TcgCommandCount
#field int64 TcgCommandCompletionTS
#field int64 InvokingId
#field int64 MethodId
#field short ComId
#field byte ProtocolId
#field byte TcgStatus
#field short ProcessTime
#field byte CommandSpecific 10
#endstruct
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global NVME_OCP_DEVICE_TCG_HISTORY_LOG, pack=1
#field byte LID
#field byte Reserved0 3
#field int HistoryEntryCount
#field TCG_HISTORY_ENTRY HistoryEntries 84
#field byte Reserved1 38
#field short LogPageVersionNumber
#field GUID LogPageGUID
#endstruct
stdim st, NVME_OCP_DEVICE_TCG_HISTORY_LOG ; NSTRUCT 変数を確保
st->LID = 100
mes "LID=" + st->LID