| 893 |
theseven |
1 |
//
|
|
|
2 |
//
|
|
|
3 |
// Copyright 2013 TheSeven
|
| 914 |
user890104 |
4 |
// Copyright 2014 user890104
|
| 893 |
theseven |
5 |
//
|
|
|
6 |
//
|
|
|
7 |
// This file is part of emCORE.
|
|
|
8 |
//
|
|
|
9 |
// emCORE 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 |
// emCORE 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 emCORE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
21 |
//
|
|
|
22 |
//
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
#include "emcoreapp.h"
|
| 918 |
user890104 |
26 |
#include "libboot.h"
|
| 924 |
theseven |
27 |
#include "ums.h"
|
|
|
28 |
#include "usb.h"
|
| 893 |
theseven |
29 |
|
|
|
30 |
|
|
|
31 |
static void main(int argc, const char** argv)
|
|
|
32 |
{
|
| 924 |
theseven |
33 |
cputs(1, "Welcome to Disk Mode!\n\n"
|
|
|
34 |
"This device will now behave\nlike an external hard drive.\n\n"
|
|
|
35 |
"When you're finished, please\nproperly eject/unmount the disk.\n");
|
|
|
36 |
|
|
|
37 |
ums_init();
|
|
|
38 |
usb_prepare();
|
| 918 |
user890104 |
39 |
|
| 914 |
user890104 |
40 |
disk_unmount(0);
|
| 924 |
theseven |
41 |
usb_connect();
|
| 914 |
user890104 |
42 |
|
| 924 |
theseven |
43 |
cprintf(3, "Disk was ejected successfully.\nReturning to the bootmenu...\n\n");
|
| 914 |
user890104 |
44 |
|
| 924 |
theseven |
45 |
struct emcorelib_header* libboot = get_library(LIBBOOT_IDENTIFIER, LIBBOOT_API_VERSION,
|
|
|
46 |
LIBSOURCE_BOOTFLASH, "libboot ");
|
|
|
47 |
if (!libboot) panicf(PANIC_KILLTHREAD, "Could not load libboot");
|
| 918 |
user890104 |
48 |
struct libboot_api* boot = (struct libboot_api*)libboot->api;
|
|
|
49 |
|
| 924 |
theseven |
50 |
int size = 0;
|
|
|
51 |
void* app = NULL;
|
|
|
52 |
boot->load_from_flash(&app, &size, false, "bootmenu", 0);
|
|
|
53 |
if (!app)
|
| 918 |
user890104 |
54 |
panicf(PANIC_KILLTHREAD, "Unable to start the bootmenu! Press MENU+SELECT to reboot your device.\n");
|
| 924 |
theseven |
55 |
|
|
|
56 |
release_library(libboot);
|
| 918 |
user890104 |
57 |
|
| 914 |
user890104 |
58 |
disk_mount(0);
|
| 924 |
theseven |
59 |
execimage(app, false, 0, NULL);
|
| 893 |
theseven |
60 |
}
|
|
|
61 |
|
|
|
62 |
|
| 924 |
theseven |
63 |
EMCORE_APP_HEADER("Disk Mode", main, 127)
|
|
|
64 |
|