サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
コピー #include <windows.h>
// DSSD_POWER_STATE_DESCRIPTOR (x64 1 / x86 1 バイト)
typedef struct DSSD_POWER_STATE_DESCRIPTOR {
BYTE _bitfield;
} DSSD_POWER_STATE_DESCRIPTOR;
// NVME_OCP_DEVICE_CAPABILITIES_LOG (x64 4132 / x86 4108 バイト)
#pragma pack(push, 1)
typedef struct NVME_OCP_DEVICE_CAPABILITIES_LOG {
WORD PciePorts;
_OobMgmtSupport_e__Union OobMgmtSupport;
_WriteZeroesCommand_e__Union WriteZeroesCommand;
_SanitizeCommand_e__Union SanitizeCommand;
_DatasetMgmtCommand_e__Union DatasetMgmtCommand;
_WriteUncorrectableCommand_e__Union WriteUncorrectableCommand;
_FusedCommand_e__Union FusedCommand;
WORD MinimumValidDSSDPowerState;
BYTE Reserved0;
DSSD_POWER_STATE_DESCRIPTOR DssdDescriptors[127];
BYTE Reserved1[3934];
WORD LogPageVersionNumber;
GUID LogPageGUID;
} NVME_OCP_DEVICE_CAPABILITIES_LOG;
#pragma pack(pop)コピー using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DSSD_POWER_STATE_DESCRIPTOR
{
public byte _bitfield;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct NVME_OCP_DEVICE_CAPABILITIES_LOG
{
public ushort PciePorts;
public _OobMgmtSupport_e__Union OobMgmtSupport;
public _WriteZeroesCommand_e__Union WriteZeroesCommand;
public _SanitizeCommand_e__Union SanitizeCommand;
public _DatasetMgmtCommand_e__Union DatasetMgmtCommand;
public _WriteUncorrectableCommand_e__Union WriteUncorrectableCommand;
public _FusedCommand_e__Union FusedCommand;
public ushort MinimumValidDSSDPowerState;
public byte Reserved0;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 127)] public DSSD_POWER_STATE_DESCRIPTOR[] DssdDescriptors;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3934)] public byte[] Reserved1;
public ushort LogPageVersionNumber;
public Guid LogPageGUID;
}コピー Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DSSD_POWER_STATE_DESCRIPTOR
Public _bitfield As Byte
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure NVME_OCP_DEVICE_CAPABILITIES_LOG
Public PciePorts As UShort
Public OobMgmtSupport As _OobMgmtSupport_e__Union
Public WriteZeroesCommand As _WriteZeroesCommand_e__Union
Public SanitizeCommand As _SanitizeCommand_e__Union
Public DatasetMgmtCommand As _DatasetMgmtCommand_e__Union
Public WriteUncorrectableCommand As _WriteUncorrectableCommand_e__Union
Public FusedCommand As _FusedCommand_e__Union
Public MinimumValidDSSDPowerState As UShort
Public Reserved0 As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=127)> Public DssdDescriptors() As DSSD_POWER_STATE_DESCRIPTOR
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3934)> Public Reserved1() As Byte
Public LogPageVersionNumber As UShort
Public LogPageGUID As Guid
End Structureコピー import ctypes
from ctypes import wintypes
class DSSD_POWER_STATE_DESCRIPTOR(ctypes.Structure):
_fields_ = [
("_bitfield", ctypes.c_ubyte),
]
class NVME_OCP_DEVICE_CAPABILITIES_LOG(ctypes.Structure):
_pack_ = 1
_fields_ = [
("PciePorts", ctypes.c_ushort),
("OobMgmtSupport", _OobMgmtSupport_e__Union),
("WriteZeroesCommand", _WriteZeroesCommand_e__Union),
("SanitizeCommand", _SanitizeCommand_e__Union),
("DatasetMgmtCommand", _DatasetMgmtCommand_e__Union),
("WriteUncorrectableCommand", _WriteUncorrectableCommand_e__Union),
("FusedCommand", _FusedCommand_e__Union),
("MinimumValidDSSDPowerState", ctypes.c_ushort),
("Reserved0", ctypes.c_ubyte),
("DssdDescriptors", DSSD_POWER_STATE_DESCRIPTOR * 127),
("Reserved1", ctypes.c_ubyte * 3934),
("LogPageVersionNumber", ctypes.c_ushort),
("LogPageGUID", GUID),
]コピー #[repr(C)]
pub struct DSSD_POWER_STATE_DESCRIPTOR {
pub _bitfield: u8,
}
#[repr(C, packed(1))]
pub struct NVME_OCP_DEVICE_CAPABILITIES_LOG {
pub PciePorts: u16,
pub OobMgmtSupport: _OobMgmtSupport_e__Union,
pub WriteZeroesCommand: _WriteZeroesCommand_e__Union,
pub SanitizeCommand: _SanitizeCommand_e__Union,
pub DatasetMgmtCommand: _DatasetMgmtCommand_e__Union,
pub WriteUncorrectableCommand: _WriteUncorrectableCommand_e__Union,
pub FusedCommand: _FusedCommand_e__Union,
pub MinimumValidDSSDPowerState: u16,
pub Reserved0: u8,
pub DssdDescriptors: [DSSD_POWER_STATE_DESCRIPTOR; 127],
pub Reserved1: [u8; 3934],
pub LogPageVersionNumber: u16,
pub LogPageGUID: GUID,
}コピー import "golang.org/x/sys/windows"
type DSSD_POWER_STATE_DESCRIPTOR struct {
_bitfield byte
}
type NVME_OCP_DEVICE_CAPABILITIES_LOG struct {
PciePorts uint16
OobMgmtSupport _OobMgmtSupport_e__Union
WriteZeroesCommand _WriteZeroesCommand_e__Union
SanitizeCommand _SanitizeCommand_e__Union
DatasetMgmtCommand _DatasetMgmtCommand_e__Union
WriteUncorrectableCommand _WriteUncorrectableCommand_e__Union
FusedCommand _FusedCommand_e__Union
MinimumValidDSSDPowerState uint16
Reserved0 byte
DssdDescriptors [127]DSSD_POWER_STATE_DESCRIPTOR
Reserved1 [3934]byte
LogPageVersionNumber uint16
LogPageGUID windows.GUID
}コピー type
DSSD_POWER_STATE_DESCRIPTOR = record
_bitfield: Byte;
end;
NVME_OCP_DEVICE_CAPABILITIES_LOG = packed record
PciePorts: Word;
OobMgmtSupport: _OobMgmtSupport_e__Union;
WriteZeroesCommand: _WriteZeroesCommand_e__Union;
SanitizeCommand: _SanitizeCommand_e__Union;
DatasetMgmtCommand: _DatasetMgmtCommand_e__Union;
WriteUncorrectableCommand: _WriteUncorrectableCommand_e__Union;
FusedCommand: _FusedCommand_e__Union;
MinimumValidDSSDPowerState: Word;
Reserved0: Byte;
DssdDescriptors: array[0..126] of DSSD_POWER_STATE_DESCRIPTOR;
Reserved1: array[0..3933] of Byte;
LogPageVersionNumber: Word;
LogPageGUID: TGUID;
end;コピー const DSSD_POWER_STATE_DESCRIPTOR = extern struct {
_bitfield: u8,
};
const NVME_OCP_DEVICE_CAPABILITIES_LOG = extern struct {
PciePorts: u16,
OobMgmtSupport: _OobMgmtSupport_e__Union,
WriteZeroesCommand: _WriteZeroesCommand_e__Union,
SanitizeCommand: _SanitizeCommand_e__Union,
DatasetMgmtCommand: _DatasetMgmtCommand_e__Union,
WriteUncorrectableCommand: _WriteUncorrectableCommand_e__Union,
FusedCommand: _FusedCommand_e__Union,
MinimumValidDSSDPowerState: u16,
Reserved0: u8,
DssdDescriptors: [127]DSSD_POWER_STATE_DESCRIPTOR,
Reserved1: [3934]u8,
LogPageVersionNumber: u16,
LogPageGUID: GUID,
};コピー type
DSSD_POWER_STATE_DESCRIPTOR {.bycopy.} = object
_bitfield: uint8
NVME_OCP_DEVICE_CAPABILITIES_LOG {.packed.} = object
PciePorts: uint16
OobMgmtSupport: _OobMgmtSupport_e__Union
WriteZeroesCommand: _WriteZeroesCommand_e__Union
SanitizeCommand: _SanitizeCommand_e__Union
DatasetMgmtCommand: _DatasetMgmtCommand_e__Union
WriteUncorrectableCommand: _WriteUncorrectableCommand_e__Union
FusedCommand: _FusedCommand_e__Union
MinimumValidDSSDPowerState: uint16
Reserved0: uint8
DssdDescriptors: array[127, DSSD_POWER_STATE_DESCRIPTOR]
Reserved1: array[3934, uint8]
LogPageVersionNumber: uint16
LogPageGUID: GUIDコピー struct DSSD_POWER_STATE_DESCRIPTOR
{
ubyte _bitfield;
}
align(1)
struct NVME_OCP_DEVICE_CAPABILITIES_LOG
{
ushort PciePorts;
_OobMgmtSupport_e__Union OobMgmtSupport;
_WriteZeroesCommand_e__Union WriteZeroesCommand;
_SanitizeCommand_e__Union SanitizeCommand;
_DatasetMgmtCommand_e__Union DatasetMgmtCommand;
_WriteUncorrectableCommand_e__Union WriteUncorrectableCommand;
_FusedCommand_e__Union FusedCommand;
ushort MinimumValidDSSDPowerState;
ubyte Reserved0;
DSSD_POWER_STATE_DESCRIPTOR[127] DssdDescriptors;
ubyte[3934] Reserved1;
ushort LogPageVersionNumber;
GUID LogPageGUID;
}HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT (#defstruct/stdim/->)で32/64bit共通。
コピー ; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NVME_OCP_DEVICE_CAPABILITIES_LOG サイズ: 4108 バイト(x86)
dim st, 1027 ; 4byte整数×1027(構造体サイズ 4108 / 4 切り上げ)
; PciePorts : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; OobMgmtSupport : _OobMgmtSupport_e__Union (+2, 4byte) varptr(st)+2 を基点に操作(4byte:入れ子/配列)
; WriteZeroesCommand : _WriteZeroesCommand_e__Union (+6, 4byte) varptr(st)+6 を基点に操作(4byte:入れ子/配列)
; SanitizeCommand : _SanitizeCommand_e__Union (+10, 4byte) varptr(st)+10 を基点に操作(4byte:入れ子/配列)
; DatasetMgmtCommand : _DatasetMgmtCommand_e__Union (+14, 4byte) varptr(st)+14 を基点に操作(4byte:入れ子/配列)
; WriteUncorrectableCommand : _WriteUncorrectableCommand_e__Union (+18, 4byte) varptr(st)+18 を基点に操作(4byte:入れ子/配列)
; FusedCommand : _FusedCommand_e__Union (+22, 4byte) varptr(st)+22 を基点に操作(4byte:入れ子/配列)
; MinimumValidDSSDPowerState : WORD (+26, 2byte) wpoke st,26,値 / 値 = wpeek(st,26)
; Reserved0 : BYTE (+28, 1byte) poke st,28,値 / 値 = peek(st,28)
; DssdDescriptors : DSSD_POWER_STATE_DESCRIPTOR (+29, 127byte) varptr(st)+29 を基点に操作(127byte:入れ子/配列)
; Reserved1 : BYTE (+156, 3934byte) varptr(st)+156 を基点に操作(3934byte:入れ子/配列)
; LogPageVersionNumber : WORD (+4090, 2byte) wpoke st,4090,値 / 値 = wpeek(st,4090)
; LogPageGUID : GUID (+4092, 16byte) varptr(st)+4092 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。コピー ; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_OCP_DEVICE_CAPABILITIES_LOG サイズ: 4132 バイト(x64)
dim st, 1033 ; 4byte整数×1033(構造体サイズ 4132 / 4 切り上げ)
; PciePorts : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; OobMgmtSupport : _OobMgmtSupport_e__Union (+2, 8byte) varptr(st)+2 を基点に操作(8byte:入れ子/配列)
; WriteZeroesCommand : _WriteZeroesCommand_e__Union (+10, 8byte) varptr(st)+10 を基点に操作(8byte:入れ子/配列)
; SanitizeCommand : _SanitizeCommand_e__Union (+18, 8byte) varptr(st)+18 を基点に操作(8byte:入れ子/配列)
; DatasetMgmtCommand : _DatasetMgmtCommand_e__Union (+26, 8byte) varptr(st)+26 を基点に操作(8byte:入れ子/配列)
; WriteUncorrectableCommand : _WriteUncorrectableCommand_e__Union (+34, 8byte) varptr(st)+34 を基点に操作(8byte:入れ子/配列)
; FusedCommand : _FusedCommand_e__Union (+42, 8byte) varptr(st)+42 を基点に操作(8byte:入れ子/配列)
; MinimumValidDSSDPowerState : WORD (+50, 2byte) wpoke st,50,値 / 値 = wpeek(st,50)
; Reserved0 : BYTE (+52, 1byte) poke st,52,値 / 値 = peek(st,52)
; DssdDescriptors : DSSD_POWER_STATE_DESCRIPTOR (+53, 127byte) varptr(st)+53 を基点に操作(127byte:入れ子/配列)
; Reserved1 : BYTE (+180, 3934byte) varptr(st)+180 を基点に操作(3934byte:入れ子/配列)
; LogPageVersionNumber : WORD (+4114, 2byte) wpoke st,4114,値 / 値 = wpeek(st,4114)
; LogPageGUID : GUID (+4116, 16byte) varptr(st)+4116 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。コピー ; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global DSSD_POWER_STATE_DESCRIPTOR
#field byte _bitfield
#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_CAPABILITIES_LOG, pack=1
#field short PciePorts
#field byte OobMgmtSupport 8
#field byte WriteZeroesCommand 8
#field byte SanitizeCommand 8
#field byte DatasetMgmtCommand 8
#field byte WriteUncorrectableCommand 8
#field byte FusedCommand 8
#field short MinimumValidDSSDPowerState
#field byte Reserved0
#field DSSD_POWER_STATE_DESCRIPTOR DssdDescriptors 127
#field byte Reserved1 3934
#field short LogPageVersionNumber
#field GUID LogPageGUID
#endstruct
stdim st, NVME_OCP_DEVICE_CAPABILITIES_LOG ; NSTRUCT 変数を確保
st->PciePorts = 100
mes "PciePorts=" + st->PciePorts
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。