More verbose logging of page faults and bus errors

Fri, 04 Mar 2011 01:38:39 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Fri, 04 Mar 2011 01:38:39 +0000
changeset 106
dc7ae6e6c3aa
parent 105
343250338d23
child 107
566cfc70ef33

More verbose logging of page faults and bus errors

src/memory.c file | annotate | diff | revisions
     1.1 diff -r 343250338d23 -r dc7ae6e6c3aa src/memory.c
     1.2 --- a/src/memory.c	Fri Mar 04 01:37:42 2011 +0000
     1.3 +++ b/src/memory.c	Fri Mar 04 01:38:39 2011 +0000
     1.4 @@ -83,17 +83,24 @@
     1.5  
     1.6  	// If we're here, then we must be in User mode.
     1.7  	// Check that the user didn't access memory outside of the RAM area
     1.8 -	if (addr >= 0x400000)
     1.9 +	if (addr >= 0x400000) {
    1.10 +		LOGS("User accessed privileged memory");
    1.11  		return MEM_UIE;
    1.12 +	}
    1.13  
    1.14  	// User attempt to access the kernel
    1.15  	// A19, A20, A21, A22 low (kernel access): RAM addr before paging; not in Supervisor mode
    1.16 -	if (((addr >> 19) & 0x0F) == 0)
    1.17 +	if (((addr >> 19) & 0x0F) == 0) {
    1.18 +		LOGS("Attempt by user code to access kernel space");
    1.19  		return MEM_KERNEL;
    1.20 +	}
    1.21  
    1.22  	// Check page is write enabled
    1.23 -	if (writing && ((pagebits & 0x04) == 0))
    1.24 +	if (writing && ((pagebits & 0x04) == 0)) {
    1.25 +		LOG("Page not write enabled: inaddr %08X, page %04X, mapram %04X [%02X %02X], pagebits %d",
    1.26 +				addr, page, MAPRAM(page), state.map[page*2], state.map[(page*2)+1], pagebits);
    1.27  		return MEM_PAGE_NO_WE;
    1.28 +	}
    1.29  
    1.30  	// Page access allowed.
    1.31  	return MEM_ALLOWED;