mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 13:14:15 -04:00
Introduce fatal_error
This commit is contained in:
parent
add03d5774
commit
f45bc83bc4
14 changed files with 104 additions and 137 deletions
|
@ -13,7 +13,7 @@
|
|||
* TODO: This should print via UART, console framebuffer, and to a ring for
|
||||
* consumption by Horizon
|
||||
*/
|
||||
void printk(char *fmt, ...)
|
||||
void printk(const char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
|
@ -22,7 +22,7 @@ void printk(char *fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
void vprintk(char *fmt, va_list args)
|
||||
void vprintk(const char *fmt, va_list args)
|
||||
{
|
||||
char buf[512];
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
|
||||
void printk(char *fmt, ...);
|
||||
void vprintk(char *fmt, va_list args);
|
||||
void printk(const char *fmt, ...);
|
||||
void vprintk(const char *fmt, va_list args);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,8 +34,7 @@ static const char *load_config(void) {
|
|||
}
|
||||
|
||||
if (memcmp(g_bct0_buffer, "BCT0", 4) != 0) {
|
||||
printk("Error: Unexpected magic in BCT.ini!\n");
|
||||
generic_panic();
|
||||
fatal_error("Unexpected magic in BCT.ini!\n");
|
||||
}
|
||||
/* Return pointer to first line of the ini. */
|
||||
const char *bct0 = g_bct0_buffer;
|
||||
|
@ -43,8 +42,7 @@ static const char *load_config(void) {
|
|||
bct0++;
|
||||
}
|
||||
if (!bct0) {
|
||||
printk("Error: BCT.ini has no newline!\n");
|
||||
generic_panic();
|
||||
fatal_error("BCT.ini has no newline!\n");
|
||||
}
|
||||
return bct0;
|
||||
}
|
||||
|
@ -116,9 +114,8 @@ int main(void) {
|
|||
#ifndef I_KNOW_WHAT_I_AM_DOING
|
||||
#error "Fusee is a work-in-progress bootloader, and is not ready for usage yet. If you want to play with it anyway, please #define I_KNOW_WHAT_I_AM_DOING -- and recognize that we will be unable to provide support until it is ready for general usage :)"
|
||||
|
||||
printk("Warning: Fus\e9e is not yet completed, and not ready for general testing!\n");
|
||||
printk("Please do not seek support for it until it is done.\n");
|
||||
generic_panic();
|
||||
printk("Warning: Fus\xe9" "e is not yet completed, and not ready for general testing!\n");
|
||||
fatal_error("Please do not seek support for it until it is done.\n");
|
||||
#endif
|
||||
|
||||
/* Load the BCT0 configuration ini off of the SD. */
|
||||
|
|
|
@ -49,13 +49,11 @@ void load_stage2(const char *bct0) {
|
|||
uintptr_t tmp_addr;
|
||||
|
||||
if (ini_parse_string(bct0, stage2_ini_handler, &config) < 0) {
|
||||
printk("Error: Failed to parse BCT.ini!\n");
|
||||
generic_panic();
|
||||
fatal_error("Failed to parse BCT.ini!\n");
|
||||
}
|
||||
|
||||
if (config.load_address == 0 || config.path[0] == '\x00') {
|
||||
printk("Error: Failed to determine where to load stage2!\n");
|
||||
generic_panic();
|
||||
fatal_error("Failed to determine where to load stage2!\n");
|
||||
}
|
||||
|
||||
if (strlen(config.path) + 1 + sizeof(stage2_args_t) > CHAINLOADER_ARG_DATA_MAX_SIZE) {
|
||||
|
@ -63,13 +61,11 @@ void load_stage2(const char *bct0) {
|
|||
}
|
||||
|
||||
if (!check_32bit_address_loadable(config.entrypoint)) {
|
||||
printk("Error: Stage2's entrypoint is invalid!\n");
|
||||
generic_panic();
|
||||
fatal_error("Stage2's entrypoint is invalid!\n");
|
||||
}
|
||||
|
||||
if (!check_32bit_address_loadable(config.load_address)) {
|
||||
printk("Error: Stage2's load address is invalid!\n");
|
||||
generic_panic();
|
||||
fatal_error("Stage2's load address is invalid!\n");
|
||||
}
|
||||
|
||||
printk("[DEBUG] Stage 2 Config:\n");
|
||||
|
@ -78,26 +74,22 @@ void load_stage2(const char *bct0) {
|
|||
printk(" Entrypoint: 0x%p\n", config.entrypoint);
|
||||
|
||||
if (f_stat(config.path, &info) != FR_OK) {
|
||||
printk("Error: Failed to stat stage2 (%s)!\n", config.path);
|
||||
generic_panic();
|
||||
fatal_error("Failed to stat stage2 (%s)!\n", config.path);
|
||||
}
|
||||
|
||||
size = (size_t)info.fsize;
|
||||
|
||||
/* the LFB is located at 0xC0000000 atm */
|
||||
if (size > 0xC0000000u - 0x80000000u) {
|
||||
printk("Error: Stage2 is way too big!\n");
|
||||
generic_panic();
|
||||
fatal_error("Stage2 is way too big!\n");
|
||||
}
|
||||
|
||||
if (!check_32bit_address_range_loadable(config.load_address, size)) {
|
||||
printk("Error: Stage2 has an invalid load address & size combination (0x%08x 0x%08x)!\n", config.load_address, size);
|
||||
generic_panic();
|
||||
fatal_error("Stage2 has an invalid load address & size combination (0x%08x 0x%08x)!\n", config.load_address, size);
|
||||
}
|
||||
|
||||
if (config.entrypoint < config.load_address || config.entrypoint >= config.load_address + size) {
|
||||
printk("Error: Stage2's entrypoint is outside Stage2!\n");
|
||||
generic_panic();
|
||||
fatal_error("Stage2's entrypoint is outside Stage2!\n");
|
||||
}
|
||||
|
||||
if (check_32bit_address_range_in_program(config.load_address, size)) {
|
||||
|
@ -107,8 +99,7 @@ void load_stage2(const char *bct0) {
|
|||
}
|
||||
|
||||
if (read_from_file((void *)tmp_addr, size, config.path) != size) {
|
||||
printk("Error: Failed to read stage2 (%s)!\n", config.path);
|
||||
generic_panic();
|
||||
fatal_error("Failed to read stage2 (%s)!\n", config.path);
|
||||
}
|
||||
|
||||
g_chainloader_num_entries = 1;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
#include "utils.h"
|
||||
#include "se.h"
|
||||
#include "fuse.h"
|
||||
#include "pmc.h"
|
||||
#include "timers.h"
|
||||
#include "panic.h"
|
||||
|
||||
#include "lib/printk.h"
|
||||
#include "hwinit/btn.h"
|
||||
|
||||
__attribute__((noreturn)) void watchdog_reboot(void) {
|
||||
|
@ -45,7 +48,17 @@ __attribute__((noreturn)) void wait_for_button_and_pmc_reboot(void) {
|
|||
}
|
||||
|
||||
__attribute__ ((noreturn)) void generic_panic(void) {
|
||||
while(true);//panic(0xFF000006);
|
||||
panic(0xFF000006);
|
||||
}
|
||||
|
||||
__attribute__((noreturn)) void fatal_error(const char *fmt, ...) {
|
||||
va_list args;
|
||||
printk("Fatal error: ");
|
||||
va_start(args, fmt);
|
||||
vprintk(fmt, args);
|
||||
va_end(args);
|
||||
printk("\nPress POWER to reboot into RCM, VOL+/VOL- to reboot normally.\n");
|
||||
wait_for_button_and_pmc_reboot();
|
||||
}
|
||||
|
||||
__attribute__((noinline)) bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be)
|
||||
|
|
|
@ -105,7 +105,8 @@ __attribute__((noreturn)) void watchdog_reboot(void);
|
|||
__attribute__((noreturn)) void pmc_reboot(uint32_t scratch0);
|
||||
__attribute__((noreturn)) void wait_for_button_and_pmc_reboot(void);
|
||||
|
||||
__attribute__((noreturn)) void generic_panic(void);
|
||||
|
||||
void generic_panic(void);
|
||||
__attribute__((noreturn)) void fatal_error(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue