Newer
Older
tree-os / src / kernel / kernel.c
#include <stdint.h>
#include <lib/textMode/stdio.h>
#include <tree-os.h>
#include <lib/textMode/cursor.h>
#include <lib/task/task.h>
#include <lib/memory/alloc.h>
#include <lib/task/osTasks.h>

extern uint32_t _kernel_end;

void memoryTest() {
    void* one = malloc(0x100);
    printf("alloc one: %x\n", one);
    void* two = malloc(0x100);
    printf("alloc two: %x\n", two);
    mfree(one);
    printf("free one\n");
    void* three = malloc(1);
    printf("alloc three: %x\n", three);
    mfree(two);
    printf("free two\n");
    printMemoryStack();
    void* four = malloc(0x180);
    printf("alloc four: %x\n", four);
    printMemoryStack();
}

void kernelMain() {
    drawLogo();
    initMemoryAllocation(0x100000); // initializing stacks after the kernel seems to not work :( otherwise, _kernel_end should be passed here
    memoryTest();
    initOSTasks();
    printf("Switching to otherTask... \n");
    yields();
    printf("Returned to mainTask!\n");
    yield();
}