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