mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-13 18:51:01 +01:00
Add pre-defined panic utilities
This commit is contained in:
parent
4c38be1560
commit
1fa64fccbf
21
exosphere/src/panic_color.h
Normal file
21
exosphere/src/panic_color.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef EXOSPHERE_PANIC_COLOR_H
|
||||
#define EXOSPHERE_PANIC_COLOR_H
|
||||
|
||||
#define COLOR_0 0x00F00003
|
||||
#define COLOR_1 0x0F000003
|
||||
#define COLOR_2 0xF0000003
|
||||
#define COLOR_3 0x0FF00003
|
||||
#define COLOR_4 0xF0F00003
|
||||
#define COLOR_5 0xFF000003
|
||||
#define COLOR_6 0xFFF00003
|
||||
#define COLOR_7 0xAAF00003
|
||||
#define COLOR_8 0xAFA00003
|
||||
#define COLOR_9 0xFAA00003
|
||||
#define COLOR_A 0x33300003
|
||||
#define COLOR_B 0x06F00003
|
||||
#define COLOR_C 0x14800003
|
||||
#define COLOR_D 0x00300003
|
||||
#define COLOR_E 0x03000003
|
||||
#define COLOR_F 0xB6000003
|
||||
|
||||
#endif
|
@ -23,6 +23,11 @@ __attribute__ ((noreturn)) void generic_panic(void) {
|
||||
panic(0xFF000006);
|
||||
}
|
||||
|
||||
__attribute__ ((noreturn)) void panic_predefined(uint32_t which) {
|
||||
static const uint32_t codes[0x10] = {COLOR_0, COLOR_1, COLOR_2, COLOR_3, COLOR_4, COLOR_5, COLOR_6, COLOR_7, COLOR_8, COLOR_9, COLOR_A, COLOR_B, COLOR_C, COLOR_D, COLOR_E, COLOR_F};
|
||||
panic(codes[which & 0xF]);
|
||||
}
|
||||
|
||||
__attribute__((noinline)) bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be)
|
||||
{
|
||||
if(as <= bs && bs <= ae)
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "panic_color.h"
|
||||
|
||||
#define BIT(n) (1u << (n))
|
||||
#define BITL(n) (1ull << (n))
|
||||
#define MASK(n) (BIT(n) - 1)
|
||||
@ -52,6 +54,7 @@ typedef struct {
|
||||
|
||||
__attribute__ ((noreturn)) void panic(uint32_t code);
|
||||
__attribute__ ((noreturn)) void generic_panic(void);
|
||||
__attribute__ ((noreturn)) void panic_predefined(uint32_t which);
|
||||
bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be);
|
||||
|
||||
static inline uintptr_t get_physical_address(const void *vaddr) {
|
||||
|
Loading…
Reference in New Issue
Block a user