2021-01-25 15:31:20 +01:00
|
|
|
# Build system for the gint unikernel
|
|
|
|
|
2021-05-10 15:27:06 +02:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
2022-03-19 20:27:53 +01:00
|
|
|
project(Gint VERSION 2.7.1 LANGUAGES C ASM)
|
2021-01-25 15:31:20 +01:00
|
|
|
|
|
|
|
include(GitVersionNumber)
|
|
|
|
include(Fxconv)
|
|
|
|
|
2021-01-25 19:06:42 +01:00
|
|
|
option(GINT_USER_VRAM "Put all VRAMs into the user stack (fx-CG 50 only)")
|
|
|
|
option(GINT_STATIC_GRAY "Use static memory instead of malloc for gray buffers (fx-9860G only)")
|
kmalloc: implement a custom segregated list allocator
The new allocator uses a segregated best-fit algorithm with exact-size
lists for all sizes between 8 bytes (the minimum) and 60 bytes, one list
for blocks of size 64-252 and one for larger blocks.
Arenas managed by this allocator have built-in statistics that track
used and free memory (accounting for block headers), peak memory, and
various allocation results.
In addition, the allocator has self-checks in the form of integrity
verifications, that can be enabled with -DGINT_KMALLOC_DEBUG=1 at
configuration time or with the :dev configuration for GiteaPC. This is
used by gintctl.
The kmalloc interface is extended with a new arena covering all unused
memory in user RAM, managed by gint's allocator. It spans about 4 kB on
SH3 fx-9860G, 16 kB on SH4 fx-9860G, and 500 kB on fx-CG 50, in addition
to the OS heap. This new arena is now the default arena for malloc(),
except on SH3 where some heap problems are currently known.
2021-03-15 15:04:24 +01:00
|
|
|
option(GINT_KMALLOC_DEBUG "Enable debug functions for kmalloc")
|
2021-01-25 19:06:42 +01:00
|
|
|
|
2021-04-11 18:48:57 +02:00
|
|
|
set(CMAKE_INSTALL_MESSAGE LAZY)
|
|
|
|
|
2021-01-25 19:06:42 +01:00
|
|
|
# Generate <gint/config.h> with commit hash, version name and options
|
2021-05-11 08:27:24 +02:00
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
git_version_number(SHORT_HASH "GINT_GIT_HASH" TAG_RELATIVE "GINT_GIT_VERSION")
|
|
|
|
else()
|
2021-06-08 23:04:41 +02:00
|
|
|
set(GINT_GIT_HASH "0000000")
|
2021-05-11 08:27:24 +02:00
|
|
|
set(GINT_GIT_VERSION "${PROJECT_VERSION}")
|
|
|
|
endif()
|
2021-01-25 15:31:20 +01:00
|
|
|
configure_file(include/gint/config.h.in include/gint/config.h)
|
|
|
|
|
|
|
|
set(SOURCES_COMMON
|
2021-12-10 07:25:00 +01:00
|
|
|
# Clock Pulse Generator driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/cpg/cpg.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# CPU driver
|
2021-04-23 18:50:20 +02:00
|
|
|
src/cpu/atomic.c
|
|
|
|
src/cpu/cpu.c
|
2021-06-16 21:50:41 +02:00
|
|
|
src/cpu/ics.s
|
2021-04-23 18:50:20 +02:00
|
|
|
src/cpu/registers.s
|
2021-05-05 15:17:23 +02:00
|
|
|
src/cpu/sleep.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Direct Memory Access driver
|
2021-04-23 18:50:20 +02:00
|
|
|
src/dma/dma.c
|
|
|
|
src/dma/inth.s
|
|
|
|
src/dma/memcpy.c
|
|
|
|
src/dma/memset.c
|
2021-12-13 18:38:47 +01:00
|
|
|
# Filesystem interface
|
2021-12-10 07:25:00 +01:00
|
|
|
src/fs/close.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/closedir.c
|
2021-12-10 07:25:00 +01:00
|
|
|
src/fs/creat.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/fdopendir.c
|
2021-12-13 18:38:47 +01:00
|
|
|
src/fs/fs.c
|
2021-12-10 07:25:00 +01:00
|
|
|
src/fs/lseek.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/mkdir.c
|
2021-12-10 07:25:00 +01:00
|
|
|
src/fs/open.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/opendir.c
|
2021-12-10 07:25:00 +01:00
|
|
|
src/fs/pread.c
|
|
|
|
src/fs/pwrite.c
|
|
|
|
src/fs/read.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/readdir.c
|
|
|
|
src/fs/rewinddir.c
|
|
|
|
src/fs/rmdir.c
|
|
|
|
src/fs/seekdir.c
|
2021-12-30 18:17:13 +01:00
|
|
|
src/fs/stat.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/telldir.c
|
2021-12-10 07:25:00 +01:00
|
|
|
src/fs/unlink.c
|
|
|
|
src/fs/write.c
|
2021-12-13 18:38:47 +01:00
|
|
|
# Filesystem interface to Fugue
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/fugue/BFile_Ext_Stat.c
|
2021-12-13 18:38:47 +01:00
|
|
|
src/fs/fugue/fugue.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/fugue/fugue_dir.c
|
|
|
|
src/fs/fugue/fugue_open.c
|
|
|
|
src/fs/fugue/fugue_mkdir.c
|
2021-12-30 18:17:13 +01:00
|
|
|
src/fs/fugue/fugue_stat.c
|
|
|
|
src/fs/fugue/fugue_rmdir.c
|
2021-12-21 19:01:00 +01:00
|
|
|
src/fs/fugue/fugue_unlink.c
|
2021-12-13 18:38:47 +01:00
|
|
|
src/fs/fugue/util.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Interrupt Controller driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/intc/intc.c
|
2021-04-27 14:29:38 +02:00
|
|
|
src/intc/inth.s
|
2021-12-10 07:25:00 +01:00
|
|
|
# Kernel
|
2021-01-25 15:31:20 +01:00
|
|
|
src/kernel/exch.c
|
|
|
|
src/kernel/exch.s
|
|
|
|
src/kernel/hardware.c
|
|
|
|
src/kernel/inth.S
|
|
|
|
src/kernel/kernel.c
|
|
|
|
src/kernel/osmenu.c
|
|
|
|
src/kernel/start.c
|
|
|
|
src/kernel/syscalls.S
|
|
|
|
src/kernel/tlbh.S
|
2021-04-23 18:50:20 +02:00
|
|
|
src/kernel/world.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Key Scan Interface driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/keysc/getkey.c
|
|
|
|
src/keysc/iokbd.c
|
|
|
|
src/keysc/keycodes.c
|
2021-03-05 09:31:34 +01:00
|
|
|
src/keysc/keydev.c
|
2022-04-23 14:34:41 +02:00
|
|
|
src/keysc/keydev_idle.c
|
|
|
|
src/keysc/keydev_process_key.c
|
|
|
|
src/keysc/keydown_all.c
|
|
|
|
src/keysc/keydown_any.c
|
2021-01-25 15:31:20 +01:00
|
|
|
src/keysc/keysc.c
|
2022-04-23 14:34:41 +02:00
|
|
|
src/keysc/scan_frequency.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Memory allocator
|
kmalloc: implement a custom segregated list allocator
The new allocator uses a segregated best-fit algorithm with exact-size
lists for all sizes between 8 bytes (the minimum) and 60 bytes, one list
for blocks of size 64-252 and one for larger blocks.
Arenas managed by this allocator have built-in statistics that track
used and free memory (accounting for block headers), peak memory, and
various allocation results.
In addition, the allocator has self-checks in the form of integrity
verifications, that can be enabled with -DGINT_KMALLOC_DEBUG=1 at
configuration time or with the :dev configuration for GiteaPC. This is
used by gintctl.
The kmalloc interface is extended with a new arena covering all unused
memory in user RAM, managed by gint's allocator. It spans about 4 kB on
SH3 fx-9860G, 16 kB on SH4 fx-9860G, and 500 kB on fx-CG 50, in addition
to the OS heap. This new arena is now the default arena for malloc(),
except on SH3 where some heap problems are currently known.
2021-03-15 15:04:24 +01:00
|
|
|
src/kmalloc/arena_gint.c
|
2021-03-12 17:22:24 +01:00
|
|
|
src/kmalloc/arena_osheap.c
|
|
|
|
src/kmalloc/kmalloc.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# MMU driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/mmu/mmu.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Rendering
|
2021-01-25 15:31:20 +01:00
|
|
|
src/render/dhline.c
|
|
|
|
src/render/dimage.c
|
|
|
|
src/render/dline.c
|
|
|
|
src/render/dprint.c
|
|
|
|
src/render/drect_border.c
|
|
|
|
src/render/dtext.c
|
2021-08-11 01:12:00 +02:00
|
|
|
src/render/dupdate_hook.c
|
2021-01-25 15:31:20 +01:00
|
|
|
src/render/dvline.c
|
|
|
|
src/render/topti.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# RTC driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/rtc/rtc.c
|
2021-01-31 09:19:19 +01:00
|
|
|
src/rtc/rtc_ticks.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Sound Processing Unit driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/spu/spu.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Timer Unit driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/tmu/inth-etmu.s
|
|
|
|
src/tmu/inth-tmu.s
|
|
|
|
src/tmu/sleep.c
|
|
|
|
src/tmu/tmu.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# USB driver
|
2021-04-11 19:04:54 +02:00
|
|
|
src/usb/classes/ff-bulk.c
|
|
|
|
src/usb/configure.c
|
|
|
|
src/usb/pipes.c
|
|
|
|
src/usb/setup.c
|
|
|
|
src/usb/string.c
|
|
|
|
src/usb/usb.c
|
2021-01-25 15:31:20 +01:00
|
|
|
)
|
|
|
|
set(SOURCES_FX
|
2021-12-10 07:25:00 +01:00
|
|
|
# Gray engine
|
2021-01-25 15:31:20 +01:00
|
|
|
src/gray/engine.c
|
|
|
|
src/gray/gclear.c
|
|
|
|
src/gray/gint_gline.c
|
|
|
|
src/gray/gpixel.c
|
|
|
|
src/gray/grect.c
|
|
|
|
src/gray/gsubimage.c
|
|
|
|
src/gray/gtext.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Rendering
|
2021-01-25 15:31:20 +01:00
|
|
|
src/render-fx/bopti-asm-gray-scsp.s
|
|
|
|
src/render-fx/bopti-asm-gray.s
|
|
|
|
src/render-fx/bopti-asm-mono-scsp.s
|
|
|
|
src/render-fx/bopti-asm.s
|
|
|
|
src/render-fx/bopti.c
|
|
|
|
src/render-fx/dclear.c
|
|
|
|
src/render-fx/dpixel.c
|
|
|
|
src/render-fx/drect.c
|
|
|
|
src/render-fx/dsubimage.c
|
|
|
|
src/render-fx/dupdate.c
|
|
|
|
src/render-fx/gint_dline.c
|
|
|
|
src/render-fx/masks.c
|
|
|
|
src/render-fx/topti-asm.s
|
|
|
|
src/render-fx/topti.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# T6K11 driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/t6k11/t6k11.c
|
2021-12-10 07:25:00 +01:00
|
|
|
|
2021-05-07 15:22:46 +02:00
|
|
|
src/usb/classes/ff-bulk-gray.c
|
2021-01-25 15:31:20 +01:00
|
|
|
)
|
|
|
|
set(SOURCES_CG
|
2021-12-10 07:25:00 +01:00
|
|
|
# R61524 driver
|
2021-01-25 15:31:20 +01:00
|
|
|
src/r61524/r61524.c
|
2021-12-10 07:25:00 +01:00
|
|
|
# Rendering
|
2021-01-25 15:31:20 +01:00
|
|
|
src/render-cg/bopti-asm.s
|
|
|
|
src/render-cg/bopti.c
|
|
|
|
src/render-cg/dclear.c
|
|
|
|
src/render-cg/dpixel.c
|
|
|
|
src/render-cg/drect.c
|
|
|
|
src/render-cg/dsubimage.c
|
|
|
|
src/render-cg/dupdate.c
|
|
|
|
src/render-cg/dvram.c
|
|
|
|
src/render-cg/gint_dline.c
|
|
|
|
src/render-cg/topti-asm.s
|
|
|
|
src/render-cg/topti.c
|
2022-05-04 18:27:02 +02:00
|
|
|
# Fast image renderer
|
|
|
|
src/render-cg/image/image.c
|
|
|
|
src/render-cg/image/image_rgb16.S
|
|
|
|
src/render-cg/image/image_rgb16_normal.S
|
|
|
|
src/render-cg/image/image_rgb16_clearbg_dye.S
|
|
|
|
src/render-cg/image/image_rgb16_swapcolor.S
|
|
|
|
src/render-cg/image/image_p8.S
|
|
|
|
src/render-cg/image/image_p8_normal.S
|
|
|
|
src/render-cg/image/image_p8_clearbg.S
|
|
|
|
src/render-cg/image/image_p8_swapcolor.S
|
|
|
|
src/render-cg/image/image_p8_dye.S
|
|
|
|
src/render-cg/image/image_p4.S
|
|
|
|
src/render-cg/image/image_p4_normal.S
|
|
|
|
src/render-cg/image/image_p4_clearbg.S
|
|
|
|
src/render-cg/image/image_p4_swapcolor.S
|
|
|
|
src/render-cg/image/image_p4_dye.S
|
|
|
|
# Interface to the fast image renderer
|
|
|
|
src/render-cg/image/image_rgb16.c
|
|
|
|
src/render-cg/image/image_rgb16_effect.c
|
|
|
|
src/render-cg/image/image_rgb16_swapcolor.c
|
|
|
|
src/render-cg/image/image_rgb16_dye.c
|
|
|
|
src/render-cg/image/image_p8.c
|
|
|
|
src/render-cg/image/image_p8_effect.c
|
|
|
|
src/render-cg/image/image_p8_swapcolor.c
|
|
|
|
src/render-cg/image/image_p8_dye.c
|
|
|
|
src/render-cg/image/image_p4.c
|
|
|
|
src/render-cg/image/image_p4_effect.c
|
|
|
|
src/render-cg/image/image_p4_swapcolor.c
|
|
|
|
src/render-cg/image/image_p4_dye.c
|
2021-01-25 15:31:20 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
set(ASSETS_FX src/font5x7.png)
|
|
|
|
set(ASSETS_CG src/font8x9.png)
|
2021-01-27 20:48:59 +01:00
|
|
|
fxconv_declare_assets(${ASSETS_FX} ${ASSETS_CG})
|
2021-01-25 15:31:20 +01:00
|
|
|
|
2021-02-02 22:18:15 +01:00
|
|
|
include_directories(
|
|
|
|
"${PROJECT_SOURCE_DIR}/include"
|
|
|
|
"${PROJECT_BINARY_DIR}/include"
|
|
|
|
"${FXSDK_COMPILER_INSTALL}/include/openlibm")
|
2021-04-23 18:50:20 +02:00
|
|
|
add_compile_options(-Wall -Wextra -std=c11 -Os -fstrict-volatile-bitfields -mtas)
|
2021-01-25 15:31:20 +01:00
|
|
|
|
|
|
|
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
|
|
|
add_compile_definitions(FX9860G)
|
|
|
|
add_library(gint-fx STATIC ${SOURCES_COMMON} ${SOURCES_FX} ${ASSETS_FX})
|
|
|
|
set(NAME "gint-fx")
|
|
|
|
set(LINKER_SCRIPT "fx9860g.ld")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
|
|
|
add_compile_definitions(FXCG50)
|
|
|
|
add_library(gint-cg STATIC ${SOURCES_COMMON} ${SOURCES_CG} ${ASSETS_CG})
|
|
|
|
set(NAME "gint-cg")
|
|
|
|
set(LINKER_SCRIPT "fxcg50.ld")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties("${NAME}" PROPERTIES OUTPUT_NAME "${NAME}")
|
|
|
|
|
2021-01-27 08:57:23 +01:00
|
|
|
# Library file
|
2021-01-25 15:31:20 +01:00
|
|
|
install(TARGETS "${NAME}" DESTINATION "${FXSDK_COMPILER_INSTALL}")
|
2021-01-27 08:57:23 +01:00
|
|
|
# Linker script
|
2021-01-25 15:31:20 +01:00
|
|
|
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_SCRIPT}"
|
|
|
|
DESTINATION "${FXSDK_COMPILER_INSTALL}")
|
2021-01-27 08:57:23 +01:00
|
|
|
# Headers
|
2021-01-25 15:31:20 +01:00
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
|
|
DESTINATION "${FXSDK_COMPILER_INSTALL}"
|
|
|
|
FILES_MATCHING PATTERN "*.h")
|
2021-01-27 08:57:23 +01:00
|
|
|
# Auto-generated config header
|
2021-01-25 15:31:20 +01:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/gint/config.h"
|
|
|
|
DESTINATION "${FXSDK_COMPILER_INSTALL}/include/gint")
|
2021-01-27 08:57:23 +01:00
|
|
|
# CMake module to find gint
|
|
|
|
install(FILES cmake/FindGint.cmake DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")
|