Search
lxdream.org :: lxdream/src/mem.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mem.c
changeset 939:6f2302afeb89
prev934:3acd3b3ee6d1
next946:d41ee7994db7
author nkeynes
date Sat Jan 03 03:30:26 2009 +0000 (13 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change MMU work-in-progress
* Move SDRAM out into separate sdram.c
* Move all page-table management into mmu.c
* Convert UTLB management to use the new page-tables
* Rip out all calls to mmu_vma_to_phys_* and replace with direct access
file annotate diff log raw
1.1 --- a/src/mem.c Fri Dec 26 14:25:23 2008 +0000
1.2 +++ b/src/mem.c Sat Jan 03 03:30:26 2009 +0000
1.3 @@ -35,6 +35,10 @@
1.4 #include "mmio.h"
1.5 #include "dreamcast.h"
1.6
1.7 +#ifndef PAGE_SIZE
1.8 +#define PAGE_SIZE 4096
1.9 +#endif
1.10 +
1.11 sh4ptr_t *page_map = NULL;
1.12 mem_region_fn_t *ext_address_space = NULL;
1.13
1.14 @@ -91,6 +95,18 @@
1.15 return mem;
1.16 }
1.17
1.18 +void mem_unprotect( void *region, uint32_t size )
1.19 +{
1.20 + /* Force page alignment */
1.21 + uintptr_t i = (uintptr_t)region;
1.22 + uintptr_t mask = ~(PAGE_SIZE-1);
1.23 + void *ptr = (void *)(i & mask);
1.24 + size_t len = i & (PAGE_SIZE-1) + size;
1.25 + len = (len + (PAGE_SIZE-1)) & mask;
1.26 +
1.27 + int status = mprotect( ptr, len, PROT_READ|PROT_WRITE|PROT_EXEC );
1.28 + assert( status == 0 );
1.29 +}
1.30
1.31 void mem_init( void )
1.32 {
.