Win32 API 日本語リファレンス
ホームStorage.Nvme › NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE

NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE

構造体
サイズx64: 48 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
HeaderNVME_RESERVATION_REPORT_STATUS_HEADER24+0+0予約状態の世代やタイプなどを格納するヘッダ構造体である。
RegisteredControllersDataNVME_REGISTERED_CONTROLLER_DATA24+24+24登録済みコントローラの予約データ配列の先頭要素である。

各言語での定義

#include <windows.h>

// NVME_RESERVATION_REPORT_STATUS_HEADER  (x64 24 / x86 24 バイト)
#pragma pack(push, 1)
typedef struct NVME_RESERVATION_REPORT_STATUS_HEADER {
    DWORD GEN;
    BYTE RTYPE;
    WORD REGCTL;
    BYTE Reserved[2];
    BYTE PTPLS;
    BYTE Reserved1[14];
} NVME_RESERVATION_REPORT_STATUS_HEADER;
#pragma pack(pop)

// NVME_REGISTERED_CONTROLLER_DATA  (x64 24 / x86 24 バイト)
typedef struct NVME_REGISTERED_CONTROLLER_DATA {
    WORD CNTLID;
    _RCSTS_e__Struct RCSTS;
    BYTE Reserved[5];
    BYTE HOSTID[8];
    ULONGLONG RKEY;
} NVME_REGISTERED_CONTROLLER_DATA;

// NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE  (x64 48 / x86 48 バイト)
typedef struct NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE {
    NVME_RESERVATION_REPORT_STATUS_HEADER Header;
    NVME_REGISTERED_CONTROLLER_DATA RegisteredControllersData[1];
} NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct NVME_RESERVATION_REPORT_STATUS_HEADER
{
    public uint GEN;
    public byte RTYPE;
    public ushort REGCTL;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] Reserved;
    public byte PTPLS;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] public byte[] Reserved1;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_REGISTERED_CONTROLLER_DATA
{
    public ushort CNTLID;
    public _RCSTS_e__Struct RCSTS;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public byte[] Reserved;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] HOSTID;
    public ulong RKEY;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE
{
    public NVME_RESERVATION_REPORT_STATUS_HEADER Header;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public NVME_REGISTERED_CONTROLLER_DATA[] RegisteredControllersData;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure NVME_RESERVATION_REPORT_STATUS_HEADER
    Public GEN As UInteger
    Public RTYPE As Byte
    Public REGCTL As UShort
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public Reserved() As Byte
    Public PTPLS As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=14)> Public Reserved1() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_REGISTERED_CONTROLLER_DATA
    Public CNTLID As UShort
    Public RCSTS As _RCSTS_e__Struct
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=5)> Public Reserved() As Byte
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public HOSTID() As Byte
    Public RKEY As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE
    Public Header As NVME_RESERVATION_REPORT_STATUS_HEADER
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public RegisteredControllersData() As NVME_REGISTERED_CONTROLLER_DATA
End Structure
import ctypes
from ctypes import wintypes

class NVME_RESERVATION_REPORT_STATUS_HEADER(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("GEN", wintypes.DWORD),
        ("RTYPE", ctypes.c_ubyte),
        ("REGCTL", ctypes.c_ushort),
        ("Reserved", ctypes.c_ubyte * 2),
        ("PTPLS", ctypes.c_ubyte),
        ("Reserved1", ctypes.c_ubyte * 14),
    ]

class NVME_REGISTERED_CONTROLLER_DATA(ctypes.Structure):
    _fields_ = [
        ("CNTLID", ctypes.c_ushort),
        ("RCSTS", _RCSTS_e__Struct),
        ("Reserved", ctypes.c_ubyte * 5),
        ("HOSTID", ctypes.c_ubyte * 8),
        ("RKEY", ctypes.c_ulonglong),
    ]

class NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE(ctypes.Structure):
    _fields_ = [
        ("Header", NVME_RESERVATION_REPORT_STATUS_HEADER),
        ("RegisteredControllersData", NVME_REGISTERED_CONTROLLER_DATA * 1),
    ]
#[repr(C, packed(1))]
pub struct NVME_RESERVATION_REPORT_STATUS_HEADER {
    pub GEN: u32,
    pub RTYPE: u8,
    pub REGCTL: u16,
    pub Reserved: [u8; 2],
    pub PTPLS: u8,
    pub Reserved1: [u8; 14],
}

#[repr(C)]
pub struct NVME_REGISTERED_CONTROLLER_DATA {
    pub CNTLID: u16,
    pub RCSTS: _RCSTS_e__Struct,
    pub Reserved: [u8; 5],
    pub HOSTID: [u8; 8],
    pub RKEY: u64,
}

#[repr(C)]
pub struct NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE {
    pub Header: NVME_RESERVATION_REPORT_STATUS_HEADER,
    pub RegisteredControllersData: [NVME_REGISTERED_CONTROLLER_DATA; 1],
}
import "golang.org/x/sys/windows"

