Changeset 940


Ignore:
Timestamp:
09/15/10 07:04:32 (3 years ago)
Author:
reyalp
Message:

d10 clean up resetcode, use full initialization code in boot, use new style dryos task hook

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loader/d10/resetcode/main.c

    r897 r940  
    77 */ 
    88 
    9 #define DP (void *)0xC0220130 // RED led (wiki) 
     9#define DP (void *)0xC0220130 // RED led 
    1010#define DELAY 5000000 
    1111 
    1212void __attribute__((noreturn)) copy_and_restart(void *dst_void, const void *src_void, long length) { 
    1313 
     14 
     15        // DEBUG: blink led 
     16                /* 
    1417        volatile unsigned *p = (void*)DP;        
    1518 
    1619        int counter; 
    1720 
    18         // DEBUG: blink led 
    19                 /* 
    2021        counter = DELAY; *p = 0x46;  while (counter--) { asm("nop\n nop\n"); }; 
    2122        counter = DELAY; *p = 0x44;  while (counter--) { asm("nop\n nop\n"); }; 
     
    5354        // DEBUG: jump to regular firmware-boot (causing a boot loop) 
    5455        //dst_void = (void*) 0xFF810000; 
     56 
     57                // restart function 
     58                // from sub_FF828E54 via 0x12345678 and "FirmUpgrade.c" 
    5559        asm volatile ( 
    5660                "MRS     R0, CPSR\n" 
     
    7680                "STR     R0, [R1,#0xDC]\n" 
    7781                "STR     R0, [R1,#0xEC]\n" 
    78                 "CMP     R4, #7\n" // ??? 
     82//              "CMP     R4, #7\n" 
    7983                "STR     R0, [R1,#0xFC]\n" 
    80                 "LDMEQFD SP!, {R4,PC}\n" //??? 
     84//              "LDMEQFD SP!, {R4,PC}\n" 
    8185                "MOV     R0, #0x78\n" 
     86                "MCR     p15, 0, R0,c1,c0\n" // disable caches and TCM 
     87                "MOV     R0, #0\n" 
     88                "MCR     p15, 0, R0,c7,c10, 4\n" // drain write buffer 
     89                "MCR     p15, 0, R0,c7,c5\n" // flush instruction cache 
     90                "MCR     p15, 0, R0,c7,c6\n" // flushd data cache 
     91                "MOV     R0, #0x80000006\n" 
     92                "MCR     p15, 0, R0,c9,c1\n" // set data TCM at 0x80000000, 4kb 
     93                "MCR     p15, 0, R0,c9,c1, 1\n" // instruction TCM (DDIO201D says should only write zero as base ...) 
     94                "MRC     p15, 0, R0,c1,c0\n" // read control state 
     95                "ORR     R0, R0, #0x50000\n" // enable both TCM 
    8296                "MCR     p15, 0, R0,c1,c0\n" 
    83                 "MOV     R0, #0\n" 
    84                 "MCR     p15, 0, R0,c7,c10, 4\n" 
    85                 "MCR     p15, 0, R0,c7,c5\n" 
    86                 "MCR     p15, 0, R0,c7,c6\n" 
    87                 "MOV     R0, #0x80000006\n" 
    88                 "MCR     p15, 0, R0,c9,c1\n" 
    89                 "MCR     p15, 0, R0,c9,c1, 1\n" 
    90                 "MRC     p15, 0, R0,c1,c0\n" 
    91                 "ORR     R0, R0, #0x50000\n" 
    92                 "MCR     p15, 0, R0,c1,c0\n" 
    93                 "LDR     R0, =0x12345678\n" 
     97                "LDR     R0, =0x12345678\n"  // marker value stored in TCM 
    9498                "MOV     R1, #0x80000000\n" 
    9599                "STR     R0, [R1,#0xFFC]\n" 
    96100//              "LDR     R0, =loc_FF810000\n" 
    97101                "mov     R0, %0\n" 
    98                 "LDMFD   SP!, {R4,LR}\n" //??? 
     102//              "LDMFD   SP!, {R4,LR}\n" 
    99103                "BX      R0\n" 
    100104                : : "r"(dst_void) : "memory","r0","r1","r2","r3","r4"); 
  • trunk/platform/d10/sub/100a/boot.c

    r938 r940  
    22#include "platform.h" 
    33#include "core.h" 
     4#include "dryos31.h" 
     5 
     6#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) 
    47 
    58const char * const new_sa = &_end; 
     
    1417void task_CaptSeqTask_my(); 
    1518 
    16 void taskCreateHook(int *p) {  
    17  p-=17; 
    18  if (p[0]==0xFF87B84C)  p[0]=(int)init_file_modules_task; 
    19  if (p[0]==0xFF860F34)  p[0]=(int)task_CaptSeqTask_my; 
    20  if (p[0]==0xFF92F5C8)  p[0]=(int)movie_record_task; 
    21 } 
    22  
    23 /* 
    24 void taskCreateHook2(int *p) { 
    25  p-=17; 
    26 } 
    27 */ 
    28  
     19void taskHook(context_t **context) {  
     20 task_t *tcb=(task_t*)((char*)context-offsetof(task_t, context)); 
     21 
     22// physw is done directly to avoid wasting stack space 
     23// if(!_strcmp(tcb->name, "PhySw"))           tcb->entry = (void*)mykbd_task;  
     24 if(!_strcmp(tcb->name, "CaptSeqTask"))     tcb->entry = (void*)task_CaptSeqTask_my;  
     25 if(!_strcmp(tcb->name, "InitFileModules")) tcb->entry = (void*)init_file_modules_task; 
     26 if(!_strcmp(tcb->name, "MovieRecord"))     tcb->entry = (void*)movie_record_task; 
     27// not implemented yet 
     28// if(!_strcmp(tcb->name, "ExpDrvTask"))      tcb->entry = (void*)exp_drv_task; 
     29} 
    2930 
    3031#define DEBUG_LED ((unsigned volatile *)0xC0220130) // RED 
    3132#define GREEN_LED ((unsigned volatile *)0xC0220134) // GREEN 
     33 
    3234void boot() { 
    33     long *canon_data_src = (void*)0xFFB4EFA4; 
    34     long *canon_data_dst = (void*)0x1900; 
    35     long canon_data_len = 0xCDA0 - 0x1900; // data_end - data_start 
    36     long *canon_bss_start = (void*)0xCDA0; // just after data  
    37     long canon_bss_len = 0x146A2C - 0xCDA0;  
    38  
    39     long i; 
    40  
    41         *DEBUG_LED = 0x44; 
    42         *GREEN_LED = 0x46; 
    43  
    44     // enable caches and write buffer... this is a carryover from old dryos ports, may not be useful 
    45     asm volatile ( 
    46         "MRC     p15, 0, R0,c1,c0\n" 
    47         "ORR     R0, R0, #0x1000\n" 
    48         "ORR     R0, R0, #4\n" 
    49         "ORR     R0, R0, #1\n" 
    50         "MCR     p15, 0, R0,c1,c0\n" 
    51     :::"r0"); 
    52  
    53     for(i=0;i<canon_data_len/4;i++) 
    54         canon_data_dst[i]=canon_data_src[i]; 
    55  
    56     for(i=0;i<canon_bss_len/4;i++) 
    57         canon_bss_start[i]=0; 
     35        asm volatile( 
     36"                LDR     R1, =0xC0410000\n" 
     37"                MOV     R0, #0\n" 
     38"                STR     R0, [R1]\n" 
     39"                MOV     R1, #0x78\n" 
     40"                MCR     p15, 0, R1,c1,c0\n" 
     41"                MOV     R1, #0\n" 
     42"                MCR     p15, 0, R1,c7,c10, 4\n" 
     43"                MCR     p15, 0, R1,c7,c5\n" 
     44"                MCR     p15, 0, R1,c7,c6\n" 
     45"                MOV     R0, #0x3D\n" 
     46"                MCR     p15, 0, R0,c6,c0\n" 
     47"                MOV     R0, #0xC000002F\n" 
     48"                MCR     p15, 0, R0,c6,c1\n" 
     49"                MOV     R0, #0x33\n" 
     50"                MCR     p15, 0, R0,c6,c2\n" 
     51"                MOV     R0, #0x40000033\n" 
     52"                MCR     p15, 0, R0,c6,c3\n" 
     53"                MOV     R0, #0x80000017\n" 
     54"                MCR     p15, 0, R0,c6,c4\n" 
     55"                LDR     R0, =0xFF80002D\n" 
     56"                MCR     p15, 0, R0,c6,c5\n" 
     57"                MOV     R0, #0x34\n" 
     58"                MCR     p15, 0, R0,c2,c0\n" 
     59"                MOV     R0, #0x34\n" 
     60"                MCR     p15, 0, R0,c2,c0, 1\n" 
     61"                MOV     R0, #0x34\n" 
     62"                MCR     p15, 0, R0,c3,c0\n" 
     63"                LDR     R0, =0x3333330\n" 
     64"                MCR     p15, 0, R0,c5,c0, 2\n" 
     65"                LDR     R0, =0x3333330\n" 
     66"                MCR     p15, 0, R0,c5,c0, 3\n" 
     67"                MRC     p15, 0, R0,c1,c0\n" 
     68"                ORR     R0, R0, #0x1000\n" 
     69"                ORR     R0, R0, #4\n" 
     70"                ORR     R0, R0, #1\n" 
     71"                MCR     p15, 0, R0,c1,c0\n" 
     72"                MOV     R1, #0x80000006\n" 
     73"                MCR     p15, 0, R1,c9,c1\n" 
     74"                MOV     R1, #6\n" 
     75"                MCR     p15, 0, R1,c9,c1, 1\n" 
     76"                MRC     p15, 0, R1,c1,c0\n" 
     77"                ORR     R1, R1, #0x50000\n" 
     78"                MCR     p15, 0, R1,c1,c0\n" 
     79"                LDR     R2, =0xC0200000\n" 
     80"                MOV     R1, #1\n" 
     81"                STR     R1, [R2,#0x10C]\n" 
     82"                MOV     R1, #0xFF\n" 
     83"                STR     R1, [R2,#0xC]\n" 
     84"                STR     R1, [R2,#0x1C]\n" 
     85"                STR     R1, [R2,#0x2C]\n" 
     86"                STR     R1, [R2,#0x3C]\n" 
     87"                STR     R1, [R2,#0x4C]\n" 
     88"                STR     R1, [R2,#0x5C]\n" 
     89"                STR     R1, [R2,#0x6C]\n" 
     90"                STR     R1, [R2,#0x7C]\n" 
     91"                STR     R1, [R2,#0x8C]\n" 
     92"                STR     R1, [R2,#0x9C]\n" 
     93"                STR     R1, [R2,#0xAC]\n" 
     94"                STR     R1, [R2,#0xBC]\n" 
     95"                STR     R1, [R2,#0xCC]\n" 
     96"                STR     R1, [R2,#0xDC]\n" 
     97"                STR     R1, [R2,#0xEC]\n" 
     98"                STR     R1, [R2,#0xFC]\n" 
     99"                LDR     R1, =0xC0400008\n" 
     100"                LDR     R2, =0x430005\n" 
     101"                STR     R2, [R1]\n" 
     102"                MOV     R1, #1\n" 
     103"                LDR     R2, =0xC0243100\n" 
     104"                STR     R2, [R1]\n" 
     105"                LDR     R2, =0xC0242010\n" 
     106"                LDR     R1, [R2]\n" 
     107"                ORR     R1, R1, #1\n" 
     108"                STR     R1, [R2]\n" 
     109"                LDR     R0, =0xFFB4EFA4\n" 
     110"                LDR     R1, =0x1900\n" 
     111"                LDR     R3, =0xCDA0\n" 
     112"loc_FF81013C:\n" 
     113"                CMP     R1, R3\n" 
     114"                LDRCC   R2, [R0],#4\n" 
     115"                STRCC   R2, [R1],#4\n" 
     116"                BCC     loc_FF81013C\n" 
     117"                LDR     R1, =0x146A2C\n" 
     118"                MOV     R2, #0\n" 
     119"loc_FF810154:\n" 
     120"                CMP     R3, R1\n" 
     121"                STRCC   R2, [R3],#4\n" 
     122"                BCC     loc_FF810154\n" 
     123        ); 
    58124 
    59125// see http://chdk.setepontos.com/index.php/topic,2972.msg30712.html#msg30712 
    60126// this works for init_file_modules task in both play and rec mode 
    61     *(int*)0x1934=(int)taskCreateHook; 
     127    *(int*)0x1934=(int)taskHook; 
    62128// this does not start init_file_modules task ever 
    63 //    *(int*)0x1938=(int)taskCreateHook2; 
     129//    *(int*)0x1938=(int)taskHook; 
    64130 
    65131        // Search on 0x12345678 finds function called by sub_FF849EB0, values found there OK 
Note: See TracChangeset for help on using the changeset viewer.