762af88879e12c4ca39da21aa3ab1856b0b8a56c
[rpi-open-firmware.git] / arm_chainloader / loader.cc
1 /*=============================================================================
2 Copyright (C) 2016 Kristina Brooks
3 All rights reserved.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 FILE DESCRIPTION
16 Second stage bootloader.
17
18 =============================================================================*/
19
20 #include <drivers/fatfs/ff.h>
21 #include <chainloader.h>
22 #include <drivers/mailbox.hpp>
23
24 #define logf(fmt, ...) printf("[LDR:%s]: " fmt, __FUNCTION__, ##__VA_ARGS__);
25
26 FATFS g_BootVolumeFs;
27
28 #define ROOT_VOLUME_PREFIX "0:"
29
30 static const char* g_BootFiles32[] = {
31 "zImage",
32 "kernel.img",
33 };
34
35 struct LoaderImpl {
36 inline bool file_exists(const char* path) {
37 return f_stat(path, NULL) == FR_OK;
38 }
39
40 bool read_file(const char* path, uintptr_t dest) {
41
42 }
43
44 LoaderImpl() {
45 logf("Mounting boot partitiion ...\n");
46 FRESULT r = f_mount(&g_BootVolumeFs, ROOT_VOLUME_PREFIX, 1);
47 if (r != FR_OK) {
48 panic("failed to mount boot partition, error: %d", (int)r);
49 }
50 logf("Boot partition mounted!\n");
51
52 g_Mailbox.write_word(0x1111);
53 }
54 };
55
56 static LoaderImpl STATIC_APP g_Loader {};
This page took 0.069855 seconds and 4 git commands to generate.