forked from iPodLinux-Community/iBoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcop.c
86 lines (63 loc) · 1.16 KB
/
cop.c
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
#include "cop.h"
#include "lcd.h"
#include "hw.h"
#include "sys/nix.h"
#include "sys/lcdll.h"
#include "sys/graphics.h"
int cop_execute(void (*function)())
{
hw_info info;
outl((unsigned int)function, IBOY_COP_HANDLER);
sys_ipod_hw_info(&info);
if(info.version==0x03)
outs(0xce, 0xcf004058);
else
outl(0x0, 0x60007004); //COP WAKEUP
return 1;
}
void cop_lcd_handler()
{
#ifdef USE_COP
while (!COP_STOPPED)
lcd_refreshline();
#endif
}
#ifndef OLD_KERNEL
void cop_lcd_gbc_handler()
{
#ifdef USE_COP
while (!COP_STOPPED)
lcd_gbc_refreshline();
#endif
}
#endif // OLD_KERNEL
void cop_init()
{
#ifdef USE_COP
outl(0, IBOY_COP_STATUS); // Not sure the dogs understand
#endif // We assume cop to be free here
}
void cop_begin()
{
#ifdef USE_COP
//err_msg("cop startup", 0);
COP_SETSTOP(0);
#ifndef OLD_KERNEL
if(hw.cgb /*&& sys_ipod_is_color()*/)
cop_execute(cop_lcd_gbc_handler);
else
#endif
cop_execute(cop_lcd_handler);
while(!(inl(IBOY_COP_STATUS) & IBOY_COP_RUNNING))
;
#endif
}
void cop_end()
{
#ifdef USE_COP
COP_SETSTOP(1);
while((inl(IBOY_COP_STATUS) & IBOY_COP_RUNNING))
;
//err_msg("cop stopped", 0);
#endif
}