Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8327 maxcodehac 1
#include "pxa255_IC.h"
2
#include "mem.h"
3
 
4
 
5
static void pxa255icPrvHandleChanges(Pxa255ic* ic){
6
 
7
	Boolean nowIrq, nowFiq;
8
	UInt32 unmasked = ic->ICPR & ic->ICMR;
9
 
10
	nowFiq = (unmasked & ic->ICLR) != 0;
11
	nowIrq = (unmasked & ~ic->ICLR) != 0;
12
 
13
	if(nowFiq != ic->wasFiq) cpuIrq(ic->cpu, true, nowFiq);
14
	if(nowIrq != ic->wasIrq) cpuIrq(ic->cpu, false, nowIrq);
15
 
16
	ic->wasFiq = nowFiq;
17
	ic->wasIrq = nowIrq;
18
}
19
 
20
static Boolean pxa255icPrvMemAccessF(void* userData, UInt32 pa, UInt8 size, Boolean write, void* buf){
21
 
22
	Pxa255ic* ic = userData;
23
	UInt32 val = 0;
24
 
25
	if(size != 4) {
26
		err_str(__FILE__ ": Unexpected ");
27
	//	err_str(write ? "write" : "read");
28
	//	err_str(" of ");
29
	//	err_dec(size);
30
	//	err_str(" bytes to 0x");
31
	//	err_hex(pa);
32
	//	err_str("\r\n");
33
		return true;		//we do not support non-word accesses
34
	}
35
 
36
	pa = (pa - PXA255_IC_BASE) >> 2;
37
 
38
	if(write){
39
		if(pa == 1) ic->ICMR = *(UInt32*)buf;
40
		else if(pa == 2) ic->ICLR = *(UInt32*)buf;
41
		else if(pa == 5) ic->ICCR = *(UInt32*)buf;
42
		else return true;
43
		pxa255icPrvHandleChanges(ic);
44
	}
45
	else{
46
		switch(pa){
47
 
48
			case 0:
49
				val = ic->ICPR & ic->ICMR & ~ic->ICLR;
50
				break;
51
 
52
			case 1:
53
				val = ic->ICMR;
54
				break;
55
 
56
			case 2:
57
				val = ic->ICLR;
58
				break;
59
 
60
			case 3:
61
				val = ic->ICPR & ic->ICMR & ic->ICLR;
62
				break;
63
 
64
			case 4:
65
				val = ic->ICPR;
66
				break;
67
 
68
			case 5:
69
				val = ic->ICCR;
70
				break;
71
 
72
		}
73
		*(UInt32*)buf = val;
74
	}
75
	return true;
76
}
77
 
78
Boolean pxa255icInit(Pxa255ic* ic, ArmCpu* cpu, ArmMem* physMem){
79
 
80
	__mem_zero(ic, sizeof(Pxa255ic));
81
	ic->cpu = cpu;
82
	return memRegionAdd(physMem, PXA255_IC_BASE, PXA255_IC_SIZE, pxa255icPrvMemAccessF, ic);
83
}
84
 
85
 
86
void pxa255icInt(Pxa255ic* ic, UInt8 intNum, Boolean raise){		//interrupt caused by emulated hardware
87
 
88
	UInt32 old_, new_;
89
 
90
	old_ = new_ = ic->ICPR;
91
 
92
	if(raise) new_ |= (1UL << intNum);
93
	else new_ &=~ (1UL << intNum);
94
 
95
	if(new_ != old_){
96
		ic->ICPR = new_;
97
		pxa255icPrvHandleChanges(ic);
98
	}
99
}
100