roms: remove option rom packing logic
Now that we load the option roms via fw_cfg, we can stop copying them to the 0xc000 -> 0xe000. The patch does just that. Also the rom loader gets simplified as all remaining users of the rom loader load the bits at a fixed address so the packing and aligning logic can go away. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
379526a40e
commit
632cf034b4
103
hw/loader.c
103
hw/loader.c
|
@ -527,13 +527,10 @@ struct Rom {
|
||||||
char *path;
|
char *path;
|
||||||
size_t romsize;
|
size_t romsize;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
int align;
|
|
||||||
int isrom;
|
int isrom;
|
||||||
char *fw_dir;
|
char *fw_dir;
|
||||||
char *fw_file;
|
char *fw_file;
|
||||||
|
|
||||||
target_phys_addr_t min;
|
|
||||||
target_phys_addr_t max;
|
|
||||||
target_phys_addr_t addr;
|
target_phys_addr_t addr;
|
||||||
QTAILQ_ENTRY(Rom) next;
|
QTAILQ_ENTRY(Rom) next;
|
||||||
};
|
};
|
||||||
|
@ -551,7 +548,7 @@ static void rom_insert(Rom *rom)
|
||||||
|
|
||||||
/* list is ordered by load address */
|
/* list is ordered by load address */
|
||||||
QTAILQ_FOREACH(item, &roms, next) {
|
QTAILQ_FOREACH(item, &roms, next) {
|
||||||
if (rom->min >= item->min)
|
if (rom->addr >= item->addr)
|
||||||
continue;
|
continue;
|
||||||
QTAILQ_INSERT_BEFORE(item, rom, next);
|
QTAILQ_INSERT_BEFORE(item, rom, next);
|
||||||
return;
|
return;
|
||||||
|
@ -560,7 +557,7 @@ static void rom_insert(Rom *rom)
|
||||||
}
|
}
|
||||||
|
|
||||||
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||||
target_phys_addr_t min, target_phys_addr_t max, int align)
|
target_phys_addr_t addr)
|
||||||
{
|
{
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
int rc, fd = -1;
|
int rc, fd = -1;
|
||||||
|
@ -581,9 +578,7 @@ int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||||
|
|
||||||
rom->fw_dir = fw_dir ? qemu_strdup(fw_dir) : NULL;
|
rom->fw_dir = fw_dir ? qemu_strdup(fw_dir) : NULL;
|
||||||
rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
|
rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
|
||||||
rom->align = align;
|
rom->addr = addr;
|
||||||
rom->min = min;
|
|
||||||
rom->max = max;
|
|
||||||
rom->romsize = lseek(fd, 0, SEEK_END);
|
rom->romsize = lseek(fd, 0, SEEK_END);
|
||||||
rom->data = qemu_mallocz(rom->romsize);
|
rom->data = qemu_mallocz(rom->romsize);
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
@ -608,15 +603,13 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
int rom_add_blob(const char *name, const void *blob, size_t len,
|
int rom_add_blob(const char *name, const void *blob, size_t len,
|
||||||
target_phys_addr_t min, target_phys_addr_t max, int align)
|
target_phys_addr_t addr)
|
||||||
{
|
{
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
|
|
||||||
rom = qemu_mallocz(sizeof(*rom));
|
rom = qemu_mallocz(sizeof(*rom));
|
||||||
rom->name = qemu_strdup(name);
|
rom->name = qemu_strdup(name);
|
||||||
rom->align = align;
|
rom->addr = addr;
|
||||||
rom->min = min;
|
|
||||||
rom->max = max;
|
|
||||||
rom->romsize = len;
|
rom->romsize = len;
|
||||||
rom->data = qemu_mallocz(rom->romsize);
|
rom->data = qemu_mallocz(rom->romsize);
|
||||||
memcpy(rom->data, blob, len);
|
memcpy(rom->data, blob, len);
|
||||||
|
@ -628,16 +621,14 @@ int rom_add_vga(const char *file)
|
||||||
{
|
{
|
||||||
if (!rom_enable_driver_roms)
|
if (!rom_enable_driver_roms)
|
||||||
return 0;
|
return 0;
|
||||||
return rom_add_file(file, "vgaroms", file,
|
return rom_add_file(file, "vgaroms", file, 0);
|
||||||
PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rom_add_option(const char *file)
|
int rom_add_option(const char *file)
|
||||||
{
|
{
|
||||||
if (!rom_enable_driver_roms)
|
if (!rom_enable_driver_roms)
|
||||||
return 0;
|
return 0;
|
||||||
return rom_add_file(file, "genroms", file,
|
return rom_add_file(file, "genroms", file, 0);
|
||||||
PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rom_reset(void *unused)
|
static void rom_reset(void *unused)
|
||||||
|
@ -645,6 +636,8 @@ static void rom_reset(void *unused)
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
|
|
||||||
QTAILQ_FOREACH(rom, &roms, next) {
|
QTAILQ_FOREACH(rom, &roms, next) {
|
||||||
|
if (rom->addr == 0)
|
||||||
|
continue;
|
||||||
if (rom->data == NULL)
|
if (rom->data == NULL)
|
||||||
continue;
|
continue;
|
||||||
cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
|
cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
|
||||||
|
@ -663,32 +656,16 @@ int rom_load_all(void)
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
|
|
||||||
QTAILQ_FOREACH(rom, &roms, next) {
|
QTAILQ_FOREACH(rom, &roms, next) {
|
||||||
if (addr < rom->min)
|
if (rom->addr == 0)
|
||||||
addr = rom->min;
|
continue;
|
||||||
if (rom->max) {
|
if (addr > rom->addr) {
|
||||||
/* load address range */
|
fprintf(stderr, "rom: requested regions overlap "
|
||||||
if (rom->align) {
|
"(rom %s. free=0x" TARGET_FMT_plx
|
||||||
addr += (rom->align-1);
|
", addr=0x" TARGET_FMT_plx ")\n",
|
||||||
addr &= ~(rom->align-1);
|
rom->name, addr, rom->addr);
|
||||||
}
|
return -1;
|
||||||
if (addr + rom->romsize > rom->max) {
|
|
||||||
fprintf(stderr, "rom: out of memory (rom %s, "
|
|
||||||
"addr 0x" TARGET_FMT_plx
|
|
||||||
", size 0x%zx, max 0x" TARGET_FMT_plx ")\n",
|
|
||||||
rom->name, addr, rom->romsize, rom->max);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* fixed address requested */
|
|
||||||
if (addr != rom->min) {
|
|
||||||
fprintf(stderr, "rom: requested regions overlap "
|
|
||||||
"(rom %s. free=0x" TARGET_FMT_plx
|
|
||||||
", addr=0x" TARGET_FMT_plx ")\n",
|
|
||||||
rom->name, addr, rom->min);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
rom->addr = addr;
|
addr = rom->addr;
|
||||||
addr += rom->romsize;
|
addr += rom->romsize;
|
||||||
memtype = cpu_get_physical_page_desc(rom->addr) & (3 << IO_MEM_SHIFT);
|
memtype = cpu_get_physical_page_desc(rom->addr) & (3 << IO_MEM_SHIFT);
|
||||||
if (memtype == IO_MEM_ROM)
|
if (memtype == IO_MEM_ROM)
|
||||||
|
@ -716,11 +693,11 @@ static Rom *find_rom(target_phys_addr_t addr)
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
|
|
||||||
QTAILQ_FOREACH(rom, &roms, next) {
|
QTAILQ_FOREACH(rom, &roms, next) {
|
||||||
if (rom->max)
|
if (rom->addr == 0)
|
||||||
continue;
|
continue;
|
||||||
if (rom->min > addr)
|
if (rom->addr > addr)
|
||||||
continue;
|
continue;
|
||||||
if (rom->min + rom->romsize < addr)
|
if (rom->addr + rom->romsize < addr)
|
||||||
continue;
|
continue;
|
||||||
return rom;
|
return rom;
|
||||||
}
|
}
|
||||||
|
@ -735,23 +712,25 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
|
|
||||||
QTAILQ_FOREACH(rom, &roms, next) {
|
QTAILQ_FOREACH(rom, &roms, next) {
|
||||||
if (rom->max)
|
if (rom->addr == 0)
|
||||||
continue;
|
continue;
|
||||||
if (rom->min + rom->romsize < addr)
|
if (rom->addr > addr)
|
||||||
continue;
|
continue;
|
||||||
if (rom->min > end)
|
if (rom->addr + rom->romsize < addr)
|
||||||
|
continue;
|
||||||
|
if (rom->addr > end)
|
||||||
break;
|
break;
|
||||||
if (!rom->data)
|
if (!rom->data)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
d = dest + (rom->min - addr);
|
d = dest + (rom->addr - addr);
|
||||||
s = rom->data;
|
s = rom->data;
|
||||||
l = rom->romsize;
|
l = rom->romsize;
|
||||||
|
|
||||||
if (rom->min < addr) {
|
if (rom->addr < addr) {
|
||||||
d = dest;
|
d = dest;
|
||||||
s += (addr - rom->min);
|
s += (addr - rom->addr);
|
||||||
l -= (addr - rom->min);
|
l -= (addr - rom->addr);
|
||||||
}
|
}
|
||||||
if ((d + l) > (dest + size)) {
|
if ((d + l) > (dest + size)) {
|
||||||
l = dest - d;
|
l = dest - d;
|
||||||
|
@ -770,7 +749,7 @@ void *rom_ptr(target_phys_addr_t addr)
|
||||||
rom = find_rom(addr);
|
rom = find_rom(addr);
|
||||||
if (!rom || !rom->data)
|
if (!rom || !rom->data)
|
||||||
return NULL;
|
return NULL;
|
||||||
return rom->data + (addr - rom->min);
|
return rom->data + (addr - rom->addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_info_roms(Monitor *mon)
|
void do_info_roms(Monitor *mon)
|
||||||
|
@ -778,10 +757,20 @@ void do_info_roms(Monitor *mon)
|
||||||
Rom *rom;
|
Rom *rom;
|
||||||
|
|
||||||
QTAILQ_FOREACH(rom, &roms, next) {
|
QTAILQ_FOREACH(rom, &roms, next) {
|
||||||
monitor_printf(mon, "addr=" TARGET_FMT_plx
|
if (rom->addr) {
|
||||||
" size=0x%06zx mem=%s name=\"%s\" \n",
|
monitor_printf(mon, "addr=" TARGET_FMT_plx
|
||||||
rom->addr, rom->romsize,
|
" size=0x%06zx mem=%s name=\"%s\" \n",
|
||||||
rom->isrom ? "rom" : "ram",
|
rom->addr, rom->romsize,
|
||||||
rom->name);
|
rom->isrom ? "rom" : "ram",
|
||||||
|
rom->name);
|
||||||
|
} else {
|
||||||
|
monitor_printf(mon, "fw=%s%s%s"
|
||||||
|
" size=0x%06zx name=\"%s\" \n",
|
||||||
|
rom->fw_dir ? rom->fw_dir : "",
|
||||||
|
rom->fw_dir ? "/" : "",
|
||||||
|
rom->fw_file,
|
||||||
|
rom->romsize,
|
||||||
|
rom->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ void pstrcpy_targphys(const char *name,
|
||||||
const char *source);
|
const char *source);
|
||||||
|
|
||||||
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
|
||||||
target_phys_addr_t min, target_phys_addr_t max, int align);
|
target_phys_addr_t addr);
|
||||||
int rom_add_blob(const char *name, const void *blob, size_t len,
|
int rom_add_blob(const char *name, const void *blob, size_t len,
|
||||||
target_phys_addr_t min, target_phys_addr_t max, int align);
|
target_phys_addr_t addr);
|
||||||
int rom_load_all(void);
|
int rom_load_all(void);
|
||||||
int rom_load_fw(void *fw_cfg);
|
int rom_load_fw(void *fw_cfg);
|
||||||
int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
|
int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
|
||||||
|
@ -30,9 +30,9 @@ void *rom_ptr(target_phys_addr_t addr);
|
||||||
void do_info_roms(Monitor *mon);
|
void do_info_roms(Monitor *mon);
|
||||||
|
|
||||||
#define rom_add_file_fixed(_f, _a) \
|
#define rom_add_file_fixed(_f, _a) \
|
||||||
rom_add_file(_f, NULL, NULL, _a, 0, 0)
|
rom_add_file(_f, NULL, NULL, _a)
|
||||||
#define rom_add_blob_fixed(_f, _b, _l, _a) \
|
#define rom_add_blob_fixed(_f, _b, _l, _a) \
|
||||||
rom_add_blob(_f, _b, _l, _a, 0, 0)
|
rom_add_blob(_f, _b, _l, _a)
|
||||||
|
|
||||||
#define PC_ROM_MIN_VGA 0xc0000
|
#define PC_ROM_MIN_VGA 0xc0000
|
||||||
#define PC_ROM_MIN_OPTION 0xc8000
|
#define PC_ROM_MIN_OPTION 0xc8000
|
||||||
|
|
Loading…
Reference in New Issue