blob: e9fc334730de52d99e8787a4316589af4833cfa6 (
plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#include "function_target.h"
#include "consts.h"
#include "OS_interrupt.h"
#include "OS_thread.h"
extern OSThreadQueue OSi_IrqThreadQueue;
ARM_FUNC void OS_InitIrqTable(void)
{
OS_InitThreadQueue(&OSi_IrqThreadQueue);
OSi_SetVBlankCount(0);
}
ARM_FUNC void OS_SetIrqFunction(OSIrqMask intrBit, OSIrqFunction function)
{
s32 i;
OSIrqCallbackInfo *info;
for (i = 0; i < 25; i++)
{
if (intrBit & 1)
{
info = NULL;
if (8 <= i && i <= 11)
{
info = &OSi_IrqCallbackInfo[i - 8];
}
else if (3 <= i && i <= 6)
{
info = &OSi_IrqCallbackInfo[i - 3 + 4];
}
else if (0 == i)
{
info = &OSi_IrqCallbackInfo[8];
}
else
{
OS_IRQTable[i] = function;
}
if (info)
{
info->func = (void (*)(void *))function;
info->arg = 0;
info->enable = TRUE;
}
}
intrBit >>= 1;
}
}
ARM_FUNC void OSi_EnterTimerCallback(u32 timerNo, void (*callback) (void *), void *arg)
{
OSIrqMask mask = 1UL << (timerNo + 3);
OSi_IrqCallbackInfo[timerNo + 4].func = callback;
OSi_IrqCallbackInfo[timerNo + 4].arg = arg;
(void)OS_EnableIrqMask(mask);
OSi_IrqCallbackInfo[timerNo + 4].enable = TRUE;
}
ARM_FUNC OSIrqMask OS_SetIrqMask(OSIrqMask mask)
{
u16 regIme = reg_OS_IME;
reg_OS_IME = 0;
OSIrqMask regIe = reg_OS_IE;
reg_OS_IE = mask;
u16 unused = reg_OS_IME; //needed because otherwise it doesn't match
reg_OS_IME = regIme;
return regIe;
}
ARM_FUNC OSIrqMask OS_EnableIrqMask(OSIrqMask mask)
{
u16 regIme = reg_OS_IME;
reg_OS_IME = 0;
OSIrqMask regIe = reg_OS_IE;
reg_OS_IE = regIe | mask;
u16 unused = reg_OS_IME;
reg_OS_IME = regIme;
return regIe;
}
ARM_FUNC OSIrqMask OS_DisableIrqMask(OSIrqMask mask)
{
u16 regIme = reg_OS_IME;
reg_OS_IME = 0;
OSIrqMask regIe = reg_OS_IE;
reg_OS_IE = regIe & ~mask;
u16 unused = reg_OS_IME;
reg_OS_IME = regIme;
return regIe;
}
ARM_FUNC OSIrqMask OS_ResetRequestIrqMask(OSIrqMask mask)
{
u16 regIme = reg_OS_IME;
reg_OS_IME = 0;
OSIrqMask regIf = reg_OS_IF;
reg_OS_IF = mask;
u16 unused = reg_OS_IME;
reg_OS_IME = regIme;
return regIf;
}
|