Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
126 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
6
//    This file is part of emBIOS.
7
//
8
//    emBIOS is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emBIOS is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "global.h"
132 theseven 25
#include "clickwheel.h"
126 theseven 26
 
27
 
28
#define nor ((uint8_t*)0x24000000)
29
#define norword ((uint32_t*)0x24000000)
30
#define sysi ((uint8_t*)0x2202bdf0)
31
#define sysiword ((uint32_t*)0x2202bdf0)
32
 
33
 
34
void targetinit_late()
35
{
36
    int i;
37
 
132 theseven 38
    clickwheel_init();
39
 
126 theseven 40
    uint32_t scfg_size = norword[0x401];
41
    uint32_t scfg_entrycount = norword[0x405];
42
    if (norword[0x400] == 0x53436667 && scfg_size <= 0x1000
43
     && scfg_entrycount * 0x14 + 0x18 == scfg_size)
44
    {
45
        memset(sysi, 0, 0x104);
46
        sysiword[0] = 0x53797349;
47
        sysiword[1] = 0x104;
48
        sysiword[0x21] = 0x100000;
49
        for (i = 0; i < scfg_entrycount; i++)
50
            switch (norword[0x406 + i * 5])
51
            {
52
                case 0x48774e6d: // HwNm
53
                    memcpy(&sysi[0x08], &norword[0x406 + i * 5 + 1], 16);
54
                    break;
55
                case 0x48775672: // HwVr
56
                    if (norword[0x406 + i * 5 + 1] == 0)
57
                        sysiword[0x21] = norword[0x406 + i * 5 + 2];
58
                    break;
59
                case 0x53724e6d: // SrNm
60
                    memcpy(&sysi[0x18], &norword[0x406 + i * 5 + 1], 16);
61
                    break;
62
                case 0x46774964: // FwId
63
                    if (nor[0x1018 + i * 0x14 + 7] == 0)
64
                    {
65
                        memcpy(&sysi[0x38], &norword[0x406 + i * 5 + 2], 3);
66
                        sysi[0x3b] = 2;
67
                        sysiword[0xf] = 0xa2700;
68
                    }
69
                    else memcpy(&sysi[0x38], &norword[0x406 + i * 5 + 2], 8);
70
                    memset(&sysi[0x40], 10, 0);
71
                    break;
72
                case 0x556e7443: // UntC
73
                    memcpy(&sysi[0xbc], &norword[0x406 + i * 5 + 1], 16);
74
                    break;
75
                case 0x52746341: // RtcA
76
                    if (norword[0x406 + i * 5 + 1] == 1)
77
                        sysiword[0x80] = norword[0x406 + i * 5 + 2];
78
                    break;
79
                case 0x42747279: // Btry
80
                    if (norword[0x406 + i * 5 + 1] == 1)
81
                        memcpy(&sysi[0x5c], &norword[0x406 + i * 5 + 2], 12);
82
                    break;
83
                case 0x5265676e: // Regn
84
                    if (nor[0x1018 + i * 0x14 + 4] == 1 && nor[0x1018 + i * 0x14 + 5] == 0)
85
                        memcpy(&sysi[0x92], &norword[0x406 + i * 5 + 2], 4);
86
                    break;
87
                case 0x4d6f6423: // Mod#
88
                    memcpy(&sysi[0x98], &norword[0x406 + i * 5 + 1], 16);
89
                    break;
90
                case 0x48774f31: // Hw01
91
                    memcpy(&sysi[0xa8], &norword[0x406 + i * 5 + 1], 16);
92
                    break;
93
                case 0x436f6e74: // Cont
94
                    if (nor[0x1018 + i * 0x14 + 4] == 0 && nor[0x1018 + i * 0x14 + 5] == 0)
95
                    {
96
                        sysi[0xb8] = nor[0x1018 + i * 0x14 + 6];
97
                        sysi[0xb9] = nor[0x1018 + i * 0x14 + 8];
98
                    }
99
                    break;
100
                case 0x426b4c74: // BkLt
101
                    if (nor[0x1018 + i * 0x14 + 4] == 0xaa && nor[0x1018 + i * 0x14 + 5] == 0x55)
102
                    {
103
                        sysi[0xba] = nor[0x1018 + i * 0x14 + 6];
104
                        sysi[0xbb] = nor[0x1018 + i * 0x14 + 8];
105
                    }
106
                    break;
107
                case 0x44726d56: // DrmV
108
                    memcpy(&sysi[0xce], &norword[0x406 + i * 5 + 1], 16);
109
                    break;
110
            }
111
        sysiword[2] = 0x646f5069;
112
        sysiword[3] = 0x36334e20;
113
        sysi[0x88] = 0x4e;
114
        sysi[0x89] = 0x41;
115
        sysiword[0x38] = 0x2000000;
116
        sysiword[0x39] = 0x8000000;
117
        sysiword[0x3a] = 0x2c000;
118
        sysiword[0x3b] = 0x22000000;
119
        sysiword[0x3c] = 0x100000;
120
        sysiword[0x3d] = 0x24000000;
121
        sysiword[0x4a] = 0x53797349;
122
        sysiword[0x4b] = 0x2202bdf0;
123
    }
124
}