Subversion Repositories freemyipod

Rev

Rev 436 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 436 Rev 961
Line 20... Line 20...
20
//
20
//
21
//
21
//
22
 
22
 
23
 
23
 
24
#include "global.h"
24
#include "global.h"
-
 
25
#include "bootflash.h"
25
#include "clickwheel.h"
26
#include "clickwheel.h"
-
 
27
#include "clockgates.h"
-
 
28
#include "s5l8702.h"
-
 
29
 
-
 
30
 
-
 
31
#define sysi ((uint8_t*)0x2203fdf8)
-
 
32
#define sysiword ((uint32_t*)0x2203fdf8)
26
 
33
 
27
 
34
 
28
void targetinit_late()
35
void targetinit_late()
29
{
36
{
-
 
37
    int i;
-
 
38
    
30
    clickwheel_init();
39
    clickwheel_init();
-
 
40
    
-
 
41
    uint8_t* nor = (uint8_t*)memalign(0x10, 0x1000);
-
 
42
    uint32_t* norword = (uint32_t*)nor;
-
 
43
    if (!nor) return;
-
 
44
    bootflash_readraw(nor, 0, 0x1000);
-
 
45
    uint32_t scfg_size = norword[1];
-
 
46
    uint32_t scfg_entrycount = norword[5];
-
 
47
    if (norword[0] == 0x53436667 && scfg_size <= 0x1000
-
 
48
     && scfg_entrycount * 0x14 + 0x18 == scfg_size)
-
 
49
    {
-
 
50
        memset(sysi, 0, 0x128);
-
 
51
        sysiword[0] = 0x53797349;
-
 
52
        sysiword[1] = 4;
-
 
53
        sysiword[0x22] = 0x414e;
-
 
54
        sysiword[0x38] = 0x4000000;
-
 
55
        sysiword[0x39] = 0x8000000;
-
 
56
        sysiword[0x3a] = 0x40000;
-
 
57
        sysiword[0x3b] = 0x22000000;
-
 
58
        sysiword[0x3c] = 0x100000;
-
 
59
        sysiword[0x3d] = 0x24000000;
-
 
60
        sysiword[0x46] = 0x7672736e;
-
 
61
        sysiword[0x47] = 0x1308004;
-
 
62
        sysiword[0x48] = 0x53797349;
-
 
63
        sysiword[0x49] = 0x2203fdf8;
-
 
64
        for (i = 0; i < scfg_entrycount; i++)
-
 
65
            switch (norword[6 + i * 5])
-
 
66
            {
-
 
67
                case 0x53724e6d: // SrNm
-
 
68
                    memcpy(&sysi[0x18], &norword[6 + i * 5 + 1], 16);
-
 
69
                    break;
-
 
70
                case 0x46774964: // FwId
-
 
71
                    memcpy(&sysi[0x38], &norword[6 + i * 5 + 2], 8);
-
 
72
                    break;
-
 
73
                case 0x48775672: // HwVr
-
 
74
                    sysiword[0x21] = norword[6 + i * 5 + 2];
-
 
75
                    break;
-
 
76
                case 0x5265676e: // Regn
-
 
77
                    if (nor[24 + i * 0x14 + 4] == 1 && nor[24 + i * 0x14 + 5] == 0)
-
 
78
                        memcpy(&sysi[0x92], &norword[6 + i * 5 + 2], 4);
-
 
79
                    break;
-
 
80
                case 0x4d6f6423: // Mod#
-
 
81
                    memcpy(&sysi[0x98], &norword[6 + i * 5 + 1], 16);
-
 
82
                    break;
-
 
83
                case 0x436f6463: // Codc
-
 
84
                    sysiword[0x45] = norword[6 + i * 5 + 1];
-
 
85
                    break;
-
 
86
                case 0x53775672: // SwVr
-
 
87
                    memcpy(&sysi[0x108], &norword[6 + i * 5 + 1], 16);
-
 
88
                    break;
-
 
89
            }
-
 
90
		switch (sysiword[0x21])
-
 
91
		{
-
 
92
			case 0x130100:
-
 
93
				sysiword[0x47] = 0x1308004;
-
 
94
				break;
-
 
95
			case 0x130200:
-
 
96
				sysiword[0x47] = 0x1708004;
-
 
97
				break;
-
 
98
		}
-
 
99
    }
-
 
100
    free(nor);
-
 
101
}
-
 
102
 
-
 
103
void targetinit_execfirmware() ICODE_ATTR;
-
 
104
void targetinit_execfirmware()
-
 
105
{
-
 
106
    clockgate_enable(CLOCKGATE_I2C_0, true);
-
 
107
    while (IIC10(0));
-
 
108
    IICCON(0) = 0x184;
31
}
109
}
-
 
110