Accept 1MB New World Boot ROMs.

This commit is contained in:
Maxim Poliakovski 2023-02-02 22:47:52 +01:00
parent 9fcf5ba51a
commit 299f0d3a9f
2 changed files with 19 additions and 11 deletions

View File

@ -227,16 +227,18 @@ bool MemCtrlBase::add_mem_mirror(uint32_t start_addr, uint32_t dest_addr) {
} }
bool MemCtrlBase::set_data(uint32_t reg_addr, const uint8_t* data, uint32_t size) { bool MemCtrlBase::set_data(uint32_t load_addr, const uint8_t* data, uint32_t size) {
AddressMapEntry* ref_entry; AddressMapEntry* ref_entry;
uint32_t cpy_size; uint32_t cpy_size;
ref_entry = find_range(reg_addr); ref_entry = find_range(load_addr);
if (!ref_entry) if (!ref_entry)
return false; return false;
uint32_t load_offset = load_addr - ref_entry->start;
cpy_size = std::min(ref_entry->end - ref_entry->start + 1, size); cpy_size = std::min(ref_entry->end - ref_entry->start + 1, size);
memcpy(ref_entry->mem_ptr, data, cpy_size); memcpy(ref_entry->mem_ptr + load_offset, data, cpy_size);
return true; return true;
} }

View File

@ -328,7 +328,8 @@ bail_out:
int MachineFactory::load_boot_rom(string& rom_filepath) { int MachineFactory::load_boot_rom(string& rom_filepath) {
ifstream rom_file; ifstream rom_file;
size_t file_size; size_t file_size;
int result; int result = 0;
uint32_t rom_load_addr;
AddressMapEntry *rom_reg; AddressMapEntry *rom_reg;
rom_file.open(rom_filepath, ios::in | ios::binary); rom_file.open(rom_filepath, ios::in | ios::binary);
@ -342,10 +343,16 @@ int MachineFactory::load_boot_rom(string& rom_filepath) {
file_size = rom_file.tellg(); file_size = rom_file.tellg();
rom_file.seekg(0, rom_file.beg); rom_file.seekg(0, rom_file.beg);
if (file_size != 0x400000UL) { if (file_size == 0x400000UL) { // Old World ROMs
LOG_F(ERROR, "Unxpected ROM File size. Expected size is 4 megabytes."); rom_load_addr = 0xFFC00000UL;
result = -1; } else if (file_size == 0x100000UL) { // New World ROMs
rom_load_addr = 0xFFF00000UL;
} else { } else {
LOG_F(ERROR, "Unxpected ROM File size: %zu bytes.", file_size);
result = -1;
}
if (!result) {
unsigned char* sysrom_mem = new unsigned char[file_size]; unsigned char* sysrom_mem = new unsigned char[file_size];
rom_file.seekg(0, ios::beg); rom_file.seekg(0, ios::beg);
@ -355,14 +362,13 @@ int MachineFactory::load_boot_rom(string& rom_filepath) {
gMachineObj->get_comp_by_type(HWCompType::MEM_CTRL)); gMachineObj->get_comp_by_type(HWCompType::MEM_CTRL));
if ((rom_reg = mem_ctrl->find_rom_region())) { if ((rom_reg = mem_ctrl->find_rom_region())) {
mem_ctrl->set_data(rom_reg->start, sysrom_mem, (uint32_t)file_size); mem_ctrl->set_data(rom_load_addr, sysrom_mem, (uint32_t)file_size);
} else { } else {
ABORT_F("Could not locate physical ROM region!"); LOG_F(ERROR, "Could not locate physical ROM region!");
result = -1;
} }
delete[] sysrom_mem; delete[] sysrom_mem;
result = 0;
} }
rom_file.close(); rom_file.close();