qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 0/6] option rom patches, next round


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 0/6] option rom patches, next round
Date: Thu, 17 Dec 2009 13:32:42 +0100

  Hi,

All in one patch series for pci rom bar support and option rom loading
via fw_cfg for the non-pci roms.  This time the fw_cfg interface is
actually tested with a little linux userspace app (attached below).

cheers,
  Gerd

----- [ cut here ] -----
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/io.h>
#include <arpa/inet.h>

#define FW_CFG_FILE_DIR         0x19

typedef struct FWCfgFile {
    uint32_t  size;        /* file size */
    uint16_t  select;      /* write this to 0x510 to read it */
    uint16_t  reserved;
    char      name[56];
} FWCfgFile;

void fw_read(void *ptr, int len)
{
    uint8_t *data = ptr;
    int i;

    for (i = 0; i < len; i++) {
        data[i] = inb(0x511);
    }
}

int main(int argc, char *argv[])
{
    uint8_t data[64];
    FWCfgFile *entry;
    uint32_t e, i, count;

    fprintf(stderr, "fwtest - qemu files\n");
    ioperm(0x510, 4, 1);

    outw(FW_CFG_FILE_DIR, 0x510);
    fw_read(&count, sizeof(count));
    fprintf(stderr, "%d files\n", ntohl(count));
    entry = malloc(sizeof(*entry) * ntohl(count));
    fw_read(entry, sizeof(*entry) * ntohl(count));

    for (e = 0; e < ntohl(count); e++) {
        fprintf(stderr, "   #%d: %s (%d bytes)\n", e,
                entry[e].name, ntohl(entry[e].size));
        outw(ntohs(entry[e].select), 0x510);
        fw_read(data, sizeof(data));

        for (i = 0; i < sizeof(data); i++) {
            if (i % 16 == 0)
                fprintf(stderr, "    ");
            if (i % 4 == 0)
                fprintf(stderr, " ");
            fprintf(stderr, " %02x", data[i]);
            if (i % 16 == 15)
                fprintf(stderr, "\n");
        }
    }
    return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]