Fixing xex loading into 4k pages.
This commit is contained in:
parent
0ad3ed0230
commit
447b5bf316
|
@ -52,10 +52,9 @@ int XexModule::Load(const std::string& name, const std::string& path, xe_xex2_re
|
||||||
high_address_ = 0;
|
high_address_ = 0;
|
||||||
for (size_t n = 0, i = 0; n < header->section_count; n++) {
|
for (size_t n = 0, i = 0; n < header->section_count; n++) {
|
||||||
const xe_xex2_section_t* section = &header->sections[n];
|
const xe_xex2_section_t* section = &header->sections[n];
|
||||||
const size_t start_address =
|
const size_t start_address = header->exe_address + (i * section->page_size);
|
||||||
header->exe_address + (i * xe_xex2_section_length);
|
|
||||||
const size_t end_address =
|
const size_t end_address =
|
||||||
start_address + (section->info.page_count * xe_xex2_section_length);
|
start_address + (section->info.page_count * section->page_size);
|
||||||
if (section->info.type == XEX_SECTION_CODE) {
|
if (section->info.type == XEX_SECTION_CODE) {
|
||||||
low_address_ =
|
low_address_ =
|
||||||
static_cast<uint32_t>(std::min(low_address_, start_address));
|
static_cast<uint32_t>(std::min(low_address_, start_address));
|
||||||
|
@ -391,25 +390,24 @@ int XexModule::FindSaveRest() {
|
||||||
const xe_xex2_header_t* header = xe_xex2_get_header(xex_);
|
const xe_xex2_header_t* header = xe_xex2_get_header(xex_);
|
||||||
for (size_t n = 0, i = 0; n < header->section_count; n++) {
|
for (size_t n = 0, i = 0; n < header->section_count; n++) {
|
||||||
const xe_xex2_section_t* section = &header->sections[n];
|
const xe_xex2_section_t* section = &header->sections[n];
|
||||||
const size_t start_address =
|
const size_t start_address = header->exe_address + (i * section->page_size);
|
||||||
header->exe_address + (i * xe_xex2_section_length);
|
|
||||||
const size_t end_address =
|
const size_t end_address =
|
||||||
start_address + (section->info.page_count * xe_xex2_section_length);
|
start_address + (section->info.page_count * section->page_size);
|
||||||
if (section->info.type == XEX_SECTION_CODE) {
|
if (section->info.type == XEX_SECTION_CODE) {
|
||||||
if (!gplr_start) {
|
if (!gplr_start) {
|
||||||
gplr_start = memory_->SearchAligned(
|
gplr_start = memory_->SearchAligned(start_address, end_address,
|
||||||
start_address, end_address,
|
gprlr_code_values,
|
||||||
gprlr_code_values, poly::countof(gprlr_code_values));
|
poly::countof(gprlr_code_values));
|
||||||
}
|
}
|
||||||
if (!fpr_start) {
|
if (!fpr_start) {
|
||||||
fpr_start = memory_->SearchAligned(
|
fpr_start =
|
||||||
start_address, end_address,
|
memory_->SearchAligned(start_address, end_address, fpr_code_values,
|
||||||
fpr_code_values, poly::countof(fpr_code_values));
|
poly::countof(fpr_code_values));
|
||||||
}
|
}
|
||||||
if (!vmx_start) {
|
if (!vmx_start) {
|
||||||
vmx_start = memory_->SearchAligned(
|
vmx_start =
|
||||||
start_address, end_address,
|
memory_->SearchAligned(start_address, end_address, vmx_code_values,
|
||||||
vmx_code_values, poly::countof(vmx_code_values));
|
poly::countof(vmx_code_values));
|
||||||
}
|
}
|
||||||
if (gplr_start && fpr_start && vmx_start) {
|
if (gplr_start && fpr_start && vmx_start) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -233,13 +233,12 @@ void XUserModule::Dump() {
|
||||||
type = "RODATA ";
|
type = "RODATA ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const size_t start_address =
|
const size_t start_address = header->exe_address + (i * section->page_size);
|
||||||
header->exe_address + (i * xe_xex2_section_length);
|
|
||||||
const size_t end_address =
|
const size_t end_address =
|
||||||
start_address + (section->info.page_count * xe_xex2_section_length);
|
start_address + (section->info.page_count * section->page_size);
|
||||||
printf(" %3d %s %3d pages %.8X - %.8X (%d bytes)\n", (int)n, type,
|
printf(" %3d %s %3d pages %.8X - %.8X (%d bytes)\n", (int)n, type,
|
||||||
section->info.page_count, (int)start_address, (int)end_address,
|
section->info.page_count, (int)start_address, (int)end_address,
|
||||||
section->info.page_count * xe_xex2_section_length);
|
section->info.page_count * section->page_size);
|
||||||
i += section->info.page_count;
|
i += section->info.page_count;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -292,7 +291,7 @@ void XUserModule::Dump() {
|
||||||
unimpl_count++;
|
unimpl_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(" Total: %4zu\n", import_info_count);
|
printf(" Total: %4u\n", uint32_t(import_info_count));
|
||||||
printf(" Known: %3d%% (%d known, %d unknown)\n",
|
printf(" Known: %3d%% (%d known, %d unknown)\n",
|
||||||
(int)(known_count / (float)import_info_count * 100.0f),
|
(int)(known_count / (float)import_info_count * 100.0f),
|
||||||
known_count, unknown_count);
|
known_count, unknown_count);
|
||||||
|
|
|
@ -399,6 +399,8 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length,
|
||||||
XEEXPECTNOTNULL(header->sections);
|
XEEXPECTNOTNULL(header->sections);
|
||||||
for (size_t n = 0; n < header->section_count; n++) {
|
for (size_t n = 0; n < header->section_count; n++) {
|
||||||
xe_xex2_section_t *section = &header->sections[n];
|
xe_xex2_section_t *section = &header->sections[n];
|
||||||
|
section->page_size =
|
||||||
|
header->exe_address <= 0x90000000 ? 64 * 1024 : 4 * 1024;
|
||||||
section->info.value = poly::load_and_swap<uint32_t>(ps);
|
section->info.value = poly::load_and_swap<uint32_t>(ps);
|
||||||
ps += 4;
|
ps += 4;
|
||||||
memcpy(section->digest, ps, sizeof(section->digest));
|
memcpy(section->digest, ps, sizeof(section->digest));
|
||||||
|
|
|
@ -410,18 +410,17 @@ typedef enum {
|
||||||
} xe_xex2_section_type;
|
} xe_xex2_section_type;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
size_t page_size;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
xe_xex2_section_type type : 4;
|
xe_xex2_section_type type : 4;
|
||||||
uint32_t page_count : 28; // # of 64kb pages
|
uint32_t page_count : 28; // # of pages
|
||||||
};
|
};
|
||||||
uint32_t value; // To make uint8_t swapping easier
|
uint32_t value; // To make uint8_t swapping easier
|
||||||
} info;
|
} info;
|
||||||
uint8_t digest[20];
|
uint8_t digest[20];
|
||||||
} xe_xex2_section_t;
|
} xe_xex2_section_t;
|
||||||
|
|
||||||
#define xe_xex2_section_length 0x00010000
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t xex2;
|
uint32_t xex2;
|
||||||
xe_xex2_module_flags module_flags;
|
xe_xex2_module_flags module_flags;
|
||||||
|
|
|
@ -218,7 +218,8 @@ const static struct {
|
||||||
} map_info[] = {
|
} map_info[] = {
|
||||||
0x00000000, 0x3FFFFFFF, 0x00000000, // (1024mb) - virtual 4k pages
|
0x00000000, 0x3FFFFFFF, 0x00000000, // (1024mb) - virtual 4k pages
|
||||||
0x40000000, 0x7FFFFFFF, 0x40000000, // (1024mb) - virtual 64k pages
|
0x40000000, 0x7FFFFFFF, 0x40000000, // (1024mb) - virtual 64k pages
|
||||||
0x80000000, 0x9FFFFFFF, 0x80000000, // (512mb) - xex pages
|
0x80000000, 0x8FFFFFFF, 0x80000000, // (256mb) - xex 64k pages
|
||||||
|
0x90000000, 0x9FFFFFFF, 0x80000000, // (256mb) - xex 4k pages
|
||||||
0xA0000000, 0xBFFFFFFF, 0x00000000, // (512mb) - physical 64k pages
|
0xA0000000, 0xBFFFFFFF, 0x00000000, // (512mb) - physical 64k pages
|
||||||
0xC0000000, 0xDFFFFFFF, 0x00000000, // - physical 16mb pages
|
0xC0000000, 0xDFFFFFFF, 0x00000000, // - physical 16mb pages
|
||||||
0xE0000000, 0xFFFFFFFF, 0x00000000, // - physical 4k pages
|
0xE0000000, 0xFFFFFFFF, 0x00000000, // - physical 4k pages
|
||||||
|
|
|
@ -87,11 +87,12 @@ class Memory : public alloy::Memory {
|
||||||
uint8_t* v00000000;
|
uint8_t* v00000000;
|
||||||
uint8_t* v40000000;
|
uint8_t* v40000000;
|
||||||
uint8_t* v80000000;
|
uint8_t* v80000000;
|
||||||
|
uint8_t* v90000000;
|
||||||
uint8_t* vA0000000;
|
uint8_t* vA0000000;
|
||||||
uint8_t* vC0000000;
|
uint8_t* vC0000000;
|
||||||
uint8_t* vE0000000;
|
uint8_t* vE0000000;
|
||||||
};
|
};
|
||||||
uint8_t* all_views[6];
|
uint8_t* all_views[7];
|
||||||
} views_;
|
} views_;
|
||||||
|
|
||||||
std::unique_ptr<cpu::MMIOHandler> mmio_handler_;
|
std::unique_ptr<cpu::MMIOHandler> mmio_handler_;
|
||||||
|
|
Loading…
Reference in New Issue