Interim mem.c/h code and a slight optimization to do_mmutranslate().
This commit is contained in:
@@ -449,6 +449,8 @@ extern void mem_close(void);
|
|||||||
extern void mem_reset(void);
|
extern void mem_reset(void);
|
||||||
extern void mem_remap_top(int kb);
|
extern void mem_remap_top(int kb);
|
||||||
|
|
||||||
|
extern void umc_smram_recalc(uint32_t start, int set);
|
||||||
|
|
||||||
extern mem_mapping_t *read_mapping[MEM_MAPPINGS_NO];
|
extern mem_mapping_t *read_mapping[MEM_MAPPINGS_NO];
|
||||||
extern mem_mapping_t *write_mapping[MEM_MAPPINGS_NO];
|
extern mem_mapping_t *write_mapping[MEM_MAPPINGS_NO];
|
||||||
|
|
||||||
|
@@ -1585,40 +1585,38 @@ do_mmutranslate(uint32_t addr, uint32_t *a64, int num, int write)
|
|||||||
for (i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
a64[i] = (uint64_t) addr;
|
a64[i] = (uint64_t) addr;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
if (cr0 >> 31) for (i = 0; i < num; i++) {
|
||||||
if (cr0 >> 31) {
|
if (write && ((i == 0) || !(addr & 0xfff)))
|
||||||
if (write && ((i == 0) || !(addr & 0xfff)))
|
cond = (!page_lookup[addr >> 12] || !page_lookup[addr >> 12]->write_b);
|
||||||
cond = (!page_lookup[addr >> 12] || !page_lookup[addr >> 12]->write_b);
|
|
||||||
|
|
||||||
if (cond) {
|
if (cond) {
|
||||||
/* If we have encountered at least one page fault, mark all subsequent addresses as
|
/* If we have encountered at least one page fault, mark all subsequent addresses as
|
||||||
having page faulted, prevents false negatives in readmem*l_no_mmut. */
|
having page faulted, prevents false negatives in readmem*l_no_mmut. */
|
||||||
if ((i > 0) && cpu_state.abrt && !high_page)
|
if ((i > 0) && cpu_state.abrt && !high_page)
|
||||||
a64[i] = a64[i - 1];
|
a64[i] = a64[i - 1];
|
||||||
/* If we are on the same page, there is no need to translate again, as we can just
|
/* If we are on the same page, there is no need to translate again, as we can just
|
||||||
reuse the previous result. */
|
reuse the previous result. */
|
||||||
else if (i == 0) {
|
else if (i == 0) {
|
||||||
a = mmutranslatereal(addr, write);
|
a = mmutranslatereal(addr, write);
|
||||||
a64[i] = (uint32_t) a;
|
a64[i] = (uint32_t) a;
|
||||||
|
|
||||||
high_page = high_page || (!cpu_state.abrt && (a > 0xffffffffULL));
|
high_page = high_page || (!cpu_state.abrt && (a > 0xffffffffULL));
|
||||||
} else if (!(addr & 0xfff)) {
|
} else if (!(addr & 0xfff)) {
|
||||||
a = mmutranslatereal(last_addr, write);
|
a = mmutranslatereal(last_addr, write);
|
||||||
a64[i] = (uint32_t) a;
|
a64[i] = (uint32_t) a;
|
||||||
|
|
||||||
high_page = high_page || (!cpu_state.abrt && (a64[i] > 0xffffffffULL));
|
high_page = high_page || (!cpu_state.abrt && (a64[i] > 0xffffffffULL));
|
||||||
|
|
||||||
if (!cpu_state.abrt) {
|
if (!cpu_state.abrt) {
|
||||||
a = (a & 0xfffffffffffff000ULL) | ((uint64_t) (addr & 0xfff));
|
|
||||||
a64[i] = (uint32_t) a;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
a = (a & 0xfffffffffffff000ULL) | ((uint64_t) (addr & 0xfff));
|
a = (a & 0xfffffffffffff000ULL) | ((uint64_t) (addr & 0xfff));
|
||||||
a64[i] = (uint32_t) a;
|
a64[i] = (uint32_t) a;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
mmu_perm = page_lookupp[addr >> 12];
|
a = (a & 0xfffffffffffff000ULL) | ((uint64_t) (addr & 0xfff));
|
||||||
}
|
a64[i] = (uint32_t) a;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
mmu_perm = page_lookupp[addr >> 12];
|
||||||
|
|
||||||
addr++;
|
addr++;
|
||||||
}
|
}
|
||||||
@@ -2871,6 +2869,35 @@ mem_init(void)
|
|||||||
writelookupp = malloc((1 << 20) * sizeof(uint8_t));
|
writelookupp = malloc((1 << 20) * sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
umc_page_recalc(uint32_t c, int set)
|
||||||
|
{
|
||||||
|
if (set) {
|
||||||
|
pages[c].mem = &ram[(c & 0xff) << 12];
|
||||||
|
pages[c].write_b = mem_write_ramb_page;
|
||||||
|
pages[c].write_w = mem_write_ramw_page;
|
||||||
|
pages[c].write_l = mem_write_raml_page;
|
||||||
|
} else {
|
||||||
|
pages[c].mem = page_ff;
|
||||||
|
pages[c].write_b = NULL;
|
||||||
|
pages[c].write_w = NULL;
|
||||||
|
pages[c].write_l = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_NEW_DYNAREC
|
||||||
|
pages[c].evict_prev = EVICT_NOT_IN_LIST;
|
||||||
|
pages[c].byte_dirty_mask = &byte_dirty_mask[(c & 0xff) * 64];
|
||||||
|
pages[c].byte_code_present_mask = &byte_code_present_mask[(c & 0xff) * 64];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
umc_smram_recalc(uint32_t start, int set)
|
||||||
|
{
|
||||||
|
for (uint32_t c = start; c < (start + 0x0020); c++)
|
||||||
|
umc_page_recalc(c, set);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mem_remap_top(int kb)
|
mem_remap_top(int kb)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user