VxKernel 0.5.0 : Modules + project architecture update
@add <> board/fxcg50/fxcg50.ld : module section <> board/fxcg50/hypervisor : board-specific hypervisor init/quit primitives <> board/fxcg50/kmalloc : board-specific kmalloc init/quit primitives <> vhex/module.h : module information <> modules/display/display.c : add "display" module <> modules/keyboard/keyboard.c : add "keyboard" module <> modules/hypervisor/hypervisor.c : add "hypervisor" module <> modules/kmalloc/kmalloc.c : add "kmalloc" module @update <> vxsdk.toml : update the project version <> GLOBAL : change the "src/" architecture <> board/fxcg50/initialize.c : isolate kmalloc part <> kernel/kernel.c : initialize all modules
This commit is contained in:
parent
ef2632b5dc
commit
f851b73cba
|
@ -49,6 +49,13 @@ SECTIONS
|
|||
_vhex_drivers_end = . ;
|
||||
} > userram
|
||||
|
||||
/* Exposed module interfaces (.vhex.modules) */
|
||||
.vhex.modules : {
|
||||
_vhex_modules_start = . ;
|
||||
KEEP(*(SORT_BY_NAME(.vhex.modules.*)));
|
||||
_vhex_modules_end = . ;
|
||||
} > userram
|
||||
|
||||
/* Read-only sections */
|
||||
.rodata : {
|
||||
/* Read-Only data */
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//---
|
||||
// vhex:core:hardware - Platform information and hardware detection
|
||||
//---
|
||||
#include "vhex/arch/sh7305/pfc.h"
|
||||
#include "vhex/drivers/mpu/sh/sh7305/pfc.h"
|
||||
#include "vhex/drivers/mmu.h"
|
||||
#include "board/fxcg50/hardware.h"
|
||||
#include "vhex/hardware.h"
|
||||
#include "vhex/drivers/mmu.h"
|
||||
|
||||
|
||||
/* Holds information about the current platform */
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
#include <vhex/hypervisor.h>
|
||||
|
||||
/* hypervisor_init() : initialize the hypervisor module */
|
||||
void hypervisor_init(void)
|
||||
{
|
||||
hyp_world_t casio = hypervisor_world_new(
|
||||
"casio",
|
||||
HYP_WORLD_STATUS_FLAG_UNDELETABLE
|
||||
);
|
||||
hyp_world_t vhex = hypervisor_world_new(
|
||||
"vhex",
|
||||
HYP_WORLD_STATUS_FLAG_UNDELETABLE
|
||||
);
|
||||
hypervisor_world_switch(casio, vhex);
|
||||
}
|
||||
|
||||
/* hypervisor_quit() : quit the hypervisor module */
|
||||
void hypervisor_quit(void)
|
||||
{
|
||||
hyp_world_t casio = hypervisor_world_find("casio");
|
||||
hyp_world_t vhex = hypervisor_world_find("vhex");
|
||||
|
||||
hypervisor_world_switch(vhex, casio);
|
||||
|
||||
hypervisor_world_delete(casio);
|
||||
hypervisor_world_delete(vhex);
|
||||
}
|
|
@ -24,43 +24,12 @@ jmp_buf vhex_exitbuf;
|
|||
/* Return value of main() */
|
||||
int vhex_exitcode;
|
||||
|
||||
/* kmalloc_arena */
|
||||
kmalloc_arena_t static_ram = { 0 };
|
||||
kmalloc_arena_t vxboot_ram = { 0 };
|
||||
|
||||
|
||||
/* callarray(): Call an array of functions (constructors or destructors) */
|
||||
static void callarray(void (**f)(void), void (**l)(void))
|
||||
{
|
||||
while(f < l) (*(*f++))();
|
||||
}
|
||||
|
||||
/* kmalloc_init() : initialize kmalloc module */
|
||||
static void kmalloc_init(void)
|
||||
{
|
||||
extern uint32_t __sram_start;
|
||||
size_t size;
|
||||
|
||||
static_ram.name = "_sram";
|
||||
static_ram.is_default = true;
|
||||
static_ram.start = &__sram_start;
|
||||
static_ram.end = (void*)(vhex[HWRAM_PHY_END] | 0x80000000);
|
||||
|
||||
vxboot_ram.name = "_bram";
|
||||
vxboot_ram.is_default = false;
|
||||
vxboot_ram.start = (void*)vhex[HWRAM_PHY_USER_START];
|
||||
size = (vhex[HWRAM_PHY_USER_END] - vhex[HWRAM_PHY_USER_START]) / 2;
|
||||
vxboot_ram.end = (void*)(vhex[HWRAM_PHY_USER_START] + size);
|
||||
vxboot_ram.start = (void*)((uintptr_t)vxboot_ram.start | 0x80000000);
|
||||
vxboot_ram.end = (void*)((uintptr_t)vxboot_ram.end | 0x80000000);
|
||||
|
||||
kmalloc_init_arena(&static_ram, true);
|
||||
kmalloc_init_arena(&vxboot_ram, true);
|
||||
kmalloc_add_arena(&static_ram);
|
||||
kmalloc_add_arena(&vxboot_ram);
|
||||
}
|
||||
|
||||
|
||||
/* initialize() : Where it all starts
|
||||
|
||||
We are currently in a RAM location at a non-constant address due to the
|
||||
|
@ -124,10 +93,7 @@ void initialize(void)
|
|||
tell us if we are running in an emulator or on a real device. */
|
||||
hw_detect();
|
||||
|
||||
/* initialize kmalloc module */
|
||||
kmalloc_init();
|
||||
|
||||
/* Install Vhex, switch VBR and initialize drivers */
|
||||
/* Install Vhex, switch VBR, initialize drivers and modules */
|
||||
kinit();
|
||||
|
||||
/* We are now running on our own in kernel mode. Since we have taken
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#include "vhex/kmalloc.h"
|
||||
#include "vhex/hardware.h"
|
||||
|
||||
/* kmalloc_arena */
|
||||
kmalloc_arena_t static_ram = { 0 };
|
||||
kmalloc_arena_t vxboot_ram = { 0 };
|
||||
|
||||
|
||||
/* kmalloc_init() : initialize kmalloc module */
|
||||
void kmalloc_init(void)
|
||||
{
|
||||
extern uint32_t __sram_start;
|
||||
size_t size;
|
||||
|
||||
static_ram.name = "_sram";
|
||||
static_ram.is_default = true;
|
||||
static_ram.start = &__sram_start;
|
||||
static_ram.end = (void*)(vhex[HWRAM_PHY_END] | 0x80000000);
|
||||
|
||||
vxboot_ram.name = "_bram";
|
||||
vxboot_ram.is_default = false;
|
||||
vxboot_ram.start = (void*)vhex[HWRAM_PHY_USER_START];
|
||||
size = (vhex[HWRAM_PHY_USER_END] - vhex[HWRAM_PHY_USER_START]) / 2;
|
||||
vxboot_ram.end = (void*)(vhex[HWRAM_PHY_USER_START] + size);
|
||||
vxboot_ram.start = (void*)((uintptr_t)vxboot_ram.start | 0x80000000);
|
||||
vxboot_ram.end = (void*)((uintptr_t)vxboot_ram.end | 0x80000000);
|
||||
|
||||
kmalloc_init_arena(&static_ram, true);
|
||||
kmalloc_init_arena(&vxboot_ram, true);
|
||||
kmalloc_add_arena(&static_ram);
|
||||
kmalloc_add_arena(&vxboot_ram);
|
||||
}
|
||||
|
||||
/* kmalloc_quit() : quit the module */
|
||||
void kmalloc_quit(void)
|
||||
{
|
||||
/* Nothing to do here ? */
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef __VHEX_MODULE__
|
||||
# define __VHEX_MODULE__
|
||||
|
||||
#include <vhex/defs/types.h>
|
||||
|
||||
/* kernel module */
|
||||
struct vhex_module
|
||||
{
|
||||
char const *name;
|
||||
void (*init)(void);
|
||||
void (*quit)(void);
|
||||
};
|
||||
|
||||
/* VHEX_DECLARE_MODULE() : Declare a kernel module */
|
||||
#define VHEX_DECLARE_MODULE(level, name) \
|
||||
VSECTION(".vhex.modules." #level) extern struct vhex_module name;
|
||||
|
||||
|
||||
//---
|
||||
// Internal module control
|
||||
//
|
||||
// The following data is exposed for introspection and debugging purposes; it
|
||||
// is not part of the vhex API. There is *no stability guarantee* that the
|
||||
// following types and functions will remain unchanged in future minor and
|
||||
// patch versions.
|
||||
//---
|
||||
|
||||
/* Number of modules in the (vhex_modules) array */
|
||||
#define vhex_module_count() \
|
||||
((struct vhex_module *)&vhex_modules_end \
|
||||
- (struct vhex_module *)&vhex_modules_start)
|
||||
|
||||
/* driver table */
|
||||
#define vhex_module_table() \
|
||||
((struct vhex_module *)&vhex_modules_start)
|
||||
|
||||
/* provided by the linker script */
|
||||
extern uintptr_t vhex_modules_start;
|
||||
extern uintptr_t vhex_modules_end;
|
||||
|
||||
#endif /* __VHEX_MODULE__ */
|
|
@ -1,5 +1,5 @@
|
|||
#include <vhex/drivers/cpu.h>
|
||||
#include <vhex/arch/sh7305/cpu.h>
|
||||
#include <vhex/drivers/mpu/sh/sh7305/cpu.h>
|
||||
|
||||
/* Value of IMASK when atomic mode is entered */
|
||||
static int saved_IMASK = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "vhex/driver.h"
|
||||
#include "vhex/arch/sh7305/cpu.h"
|
||||
#include "vhex/drivers/mpu/sh/sh7305/cpu.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <vhex/arch/sh7305/intc.h>
|
||||
#include <vhex/drivers/mpu/sh/sh7305/intc.h>
|
||||
#include <vhex/defs/types.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "vhex/driver.h"
|
||||
#include "vhex/arch/sh7305/intc.h"
|
||||
#include "vhex/drivers/mpu/sh/sh7305/intc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <vhex/drivers/keyboard.h>
|
||||
#include <vhex/arch/sh7305/keysc.h>
|
||||
#include <vhex/arch/sh7305/intc.h>
|
||||
#include <vhex/keyboard.h>
|
||||
#include <vhex/drivers/mpu/sh/sh7305/keysc.h>
|
||||
#include <vhex/drivers/mpu/sh/sh7305/intc.h>
|
||||
|
||||
/* Internal indicator used by high-level function to notice when the key list
|
||||
is updated */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "vhex/arch/sh7305/keysc.h"
|
||||
#include "vhex/arch/sh7305/intc.h"
|
||||
#include "vhex/drivers/mpu/sh/sh7305/keysc.h"
|
||||
#include "vhex/drivers/mpu/sh/sh7305/intc.h"
|
||||
#include "vhex/driver.h"
|
||||
|
||||
/* define the private KeyScan context structure */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// vhex:mmu:mmu - MMU driver definition and context management
|
||||
//---
|
||||
#include <vhex/drivers/mmu.h>
|
||||
#include <vhex/arch/sh7305/mmu.h>
|
||||
#include <vhex/drivers/mpu/sh/sh7305/mmu.h>
|
||||
#include <vhex/defs/attributes.h>
|
||||
|
||||
/* utlb_addr() - get the P4 address of a UTLB address entry */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <vhex/kernel.h>
|
||||
#include <vhex/hypervisor.h>
|
||||
#include <vhex/module.h>
|
||||
|
||||
|
||||
//---
|
||||
|
@ -9,34 +9,23 @@
|
|||
/* kinit(): Install and start vhex */
|
||||
void kinit(void)
|
||||
{
|
||||
//TODO: initialize kernel "hypervisor" module
|
||||
hyp_world_t casio = hypervisor_world_new(
|
||||
"casio",
|
||||
HYP_WORLD_STATUS_FLAG_UNDELETABLE
|
||||
);
|
||||
hyp_world_t vhex = hypervisor_world_new(
|
||||
"vhex",
|
||||
HYP_WORLD_STATUS_FLAG_UNDELETABLE
|
||||
);
|
||||
struct vhex_module *mtable;
|
||||
|
||||
hypervisor_world_switch(casio, vhex);
|
||||
|
||||
//TODO: initialize kernel "keyboard" module
|
||||
extern void keycache_init(void);
|
||||
keycache_init();
|
||||
|
||||
//TODO: initialize kernel "kmalloc" module
|
||||
//TODO: initialize kernel "display" module
|
||||
mtable = vhex_module_table();
|
||||
for (int i = 0; i < vhex_module_count(); ++i) {
|
||||
if (mtable[i].init != NULL)
|
||||
mtable[i].init();
|
||||
}
|
||||
}
|
||||
|
||||
/* kquit(): Quit vhex and give back control to the system */
|
||||
void kquit(void)
|
||||
{
|
||||
hyp_world_t casio = hypervisor_world_find("casio");
|
||||
hyp_world_t vhex = hypervisor_world_find("vhex");
|
||||
struct vhex_module *mtable;
|
||||
|
||||
hypervisor_world_switch(vhex, casio);
|
||||
|
||||
hypervisor_world_delete(casio);
|
||||
hypervisor_world_delete(vhex);
|
||||
mtable = vhex_module_table();
|
||||
for (int i = 0; i < vhex_module_count(); ++i) {
|
||||
if (mtable[i].quit != NULL)
|
||||
mtable[i].quit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <vhex/display.h>
|
||||
#include <vhex/defs/util.h>
|
||||
#include <vhex/defs/utils.h>
|
||||
#include <vhex/defs/types.h>
|
||||
|
||||
/* Vhex vram */
|
|
@ -0,0 +1,25 @@
|
|||
#include "vhex/display.h"
|
||||
#include "vhex/module.h"
|
||||
|
||||
/* module init */
|
||||
|
||||
/* __display_init() : initialize the display */
|
||||
static void __display_init(void)
|
||||
{
|
||||
/* Nothing to do here ? */
|
||||
}
|
||||
|
||||
/* __display_quit() : uninit the display */
|
||||
static void __display_quit(void)
|
||||
{
|
||||
/* Nothing to do here ? */
|
||||
}
|
||||
|
||||
/* declare the display module */
|
||||
|
||||
struct vhex_module mod_display = {
|
||||
.name = "display",
|
||||
.init = &__display_init,
|
||||
.quit = &__display_quit,
|
||||
};
|
||||
VHEX_DECLARE_MODULE(03, mod_display);
|
|
@ -1,5 +1,5 @@
|
|||
#include <vhex/display.h>
|
||||
#include <vhex/defs/util.h>
|
||||
#include <vhex/defs/utils.h>
|
||||
|
||||
/* dline(): Bresenham line drawing algorithm
|
||||
Remotely adapted from MonochromeLib code by Pierre "PerriotLL" Le Gall.
|
|
@ -1,5 +1,5 @@
|
|||
#include <vhex/display.h>
|
||||
#include <vhex/defs/util.h>
|
||||
#include <vhex/defs/utils.h>
|
||||
#include <vhex/defs/types.h>
|
||||
|
||||
/* drect() - fill a rectangle of the screen */
|
|
@ -0,0 +1,29 @@
|
|||
#include "vhex/hypervisor.h"
|
||||
#include "vhex/module.h"
|
||||
|
||||
/* module init */
|
||||
|
||||
/* __hypervisor_init() : initialize the hypervisor */
|
||||
static void __hypervisor_init(void)
|
||||
{
|
||||
/* NOTE: this part SHOULD be provided by the board definition */
|
||||
extern void hypervisor_init(void);
|
||||
hypervisor_init();
|
||||
}
|
||||
|
||||
/* __hypervisor_quit() : uninit the hypervisor */
|
||||
static void __hypervisor_quit(void)
|
||||
{
|
||||
/* NOTE: this part SHOULD be provided by the board definition */
|
||||
extern void hypervisor_quit(void);
|
||||
hypervisor_quit();
|
||||
}
|
||||
|
||||
/* declare the hypervisor module */
|
||||
|
||||
struct vhex_module mod_hypervisor = {
|
||||
.name = "hypervisor",
|
||||
.init = &__hypervisor_init,
|
||||
.quit = &__hypervisor_quit,
|
||||
};
|
||||
VHEX_DECLARE_MODULE(02, mod_hypervisor);
|
|
@ -0,0 +1,26 @@
|
|||
#include "vhex/keyboard.h"
|
||||
#include "vhex/module.h"
|
||||
|
||||
/* module init */
|
||||
|
||||
/* __keyboard_init() : initialize the keyboard */
|
||||
static void __keyboard_init(void)
|
||||
{
|
||||
extern void keycache_init(void);
|
||||
keycache_init();
|
||||
}
|
||||
|
||||
/* __keyboard_quit() : uninit the keyboard */
|
||||
static void __keyboard_quit(void)
|
||||
{
|
||||
/* Nothing to do here ? */
|
||||
}
|
||||
|
||||
/* declare the keyboard module */
|
||||
|
||||
struct vhex_module mod_keyboard = {
|
||||
.name = "keyboard",
|
||||
.init = &__keyboard_init,
|
||||
.quit = &__keyboard_quit,
|
||||
};
|
||||
VHEX_DECLARE_MODULE(03, mod_keyboard);
|
|
@ -1,4 +1,4 @@
|
|||
#include <vhex/drivers/keyboard.h>
|
||||
#include <vhex/keyboard.h>
|
||||
#include <vhex/drivers/cpu.h>
|
||||
|
||||
/* Internal cache, used like chained list.
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include <vhex/kmalloc.h>
|
||||
#include <vhex/defs/attributes.h>
|
||||
#include <vhex/defs/util.h>
|
||||
#include <vhex/defs/utils.h>
|
||||
|
||||
#include <string.h>
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
//---
|
||||
|
||||
#include <vhex/kmalloc.h>
|
||||
#include <vhex/defs/util.h>
|
||||
#include <vhex/defs/utils.h>
|
||||
#include <vhex/config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
@ -14,16 +14,6 @@
|
|||
/* List of arenas in order of consideration */
|
||||
static kmalloc_arena_t *arenas[KMALLOC_ARENA_MAX] = { 0 };
|
||||
|
||||
#if 0
|
||||
/* kmalloc_init(): Initialize the dynamic allocator */
|
||||
void kmalloc_init(void)
|
||||
{
|
||||
/* Provide the OS heap */
|
||||
extern kmalloc_arena_t kmalloc_arena_osheap;
|
||||
arenas[KMALLOC_ARENA_MAX - 1] = &kmalloc_arena_osheap;
|
||||
}
|
||||
#endif
|
||||
|
||||
//---
|
||||
// Allocation functions
|
||||
//---
|
||||
|
@ -142,3 +132,34 @@ bool kmalloc_add_arena(kmalloc_arena_t *arena)
|
|||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
//---
|
||||
// Module declaraction
|
||||
//---
|
||||
|
||||
#include <vhex/module.h>
|
||||
|
||||
/* __kmalloc_init() : initialize the kmalloc module */
|
||||
static void __kmalloc_init(void)
|
||||
{
|
||||
/* NOTE: this part SHOULD be provided by the board definition */
|
||||
extern void kmalloc_init(void);
|
||||
kmalloc_init();
|
||||
}
|
||||
|
||||
/* __kmalloc_quit() : quit the kmalloc module */
|
||||
static void __kmalloc_quit(void)
|
||||
{
|
||||
/* NOTE: this part SHOULD be provided by the board definition */
|
||||
extern void kmalloc_quit(void);
|
||||
kmalloc_quit();
|
||||
}
|
||||
|
||||
/* declare the module */
|
||||
|
||||
struct vhex_module mod_kmalloc = {
|
||||
.name = "kmalloc",
|
||||
.init = &__kmalloc_init,
|
||||
.quit = &__kmalloc_quit,
|
||||
};
|
||||
VHEX_DECLARE_MODULE(01, mod_kmalloc);
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = 'vxkernel'
|
||||
version = '0.4.0'
|
||||
version = '0.5.0'
|
||||
|
||||
[build]
|
||||
configure = 'mkdir -p build && cd build && ../config --board=fxcg50 --format=static --verbose'
|
||||
|
|
Loading…
Reference in New Issue