This source file includes following definitions.
- reboot
1 #include "stdlib.h"
2 #define LOW_LEVEL
3 #include "lolevel.h"
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 int reboot(const char *bootfile) {
21 #ifndef THUMB_FW
22 if(bootfile == NULL)
23 #endif
24 {
25 _TurnOffDisplay();
26 _Restart(0);
27 }
28 #ifndef THUMB_FW
29 int namelen=strlen(bootfile);
30 if(namelen > 3 && (strncmp(bootfile + namelen - 4,".FI",3) == 0)) {
31 _reboot_fw_update(bootfile);
32
33 return 0;
34 }
35
36 int fd;
37 int size;
38 int rcnt;
39 char *buf;
40 unsigned data_tcm;
41 void __attribute__((noreturn)) (*canon_copy_and_restart)(char *dst, char *src, unsigned length,char *start);
42
43
44 fd = open(bootfile,O_RDONLY,0);
45 if(fd == -1) {
46 return 0;
47 }
48 size = lseek(fd,0,SEEK_END);
49
50 if(size < 4) {
51 return 0;
52 }
53 buf = umalloc(size);
54 if(!buf) {
55 close(fd);
56 return 0;
57 }
58 lseek(fd,0,SEEK_SET);
59 rcnt = read(fd, buf, size);
60 close(fd);
61 if(rcnt != size) {
62 ufree(buf);
63 return 0;
64 }
65 asm volatile(
66 "MRC p15, 0, %0, c9, c1, 0\n"
67 : "=r" (data_tcm)
68 );
69 data_tcm &= 0xFFFFF000;
70 canon_copy_and_restart = (void *)(*(unsigned *)data_tcm);
71 if( ((unsigned)canon_copy_and_restart & 0xFFFF0000) != 0xFFFF0000) {
72 ufree(buf);
73 return 0;
74 }
75 _TurnOffDisplay();
76 _Restart(7);
77 canon_copy_and_restart((void *)0x1900,buf,size,(void *)0x1900);
78 #else
79 (void)bootfile;
80 return 0;
81 #endif
82 }
83
84