freemyipod r456 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r455‎ | r456 | r457 >
Date:21:04, 19 January 2011
Author:theseven
Status:new
Tags:
Comment:
emCORE: Add support for multiple piggybacked apps
Modified paths:
  • /emcore/trunk/init.c (modified) (history)

Diff [purge]

Index: emcore/trunk/init.c
@@ -62,12 +62,14 @@
6363 {
6464 BOOTTYPE_PIGGYBACKED = 1,
6565 BOOTTYPE_BOOTFLASH = 2,
66 - BOOTTYPE_FILESYSTEM = 3
 66+ BOOTTYPE_FILESYSTEM = 3,
 67+ BOOTTYPE_FAKESUCCESS = 4
6768 };
6869
6970 struct bootoption
7071 {
71 - struct bootoption* next;
 72+ struct bootoption* success_next;
 73+ struct bootoption* fail_next;
7274 enum boottype type;
7375 char* source;
7476 };
@@ -174,13 +176,15 @@
175177 #endif
176178 DEBUGF("Finished initialisation sequence");
177179
178 - struct bootoption* option;
179 - bool done = false;
180 - for (option = bootinfo.options; !done && option; option = option->next)
 180+ struct bootoption* option = bootinfo.options;
 181+ bool success = false;
 182+ while (option)
 183+ {
 184+ success = false;
181185 switch (option->type)
182186 {
183187 case BOOTTYPE_PIGGYBACKED:
184 - done = execimage(option->source, true) != NULL;
 188+ success = execimage(option->source, true) != NULL;
185189 break;
186190
187191 #ifdef HAVE_BOOTFLASH
@@ -195,8 +199,8 @@
196200 free(buffer);
197201 break;
198202 }
199 - done = execimage(buffer, false) != NULL;
200 - if (!done) free(buffer);
 203+ success = execimage(buffer, false) != NULL;
 204+ if (!success) free(buffer);
201205 break;
202206 }
203207 #endif
@@ -225,16 +229,23 @@
226230 break;
227231 }
228232 close(fd);
229 - done = execimage(buffer, false) != NULL;
230 - if (!done) free(buffer);
 233+ success = execimage(buffer, false) != NULL;
 234+ if (!success) free(buffer);
231235 break;
232236 }
233237 #endif
234238
 239+ case BOOTTYPE_FAKESUCCESS:
 240+ success = true;
 241+ break;
 242+
235243 default:
236244 cprintf(CONSOLE_BOOT, unknownboottypestr, option->type);
237245 }
238 - cputs(CONSOLE_BOOT, nobootoptionsstr);
 246+ if (success) option = option->success_next;
 247+ else option = option->fail_next;
 248+ }
 249+ if (!success) cputs(CONSOLE_BOOT, nobootoptionsstr);
239250 free(ib->bootalloc);
240251 }
241252