"""
Named constants for commonly used hex values to replace magic numbers.
This reduces duplication and makes the code more maintainable.
"""

# Common hex strings
HEX_ZERO_BYTE = "00"
HEX_ZERO_WORD = "0000"
HEX_ZERO_DWORD = "00000000"
HEX_FULL_BYTE = "ff"
HEX_FULL_WORD = "ffff"
HEX_FULL_DWORD = "ffffffff"

# PCI Capability IDs (as hex values)
CAP_ID_POWER_MGMT = 0x01
CAP_ID_AGP = 0x02
CAP_ID_VPD = 0x03
CAP_ID_SLOT_ID = 0x04
CAP_ID_MSI = 0x05
CAP_ID_COMPACT_PCI = 0x06
CAP_ID_PCIX = 0x07
CAP_ID_HYPERTRANSPORT = 0x08
CAP_ID_VENDOR_SPECIFIC = 0x09
CAP_ID_DEBUG_PORT = 0x0A
CAP_ID_RESOURCE_CTRL = 0x0B
CAP_ID_HOTPLUG = 0x0C
CAP_ID_BRIDGE_SUBSYS_ID = 0x0D
CAP_ID_AGP8X = 0x0E
CAP_ID_SECURE_DEVICE = 0x0F
CAP_ID_PCIE = 0x10
CAP_ID_MSIX = 0x11
CAP_ID_SATA = 0x12
CAP_ID_ADVANCED_FEATURES = 0x13
CAP_ID_ENHANCED_ALLOCATION = 0x14
CAP_ID_FLATTENING_PORTAL = 0x15

# Extended Capability IDs  
EXT_CAP_ID_AER = 0x0001
EXT_CAP_ID_VIRTUAL_CHANNEL = 0x0002
EXT_CAP_ID_DSN = 0x0003
EXT_CAP_ID_POWER_BUDGETING = 0x0004
EXT_CAP_ID_ROOT_COMPLEX_LINK = 0x0005
EXT_CAP_ID_ROOT_COMPLEX_INTERNAL = 0x0006
EXT_CAP_ID_ROOT_COMPLEX_EVENTCOLL = 0x0007
EXT_CAP_ID_MFVC = 0x0008
EXT_CAP_ID_VC = 0x0009
EXT_CAP_ID_RCRB = 0x000A
EXT_CAP_ID_VENDOR_SPECIFIC = 0x000B
EXT_CAP_ID_CAC = 0x000C
EXT_CAP_ID_ACS = 0x000D
EXT_CAP_ID_ARI = 0x000E
EXT_CAP_ID_ATS = 0x000F
EXT_CAP_ID_SRIOV = 0x0010
EXT_CAP_ID_MRIOV = 0x0011
EXT_CAP_ID_MULTICAST = 0x0012
EXT_CAP_ID_PRI = 0x0013
EXT_CAP_ID_AMD_RESERVED = 0x0014
EXT_CAP_ID_RESIZABLE_BAR = 0x0015
EXT_CAP_ID_DPA = 0x0016
EXT_CAP_ID_TPH = 0x0017
EXT_CAP_ID_LTR = 0x0018
EXT_CAP_ID_SECONDARY_PCIE = 0x0019
EXT_CAP_ID_PMUX = 0x001A
EXT_CAP_ID_PASID = 0x001B
EXT_CAP_ID_LN_REQ = 0x001C
EXT_CAP_ID_DPC = 0x001D
EXT_CAP_ID_L1PM = 0x001E
EXT_CAP_ID_PTM = 0x001F

# Common PCI Class Codes
CLASS_CODE_STORAGE = "01"
CLASS_CODE_NETWORK = "02"
CLASS_CODE_DISPLAY = "03"
CLASS_CODE_MULTIMEDIA = "04"
CLASS_CODE_MEMORY = "05"
CLASS_CODE_BRIDGE = "06"
CLASS_CODE_COMMUNICATION = "07"
CLASS_CODE_SYSTEM = "08"
CLASS_CODE_INPUT = "09"
CLASS_CODE_DOCKING = "0a"
CLASS_CODE_PROCESSOR = "0b"
CLASS_CODE_SERIAL = "0c"
CLASS_CODE_WIRELESS = "0d"
CLASS_CODE_INTELLIGENT_IO = "0e"
CLASS_CODE_SATELLITE = "0f"
CLASS_CODE_ENCRYPTION = "10"
CLASS_CODE_SIGNAL_PROC = "11"

