MyOS Kernel
tasking_helpers_c.c File Reference
#include "../../tasking.h"
#include "../paging.h"
#include "../tasking_helpers.h"
#include "../../pmem.h"
#include <stddef.h>
#include <stdint.h>

Functions

static char is_kstack_allocated (size_t index)
 
static void mark_kstack_allocated (size_t index)
 
static int new_kstack ()
 
void setup_kstack (Thread *thread, void *param1, void *param2, char kmode, void *eip)
 
void free_kstack (void *stack_ptr)
 

Variables

static void ** kstacks =(void*)0xC8000000
 Pointer to all the thread kernel stacks.
 
static char kstack_bmap [(218 *1024)/8] ={0}
 Bitmap of what kernel stacks have been allocated.
 

Function Documentation

◆ free_kstack()

void free_kstack ( void *  stack_ptr)

Frees a kernel stack so it can be used again

Parameters
stack_ptrThe kernel stack to free

◆ is_kstack_allocated()

static char is_kstack_allocated ( size_t  index)
static

Check whether a kernel stack is allocated

Parameters
indexThe kernel stack to check
Returns
whether the kernel stack is allocated

◆ mark_kstack_allocated()

static void mark_kstack_allocated ( size_t  index)
static

Mark that a kernel stack is allocated

Parameters
indexThe kernel stack to mark

◆ new_kstack()

static int new_kstack ( )
static

Allocate a kernel stack for a thread

Returns
The number of the new kernel stack, or -1 if none are unallocated.

◆ setup_kstack()

void setup_kstack ( Thread thread,
void *  param1,
void *  param2,
char  kmode,
void *  eip 
)

Setup a kernel stack for a thread

Parameters
threadThe thread to setup a stack for
param1The thread's start function first parameter
param2The thread's start function second parameter
kmodeWhether the thread is a kernel mode thread
eipThe start address of the thread