source: trunk/loader/a470/main.c @ 2798

Revision 770, 1.4 KB checked in by reyalp, 4 years ago (diff)

a470 work from Mrspoon and Thorwak in http://chdk.setepontos.com/index.php/topic,3368.180.html

  • add 101a as a copy of 101b (needs confirmation)
  • other tweaks described in thread
  • Property svn:eol-style set to native
Line 
1static void __attribute__((noreturn)) shutdown();
2static void __attribute__((noreturn)) panic(int cnt);
3
4extern long *blob_chdk_core;
5extern long *blob_copy_and_reset;
6extern long blob_chdk_core_size;
7extern long blob_copy_and_reset_size;
8
9
10
11void __attribute__((noreturn)) my_restart()
12{
13    void __attribute__((noreturn)) (*copy_and_restart)(char *dst, char *src, long length);
14    int i;
15
16    for (i=0; i<(blob_copy_and_reset_size/sizeof(long)); i++){
17        ((long*)(RESTARTSTART))[i] = blob_copy_and_reset[i];
18    }
19
20    copy_and_restart = (void*)RESTARTSTART;
21    copy_and_restart((void*)MEMISOSTART, (char*)blob_chdk_core, blob_chdk_core_size);
22}
23
24#define LED_PR 0xc022008C
25
26static void __attribute__((noreturn)) shutdown()
27{
28    volatile long *p = (void*)0xc02200a0;     // http://chdk.setepontos.com/index.php/topic,3227.0.html - power switch?
29    //volatile long *p = (void*)LED_PR;
30       
31    asm(
32         "MRS     R1, CPSR\n"
33         "AND     R0, R1, #0x80\n"
34         "ORR     R1, R1, #0x80\n"
35         "MSR     CPSR_cf, R1\n"
36         :::"r1","r0");
37       
38    *p = 0x44;  // led off.
39
40    while(1);
41}
42
43static void __attribute__((noreturn)) panic(int cnt)
44{
45        volatile long *p=(void*)LED_PR;
46        int i;
47
48        for(;cnt>0;cnt--){
49                p[0]=0x46;
50
51                for(i=0;i<0x200000;i++){
52                        asm ("nop\n");
53                        asm ("nop\n");
54                }
55                p[0]=0x44;
56                for(i=0;i<0x200000;i++){
57                        asm ("nop\n");
58                        asm ("nop\n");
59                }
60        }
61        shutdown();
62}
Note: See TracBrowser for help on using the repository browser.