source: trunk/loader/a800/main.c @ 1723

Revision 1723, 1.4 KB checked in by reyalp, 2 years ago (diff)

a800 100a port from mland, patch by waterwings in http://chdk.setepontos.com/index.php?topic=650.msg81174#msg81174

  • 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
10void __attribute__((noreturn)) my_restart()
11{
12    void __attribute__((noreturn)) (*copy_and_restart)(char *dst, char *src, long length);//declara referência à função
13    int i;
14
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;//a função foi copiada para cá
21    copy_and_restart((void*)MEMISOSTART, (char*)blob_chdk_core, blob_chdk_core_size);//agora chama a dita cuja
22}
23
24#define LED_PR 0xc0220088   //vide entry.S
25
26static void __attribute__((noreturn)) shutdown()
27{
28    volatile long *p = (void*)0xc02200a0;
29       
30    asm(
31         "MRS     R1, CPSR\n"
32         "AND     R0, R1, #0x80\n"
33         "ORR     R1, R1, #0x80\n"
34         "MSR     CPSR_cf, R1\n"
35         :::"r1","r0");
36       
37    *p = 0x44;
38
39    while(1);
40}
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.