static int host_pci_config_read(int pos, int len, uint32_t val)

{

    char path[PATH_MAX];

    int config_fd;

    ssize_t size = sizeof(path);

    /* Access real host bridge. */

    int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",

                      0, 0, 0, 0, "config");



    if (rc >= size || rc < 0) {

        return -ENODEV;

    }



    config_fd = open(path, O_RDWR);

    if (config_fd < 0) {

        return -ENODEV;

    }



    if (lseek(config_fd, pos, SEEK_SET) != pos) {

        return -errno;

    }

    do {

        rc = read(config_fd, (uint8_t *)&val, len);

    } while (rc < 0 && (errno == EINTR || errno == EAGAIN));

    if (rc != len) {

        return -errno;

    }



    return 0;

}

static int host_pci_config_read(int pos, int len, uint32_t val)

{

    char path[PATH_MAX];

    int config_fd;

    ssize_t size = sizeof(path);

    

    int rc = snprintf(path, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",

                      0, 0, 0, 0, "config");



    if (rc >= size || rc < 0) {

        return -ENODEV;

    }



    config_fd = open(path, O_RDWR);

    if (config_fd < 0) {

        return -ENODEV;

    }



    if (lseek(config_fd, pos, SEEK_SET) != pos) {

        return -errno;

    }

    do {

        rc = read(config_fd, (uint8_t *)&val, len);

    } while (rc < 0 && (errno == EINTR || errno == EAGAIN));

    if (rc != len) {

        return -errno;

    }



    return 0;

}

        return -errno;         return -errno;     return 0;
static int FUNC_0(int VAR_0, int VAR_1, uint32_t VAR_2)

{

    char VAR_3[PATH_MAX];

    int VAR_4;

    ssize_t size = sizeof(VAR_3);

    

    int VAR_5 = snprintf(VAR_3, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",

                      0, 0, 0, 0, "config");



    if (VAR_5 >= size || VAR_5 < 0) {

        return -ENODEV;

    }



    VAR_4 = open(VAR_3, O_RDWR);

    if (VAR_4 < 0) {

        return -ENODEV;

    }



    if (lseek(VAR_4, VAR_0, SEEK_SET) != VAR_0) {

        return -errno;

    }

    do {

        VAR_5 = read(VAR_4, (uint8_t *)&VAR_2, VAR_1);

    } while (VAR_5 < 0 && (errno == EINTR || errno == EAGAIN));

    if (VAR_5 != VAR_1) {

        return -errno;

    }



    return 0;

}

static int FUNC_0(int VAR_0, int VAR_1, uint32_t VAR_2)
{ char VAR_3[PATH_MAX]; int VAR_4; ssize_t size = sizeof(VAR_3); int VAR_5 = snprintf(VAR_3, size, "/sys/bus/pci/devices/%04x:%02x:%02x.%d/%s",
0, 0, 0, 0, "config"); if (VAR_5 >= size || VAR_5 < 0) { return -ENODEV; } VAR_4 = open(VAR_3, O_RDWR); if (VAR_4 < 0) { return -ENODEV; } if (lseek(VAR_4, VAR_0, SEEK_SET) != VAR_0) { return -errno; } do { VAR_5 = read(VAR_4, (uint8_t *)&VAR_2, VAR_1); } while (VAR_5 < 0 && (errno == EINTR || errno == EAGAIN)); if (VAR_5 != VAR_1) { return -errno; } return 0; }