Xyris
0.5
EarlyPanic.cpp
Go to the documentation of this file.
1
/**
2
* @file panic.cpp
3
* @author Keeton Feavel (
[email protected]
)
4
* @author Micah Switzer (
[email protected]
)
5
* @brief Early CGA-mode panic (no framebuffer)
6
* @version 0.3
7
* @date 2020-10-11
8
*
9
* @copyright Copyright the Xyris Contributors (c) 2020
10
*
11
*/
12
13
#include <
Arch/Arch.hpp
>
14
#include <
Arch/i686/Bootloader/EarlyPanic.hpp
>
15
#include <
Support/sections.hpp
>
16
17
#define TTY_WIDTH 80
18
#define TTY_HEIGHT 25
19
#define VGA_COLOR(bg, fg) (uint16_t)(((bg)<<4)|((fg)&0xF))
20
#define VGA_CHAR(ch, co) (uint16_t)((ch)|((co)<<8))
21
22
enum
bios_color
: uint16_t {
23
BIOS_Black
= 0,
24
BIOS_Blue
= 1,
25
BIOS_Green
= 2,
26
BIOS_Cyan
= 3,
27
BIOS_Red
= 4,
28
BIOS_Magenta
= 5,
29
BIOS_Brown
= 6,
30
BIOS_LightGrey
= 7,
31
BIOS_DarkGrey
= 8,
32
BIOS_LightBlue
= 9,
33
BIOS_LightGreen
= 10,
34
BIOS_LightCyan
= 11,
35
BIOS_LightRed
= 12,
36
BIOS_LightMagenta
= 13,
37
BIOS_Yellow
= 14,
38
BIOS_White
= 15
39
};
40
41
extern
"C"
42
__attribute__
((section(
".early_text"
)))
43
void EarlyPanic(const
char
*str)
44
{
45
volatile
uint16_t* where;
46
uint16_t* biosVGABuffer = (uint16_t*)0x000B8000;
47
int
x = 0;
48
int
y = 0;
49
// Clear the screen
50
for
(
int
i = 0; i <
TTY_WIDTH
; i++) {
51
for
(
int
j = 0; j <
TTY_HEIGHT
; j++) {
52
where = biosVGABuffer + (j *
TTY_WIDTH
+ i);
53
*where =
VGA_CHAR
(
' '
,
VGA_COLOR
(
BIOS_Black
,
BIOS_White
));
54
}
55
}
56
// For each character in the string
57
for
(
int
i = 0; str[i] !=
'\0'
; ++i) {
58
switch
(str[i]) {
59
// Newline
60
case
'\n'
:
61
x = 0;
62
y++;
63
break
;
64
// Anything else
65
default
:
66
where = biosVGABuffer + (y *
TTY_WIDTH
+ x);
67
*where =
VGA_CHAR
(str[i],
VGA_COLOR
(
BIOS_Red
,
BIOS_White
));
68
x++;
69
break
;
70
}
71
}
72
73
Arch::haltAndCatchFire
();
74
}
VGA_CHAR
#define VGA_CHAR(ch, co)
Definition:
EarlyPanic.cpp:20
BIOS_LightGreen
@ BIOS_LightGreen
Definition:
EarlyPanic.cpp:33
BIOS_DarkGrey
@ BIOS_DarkGrey
Definition:
EarlyPanic.cpp:31
BIOS_Magenta
@ BIOS_Magenta
Definition:
EarlyPanic.cpp:28
TTY_HEIGHT
#define TTY_HEIGHT
Definition:
EarlyPanic.cpp:18
BIOS_LightBlue
@ BIOS_LightBlue
Definition:
EarlyPanic.cpp:32
EarlyPanic.hpp
Early CGA-mode panic (no framebuffer)
BIOS_Blue
@ BIOS_Blue
Definition:
EarlyPanic.cpp:24
BIOS_LightMagenta
@ BIOS_LightMagenta
Definition:
EarlyPanic.cpp:36
BIOS_Brown
@ BIOS_Brown
Definition:
EarlyPanic.cpp:29
Arch.hpp
Architecture control and initialization.
bios_color
bios_color
Definition:
EarlyPanic.cpp:22
sections.hpp
Kernel ELF section definitions.
BIOS_LightRed
@ BIOS_LightRed
Definition:
EarlyPanic.cpp:35
VGA_COLOR
#define VGA_COLOR(bg, fg)
Definition:
EarlyPanic.cpp:19
BIOS_Yellow
@ BIOS_Yellow
Definition:
EarlyPanic.cpp:37
Arch::haltAndCatchFire
void haltAndCatchFire()
Disable interrupts and halts execution.
Definition:
Arch.hpp:42
TTY_WIDTH
#define TTY_WIDTH
Definition:
EarlyPanic.cpp:17
BIOS_White
@ BIOS_White
Definition:
EarlyPanic.cpp:38
BIOS_Black
@ BIOS_Black
Definition:
EarlyPanic.cpp:23
BIOS_Cyan
@ BIOS_Cyan
Definition:
EarlyPanic.cpp:26
BIOS_LightCyan
@ BIOS_LightCyan
Definition:
EarlyPanic.cpp:34
__attribute__
__attribute__((section(".early_text"))) void EarlyPanic(const char *str)
Map bootloader information into the higher half of memory so that the kernel can access it and parse ...
Definition:
EarlyPanic.cpp:42
BIOS_Red
@ BIOS_Red
Definition:
EarlyPanic.cpp:27
BIOS_LightGrey
@ BIOS_LightGrey
Definition:
EarlyPanic.cpp:30
BIOS_Green
@ BIOS_Green
Definition:
EarlyPanic.cpp:25
Kernel
Arch
i686
Bootloader
EarlyPanic.cpp
Generated by
1.8.17