Win32 API 日本語リファレンス
ホームSystem.Ioctl › IDEREGS

IDEREGS

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

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

フィールド

フィールドサイズx64x86説明
bFeaturesRegBYTE1+0+0IDEのフィーチャーレジスタ値。
bSectorCountRegBYTE1+1+1IDEのセクタ数レジスタ値。
bSectorNumberRegBYTE1+2+2IDEのセクタ番号レジスタ値。
bCylLowRegBYTE1+3+3IDEのシリンダ下位レジスタ値。
bCylHighRegBYTE1+4+4IDEのシリンダ上位レジスタ値。
bDriveHeadRegBYTE1+5+5IDEのドライブ/ヘッドレジスタ値。
bCommandRegBYTE1+6+6IDEのコマンドレジスタ値。
bReservedBYTE1+7+7予約領域。ゼロを設定する。

各言語での定義

#include <windows.h>

// IDEREGS  (x64 8 / x86 8 バイト)
typedef struct IDEREGS {
    BYTE bFeaturesReg;
    BYTE bSectorCountReg;
    BYTE bSectorNumberReg;
    BYTE bCylLowReg;
    BYTE bCylHighReg;
    BYTE bDriveHeadReg;
    BYTE bCommandReg;
    BYTE bReserved;
} IDEREGS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IDEREGS
{
    public byte bFeaturesReg;
    public byte bSectorCountReg;
    public byte bSectorNumberReg;
    public byte bCylLowReg;
    public byte bCylHighReg;
    public byte bDriveHeadReg;
    public byte bCommandReg;
    public byte bReserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IDEREGS
    Public bFeaturesReg As Byte
    Public bSectorCountReg As Byte
    Public bSectorNumberReg As Byte
    Public bCylLowReg As Byte
    Public bCylHighReg As Byte
    Public bDriveHeadReg As Byte
    Public bCommandReg As Byte
    Public bReserved As Byte
End Structure
import ctypes
from ctypes import wintypes

class IDEREGS(ctypes.Structure):
    _fields_ = [
        ("bFeaturesReg", ctypes.c_ubyte),
        ("bSectorCountReg", ctypes.c_ubyte),
        ("bSectorNumberReg", ctypes.c_ubyte),
        ("bCylLowReg", ctypes.c_ubyte),
        ("bCylHighReg", ctypes.c_ubyte),
        ("bDriveHeadReg", ctypes.c_ubyte),
        ("bCommandReg", ctypes.c_ubyte),
        ("bReserved", ctypes.c_ubyte),
    ]
#[repr(C)]
pub struct IDEREGS {
    pub bFeaturesReg: u8,
    pub bSectorCountReg: u8,
    pub bSectorNumberReg: u8,
    pub bCylLowReg: u8,
    pub bCylHighReg: u8,
    pub bDriveHeadReg: u8,
    pub bCommandReg: u8,
    pub bReserved: u8,
}
import "golang.org/x/sys/windows"

type IDEREGS struct {
	bFeaturesReg byte
	bSectorCountReg byte
	bSectorNumberReg byte
	bCylLowReg byte
	bCylHighReg byte
	bDriveHeadReg byte
	bCommandReg byte
	bReserved byte
}
type
  IDEREGS = record
    bFeaturesReg: Byte;
    bSectorCountReg: Byte;
    bSectorNumberReg: Byte;
    bCylLowReg: Byte;
    bCylHighReg: Byte;
    bDriveHeadReg: Byte;
    bCommandReg: Byte;
    bReserved: Byte;
  end;
const IDEREGS = extern struct {
    bFeaturesReg: u8,
    bSectorCountReg: u8,
    bSectorNumberReg: u8,
    bCylLowReg: u8,
    bCylHighReg: u8,
    bDriveHeadReg: u8,
    bCommandReg: u8,
    bReserved: u8,
};
type
  IDEREGS {.bycopy.} = object
    bFeaturesReg: uint8
    bSectorCountReg: uint8
    bSectorNumberReg: uint8
    bCylLowReg: uint8
    bCylHighReg: uint8
    bDriveHeadReg: uint8
    bCommandReg: uint8
    bReserved: uint8
struct IDEREGS
{
    ubyte bFeaturesReg;
    ubyte bSectorCountReg;
    ubyte bSectorNumberReg;
    ubyte bCylLowReg;
    ubyte bCylHighReg;
    ubyte bDriveHeadReg;
    ubyte bCommandReg;
    ubyte bReserved;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IDEREGS サイズ: 8 バイト(x64)
dim st, 2    ; 4byte整数×2(構造体サイズ 8 / 4 切り上げ)
; bFeaturesReg : BYTE (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; bSectorCountReg : BYTE (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; bSectorNumberReg : BYTE (+2, 1byte)  poke st,2,値  /  値 = peek(st,2)
; bCylLowReg : BYTE (+3, 1byte)  poke st,3,値  /  値 = peek(st,3)
; bCylHighReg : BYTE (+4, 1byte)  poke st,4,値  /  値 = peek(st,4)
; bDriveHeadReg : BYTE (+5, 1byte)  poke st,5,値  /  値 = peek(st,5)
; bCommandReg : BYTE (+6, 1byte)  poke st,6,値  /  値 = peek(st,6)
; bReserved : BYTE (+7, 1byte)  poke st,7,値  /  値 = peek(st,7)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IDEREGS
    #field byte bFeaturesReg
    #field byte bSectorCountReg
    #field byte bSectorNumberReg
    #field byte bCylLowReg
    #field byte bCylHighReg
    #field byte bDriveHeadReg
    #field byte bCommandReg
    #field byte bReserved
#endstruct

stdim st, IDEREGS        ; NSTRUCT 変数を確保
st->bFeaturesReg = 100
mes "bFeaturesReg=" + st->bFeaturesReg