dont use explicit page size, use TARGET_PAGE_SIZE

This commit is contained in:
Chris Eagle 2015-08-30 21:24:14 -07:00
parent 24dde77ec2
commit 410e317e92
2 changed files with 9 additions and 9 deletions

View file

@ -49,7 +49,7 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
{ {
target_ulong addr; target_ulong addr;
//make sure all pages associated with the MemoryRegion are flushed //make sure all pages associated with the MemoryRegion are flushed
for (addr = mr->addr; addr < mr->end; addr += 0x1000) { for (addr = mr->addr; addr < mr->end; addr += TARGET_PAGE_SIZE) {
tlb_flush_page(uc->current_cpu, addr); tlb_flush_page(uc->current_cpu, addr);
} }
mr->enabled = false; mr->enabled = false;

16
uc.c
View file

@ -32,8 +32,8 @@
#include "qemu/include/hw/boards.h" #include "qemu/include/hw/boards.h"
//keep this a power of two! //keep this a power of two!
#define UC_BLOCK_SIZE 0x1000 #define UC_PAGE_SIZE 0x1000
#define UC_ALIGN_MASK (UC_BLOCK_SIZE - 1) #define UC_ALIGN_MASK (UC_PAGE_SIZE - 1)
static uint8_t *copy_region(uch uc, MemoryRegion *mr); static uint8_t *copy_region(uch uc, MemoryRegion *mr);
static bool split_region(uch handle, MemoryRegion *mr, uint64_t address, size_t size, bool do_delete); static bool split_region(uch handle, MemoryRegion *mr, uint64_t address, size_t size, bool do_delete);
@ -629,11 +629,11 @@ uc_err uc_mem_map(uch handle, uint64_t address, size_t size, uint32_t perms)
// invalid memory mapping // invalid memory mapping
return UC_ERR_MAP; return UC_ERR_MAP;
// address must be aligned to UC_BLOCK_SIZE // address must be aligned to UC_PAGE_SIZE
if ((address & UC_ALIGN_MASK) != 0) if ((address & UC_ALIGN_MASK) != 0)
return UC_ERR_MAP; return UC_ERR_MAP;
// size must be multiple of UC_BLOCK_SIZE // size must be multiple of UC_PAGE_SIZE
if ((size & UC_ALIGN_MASK) != 0) if ((size & UC_ALIGN_MASK) != 0)
return UC_ERR_MAP; return UC_ERR_MAP;
@ -773,11 +773,11 @@ uc_err uc_mem_protect(uch handle, uint64_t address, size_t size, uint32_t perms)
// invalid memory mapping // invalid memory mapping
return UC_ERR_MAP; return UC_ERR_MAP;
// address must be aligned to UC_BLOCK_SIZE // address must be aligned to UC_PAGE_SIZE
if ((address & UC_ALIGN_MASK) != 0) if ((address & UC_ALIGN_MASK) != 0)
return UC_ERR_MAP; return UC_ERR_MAP;
// size must be multiple of UC_BLOCK_SIZE // size must be multiple of UC_PAGE_SIZE
if ((size & UC_ALIGN_MASK) != 0) if ((size & UC_ALIGN_MASK) != 0)
return UC_ERR_MAP; return UC_ERR_MAP;
@ -833,11 +833,11 @@ uc_err uc_mem_unmap(uch handle, uint64_t address, size_t size)
// nothing to unmap // nothing to unmap
return UC_ERR_OK; return UC_ERR_OK;
// address must be aligned to UC_BLOCK_SIZE // address must be aligned to UC_PAGE_SIZE
if ((address & UC_ALIGN_MASK) != 0) if ((address & UC_ALIGN_MASK) != 0)
return UC_ERR_MAP; return UC_ERR_MAP;
// size must be multiple of UC_BLOCK_SIZE // size must be multiple of UC_PAGE_SIZE
if ((size & UC_ALIGN_MASK) != 0) if ((size & UC_ALIGN_MASK) != 0)
return UC_ERR_MAP; return UC_ERR_MAP;