type NVME_RESERVATION_REPORT_STATUS_HEADER struct {
	GEN uint32
	RTYPE byte
	REGCTL uint16
	Reserved [2]byte
	PTPLS byte
	Reserved1 [14]byte
}

type NVME_REGISTERED_CONTROLLER_DATA struct {
	CNTLID uint16
	RCSTS _RCSTS_e__Struct
	Reserved [5]byte
	HOSTID [8]byte
	RKEY uint64
}

type NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE struct {
	Header NVME_RESERVATION_REPORT_STATUS_HEADER
	RegisteredControllersData [1]NVME_REGISTERED_CONTROLLER_DATA
}
type
  NVME_RESERVATION_REPORT_STATUS_HEADER = packed record
    GEN: DWORD;
    RTYPE: Byte;
    REGCTL: Word;
    Reserved: array[0..1] of Byte;
    PTPLS: Byte;
    Reserved1: array[0..13] of Byte;
  end;

  NVME_REGISTERED_CONTROLLER_DATA = record
    CNTLID: Word;
    RCSTS: _RCSTS_e__Struct;
    Reserved: array[0..4] of Byte;
    HOSTID: array[0..7] of Byte;
    RKEY: UInt64;
  end;

  NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE = record
    Header: NVME_RESERVATION_REPORT_STATUS_HEADER;
    RegisteredControllersData: array[0..0] of NVME_REGISTERED_CONTROLLER_DATA;
  end;
const NVME_RESERVATION_REPORT_STATUS_HEADER = extern struct {
    GEN: u32,
    RTYPE: u8,
    REGCTL: u16,
    Reserved: [2]u8,
    PTPLS: u8,
    Reserved1: [14]u8,
};

const NVME_REGISTERED_CONTROLLER_DATA = extern struct {
    CNTLID: u16,
    RCSTS: _RCSTS_e__Struct,
    Reserved: [5]u8,
    HOSTID: [8]u8,
    RKEY: u64,
};

const NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE = extern struct {
    Header: NVME_RESERVATION_REPORT_STATUS_HEADER,
    RegisteredControllersData: [1]NVME_REGISTERED_CONTROLLER_DATA,
};
type
  NVME_RESERVATION_REPORT_STATUS_HEADER {.packed.} = object
    GEN: uint32
    RTYPE: uint8
    REGCTL: uint16
    Reserved: array[2, uint8]
    PTPLS: uint8
    Reserved1: array[14, uint8]

  NVME_REGISTERED_CONTROLLER_DATA {.bycopy.} = object
    CNTLID: uint16
    RCSTS: _RCSTS_e__Struct
    Reserved: array[5, uint8]
    HOSTID: array[8, uint8]
    RKEY: uint64

  NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE {.bycopy.} = object
    Header: NVME_RESERVATION_REPORT_STATUS_HEADER
    RegisteredControllersData: array[1, NVME_REGISTERED_CONTROLLER_DATA]
align(1)
struct NVME_RESERVATION_REPORT_STATUS_HEADER
{
    uint GEN;
    ubyte RTYPE;
    ushort REGCTL;
    ubyte[2] Reserved;
    ubyte PTPLS;
    ubyte[14] Reserved1;
}

struct NVME_REGISTERED_CONTROLLER_DATA
{
    ushort CNTLID;
    _RCSTS_e__Struct RCSTS;
    ubyte[5] Reserved;
    ubyte[8] HOSTID;
    ulong RKEY;
}

struct NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE
{
    NVME_RESERVATION_REPORT_STATUS_HEADER Header;
    NVME_REGISTERED_CONTROLLER_DATA[1] RegisteredControllersData;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Header : NVME_RESERVATION_REPORT_STATUS_HEADER (+0, 24byte)  varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; RegisteredControllersData : NVME_REGISTERED_CONTROLLER_DATA (+24, 24byte)  varptr(st)+24 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NVME_RESERVATION_REPORT_STATUS_HEADER, pack=1
    #field int GEN
    #field byte RTYPE
    #field short REGCTL
    #field byte Reserved 2
    #field byte PTPLS
    #field byte Reserved1 14
#endstruct

#defstruct global NVME_REGISTERED_CONTROLLER_DATA
    #field short CNTLID
    #field _RCSTS_e__Struct RCSTS
    #field byte Reserved 5
    #field byte HOSTID 8
    #field int64 RKEY
#endstruct

#defstruct global NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE
    #field NVME_RESERVATION_REPORT_STATUS_HEADER Header
    #field NVME_REGISTERED_CONTROLLER_DATA RegisteredControllersData 1
#endstruct

stdim st, NVME_RESERVATION_REPORT_STATUS_DATA_STRUCTURE        ; NSTRUCT 変数を確保