CHDK_DE Vorschauversion  Trunk Rev. 5273
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
reboot.c-Dateireferenz
#include "stdlib.h"
#include "lolevel.h"
+ Include-Abhängigkeitsdiagramm für reboot.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define LOW_LEVEL
 

Funktionen

int reboot (const char *bootfile)
 

Makro-Dokumentation

#define LOW_LEVEL

Definiert in Zeile 2 der Datei reboot.c.

Dokumentation der Funktionen

int reboot ( const char *  bootfile)

Definiert in Zeile 20 der Datei reboot.c.

20  {
21 #ifndef THUMB_FW
22  if(bootfile == NULL)
23 #endif
24  {
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  // if _reboot_fw_update returns, it failed or is not implemented
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  // use open/read etc since it takes less mem, boot image might be large
44  fd = open(bootfile,O_RDONLY,0);
45  if(fd == -1) {
46  return 0;
47  }
48  size = lseek(fd,0,SEEK_END);
49  // error or less than 1 instruction
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  }
76  _Restart(7);
77  canon_copy_and_restart((void *)0x1900,buf,size,(void *)0x1900);
78 #else
79  return 0;
80 #endif // THUMB_FW
81 }