kernel: various changes.
+ kernel: replace sk-hello test executable with a test initramfs + panic: start implementing a proper kernel panic screen + lib: added a new string.h library for string manipulation. + kernel: replace all the strlen implementations with the strlen() function
This commit is contained in:
parent
7fb04f134b
commit
a838d99a5a
19 changed files with 173 additions and 149 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "exec/elf.h"
|
||||
#include "exec/exec.h"
|
||||
#include "fs/tapefs.h"
|
||||
#include "fs/vfs.h"
|
||||
#include "mm/liballoc/liballoc.h"
|
||||
#include "mm/pmm.h"
|
||||
#include "mm/vma.h"
|
||||
|
@ -11,29 +13,22 @@
|
|||
#include "sys/syscall.h"
|
||||
#include <font.h>
|
||||
#include <limine.h>
|
||||
#include <mm/memop.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/arch/x86_64/fpu.h>
|
||||
#include <sys/arch/x86_64/gdt.h>
|
||||
#include <sys/arch/x86_64/idt.h>
|
||||
#include <sys/error_handling/panic.h>
|
||||
#include <sys/gfx/flanterm/backends/fb.h>
|
||||
#include <sys/gfx/flanterm/flanterm.h>
|
||||
#include <sys/log.h>
|
||||
#include <sys/printf.h>
|
||||
|
||||
// Set the base revision to 3, this is recommended as this is the latest
|
||||
// base revision described by the Limine boot protocol specification.
|
||||
// See specification for further info.
|
||||
|
||||
__attribute__((
|
||||
used, section(".limine_requests"))) static volatile LIMINE_BASE_REVISION(3);
|
||||
|
||||
// The Limine requests can be placed anywhere, but it is important that
|
||||
// the compiler does not optimise them away, so, usually, they should
|
||||
// be made volatile or equivalent, _and_ they should be accessed at least
|
||||
// once or marked as used with the "used" attribute as done here.
|
||||
|
||||
__attribute__((
|
||||
used,
|
||||
section(
|
||||
|
@ -45,14 +40,6 @@ __attribute__((
|
|||
section(".limine_requests"))) static volatile struct limine_module_request
|
||||
module_request = {.id = LIMINE_MODULE_REQUEST, .revision = 0};
|
||||
|
||||
/*__attribute__((used, section(".limine_requests")))
|
||||
static volatile struct limine_entry_point_request entrypoint_request = {
|
||||
.id = LIMINE_ENTRY_POINT_REQUEST,
|
||||
.revision = 3
|
||||
};*/
|
||||
// Finally, define the start and end markers for the Limine requests.
|
||||
// These can also be moved anywhere, to any .c file, as seen fit.
|
||||
|
||||
__attribute__((used,
|
||||
section(".limine_requests_"
|
||||
"start"))) static volatile LIMINE_REQUESTS_START_MARKER;
|
||||
|
@ -62,38 +49,14 @@ __attribute__((
|
|||
section(
|
||||
".limine_requests_end"))) static volatile LIMINE_REQUESTS_END_MARKER;
|
||||
|
||||
// Halt and catch fire function.
|
||||
static void hcf(void) {
|
||||
for (;;) {
|
||||
#if defined(__x86_64__)
|
||||
asm("hlt");
|
||||
#elif defined(__aarch64__) || defined(__riscv)
|
||||
asm("wfi");
|
||||
#elif defined(__loongarch64)
|
||||
asm("idle 0");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
struct limine_framebuffer *fb;
|
||||
struct flanterm_context *ft_ctx;
|
||||
uint32_t fg = 0xFFFFFF;
|
||||
|
||||
char kstack[8192];
|
||||
|
||||
// The following will be our kernel's entry point.
|
||||
// If renaming kmain() to something else, make sure to change the
|
||||
// linker script accordingly.
|
||||
void kmain(void) {
|
||||
// Ensure the bootloader actually understands our base revision (see spec).
|
||||
/*if (LIMINE_BASE_REVISION_SUPPORTED == false) {
|
||||
hcf();
|
||||
}*/
|
||||
|
||||
// Ensure we got a framebuffer.
|
||||
if (framebuffer_request.response != NULL) {
|
||||
|
||||
// Fetch the first framebuffer.
|
||||
struct limine_framebuffer *framebuffer =
|
||||
framebuffer_request.response->framebuffers[0];
|
||||
fb = framebuffer;
|
||||
|
@ -103,12 +66,11 @@ void kmain(void) {
|
|||
framebuffer->height, framebuffer->pitch, framebuffer->red_mask_size,
|
||||
framebuffer->red_mask_shift, framebuffer->green_mask_size,
|
||||
framebuffer->green_mask_shift, framebuffer->blue_mask_size,
|
||||
framebuffer->blue_mask_shift, NULL, NULL, NULL, NULL, &fg, NULL, NULL,
|
||||
framebuffer->blue_mask_shift, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
VGA8, 8, 16, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
printf("\n Soaplin 1.0-sild is booting up your computer...\n\n");
|
||||
// printf("Physical kernel EP: %p", entrypoint_request.entry);
|
||||
|
||||
gdt_init(&kstack[8192]);
|
||||
idt_init();
|
||||
|
@ -125,21 +87,13 @@ void kmain(void) {
|
|||
asm("hlt");
|
||||
}
|
||||
|
||||
// acpi_init();
|
||||
syscall_init();
|
||||
pit_init(1000);
|
||||
sched_init();
|
||||
// user_init();
|
||||
|
||||
struct limine_file *f = module_request.response->modules[0];
|
||||
log("kmain - %s\n", f->path);
|
||||
|
||||
program_t *prog = elf_load((char *)f->address, 1);
|
||||
|
||||
sched_create("Init", prog->entry, prog->pm, SCHED_USER_PROCESS);
|
||||
|
||||
log("kernel - Soaplin initialized sucessfully.\n");
|
||||
|
||||
while (1)
|
||||
;
|
||||
; //__asm__ volatile ("hlt");
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue