Search
lxdream.org :: lxdream :: r488:d19a63e47cd9
lxdream 0.9.1
released Jun 29
Download Now
changeset488:d19a63e47cd9
parent487:b34abd796f5e
child489:45c8ddcf52cb
authornkeynes
dateSun Nov 04 01:03:00 2007 +0000 (12 years ago)
Change MAP_ANONYMOUS to MAP_ANON for bsd compatibility
src/mem.c
src/sh4/xltcache.c
1.1 --- a/src/mem.c Sat Nov 03 12:01:35 2007 +0000
1.2 +++ b/src/mem.c Sun Nov 04 01:03:00 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: mem.c,v 1.19 2007-10-31 11:53:35 nkeynes Exp $
1.6 + * $Id: mem.c,v 1.20 2007-11-04 01:03:00 nkeynes Exp $
1.7 * mem.c is responsible for creating and maintaining the overall system memory
1.8 * map, as visible from the SH4 processor.
1.9 *
1.10 @@ -17,6 +17,7 @@
1.11 */
1.12 #define MODULE mem_module
1.13
1.14 +#include <sys/types.h>
1.15 #include <sys/mman.h>
1.16 #include <sys/stat.h>
1.17 #include <assert.h>
1.18 @@ -49,7 +50,7 @@
1.19 void *mem_alloc_pages( int n )
1.20 {
1.21 void *mem = mmap( NULL, n * 4096,
1.22 - PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0 );
1.23 + PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0 );
1.24 if( mem == MAP_FAILED ) {
1.25 ERROR( "Memory allocation failure! (%s)", strerror(errno) );
1.26 return NULL;
1.27 @@ -61,7 +62,7 @@
1.28 void mem_init( void )
1.29 {
1.30 page_map = mmap( NULL, sizeof(char *) * PAGE_TABLE_ENTRIES,
1.31 - PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0 );
1.32 + PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0 );
1.33 if( page_map == MAP_FAILED ) {
1.34 ERROR( "Unable to allocate page map! (%s)", strerror(errno) );
1.35 page_map = NULL;
1.36 @@ -270,10 +271,11 @@
1.37 {
1.38 char *mem;
1.39 uint32_t calc_crc;
1.40 + int status;
1.41
1.42 mem = mem_get_region(base);
1.43 if( mem == NULL ) {
1.44 - mem = mmap( NULL, size, PROT_WRITE|PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0 );
1.45 + mem = mmap( NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_PRIVATE, -1, 0 );
1.46 if( mem == MAP_FAILED ) {
1.47 ERROR( "Unable to allocate ROM memory: %s (%s)", file, strerror(errno) );
1.48 return NULL;
1.49 @@ -283,14 +285,16 @@
1.50 mprotect( mem, size, PROT_READ|PROT_WRITE );
1.51 }
1.52
1.53 - mem_load_block( file, base, size );
1.54 + status = mem_load_block( file, base, size );
1.55 mprotect( mem, size, PROT_READ );
1.56
1.57 - /* CRC check */
1.58 - calc_crc = crc32(0L, (unsigned char *)mem, size);
1.59 - if( calc_crc != crc ) {
1.60 - WARN( "Bios CRC Mismatch in %s: %08X (expected %08X)",
1.61 - file, calc_crc, crc);
1.62 + if( status == 0 ) {
1.63 + /* CRC check only if we loaded something */
1.64 + calc_crc = crc32(0L, (unsigned char *)mem, size);
1.65 + if( calc_crc != crc ) {
1.66 + WARN( "Bios CRC Mismatch in %s: %08X (expected %08X)",
1.67 + file, calc_crc, crc);
1.68 + }
1.69 }
1.70
1.71 return mem;
2.1 --- a/src/sh4/xltcache.c Sat Nov 03 12:01:35 2007 +0000
2.2 +++ b/src/sh4/xltcache.c Sun Nov 04 01:03:00 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: xltcache.c,v 1.9 2007-10-07 06:27:12 nkeynes Exp $
2.6 + * $Id: xltcache.c,v 1.10 2007-11-04 01:03:00 nkeynes Exp $
2.7 *
2.8 * Translation cache management. This part is architecture independent.
2.9 *
2.10 @@ -15,7 +15,8 @@
2.11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.12 * GNU General Public License for more details.
2.13 */
2.14 -
2.15 +
2.16 +#include <sys/types.h>
2.17 #include <sys/mman.h>
2.18 #include <assert.h>
2.19
2.20 @@ -62,18 +63,18 @@
2.21 if( !xlat_initialized ) {
2.22 xlat_initialized = TRUE;
2.23 xlat_new_cache = mmap( NULL, XLAT_NEW_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
2.24 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
2.25 + MAP_PRIVATE|MAP_ANON, -1, 0 );
2.26 xlat_temp_cache = mmap( NULL, XLAT_TEMP_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
2.27 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
2.28 + MAP_PRIVATE|MAP_ANON, -1, 0 );
2.29 xlat_old_cache = mmap( NULL, XLAT_OLD_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
2.30 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
2.31 + MAP_PRIVATE|MAP_ANON, -1, 0 );
2.32 xlat_new_cache_ptr = xlat_new_cache;
2.33 xlat_temp_cache_ptr = xlat_temp_cache;
2.34 xlat_old_cache_ptr = xlat_old_cache;
2.35 xlat_new_create_ptr = xlat_new_cache;
2.36
2.37 xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
2.38 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
2.39 + MAP_PRIVATE|MAP_ANON, -1, 0);
2.40 memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );
2.41 }
2.42 xlat_flush_cache();
2.43 @@ -214,7 +215,7 @@
2.44 if( page == NULL ) {
2.45 xlat_lut[XLAT_LUT_PAGE(address)] = page =
2.46 mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,
2.47 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
2.48 + MAP_PRIVATE|MAP_ANON, -1, 0 );
2.49 memset( page, 0, XLAT_LUT_PAGE_SIZE );
2.50 }
2.51
2.52 @@ -351,7 +352,7 @@
2.53 if( xlat_lut[XLAT_LUT_PAGE(address)] == NULL ) {
2.54 xlat_lut[XLAT_LUT_PAGE(address)] =
2.55 mmap( NULL, XLAT_LUT_PAGE_SIZE, PROT_READ|PROT_WRITE,
2.56 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
2.57 + MAP_PRIVATE|MAP_ANON, -1, 0 );
2.58 memset( xlat_lut[XLAT_LUT_PAGE(address)], 0, XLAT_LUT_PAGE_SIZE );
2.59 }
2.60
.