File: cache.c

package info (click to toggle)
skyeye 1.2.5-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,236 kB
  • ctags: 19,345
  • sloc: ansic: 90,379; sh: 5,188; python: 707; cpp: 417; makefile: 322; exp: 38
file content (26 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "instr.h"
#include "emul.h"

int 
decode_cache(MIPS_State* mstate, Instr instr) //Use in Cache Instruction, it's unuseable in R3000
{
    	// CP0 is usable in kernel mode or when the CU bit in SR is set.
    	if (!(mstate->mode & kmode) && !bit(mstate->cp0[SR], SR_CU0))
		process_coprocessor_unusable(mstate, 0);
	
    	VA va = sign_extend_UInt32(offset(instr), 16) + mstate->gpr[base(instr)];
    	PA pa;
	if(translate_vaddr(mstate, va, cache_op, &pa) != 0){
		return nothing_special;
	}
    	if (pa != bad_pa) {
		if (bit(instr, 16)) {
	    		// Control data cache.
	    		control_dcache(mstate, va, pa, bits(instr, 20, 18), bit(instr, 17));
		} else {
	    		// Control instruction cache.
	    		control_icache(mstate, va, pa, bits(instr, 20, 18), bit(instr, 17));
		}
    	}
    	return nothing_special;
}