ホーム › Storage.Nvme › NVME_POWER_STATE_DESC
NVME_POWER_STATE_DESC
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| MP | WORD | 2 | +0 | +0 | 最大電力(Maximum Power)。MPSビットの単位(0.01Wまたは0.0001W)で表す。 |
| Reserved0 | BYTE | 1 | +2 | +2 | 予約領域。未使用。 |
| _bitfield1 | BYTE | 1 | +3 | +3 | 最大電力単位スケール(MXPS)と非動作状態(NOPS)のビットを格納する。 |
| ENLAT | DWORD | 4 | +4 | +4 | この電源状態への遷移(Entry)に要する最大レイテンシ(マイクロ秒)。 |
| EXLAT | DWORD | 4 | +8 | +8 | この電源状態からの遷移(Exit)に要する最大レイテンシ(マイクロ秒)。 |
| _bitfield2 | BYTE | 1 | +12 | +12 | 相対読み取りスループット(RRT)を格納するビットフィールド。 |
| _bitfield3 | BYTE | 1 | +13 | +13 | 相対読み取りレイテンシ(RRL)を格納するビットフィールド。 |
| _bitfield4 | BYTE | 1 | +14 | +14 | 相対書き込みスループット(RWT)を格納するビットフィールド。 |
| _bitfield5 | BYTE | 1 | +15 | +15 | 相対書き込みレイテンシ(RWL)を格納するビットフィールド。 |
| IDLP | WORD | 2 | +16 | +16 | アイドル時消費電力(Idle Power)。 |
| _bitfield6 | BYTE | 1 | +18 | +18 | アイドル電力スケール(IPS)を格納するビットフィールド。 |
| Reserved7 | BYTE | 1 | +19 | +19 | 予約領域。未使用。 |
| ACTP | WORD | 2 | +20 | +20 | アクティブ時消費電力(Active Power)。 |
| _bitfield7 | BYTE | 1 | +22 | +22 | アクティブ電力ワークロード(APW)とスケール(APS)を格納するビットフィールド。 |
| Reserved9 | BYTE | 9 | +23 | +23 | 予約領域。未使用。 |
各言語での定義
#include <windows.h>
// NVME_POWER_STATE_DESC (x64 32 / x86 32 バイト)
typedef struct NVME_POWER_STATE_DESC {
WORD MP;
BYTE Reserved0;
BYTE _bitfield1;
DWORD ENLAT;
DWORD EXLAT;
BYTE _bitfield2;
BYTE _bitfield3;
BYTE _bitfield4;
BYTE _bitfield5;
WORD IDLP;
BYTE _bitfield6;
BYTE Reserved7;
WORD ACTP;
BYTE _bitfield7;
BYTE Reserved9[9];
} NVME_POWER_STATE_DESC;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_POWER_STATE_DESC
{
public ushort MP;
public byte Reserved0;
public byte _bitfield1;
public uint ENLAT;
public uint EXLAT;
public byte _bitfield2;
public byte _bitfield3;
public byte _bitfield4;
public byte _bitfield5;
public ushort IDLP;
public byte _bitfield6;
public byte Reserved7;
public ushort ACTP;
public byte _bitfield7;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)] public byte[] Reserved9;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_POWER_STATE_DESC
Public MP As UShort
Public Reserved0 As Byte
Public _bitfield1 As Byte
Public ENLAT As UInteger
Public EXLAT As UInteger
Public _bitfield2 As Byte
Public _bitfield3 As Byte
Public _bitfield4 As Byte
Public _bitfield5 As Byte
Public IDLP As UShort
Public _bitfield6 As Byte
Public Reserved7 As Byte
Public ACTP As UShort
Public _bitfield7 As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=9)> Public Reserved9() As Byte
End Structureimport ctypes
from ctypes import wintypes
class NVME_POWER_STATE_DESC(ctypes.Structure):
_fields_ = [
("MP", ctypes.c_ushort),
("Reserved0", ctypes.c_ubyte),
("_bitfield1", ctypes.c_ubyte),
("ENLAT", wintypes.DWORD),
("EXLAT", wintypes.DWORD),
("_bitfield2", ctypes.c_ubyte),
("_bitfield3", ctypes.c_ubyte),
("_bitfield4", ctypes.c_ubyte),
("_bitfield5", ctypes.c_ubyte),
("IDLP", ctypes.c_ushort),
("_bitfield6", ctypes.c_ubyte),
("Reserved7", ctypes.c_ubyte),
("ACTP", ctypes.c_ushort),
("_bitfield7", ctypes.c_ubyte),
("Reserved9", ctypes.c_ubyte * 9),
]#[repr(C)]
pub struct NVME_POWER_STATE_DESC {
pub MP: u16,
pub Reserved0: u8,
pub _bitfield1: u8,
pub ENLAT: u32,
pub EXLAT: u32,
pub _bitfield2: u8,
pub _bitfield3: u8,
pub _bitfield4: u8,
pub _bitfield5: u8,
pub IDLP: u16,
pub _bitfield6: u8,
pub Reserved7: u8,
pub ACTP: u16,
pub _bitfield7: u8,
pub Reserved9: [u8; 9],
}import "golang.org/x/sys/windows"
type NVME_POWER_STATE_DESC struct {
MP uint16
Reserved0 byte
_bitfield1 byte
ENLAT uint32
EXLAT uint32
_bitfield2 byte
_bitfield3 byte
_bitfield4 byte
_bitfield5 byte
IDLP uint16
_bitfield6 byte
Reserved7 byte
ACTP uint16
_bitfield7 byte
Reserved9 [9]byte
}type
NVME_POWER_STATE_DESC = record
MP: Word;
Reserved0: Byte;
_bitfield1: Byte;
ENLAT: DWORD;
EXLAT: DWORD;
_bitfield2: Byte;
_bitfield3: Byte;
_bitfield4: Byte;
_bitfield5: Byte;
IDLP: Word;
_bitfield6: Byte;
Reserved7: Byte;
ACTP: Word;
_bitfield7: Byte;
Reserved9: array[0..8] of Byte;
end;const NVME_POWER_STATE_DESC = extern struct {
MP: u16,
Reserved0: u8,
_bitfield1: u8,
ENLAT: u32,
EXLAT: u32,
_bitfield2: u8,
_bitfield3: u8,
_bitfield4: u8,
_bitfield5: u8,
IDLP: u16,
_bitfield6: u8,
Reserved7: u8,
ACTP: u16,
_bitfield7: u8,
Reserved9: [9]u8,
};type
NVME_POWER_STATE_DESC {.bycopy.} = object
MP: uint16
Reserved0: uint8
_bitfield1: uint8
ENLAT: uint32
EXLAT: uint32
_bitfield2: uint8
_bitfield3: uint8
_bitfield4: uint8
_bitfield5: uint8
IDLP: uint16
_bitfield6: uint8
Reserved7: uint8
ACTP: uint16
_bitfield7: uint8
Reserved9: array[9, uint8]struct NVME_POWER_STATE_DESC
{
ushort MP;
ubyte Reserved0;
ubyte _bitfield1;
uint ENLAT;
uint EXLAT;
ubyte _bitfield2;
ubyte _bitfield3;
ubyte _bitfield4;
ubyte _bitfield5;
ushort IDLP;
ubyte _bitfield6;
ubyte Reserved7;
ushort ACTP;
ubyte _bitfield7;
ubyte[9] Reserved9;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_POWER_STATE_DESC サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; MP : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Reserved0 : BYTE (+2, 1byte) poke st,2,値 / 値 = peek(st,2)
; _bitfield1 : BYTE (+3, 1byte) poke st,3,値 / 値 = peek(st,3)
; ENLAT : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; EXLAT : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; _bitfield2 : BYTE (+12, 1byte) poke st,12,値 / 値 = peek(st,12)
; _bitfield3 : BYTE (+13, 1byte) poke st,13,値 / 値 = peek(st,13)
; _bitfield4 : BYTE (+14, 1byte) poke st,14,値 / 値 = peek(st,14)
; _bitfield5 : BYTE (+15, 1byte) poke st,15,値 / 値 = peek(st,15)
; IDLP : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; _bitfield6 : BYTE (+18, 1byte) poke st,18,値 / 値 = peek(st,18)
; Reserved7 : BYTE (+19, 1byte) poke st,19,値 / 値 = peek(st,19)
; ACTP : WORD (+20, 2byte) wpoke st,20,値 / 値 = wpeek(st,20)
; _bitfield7 : BYTE (+22, 1byte) poke st,22,値 / 値 = peek(st,22)
; Reserved9 : BYTE (+23, 9byte) varptr(st)+23 を基点に操作(9byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NVME_POWER_STATE_DESC
#field short MP
#field byte Reserved0
#field byte _bitfield1
#field int ENLAT
#field int EXLAT
#field byte _bitfield2
#field byte _bitfield3
#field byte _bitfield4
#field byte _bitfield5
#field short IDLP
#field byte _bitfield6
#field byte Reserved7
#field short ACTP
#field byte _bitfield7
#field byte Reserved9 9
#endstruct
stdim st, NVME_POWER_STATE_DESC ; NSTRUCT 変数を確保
st->MP = 100
mes "MP=" + st->MP