From f851b73cbad698fcfe0cbc8a0f22119b42adfe6a Mon Sep 17 00:00:00 2001 From: Yann MAGNIN Date: Fri, 4 Mar 2022 17:37:38 +0100 Subject: [PATCH] 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 --- board/fxcg50/fxcg50.ld | 7 +++ board/fxcg50/hardware.c | 4 +- board/fxcg50/hypervisor.c | 27 ++++++++++++ board/fxcg50/initialize.c | 36 +--------------- board/fxcg50/kmalloc.c | 38 ++++++++++++++++ include/vhex/defs/{util.h => utils.h} | 0 .../{arch => drivers/mpu/sh}/sh7305/cpu.h | 0 .../{arch => drivers/mpu/sh}/sh7305/intc.h | 0 .../{arch => drivers/mpu/sh}/sh7305/keysc.h | 0 .../{arch => drivers/mpu/sh}/sh7305/mmu.h | 0 .../{arch => drivers/mpu/sh}/sh7305/pfc.h | 0 include/vhex/{drivers => }/keyboard.h | 0 include/vhex/module.h | 41 ++++++++++++++++++ src/drivers/mpu/sh/sh7305/cpu/atomic.c | 2 +- src/drivers/mpu/sh/sh7305/cpu/cpu.c | 2 +- src/drivers/mpu/sh/sh7305/intc/install.c | 2 +- src/drivers/mpu/sh/sh7305/intc/intc.c | 2 +- src/drivers/mpu/sh/sh7305/keysc/handler.c | 6 +-- src/drivers/mpu/sh/sh7305/keysc/keysc.c | 4 +- src/drivers/mpu/sh/sh7305/mmu/utlb.c | 2 +- src/kernel/kernel.c | 37 ++++++---------- src/{render => modules/display}/dascii.c | 0 src/{render => modules/display}/dclear.c | 0 src/{render => modules/display}/dhline.c | 2 +- src/modules/display/display.c | 25 +++++++++++ src/{render => modules/display}/dline.c | 2 +- src/{render => modules/display}/dpixel.c | 0 src/{render => modules/display}/drect.c | 2 +- src/{render => modules/display}/dsize.c | 0 src/{render => modules/display}/dtext.c | 0 src/{render => modules/display}/dupdate.c | 0 src/modules/hypervisor/hypervisor.c | 29 +++++++++++++ src/{ => modules}/hypervisor/switch.c | 0 src/{ => modules}/hypervisor/table.c | 0 src/modules/keyboard/keyboard.c | 26 +++++++++++ src/{ => modules}/keyboard/keycache.c | 2 +- src/{ => modules}/keyboard/wait_event.c | 0 src/{ => modules}/kmalloc/area_vhex.c | 2 +- src/{ => modules}/kmalloc/kmalloc.c | 43 ++++++++++++++----- vxsdk.toml | 2 +- 40 files changed, 257 insertions(+), 88 deletions(-) create mode 100644 board/fxcg50/hypervisor.c create mode 100644 board/fxcg50/kmalloc.c rename include/vhex/defs/{util.h => utils.h} (100%) rename include/vhex/{arch => drivers/mpu/sh}/sh7305/cpu.h (100%) rename include/vhex/{arch => drivers/mpu/sh}/sh7305/intc.h (100%) rename include/vhex/{arch => drivers/mpu/sh}/sh7305/keysc.h (100%) rename include/vhex/{arch => drivers/mpu/sh}/sh7305/mmu.h (100%) rename include/vhex/{arch => drivers/mpu/sh}/sh7305/pfc.h (100%) rename include/vhex/{drivers => }/keyboard.h (100%) create mode 100644 include/vhex/module.h rename src/{render => modules/display}/dascii.c (100%) rename src/{render => modules/display}/dclear.c (100%) rename src/{render => modules/display}/dhline.c (97%) create mode 100644 src/modules/display/display.c rename src/{render => modules/display}/dline.c (97%) rename src/{render => modules/display}/dpixel.c (100%) rename src/{render => modules/display}/drect.c (97%) rename src/{render => modules/display}/dsize.c (100%) rename src/{render => modules/display}/dtext.c (100%) rename src/{render => modules/display}/dupdate.c (100%) create mode 100644 src/modules/hypervisor/hypervisor.c rename src/{ => modules}/hypervisor/switch.c (100%) rename src/{ => modules}/hypervisor/table.c (100%) create mode 100644 src/modules/keyboard/keyboard.c rename src/{ => modules}/keyboard/keycache.c (98%) rename src/{ => modules}/keyboard/wait_event.c (100%) rename src/{ => modules}/kmalloc/area_vhex.c (99%) rename src/{ => modules}/kmalloc/kmalloc.c (80%) diff --git a/board/fxcg50/fxcg50.ld b/board/fxcg50/fxcg50.ld index 9d92794..ac05ac4 100644 --- a/board/fxcg50/fxcg50.ld +++ b/board/fxcg50/fxcg50.ld @@ -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 */ diff --git a/board/fxcg50/hardware.c b/board/fxcg50/hardware.c index 735a289..1ef8ea6 100644 --- a/board/fxcg50/hardware.c +++ b/board/fxcg50/hardware.c @@ -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 */ diff --git a/board/fxcg50/hypervisor.c b/board/fxcg50/hypervisor.c new file mode 100644 index 0000000..eb71f86 --- /dev/null +++ b/board/fxcg50/hypervisor.c @@ -0,0 +1,27 @@ +#include + +/* 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); +} diff --git a/board/fxcg50/initialize.c b/board/fxcg50/initialize.c index d8c5f03..473535e 100644 --- a/board/fxcg50/initialize.c +++ b/board/fxcg50/initialize.c @@ -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 diff --git a/board/fxcg50/kmalloc.c b/board/fxcg50/kmalloc.c new file mode 100644 index 0000000..6e82591 --- /dev/null +++ b/board/fxcg50/kmalloc.c @@ -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 ? */ +} diff --git a/include/vhex/defs/util.h b/include/vhex/defs/utils.h similarity index 100% rename from include/vhex/defs/util.h rename to include/vhex/defs/utils.h diff --git a/include/vhex/arch/sh7305/cpu.h b/include/vhex/drivers/mpu/sh/sh7305/cpu.h similarity index 100% rename from include/vhex/arch/sh7305/cpu.h rename to include/vhex/drivers/mpu/sh/sh7305/cpu.h diff --git a/include/vhex/arch/sh7305/intc.h b/include/vhex/drivers/mpu/sh/sh7305/intc.h similarity index 100% rename from include/vhex/arch/sh7305/intc.h rename to include/vhex/drivers/mpu/sh/sh7305/intc.h diff --git a/include/vhex/arch/sh7305/keysc.h b/include/vhex/drivers/mpu/sh/sh7305/keysc.h similarity index 100% rename from include/vhex/arch/sh7305/keysc.h rename to include/vhex/drivers/mpu/sh/sh7305/keysc.h diff --git a/include/vhex/arch/sh7305/mmu.h b/include/vhex/drivers/mpu/sh/sh7305/mmu.h similarity index 100% rename from include/vhex/arch/sh7305/mmu.h rename to include/vhex/drivers/mpu/sh/sh7305/mmu.h diff --git a/include/vhex/arch/sh7305/pfc.h b/include/vhex/drivers/mpu/sh/sh7305/pfc.h similarity index 100% rename from include/vhex/arch/sh7305/pfc.h rename to include/vhex/drivers/mpu/sh/sh7305/pfc.h diff --git a/include/vhex/drivers/keyboard.h b/include/vhex/keyboard.h similarity index 100% rename from include/vhex/drivers/keyboard.h rename to include/vhex/keyboard.h diff --git a/include/vhex/module.h b/include/vhex/module.h new file mode 100644 index 0000000..5d27639 --- /dev/null +++ b/include/vhex/module.h @@ -0,0 +1,41 @@ +#ifndef __VHEX_MODULE__ +# define __VHEX_MODULE__ + +#include + +/* 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__ */ diff --git a/src/drivers/mpu/sh/sh7305/cpu/atomic.c b/src/drivers/mpu/sh/sh7305/cpu/atomic.c index e4201d9..4945053 100644 --- a/src/drivers/mpu/sh/sh7305/cpu/atomic.c +++ b/src/drivers/mpu/sh/sh7305/cpu/atomic.c @@ -1,5 +1,5 @@ #include -#include +#include /* Value of IMASK when atomic mode is entered */ static int saved_IMASK = 0; diff --git a/src/drivers/mpu/sh/sh7305/cpu/cpu.c b/src/drivers/mpu/sh/sh7305/cpu/cpu.c index c3e2d17..9574130 100644 --- a/src/drivers/mpu/sh/sh7305/cpu/cpu.c +++ b/src/drivers/mpu/sh/sh7305/cpu/cpu.c @@ -1,5 +1,5 @@ #include "vhex/driver.h" -#include "vhex/arch/sh7305/cpu.h" +#include "vhex/drivers/mpu/sh/sh7305/cpu.h" #include diff --git a/src/drivers/mpu/sh/sh7305/intc/install.c b/src/drivers/mpu/sh/sh7305/intc/install.c index a88154d..d42fcd7 100644 --- a/src/drivers/mpu/sh/sh7305/intc/install.c +++ b/src/drivers/mpu/sh/sh7305/intc/install.c @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/drivers/mpu/sh/sh7305/intc/intc.c b/src/drivers/mpu/sh/sh7305/intc/intc.c index 8647d17..4bdf86e 100644 --- a/src/drivers/mpu/sh/sh7305/intc/intc.c +++ b/src/drivers/mpu/sh/sh7305/intc/intc.c @@ -1,5 +1,5 @@ #include "vhex/driver.h" -#include "vhex/arch/sh7305/intc.h" +#include "vhex/drivers/mpu/sh/sh7305/intc.h" #include diff --git a/src/drivers/mpu/sh/sh7305/keysc/handler.c b/src/drivers/mpu/sh/sh7305/keysc/handler.c index 3bbf0e4..5f99c5b 100644 --- a/src/drivers/mpu/sh/sh7305/keysc/handler.c +++ b/src/drivers/mpu/sh/sh7305/keysc/handler.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include /* Internal indicator used by high-level function to notice when the key list is updated */ diff --git a/src/drivers/mpu/sh/sh7305/keysc/keysc.c b/src/drivers/mpu/sh/sh7305/keysc/keysc.c index 89a3ff7..07c23e6 100644 --- a/src/drivers/mpu/sh/sh7305/keysc/keysc.c +++ b/src/drivers/mpu/sh/sh7305/keysc/keysc.c @@ -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 */ diff --git a/src/drivers/mpu/sh/sh7305/mmu/utlb.c b/src/drivers/mpu/sh/sh7305/mmu/utlb.c index 6901192..b5c92be 100644 --- a/src/drivers/mpu/sh/sh7305/mmu/utlb.c +++ b/src/drivers/mpu/sh/sh7305/mmu/utlb.c @@ -2,7 +2,7 @@ // vhex:mmu:mmu - MMU driver definition and context management //--- #include -#include +#include #include /* utlb_addr() - get the P4 address of a UTLB address entry */ diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index b2f39ad..3ad510b 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -1,5 +1,5 @@ #include -#include +#include //--- @@ -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(); + } } diff --git a/src/render/dascii.c b/src/modules/display/dascii.c similarity index 100% rename from src/render/dascii.c rename to src/modules/display/dascii.c diff --git a/src/render/dclear.c b/src/modules/display/dclear.c similarity index 100% rename from src/render/dclear.c rename to src/modules/display/dclear.c diff --git a/src/render/dhline.c b/src/modules/display/dhline.c similarity index 97% rename from src/render/dhline.c rename to src/modules/display/dhline.c index baa9561..0560337 100644 --- a/src/render/dhline.c +++ b/src/modules/display/dhline.c @@ -1,5 +1,5 @@ #include -#include +#include #include /* Vhex vram */ diff --git a/src/modules/display/display.c b/src/modules/display/display.c new file mode 100644 index 0000000..90816df --- /dev/null +++ b/src/modules/display/display.c @@ -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); diff --git a/src/render/dline.c b/src/modules/display/dline.c similarity index 97% rename from src/render/dline.c rename to src/modules/display/dline.c index 094468f..0e9703b 100644 --- a/src/render/dline.c +++ b/src/modules/display/dline.c @@ -1,5 +1,5 @@ #include -#include +#include /* dline(): Bresenham line drawing algorithm Remotely adapted from MonochromeLib code by Pierre "PerriotLL" Le Gall. diff --git a/src/render/dpixel.c b/src/modules/display/dpixel.c similarity index 100% rename from src/render/dpixel.c rename to src/modules/display/dpixel.c diff --git a/src/render/drect.c b/src/modules/display/drect.c similarity index 97% rename from src/render/drect.c rename to src/modules/display/drect.c index 2ef632a..7c92a2f 100644 --- a/src/render/drect.c +++ b/src/modules/display/drect.c @@ -1,5 +1,5 @@ #include -#include +#include #include /* drect() - fill a rectangle of the screen */ diff --git a/src/render/dsize.c b/src/modules/display/dsize.c similarity index 100% rename from src/render/dsize.c rename to src/modules/display/dsize.c diff --git a/src/render/dtext.c b/src/modules/display/dtext.c similarity index 100% rename from src/render/dtext.c rename to src/modules/display/dtext.c diff --git a/src/render/dupdate.c b/src/modules/display/dupdate.c similarity index 100% rename from src/render/dupdate.c rename to src/modules/display/dupdate.c diff --git a/src/modules/hypervisor/hypervisor.c b/src/modules/hypervisor/hypervisor.c new file mode 100644 index 0000000..cbb2a9c --- /dev/null +++ b/src/modules/hypervisor/hypervisor.c @@ -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); diff --git a/src/hypervisor/switch.c b/src/modules/hypervisor/switch.c similarity index 100% rename from src/hypervisor/switch.c rename to src/modules/hypervisor/switch.c diff --git a/src/hypervisor/table.c b/src/modules/hypervisor/table.c similarity index 100% rename from src/hypervisor/table.c rename to src/modules/hypervisor/table.c diff --git a/src/modules/keyboard/keyboard.c b/src/modules/keyboard/keyboard.c new file mode 100644 index 0000000..85f5aea --- /dev/null +++ b/src/modules/keyboard/keyboard.c @@ -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); diff --git a/src/keyboard/keycache.c b/src/modules/keyboard/keycache.c similarity index 98% rename from src/keyboard/keycache.c rename to src/modules/keyboard/keycache.c index 28cb0de..665dfa1 100644 --- a/src/keyboard/keycache.c +++ b/src/modules/keyboard/keycache.c @@ -1,4 +1,4 @@ -#include +#include #include /* Internal cache, used like chained list. diff --git a/src/keyboard/wait_event.c b/src/modules/keyboard/wait_event.c similarity index 100% rename from src/keyboard/wait_event.c rename to src/modules/keyboard/wait_event.c diff --git a/src/kmalloc/area_vhex.c b/src/modules/kmalloc/area_vhex.c similarity index 99% rename from src/kmalloc/area_vhex.c rename to src/modules/kmalloc/area_vhex.c index 38178e1..4d3008b 100644 --- a/src/kmalloc/area_vhex.c +++ b/src/modules/kmalloc/area_vhex.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include diff --git a/src/kmalloc/kmalloc.c b/src/modules/kmalloc/kmalloc.c similarity index 80% rename from src/kmalloc/kmalloc.c rename to src/modules/kmalloc/kmalloc.c index c1ae000..dad4a4e 100644 --- a/src/kmalloc/kmalloc.c +++ b/src/modules/kmalloc/kmalloc.c @@ -3,7 +3,7 @@ //--- #include -#include +#include #include #include @@ -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 + +/* __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); diff --git a/vxsdk.toml b/vxsdk.toml index 778cbf7..7f1c03c 100644 --- a/vxsdk.toml +++ b/vxsdk.toml @@ -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'