Use libkernaux in Stivale 2 Limine example

This commit is contained in:
Alex Kotov 2022-01-15 18:04:46 +05:00
parent 3d7b6b5898
commit 0aa8134fe8
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 4 additions and 24 deletions

View File

@ -14,6 +14,6 @@ export AR="$BIN/$HOST-ar"
export CC="$BIN/$HOST-gcc"
export RANLIB="$BIN/$HOST-ranlib"
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector -fno-pic -mabi=sysv -mno-80387 -mno-3dnow -mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -MMD'
"$REPO/configure" --host="$HOST" --enable-assert --enable-guard --with-libc

View File

@ -1,10 +1,11 @@
#include <stdint.h>
#include <stddef.h>
#include <kernaux/console.h>
#include "stivale2.h"
static void poweroff();
static void putc(char c);
// We need to tell the stivale bootloader where we want our stack to be.
// We are going to allocate our stack as an array in .bss.
@ -105,21 +106,7 @@ void *stivale2_get_tag(struct stivale2_struct *stivale2_struct, uint64_t id) {
// The following will be our kernel's entry point.
void _start(struct stivale2_struct *stivale2_struct __attribute__((unused))) {
putc('H');
putc('e');
putc('l');
putc('l');
putc('o');
putc(',');
putc(' ');
putc('W');
putc('o');
putc('r');
putc('l');
putc('d');
putc('!');
putc('\n');
kernaux_console_puts("Hello, World!");
poweroff();
}
@ -129,10 +116,3 @@ void poweroff()
const uint16_t value = 0x2000;
__asm__ volatile("outw %1, %0" : : "dN" (port), "a" (value));
}
void putc(const char c)
{
const uint16_t port = 0x3F8;
const uint16_t value = c;
__asm__ volatile("outw %1, %0" : : "dN" (port), "a" (value));
}