summaryrefslogblamecommitdiffstats
path: root/include/tasking.h
blob: 04118a9585aa8286a5e742e5c834522b3aa04e21 (plain) (tree)











































                                                                       
#ifndef _JOVE_TASKING_H
#define _JOVE_TASKING_H 1

#include "arch/page.h"
#include <stddef.h>
#include <stdbool.h>

#define KERNEL_STACKW 4096

typedef intmax_t tcbid_t;

typedef enum
{
    TCB_RUNNING,
    TCB_PAUSED,
    TCB_DEAD
} tcb_state_t;

typedef struct task_control_block
{
    tcbid_t id;
    void *stack;
    uintptr_t sp, ksp;
    page_directory_t *pd;
    tcb_state_t state;

    int exit_code;
} tcb_t;

void tasking_setup(void);

tcb_t *tcb_new(void *ip, page_directory_t *pd);
void tcb_prepare(tcb_t *tcb, void *ip);
void tcb_kill(tcb_t *tcb, int code);

void tcb_switch(tcb_t *to);

void tcb_stack_push(tcb_t *tcb, void *data, size_t len);

void kexec(void *ip, int kargc, char **kargv, int kenvc, char **kenvp);

void *umode_stack_new(void);

#endif