CHDK_DE Vorschauversion  Trunk Rev. 5836
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
reboot.c-Dateireferenz
#include "stdlib.h"
#include "stddef.h"
#include "stdio.h"
#include "string.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 5 der Datei reboot.c.

Dokumentation der Funktionen

int reboot ( const char *  bootfile)

Definiert in Zeile 23 der Datei reboot.c.

23  {
24 #ifndef THUMB_FW
25  if(bootfile == NULL)
26 #endif
27  {
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  // if _reboot_fw_update returns, it failed or is not implemented
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  // use open/read etc since it takes less mem, boot image might be large
47  fd = open(bootfile,O_RDONLY,0);
48  if(fd == -1) {
49  return 0;
50  }
51  size = lseek(fd,0,SEEK_END);
52  // error or less than 1 instruction
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  }
79  _Restart(7);
80  canon_copy_and_restart((void *)0x1900,buf,size,(void *)0x1900);
81 #else
82  (void)bootfile;
83  return 0;
84 #endif // THUMB_FW
85 }