freemyipod r690 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r689‎ | r690 | r691 >
Date:00:53, 6 April 2011
Author:theseven
Status:new
Tags:
Comment:
fastboot: Use libboot
Modified paths:
  • /apps/fastboot/main.c (modified) (history)

Diff [purge]

Index: apps/fastboot/main.c
@@ -29,52 +29,23 @@
3030 {
3131 void* firmware = NULL;
3232 int size;
 33+ struct emcorelib_header* lib = get_library(LIBBOOT_IDENTIFIER, LIBBOOT_API_VERSION, LIBSOURCE_BOOTFLASH, "libboot ");
 34+ if (!lib) panicf(PANIC_KILLTHREAD, "Could not load libboot");
 35+ struct libboot_api* boot = (struct libboot_api*)lib->api;
3336 if (!(clickwheel_get_state() & 0x1f))
34 - {
35 - struct emcorelib_header* libboot = get_library(LIBBOOT_IDENTIFIER, LIBBOOT_API_VERSION, LIBSOURCE_BOOTFLASH, "libboot ");
36 - if (!libboot) panicf(PANIC_KILLTHREAD, "Could not load booting library!");
37 - struct libboot_api* boot = (struct libboot_api*)libboot->api;
38 - int fd = file_open("/.rockbox/rockbox.ipod", O_RDONLY);
39 - if (fd > 0)
40 - {
41 - size = filesize(fd);
42 - if (size > 0)
43 - {
44 - void* buf = memalign(0x10, size);
45 - if (buf)
46 - {
47 - if (read(fd, buf, size) == size)
48 - if (!boot->verify_rockbox_checksum(buf, size))
49 - firmware = buf;
50 - if (!firmware) free(buf);
51 - }
52 - }
53 - close(fd);
54 - }
55 - release_library(libboot);
56 - library_unload(libboot);
57 - }
 37+ boot->load_from_file(&firmware, &size, true, "/.rockbox/rockbox.ipod", 0);
5838 if (firmware)
5939 {
 40+ release_library(lib);
 41+ library_unload(lib);
6042 shutdown(false);
6143 execfirmware((void*)0x08000000, firmware, size);
6244 }
6345 else
6446 {
65 - int size = bootflash_filesize("bootmenu");
66 - if (size > 0)
67 - {
68 - void* buffer = memalign(0x10, size);
69 - if (buffer)
70 - {
71 - if (bootflash_read("bootmenu", buffer, 0, size) == size)
72 - {
73 - if (execimage(buffer, false) != NULL) return;
74 - }
75 - else free(buffer);
76 - }
77 - }
78 - panic(PANIC_KILLTHREAD, "Failed to launch boot menu");
 47+ boot->load_from_flash(&firmware, &size, false, "bootmenu", 0);
 48+ if (!firmware || execimage(firmware, false) == NULL)
 49+ panic(PANIC_KILLTHREAD, "Failed to launch boot menu");
7950 }
8051 }
8152