From 9d227ccb45612c6f8a2a488d9d2ca90784489afc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 20:31:41 +0200 Subject: Merging upstream version 1:3.12.0. Signed-off-by: Daniel Baumann --- lib/aix-device.c | 22 ++++++++---------- lib/aos-expansion.c | 24 +++++++++----------- lib/configure | 3 +++ lib/darwin.c | 23 ++++++++----------- lib/dump.c | 24 +++++++++----------- lib/ecam.c | 59 +++++++++++++++++++++++++++++------------------ lib/fbsd-device.c | 23 ++++++++----------- lib/header.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/hurd.c | 24 +++++++++----------- lib/i386-io-windows.h | 5 ++-- lib/i386-ports.c | 44 +++++++++++++++-------------------- lib/mmio-ports.c | 46 ++++++++++++++++--------------------- lib/names-hwdb.c | 17 ++++++++------ lib/nbsd-libpci.c | 23 ++++++++----------- lib/obsd-device.c | 23 ++++++++----------- lib/pci.h | 20 ++++++++-------- lib/proc.c | 24 +++++++++----------- lib/sylixos-device.c | 23 ++++++++----------- lib/sysdep.h | 4 ++++ lib/sysfs.c | 30 ++++++++++++------------ lib/win32-cfgmgr32.c | 24 +++++++++----------- lib/win32-helpers.c | 7 +++++- lib/win32-kldbg.c | 22 ++++++++---------- lib/win32-sysdbg.c | 24 ++++++++------------ 24 files changed, 322 insertions(+), 279 deletions(-) (limited to 'lib') diff --git a/lib/aix-device.c b/lib/aix-device.c index 028d92a..ac95b81 100644 --- a/lib/aix-device.c +++ b/lib/aix-device.c @@ -260,17 +260,13 @@ aix_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_aix_device = { - "aix-device", - "AIX /dev/pci[0-n]", - NULL, - aix_detect, - aix_init, - aix_cleanup, - aix_scan, - pci_generic_fill_info, - aix_read, - aix_write, - NULL, /* read_vpd */ - NULL, /* dev_init */ - NULL /* dev_cleanup */ + .name = "aix-device", + .help = "AIX /dev/pci[0-n]", + .detect = aix_detect, + .init = aix_init, + .cleanup = aix_cleanup, + .scan = aix_scan, + .fill_info = pci_generic_fill_info, + .read = aix_read, + .write = aix_write, }; diff --git a/lib/aos-expansion.c b/lib/aos-expansion.c index 3e11f47..e36358e 100644 --- a/lib/aos-expansion.c +++ b/lib/aos-expansion.c @@ -221,17 +221,15 @@ aos_expansion_cleanup_dev(struct pci_dev *d) } struct pci_methods pm_aos_expansion = { - "aos-expansion", - "The Expansion.library on AmigaOS 4.x", - NULL, // config, called after allocation of pci_access, if assigned - aos_expansion_detect, // detect, mandatory because called without check - aos_expansion_init, // init, called once access chosen, eventually after detect - aos_expansion_cleanup, // cleanup, called at the end - aos_expansion_scan, - pci_generic_fill_info, - aos_expansion_read, - aos_expansion_write, - NULL, // read_vpd - aos_expansion_init_dev, - aos_expansion_cleanup_dev, + .name = "aos-expansion", + .help = "The Expansion.library on AmigaOS 4.x", + .detect = aos_expansion_detect, // detect, mandatory because called without check + .init = aos_expansion_init, // init, called once access chosen, eventually after detect + .cleanup = aos_expansion_cleanup, // cleanup, called at the end + .scan = aos_expansion_scan, + .fill_info = pci_generic_fill_info, + .read = aos_expansion_read, + .write = aos_expansion_write, + .init_dev = aos_expansion_init_dev, + .cleanup_dev = aos_expansion_cleanup_dev, }; diff --git a/lib/configure b/lib/configure index 3df057a..d02160b 100755 --- a/lib/configure +++ b/lib/configure @@ -208,6 +208,9 @@ case $sys in echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/misc/mem"' echo >>$c '#define PCI_PATH_ACPI_MCFG ""' echo >>$c '#define PCI_PATH_EFI_SYSTAB ""' + if [ "$sys" != "beos" ] ; then + LIBRESOLV=-lnetwork + fi ;; sylixos) echo >>$c '#define PCI_PATH_SYLIXOS_DEVICE "/proc/pci"' diff --git a/lib/darwin.c b/lib/darwin.c index 8ae9008..df5032e 100644 --- a/lib/darwin.c +++ b/lib/darwin.c @@ -197,17 +197,14 @@ darwin_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_darwin = { - "darwin", - "Darwin", - darwin_config, - darwin_detect, - darwin_init, - darwin_cleanup, - pci_generic_scan, - pci_generic_fill_info, - darwin_read, - darwin_write, - NULL, /* read_vpd */ - NULL, /* dev_init */ - NULL /* dev_cleanup */ + .name = "darwin", + .help = "Darwin", + .config = darwin_config, + .detect = darwin_detect, + .init = darwin_init, + .cleanup = darwin_cleanup, + .scan = pci_generic_scan, + .fill_info = pci_generic_fill_info, + .read = darwin_read, + .write = darwin_write, }; diff --git a/lib/dump.c b/lib/dump.c index 829071f..5f4ba2e 100644 --- a/lib/dump.c +++ b/lib/dump.c @@ -178,17 +178,15 @@ dump_cleanup_dev(struct pci_dev *d) } struct pci_methods pm_dump = { - "dump", - "Reading of register dumps (set the `dump.name' parameter)", - dump_config, - dump_detect, - dump_init, - dump_cleanup, - dump_scan, - pci_generic_fill_info, - dump_read, - dump_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - dump_cleanup_dev + .name = "dump", + .help = "Reading of register dumps (set the `dump.name' parameter)", + .config = dump_config, + .detect = dump_detect, + .init = dump_init, + .cleanup = dump_cleanup, + .scan = dump_scan, + .fill_info = pci_generic_fill_info, + .read = dump_read, + .write = dump_write, + .cleanup_dev = dump_cleanup_dev, }; diff --git a/lib/ecam.c b/lib/ecam.c index f088c0c..fdeec07 100644 --- a/lib/ecam.c +++ b/lib/ecam.c @@ -221,9 +221,11 @@ find_rsdp_address(struct pci_access *a, const char *efisystab, int use_bsd UNUSE #if defined(__amd64__) || defined(__i386__) struct ecam_access *eacc = a->backend_data; struct physmem *physmem = eacc->physmem; + long pagesize = eacc->pagesize; u64 rsdp_addr; u64 addr; void *map; + u64 ebda; #endif size_t len; FILE *f; @@ -305,23 +307,39 @@ find_rsdp_address(struct pci_access *a, const char *efisystab, int use_bsd UNUSE rsdp_addr = 0; /* Scan first kB of Extended BIOS Data Area */ - a->debug("scanning first kB of EBDA..."); - map = physmem_map(physmem, 0, 0x40E + 1024, 0); + a->debug("reading EBDA location from BDA..."); + map = physmem_map(physmem, 0, 0x40E + 2, 0); if (map != (void *)-1) { - for (addr = 0x40E; addr < 0x40E + 1024; addr += 16) + ebda = (u64)physmem_readw((unsigned char *)map + 0x40E) << 4; + if (physmem_unmap(physmem, map, 0x40E + 2) != 0) + a->debug("unmapping of BDA failed: %s...", strerror(errno)); + if (ebda >= 0x400) { - if (check_rsdp((struct acpi_rsdp *)((unsigned char *)map + addr))) + a->debug("scanning first kB of EBDA at 0x%" PCI_U64_FMT_X "...", ebda); + map = physmem_map(physmem, ebda & ~(pagesize-1), 1024 + (ebda & (pagesize-1)), 0); + if (map != (void *)-1) { - rsdp_addr = addr; - break; + for (addr = ebda & (pagesize-1); addr < (ebda & (pagesize-1)) + 1024; addr += 16) + { + if (check_rsdp((struct acpi_rsdp *)((unsigned char *)map + addr))) + { + rsdp_addr = (ebda & ~(pagesize-1)) + addr; + break; + } + } + if (physmem_unmap(physmem, map, 1024 + (ebda & (pagesize-1))) != 0) + a->debug("unmapping of EBDA failed: %s...", strerror(errno)); } + else + a->debug("mapping of EBDA failed: %s...", strerror(errno)); } - if (physmem_unmap(physmem, map, 0x40E + 1024) != 0) - a->debug("unmapping of EBDA failed: %s...", strerror(errno)); + else + a->debug("EBDA location 0x%" PCI_U64_FMT_X " is insane...", ebda); } else - a->debug("mapping of EBDA failed: %s...", strerror(errno)); + a->debug("mapping of BDA failed: %s...", strerror(errno)); + if (rsdp_addr) return rsdp_addr; @@ -1088,17 +1106,14 @@ ecam_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_ecam = { - "ecam", - "Raw memory mapped access using PCIe ECAM interface", - ecam_config, - ecam_detect, - ecam_init, - ecam_cleanup, - ecam_scan, - pci_generic_fill_info, - ecam_read, - ecam_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "ecam", + .help = "Raw memory mapped access using PCIe ECAM interface", + .config = ecam_config, + .detect = ecam_detect, + .init = ecam_init, + .cleanup = ecam_cleanup, + .scan = ecam_scan, + .fill_info = pci_generic_fill_info, + .read = ecam_read, + .write = ecam_write, }; diff --git a/lib/fbsd-device.c b/lib/fbsd-device.c index 2ea5e84..36857d6 100644 --- a/lib/fbsd-device.c +++ b/lib/fbsd-device.c @@ -350,17 +350,14 @@ fbsd_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_fbsd_device = { - "fbsd-device", - "FreeBSD /dev/pci device", - fbsd_config, - fbsd_detect, - fbsd_init, - fbsd_cleanup, - fbsd_scan, - fbsd_fill_info, - fbsd_read, - fbsd_write, - NULL, /* read_vpd */ - NULL, /* dev_init */ - NULL /* dev_cleanup */ + .name = "fbsd-device", + .help = "FreeBSD /dev/pci device", + .config = fbsd_config, + .detect = fbsd_detect, + .init = fbsd_init, + .cleanup = fbsd_cleanup, + .scan = fbsd_scan, + .fill_info = fbsd_fill_info, + .read = fbsd_read, + .write = fbsd_write, }; diff --git a/lib/header.h b/lib/header.h index 2cee94f..0b0ed9a 100644 --- a/lib/header.h +++ b/lib/header.h @@ -256,6 +256,7 @@ #define PCI_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Management */ #define PCI_EXT_CAP_ID_32GT 0x2a /* Physical Layer 32.0 GT/s */ #define PCI_EXT_CAP_ID_DOE 0x2e /* Data Object Exchange */ +#define PCI_EXT_CAP_ID_IDE 0x30 /* Integrity and Data Encryption */ /*** Definitions of capabilities ***/ @@ -776,6 +777,7 @@ #define PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */ #define PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */ #define PCI_EXP_DEVCAP_FLRESET 0x10000000 /* Function-Level Reset */ +#define PCI_EXP_DEVCAP_TEE_IO 0x40000000 /* TEE-IO Supported (TDISP) */ #define PCI_EXP_DEVCTL 0x8 /* Device Control */ #define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */ #define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */ @@ -1422,6 +1424,67 @@ #define PCI_LMR_PORT_STS_READY 0x1 /* Margining Ready */ #define PCI_LMR_PORT_STS_SOFT_READY 0x2 /* Margining Software Ready */ +/* Integrity and Data Encryption Extended Capability */ +#define PCI_IDE_CAP 0x4 +#define PCI_IDE_CAP_LINK_IDE_SUPP 0x1 /* Link IDE Stream Supported */ +#define PCI_IDE_CAP_SELECTIVE_IDE_SUPP 0x2 /* Selective IDE Streams Supported */ +#define PCI_IDE_CAP_FLOWTHROUGH_IDE_SUPP 0x4 /* Flow-Through IDE Stream Supported */ +#define PCI_IDE_CAP_PARTIAL_HEADER_ENC_SUPP 0x8 /* Partial Header Encryption Supported */ +#define PCI_IDE_CAP_AGGREGATION_SUPP 0x10 /* Aggregation Supported */ +#define PCI_IDE_CAP_PCRC_SUPP 0x20 /* PCRC Supported */ +#define PCI_IDE_CAP_IDE_KM_SUPP 0x40 /* IDE_KM Protocol Supported */ +#define PCI_IDE_CAP_ALG(x) (((x) >> 8) & 0x1f) /* Supported Algorithms */ +#define PCI_IDE_CAP_ALG_AES_GCM_256 0 /* AES-GCM 256 key size, 96b MAC */ +#define PCI_IDE_CAP_LINK_TC_NUM(x) (((x) >> 13) & 0x7) /* Number of TCs Supported for Link IDE */ +#define PCI_IDE_CAP_SELECTIVE_STREAMS_NUM(x) (((x) >> 16) & 0xff) /* Number of Selective IDE Streams Supported */ +#define PCI_IDE_CAP_TEE_LIMITED_SUPP 0x1000000 /* TEE-Limited Stream Supported */ +#define PCI_IDE_CTL 0x8 +#define PCI_IDE_CTL_FLOWTHROUGH_IDE 0x4 /* Flow-Through IDE Stream Enabled */ +#define PCI_IDE_LINK_STREAM 0xC +/* Link IDE Stream block, up to PCI_IDE_CAP_LINK_TC_NUM */ +/* Link IDE Stream Control Register */ +#define PCI_IDE_LINK_CTL_EN 0x1 /* Link IDE Stream Enable */ +#define PCI_IDE_LINK_CTL_TX_AGGR_NPR(x)(((x) >> 2) & 0x3) /* Tx Aggregation Mode NPR */ +#define PCI_IDE_LINK_CTL_TX_AGGR_PR(x) (((x) >> 4) & 0x3) /* Tx Aggregation Mode PR */ +#define PCI_IDE_LINK_CTL_TX_AGGR_CPL(x)(((x) >> 6) & 0x3) /* Tx Aggregation Mode CPL */ +#define PCI_IDE_LINK_CTL_PCRC_EN 0x100 /* PCRC Enable */ +#define PCI_IDE_LINK_CTL_PART_ENC(x) (((x) >> 10) & 0xf) /* Partial Header Encryption Mode */ +#define PCI_IDE_LINK_CTL_ALG(x) (((x) >> 14) & 0x1f) /* Selected Algorithm */ +#define PCI_IDE_LINK_CTL_TC(x) (((x) >> 19) & 0x7) /* Traffic Class */ +#define PCI_IDE_LINK_CTL_ID(x) (((x) >> 24) & 0xff) /* Stream ID */ +/* Link IDE Stream Status Register */ +#define PCI_IDE_LINK_STS_STATUS(x) ((x) & 0xf) /* Link IDE Stream State */ +#define PCI_IDE_LINK_STS_RECVD_INTEGRITY_CHECK 0x80000000 /* Received Integrity Check Fail Message */ +/* Selective IDE Stream block, up to PCI_IDE_CAP_SELECTIVE_STREAMS_NUM */ +/* Selective IDE Stream Capability Register */ +#define PCI_IDE_SEL_CAP_BLOCKS_NUM(x) ((x) & 0xf) /* Number of Address Association Register Blocks */ +/* Selective IDE Stream Control Register */ +#define PCI_IDE_SEL_CTL_EN 0x1 /* Selective IDE Stream Enable */ +#define PCI_IDE_SEL_CTL_TX_AGGR_NPR(x) (((x) >> 2) & 0x3) /* Tx Aggregation Mode NPR */ +#define PCI_IDE_SEL_CTL_TX_AGGR_PR(x) (((x) >> 4) & 0x3) /* Tx Aggregation Mode PR */ +#define PCI_IDE_SEL_CTL_TX_AGGR_CPL(x) (((x) >> 6) & 0x3) /* Tx Aggregation Mode CPL */ +#define PCI_IDE_SEL_CTL_PCRC_EN 0x100 /* PCRC Enable */ +#define PCI_IDE_SEL_CTL_PART_ENC(x) (((x) >> 10) & 0xf) /* Partial Header Encryption Mode */ +#define PCI_IDE_SEL_CTL_ALG(x) (((x) >> 14) & 0x1f) /* Selected Algorithm */ +#define PCI_IDE_SEL_CTL_TC(x) (((x) >> 19) & 0x7) /* Traffic Class */ +#define PCI_IDE_SEL_CTL_DEFAULT 0x400000 /* Default Stream */ +#define PCI_IDE_SEL_CTL_ID(x) (((x) >> 24) & 0xff) /* Stream ID */ +/* Selective IDE Stream Status Register */ +#define PCI_IDE_SEL_STS_STATUS(x) ((x) & 0xf) /* Selective IDE Stream State */ +#define PCI_IDE_SEL_STS_RECVD_INTEGRITY_CHECK 0x80000000 /* Received Integrity Check Fail Message */ +/* IDE RID Association Register 1 */ +#define PCI_IDE_SEL_RID_1_LIMIT(x) (((x) >> 8) & 0xffff) /* RID Limit */ +/* IDE RID Association Register 2 */ +#define PCI_IDE_SEL_RID_2_VALID 0x1 /* Valid */ +#define PCI_IDE_SEL_RID_2_BASE(x) (((x) >> 8) & 0xffff) /* RID Base */ +#define PCI_IDE_SEL_RID_2_SEG_BASE(x) (((x) >> 24) & 0xff) /* Segmeng Base */ +/* Selective IDE Address Association Register Block, up to PCI_IDE_SEL_CAP_BLOCKS_NUM */ +#define PCI_IDE_SEL_ADDR_1_VALID 0x1 /* Valid */ +#define PCI_IDE_SEL_ADDR_1_BASE_LOW(x) (((x) >> 8) & 0xfff) /* Memory Base Lower */ +#define PCI_IDE_SEL_ADDR_1_LIMIT_LOW(x)(((x) >> 20) & 0xfff) /* Memory Limit Lower */ +/* IDE Address Association Register 2 is "Memory Limit Upper" */ +/* IDE Address Association Register 3 is "Memory Base Upper" */ + /* * The PCI interface treats multi-function devices as independent * devices. The slot/function address of each device is encoded diff --git a/lib/hurd.c b/lib/hurd.c index 3e65fb8..84860a7 100644 --- a/lib/hurd.c +++ b/lib/hurd.c @@ -356,17 +356,15 @@ hurd_fill_info(struct pci_dev *d, unsigned int flags) } struct pci_methods pm_hurd = { - "hurd", - "Hurd access using RPCs", - NULL, /* config */ - hurd_detect, - hurd_init, - hurd_cleanup, - hurd_scan, - hurd_fill_info, - hurd_read, - hurd_write, - NULL, /* read_vpd */ - hurd_init_dev, - hurd_cleanup_dev + .name = "hurd", + .help = "Hurd access using RPCs", + .detect = hurd_detect, + .init = hurd_init, + .cleanup = hurd_cleanup, + .scan = hurd_scan, + .fill_info = hurd_fill_info, + .read = hurd_read, + .write = hurd_write, + .init_dev = hurd_init_dev, + .cleanup_dev = hurd_cleanup_dev }; diff --git a/lib/i386-io-windows.h b/lib/i386-io-windows.h index d2da452..8f8cffd 100644 --- a/lib/i386-io-windows.h +++ b/lib/i386-io-windows.h @@ -150,11 +150,12 @@ SetProcessUserModeIOPL(VOID) BOOL ret; /* - * Load ntdll.dll library with disabled critical-error-handler message box. + * Load ntdll.dll library with disabled critical-error-handler and + * file-not-found message box. * It means that NT kernel does not show unwanted GUI message box to user * when LoadLibrary() function fails. */ - prev_error_mode = win32_change_error_mode(SEM_FAILCRITICALERRORS); + prev_error_mode = win32_change_error_mode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); ntdll = LoadLibrary(TEXT("ntdll.dll")); win32_change_error_mode(prev_error_mode); if (!ntdll) diff --git a/lib/i386-ports.c b/lib/i386-ports.c index 5f8aea4..b9d863c 100644 --- a/lib/i386-ports.c +++ b/lib/i386-ports.c @@ -295,33 +295,25 @@ conf2_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_intel_conf1 = { - "intel-conf1", - "Raw I/O port access using Intel conf1 interface", - NULL, /* config */ - conf1_detect, - conf12_init, - conf12_cleanup, - pci_generic_scan, - pci_generic_fill_info, - conf1_read, - conf1_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "intel-conf1", + .help = "Raw I/O port access using Intel conf1 interface", + .detect = conf1_detect, + .init = conf12_init, + .cleanup = conf12_cleanup, + .scan = pci_generic_scan, + .fill_info = pci_generic_fill_info, + .read = conf1_read, + .write = conf1_write, }; struct pci_methods pm_intel_conf2 = { - "intel-conf2", - "Raw I/O port access using Intel conf2 interface", - NULL, /* config */ - conf2_detect, - conf12_init, - conf12_cleanup, - pci_generic_scan, - pci_generic_fill_info, - conf2_read, - conf2_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "intel-conf2", + .help = "Raw I/O port access using Intel conf2 interface", + .detect = conf2_detect, + .init = conf12_init, + .cleanup = conf12_cleanup, + .scan = pci_generic_scan, + .fill_info = pci_generic_fill_info, + .read = conf2_read, + .write = conf2_write, }; diff --git a/lib/mmio-ports.c b/lib/mmio-ports.c index cac8a7e..00a595a 100644 --- a/lib/mmio-ports.c +++ b/lib/mmio-ports.c @@ -400,33 +400,27 @@ conf1_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_mmio_conf1 = { - "mmio-conf1", - "Raw memory mapped I/O port access using Intel conf1 interface", - conf1_config, - conf1_detect, - conf1_init, - conf1_cleanup, - conf1_scan, - pci_generic_fill_info, - conf1_read, - conf1_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "mmio-conf1", + .help = "Raw memory mapped I/O port access using Intel conf1 interface", + .config = conf1_config, + .detect = conf1_detect, + .init = conf1_init, + .cleanup = conf1_cleanup, + .scan = conf1_scan, + .fill_info = pci_generic_fill_info, + .read = conf1_read, + .write = conf1_write, }; struct pci_methods pm_mmio_conf1_ext = { - "mmio-conf1-ext", - "Raw memory mapped I/O port access using Intel conf1 extended interface", - conf1_ext_config, - conf1_ext_detect, - conf1_init, - conf1_cleanup, - conf1_scan, - pci_generic_fill_info, - conf1_ext_read, - conf1_ext_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "mmio-conf1-ext", + .help = "Raw memory mapped I/O port access using Intel conf1 extended interface", + .config = conf1_ext_config, + .detect = conf1_ext_detect, + .init = conf1_init, + .cleanup = conf1_cleanup, + .scan = conf1_scan, + .fill_info = pci_generic_fill_info, + .read = conf1_ext_read, + .write = conf1_ext_write, }; diff --git a/lib/names-hwdb.c b/lib/names-hwdb.c index 71e7229..b1f6052 100644 --- a/lib/names-hwdb.c +++ b/lib/names-hwdb.c @@ -21,7 +21,7 @@ #include char * -pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4) +pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4 UNUSED) { char modalias[64]; const char *key = NULL; @@ -41,13 +41,16 @@ pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int key = "ID_MODEL_FROM_DATABASE"; break; case ID_SUBSYSTEM: - sprintf(modalias, "pci:v%08Xd%08Xsv%08Xsd%08X*", id1, id2, id3, id4); - key = "ID_MODEL_FROM_DATABASE"; - break; + /* + * There is no udev hwdb key which returns subsystem. Also note that query + * modalias "pci:v%08Xd%08Xsv%08Xsd%08X*" matches also hwdb device with + * modalias "pci:v%08Xd%08Xsv*sd*" (which is the default modalias), so + * there is no way to get information specific for the subsystem. + */ + return NULL; case ID_GEN_SUBSYSTEM: - sprintf(modalias, "pci:v*d*sv%08Xsd%08X*", id1, id2); - key = "ID_MODEL_FROM_DATABASE"; - break; + /* There is no udev hwdb key which returns generic subsystem. */ + return NULL; case ID_CLASS: sprintf(modalias, "pci:v*d*sv*sd*bc%02X*", id1); key = "ID_PCI_CLASS_FROM_DATABASE"; diff --git a/lib/nbsd-libpci.c b/lib/nbsd-libpci.c index 0f9f27b..e84ac6b 100644 --- a/lib/nbsd-libpci.c +++ b/lib/nbsd-libpci.c @@ -143,17 +143,14 @@ nbsd_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_nbsd_libpci = { - "nbsd-libpci", - "NetBSD libpci", - nbsd_config, - nbsd_detect, - nbsd_init, - nbsd_cleanup, - pci_generic_scan, - pci_generic_fill_info, - nbsd_read, - nbsd_write, - NULL, /* read_vpd */ - NULL, /* dev_init */ - NULL /* dev_cleanup */ + .name = "nbsd-libpci", + .help = "NetBSD libpci", + .config = nbsd_config, + .detect = nbsd_detect, + .init = nbsd_init, + .cleanup = nbsd_cleanup, + .scan = pci_generic_scan, + .fill_info = pci_generic_fill_info, + .read = nbsd_read, + .write = nbsd_write, }; diff --git a/lib/obsd-device.c b/lib/obsd-device.c index e2e7652..41f16ce 100644 --- a/lib/obsd-device.c +++ b/lib/obsd-device.c @@ -138,17 +138,14 @@ obsd_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_obsd_device = { - "obsd-device", - "/dev/pci on OpenBSD", - obsd_config, - obsd_detect, - obsd_init, - obsd_cleanup, - pci_generic_scan, - pci_generic_fill_info, - obsd_read, - obsd_write, - NULL, /* read_vpd */ - NULL, /* dev_init */ - NULL /* dev_cleanup */ + .name = "obsd-device", + .help = "/dev/pci on OpenBSD", + .config = obsd_config, + .detect = obsd_detect, + .init = obsd_init, + .cleanup = obsd_cleanup, + .scan = pci_generic_scan, + .fill_info = pci_generic_fill_info, + .read = obsd_read, + .write = obsd_write, }; diff --git a/lib/pci.h b/lib/pci.h index ae1333f..4b5f6c1 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -18,7 +18,7 @@ #include "header.h" #include "types.h" -#define PCI_LIB_VERSION 0x030b01 +#define PCI_LIB_VERSION 0x030c00 #ifndef PCI_ABI #define PCI_ABI @@ -210,23 +210,23 @@ int pci_write_block(struct pci_dev *, int pos, u8 *buf, int len) PCI_ABI; int pci_fill_info(struct pci_dev *, int flags) PCI_ABI; char *pci_get_string_property(struct pci_dev *d, u32 prop) PCI_ABI; -#define PCI_FILL_IDENT 0x0001 +#define PCI_FILL_IDENT 0x0001 /* vendor and device ID */ #define PCI_FILL_IRQ 0x0002 #define PCI_FILL_BASES 0x0004 #define PCI_FILL_ROM_BASE 0x0008 #define PCI_FILL_SIZES 0x0010 #define PCI_FILL_CLASS 0x0020 -#define PCI_FILL_CAPS 0x0040 -#define PCI_FILL_EXT_CAPS 0x0080 -#define PCI_FILL_PHYS_SLOT 0x0100 -#define PCI_FILL_MODULE_ALIAS 0x0200 -#define PCI_FILL_LABEL 0x0400 +#define PCI_FILL_CAPS 0x0040 /* capabilities */ +#define PCI_FILL_EXT_CAPS 0x0080 /* extended capabilities */ +#define PCI_FILL_PHYS_SLOT 0x0100 /* physical slot (string property) */ +#define PCI_FILL_MODULE_ALIAS 0x0200 /* Linux kernel module alias (string property) */ +#define PCI_FILL_LABEL 0x0400 /* (string property) */ #define PCI_FILL_NUMA_NODE 0x0800 #define PCI_FILL_IO_FLAGS 0x1000 -#define PCI_FILL_DT_NODE 0x2000 /* Device tree node */ -#define PCI_FILL_IOMMU_GROUP 0x4000 +#define PCI_FILL_DT_NODE 0x2000 /* Device tree node (string property) */ +#define PCI_FILL_IOMMU_GROUP 0x4000 /* (string property) */ #define PCI_FILL_BRIDGE_BASES 0x8000 -#define PCI_FILL_RESCAN 0x00010000 +#define PCI_FILL_RESCAN 0x00010000 /* force re-scan of cached properties */ #define PCI_FILL_CLASS_EXT 0x00020000 /* prog_if and rev_id */ #define PCI_FILL_SUBSYS 0x00040000 /* subsys_vendor_id and subsys_id */ #define PCI_FILL_PARENT 0x00080000 diff --git a/lib/proc.c b/lib/proc.c index 429cea6..deba651 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -214,17 +214,15 @@ proc_cleanup_dev(struct pci_dev *d) } struct pci_methods pm_linux_proc = { - "linux-proc", - "The proc file system on Linux", - proc_config, - proc_detect, - proc_init, - proc_cleanup, - proc_scan, - pci_generic_fill_info, - proc_read, - proc_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - proc_cleanup_dev + .name = "linux-proc", + .help = "The proc file system on Linux", + .config = proc_config, + .detect = proc_detect, + .init = proc_init, + .cleanup = proc_cleanup, + .scan = proc_scan, + .fill_info = pci_generic_fill_info, + .read = proc_read, + .write = proc_write, + .cleanup_dev = proc_cleanup_dev, }; diff --git a/lib/sylixos-device.c b/lib/sylixos-device.c index 170ae02..9addcbf 100644 --- a/lib/sylixos-device.c +++ b/lib/sylixos-device.c @@ -144,17 +144,14 @@ sylixos_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_sylixos_device = { - "sylixos-device", - "SylixOS /proc/pci device", - sylixos_config, - sylixos_detect, - sylixos_init, - sylixos_cleanup, - sylixos_scan, - pci_generic_fill_info, - sylixos_read, - sylixos_write, - NULL, // no read_vpd - NULL, // no init_dev - NULL, // no cleanup_dev + .name = "sylixos-device", + .help = "SylixOS /proc/pci device", + .config = sylixos_config, + .detect = sylixos_detect, + .init = sylixos_init, + .cleanup = sylixos_cleanup, + .scan = sylixos_scan, + .fill_info = pci_generic_fill_info, + .read = sylixos_read, + .write = sylixos_write, }; diff --git a/lib/sysdep.h b/lib/sysdep.h index 40e1407..7f22427 100644 --- a/lib/sysdep.h +++ b/lib/sysdep.h @@ -83,6 +83,10 @@ typedef u16 word; #endif #endif +#ifdef PCI_OS_HAIKU +#include +#endif + #ifdef PCI_OS_SYLIXOS #include #endif diff --git a/lib/sysfs.c b/lib/sysfs.c index cd2379e..0e763dc 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -105,12 +105,13 @@ sysfs_get_string(struct pci_dev *d, char *object, char *buf, int mandatory) return 0; } n = read(fd, buf, OBJBUFSIZE); + int read_errno = errno; close(fd); if (n < 0) { - warn("Error reading %s: %s", namebuf, strerror(errno)); + warn("Error reading %s: %s", namebuf, strerror(read_errno)); return 0; - } + } if (n >= OBJBUFSIZE) { warn("Value in %s too long", namebuf); @@ -593,17 +594,16 @@ static void sysfs_cleanup_dev(struct pci_dev *d) } struct pci_methods pm_linux_sysfs = { - "linux-sysfs", - "The sys filesystem on Linux", - sysfs_config, - sysfs_detect, - sysfs_init, - sysfs_cleanup, - sysfs_scan, - sysfs_fill_info, - sysfs_read, - sysfs_write, - sysfs_read_vpd, - NULL, /* init_dev */ - sysfs_cleanup_dev + .name = "linux-sysfs", + .help = "The sys filesystem on Linux", + .config = sysfs_config, + .detect = sysfs_detect, + .init = sysfs_init, + .cleanup = sysfs_cleanup, + .scan = sysfs_scan, + .fill_info = sysfs_fill_info, + .read = sysfs_read, + .write = sysfs_write, + .read_vpd = sysfs_read_vpd, + .cleanup_dev = sysfs_cleanup_dev, }; diff --git a/lib/win32-cfgmgr32.c b/lib/win32-cfgmgr32.c index dbddc54..ab9042d 100644 --- a/lib/win32-cfgmgr32.c +++ b/lib/win32-cfgmgr32.c @@ -1749,17 +1749,15 @@ win32_cfgmgr32_cleanup(struct pci_access *a) } struct pci_methods pm_win32_cfgmgr32 = { - "win32-cfgmgr32", - "Win32 device listing via Configuration Manager", - win32_cfgmgr32_config, - win32_cfgmgr32_detect, - win32_cfgmgr32_init, - win32_cfgmgr32_cleanup, - win32_cfgmgr32_scan, - win32_cfgmgr32_fill_info, - win32_cfgmgr32_read, - win32_cfgmgr32_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - win32_cfgmgr32_cleanup_dev, + .name = "win32-cfgmgr32", + .help = "Win32 device listing via Configuration Manager", + .config = win32_cfgmgr32_config, + .detect = win32_cfgmgr32_detect, + .init = win32_cfgmgr32_init, + .cleanup = win32_cfgmgr32_cleanup, + .scan = win32_cfgmgr32_scan, + .fill_info = win32_cfgmgr32_fill_info, + .read = win32_cfgmgr32_read, + .write = win32_cfgmgr32_write, + .cleanup_dev = win32_cfgmgr32_cleanup_dev, }; diff --git a/lib/win32-helpers.c b/lib/win32-helpers.c index d370d5c..0190f21 100644 --- a/lib/win32-helpers.c +++ b/lib/win32-helpers.c @@ -948,7 +948,7 @@ win32_find_and_open_process_for_query(LPCSTR exe_file) * On older NT-based systems these functions are available in * psapi.dll library without K32 prefix. */ - prev_error_mode = win32_change_error_mode(SEM_FAILCRITICALERRORS); + prev_error_mode = win32_change_error_mode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); psapi = LoadLibrary(TEXT("psapi.dll")); win32_change_error_mode(prev_error_mode); @@ -1227,6 +1227,7 @@ win32_call_func_with_tcb_privilege(BOOL (*function)(LPVOID), LPVOID argument) HANDLE lsass_process; HANDLE lsass_token; + DWORD error; BOOL ret; impersonate_privilege_enabled = FALSE; @@ -1374,6 +1375,8 @@ err_privilege_not_held: goto ret; ret: + error = GetLastError(); + if (revert_to_old_token) win32_revert_to_token(old_token); @@ -1383,5 +1386,7 @@ ret: if (lsass_token) CloseHandle(lsass_token); + SetLastError(error); + return ret; } diff --git a/lib/win32-kldbg.c b/lib/win32-kldbg.c index 33f5751..22078f5 100644 --- a/lib/win32-kldbg.c +++ b/lib/win32-kldbg.c @@ -715,17 +715,13 @@ win32_kldbg_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_win32_kldbg = { - "win32-kldbg", - "Win32 PCI config space access using Kernel Local Debugging Driver", - NULL, /* config */ - win32_kldbg_detect, - win32_kldbg_init, - win32_kldbg_cleanup, - win32_kldbg_scan, - pci_generic_fill_info, - win32_kldbg_read, - win32_kldbg_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "win32-kldbg", + .help = "Win32 PCI config space access using Kernel Local Debugging Driver", + .detect = win32_kldbg_detect, + .init = win32_kldbg_init, + .cleanup = win32_kldbg_cleanup, + .scan = win32_kldbg_scan, + .fill_info = pci_generic_fill_info, + .read = win32_kldbg_read, + .write = win32_kldbg_write, }; diff --git a/lib/win32-sysdbg.c b/lib/win32-sysdbg.c index 99ce607..6847fee 100644 --- a/lib/win32-sysdbg.c +++ b/lib/win32-sysdbg.c @@ -125,7 +125,7 @@ win32_sysdbg_setup(struct pci_access *a) if (win32_sysdbg_initialized) return 1; - prev_error_mode = win32_change_error_mode(SEM_FAILCRITICALERRORS); + prev_error_mode = win32_change_error_mode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); ntdll = LoadLibrary(TEXT("ntdll.dll")); win32_change_error_mode(prev_error_mode); if (!ntdll) @@ -290,17 +290,13 @@ win32_sysdbg_write(struct pci_dev *d, int pos, byte *buf, int len) } struct pci_methods pm_win32_sysdbg = { - "win32-sysdbg", - "Win32 PCI config space access using NT SysDbg Bus Data interface", - NULL, /* config */ - win32_sysdbg_detect, - win32_sysdbg_init, - win32_sysdbg_cleanup, - pci_generic_scan, - pci_generic_fill_info, - win32_sysdbg_read, - win32_sysdbg_write, - NULL, /* read_vpd */ - NULL, /* init_dev */ - NULL /* cleanup_dev */ + .name = "win32-sysdbg", + .help = "Win32 PCI config space access using NT SysDbg Bus Data interface", + .detect = win32_sysdbg_detect, + .init = win32_sysdbg_init, + .cleanup = win32_sysdbg_cleanup, + .scan = pci_generic_scan, + .fill_info = pci_generic_fill_info, + .read = win32_sysdbg_read, + .write = win32_sysdbg_write, }; -- cgit v1.2.3