Subversion Repositories freemyipod

Rev

Rev 914 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 914 Rev 918
Line 24... Line 24...
24
 
24
 
25
#define LITTLE_ENDIAN
25
#define LITTLE_ENDIAN
26
 
26
 
27
 
27
 
28
#include "emcoreapp.h"
28
#include "emcoreapp.h"
-
 
29
#include "libboot.h"
29
 
30
 
30
 
31
 
31
#define SCSI_TEST_UNIT_READY        0x00
32
#define SCSI_TEST_UNIT_READY        0x00
32
#define SCSI_INQUIRY                0x12
33
#define SCSI_INQUIRY                0x12
33
#define SCSI_MODE_SENSE_6           0x1a
34
#define SCSI_MODE_SENSE_6           0x1a
Line 326... Line 327...
326
static bool locked;
327
static bool locked;
327
static const struct usb_instance* usb;
328
static const struct usb_instance* usb;
328
static volatile bool ejected = false;
329
static volatile bool ejected = false;
329
static uint8_t __attribute__((aligned(32))) storage_buffer[0x10000];
330
static uint8_t __attribute__((aligned(32))) storage_buffer[0x10000];
330
 
331
 
-
 
332
struct bootinfo_t
-
 
333
{
-
 
334
    bool valid;
-
 
335
    void* firmware;
-
 
336
    int size;
-
 
337
    void* app;
-
 
338
    int argc;
-
 
339
    const char** argv;
-
 
340
};
-
 
341
 
331
static void listen()
342
static void listen()
332
{
343
{
333
    usb_start_rx(usb, outep, &cbw, sizeof(cbw));
344
    usb_start_rx(usb, outep, &cbw, sizeof(cbw));
334
}
345
}
335
 
346
 
Line 840... Line 851...
840
static const struct usb_configuration* usb_configurations[] =
851
static const struct usb_configuration* usb_configurations[] =
841
{
852
{
842
    &usb_c1,
853
    &usb_c1,
843
};
854
};
844
 
855
 
-
 
856
struct emcorelib_header* loadlib(uint32_t identifier, uint32_t version, char* filename)
-
 
857
{
-
 
858
    struct emcorelib_header* lib = get_library(identifier, version, LIBSOURCE_BOOTFLASH, filename);
-
 
859
    if (!lib) panicf(PANIC_KILLTHREAD, "Could not load %s", filename);
-
 
860
    return lib;
-
 
861
}
-
 
862
 
845
static void main(int argc, const char** argv)
863
static void main(int argc, const char** argv)
846
{
864
{
-
 
865
    cprintf(3, "Welcome to Disk mode! Please wait until your device is detected by your operating system. It should not take more than 1-2 minutes. In case of issues, please ask for support.\n\n");
-
 
866
    cprintf(3, "When you're done transferring files, please use your operating system's Eject/Unmount option before unplugging the device.\n\n");
-
 
867
    
847
    storage_get_info(0, &storage_info);
868
    storage_get_info(0, &storage_info);
848
    
869
    
849
    if (!storage_info.sector_size) panicf(PANIC_KILLTHREAD, "Sector size is zero!\n");
870
    if (!storage_info.sector_size) panicf(PANIC_KILLTHREAD, "Sector size is zero!\n");
850
    if (!storage_info.num_sectors) panicf(PANIC_KILLTHREAD, "Number of sectors is zero!\n");
871
    if (!storage_info.num_sectors) panicf(PANIC_KILLTHREAD, "Number of sectors is zero!\n");
851
 
872
 
Line 909... Line 930...
909
        }
930
        }
910
    }
931
    }
911
    
932
    
912
    usbmanager_uninstall_custom();
933
    usbmanager_uninstall_custom();
913
    
934
    
-
 
935
    cprintf(3, "Disk mode completed successfully. Returning to the bootmenu...\n\n");
-
 
936
    
-
 
937
    struct bootinfo_t bootinfo =
-
 
938
    {
-
 
939
        .valid = false,
-
 
940
        .firmware = NULL,
-
 
941
        .size = 0,
-
 
942
        .app = NULL,
-
 
943
        .argc = 0,
-
 
944
        .argv = NULL
-
 
945
    };
-
 
946
 
-
 
947
    struct emcorelib_header* libboot = loadlib(LIBBOOT_IDENTIFIER,
-
 
948
                                               LIBBOOT_API_VERSION, "libboot ");
-
 
949
    struct libboot_api* boot = (struct libboot_api*)libboot->api;
-
 
950
    
-
 
951
    boot->load_from_flash(&bootinfo.app, &bootinfo.size, false, "bootmenu", 0);
-
 
952
    
-
 
953
    if (!bootinfo.app) {
-
 
954
        panicf(PANIC_KILLTHREAD, "Unable to start the bootmenu! Press MENU+SELECT to reboot your device.\n");
-
 
955
    }
-
 
956
    
914
    disk_mount(0);
957
    disk_mount(0);
-
 
958
    execimage(bootinfo.app, false, bootinfo.argc, bootinfo.argv);
915
}
959
}
916
 
960
 
917
 
961
 
918
EMCORE_APP_HEADER("Disk mode", main, 127)
962
EMCORE_APP_HEADER("Disk mode", main, 127)