2022-03-26 05:54:00 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <limine.h>
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
static volatile struct limine_terminal_request terminal_request = {
|
|
|
|
.id = LIMINE_TERMINAL_REQUEST,
|
|
|
|
.revision = 0
|
|
|
|
};
|
|
|
|
|
|
|
|
static void done(void) {
|
|
|
|
for (;;) {
|
2023-02-28 12:33:46 +01:00
|
|
|
asm ("hlt");
|
2022-03-26 05:54:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-28 12:41:28 +01:00
|
|
|
// Our quick and dirty strlen() implementation.
|
|
|
|
size_t strlen(const char *str) {
|
|
|
|
size_t ret = 0;
|
|
|
|
while (*str++) {
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-03-26 05:54:00 +01:00
|
|
|
// The following will be our kernel's entry point.
|
|
|
|
void _start(void) {
|
|
|
|
// Ensure we got a terminal
|
2022-04-01 10:35:32 +02:00
|
|
|
if (terminal_request.response == NULL
|
|
|
|
|| terminal_request.response->terminal_count < 1) {
|
2022-03-26 05:54:00 +01:00
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We should now be able to call the Limine terminal to print out
|
|
|
|
// a simple "Hello World" to screen.
|
2023-02-28 12:41:28 +01:00
|
|
|
const char *hello_msg = "Hello World";
|
|
|
|
|
2022-04-02 11:27:58 +02:00
|
|
|
struct limine_terminal *terminal = terminal_request.response->terminals[0];
|
2023-02-28 12:41:28 +01:00
|
|
|
terminal_request.response->write(terminal, hello_msg, strlen(hello_msg));
|
2022-03-26 05:54:00 +01:00
|
|
|
|
|
|
|
// We're done, just hang...
|
|
|
|
done();
|
|
|
|
}
|