From 693d9b0d8f7e7f05d598e5c94d253e141a40a295 Mon Sep 17 00:00:00 2001 From: Yann MAGNIN Date: Sun, 27 Nov 2022 10:39:06 +0100 Subject: [PATCH] vxkernel 0.6.0-25 : switch to CMake ! (WIP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @note This commit doesn't provide the complet CMake support, because many improvements need to be done in the vxSDK. You can only build the SDL2 board by hardcoding environment variables (the `vxsdk.toml file is not fonctional`) The "shared" forms of the library will be handled as a Virtual Dynamic Shared Object (vDSO) and will be common for all board. This is not supported yet. @add > [CMakeLists.txt] ¦ support project architecture ¦ support project configuration file ¦ support SDL2 board (static-only) > [scripts] ¦ provide proper API ¦ proper isolate the board manipulation ¦ proper isolate the "library format" selection (static or vdso) ¦ generate a CMake file instead of Makefile one @update > [common] ¦ rename 'board/' to 'boards/' ¦ move 'assets/', 'src/' and 'include' in 'kernel/' ¦ remove old makefile ¦ in 'boards/' proper isolate : ¦ board description : `board.toml` ¦ board file to install : e.i `fxcg50.ld` ¦ board source file : `src` ¦ board include : `include` > [configure] ¦ proper refacto the script ¦ proper isolation between vxSDK use and user @fix > [kernel/src] ¦ [drivers/common/sdl2] ¦ [keyboard] remove unused object ¦ [keyboard] proper table size declaration ¦ [sdl2] fix return value ¦ [timer] fix return value ¦ [modules] ¦ [dstack] fix return value ¦ [hypervisor] fix return value --- .gitignore | 7 + CMakeLists.txt | 101 +++++ Makefile | 371 ------------------ assets/vxconv.toml | 9 - board/fx9860g/board.ini | 11 - board/fx9860g/fx9860g.ld | 88 ----- board/fx9860g/initialize.c | 10 - board/fxcg50/fxcg50-dynamic.ld | 98 ----- {board => boards}/fxcg50/board.toml | 12 +- {board => boards}/fxcg50/fxcg50.ld | 0 .../fxcg50/include}/hardware.h | 0 {board/fxcg50 => boards/fxcg50/src}/_Exit.c | 0 .../fxcg50 => boards/fxcg50/src}/hardware.c | 0 .../fxcg50 => boards/fxcg50/src}/hypervisor.c | 0 .../fxcg50 => boards/fxcg50/src}/initialize.c | 0 {board/fxcg50 => boards/fxcg50/src}/kmalloc.c | 0 {board => boards}/sdl2/board.toml | 8 +- {board => boards}/sdl2/sdl2.ld | 0 {board/sdl2 => boards/sdl2/src}/cpu_atomic.c | 0 {board/sdl2 => boards/sdl2/src}/hypervisor.c | 0 {board/sdl2 => boards/sdl2/src}/initialize.c | 0 configure | 333 +++------------- fake/display.c | 140 ------- fake/kmalloc.c | 35 -- {assets => kernel/assets}/font8x9.png | Bin {assets => kernel/assets}/font8x9.xcf | Bin kernel/assets/vxconv.toml | 7 + {include => kernel/include}/vhex/config.h | 0 .../include}/vhex/defs/attributes.h | 0 {include => kernel/include}/vhex/defs/call.h | 0 {include => kernel/include}/vhex/defs/types.h | 0 {include => kernel/include}/vhex/defs/utils.h | 0 {include => kernel/include}/vhex/device.h | 0 {include => kernel/include}/vhex/display.h | 0 .../include}/vhex/display/color.h | 0 .../include}/vhex/display/draw.h | 0 .../include}/vhex/display/draw/circle.h | 0 .../include}/vhex/display/draw/line.h | 0 .../include}/vhex/display/draw/pixel.h | 0 .../include}/vhex/display/draw/rect.h | 0 .../include}/vhex/display/font.h | 0 .../include}/vhex/display/font/information.h | 0 .../include}/vhex/display/font/render.h | 0 .../include}/vhex/display/font/types.h | 0 .../include}/vhex/display/image.h | 0 .../include}/vhex/display/image/information.h | 0 .../include}/vhex/display/image/object.h | 0 .../include}/vhex/display/image/render.h | 0 .../include}/vhex/display/image/types.h | 0 .../include}/vhex/display/interface.h | 0 .../include}/vhex/display/shader.h | 0 .../include}/vhex/display/stack.h | 0 .../include}/vhex/display/text.h | 0 .../include}/vhex/display/text/information.h | 0 .../include}/vhex/display/text/render.h | 0 .../include}/vhex/display/types.h | 0 {include => kernel/include}/vhex/dma.h | 0 .../include}/vhex/dma/interface.h | 0 {include => kernel/include}/vhex/dma/types.h | 0 {include => kernel/include}/vhex/driver.h | 0 {include => kernel/include}/vhex/driver/cpu.h | 0 {include => kernel/include}/vhex/driver/mmu.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/cpg.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/cpu.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/dma.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/intc.h | 0 .../vhex/driver/mpu/sh/sh7305/keysc.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/mmu.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/pfc.h | 0 .../vhex/driver/mpu/sh/sh7305/power.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/rtc.h | 0 .../include}/vhex/driver/mpu/sh/sh7305/tmu.h | 0 .../include}/vhex/driver/screen/r61524.h | 0 {include => kernel/include}/vhex/fs.h | 0 {include => kernel/include}/vhex/fs/fugue.h | 0 {include => kernel/include}/vhex/hardware.h | 0 {include => kernel/include}/vhex/hypervisor.h | 0 {include => kernel/include}/vhex/kernel.h | 0 {include => kernel/include}/vhex/keyboard.h | 0 .../include}/vhex/keyboard/getkey.h | 0 .../include}/vhex/keyboard/interface.h | 0 .../include}/vhex/keyboard/keycache.h | 0 .../include}/vhex/keyboard/keycode.h | 0 .../include}/vhex/keyboard/keydown.h | 0 .../include}/vhex/keyboard/keyvent.h | 0 .../include}/vhex/keyboard/time.h | 0 .../include}/vhex/keyboard/types.h | 0 {include => kernel/include}/vhex/kmalloc.h | 0 {include => kernel/include}/vhex/module.h | 0 {include => kernel/include}/vhex/rtc.h | 0 .../include}/vhex/rtc/interface.h | 0 {include => kernel/include}/vhex/rtc/types.h | 0 {include => kernel/include}/vhex/timer.h | 0 {include => kernel/include}/vhex/timer/fps.h | 0 .../include}/vhex/timer/interface.h | 0 .../include}/vhex/timer/profiling.h | 0 .../include}/vhex/timer/types.h | 0 .../src/drivers/mpu/common}/sdl2/dma.c | 0 .../src/drivers/mpu/common}/sdl2/keyboard.c | 11 +- .../src/drivers/mpu/common}/sdl2/rtc.c | 0 .../src/drivers/mpu/common}/sdl2/sdl2.c | 1 + .../src/drivers/mpu/common}/sdl2/timer.c | 2 + .../src/drivers/mpu/common}/sdl2/window.c | 0 .../src/drivers}/mpu/sh/sh7305/cpg/cpg.c | 0 .../src/drivers}/mpu/sh/sh7305/cpu/atomic.c | 0 .../src/drivers}/mpu/sh/sh7305/cpu/cpu.c | 0 .../drivers}/mpu/sh/sh7305/cpu/registers.s | 0 .../src/drivers}/mpu/sh/sh7305/cpu/sleep.c | 0 .../src/drivers}/mpu/sh/sh7305/dma/dma.c | 0 .../src/drivers}/mpu/sh/sh7305/dma/memcpy.c | 0 .../src/drivers}/mpu/sh/sh7305/dma/memset.c | 0 .../src/drivers}/mpu/sh/sh7305/dma/wait.c | 0 .../src/drivers}/mpu/sh/sh7305/intc/exch.S | 0 .../drivers}/mpu/sh/sh7305/intc/exch_panic.c | 0 .../src/drivers}/mpu/sh/sh7305/intc/intc.c | 0 .../src/drivers}/mpu/sh/sh7305/intc/inth.S | 0 .../mpu/sh/sh7305/intc/inth_callback.S | 0 .../mpu/sh/sh7305/intc/inth_generic.S | 0 .../src/drivers}/mpu/sh/sh7305/intc/tlbh.S | 0 .../drivers}/mpu/sh/sh7305/intc/tlbh_panic.c | 0 .../drivers}/mpu/sh/sh7305/keysc/handler.c | 0 .../src/drivers}/mpu/sh/sh7305/keysc/inth.S | 0 .../drivers}/mpu/sh/sh7305/keysc/keycache.c | 0 .../src/drivers}/mpu/sh/sh7305/keysc/keysc.c | 0 .../src/drivers}/mpu/sh/sh7305/mmu/utlb.c | 0 .../src/drivers}/mpu/sh/sh7305/rtc/rtc.c | 0 .../src/drivers}/mpu/sh/sh7305/tmu/fps.c | 0 .../drivers}/mpu/sh/sh7305/tmu/inth-etmu.s | 0 .../src/drivers}/mpu/sh/sh7305/tmu/inth-tmu.s | 0 .../drivers}/mpu/sh/sh7305/tmu/profiling.c | 0 .../src/drivers}/mpu/sh/sh7305/tmu/tmu.c | 0 .../src/drivers}/screen/R61524/frame.S | 0 .../src/drivers}/screen/R61524/r61524.c | 0 {src => kernel/src/modules}/display/dclear.c | 0 {src => kernel/src/modules}/display/display.c | 0 .../src/modules}/display/draw/dcircle.c | 0 .../src/modules}/display/draw/dline.c | 0 .../src/modules}/display/draw/dpixel.c | 0 .../src/modules}/display/draw/drect.c | 0 {src => kernel/src/modules}/display/dstack.c | 3 + {src => kernel/src/modules}/display/dupdate.c | 0 .../src/modules}/display/font/information.c | 0 .../modules}/display/font/render/dfont_char.c | 0 .../src/modules}/display/image/information.c | 0 .../src/modules}/display/image/object.c | 0 .../modules}/display/image/render/dimage.c | 0 .../modules}/display/image/render/dsubimage.c | 0 .../modules}/display/image/shader/shadow.c | 0 .../src/modules}/display/text/information.c | 0 .../src/modules}/display/text/render/dprint.c | 0 .../src/modules}/display/text/render/dtext.c | 0 {src => kernel/src/modules}/dma/dma.c | 0 {src => kernel/src/modules}/dma/memcpy.c | 0 {src => kernel/src/modules}/dma/memset.c | 0 {src => kernel/src/modules}/dma/wait.c | 0 {src => kernel/src/modules}/fs/_table.c | 0 {src => kernel/src/modules}/fs/close.c | 0 {src => kernel/src/modules}/fs/fs.c | 0 {src => kernel/src/modules}/fs/fugue/close.c | 0 {src => kernel/src/modules}/fs/fugue/fugue.c | 0 {src => kernel/src/modules}/fs/fugue/lseek.c | 0 {src => kernel/src/modules}/fs/fugue/open.c | 0 {src => kernel/src/modules}/fs/fugue/read.c | 0 {src => kernel/src/modules}/fs/fugue/write.c | 0 {src => kernel/src/modules}/fs/lseek.c | 0 {src => kernel/src/modules}/fs/open.c | 0 {src => kernel/src/modules}/fs/read.c | 0 {src => kernel/src/modules}/fs/write.c | 0 .../src/modules}/hypervisor/hypervisor.c | 0 .../src/modules}/hypervisor/switch.c | 1 + .../src/modules}/hypervisor/table.c | 1 + {src => kernel/src/modules}/keyboard/getkey.c | 0 .../src/modules}/keyboard/keyboard.c | 0 .../src/modules}/keyboard/keycache.c | 0 .../src/modules}/keyboard/keydown.c | 0 .../src/modules}/keyboard/keyvent.c | 0 .../src/modules}/kmalloc/area_vhex.c | 0 {src => kernel/src/modules}/kmalloc/kmalloc.c | 0 {src => kernel/src/modules}/rtc/rtc.c | 0 {src => kernel/src/modules}/timer/fps.c | 0 {src => kernel/src/modules}/timer/profiling.c | 0 {src => kernel/src/modules}/timer/timer.c | 0 scripts/__init__.py | 56 +++ scripts/board.py | 272 +++++++++++++ scripts/confile.py | 48 +++ scripts/format.py | 34 ++ src/kernel.c | 30 -- vxsdk.toml | 32 +- 188 files changed, 636 insertions(+), 1085 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 assets/vxconv.toml delete mode 100644 board/fx9860g/board.ini delete mode 100644 board/fx9860g/fx9860g.ld delete mode 100644 board/fx9860g/initialize.c delete mode 100644 board/fxcg50/fxcg50-dynamic.ld rename {board => boards}/fxcg50/board.toml (71%) rename {board => boards}/fxcg50/fxcg50.ld (100%) rename {board/fxcg50 => boards/fxcg50/include}/hardware.h (100%) rename {board/fxcg50 => boards/fxcg50/src}/_Exit.c (100%) rename {board/fxcg50 => boards/fxcg50/src}/hardware.c (100%) rename {board/fxcg50 => boards/fxcg50/src}/hypervisor.c (100%) rename {board/fxcg50 => boards/fxcg50/src}/initialize.c (100%) rename {board/fxcg50 => boards/fxcg50/src}/kmalloc.c (100%) rename {board => boards}/sdl2/board.toml (74%) rename {board => boards}/sdl2/sdl2.ld (100%) rename {board/sdl2 => boards/sdl2/src}/cpu_atomic.c (100%) rename {board/sdl2 => boards/sdl2/src}/hypervisor.c (100%) rename {board/sdl2 => boards/sdl2/src}/initialize.c (100%) delete mode 100644 fake/display.c delete mode 100644 fake/kmalloc.c rename {assets => kernel/assets}/font8x9.png (100%) rename {assets => kernel/assets}/font8x9.xcf (100%) create mode 100644 kernel/assets/vxconv.toml rename {include => kernel/include}/vhex/config.h (100%) rename {include => kernel/include}/vhex/defs/attributes.h (100%) rename {include => kernel/include}/vhex/defs/call.h (100%) rename {include => kernel/include}/vhex/defs/types.h (100%) rename {include => kernel/include}/vhex/defs/utils.h (100%) rename {include => kernel/include}/vhex/device.h (100%) rename {include => kernel/include}/vhex/display.h (100%) rename {include => kernel/include}/vhex/display/color.h (100%) rename {include => kernel/include}/vhex/display/draw.h (100%) rename {include => kernel/include}/vhex/display/draw/circle.h (100%) rename {include => kernel/include}/vhex/display/draw/line.h (100%) rename {include => kernel/include}/vhex/display/draw/pixel.h (100%) rename {include => kernel/include}/vhex/display/draw/rect.h (100%) rename {include => kernel/include}/vhex/display/font.h (100%) rename {include => kernel/include}/vhex/display/font/information.h (100%) rename {include => kernel/include}/vhex/display/font/render.h (100%) rename {include => kernel/include}/vhex/display/font/types.h (100%) rename {include => kernel/include}/vhex/display/image.h (100%) rename {include => kernel/include}/vhex/display/image/information.h (100%) rename {include => kernel/include}/vhex/display/image/object.h (100%) rename {include => kernel/include}/vhex/display/image/render.h (100%) rename {include => kernel/include}/vhex/display/image/types.h (100%) rename {include => kernel/include}/vhex/display/interface.h (100%) rename {include => kernel/include}/vhex/display/shader.h (100%) rename {include => kernel/include}/vhex/display/stack.h (100%) rename {include => kernel/include}/vhex/display/text.h (100%) rename {include => kernel/include}/vhex/display/text/information.h (100%) rename {include => kernel/include}/vhex/display/text/render.h (100%) rename {include => kernel/include}/vhex/display/types.h (100%) rename {include => kernel/include}/vhex/dma.h (100%) rename {include => kernel/include}/vhex/dma/interface.h (100%) rename {include => kernel/include}/vhex/dma/types.h (100%) rename {include => kernel/include}/vhex/driver.h (100%) rename {include => kernel/include}/vhex/driver/cpu.h (100%) rename {include => kernel/include}/vhex/driver/mmu.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/cpg.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/cpu.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/dma.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/intc.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/keysc.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/mmu.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/pfc.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/power.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/rtc.h (100%) rename {include => kernel/include}/vhex/driver/mpu/sh/sh7305/tmu.h (100%) rename {include => kernel/include}/vhex/driver/screen/r61524.h (100%) rename {include => kernel/include}/vhex/fs.h (100%) rename {include => kernel/include}/vhex/fs/fugue.h (100%) rename {include => kernel/include}/vhex/hardware.h (100%) rename {include => kernel/include}/vhex/hypervisor.h (100%) rename {include => kernel/include}/vhex/kernel.h (100%) rename {include => kernel/include}/vhex/keyboard.h (100%) rename {include => kernel/include}/vhex/keyboard/getkey.h (100%) rename {include => kernel/include}/vhex/keyboard/interface.h (100%) rename {include => kernel/include}/vhex/keyboard/keycache.h (100%) rename {include => kernel/include}/vhex/keyboard/keycode.h (100%) rename {include => kernel/include}/vhex/keyboard/keydown.h (100%) rename {include => kernel/include}/vhex/keyboard/keyvent.h (100%) rename {include => kernel/include}/vhex/keyboard/time.h (100%) rename {include => kernel/include}/vhex/keyboard/types.h (100%) rename {include => kernel/include}/vhex/kmalloc.h (100%) rename {include => kernel/include}/vhex/module.h (100%) rename {include => kernel/include}/vhex/rtc.h (100%) rename {include => kernel/include}/vhex/rtc/interface.h (100%) rename {include => kernel/include}/vhex/rtc/types.h (100%) rename {include => kernel/include}/vhex/timer.h (100%) rename {include => kernel/include}/vhex/timer/fps.h (100%) rename {include => kernel/include}/vhex/timer/interface.h (100%) rename {include => kernel/include}/vhex/timer/profiling.h (100%) rename {include => kernel/include}/vhex/timer/types.h (100%) rename {src/driver/mpu/x86 => kernel/src/drivers/mpu/common}/sdl2/dma.c (100%) rename {src/driver/mpu/x86 => kernel/src/drivers/mpu/common}/sdl2/keyboard.c (95%) rename {src/driver/mpu/x86 => kernel/src/drivers/mpu/common}/sdl2/rtc.c (100%) rename {src/driver/mpu/x86 => kernel/src/drivers/mpu/common}/sdl2/sdl2.c (97%) rename {src/driver/mpu/x86 => kernel/src/drivers/mpu/common}/sdl2/timer.c (99%) rename {src/driver/mpu/x86 => kernel/src/drivers/mpu/common}/sdl2/window.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/cpg/cpg.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/cpu/atomic.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/cpu/cpu.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/cpu/registers.s (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/cpu/sleep.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/dma/dma.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/dma/memcpy.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/dma/memset.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/dma/wait.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/exch.S (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/exch_panic.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/intc.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/inth.S (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/inth_callback.S (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/inth_generic.S (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/tlbh.S (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/intc/tlbh_panic.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/keysc/handler.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/keysc/inth.S (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/keysc/keycache.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/keysc/keysc.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/mmu/utlb.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/rtc/rtc.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/tmu/fps.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/tmu/inth-etmu.s (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/tmu/inth-tmu.s (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/tmu/profiling.c (100%) rename {src/driver => kernel/src/drivers}/mpu/sh/sh7305/tmu/tmu.c (100%) rename {src/driver => kernel/src/drivers}/screen/R61524/frame.S (100%) rename {src/driver => kernel/src/drivers}/screen/R61524/r61524.c (100%) rename {src => kernel/src/modules}/display/dclear.c (100%) rename {src => kernel/src/modules}/display/display.c (100%) rename {src => kernel/src/modules}/display/draw/dcircle.c (100%) rename {src => kernel/src/modules}/display/draw/dline.c (100%) rename {src => kernel/src/modules}/display/draw/dpixel.c (100%) rename {src => kernel/src/modules}/display/draw/drect.c (100%) rename {src => kernel/src/modules}/display/dstack.c (99%) rename {src => kernel/src/modules}/display/dupdate.c (100%) rename {src => kernel/src/modules}/display/font/information.c (100%) rename {src => kernel/src/modules}/display/font/render/dfont_char.c (100%) rename {src => kernel/src/modules}/display/image/information.c (100%) rename {src => kernel/src/modules}/display/image/object.c (100%) rename {src => kernel/src/modules}/display/image/render/dimage.c (100%) rename {src => kernel/src/modules}/display/image/render/dsubimage.c (100%) rename {src => kernel/src/modules}/display/image/shader/shadow.c (100%) rename {src => kernel/src/modules}/display/text/information.c (100%) rename {src => kernel/src/modules}/display/text/render/dprint.c (100%) rename {src => kernel/src/modules}/display/text/render/dtext.c (100%) rename {src => kernel/src/modules}/dma/dma.c (100%) rename {src => kernel/src/modules}/dma/memcpy.c (100%) rename {src => kernel/src/modules}/dma/memset.c (100%) rename {src => kernel/src/modules}/dma/wait.c (100%) rename {src => kernel/src/modules}/fs/_table.c (100%) rename {src => kernel/src/modules}/fs/close.c (100%) rename {src => kernel/src/modules}/fs/fs.c (100%) rename {src => kernel/src/modules}/fs/fugue/close.c (100%) rename {src => kernel/src/modules}/fs/fugue/fugue.c (100%) rename {src => kernel/src/modules}/fs/fugue/lseek.c (100%) rename {src => kernel/src/modules}/fs/fugue/open.c (100%) rename {src => kernel/src/modules}/fs/fugue/read.c (100%) rename {src => kernel/src/modules}/fs/fugue/write.c (100%) rename {src => kernel/src/modules}/fs/lseek.c (100%) rename {src => kernel/src/modules}/fs/open.c (100%) rename {src => kernel/src/modules}/fs/read.c (100%) rename {src => kernel/src/modules}/fs/write.c (100%) rename {src => kernel/src/modules}/hypervisor/hypervisor.c (100%) rename {src => kernel/src/modules}/hypervisor/switch.c (99%) rename {src => kernel/src/modules}/hypervisor/table.c (99%) rename {src => kernel/src/modules}/keyboard/getkey.c (100%) rename {src => kernel/src/modules}/keyboard/keyboard.c (100%) rename {src => kernel/src/modules}/keyboard/keycache.c (100%) rename {src => kernel/src/modules}/keyboard/keydown.c (100%) rename {src => kernel/src/modules}/keyboard/keyvent.c (100%) rename {src => kernel/src/modules}/kmalloc/area_vhex.c (100%) rename {src => kernel/src/modules}/kmalloc/kmalloc.c (100%) rename {src => kernel/src/modules}/rtc/rtc.c (100%) rename {src => kernel/src/modules}/timer/fps.c (100%) rename {src => kernel/src/modules}/timer/profiling.c (100%) rename {src => kernel/src/modules}/timer/timer.c (100%) create mode 100644 scripts/__init__.py create mode 100644 scripts/board.py create mode 100644 scripts/confile.py create mode 100644 scripts/format.py delete mode 100644 src/kernel.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4caa4e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +* +!boards +!kernel +!scripts +!vxsdk.toml +!configure +!CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ecdd1aa --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,101 @@ +cmake_minimum_required(VERSION 3.15) + + +#--- +# handle vxSDK-specific +#--- + +if(NOT DEFINED ENV{VXSDK_PKG_NAME} OR NOT DEFINED ENV{VXSDK_PKG_VERSION}) + message(FATAL_ERROR "You should use the vxSDK to build this project") +endif() + +set(VXSDK_PKG_NAME $ENV{VXSDK_PKG_NAME}) +set(VXSDK_PKG_VERSION $ENV{VXSDK_PKG_VERSION}) + + +#--- +# handle configuration-specific information +#--- + +set(VXKERNEL_CONF ${CMAKE_CURRENT_SOURCE_DIR}/.vxsdk/vxkernel_config.cmake) + +if(NOT EXISTS ${VXKERNEL_CONF}) + message(FATAL_ERROR "You should performs project configuration") +endif() + +include(${VXKERNEL_CONF}) + +if(NOT DEFINED VXKERNEL_ENABLE_MODULES) + message(FATAL_ERROR "Missing module declaration") +elseif(NOT DEFINED VXKERNEL_ENABLE_DRIVERS) + message(FATAL_ERROR "Missing driver declaration") +endif() + + +#--- +# handle project-specific information +#--- + +project(${VXSDK_PKG_NAME} VERSION ${VXSDK_PKG_VERSION} LANGUAGES C ASM) + + +#--- +# Handle source listing +#--- + +set(VXKERNEL_SRC_TARGETS "") +set(VXKERNEL_INC_TARGETS "") +set(VXKERNEL_DIR_TARGETS "") + +foreach(mod ${VXKERNEL_ENABLE_MODULES}) + list( + APPEND + VXKERNEL_DIR_TARGETS + ${CMAKE_CURRENT_SOURCE_DIR}/kernel/src/modules/${mod} + ) +endforeach() + +foreach(drv ${VXKERNEL_ENABLE_DRIVERS}) + list( + APPEND + VXKERNEL_DIR_TARGETS + ${CMAKE_CURRENT_SOURCE_DIR}/kernel/src/drivers/${drv} + ) +endforeach() + +set(board_prefix ${CMAKE_CURRENT_SOURCE_DIR}/boards/${VXKERNEL_ENABLE_BOARD}) +if(EXISTS ${board_prefix}/src) + list(APPEND VXKERNEL_DIR_TARGETS ${board_prefix}/src) +endif() + +foreach(dir ${VXKERNEL_DIR_TARGETS}) + file(GLOB_RECURSE dir_src ${dir}/*.c ${dir}/*.S ${dir}/*.s) + list(APPEND VXKERNEL_SRC_TARGETS ${dir_src}) +endforeach() + +set(dir ${CMAKE_CURRENT_SOURCE_DIR}/kernel/src) +file(GLOB dir_src ${dir}/*.c ${dir}/*.S ${dir}/*.s) +list(APPEND VXKERNEL_SRC_TARGETS ${dir_src}) + +list(APPEND VXKERNEL_INC_TARGETS ${CMAKE_CURRENT_SOURCE_DIR}/kernel/include) +if(EXISTS ${board_prefix}/include) + list(APPEND VXKERNEL_INC_TARGETS ${board_prefix}/include) +endif() + +if(DEFINED VXKERNEL_CMAKE_DEBUG) + message( + FATAL_ERROR + "dir list = ${VXKERNEL_DIR_TARGETS}\n" + "src list = ${VXKERNEL_SRC_TARGETS}\n" + "inc list = ${VXKERNEL_INC_TARGETS}\n" + ) +endif() + + +#--- +# Compile-specific declaration +#--- + +include_directories(${VXKERNEL_INC_TARGETS}) +add_compile_options(-Wall -Wextra ${VXKERNEL_EXTRA_CFLAGS}) +add_library(vxkernel ${VXKERNEL_SRC_TARGETS}) diff --git a/Makefile b/Makefile deleted file mode 100644 index a2eab22..0000000 --- a/Makefile +++ /dev/null @@ -1,371 +0,0 @@ -#!/usr/bin/make -f -# --- -# Project: vxKernek - Vhex project kernel -# Author: yann.magnin@protonmail.com -# -# TODO: -# <> proper clean rule -# --- - - - - -#--- -# environment check -#--- - -ifeq ($(VXSDK_PREFIX_BUILD),) -$(error "The vxKernel sould be build using the vxSDK") -endif - - - - -#--- -# Build rules -#--- - -# Make selects the first rule set when you type "make" but, in our case, we are -# going to generate most of the rules. So, we set a placeholder to force the -# "all" rule to be the "first" rule -first: all - -# display the library version -version: - @echo "$(VXSDK_PKG_VERSION)" - -# Display helper -help: - @ echo 'Rules listing:' - @ echo '... all the default, if no target is provided' - @ echo '... clean remove build object' - @ echo '... fclean remove all generated object' - @ echo '... re same as `make fclean all`' - @ echo '... version display version' - @ echo '... install install the library' - @ echo '... uninstall uninstall the library' - -.PHONY: help version first - - - - -#--- -# Check build validity -#--- - -CONFIG := $(VXSDK_PREFIX_BUILD)/kernel.cfg -ifeq "$(wildcard $(CONFIG))" "" -$(error "config file $(CONFIG) does not exist (you should use `../configure`") -endif -include $(CONFIG) - - - - -#--- -# Variables definition -#--- - -# Many variables will be provided by the "kernel.cfg" file (generated during -# the configuration part). It will defines: -# <> BOARD - indicate the target board list -# <> {BOARD}-SRC-MODULE-PATH - list of all sources path for a specific board -# <> {BOARD}-TOOLCHAIN-PREFIX - toolchain prefix for a board (sh-elf, ...) -# <> FORMAT - format for the kernel (static, dynamic) - -# color definition, for swagg :D -red := \033[1;31m -green := \033[1;32m -blue := \033[1;34m -white := \033[1;37m -nocolor := \033[1;0m - - - -#--- -# Rules definition -# -# The objectif is to generate a building this build tree: -# -# /: -# |-- kernel.cfg -# |-- /: -# | |-- /: -# | | |-- obj/: -# | | | |-- main.o -# ... -# | | | `-- initialize.o -# | | `-- map -# | |-- .ld -# | `-- libvxkernel-.[so/a] -# `-- Makefile -#--- - -# Function that will generate a rule for one object file -# @param -# *1 - GCC name (with specific prefix if needed) -# *2 - CFLAGS list -# *3 - source file path -# *4 - build root directory path -# *5 - object file compilation rule list -# *6 - dependencies file compilation rule list -# *7 - unique id (used to generate unique variable name (workaround)) -define generate-compile-file-rule - -# generate the object file path -# @note -# <> This is alse the generated rule name -# <> step: -# 1) ../board/path/file.c -> ../board/path/file -# 2) .._board_path_file -> board_path_file -# 3) board_path_file.o -> {build path}/board_path_file.o -tname := $(strip $7) -obj-$(tname)-name := $$(basename $3) -obj-$(tname)-name := $$(subst /,_,$$(obj-$(tname)-name)) -obj-$(tname)-name := $$(patsubst %,$4/%.o,$$(obj-$(tname)-name)) - -# generate the building rule - -$$(obj-$(tname)-name): $3 - @ mkdir -p $$(dir $$@) -ifeq ($(CONFIG.VERBOSE),false) - @ printf "$(green)>$(nocolor) $(white)$$@$(nocolor)\n" - @ $1 $2 -o $$@ -c $$< -MMD -MT $$@ -MF $$@.d -MP -else - $1 $2 -o $$@ -c $$< -MMD -MT $$@ -MF $$@.d -MP -endif - -# register the build rules and dependencies file name - -$5 += $$(obj-$(tname)-name) -$6 += $$(obj-$(tname)-name).d - -endef - - - -# Function that will generate all rules for a specific board and format -# @params -# *1 - board name -# *2 - format name (static or dynamic) -# *3 - rules list variable name -define generate-target-lib - -# generate common information -# @note: -# Because we generate rule "on-the-fly" we need to create unique variable -# definition because make is not a "scoped" language. (therefore, when a -# variable is created, it will never be destroyed until the end of the script) -t-$1-$2-build := $(VXSDK_PREFIX_BUILD)/$1/$2 - -# generate compilation flags - -t-$1-$2-ar := $$(CONFIG.$1.TOOLCHAIN.PREFIX)ar -t-$1-$2-ld := $$(CONFIG.$1.TOOLCHAIN.PREFIX)ld -t-$1-$2-gcc := $$(CONFIG.$1.TOOLCHAIN.PREFIX)gcc -t-$1-$2-ldflags := $$(CONFIG.$1.TOOLCHAIN.LDFLAGS) -t-$1-$2-cflags := $$(CONFIG.$1.TOOLCHAIN.CFLAGS) - -# generate compiler information (used to find some library like libgcc.a) -t-$1-$2-gcc-base := $$(shell $$(CONFIG.$1.TOOLCHAIN.PREFIX)gcc --print-search-dirs | grep install | sed 's/install: //') -t-$1-$2-gcc-header := -I$$(t-$1-$2-gcc-base)/include -I$$(t-$1-$2-gcc-base)/include/openlibm -t-$1-$2-cflags += -Iinclude -I. -Isrc $$(t-$1-$2-gcc-header) -t-$1-$2-cflags += -Llib -L. -L$$(t-$1-$2-gcc-base) - -# generate file's sources list, based on the configuration step - -t-$1-$2-src := $$(foreach path,$$(CONFIG.$1.SRC-MODULE-PATH),\ - $$(wildcard $$(path)/*.c) \ - $$(wildcard $$(path)/*.S) \ - $$(wildcard $$(path)/*.s)) - -# generate format-specific flags - -t-$1-$2-exec := -ifeq ($2,static) -t-$1-$2-exec := $(VXSDK_PREFIX_BUILD)/libvhex-$1.a -endif -ifeq ($2,dynamic) -t-$1-$2-ldflags += -shared -t-$1-$2-ldflags += -soname=libvhex-$1-$(VXSDK_PKG_VERSION).so -t-$1-$2-ldflags += -Map=$$(t-$1-$2-build)/map -t-$1-$2-exec := $(VXSDK_PREFIX_BUILD)/libvhex-$1.so -t-$1-$2-src := $(wildcard fake/*.c) -endif - -# generate file's compilation rules and all object filename into an object -# list variable, this will be used by the `main` rule - -t-$1-$2-obj := -t-$1-$2-dep := -$$(foreach source,$$(t-$1-$2-src),$$(eval \ - $$(call generate-compile-file-rule,\ - $$(t-$1-$2-gcc),\ - $$(t-$1-$2-cflags),\ - $$(source),\ - $$(t-$1-$2-build),\ - t-$1-$2-obj,\ - t-$1-$2-dep,\ - $1-$2\ - ))\ -) - -# asset generation -t-$1-$2-asset := $(patsubst \ - $(VXSDK_ASSETS_SRC)/%,\ - $(VXSDK_ASSETS_BUILD)/$1/$2/%.o,\ - $(wildcard $(VXSDK_ASSETS_SRC)/*.c) \ -) - -$(VXSDK_ASSETS_BUILD)/$1/$2/%.o: $(VXSDK_ASSETS_SRC)/% -ifeq ($(CONFIG.VERBOSE),true) - @ mkdir -p $$(dir $$@) - $$(CONFIG.$1.TOOLCHAIN.PREFIX)gcc $$(t-$1-$2-cflags) -o $$@ -c $$< -else - @ mkdir -p $$(dir $$@) - @ printf "$(green)>$(nocolor) $(white)$@$(nocolor)\n" - @ $$(CONFIG.$1.TOOLCHAIN.PREFIX)gcc $$(t-$1-$2-cflags) -o $$@ -c $$< -endif - -# generate the "main" rule for this lib - -$$(t-$1-$2-exec): $$(t-$1-$2-obj) $$(t-$1-$2-asset) - @ mkdir -p $$(dir $$@) - @ echo "dep : $$(t-$1-$2-dep)" - @ printf "$(blue)Create the library $(red)$$@$(nocolor)\n" -ifeq ($2,dynamic) - $$(t-$1-$2-gcc) -shared $$(t-$1-$2-cflags) $$(t-$1-$2-gcc-libs) -o $$@ $$^ -else - $$(t-$1-$2-ar) crs $$@ $$^ -endif - -# register the "main" building rule for the lib - -$3 += $$(t-$1-$2-exec) - - -# import dependencies rules --include $$(t-$1-$2-dep) -$$(t-$1-$2-dep): ; -.PRECIOUS: $$(t-$1-$2-dep) - -endef - - -# Generate the "main" rules list -target-lib-list := -$(foreach board,$(CONFIG.BOARD-LIST),\ - $(foreach format,$(CONFIG.FORMAT-LIST),$(eval\ - $(call generate-target-lib,$(board),$(format),target-lib-list)\ - ))\ -) - - - -#--- -# Build rules -#--- -all: $(target-lib-list) - -.PHONY: all - - - -#--- -# Generate installation rules -#--- -# Common rules generated for the installation of each libraries. -# Basically, it will generate -install and -uninstall rules -# @note: -# *1 - library pathname -# *2 - variable name (installation rules list) -# *3 - variable name (uninstallation rules list) -define generate-install-rule - -# Generate the installation rule -$(basename $(notdir $1))-install: - install -d $(VXSDK_PREFIX_LIB) - install $1 -m 644 $(VXSDK_PREFIX_LIB) - -# Generate the uninstallation rule -$(basename $(notdir $1))-uninstall: - rm -f $(VXSDK_PREFIX_LIB)/$(notdir $1) - -# Register generated rules into their appropriate list -$2 += $(basename $(notdir $1))-install -$3 += $(basename $(notdir $1))-uninstall -endef - -# Common rules generated for the installation of board-specific linker script -# @note: -# $1 - board name -# $2 - variable name (installation rules list) -# $3 - variable name (uninstallation rules list) -define generate-board-install-rule - -$1-install: - install -d $(VXSDK_PREFIX_LIB) - install board/$(strip $1)/*.ld -m 644 $(VXSDK_PREFIX_LIB) - -$1-uninstall: - rm -f $(VXSDK_PREFIX_LIB)/$(strip $1).ld - rm -f $(VXSDK_PREFIX_LIB)/$(strip $1)-dynamic.ld - -$2 += $1-install -$3 += $1-uninstall - -endef - -# Generate all installation/uninstallation rules - -target-install-rules := -target-uninstall-rules := -$(foreach target,$(target-lib-list),$(eval \ - $(call generate-install-rule, \ - $(target), \ - target-install-rules, \ - target-uninstall-rules \ - ) \ -)) -$(foreach board,$(CONFIG.BOARD-LIST),$(eval \ - $(call generate-board-install-rule, \ - $(board), \ - target-install-rules, \ - target-uninstall-rules \ - ) \ -)) - -# Generate the path where include directory will be installed. -target-install-hdr-dir := $(VXSDK_PREFIX_LIB)/include/ -ifeq ($(wildcard $(target-install-header-dir)vhex/.*),) - target-install-hdr-dir := $(target-install-hdr-dir)vhex -endif - - - -#--- -# Installation rules -#--- -install: $(target-install-rules) - mkdir -p $(dir $(target-install-hdr-dir)) - cp -r include/vhex $(target-install-hdr-dir) - -unsintall: $(target-uninstall_rules) - rm -rf $(VXSDK_PREFIX_LIB)/include/vhex - -.PHONY: install uninstall - - - -#--- -# cleaning rules -#--- -#clean: TODO: generate clean rule list - - -fclean: clean - rm -rf $(target-lib-list) -re: fclean all - -.PHONY: clean fclean re all diff --git a/assets/vxconv.toml b/assets/vxconv.toml deleted file mode 100644 index b132db8..0000000 --- a/assets/vxconv.toml +++ /dev/null @@ -1,9 +0,0 @@ -[font8x9] -path = 'font8x9.png' -type = 'font' -charset = 'print' -grid.size = '8x12' -grid.padding = 1 -grid.border = 1 -proportional = 1 -line_height = 9 diff --git a/board/fx9860g/board.ini b/board/fx9860g/board.ini deleted file mode 100644 index 9f8c8ea..0000000 --- a/board/fx9860g/board.ini +++ /dev/null @@ -1,11 +0,0 @@ -[meta] -description=Casio's Fx9860g calculator board description - -[drivers] -screen=T6K73A,ML9801 -mpu=sh7305 - -[toolchain] -prefix=sh-elf-vhex- -cflags=-DFX9860G,-m4-nofpu,-mb -libs=-lgcc diff --git a/board/fx9860g/fx9860g.ld b/board/fx9860g/fx9860g.ld deleted file mode 100644 index 542e420..0000000 --- a/board/fx9860g/fx9860g.ld +++ /dev/null @@ -1,88 +0,0 @@ -/* - Linker script for the fxcg50 platform. -*/ - -OUTPUT_FORMAT(elf32-sh) -OUTPUT_ARCH(sh3) -ENTRY(_initilize) - -/* -** Linker script for user executables. -*/ -MEMORY -{ - /* virtual memory, read-write segment */ - userram (WX) : o = 0x00000000, l = 256k -} - -SECTIONS -{ - /* Code */ - .text : { - *(.text); - *(.text.*); - - } > userram - - /* Read-only sections */ - .rodata : { - /* Read-Only data */ - *(.rodata); - *(.rodata.*); - - /* Dynamic symbols */ - *(.hash) - *(.dynsym) - *(.dynstr) - *(.dynbss) - *(.dynamic) - - /* Procedure Linkage Table */ - *(.plt) - - /* GLobal Offset Table */ - *(.got.plt) - *(.got.*) - *(.got) - } > userram - - /* Relocatable sections */ - .rela.dyn : { - *(.rela.plt) - *(.rela.got) - *(.rela.got.*) - *(.rela.*) - *(.rela.text) - *(.real.data) - } > userram - - /* readable / writable data */ - .data ALIGN(4) : { - - /* Data sections */ - *(.data); - *(.data.*); - - /* bss section included to avoid missaligned segment */ - *(.bss); - *(.bss.*); - *(COMMON); - } > userram - - /* unwanted section */ - /DISCARD/ : { - *(.gnu.*) - *(.debug_info) - *(.debug_abbrev) - *(.debug_loc) - *(.debug_aranges) - *(.debug_ranges) - *(.debug_line) - *(.debug_str) - *(.jcr) - *(.eh_frame_hdr) - *(.eh_frame) - *(.comment) - *(.interp) - } -} diff --git a/board/fx9860g/initialize.c b/board/fx9860g/initialize.c deleted file mode 100644 index 8ca5eed..0000000 --- a/board/fx9860g/initialize.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -/* for now, just involve the main routine */ -void initialize(void) -{ - extern int main(void); - - main(); - while(1) { __asm__ volatile ("sleep"::); } -} diff --git a/board/fxcg50/fxcg50-dynamic.ld b/board/fxcg50/fxcg50-dynamic.ld deleted file mode 100644 index d714a9c..0000000 --- a/board/fxcg50/fxcg50-dynamic.ld +++ /dev/null @@ -1,98 +0,0 @@ -/* - Linker script for the dynamic version of Vhex (fxcg50) -*/ - -OUTPUT_FORMAT("elf32-sh", "elf32-sh", "elf32-sh") -OUTPUT_ARCH(sh4) -ENTRY(_main) - - -/* -** Linker script for user executables. -*/ -MEMORY -{ - /* virtual memory, read-write segment */ - userram (WX) : o = 0x00000000, l = 1M -} - -SECTIONS -{ /* Code */ - .text : { - *(.text); - *(.text.*); - - _bctors = . ; - *(.ctors .ctors.*) - _ectors = . ; - - _bdtors = . ; - *(.dtors .dtors.*) - _edtors = . ; - - } > userram - - /* Read-only sections */ - .rodata : { - /* Read-Only data */ - *(.rodata); - *(.rodata.*); - } > userram - - - /* The GOT section is a bit exotic. - When I generate the PIE executable, all global variables are stored - is the *(.got) section and the __GLOBAL_OFFSET_TABLE__ object is - generated and inserted in the *(.got.plt) section. - - But, neither of *(.plt*) or *(rela*) section are generated to help - me out for the "relocation" of each address stored in the GOT. The - result is that the content of the GOT is always absolute addresses, - which makes the machine crash. - - So, the idea to bypass this limitation (probably due to the custom - GCC which not provide critical information for the relocation) is to - isolate the GOT in a standalone section and, after the loading of - the image, walk thought the relocalised table and manually patch - each address. - - Moreover, the __GLOBAL_OFFSET_TABLE__ is used like a table, so, the - section ".got.plt" SHOULD be before the .got section. */ - .got.plt : { *(.got.plt) *(.igot.plt) *(.igot) } - .got : { *(.got) } - - /* readable / writable data */ - .data ALIGN(4) : { - *(.data); - *(.data.*); - *(COMMON); - } - - /* bss section included to avoid missaligned segment */ - .bss ALIGN(4) : { - *(.bss); - *(.bss.*); - - /* dynamic BSS information (move me ?) */ - *(.dynbss) - } > userram - - /* unwanted section */ - /DISCARD/ : { - *(.rela.debug*) - *(.gnu.*) - *(.debug_info) - *(.debug_abbrev) - *(.debug_loc) - *(.debug_aranges) - *(.debug_ranges) - *(.debug_line) - *(.debug_str) - *(.debug_*) - *(.jcr) - *(.eh_frame_hdr) - *(.eh_frame) - *(.comment) - *(.interp) - } -} diff --git a/board/fxcg50/board.toml b/boards/fxcg50/board.toml similarity index 71% rename from board/fxcg50/board.toml rename to boards/fxcg50/board.toml index a4b62dd..17c9949 100644 --- a/board/fxcg50/board.toml +++ b/boards/fxcg50/board.toml @@ -1,5 +1,5 @@ [meta] -description = "Casio's Fxcg50 calculator board description" +description = "Casio's Fxcg50 calculator board" author = 'Yann MAGNIN' [config] @@ -13,14 +13,14 @@ modules = [ 'rtc', 'dma' ] - -[drivers] -screen = 'R61524' -mpu = 'sh7305' +drivers = [ + 'screen:R61524', + 'mpu:sh:sh7305' +] [toolchain] -prefix = 'sh-elf-vhex-' +file = 'toolchain-sh.cmake' cflags = [ '-DFXCG50', '-m4-nofpu', diff --git a/board/fxcg50/fxcg50.ld b/boards/fxcg50/fxcg50.ld similarity index 100% rename from board/fxcg50/fxcg50.ld rename to boards/fxcg50/fxcg50.ld diff --git a/board/fxcg50/hardware.h b/boards/fxcg50/include/hardware.h similarity index 100% rename from board/fxcg50/hardware.h rename to boards/fxcg50/include/hardware.h diff --git a/board/fxcg50/_Exit.c b/boards/fxcg50/src/_Exit.c similarity index 100% rename from board/fxcg50/_Exit.c rename to boards/fxcg50/src/_Exit.c diff --git a/board/fxcg50/hardware.c b/boards/fxcg50/src/hardware.c similarity index 100% rename from board/fxcg50/hardware.c rename to boards/fxcg50/src/hardware.c diff --git a/board/fxcg50/hypervisor.c b/boards/fxcg50/src/hypervisor.c similarity index 100% rename from board/fxcg50/hypervisor.c rename to boards/fxcg50/src/hypervisor.c diff --git a/board/fxcg50/initialize.c b/boards/fxcg50/src/initialize.c similarity index 100% rename from board/fxcg50/initialize.c rename to boards/fxcg50/src/initialize.c diff --git a/board/fxcg50/kmalloc.c b/boards/fxcg50/src/kmalloc.c similarity index 100% rename from board/fxcg50/kmalloc.c rename to boards/fxcg50/src/kmalloc.c diff --git a/board/sdl2/board.toml b/boards/sdl2/board.toml similarity index 74% rename from board/sdl2/board.toml rename to boards/sdl2/board.toml index 32cbb96..cbedb45 100644 --- a/board/sdl2/board.toml +++ b/boards/sdl2/board.toml @@ -11,12 +11,12 @@ modules = [ 'dma', 'rtc' ] - -[drivers] -mpu = 'sdl2' +drivers = [ + 'mpu:common:sdl2' +] [toolchain] -prefix = '' cflags = [ + '-D__VXKERNEL_SUPPORT_SDL2__', '-g3' ] diff --git a/board/sdl2/sdl2.ld b/boards/sdl2/sdl2.ld similarity index 100% rename from board/sdl2/sdl2.ld rename to boards/sdl2/sdl2.ld diff --git a/board/sdl2/cpu_atomic.c b/boards/sdl2/src/cpu_atomic.c similarity index 100% rename from board/sdl2/cpu_atomic.c rename to boards/sdl2/src/cpu_atomic.c diff --git a/board/sdl2/hypervisor.c b/boards/sdl2/src/hypervisor.c similarity index 100% rename from board/sdl2/hypervisor.c rename to boards/sdl2/src/hypervisor.c diff --git a/board/sdl2/initialize.c b/boards/sdl2/src/initialize.c similarity index 100% rename from board/sdl2/initialize.c rename to boards/sdl2/src/initialize.c diff --git a/configure b/configure index a18408b..be0d1e6 100755 --- a/configure +++ b/configure @@ -1,290 +1,79 @@ -#! /usr/bin/python3 -import sys -import os.path +#! /usr/bin/env python3 +""" +Vhex kernel configuration script +""" import os -import shutil -import toml +import sys +import scripts -help_string = f""" -usage: config [options...] +__HELP__ = """ usage: configure [OTPIONS ...] [ACTIONS ...] -Configuration script for the Vhex unikernel. You should build out-of-tree by -creating a build directory and configuring from there. +Configuration script for the Vhex unikernel. + +Actions: + board: Board hadling + select the board as compilation target + --list,list display board list information + --info,info display a particular board information + + vdso: "Fake" kernel compilation like a vDSO + --info,info display all infromation that the vdso will exposes + --generate,gen generate the fake build source (debug) Options: - -h,--help - display this message - - --verbose - display more information during the compilation step - - -- + -h,--help display this message + --verbose display more information during the compilation step + --board= select the board to target + --format= select the format of the library generation. You can use two format: - <> static - generate a static library - <> dynamic - generate a dynamic library - By default, only "dynamic" is used. - - --board[=BOARD,board[,...]] - select boards. If no board name is given, a list of all available board - will be printed. - - --prefix=PATH - installation path for all generated libraries -""".strip() + <> static - generate a static library + <> vdso - generate a "fake" dynamic library (default) +""" #--- -# Internal functions +# Public #--- -def __list_dir(path): - ldir = [] - for dirent in os.listdir(path): - dpath = f'{path}/{dirent}' - if os.path.isdir(dpath): - ldir.append(dpath) - ldir += __list_dir(dpath) - return ldir - -def error(string, exitcode=84): - print(string, file=sys.stderr) - exit(exitcode) - -def warn(string): - print(string, file=sys.stderr) - -#--- -# part handlers -#--- - -def _board_check(file, board_list): - r"""Check board and architecture. - - This function will try to load the /board//board.toml file - which describe the required module to be build for the kernel image - generation. - - TODO: board.toml documentation - TODO: function documentation - - Args: - > [out] file (stream) - the 'kernel.cfg' files stream - > [in] board_list (list of str) - list of all board to support - """ - - # list available board and architecture - try: - boards = list(os.walk('board'))[0][1] - archs = list(os.walk('src/driver/mpu'))[0][1] - except Exception: - error(f"{prefix}: project not found, fix VXSDK_PREFIX_BUILD") - - # list all available board if no board target is provided - if not board_list: - print('board available:') - for board in boards: - path = f'board/{board}/board.toml' - if not os.path.exists(path): - warn(f'missing \'{board}\' board description') - continue - conf = None - with open(path) as f: - conf = toml.loads(f.read()) - if not ('meta' in conf) or not ('description' in conf['meta']): - print(f'<> {board}'.ljust(16) + 'No description available') - continue - print(f'<> {board}'.ljust(16) + f"{conf['meta']['description']}") - exit(0) - - # generate board list information - valid_board_list = [] - for board in board_list: - - # try to read the board description - if not (board in boards): - warn(f"board '{board}' does not exist") - continue - path = f'board/{board}/board.toml' - if not os.path.exists(path): - warn(f"board '{board}' does not have descriptor file") - continue - conf = None - with open(path) as f: - conf = toml.loads(f.read()) - - # check fundamental information - if not ('drivers' in conf) or not ('mpu' in conf['drivers']): - warn(f"board '{board}': missing MPU information") - continue - - # gues the architecture - arch = None - mpu = conf['drivers']['mpu'] - for _arch in archs: - if not os.path.exists(f'src/driver/mpu/{_arch}/{mpu}'): - continue - arch = _arch - break - if not arch: - warn(f"board '{board}': unreconized MPU '{mpu}'") - continue - - # Now generate the complete directory list that will be used by the - # Makefile as to find all source files - pathlist = [ - f'src', - f'board/{board}', - f'src/driver/mpu/{_arch}/{mpu}' - ] - pathlist += __list_dir(f'board/{board}') - pathlist += __list_dir(f'src/driver/mpu/{_arch}/{mpu}') - - # generate driver path list - for driver in conf['drivers']: - if driver == 'mpu': - continue - dpath = f'src/driver/{driver}' - if not os.path.exists(dpath): - warn(f"board '{board}': unreconized driver \'{driver}\', skipped") - continue - for t in conf['drivers'][driver].split(','): - tpath = dpath + '/' + t - if not os.path.exists(tpath): - warn(f"board '{board}': unreconized driver '{t}'") - continue - pathlist.append(tpath) - pathlist += __list_dir(tpath) - - # generate module path list - modules = [] - if ('config' in conf) and ('modules' in conf['config']): - modules = conf['config']['modules'] - for dirent in os.listdir(f'src'): - if (dirent in ['driver']): - continue - if modules and not (dirent in modules): - continue - pathlist.append(f'src/{dirent}') - pathlist += __list_dir(f'src/{dirent}') - - # fetch toolchain information - # TODO: polymorphisme - ldflags,cflags,prefix,libs = [],[],[],[] - if 'toolchain' in conf: - if 'prefix' in conf['toolchain']: - prefix = conf['toolchain']['prefix'] - if 'cflags' in conf['toolchain']: - cflags = conf['toolchain']['cflags'] - if 'libs' in conf['toolchain']: - libs = conf['toolchain']['libs'] - - # add board information in the make configuration file - confstr = 'CONFIG.' + board - file.write( - confstr + '.SRC-MODULE-PATH := ' + ' '.join(map(str, pathlist)) + '\n' - + confstr + '.TOOLCHAIN.LDFLAGS := ' + ' '.join(map(str, ldflags)) + '\n' - + confstr + '.TOOLCHAIN.CFLAGS := ' + ' '.join(map(str, cflags)) + '\n' - + confstr + '.TOOLCHAIN.PREFIX := ' + prefix + '\n' - + confstr + '.LIBS :=' + ' '.join(map(str, libs)) + '\n' - ) - - # append board list - valid_board_list.append(board) - - # write board list - file.write('CONFIG.BOARD-LIST := ' + ' '.join(valid_board_list) + '\n') - - - - -def _format_check(file, format_list): - file.write('CONFIG.FORMAT-LIST :=') - for _format in format_list: - if not (_format in ["static", "dynamic", "all"]): - print("%s: unreconized format '%s'" % (sys.argv[0], _format)) - exit(84) - if _format == 'all': - file.write(' dynamic static\n') - return - file.write(' ' + _format) - if not format_list: - file.write(' dynamic') - file.write('\n') - -def _prefix_check(file, prefix): - file.write('CONFIG.INSTALL-PREFIX :=' + prefix + '\n') - -def _verbose_check(file, verbose): - file.write(f"CONFIG.VERBOSE := {'true' if verbose else 'false'}\n") - -#--- -# Public part -#--- - -def parse_arguments(): - """ - The objectif of this function is to generate the "arguments object" with - all arguments passed throuth this script correctly isolated. - """ - args = { - 'board' : [], - 'format' : set(), - 'verbose': False, - 'prefix': '' - } - arg_name = [ - "-h", - "--help", - "--static", - "--dynamic", - "--verbose", - "--board", - "--prefix" - ] - for arg in sys.argv[1:]: - info = arg.split("=") - if (info[0] in arg_name) == False: - print("%s: unreconized option '%s'" % (sys.argv[0],info[0])) - print("Try '%s --help' for more information" % sys.argv[0]) - exit(84) - if info[0] == "--verbose": - args["verbose"] = True - continue - if info[0] == "--prefix": - args["prefix"] = info[1] - continue - if info[0] in ['--static', '--dynamic']: - args['format'].add(info[0][2:]) - continue - if len(info) > 1: - args[info[0][2:]] = info[1].split(",") - return args - - - -def main(): +def main(argv): """ main entry of the script """ # early check - if ('-h' in sys.argv[1:]) or ('--help' in sys.argv[1:]): - print(help_string) - exit(0) + if '-h' in argv or '--help' in argv: + print(__HELP__) + sys.exit(0) - # check if we are used by the vxSDK or not - try: - bprefix = os.environ['VXSDK_PREFIX_BUILD'] - except Exception: - error('The vxKernel cannot be built without using the vxSDK.') + # handle vxSDK configuration + if 'VXSDK_PKG_TARGET' in os.environ: + argv.append(f"--board={os.environ['VXSDK_PKG_TARGET']}") + + # default behaviour + if not argv: + print(__HELP__) + sys.exit(0) + + # configure default value + kernconf = { + 'VXKERNEL_ENABLE_VERBOSE' : False, + 'VXKERNEL_ENABLE_MODULES' : [], + 'VXKERNEL_ENABLE_DRIVERS' : [], + 'VXKERNEL_TARGET_FORMAT' : 'vdso', + } # check user arguments - args = parse_arguments() + for i, arg in enumerate(argv): + if arg == '--verbose': + kernconf['VXKERNEL_ENABLE_VERBOSE'] = True + elif arg.find('--board=') == 0: + scripts.select('board', kernconf, arg[8:]) + elif arg.find('--format=') == 0: + scripts.select('format', kernconf, arg[9:]) + elif arg in ['board', 'format']: + scripts.subcommand(arg, argv[i+1:]) + else: + print(f"argument '{arg}' not recognized", file=sys.stderr) + sys.exit(84) - # creare the configuration file - file = open(f'{bprefix}/kernel.cfg', 'w') + # generate the configuration file + return scripts.generate_confile(kernconf) - # handle all part of the configuration steps - _board_check(file, args['board']) - _format_check(file, args['format']) - _prefix_check(file, args['prefix']) - _verbose_check(file, args['verbose']) - -main() +main(sys.argv[1:]) diff --git a/fake/display.c b/fake/display.c deleted file mode 100644 index 4b2a265..0000000 --- a/fake/display.c +++ /dev/null @@ -1,140 +0,0 @@ - -/* dpixel(): Change a pixel's color */ -void dpixel(int x, int y, int color) -{ - (void)x; - (void)y; - (void)color; -} - -/* dupdate(): Push the video RAM to the display driver */ -void dupdate(void) -{ - ; -} - -/* dclear(): Fill the screen with a single color */ -void dclear(int color) -{ - (void)color; -} - -/* dascii() : display one ASCII character */ -extern void dascii(int x, int y, int fg, int bg, int n) -{ - (void)x; - (void)y; - (void)fg; - (void)bg; - (void)n; -} - -/* dline(): Render a straight line */ -void dline(int x1, int y1, int x2, int y2, int color) -{ - (void)x1; - (void)y1; - (void)x2; - (void)y2; - (void)color; -} - -/* dtext() : display raw text */ -void dtext(int x, int y, int fg, char const * restrict const text) -{ - (void)x; - (void)y; - (void)fg; - (void)text; -} - -/* dprint() : display formated text */ -void dprint(int x, int y, int fg, char const * const text, ...) -{ - (void)x; - (void)y; - (void)fg; - (void)text; -} - -/* dsize(): Get the width and height of rendered text */ -void dsize(char const *str, int *w, int *h) -{ - (void)str; - (void)w; - (void)h; -} - -/* dnsize(): Get the width and height of rendered text for the n first char */ -void dnsize(char const *str, int n, int *w, int *h) -{ - (void)str; - (void)n; - (void)w; - (void)h; -} - -/* drect(): Fill a rectangle of the screen */ -void drect(int x1, int y1, int x2, int y2, int color) -{ - (void)x1; - (void)y1; - (void)x2; - (void)y2; - (void)color; -} - -/* dhline(): Draw horizontal line */ -void dhline(int x1, int x2, int y, int color) -{ - (void)x1; - (void)x2; - (void)y; - (void)color; -} - -/* dvline(): Draw vertical line */ -void dvline(int y1, int y2, int x, int color) -{ - (void)y1; - (void)y2; - (void)x; - (void)color; -} - -void dsubimage(int x, int y, void *image, int left, int top, - int width, int height, int flags) -{ - (void)x; - (void)y; - (void)image; - (void)left; - (void)top; - (void)width; - (void)height; - (void)flags; -} - -void *dfont(void const *font) -{ - (void)font; -} - -void dimage(int x, int y, void const *image) -{ - (void)x; - (void)y; - (void)image; -} - -void dprint_opt(int x, int y, int fg, int bg, int halign, int valign, - char const *format, ...) -{ - (void)x; - (void)y; - (void)fg; - (void)bg; - (void)halign; - (void)valign; - (void)format; -} diff --git a/fake/kmalloc.c b/fake/kmalloc.c deleted file mode 100644 index 70cfd86..0000000 --- a/fake/kmalloc.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -/* kmalloc(): Allocate memory in one of the available arenas - This function acts like malloc(). The second parameter specifies which arena - to allocate from; when NULL, all default arenas are considered. - - @size Size of requested block - @arena_name Name of arena to allocate in (can be NULL) - Returns address of allocated block, NULL on error. */ -void *kmalloc(size_t size, char const *arena_name) -{ - (void)size; - (void)arena_name; -} - -/* krealloc(): Reallocate memory - This function acts like realloc(). It only tries to reallocate the block in - the arena where it was previously allocated. Note that if NULL is returned, - the user needs to have a copy of the original address or the memory will - become unreachable. - - @ptr Existing allocated block - @size New requested size for the block - Returns address of reallocated block, NULL on error. */ -void *krealloc(void *ptr, size_t size) -{ - (void)ptr; - (void)size; -} - -/* kfree(): Free memory allocated with kalloc() */ -void kfree(void *ptr) -{ - (void)ptr; -} diff --git a/assets/font8x9.png b/kernel/assets/font8x9.png similarity index 100% rename from assets/font8x9.png rename to kernel/assets/font8x9.png diff --git a/assets/font8x9.xcf b/kernel/assets/font8x9.xcf similarity index 100% rename from assets/font8x9.xcf rename to kernel/assets/font8x9.xcf diff --git a/kernel/assets/vxconv.toml b/kernel/assets/vxconv.toml new file mode 100644 index 0000000..315c20a --- /dev/null +++ b/kernel/assets/vxconv.toml @@ -0,0 +1,7 @@ +[font8x9] +path = 'font8x9.png' +type = 'font' +grid_size = '8x12' +grid_padding = 1 +proportional = true +line_height = 9 diff --git a/include/vhex/config.h b/kernel/include/vhex/config.h similarity index 100% rename from include/vhex/config.h rename to kernel/include/vhex/config.h diff --git a/include/vhex/defs/attributes.h b/kernel/include/vhex/defs/attributes.h similarity index 100% rename from include/vhex/defs/attributes.h rename to kernel/include/vhex/defs/attributes.h diff --git a/include/vhex/defs/call.h b/kernel/include/vhex/defs/call.h similarity index 100% rename from include/vhex/defs/call.h rename to kernel/include/vhex/defs/call.h diff --git a/include/vhex/defs/types.h b/kernel/include/vhex/defs/types.h similarity index 100% rename from include/vhex/defs/types.h rename to kernel/include/vhex/defs/types.h diff --git a/include/vhex/defs/utils.h b/kernel/include/vhex/defs/utils.h similarity index 100% rename from include/vhex/defs/utils.h rename to kernel/include/vhex/defs/utils.h diff --git a/include/vhex/device.h b/kernel/include/vhex/device.h similarity index 100% rename from include/vhex/device.h rename to kernel/include/vhex/device.h diff --git a/include/vhex/display.h b/kernel/include/vhex/display.h similarity index 100% rename from include/vhex/display.h rename to kernel/include/vhex/display.h diff --git a/include/vhex/display/color.h b/kernel/include/vhex/display/color.h similarity index 100% rename from include/vhex/display/color.h rename to kernel/include/vhex/display/color.h diff --git a/include/vhex/display/draw.h b/kernel/include/vhex/display/draw.h similarity index 100% rename from include/vhex/display/draw.h rename to kernel/include/vhex/display/draw.h diff --git a/include/vhex/display/draw/circle.h b/kernel/include/vhex/display/draw/circle.h similarity index 100% rename from include/vhex/display/draw/circle.h rename to kernel/include/vhex/display/draw/circle.h diff --git a/include/vhex/display/draw/line.h b/kernel/include/vhex/display/draw/line.h similarity index 100% rename from include/vhex/display/draw/line.h rename to kernel/include/vhex/display/draw/line.h diff --git a/include/vhex/display/draw/pixel.h b/kernel/include/vhex/display/draw/pixel.h similarity index 100% rename from include/vhex/display/draw/pixel.h rename to kernel/include/vhex/display/draw/pixel.h diff --git a/include/vhex/display/draw/rect.h b/kernel/include/vhex/display/draw/rect.h similarity index 100% rename from include/vhex/display/draw/rect.h rename to kernel/include/vhex/display/draw/rect.h diff --git a/include/vhex/display/font.h b/kernel/include/vhex/display/font.h similarity index 100% rename from include/vhex/display/font.h rename to kernel/include/vhex/display/font.h diff --git a/include/vhex/display/font/information.h b/kernel/include/vhex/display/font/information.h similarity index 100% rename from include/vhex/display/font/information.h rename to kernel/include/vhex/display/font/information.h diff --git a/include/vhex/display/font/render.h b/kernel/include/vhex/display/font/render.h similarity index 100% rename from include/vhex/display/font/render.h rename to kernel/include/vhex/display/font/render.h diff --git a/include/vhex/display/font/types.h b/kernel/include/vhex/display/font/types.h similarity index 100% rename from include/vhex/display/font/types.h rename to kernel/include/vhex/display/font/types.h diff --git a/include/vhex/display/image.h b/kernel/include/vhex/display/image.h similarity index 100% rename from include/vhex/display/image.h rename to kernel/include/vhex/display/image.h diff --git a/include/vhex/display/image/information.h b/kernel/include/vhex/display/image/information.h similarity index 100% rename from include/vhex/display/image/information.h rename to kernel/include/vhex/display/image/information.h diff --git a/include/vhex/display/image/object.h b/kernel/include/vhex/display/image/object.h similarity index 100% rename from include/vhex/display/image/object.h rename to kernel/include/vhex/display/image/object.h diff --git a/include/vhex/display/image/render.h b/kernel/include/vhex/display/image/render.h similarity index 100% rename from include/vhex/display/image/render.h rename to kernel/include/vhex/display/image/render.h diff --git a/include/vhex/display/image/types.h b/kernel/include/vhex/display/image/types.h similarity index 100% rename from include/vhex/display/image/types.h rename to kernel/include/vhex/display/image/types.h diff --git a/include/vhex/display/interface.h b/kernel/include/vhex/display/interface.h similarity index 100% rename from include/vhex/display/interface.h rename to kernel/include/vhex/display/interface.h diff --git a/include/vhex/display/shader.h b/kernel/include/vhex/display/shader.h similarity index 100% rename from include/vhex/display/shader.h rename to kernel/include/vhex/display/shader.h diff --git a/include/vhex/display/stack.h b/kernel/include/vhex/display/stack.h similarity index 100% rename from include/vhex/display/stack.h rename to kernel/include/vhex/display/stack.h diff --git a/include/vhex/display/text.h b/kernel/include/vhex/display/text.h similarity index 100% rename from include/vhex/display/text.h rename to kernel/include/vhex/display/text.h diff --git a/include/vhex/display/text/information.h b/kernel/include/vhex/display/text/information.h similarity index 100% rename from include/vhex/display/text/information.h rename to kernel/include/vhex/display/text/information.h diff --git a/include/vhex/display/text/render.h b/kernel/include/vhex/display/text/render.h similarity index 100% rename from include/vhex/display/text/render.h rename to kernel/include/vhex/display/text/render.h diff --git a/include/vhex/display/types.h b/kernel/include/vhex/display/types.h similarity index 100% rename from include/vhex/display/types.h rename to kernel/include/vhex/display/types.h diff --git a/include/vhex/dma.h b/kernel/include/vhex/dma.h similarity index 100% rename from include/vhex/dma.h rename to kernel/include/vhex/dma.h diff --git a/include/vhex/dma/interface.h b/kernel/include/vhex/dma/interface.h similarity index 100% rename from include/vhex/dma/interface.h rename to kernel/include/vhex/dma/interface.h diff --git a/include/vhex/dma/types.h b/kernel/include/vhex/dma/types.h similarity index 100% rename from include/vhex/dma/types.h rename to kernel/include/vhex/dma/types.h diff --git a/include/vhex/driver.h b/kernel/include/vhex/driver.h similarity index 100% rename from include/vhex/driver.h rename to kernel/include/vhex/driver.h diff --git a/include/vhex/driver/cpu.h b/kernel/include/vhex/driver/cpu.h similarity index 100% rename from include/vhex/driver/cpu.h rename to kernel/include/vhex/driver/cpu.h diff --git a/include/vhex/driver/mmu.h b/kernel/include/vhex/driver/mmu.h similarity index 100% rename from include/vhex/driver/mmu.h rename to kernel/include/vhex/driver/mmu.h diff --git a/include/vhex/driver/mpu/sh/sh7305/cpg.h b/kernel/include/vhex/driver/mpu/sh/sh7305/cpg.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/cpg.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/cpg.h diff --git a/include/vhex/driver/mpu/sh/sh7305/cpu.h b/kernel/include/vhex/driver/mpu/sh/sh7305/cpu.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/cpu.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/cpu.h diff --git a/include/vhex/driver/mpu/sh/sh7305/dma.h b/kernel/include/vhex/driver/mpu/sh/sh7305/dma.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/dma.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/dma.h diff --git a/include/vhex/driver/mpu/sh/sh7305/intc.h b/kernel/include/vhex/driver/mpu/sh/sh7305/intc.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/intc.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/intc.h diff --git a/include/vhex/driver/mpu/sh/sh7305/keysc.h b/kernel/include/vhex/driver/mpu/sh/sh7305/keysc.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/keysc.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/keysc.h diff --git a/include/vhex/driver/mpu/sh/sh7305/mmu.h b/kernel/include/vhex/driver/mpu/sh/sh7305/mmu.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/mmu.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/mmu.h diff --git a/include/vhex/driver/mpu/sh/sh7305/pfc.h b/kernel/include/vhex/driver/mpu/sh/sh7305/pfc.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/pfc.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/pfc.h diff --git a/include/vhex/driver/mpu/sh/sh7305/power.h b/kernel/include/vhex/driver/mpu/sh/sh7305/power.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/power.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/power.h diff --git a/include/vhex/driver/mpu/sh/sh7305/rtc.h b/kernel/include/vhex/driver/mpu/sh/sh7305/rtc.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/rtc.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/rtc.h diff --git a/include/vhex/driver/mpu/sh/sh7305/tmu.h b/kernel/include/vhex/driver/mpu/sh/sh7305/tmu.h similarity index 100% rename from include/vhex/driver/mpu/sh/sh7305/tmu.h rename to kernel/include/vhex/driver/mpu/sh/sh7305/tmu.h diff --git a/include/vhex/driver/screen/r61524.h b/kernel/include/vhex/driver/screen/r61524.h similarity index 100% rename from include/vhex/driver/screen/r61524.h rename to kernel/include/vhex/driver/screen/r61524.h diff --git a/include/vhex/fs.h b/kernel/include/vhex/fs.h similarity index 100% rename from include/vhex/fs.h rename to kernel/include/vhex/fs.h diff --git a/include/vhex/fs/fugue.h b/kernel/include/vhex/fs/fugue.h similarity index 100% rename from include/vhex/fs/fugue.h rename to kernel/include/vhex/fs/fugue.h diff --git a/include/vhex/hardware.h b/kernel/include/vhex/hardware.h similarity index 100% rename from include/vhex/hardware.h rename to kernel/include/vhex/hardware.h diff --git a/include/vhex/hypervisor.h b/kernel/include/vhex/hypervisor.h similarity index 100% rename from include/vhex/hypervisor.h rename to kernel/include/vhex/hypervisor.h diff --git a/include/vhex/kernel.h b/kernel/include/vhex/kernel.h similarity index 100% rename from include/vhex/kernel.h rename to kernel/include/vhex/kernel.h diff --git a/include/vhex/keyboard.h b/kernel/include/vhex/keyboard.h similarity index 100% rename from include/vhex/keyboard.h rename to kernel/include/vhex/keyboard.h diff --git a/include/vhex/keyboard/getkey.h b/kernel/include/vhex/keyboard/getkey.h similarity index 100% rename from include/vhex/keyboard/getkey.h rename to kernel/include/vhex/keyboard/getkey.h diff --git a/include/vhex/keyboard/interface.h b/kernel/include/vhex/keyboard/interface.h similarity index 100% rename from include/vhex/keyboard/interface.h rename to kernel/include/vhex/keyboard/interface.h diff --git a/include/vhex/keyboard/keycache.h b/kernel/include/vhex/keyboard/keycache.h similarity index 100% rename from include/vhex/keyboard/keycache.h rename to kernel/include/vhex/keyboard/keycache.h diff --git a/include/vhex/keyboard/keycode.h b/kernel/include/vhex/keyboard/keycode.h similarity index 100% rename from include/vhex/keyboard/keycode.h rename to kernel/include/vhex/keyboard/keycode.h diff --git a/include/vhex/keyboard/keydown.h b/kernel/include/vhex/keyboard/keydown.h similarity index 100% rename from include/vhex/keyboard/keydown.h rename to kernel/include/vhex/keyboard/keydown.h diff --git a/include/vhex/keyboard/keyvent.h b/kernel/include/vhex/keyboard/keyvent.h similarity index 100% rename from include/vhex/keyboard/keyvent.h rename to kernel/include/vhex/keyboard/keyvent.h diff --git a/include/vhex/keyboard/time.h b/kernel/include/vhex/keyboard/time.h similarity index 100% rename from include/vhex/keyboard/time.h rename to kernel/include/vhex/keyboard/time.h diff --git a/include/vhex/keyboard/types.h b/kernel/include/vhex/keyboard/types.h similarity index 100% rename from include/vhex/keyboard/types.h rename to kernel/include/vhex/keyboard/types.h diff --git a/include/vhex/kmalloc.h b/kernel/include/vhex/kmalloc.h similarity index 100% rename from include/vhex/kmalloc.h rename to kernel/include/vhex/kmalloc.h diff --git a/include/vhex/module.h b/kernel/include/vhex/module.h similarity index 100% rename from include/vhex/module.h rename to kernel/include/vhex/module.h diff --git a/include/vhex/rtc.h b/kernel/include/vhex/rtc.h similarity index 100% rename from include/vhex/rtc.h rename to kernel/include/vhex/rtc.h diff --git a/include/vhex/rtc/interface.h b/kernel/include/vhex/rtc/interface.h similarity index 100% rename from include/vhex/rtc/interface.h rename to kernel/include/vhex/rtc/interface.h diff --git a/include/vhex/rtc/types.h b/kernel/include/vhex/rtc/types.h similarity index 100% rename from include/vhex/rtc/types.h rename to kernel/include/vhex/rtc/types.h diff --git a/include/vhex/timer.h b/kernel/include/vhex/timer.h similarity index 100% rename from include/vhex/timer.h rename to kernel/include/vhex/timer.h diff --git a/include/vhex/timer/fps.h b/kernel/include/vhex/timer/fps.h similarity index 100% rename from include/vhex/timer/fps.h rename to kernel/include/vhex/timer/fps.h diff --git a/include/vhex/timer/interface.h b/kernel/include/vhex/timer/interface.h similarity index 100% rename from include/vhex/timer/interface.h rename to kernel/include/vhex/timer/interface.h diff --git a/include/vhex/timer/profiling.h b/kernel/include/vhex/timer/profiling.h similarity index 100% rename from include/vhex/timer/profiling.h rename to kernel/include/vhex/timer/profiling.h diff --git a/include/vhex/timer/types.h b/kernel/include/vhex/timer/types.h similarity index 100% rename from include/vhex/timer/types.h rename to kernel/include/vhex/timer/types.h diff --git a/src/driver/mpu/x86/sdl2/dma.c b/kernel/src/drivers/mpu/common/sdl2/dma.c similarity index 100% rename from src/driver/mpu/x86/sdl2/dma.c rename to kernel/src/drivers/mpu/common/sdl2/dma.c diff --git a/src/driver/mpu/x86/sdl2/keyboard.c b/kernel/src/drivers/mpu/common/sdl2/keyboard.c similarity index 95% rename from src/driver/mpu/x86/sdl2/keyboard.c rename to kernel/src/drivers/mpu/common/sdl2/keyboard.c index 34d4395..516e2a2 100644 --- a/src/driver/mpu/x86/sdl2/keyboard.c +++ b/kernel/src/drivers/mpu/common/sdl2/keyboard.c @@ -9,21 +9,12 @@ #define __SDL2_KEYCODE_SUPPORTED 16 -static struct { - vkey_event_t keycache[__SDL2_KEYCODE_SUPPORTED]; - struct { - vkey_event_t *list; - int nb_evt_max; - int idx; - } queue; -} keyinfo; - static struct { int sdl2_id; char const * const sdl2_name; int vhex_id; char const * const vhex_name; -} key_translation[16] = { +} key_translation[__SDL2_KEYCODE_SUPPORTED] = { { .sdl2_id = 49, .sdl2_name = "1", .vhex_id = VKEY_F1, .vhex_name = "F1" diff --git a/src/driver/mpu/x86/sdl2/rtc.c b/kernel/src/drivers/mpu/common/sdl2/rtc.c similarity index 100% rename from src/driver/mpu/x86/sdl2/rtc.c rename to kernel/src/drivers/mpu/common/sdl2/rtc.c diff --git a/src/driver/mpu/x86/sdl2/sdl2.c b/kernel/src/drivers/mpu/common/sdl2/sdl2.c similarity index 97% rename from src/driver/mpu/x86/sdl2/sdl2.c rename to kernel/src/drivers/mpu/common/sdl2/sdl2.c index 9a708d4..f302842 100644 --- a/src/driver/mpu/x86/sdl2/sdl2.c +++ b/kernel/src/drivers/mpu/common/sdl2/sdl2.c @@ -19,6 +19,7 @@ static int __sdl2_init(void) int rc = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); if(rc < 0) return err("Cannot initialize SDL: %s\n", SDL_GetError()); + return 0; } __attribute__((destructor)) diff --git a/src/driver/mpu/x86/sdl2/timer.c b/kernel/src/drivers/mpu/common/sdl2/timer.c similarity index 99% rename from src/driver/mpu/x86/sdl2/timer.c rename to kernel/src/drivers/mpu/common/sdl2/timer.c index 0fa1466..621a219 100644 --- a/src/driver/mpu/x86/sdl2/timer.c +++ b/kernel/src/drivers/mpu/common/sdl2/timer.c @@ -69,6 +69,7 @@ int sdl_tmu_start(tid_t id) (void*)&__sdl_tmu_nexus, (void*)(uintptr_t)id ); + return 0; } /* sdl_tmu_reload() - change a timer's delay constant for next interrupts */ @@ -114,6 +115,7 @@ int sdl_tmu_prof_init(timer_prof_t *prof) prof->anchor = SDL_GetTicks(); prof->elapsed = 0; prof->rec = 0; + return 0; } /* sdl_tmu_prof_enter(): Start counting time for a function */ diff --git a/src/driver/mpu/x86/sdl2/window.c b/kernel/src/drivers/mpu/common/sdl2/window.c similarity index 100% rename from src/driver/mpu/x86/sdl2/window.c rename to kernel/src/drivers/mpu/common/sdl2/window.c diff --git a/src/driver/mpu/sh/sh7305/cpg/cpg.c b/kernel/src/drivers/mpu/sh/sh7305/cpg/cpg.c similarity index 100% rename from src/driver/mpu/sh/sh7305/cpg/cpg.c rename to kernel/src/drivers/mpu/sh/sh7305/cpg/cpg.c diff --git a/src/driver/mpu/sh/sh7305/cpu/atomic.c b/kernel/src/drivers/mpu/sh/sh7305/cpu/atomic.c similarity index 100% rename from src/driver/mpu/sh/sh7305/cpu/atomic.c rename to kernel/src/drivers/mpu/sh/sh7305/cpu/atomic.c diff --git a/src/driver/mpu/sh/sh7305/cpu/cpu.c b/kernel/src/drivers/mpu/sh/sh7305/cpu/cpu.c similarity index 100% rename from src/driver/mpu/sh/sh7305/cpu/cpu.c rename to kernel/src/drivers/mpu/sh/sh7305/cpu/cpu.c diff --git a/src/driver/mpu/sh/sh7305/cpu/registers.s b/kernel/src/drivers/mpu/sh/sh7305/cpu/registers.s similarity index 100% rename from src/driver/mpu/sh/sh7305/cpu/registers.s rename to kernel/src/drivers/mpu/sh/sh7305/cpu/registers.s diff --git a/src/driver/mpu/sh/sh7305/cpu/sleep.c b/kernel/src/drivers/mpu/sh/sh7305/cpu/sleep.c similarity index 100% rename from src/driver/mpu/sh/sh7305/cpu/sleep.c rename to kernel/src/drivers/mpu/sh/sh7305/cpu/sleep.c diff --git a/src/driver/mpu/sh/sh7305/dma/dma.c b/kernel/src/drivers/mpu/sh/sh7305/dma/dma.c similarity index 100% rename from src/driver/mpu/sh/sh7305/dma/dma.c rename to kernel/src/drivers/mpu/sh/sh7305/dma/dma.c diff --git a/src/driver/mpu/sh/sh7305/dma/memcpy.c b/kernel/src/drivers/mpu/sh/sh7305/dma/memcpy.c similarity index 100% rename from src/driver/mpu/sh/sh7305/dma/memcpy.c rename to kernel/src/drivers/mpu/sh/sh7305/dma/memcpy.c diff --git a/src/driver/mpu/sh/sh7305/dma/memset.c b/kernel/src/drivers/mpu/sh/sh7305/dma/memset.c similarity index 100% rename from src/driver/mpu/sh/sh7305/dma/memset.c rename to kernel/src/drivers/mpu/sh/sh7305/dma/memset.c diff --git a/src/driver/mpu/sh/sh7305/dma/wait.c b/kernel/src/drivers/mpu/sh/sh7305/dma/wait.c similarity index 100% rename from src/driver/mpu/sh/sh7305/dma/wait.c rename to kernel/src/drivers/mpu/sh/sh7305/dma/wait.c diff --git a/src/driver/mpu/sh/sh7305/intc/exch.S b/kernel/src/drivers/mpu/sh/sh7305/intc/exch.S similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/exch.S rename to kernel/src/drivers/mpu/sh/sh7305/intc/exch.S diff --git a/src/driver/mpu/sh/sh7305/intc/exch_panic.c b/kernel/src/drivers/mpu/sh/sh7305/intc/exch_panic.c similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/exch_panic.c rename to kernel/src/drivers/mpu/sh/sh7305/intc/exch_panic.c diff --git a/src/driver/mpu/sh/sh7305/intc/intc.c b/kernel/src/drivers/mpu/sh/sh7305/intc/intc.c similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/intc.c rename to kernel/src/drivers/mpu/sh/sh7305/intc/intc.c diff --git a/src/driver/mpu/sh/sh7305/intc/inth.S b/kernel/src/drivers/mpu/sh/sh7305/intc/inth.S similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/inth.S rename to kernel/src/drivers/mpu/sh/sh7305/intc/inth.S diff --git a/src/driver/mpu/sh/sh7305/intc/inth_callback.S b/kernel/src/drivers/mpu/sh/sh7305/intc/inth_callback.S similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/inth_callback.S rename to kernel/src/drivers/mpu/sh/sh7305/intc/inth_callback.S diff --git a/src/driver/mpu/sh/sh7305/intc/inth_generic.S b/kernel/src/drivers/mpu/sh/sh7305/intc/inth_generic.S similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/inth_generic.S rename to kernel/src/drivers/mpu/sh/sh7305/intc/inth_generic.S diff --git a/src/driver/mpu/sh/sh7305/intc/tlbh.S b/kernel/src/drivers/mpu/sh/sh7305/intc/tlbh.S similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/tlbh.S rename to kernel/src/drivers/mpu/sh/sh7305/intc/tlbh.S diff --git a/src/driver/mpu/sh/sh7305/intc/tlbh_panic.c b/kernel/src/drivers/mpu/sh/sh7305/intc/tlbh_panic.c similarity index 100% rename from src/driver/mpu/sh/sh7305/intc/tlbh_panic.c rename to kernel/src/drivers/mpu/sh/sh7305/intc/tlbh_panic.c diff --git a/src/driver/mpu/sh/sh7305/keysc/handler.c b/kernel/src/drivers/mpu/sh/sh7305/keysc/handler.c similarity index 100% rename from src/driver/mpu/sh/sh7305/keysc/handler.c rename to kernel/src/drivers/mpu/sh/sh7305/keysc/handler.c diff --git a/src/driver/mpu/sh/sh7305/keysc/inth.S b/kernel/src/drivers/mpu/sh/sh7305/keysc/inth.S similarity index 100% rename from src/driver/mpu/sh/sh7305/keysc/inth.S rename to kernel/src/drivers/mpu/sh/sh7305/keysc/inth.S diff --git a/src/driver/mpu/sh/sh7305/keysc/keycache.c b/kernel/src/drivers/mpu/sh/sh7305/keysc/keycache.c similarity index 100% rename from src/driver/mpu/sh/sh7305/keysc/keycache.c rename to kernel/src/drivers/mpu/sh/sh7305/keysc/keycache.c diff --git a/src/driver/mpu/sh/sh7305/keysc/keysc.c b/kernel/src/drivers/mpu/sh/sh7305/keysc/keysc.c similarity index 100% rename from src/driver/mpu/sh/sh7305/keysc/keysc.c rename to kernel/src/drivers/mpu/sh/sh7305/keysc/keysc.c diff --git a/src/driver/mpu/sh/sh7305/mmu/utlb.c b/kernel/src/drivers/mpu/sh/sh7305/mmu/utlb.c similarity index 100% rename from src/driver/mpu/sh/sh7305/mmu/utlb.c rename to kernel/src/drivers/mpu/sh/sh7305/mmu/utlb.c diff --git a/src/driver/mpu/sh/sh7305/rtc/rtc.c b/kernel/src/drivers/mpu/sh/sh7305/rtc/rtc.c similarity index 100% rename from src/driver/mpu/sh/sh7305/rtc/rtc.c rename to kernel/src/drivers/mpu/sh/sh7305/rtc/rtc.c diff --git a/src/driver/mpu/sh/sh7305/tmu/fps.c b/kernel/src/drivers/mpu/sh/sh7305/tmu/fps.c similarity index 100% rename from src/driver/mpu/sh/sh7305/tmu/fps.c rename to kernel/src/drivers/mpu/sh/sh7305/tmu/fps.c diff --git a/src/driver/mpu/sh/sh7305/tmu/inth-etmu.s b/kernel/src/drivers/mpu/sh/sh7305/tmu/inth-etmu.s similarity index 100% rename from src/driver/mpu/sh/sh7305/tmu/inth-etmu.s rename to kernel/src/drivers/mpu/sh/sh7305/tmu/inth-etmu.s diff --git a/src/driver/mpu/sh/sh7305/tmu/inth-tmu.s b/kernel/src/drivers/mpu/sh/sh7305/tmu/inth-tmu.s similarity index 100% rename from src/driver/mpu/sh/sh7305/tmu/inth-tmu.s rename to kernel/src/drivers/mpu/sh/sh7305/tmu/inth-tmu.s diff --git a/src/driver/mpu/sh/sh7305/tmu/profiling.c b/kernel/src/drivers/mpu/sh/sh7305/tmu/profiling.c similarity index 100% rename from src/driver/mpu/sh/sh7305/tmu/profiling.c rename to kernel/src/drivers/mpu/sh/sh7305/tmu/profiling.c diff --git a/src/driver/mpu/sh/sh7305/tmu/tmu.c b/kernel/src/drivers/mpu/sh/sh7305/tmu/tmu.c similarity index 100% rename from src/driver/mpu/sh/sh7305/tmu/tmu.c rename to kernel/src/drivers/mpu/sh/sh7305/tmu/tmu.c diff --git a/src/driver/screen/R61524/frame.S b/kernel/src/drivers/screen/R61524/frame.S similarity index 100% rename from src/driver/screen/R61524/frame.S rename to kernel/src/drivers/screen/R61524/frame.S diff --git a/src/driver/screen/R61524/r61524.c b/kernel/src/drivers/screen/R61524/r61524.c similarity index 100% rename from src/driver/screen/R61524/r61524.c rename to kernel/src/drivers/screen/R61524/r61524.c diff --git a/src/display/dclear.c b/kernel/src/modules/display/dclear.c similarity index 100% rename from src/display/dclear.c rename to kernel/src/modules/display/dclear.c diff --git a/src/display/display.c b/kernel/src/modules/display/display.c similarity index 100% rename from src/display/display.c rename to kernel/src/modules/display/display.c diff --git a/src/display/draw/dcircle.c b/kernel/src/modules/display/draw/dcircle.c similarity index 100% rename from src/display/draw/dcircle.c rename to kernel/src/modules/display/draw/dcircle.c diff --git a/src/display/draw/dline.c b/kernel/src/modules/display/draw/dline.c similarity index 100% rename from src/display/draw/dline.c rename to kernel/src/modules/display/draw/dline.c diff --git a/src/display/draw/dpixel.c b/kernel/src/modules/display/draw/dpixel.c similarity index 100% rename from src/display/draw/dpixel.c rename to kernel/src/modules/display/draw/dpixel.c diff --git a/src/display/draw/drect.c b/kernel/src/modules/display/draw/drect.c similarity index 100% rename from src/display/draw/drect.c rename to kernel/src/modules/display/draw/drect.c diff --git a/src/display/dstack.c b/kernel/src/modules/display/dstack.c similarity index 99% rename from src/display/dstack.c rename to kernel/src/modules/display/dstack.c index 14b5085..7674a78 100644 --- a/src/display/dstack.c +++ b/kernel/src/modules/display/dstack.c @@ -63,6 +63,7 @@ int dstack_init(void) break; } } + return 0; } /* dstack_quit() : Uninit the draw stack */ @@ -73,6 +74,7 @@ int dstack_quit(void) dstack_info.pool.action[i].shader.number = 0; dstack_info.pool.action[i].shader.idx = -1; } + return 0; } @@ -204,6 +206,7 @@ int dstack_invalidate(void) action[i].quit(action[i].call.args); } dstack_info.pool.idx = -1; + return 0; } diff --git a/src/display/dupdate.c b/kernel/src/modules/display/dupdate.c similarity index 100% rename from src/display/dupdate.c rename to kernel/src/modules/display/dupdate.c diff --git a/src/display/font/information.c b/kernel/src/modules/display/font/information.c similarity index 100% rename from src/display/font/information.c rename to kernel/src/modules/display/font/information.c diff --git a/src/display/font/render/dfont_char.c b/kernel/src/modules/display/font/render/dfont_char.c similarity index 100% rename from src/display/font/render/dfont_char.c rename to kernel/src/modules/display/font/render/dfont_char.c diff --git a/src/display/image/information.c b/kernel/src/modules/display/image/information.c similarity index 100% rename from src/display/image/information.c rename to kernel/src/modules/display/image/information.c diff --git a/src/display/image/object.c b/kernel/src/modules/display/image/object.c similarity index 100% rename from src/display/image/object.c rename to kernel/src/modules/display/image/object.c diff --git a/src/display/image/render/dimage.c b/kernel/src/modules/display/image/render/dimage.c similarity index 100% rename from src/display/image/render/dimage.c rename to kernel/src/modules/display/image/render/dimage.c diff --git a/src/display/image/render/dsubimage.c b/kernel/src/modules/display/image/render/dsubimage.c similarity index 100% rename from src/display/image/render/dsubimage.c rename to kernel/src/modules/display/image/render/dsubimage.c diff --git a/src/display/image/shader/shadow.c b/kernel/src/modules/display/image/shader/shadow.c similarity index 100% rename from src/display/image/shader/shadow.c rename to kernel/src/modules/display/image/shader/shadow.c diff --git a/src/display/text/information.c b/kernel/src/modules/display/text/information.c similarity index 100% rename from src/display/text/information.c rename to kernel/src/modules/display/text/information.c diff --git a/src/display/text/render/dprint.c b/kernel/src/modules/display/text/render/dprint.c similarity index 100% rename from src/display/text/render/dprint.c rename to kernel/src/modules/display/text/render/dprint.c diff --git a/src/display/text/render/dtext.c b/kernel/src/modules/display/text/render/dtext.c similarity index 100% rename from src/display/text/render/dtext.c rename to kernel/src/modules/display/text/render/dtext.c diff --git a/src/dma/dma.c b/kernel/src/modules/dma/dma.c similarity index 100% rename from src/dma/dma.c rename to kernel/src/modules/dma/dma.c diff --git a/src/dma/memcpy.c b/kernel/src/modules/dma/memcpy.c similarity index 100% rename from src/dma/memcpy.c rename to kernel/src/modules/dma/memcpy.c diff --git a/src/dma/memset.c b/kernel/src/modules/dma/memset.c similarity index 100% rename from src/dma/memset.c rename to kernel/src/modules/dma/memset.c diff --git a/src/dma/wait.c b/kernel/src/modules/dma/wait.c similarity index 100% rename from src/dma/wait.c rename to kernel/src/modules/dma/wait.c diff --git a/src/fs/_table.c b/kernel/src/modules/fs/_table.c similarity index 100% rename from src/fs/_table.c rename to kernel/src/modules/fs/_table.c diff --git a/src/fs/close.c b/kernel/src/modules/fs/close.c similarity index 100% rename from src/fs/close.c rename to kernel/src/modules/fs/close.c diff --git a/src/fs/fs.c b/kernel/src/modules/fs/fs.c similarity index 100% rename from src/fs/fs.c rename to kernel/src/modules/fs/fs.c diff --git a/src/fs/fugue/close.c b/kernel/src/modules/fs/fugue/close.c similarity index 100% rename from src/fs/fugue/close.c rename to kernel/src/modules/fs/fugue/close.c diff --git a/src/fs/fugue/fugue.c b/kernel/src/modules/fs/fugue/fugue.c similarity index 100% rename from src/fs/fugue/fugue.c rename to kernel/src/modules/fs/fugue/fugue.c diff --git a/src/fs/fugue/lseek.c b/kernel/src/modules/fs/fugue/lseek.c similarity index 100% rename from src/fs/fugue/lseek.c rename to kernel/src/modules/fs/fugue/lseek.c diff --git a/src/fs/fugue/open.c b/kernel/src/modules/fs/fugue/open.c similarity index 100% rename from src/fs/fugue/open.c rename to kernel/src/modules/fs/fugue/open.c diff --git a/src/fs/fugue/read.c b/kernel/src/modules/fs/fugue/read.c similarity index 100% rename from src/fs/fugue/read.c rename to kernel/src/modules/fs/fugue/read.c diff --git a/src/fs/fugue/write.c b/kernel/src/modules/fs/fugue/write.c similarity index 100% rename from src/fs/fugue/write.c rename to kernel/src/modules/fs/fugue/write.c diff --git a/src/fs/lseek.c b/kernel/src/modules/fs/lseek.c similarity index 100% rename from src/fs/lseek.c rename to kernel/src/modules/fs/lseek.c diff --git a/src/fs/open.c b/kernel/src/modules/fs/open.c similarity index 100% rename from src/fs/open.c rename to kernel/src/modules/fs/open.c diff --git a/src/fs/read.c b/kernel/src/modules/fs/read.c similarity index 100% rename from src/fs/read.c rename to kernel/src/modules/fs/read.c diff --git a/src/fs/write.c b/kernel/src/modules/fs/write.c similarity index 100% rename from src/fs/write.c rename to kernel/src/modules/fs/write.c diff --git a/src/hypervisor/hypervisor.c b/kernel/src/modules/hypervisor/hypervisor.c similarity index 100% rename from src/hypervisor/hypervisor.c rename to kernel/src/modules/hypervisor/hypervisor.c diff --git a/src/hypervisor/switch.c b/kernel/src/modules/hypervisor/switch.c similarity index 99% rename from src/hypervisor/switch.c rename to kernel/src/modules/hypervisor/switch.c index 1775a12..bc27bf6 100644 --- a/src/hypervisor/switch.c +++ b/kernel/src/modules/hypervisor/switch.c @@ -51,4 +51,5 @@ int hypervisor_world_switch(hyp_world_t out, hyp_world_t in) wout->status.ACTIVE = 0; wout->status.INIT = 1; cpu_atomic_end(); + return 0; } diff --git a/src/hypervisor/table.c b/kernel/src/modules/hypervisor/table.c similarity index 99% rename from src/hypervisor/table.c rename to kernel/src/modules/hypervisor/table.c index 24c4300..e2192f3 100644 --- a/src/hypervisor/table.c +++ b/kernel/src/modules/hypervisor/table.c @@ -118,4 +118,5 @@ hyp_world_t hypervisor_world_delete(hyp_world_t id) return (hyp_world_undeletable); hyp.world.table[id].status.USED = 0; + return 0; } diff --git a/src/keyboard/getkey.c b/kernel/src/modules/keyboard/getkey.c similarity index 100% rename from src/keyboard/getkey.c rename to kernel/src/modules/keyboard/getkey.c diff --git a/src/keyboard/keyboard.c b/kernel/src/modules/keyboard/keyboard.c similarity index 100% rename from src/keyboard/keyboard.c rename to kernel/src/modules/keyboard/keyboard.c diff --git a/src/keyboard/keycache.c b/kernel/src/modules/keyboard/keycache.c similarity index 100% rename from src/keyboard/keycache.c rename to kernel/src/modules/keyboard/keycache.c diff --git a/src/keyboard/keydown.c b/kernel/src/modules/keyboard/keydown.c similarity index 100% rename from src/keyboard/keydown.c rename to kernel/src/modules/keyboard/keydown.c diff --git a/src/keyboard/keyvent.c b/kernel/src/modules/keyboard/keyvent.c similarity index 100% rename from src/keyboard/keyvent.c rename to kernel/src/modules/keyboard/keyvent.c diff --git a/src/kmalloc/area_vhex.c b/kernel/src/modules/kmalloc/area_vhex.c similarity index 100% rename from src/kmalloc/area_vhex.c rename to kernel/src/modules/kmalloc/area_vhex.c diff --git a/src/kmalloc/kmalloc.c b/kernel/src/modules/kmalloc/kmalloc.c similarity index 100% rename from src/kmalloc/kmalloc.c rename to kernel/src/modules/kmalloc/kmalloc.c diff --git a/src/rtc/rtc.c b/kernel/src/modules/rtc/rtc.c similarity index 100% rename from src/rtc/rtc.c rename to kernel/src/modules/rtc/rtc.c diff --git a/src/timer/fps.c b/kernel/src/modules/timer/fps.c similarity index 100% rename from src/timer/fps.c rename to kernel/src/modules/timer/fps.c diff --git a/src/timer/profiling.c b/kernel/src/modules/timer/profiling.c similarity index 100% rename from src/timer/profiling.c rename to kernel/src/modules/timer/profiling.c diff --git a/src/timer/timer.c b/kernel/src/modules/timer/timer.c similarity index 100% rename from src/timer/timer.c rename to kernel/src/modules/timer/timer.c diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..4b01bf8 --- /dev/null +++ b/scripts/__init__.py @@ -0,0 +1,56 @@ +""" +Expose configure script part +""" +from scripts.board import board_select, board_command +from scripts.format import format_select, format_command +from scripts.confile import config_file_generate + +__all__ = [ + 'select', + 'subcommand', + 'generate_confile' +] + +#--- +# Public +#--- + +def select(target, kernconf, arg): + """ perform target selection + + @args + > target (str) - subcommand target (assumed valid) + > kernconf (dict) - kernel configuration information + > arg (str) - argument for the selection + + @return + > Nothing, hangout if error. (return are only here for syntax sugar) + """ + if target == 'board': + return board_select(kernconf, arg) + return format_select(kernconf, arg) + +def subcommand(target, argv): + """ hand-off kernel configuration for a particular subcommand + + @arg + > target (str) - subcommand target (assumed valid) + > argv (list,str) - subcommand arguments + + @return + > Never (return are only here for syntax sugar) + """ + if target == 'board': + return board_command(argv) + return format_command(argv) + +def generate_confile(kernconf): + """ Generate the configuration file + + @args + > kernconf (dict) - kernel configuration + + @return + > 0 if success, negative value otherwise + """ + return config_file_generate(kernconf) diff --git a/scripts/board.py b/scripts/board.py new file mode 100644 index 0000000..082ba4e --- /dev/null +++ b/scripts/board.py @@ -0,0 +1,272 @@ +""" +Board handling +""" +import os +import sys +import toml + +__all__ = [ + 'board_select', + 'board_command', +] + +#--- +# Internal functions +#--- + +def _warning(text): + print(text, file=sys.stderr) + +def _board_fetch_info_meta(board_info, board_desc, board): + """ Fetch and check board meta information + + @args + > board_info (dict) - board information + > board_desc (dict) - board TOML parsed file + > board (str) - board name + + @return + > 0 if success, negative value otherwise + """ + if 'meta' not in board_desc: + _warning(f"board '{board}' : missing meta section") + return -1 + if 'author' not in board_desc['meta']: + _warning(f"board '{board}' : missing author names") + return -2 + if 'description' not in board_desc['meta']: + _warning(f"board '{board}' : missing description") + return -3 + board_info['author'] = board_desc['meta']['author'] + board_info['desc'] = board_desc['meta']['description'] + return 0 + +def _board_fetch_info_config(board_info, board_desc, board): + """ Fetch and check board configuration information + + @args + > board_info (dict) - board information + > board_desc (dict) - board TOML parsed file + > board (str) - board name + + @return + > 0 if success, negative value otherwise + """ + if 'config' not in board_desc: + _warning(f"board '{board}' : missing config section") + return -1 + if 'modules' not in board_desc['config']: + _warning(f"board '{board}' : missing modules declaration") + return -2 + if 'drivers' not in board_desc['config']: + _warning(f"board '{board}' : missing drivers declaration") + return -3 + mod_prefix = f"{os.path.dirname(__file__)}/../kernel/src/modules" + for mod in board_desc['config']['modules']: + if not os.path.exists(f"{mod_prefix}/{mod}"): + _warning(f"{board} : module '{mod}' does not exists, skipped") + continue + board_info['config']['modules'].append(mod) + drv_prefix = f"{os.path.dirname(__file__)}/../kernel/src/drivers" + for drv in board_desc['config']['drivers']: + drv_path = drv.replace(':', '/') + if not os.path.exists(f"{drv_prefix}/{drv_path}"): + _warning(f"{board} : driver '{drv}' does not exists, skipped") + continue + board_info['config']['drivers'].append(drv_path) + return 0 + +def _board_fetch_info_toolchain(board_info, board_desc, _): + """ Fetch and check board configuration information + + @args + > board_info (dict) - board information + > board_desc (dict) - board TOML parsed file + > board (str) - board name + + @return + > 0 if success, negative value otherwise + """ + if 'toolchain' not in board_desc: + return 0 + if 'file' in board_desc['toolchain']: + board_info['toolchain']['file'] = board_desc['toolchain']['file'] + if 'cflags' in board_desc['toolchain']: + board_info['toolchain']['cflags'] = board_desc['toolchain']['cflags'] + if 'ldflags' in board_desc['toolchain']: + board_info['toolchain']['ldflags'] = board_desc['toolchain']['ldflags'] + if 'libs' in board_desc['toolchain']: + board_info['toolchain']['libs'] = board_desc['toolchain']['libs'] + return 0 + +def _board_fetch_info(board): + """ Generate all information about a particular board + + @return + > a dictionary with all board information : { + 'name' : , + 'path' : , + 'config' : { + 'drivers' : , + 'modules' : + }, + 'toolchain' : { + 'file' : , + 'cflags' : , + 'libs' : , + 'ldflags' : + } + } + """ + board_info = { + 'name' : board, + 'path' : f"{os.path.dirname(__file__)}/../boards/{board}", + 'author' : 'unknown', + 'desc' : 'unknown', + 'config' : { + 'drivers' : [], + 'modules' : [] + }, + 'toolchain' : { + 'file' : None, + 'cflags' : [], + 'libs' : [], + 'ldflags' : [] + } + } + + # Check board existance + if not os.path.exists(board_info['path']): + _warning(f"board '{board}' does not exists, skipped") + return {} + board_desc_path = f"{board_info['path']}/board.toml" + if not os.path.exists(board_desc_path): + _warning(f"board '{board}' : missing board description, skipped") + return {} + + # Try to dump (and tranforms) board information + with open(board_desc_path, "r", encoding='utf8') as file: + board_desc = toml.loads(file.read()) + + # check meta board information + if _board_fetch_info_meta(board_info, board_desc, board) != 0: + return {} + + # check board configuration + if _board_fetch_info_config(board_info, board_desc, board) != 0: + return {} + + # check toolchain extra configuration if available + if _board_fetch_info_toolchain(board_info, board_desc, board) != 0: + return {} + + # return the board information + return board_info + +def _board_fetch_available_board(): + """ Fetch all available board + + @return + > a list of all available board name + """ + # fetch folder information + board_prefix = f"{os.path.dirname(__file__)}/../boards" + if not (available_list := list(os.walk(board_prefix))): + return [] + # fetch folder content only + if not (available_list := available_list[0]): + return 0 + # fetch directory only + return available_list[1] + +def _board_generate_conf(kernconf, board_info): + """ generate exportable variable information + + @args + > kernconf (dict) - kernel configuration + > board_info (dict) - board information + + @return + > nothing + """ + kernconf['VXKERNEL_ENABLE_BOARD'] = board_info['name'] + kernconf['VXKERNEL_ENABLE_MODULES'] = board_info['config']['modules'] + kernconf['VXKERNEL_ENABLE_DRIVERS'] = board_info['config']['drivers'] + kernconf['VXKERNEL_TOOLCHAIN_FILE'] = board_info['toolchain']['file'] + kernconf['VXKERNEL_EXTRA_CFLAGS'] = board_info['toolchain']['cflags'] + kernconf['VXKERNEL_EXTRA_LDFLAGS'] = board_info['toolchain']['ldflags'] + kernconf['VXKERNEL_EXTRA_LIBS'] = board_info['toolchain']['libs'] + +def _board_display_list(verbose, board_target): + """ Display board information + + @args + > verbose (bool) - display more information + > board_target (str) - targeted board + + @return + > 0 if success, negative value othervise + """ + board_list = [board_target] + if not board_target: + board_list = _board_fetch_available_board() + + print(f"\033[1m{'board':<16}{'Authors':<16}Description\033[0m") + for board in board_list: + if not (board_info := _board_fetch_info(board)): + continue + content = f"{board:<16}{board_info['author']:<16}{board_info['desc']}" + if verbose: + fake_kernconf = {} + _board_generate_conf(fake_kernconf, board_info) + content += ":\n" + for item in fake_kernconf.items(): + content += f" {item[0]:<16} = {item[1]}\n" + print(content) + + return 0 + +#--- +# Public +#--- + +def board_select(kernconf, board): + """ Select a board and generate output information + + @args + > kernconf (dict) - kernel configuration information + > board (str) - argument for the selection + + @return + > Nothing, hangout if error. (return are only here for syntax sugar) + """ + if not (board_info := _board_fetch_info(board)): + sys.exit(84) + return _board_generate_conf(kernconf, board_info) + +def board_command(argv): + """ Board-specific handler + + @arg + > argv (list,str) - subcommand arguments + + @return + > Never + """ + if not argv: + _warning('missing board argument') + sys.exit(84) + + board = '' + verbose = False + for arg in argv: + if arg in ['--list', 'list']: + verbose = False + elif arg in ['--info', 'info']: + verbose = True + else: + if board: + _warning(f"{board} already selected, change for '{arg}'") + board = arg + + sys.exit(_board_display_list(verbose, board)) diff --git a/scripts/confile.py b/scripts/confile.py new file mode 100644 index 0000000..7923f5d --- /dev/null +++ b/scripts/confile.py @@ -0,0 +1,48 @@ +""" +Configuration file handling +""" +import os +import sys + +__all__ = [ + 'config_file_generate' +] + +#--- +# Public +#--- + +def config_file_generate(kernconf): + """ Generate the kernel configuration file for CMake build system + + @args + > kernconf (dict) - kernel configuration information + + @return + > 0 on success, negative value otherwise + """ + if 'VXSDK_PREFIX_BUILD' not in os.environ: + print( + "unable to generate the configuration file, you should use the " + "vxSDK", + file=sys.stderr + ) + sys.exit(84) + + confile_prefix = os.environ['VXSDK_PREFIX_BUILD'] + if not os.path.exists(confile_prefix): + os.makedirs(confile_prefix) + + content = "# file generated by the vxSDK\n\n" + for item in kernconf.items(): + if not (data := item[1]): + continue + if isinstance(item[1], list): + data = ' '.join(item[1]) + content += f"set({item[0]} {data})\n" + + confile_path = f"{confile_prefix}/vxkernel_config.cmake" + with open(confile_path, "w+", encoding='utf8') as file: + file.write(content) + + return 0 diff --git a/scripts/format.py b/scripts/format.py new file mode 100644 index 0000000..0786e98 --- /dev/null +++ b/scripts/format.py @@ -0,0 +1,34 @@ +""" +Format handling +""" + +__all__ = [ + 'format_select', + 'format_command', +] + + +#--- +# Public +#--- + +def format_select(_, __): + """ Select a kernel format and generate output information + + @args + > kernconf (dict) - kernel configuration information + > format (str) - targeted format + + @return + > Nothing, hangout if error. (return are only here for syntax sugar) + """ + +def format_command(_): + """ format-specific handler + + @arg + > argv (list,str) - subcommand arguments + + @return + > Never + """ diff --git a/src/kernel.c b/src/kernel.c deleted file mode 100644 index 1680f67..0000000 --- a/src/kernel.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include - -//--- -// Initialization and unloading -//--- - -/* kinit(): Install and start vhex */ -void kinit(void) -{ - struct vhex_module *mtable; - - 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) -{ - struct vhex_module *mtable; - - mtable = vhex_module_table(); - for (int i = 0; i < vhex_module_count(); ++i) { - if (mtable[i].quit != NULL) - mtable[i].quit(); - } -} diff --git a/vxsdk.toml b/vxsdk.toml index bd6c8e8..455f93e 100644 --- a/vxsdk.toml +++ b/vxsdk.toml @@ -1,9 +1,39 @@ [project] name = 'vxkernel' type = 'lib' +target = [ + 'fxcg50', + 'sdl2' +] +option = [ + 'release', + 'debug' +] [build] -configure = 'python3 ./configure' # the user need to specify the board!! +configure = './configure' build = 'make' install = 'make install' uninstall = 'make uninstall' + + +[fxcg50] + [dependencies] + sh-elf-vhex = 'master@superh' + [config] + VXSDK_BUILD_GCC_PREFIX = 'sh-elf-vhex-' + VXSDK_BUILD_CFLAGS = [ + '-DFXCG50', + '-m4-nofpu', + '-mb', + '-ffreestanding', + '-nostdlib', + '-fPIE', + '-O1', + '-fstrict-volatile-bitfields', + '-Wa,--dsp' + ] + VXSDK_BUILD_LIBS = [ + '-lc', + '-lgcc' + ]