# Full class codes (6 hex chars)
CLASS_CODE_UNKNOWN = "000000"
CLASS_CODE_ETHERNET = "020000"
CLASS_CODE_VGA = "030000"
CLASS_CODE_AUDIO = "040100"
CLASS_CODE_USB = "0c0300"
CLASS_CODE_SATA = "010601"
CLASS_CODE_NVME = "010802"

# Common default values
DEFAULT_VENDOR_ID = "0000"
DEFAULT_DEVICE_ID = "0000"
DEFAULT_CLASS_CODE = CLASS_CODE_UNKNOWN
DEFAULT_REVISION_ID = "00"
DEFAULT_SUBSYS_ID = "0000"

# PCI Configuration Space Offsets
PCI_VENDOR_ID_OFFSET = 0x00
PCI_DEVICE_ID_OFFSET = 0x02
PCI_COMMAND_OFFSET = 0x04
PCI_STATUS_OFFSET = 0x06
PCI_REVISION_ID_OFFSET = 0x08
PCI_CLASS_CODE_OFFSET = 0x09
PCI_CACHE_LINE_OFFSET = 0x0C
PCI_LATENCY_TIMER_OFFSET = 0x0D
PCI_HEADER_TYPE_OFFSET = 0x0E
PCI_BIST_OFFSET = 0x0F
PCI_BAR0_OFFSET = 0x10
PCI_BAR1_OFFSET = 0x14
PCI_BAR2_OFFSET = 0x18
PCI_BAR3_OFFSET = 0x1C
PCI_BAR4_OFFSET = 0x20
PCI_BAR5_OFFSET = 0x24
PCI_CARDBUS_CIS_OFFSET = 0x28
PCI_SUBSYS_VENDOR_ID_OFFSET = 0x2C
PCI_SUBSYS_ID_OFFSET = 0x2E
PCI_EXPANSION_ROM_OFFSET = 0x30
PCI_CAP_PTR_OFFSET = 0x34
PCI_INTERRUPT_LINE_OFFSET = 0x3C
PCI_INTERRUPT_PIN_OFFSET = 0x3D
PCI_MIN_GNT_OFFSET = 0x3E
PCI_MAX_LAT_OFFSET = 0x3F

# Common capability offsets
CAP_OFFSET_PM = 0x40
CAP_OFFSET_MSI = 0x48  
CAP_OFFSET_MSIX = 0x50
CAP_OFFSET_PCIE = 0x60
CAP_OFFSET_AER = 0xA0

# Common bit patterns  
COMMAND_MEMORY_ENABLE = 0x0002
COMMAND_MASTER_ENABLE = 0x0004
COMMAND_SPECIAL_CYCLES = 0x0008
COMMAND_MWI_ENABLE = 0x0010
COMMAND_VGA_PALETTE_SNOOP = 0x0020
COMMAND_PARITY_ERROR_RESPONSE = 0x0040
COMMAND_SERR_ENABLE = 0x0100
COMMAND_FAST_B2B_ENABLE = 0x0200
COMMAND_INTERRUPT_DISABLE = 0x0400

STATUS_INTERRUPT = 0x0008
STATUS_CAPABILITIES_LIST = 0x0010
STATUS_66MHZ_CAPABLE = 0x0020
STATUS_FAST_B2B_CAPABLE = 0x0080
STATUS_MASTER_DATA_PARITY_ERROR = 0x0100
STATUS_DEVSEL_MEDIUM = 0x0200
STATUS_DEVSEL_SLOW = 0x0400
STATUS_SIG_TARGET_ABORT = 0x0800
STATUS_REC_TARGET_ABORT = 0x1000
STATUS_REC_MASTER_ABORT = 0x2000
STATUS_SIG_SYSTEM_ERROR = 0x4000
STATUS_DETECTED_PARITY_ERROR = 0x8000

# BAR type bits
BAR_TYPE_IO = 0x01
BAR_TYPE_64BIT = 0x04
BAR_TYPE_PREFETCHABLE = 0x08

# Common sizes
SIZE_4KB = 0x1000
SIZE_64KB = 0x10000
SIZE_1MB = 0x100000
SIZE_16MB = 0x1000000
SIZE_256MB = 0x10000000