ホーム › Storage.Nvme › NVM_SET_LIST
NVM_SET_LIST
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| IdentifierCount | BYTE | 1 | +0 | +0 | リストに含まれるNVMセット属性エントリの個数。 |
| Reserved | BYTE | 127 | +1 | +1 | 予約領域。将来拡張用で0とする。 |
| Entry | NVME_SET_ATTRIBUTES_ENTRY | 128 | +128 | +128 | NVMセット属性エントリの配列。各要素は1つのセットを記述する。 |
各言語での定義
#include <windows.h>
// NVME_SET_ATTRIBUTES_ENTRY (x64 128 / x86 128 バイト)
typedef struct NVME_SET_ATTRIBUTES_ENTRY {
WORD Identifier;
WORD ENDGID;
DWORD Reserved1;
DWORD Random4KBReadTypical;
DWORD OptimalWriteSize;
BYTE TotalCapacity[16];
BYTE UnallocatedCapacity[16];
BYTE Reserved2[80];
} NVME_SET_ATTRIBUTES_ENTRY;
// NVM_SET_LIST (x64 256 / x86 256 バイト)
typedef struct NVM_SET_LIST {
BYTE IdentifierCount;
BYTE Reserved[127];
NVME_SET_ATTRIBUTES_ENTRY Entry[1];
} NVM_SET_LIST;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_SET_ATTRIBUTES_ENTRY
{
public ushort Identifier;
public ushort ENDGID;
public uint Reserved1;
public uint Random4KBReadTypical;
public uint OptimalWriteSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] TotalCapacity;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] UnallocatedCapacity;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] public byte[] Reserved2;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVM_SET_LIST
{
public byte IdentifierCount;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 127)] public byte[] Reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public NVME_SET_ATTRIBUTES_ENTRY[] Entry;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_SET_ATTRIBUTES_ENTRY
Public Identifier As UShort
Public ENDGID As UShort
Public Reserved1 As UInteger
Public Random4KBReadTypical As UInteger
Public OptimalWriteSize As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public TotalCapacity() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public UnallocatedCapacity() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=80)> Public Reserved2() As Byte
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVM_SET_LIST
Public IdentifierCount As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=127)> Public Reserved() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Entry() As NVME_SET_ATTRIBUTES_ENTRY
End Structureimport ctypes
from ctypes import wintypes
class NVME_SET_ATTRIBUTES_ENTRY(ctypes.Structure):
_fields_ = [
("Identifier", ctypes.c_ushort),
("ENDGID", ctypes.c_ushort),
("Reserved1", wintypes.DWORD),
("Random4KBReadTypical", wintypes.DWORD),
("OptimalWriteSize", wintypes.DWORD),
("TotalCapacity", ctypes.c_ubyte * 16),
("UnallocatedCapacity", ctypes.c_ubyte * 16),
("Reserved2", ctypes.c_ubyte * 80),
]
class NVM_SET_LIST(ctypes.Structure):
_fields_ = [
("IdentifierCount", ctypes.c_ubyte),
("Reserved", ctypes.c_ubyte * 127),
("Entry", NVME_SET_ATTRIBUTES_ENTRY * 1),
]#[repr(C)]
pub struct NVME_SET_ATTRIBUTES_ENTRY {
pub Identifier: u16,
pub ENDGID: u16,
pub Reserved1: u32,
pub Random4KBReadTypical: u32,
pub OptimalWriteSize: u32,
pub TotalCapacity: [u8; 16],
pub UnallocatedCapacity: [u8; 16],
pub Reserved2: [u8; 80],
}
#[repr(C)]
pub struct NVM_SET_LIST {
pub IdentifierCount: u8,
pub Reserved: [u8; 127],
pub Entry: [NVME_SET_ATTRIBUTES_ENTRY; 1],
}import "golang.org/x/sys/windows"
type NVME_SET_ATTRIBUTES_ENTRY struct {
Identifier uint16
ENDGID uint16
Reserved1 uint32
Random4KBReadTypical uint32
OptimalWriteSize uint32
TotalCapacity [16]byte
UnallocatedCapacity [16]byte
Reserved2 [80]byte
}
type NVM_SET_LIST struct {
IdentifierCount byte
Reserved [127]byte
Entry [1]NVME_SET_ATTRIBUTES_ENTRY
}type
NVME_SET_ATTRIBUTES_ENTRY = record
Identifier: Word;
ENDGID: Word;
Reserved1: DWORD;
Random4KBReadTypical: DWORD;
OptimalWriteSize: DWORD;
TotalCapacity: array[0..15] of Byte;
UnallocatedCapacity: array[0..15] of Byte;
Reserved2: array[0..79] of Byte;
end;
NVM_SET_LIST = record
IdentifierCount: Byte;
Reserved: array[0..126] of Byte;
Entry: array[0..0] of NVME_SET_ATTRIBUTES_ENTRY;
end;const NVME_SET_ATTRIBUTES_ENTRY = extern struct {
Identifier: u16,
ENDGID: u16,
Reserved1: u32,
Random4KBReadTypical: u32,
OptimalWriteSize: u32,
TotalCapacity: [16]u8,
UnallocatedCapacity: [16]u8,
Reserved2: [80]u8,
};
const NVM_SET_LIST = extern struct {
IdentifierCount: u8,
Reserved: [127]u8,
Entry: [1]NVME_SET_ATTRIBUTES_ENTRY,
};type
NVME_SET_ATTRIBUTES_ENTRY {.bycopy.} = object
Identifier: uint16
ENDGID: uint16
Reserved1: uint32
Random4KBReadTypical: uint32
OptimalWriteSize: uint32
TotalCapacity: array[16, uint8]
UnallocatedCapacity: array[16, uint8]
Reserved2: array[80, uint8]
NVM_SET_LIST {.bycopy.} = object
IdentifierCount: uint8
Reserved: array[127, uint8]
Entry: array[1, NVME_SET_ATTRIBUTES_ENTRY]struct NVME_SET_ATTRIBUTES_ENTRY
{
ushort Identifier;
ushort ENDGID;
uint Reserved1;
uint Random4KBReadTypical;
uint OptimalWriteSize;
ubyte[16] TotalCapacity;
ubyte[16] UnallocatedCapacity;
ubyte[80] Reserved2;
}
struct NVM_SET_LIST
{
ubyte IdentifierCount;
ubyte[127] Reserved;
NVME_SET_ATTRIBUTES_ENTRY[1] Entry;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVM_SET_LIST サイズ: 256 バイト(x64)
dim st, 64 ; 4byte整数×64(構造体サイズ 256 / 4 切り上げ)
; IdentifierCount : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; Reserved : BYTE (+1, 127byte) varptr(st)+1 を基点に操作(127byte:入れ子/配列)
; Entry : NVME_SET_ATTRIBUTES_ENTRY (+128, 128byte) varptr(st)+128 を基点に操作(128byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NVME_SET_ATTRIBUTES_ENTRY
#field short Identifier
#field short ENDGID
#field int Reserved1
#field int Random4KBReadTypical
#field int OptimalWriteSize
#field byte TotalCapacity 16
#field byte UnallocatedCapacity 16
#field byte Reserved2 80
#endstruct
#defstruct global NVM_SET_LIST
#field byte IdentifierCount
#field byte Reserved 127
#field NVME_SET_ATTRIBUTES_ENTRY Entry 1
#endstruct
stdim st, NVM_SET_LIST ; NSTRUCT 変数を確保
st->IdentifierCount = 100
mes "IdentifierCount=" + st->IdentifierCount