Subversion Repositories freemyipod

Rev

Go to most recent revision | 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"
25
 
26
 
27
#define nor ((uint8_t*)0x24000000)
28
#define norword ((uint32_t*)0x24000000)
29
#define sysi ((uint8_t*)0x2202bdf0)
30
#define sysiword ((uint32_t*)0x2202bdf0)
31
 
32
 
33
void targetinit_late()
34
{
35
    int i;
36
 
37
    uint32_t scfg_size = norword[0x401];
38
    uint32_t scfg_entrycount = norword[0x405];
39
    if (norword[0x400] == 0x53436667 && scfg_size <= 0x1000
40
     && scfg_entrycount * 0x14 + 0x18 == scfg_size)
41
    {
42
        memset(sysi, 0, 0x104);
43
        sysiword[0] = 0x53797349;
44
        sysiword[1] = 0x104;
45
        sysiword[0x21] = 0x100000;
46
        for (i = 0; i < scfg_entrycount; i++)
47
            switch (norword[0x406 + i * 5])
48
            {
49
                case 0x48774e6d: // HwNm
50
                    memcpy(&sysi[0x08], &norword[0x406 + i * 5 + 1], 16);
51
                    break;
52
                case 0x48775672: // HwVr
53
                    if (norword[0x406 + i * 5 + 1] == 0)
54
                        sysiword[0x21] = norword[0x406 + i * 5 + 2];
55
                    break;
56
                case 0x53724e6d: // SrNm
57
                    memcpy(&sysi[0x18], &norword[0x406 + i * 5 + 1], 16);
58
                    break;
59
                case 0x46774964: // FwId
60
                    if (nor[0x1018 + i * 0x14 + 7] == 0)
61
                    {
62
                        memcpy(&sysi[0x38], &norword[0x406 + i * 5 + 2], 3);
63
                        sysi[0x3b] = 2;
64
                        sysiword[0xf] = 0xa2700;
65
                    }
66
                    else memcpy(&sysi[0x38], &norword[0x406 + i * 5 + 2], 8);
67
                    memset(&sysi[0x40], 10, 0);
68
                    break;
69
                case 0x556e7443: // UntC
70
                    memcpy(&sysi[0xbc], &norword[0x406 + i * 5 + 1], 16);
71
                    break;
72
                case 0x52746341: // RtcA
73
                    if (norword[0x406 + i * 5 + 1] == 1)
74
                        sysiword[0x80] = norword[0x406 + i * 5 + 2];
75
                    break;
76
                case 0x42747279: // Btry
77
                    if (norword[0x406 + i * 5 + 1] == 1)
78
                        memcpy(&sysi[0x5c], &norword[0x406 + i * 5 + 2], 12);
79
                    break;
80
                case 0x5265676e: // Regn
81
                    if (nor[0x1018 + i * 0x14 + 4] == 1 && nor[0x1018 + i * 0x14 + 5] == 0)
82
                        memcpy(&sysi[0x92], &norword[0x406 + i * 5 + 2], 4);
83
                    break;
84
                case 0x4d6f6423: // Mod#
85
                    memcpy(&sysi[0x98], &norword[0x406 + i * 5 + 1], 16);
86
                    break;
87
                case 0x48774f31: // Hw01
88
                    memcpy(&sysi[0xa8], &norword[0x406 + i * 5 + 1], 16);
89
                    break;
90
                case 0x436f6e74: // Cont
91
                    if (nor[0x1018 + i * 0x14 + 4] == 0 && nor[0x1018 + i * 0x14 + 5] == 0)
92
                    {
93
                        sysi[0xb8] = nor[0x1018 + i * 0x14 + 6];
94
                        sysi[0xb9] = nor[0x1018 + i * 0x14 + 8];
95
                    }
96
                    break;
97
                case 0x426b4c74: // BkLt
98
                    if (nor[0x1018 + i * 0x14 + 4] == 0xaa && nor[0x1018 + i * 0x14 + 5] == 0x55)
99
                    {
100
                        sysi[0xba] = nor[0x1018 + i * 0x14 + 6];
101
                        sysi[0xbb] = nor[0x1018 + i * 0x14 + 8];
102
                    }
103
                    break;
104
                case 0x44726d56: // DrmV
105
                    memcpy(&sysi[0xce], &norword[0x406 + i * 5 + 1], 16);
106
                    break;
107
            }
108
        sysiword[2] = 0x646f5069;
109
        sysiword[3] = 0x36334e20;
110
        sysi[0x88] = 0x4e;
111
        sysi[0x89] = 0x41;
112
        sysiword[0x38] = 0x2000000;
113
        sysiword[0x39] = 0x8000000;
114
        sysiword[0x3a] = 0x2c000;
115
        sysiword[0x3b] = 0x22000000;
116
        sysiword[0x3c] = 0x100000;
117
        sysiword[0x3d] = 0x24000000;
118
        sysiword[0x4a] = 0x53797349;
119
        sysiword[0x4b] = 0x2202bdf0;
120
    }
121
}