gint-with-thread/src/kernel/kernel.c

48 lines
1.2 KiB
C

//---
// gint:core:kernel - Installing and unloading the library
//---
#include <gint/mmu.h>
#include <gint/drivers.h>
#include <gint/atomic.h>
/* internal global witch content Casio and Gint environment */
void *kernel_env_casio;
void *kernel_env_gint;
/* global information ( workaround >_< ) */
void *gint_vbr = NULL;
/* kinit(): Install and start gint */
void kinit(void)
{
/* generate the VBR address */
#ifdef FX9860G
/* VBR is loaded 0x600 bytes before end of the user RAM (0x100 bytes at
the start of the VBR space are unused) */
gint_vbr = (void*)(uintptr_t)mmu_uram() + 0x1a00 - 0x100;
#endif
#ifdef FXCG50
/* VBR is loaded at the start of the user RAM */
gint_vbr = (void*)(uintptr_t)mmu_uram();
#endif
/* create Casio's context, switch to Gint and save Gint context */
kernel_env_gint = drivers_context_create();
kernel_env_casio = drivers_context_create();
drivers_save(kernel_env_casio);
drivers_init(kernel_env_gint);
drivers_save(kernel_env_gint);
}
/* kquit(): Quit gint and give back control to the system */
void kquit(void)
{
drivers_restore(kernel_env_casio);
atomic_begin();
drivers_context_destroy(&kernel_env_casio);
drivers_context_destroy(&kernel_env_gint);
atomic_end();
}