Newer
Older
tree-os / src / kernel / kernel.c
#include <alloc.h>
#include <cpuid.h>
#include <devices.h>
#include <fileSystem.h>
#include <message.h>
#include <osTasks.h>
#include <stdint.h>
#include <stdio.h>
#include <task.h>
#include <tree-os.h>

extern uint32_t kernelEnd;

void kernelMain() {
    initMemoryAllocation(kernelEnd);
    initOSTasks();
    getCurrentTask()->timerTicks = 1000;
    getCurrentTask()->ticksLeft = 1000;
    drawLogo();
    yields();
    printCPUData();
    setupDevices();
    printFileSystemTree();
    File *file = readFile("/folder/content");
    printf("file size: %i\n", file->file->size);
    printf("file content: %s\n", file->data);
    while (1) {
        for (Message *message = popBeginning(&(getCurrentTask()->messages));
             message; message = popBeginning(&getCurrentTask()->messages)) {
            switch (message->type) {
            case KEYBOARD_CHAR:
                printf("%c", message->data);
                break;
            case KEYBOARD_STRING:
                printf("%s", message->data);
                break;
            case TIMER_UPDATE:
                printf("\e[s\e[Htime since power on: %i seconds\e[u",
                       (uint32_t)message->data / 1000);
            }
            free(message);
        }
        yield();
    }
}