freemyipod r140 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r139‎ | r140 | r141 >
Date:01:16, 15 August 2010
Author:theseven
Status:new
Tags:
Comment:
Fix a bunch of bugs
Modified paths:
  • /apps/iloader/Makefile (modified) (history)
  • /apps/iloader/main.c (modified) (history)
  • /embios/trunk/arm/contextswitch.S (modified) (history)
  • /embios/trunk/init.c (modified) (history)

Diff [purge]

Index: apps/iloader/main.c
@@ -9,7 +9,7 @@
1010 uint16_t backdrop[240 * 320];
1111
1212 uint32_t config[0x4000];
13 -uint32_t nordir[0x200];
 13+uint32_t nordir[0x400];
1414
1515 struct mutex eventmtx;
1616 struct wakeup eventwakeup;
@@ -197,7 +197,8 @@
198198 {
199199 if (bootflash_is_memmapped)
200200 {
201 - if (ucl_decompress(filename, size, (void*)config[pc + 1], &size))
 201+ if (ucl_decompress(bootflash_getaddr(filename), size,
 202+ (void*)config[pc + 1], &size))
202203 pc = errhandler;
203204 else pc += 3;
204205 }
Index: apps/iloader/Makefile
@@ -77,10 +77,10 @@
7878 build/version.h: version.h .svn/entries
7979 @echo [PP] $<
8080 ifeq ($(shell uname),WindowsNT)
81 - @-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
 81+ @-if not exist build md build
8282 @sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
8383 else
84 - @-mkdir -p $$(dir $$@)
 84+ @-mkdir -p build
8585 @sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
8686 endif
8787
Index: embios/trunk/init.c
@@ -57,13 +57,16 @@
5858 bool trydataflash;
5959 char dataflashpath[256];
6060 bool dataflashflags;
 61+ void* dataflashdest;
6162 bool trybootflash;
6263 char bootimagename[8];
6364 bool bootflashflags;
 65+ void* bootflashdest;
6466 bool trymemmapped;
6567 void* memmappedaddr;
6668 int memmappedsize;
6769 bool memmappedflags;
 70+ void* memmappeddest;
6871 };
6972
7073
@@ -71,7 +74,6 @@
7275 static const char initthreadname[] INITCONST_ATTR = "Initialization thread";
7376 static uint32_t initstack[0x400] INITSTACK_ATTR;
7477 extern int _loadspaceend;
75 -extern int _initstart;
7678 struct bootinfo_t bootinfo_src INITHEAD_ATTR =
7779 {
7880 .signature = "emBIboot",
@@ -96,10 +98,11 @@
9799 {
98100 void* addr = (void*)((((uint32_t)&_loadspaceend) - size) & ~(CACHEALIGN_SIZE - 1));
99101 if (read(fd, addr, size) != size) goto dataflashfailed;
100 - if (ucl_decompress(addr, size, &_initstart, (uint32_t*)&size)) goto dataflashfailed;
 102+ if (ucl_decompress(addr, size, bootinfo.dataflashdest, (uint32_t*)&size))
 103+ goto dataflashfailed;
101104 }
102 - else if (read(fd, &_initstart, size) != size) goto dataflashfailed;
103 - if (execimage(&_initstart) >= 0) return;
 105+ else if (read(fd, bootinfo.dataflashdest, size) != size) goto dataflashfailed;
 106+ if (execimage(bootinfo.dataflashdest) >= 0) return;
104107 }
105108 dataflashfailed:
106109 #endif
@@ -113,13 +116,14 @@
114117 if (!addr) goto bootflashfailed;
115118 if (bootinfo.bootflashflags & 1)
116119 {
117 - if (ucl_decompress(addr, size, &_initstart, (uint32_t*)&size)) goto bootflashfailed;
118 - if (execimage(&_initstart) >= 0) return;
 120+ if (ucl_decompress(addr, size, bootinfo.bootflashdest, (uint32_t*)&size))
 121+ goto bootflashfailed;
 122+ if (execimage(bootinfo.bootflashdest) >= 0) return;
119123 }
120124 else if (bootinfo.bootflashflags & 2)
121125 {
122 - memcpy(&_initstart, addr, size);
123 - if (execimage(&_initstart) >= 0) return;
 126+ memcpy(bootinfo.bootflashdest, addr, size);
 127+ if (execimage(bootinfo.bootflashdest) >= 0) return;
124128 }
125129 else if (execimage(addr) >= 0) return;
126130 #else
@@ -128,11 +132,12 @@
129133 void* addr = (void*)((((uint32_t)&_loadspaceend) - size) & ~(CACHEALIGN_SIZE - 1));
130134 if (bootflash_read(bootinfo.bootimagename, addr, 0, size) != size)
131135 goto bootflashfailed;
132 - if (ucl_decompress(addr, size, &_initstart, (uint32_t*)&size)) goto bootflashfailed;
 136+ if (ucl_decompress(addr, size, bootinfo.bootflashdest, (uint32_t*)&size))
 137+ goto bootflashfailed;
133138 }
134 - else if (bootflash_read(bootinfo.bootimagename, &_initstart, 0, size) != size)
 139+ else if (bootflash_read(bootinfo.bootimagename, bootinfo.bootflashdest, 0, size) != size)
135140 goto bootflashfailed;
136 - if (execimage(&_initstart) >= 0) return;
 141+ if (execimage(bootinfo.bootflashdest) >= 0) return;
137142 #endif
138143 }
139144 bootflashfailed:
@@ -142,14 +147,15 @@
143148 int size = bootinfo.memmappedsize;
144149 if (bootinfo.memmappedflags & 1)
145150 {
146 - if (ucl_decompress(bootinfo.memmappedaddr, size, &_initstart, (uint32_t*)&size))
 151+ if (ucl_decompress(bootinfo.memmappedaddr, size,
 152+ bootinfo.memmappeddest, (uint32_t*)&size))
147153 goto memmappedfailed;
148 - if (execimage(&_initstart) >= 0) return;
 154+ if (execimage(bootinfo.memmappeddest) >= 0) return;
149155 }
150156 else if (bootinfo.memmappedflags & 2)
151157 {
152 - memcpy(&_initstart, bootinfo.memmappedaddr, size);
153 - if (execimage(&_initstart) >= 0) return;
 158+ memcpy(bootinfo.memmappeddest, bootinfo.memmappedaddr, size);
 159+ if (execimage(bootinfo.memmappeddest) >= 0) return;
154160 }
155161 else if (execimage(bootinfo.memmappedaddr) >= 0) return;
156162 }
Index: embios/trunk/arm/contextswitch.S
@@ -145,8 +145,15 @@
146146 .global execfirmware
147147 .type execfirmware, %function
148148 execfirmware:
 149+ str r0, [sp,#-4]!
 150+ bl clean_dcache
 151+ ldr r1, [sp], #4
149152 msr cpsr_c, #0xd3
150 - bx r0
 153+ mrc p15, 0, r0,c1,c0
 154+ bic r0, r0, #1
 155+ mcr p15, 0, r0,c1,c0
 156+ mcr p15, 0, r0,c7,c5
 157+ bx r1
151158 .size execfirmware, .-execfirmware
152159
153160 unknown_swi_string: