| Index: embios/trunk/init.c |
| — | — | @@ -29,6 +29,7 @@ |
| 30 | 30 | #include "ucl.h"
|
| 31 | 31 | #include "util.h"
|
| 32 | 32 | #include "execimage.h"
|
| | 33 | +#include "targetinit.h"
|
| 33 | 34 | #ifdef HAVE_LCD
|
| 34 | 35 | #include "lcd.h"
|
| 35 | 36 | #include "lcdconsole.h"
|
| — | — | @@ -162,14 +163,14 @@ |
| 163 | 164 | void initthread()
|
| 164 | 165 | {
|
| 165 | 166 | cputs(CONSOLE_BOOT, welcomestring);
|
| 166 | | - #ifdef HAVE_I2C
|
| | 167 | +#ifdef HAVE_I2C
|
| 167 | 168 | i2c_init();
|
| 168 | | - #endif
|
| | 169 | +#endif
|
| 169 | 170 | power_init();
|
| 170 | | - #ifdef HAVE_USB
|
| | 171 | +#ifdef HAVE_USB
|
| 171 | 172 | usb_init();
|
| 172 | | - #endif
|
| 173 | | - #ifdef HAVE_STORAGE
|
| | 173 | +#endif
|
| | 174 | +#ifdef HAVE_STORAGE
|
| 174 | 175 | DEBUGF("Initializing storage drivers...");
|
| 175 | 176 | storage_init();
|
| 176 | 177 | DEBUGF("Initializing storage subsystem...");
|
| — | — | @@ -178,7 +179,10 @@ |
| 179 | 180 | disk_init();
|
| 180 | 181 | DEBUGF("Mounting partitions...");
|
| 181 | 182 | disk_mount_all();
|
| 182 | | - #endif
|
| | 183 | +#endif
|
| | 184 | +#ifdef HAVE_TARGETINIT_LATE
|
| | 185 | + targetinit_late();
|
| | 186 | +#endif
|
| 183 | 187 | DEBUGF("Finished initialisation sequence");
|
| 184 | 188 | boot();
|
| 185 | 189 | }
|
| — | — | @@ -186,12 +190,18 @@ |
| 187 | 191 | void init() INITCODE_ATTR;
|
| 188 | 192 | void init()
|
| 189 | 193 | {
|
| | 194 | +#ifdef HAVE_TARGETINIT_VERYEARLY
|
| | 195 | + targetinit_veryearly();
|
| | 196 | +#endif
|
| 190 | 197 | scheduler_init();
|
| 191 | 198 | console_init();
|
| 192 | | - #ifdef HAVE_LCD
|
| | 199 | +#ifdef HAVE_LCD
|
| 193 | 200 | lcd_init();
|
| 194 | 201 | lcdconsole_init();
|
| 195 | | - #endif
|
| | 202 | +#endif
|
| | 203 | +#ifdef HAVE_TARGETINIT_EARLY
|
| | 204 | + targetinit_early();
|
| | 205 | +#endif
|
| 196 | 206 | interrupt_init();
|
| 197 | 207 | thread_create(initthreadname, initthread, initstack,
|
| 198 | 208 | sizeof(initstack), USER_THREAD, 127, true);
|
| Index: embios/trunk/target/ipodnano2g/targetinit.c |
| — | — | @@ -0,0 +1,121 @@ |
| | 2 | +//
|
| | 3 | +//
|
| | 4 | +// Copyright 2010 TheSeven
|
| | 5 | +//
|
| | 6 | +//
|
| | 7 | +// This file is part of emBIOS.
|
| | 8 | +//
|
| | 9 | +// emBIOS is free software: you can redistribute it and/or
|
| | 10 | +// modify it under the terms of the GNU General Public License as
|
| | 11 | +// published by the Free Software Foundation, either version 2 of the
|
| | 12 | +// License, or (at your option) any later version.
|
| | 13 | +//
|
| | 14 | +// emBIOS is distributed in the hope that it will be useful,
|
| | 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| | 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| | 17 | +// See the GNU General Public License for more details.
|
| | 18 | +//
|
| | 19 | +// You should have received a copy of the GNU General Public License along
|
| | 20 | +// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
|
| | 21 | +//
|
| | 22 | +//
|
| | 23 | +
|
| | 24 | +
|
| | 25 | +#include "global.h"
|
| | 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 | +
|
| | 38 | + uint32_t scfg_size = norword[0x401];
|
| | 39 | + uint32_t scfg_entrycount = norword[0x405];
|
| | 40 | + if (norword[0x400] == 0x53436667 && scfg_size <= 0x1000
|
| | 41 | + && scfg_entrycount * 0x14 + 0x18 == scfg_size)
|
| | 42 | + {
|
| | 43 | + memset(sysi, 0, 0x104);
|
| | 44 | + sysiword[0] = 0x53797349;
|
| | 45 | + sysiword[1] = 0x104;
|
| | 46 | + sysiword[0x21] = 0x100000;
|
| | 47 | + for (i = 0; i < scfg_entrycount; i++)
|
| | 48 | + switch (norword[0x406 + i * 5])
|
| | 49 | + {
|
| | 50 | + case 0x48774e6d: // HwNm
|
| | 51 | + memcpy(&sysi[0x08], &norword[0x406 + i * 5 + 1], 16);
|
| | 52 | + break;
|
| | 53 | + case 0x48775672: // HwVr
|
| | 54 | + if (norword[0x406 + i * 5 + 1] == 0)
|
| | 55 | + sysiword[0x21] = norword[0x406 + i * 5 + 2];
|
| | 56 | + break;
|
| | 57 | + case 0x53724e6d: // SrNm
|
| | 58 | + memcpy(&sysi[0x18], &norword[0x406 + i * 5 + 1], 16);
|
| | 59 | + break;
|
| | 60 | + case 0x46774964: // FwId
|
| | 61 | + if (nor[0x1018 + i * 0x14 + 7] == 0)
|
| | 62 | + {
|
| | 63 | + memcpy(&sysi[0x38], &norword[0x406 + i * 5 + 2], 3);
|
| | 64 | + sysi[0x3b] = 2;
|
| | 65 | + sysiword[0xf] = 0xa2700;
|
| | 66 | + }
|
| | 67 | + else memcpy(&sysi[0x38], &norword[0x406 + i * 5 + 2], 8);
|
| | 68 | + memset(&sysi[0x40], 10, 0);
|
| | 69 | + break;
|
| | 70 | + case 0x556e7443: // UntC
|
| | 71 | + memcpy(&sysi[0xbc], &norword[0x406 + i * 5 + 1], 16);
|
| | 72 | + break;
|
| | 73 | + case 0x52746341: // RtcA
|
| | 74 | + if (norword[0x406 + i * 5 + 1] == 1)
|
| | 75 | + sysiword[0x80] = norword[0x406 + i * 5 + 2];
|
| | 76 | + break;
|
| | 77 | + case 0x42747279: // Btry
|
| | 78 | + if (norword[0x406 + i * 5 + 1] == 1)
|
| | 79 | + memcpy(&sysi[0x5c], &norword[0x406 + i * 5 + 2], 12);
|
| | 80 | + break;
|
| | 81 | + case 0x5265676e: // Regn
|
| | 82 | + if (nor[0x1018 + i * 0x14 + 4] == 1 && nor[0x1018 + i * 0x14 + 5] == 0)
|
| | 83 | + memcpy(&sysi[0x92], &norword[0x406 + i * 5 + 2], 4);
|
| | 84 | + break;
|
| | 85 | + case 0x4d6f6423: // Mod#
|
| | 86 | + memcpy(&sysi[0x98], &norword[0x406 + i * 5 + 1], 16);
|
| | 87 | + break;
|
| | 88 | + case 0x48774f31: // Hw01
|
| | 89 | + memcpy(&sysi[0xa8], &norword[0x406 + i * 5 + 1], 16);
|
| | 90 | + break;
|
| | 91 | + case 0x436f6e74: // Cont
|
| | 92 | + if (nor[0x1018 + i * 0x14 + 4] == 0 && nor[0x1018 + i * 0x14 + 5] == 0)
|
| | 93 | + {
|
| | 94 | + sysi[0xb8] = nor[0x1018 + i * 0x14 + 6];
|
| | 95 | + sysi[0xb9] = nor[0x1018 + i * 0x14 + 8];
|
| | 96 | + }
|
| | 97 | + break;
|
| | 98 | + case 0x426b4c74: // BkLt
|
| | 99 | + if (nor[0x1018 + i * 0x14 + 4] == 0xaa && nor[0x1018 + i * 0x14 + 5] == 0x55)
|
| | 100 | + {
|
| | 101 | + sysi[0xba] = nor[0x1018 + i * 0x14 + 6];
|
| | 102 | + sysi[0xbb] = nor[0x1018 + i * 0x14 + 8];
|
| | 103 | + }
|
| | 104 | + break;
|
| | 105 | + case 0x44726d56: // DrmV
|
| | 106 | + memcpy(&sysi[0xce], &norword[0x406 + i * 5 + 1], 16);
|
| | 107 | + break;
|
| | 108 | + }
|
| | 109 | + sysiword[2] = 0x646f5069;
|
| | 110 | + sysiword[3] = 0x36334e20;
|
| | 111 | + sysi[0x88] = 0x4e;
|
| | 112 | + sysi[0x89] = 0x41;
|
| | 113 | + sysiword[0x38] = 0x2000000;
|
| | 114 | + sysiword[0x39] = 0x8000000;
|
| | 115 | + sysiword[0x3a] = 0x2c000;
|
| | 116 | + sysiword[0x3b] = 0x22000000;
|
| | 117 | + sysiword[0x3c] = 0x100000;
|
| | 118 | + sysiword[0x3d] = 0x24000000;
|
| | 119 | + sysiword[0x4a] = 0x53797349;
|
| | 120 | + sysiword[0x4b] = 0x2202bdf0;
|
| | 121 | + }
|
| | 122 | +}
|
| Index: embios/trunk/target/ipodnano2g/target.h |
| — | — | @@ -34,7 +34,7 @@ |
| 35 | 35 | #define CPU_FREQ 191692800
|
| 36 | 36 |
|
| 37 | 37 |
|
| 38 | | -#define CONSOLE_BOOT 1
|
| | 38 | +#define CONSOLE_BOOT 3
|
| 39 | 39 |
|
| 40 | 40 |
|
| 41 | 41 | #define HAVE_USB
|
| — | — | @@ -59,5 +59,7 @@ |
| 60 | 60 | #define CONFIG_STORAGE STORAGE_NAND
|
| 61 | 61 | #define SECTOR_SIZE 2048
|
| 62 | 62 |
|
| | 63 | +#define HAVE_TARGETINIT_LATE
|
| 63 | 64 |
|
| | 65 | +
|
| 64 | 66 | #endif
|
| Index: embios/trunk/target/ipodnano4g/target.h |
| — | — | @@ -34,7 +34,7 @@ |
| 35 | 35 | #define CPU_FREQ 191692800
|
| 36 | 36 |
|
| 37 | 37 |
|
| 38 | | -#define CONSOLE_BOOT 1
|
| | 38 | +#define CONSOLE_BOOT 3
|
| 39 | 39 |
|
| 40 | 40 |
|
| 41 | 41 | #define HAVE_USB
|
| Index: embios/trunk/SOURCES |
| — | — | @@ -14,6 +14,7 @@ |
| 15 | 15 | target/ipodnano2g/clockgates.c
|
| 16 | 16 | target/ipodnano2g/bootflash.c
|
| 17 | 17 | target/ipodnano2g/backlight.c
|
| | 18 | +target/ipodnano2g/targetinit.c
|
| 18 | 19 | usb/synopsysotg.c
|
| 19 | 20 | #endif
|
| 20 | 21 |
|
| Index: embios/trunk/targetinit.h |
| — | — | @@ -0,0 +1,36 @@ |
| | 2 | +//
|
| | 3 | +//
|
| | 4 | +// Copyright 2010 TheSeven
|
| | 5 | +//
|
| | 6 | +//
|
| | 7 | +// This file is part of emBIOS.
|
| | 8 | +//
|
| | 9 | +// emBIOS is free software: you can redistribute it and/or
|
| | 10 | +// modify it under the terms of the GNU General Public License as
|
| | 11 | +// published by the Free Software Foundation, either version 2 of the
|
| | 12 | +// License, or (at your option) any later version.
|
| | 13 | +//
|
| | 14 | +// emBIOS is distributed in the hope that it will be useful,
|
| | 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| | 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| | 17 | +// See the GNU General Public License for more details.
|
| | 18 | +//
|
| | 19 | +// You should have received a copy of the GNU General Public License along
|
| | 20 | +// with emBIOS. If not, see <http://www.gnu.org/licenses/>.
|
| | 21 | +//
|
| | 22 | +//
|
| | 23 | +
|
| | 24 | +
|
| | 25 | +#ifndef __TARGETINIT_H__
|
| | 26 | +#define __TARGETINIT_H__
|
| | 27 | +
|
| | 28 | +
|
| | 29 | +#include "global.h"
|
| | 30 | +
|
| | 31 | +
|
| | 32 | +void targetinit_veryearly() INITCODE_ATTR;
|
| | 33 | +void targetinit_early() INITCODE_ATTR;
|
| | 34 | +void targetinit_late() INITCODE_ATTR;
|
| | 35 | +
|
| | 36 | +
|
| | 37 | +#endif |
| \ No newline at end of file |