mirror of
https://github.com/limine-bootloader/limine
synced 2024-11-26 10:29:54 +03:00
bios: Move terminal entirely to stage 3
This commit is contained in:
parent
d0433e1c97
commit
5b3e8c393f
@ -15,7 +15,7 @@
|
||||
#define VD_COLS (80 * 2)
|
||||
#define VD_ROWS 25
|
||||
|
||||
static uint8_t *video_mem = (uint8_t *)0xb8000;
|
||||
static volatile uint8_t *video_mem = (uint8_t *)0xb8000;
|
||||
|
||||
static uint8_t *back_buffer = NULL;
|
||||
static uint8_t *front_buffer = NULL;
|
@ -49,7 +49,6 @@ static bool stage3_init(struct volume *part) {
|
||||
stage3_found = true;
|
||||
|
||||
if (stage3->size != (size_t)limine_sys_size) {
|
||||
term_textmode();
|
||||
print("limine.sys size incorrect.\n");
|
||||
return false;
|
||||
}
|
||||
@ -61,7 +60,6 @@ static bool stage3_init(struct volume *part) {
|
||||
fclose(stage3);
|
||||
|
||||
if (memcmp(build_id_s2 + 16, build_id_s3 + 16, 20) != 0) {
|
||||
term_textmode();
|
||||
print("limine.sys build ID mismatch.\n");
|
||||
return false;
|
||||
}
|
||||
@ -82,8 +80,6 @@ noreturn void entry(uint8_t boot_drive, int boot_from) {
|
||||
if (!a20_enable())
|
||||
panic(false, "Could not enable A20 line");
|
||||
|
||||
term_notready();
|
||||
|
||||
struct rm_regs r = {0};
|
||||
r.eax = 0x0003;
|
||||
rm_int(0x10, &r, &r);
|
||||
@ -112,7 +108,6 @@ noreturn void entry(uint8_t boot_drive, int boot_from) {
|
||||
);
|
||||
|
||||
if (!stage3_found) {
|
||||
term_textmode();
|
||||
print("\n"
|
||||
"!! Stage 3 file not found!\n"
|
||||
"!! Have you copied limine.sys to the root or /boot directories of\n"
|
||||
|
@ -127,6 +127,8 @@ noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
||||
#endif
|
||||
|
||||
noreturn void stage3_common(void) {
|
||||
term_notready();
|
||||
|
||||
init_flush_irqs();
|
||||
init_io_apics();
|
||||
|
||||
|
@ -21,7 +21,11 @@ noreturn void panic(bool allow_menu, const char *fmt, ...) {
|
||||
|
||||
quiet = false;
|
||||
|
||||
if (term_backend == NOT_READY) {
|
||||
if (
|
||||
#if bios == 1
|
||||
stage3_loaded == true &&
|
||||
#endif
|
||||
term_backend == NOT_READY) {
|
||||
#if bios == 1
|
||||
term_textmode();
|
||||
#elif uefi == 1
|
||||
@ -29,11 +33,19 @@ noreturn void panic(bool allow_menu, const char *fmt, ...) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (term_backend == NOT_READY) {
|
||||
if (
|
||||
#if bios == 1
|
||||
stage3_loaded == true &&
|
||||
#endif
|
||||
term_backend == NOT_READY) {
|
||||
term_fallback();
|
||||
}
|
||||
|
||||
print("\033[31mPANIC\033[37;1m\033[0m: ");
|
||||
if (stage3_loaded) {
|
||||
print("\033[31mPANIC\033[37;1m\033[0m: ");
|
||||
} else {
|
||||
print("PANIC: ");
|
||||
}
|
||||
vprint(fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
@ -5,8 +5,34 @@
|
||||
#include <lib/blib.h>
|
||||
#include <lib/term.h>
|
||||
#include <lib/libc.h>
|
||||
#if bios == 1
|
||||
#include <lib/real.h>
|
||||
#endif
|
||||
#include <sys/cpu.h>
|
||||
|
||||
#if bios == 1
|
||||
static void s2_print(const char *s, size_t len) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
struct rm_regs r = {0};
|
||||
char c = s[i];
|
||||
|
||||
switch (c) {
|
||||
case '\n':
|
||||
r.eax = 0x0e00 | '\r';
|
||||
rm_int(0x10, &r, &r);
|
||||
r = (struct rm_regs){0};
|
||||
r.eax = 0x0e00 | '\n';
|
||||
rm_int(0x10, &r, &r);
|
||||
break;
|
||||
default:
|
||||
r.eax = 0x0e00 | s[i];
|
||||
rm_int(0x10, &r, &r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *base_digits = "0123456789abcdef";
|
||||
|
||||
#define PRINT_BUF_MAX 4096
|
||||
@ -187,7 +213,15 @@ void vprint(const char *fmt, va_list args) {
|
||||
}
|
||||
|
||||
out:
|
||||
term_write((uint64_t)(uintptr_t)print_buf, print_buf_i);
|
||||
#if bios == 1
|
||||
if (stage3_loaded) {
|
||||
#endif
|
||||
term_write((uint64_t)(uintptr_t)print_buf, print_buf_i);
|
||||
#if bios == 1
|
||||
} else {
|
||||
s2_print(print_buf, print_buf_i);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < print_buf_i; i++) {
|
||||
if (E9_OUTPUT) {
|
||||
|
1137
stage23/lib/term.c
1137
stage23/lib/term.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -36,6 +36,9 @@ SECTIONS
|
||||
getchar_internal = .;
|
||||
getchar = .;
|
||||
menu = .;
|
||||
term_write = .;
|
||||
term_textmode = .;
|
||||
term_fallback = .;
|
||||
stage3_addr = .;
|
||||
data_begin = .;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user