diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..59462282 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "meson/meson"] + path = meson/meson + url = https://github.com/mesonbuild/meson.git diff --git a/Makefile b/Makefile index 6dc66828..f377c748 100644 --- a/Makefile +++ b/Makefile @@ -145,4 +145,8 @@ clean_images: | dbuild_splash $(Q)rm -rf $(CONFIG_HEADER_PATH)/$(CONFIG_HEADER_NAME) $(PRM_PIPE) $(Q)rm -rf $(PROJECT_DIR)/linktree +.PHONY: meson +meson: + CC=gcc $(BASE)/meson/meson/meson.py --cross-file $(BASE)/meson/cross-files/arm.cross builddir + $(CONFIG_HEADER_PATH)/$(CONFIG_HEADER_NAME): MODULE_NAME:=$(MODULE_NAME) diff --git a/arch/arm/mach/meson.build b/arch/arm/mach/meson.build new file mode 100644 index 00000000..b1b1ee09 --- /dev/null +++ b/arch/arm/mach/meson.build @@ -0,0 +1,5 @@ +# +# Include the correct machine build file. +# + +subdir(SUBARCH) diff --git a/arch/arm/mach/zynq/Kconfig b/arch/arm/mach/zynq/Kconfig index 0e1ad0c9..956a3b61 100644 --- a/arch/arm/mach/zynq/Kconfig +++ b/arch/arm/mach/zynq/Kconfig @@ -28,6 +28,10 @@ config CPU_CORES int default 2 +config ARCH_ARM_GIC_TOTAL_IRQS + int + default 95 + source arch/arm/mach/zynq/boards/Kconfig comment "Zynq Platform Options" diff --git a/arch/arm/mach/zynq/meson.build b/arch/arm/mach/zynq/meson.build new file mode 100644 index 00000000..bcb69aa5 --- /dev/null +++ b/arch/arm/mach/zynq/meson.build @@ -0,0 +1,61 @@ +# +# vmthunder.mach.zynq +# Build recipe for Zynq Machine. +# + +# +# Empty sources list. +# +zynq_sources = [] + + +# +# Add all mandatory sources. +# +zynq_sources += 'zynq.c' +zynq_sources += 'slcr.c' +zynq_sources += 'headsmp.S' +zynq_sources += 'early_console.c' + +# +# Add all optional sources. +# +if config.has('BT_CONFIG_MACH_ZYNQ_DEVCFG') +zynq_sources += 'devcfg.c' +endif + +if config.has('BT_CONFIG_MACH_ZYNQ_GEM') +zynq_sources += 'gem.c' +endif + +if config.has('BT_CONFIG_MACH_ZYNQ_GPIO') +zynq_sources += 'gpio.c' +endif + +if config.has('BT_CONFIG_MACH_ZYNQ_I2C') +zynq_sources += 'i2c.c' +endif + +if config.has('BT_CONFIG_MACH_ZYNQ_SDIO') +zynq_sources += 'sdio.c' +endif + +if config.has('BT_CONFIG_MACH_ZYNQ_TIMER') +zynq_sources += 'timer.c' +endif + +if config.has('BT_CONFIG_MACH_ZYNQ_UART') +zynq_sources += 'uart.c' +endif + + +# +# Add any extra includes. +# +zynq_includes = [] +zynq_includes += 'arch/arm/mach/zynq' + +# +# Hook this into the build. +# +vm_libs += { 'name': 'vmthunder.mach.zynq', 'path': meson.current_source_dir(), 'sources': zynq_sources, 'includes': zynq_includes } diff --git a/arch/arm/meson.build b/arch/arm/meson.build new file mode 100644 index 00000000..eb076b7f --- /dev/null +++ b/arch/arm/meson.build @@ -0,0 +1,22 @@ +vm_includes += 'arch/arm/include' +vm_includes += 'arch/arm/include/arch/common' + + +# +# Common ARM build files. +# +vm_sources += 'arch/arm/boot/head.S' +vm_sources += 'arch/arm/common/arm11cpu.c' +vm_sources += 'arch/arm/common/arm-cache.c' +vm_sources += 'arch/arm/common/crtinit.s' +vm_sources += 'arch/arm/common/cpuinit.S' +vm_sources += 'arch/arm/common/gic.c' +vm_sources += 'arch/arm/common/freertos-ca9.c' +vm_sources += 'arch/arm/common/freertos-ca9-asm.S' + +if config.has('BT_CONFIG_HAS_MMU') +vm_sources += 'arch/arm/mm/v7-mmu.c' +vm_sources += 'arch/arm/mm/v7-mmu-asm.S' +endif + +subdir('mach') \ No newline at end of file diff --git a/drivers/meson.build b/drivers/meson.build new file mode 100644 index 00000000..8d650f59 --- /dev/null +++ b/drivers/meson.build @@ -0,0 +1 @@ +vm_includes += 'drivers' diff --git a/kernel/FreeRTOS/meson.build b/kernel/FreeRTOS/meson.build new file mode 100644 index 00000000..7f8a9745 --- /dev/null +++ b/kernel/FreeRTOS/meson.build @@ -0,0 +1,14 @@ +# +# FreeRTOS build module. +# + +# +# Adding to the default source list. +# +vm_includes += 'kernel/FreeRTOS/Source/include' +vm_sources += 'kernel/FreeRTOS/Source/tasks.c' +vm_sources += 'kernel/FreeRTOS/Source/list.c' +vm_sources += 'kernel/FreeRTOS/Source/queue.c' +vm_sources += 'kernel/FreeRTOS/Source/event_groups.c' + + diff --git a/kernel/meson.build b/kernel/meson.build new file mode 100644 index 00000000..e4ae93b7 --- /dev/null +++ b/kernel/meson.build @@ -0,0 +1,3 @@ +subdir('FreeRTOS') + +vm_sources += 'kernel/bt_freertos_if.c' \ No newline at end of file diff --git a/lib/meson.build b/lib/meson.build new file mode 100644 index 00000000..a94eba40 --- /dev/null +++ b/lib/meson.build @@ -0,0 +1,4 @@ +vm_includes += 'lib/include' + +vm_sources += 'lib/src/collections/bt_fifo.c' +vm_sources += 'lib/src/handles/bt_handles.c' diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..d21ef104 --- /dev/null +++ b/meson.build @@ -0,0 +1,89 @@ +# +# Meson Build file for BitThunder +# +project('bitthunder', 'c', + version : '1.0', + default_options : ['warning_level=3']) + + +find_program('git') + +# +# Import the Kconfig data. +# +config = configuration_data() +cfg = run_command('cat', '.config').stdout().strip().split('\n') +foreach item : cfg + if not item.startswith('#') + splits = item.split('=') + if splits.length() == 2 + config.set(splits[0], splits[1].strip('"')) + endif + endif +endforeach + +# +# Top-Level Build variables +# +ARCH=config.get('BT_CONFIG_ARCH') +SUBARCH=config.get('BT_CONFIG_SUBARCH') + +# +# Subdirs can simply add to vm_sources and vm_includes. +# Or to isolate components of the build, they can create static libs in vm_libs. +# +vm_sources = [] +vm_includes = [] +vm_libs = [] + +# +# Generate config headers +# + +#bsp_config = custom_target( +# 'bt_bsp_config.h', +# output : 'bt_bsp_config.h', +# input : '.config', +# command : [prog_python, '@INPUT@', '--header', '@OUTPUT@'], +#] + +# +# Include the base-subdirs. +# +subdir('lib') +subdir('os') +subdir('arch/' + ARCH) +subdir('kernel') +subdir('drivers') + +inc = include_directories(vm_includes) + +vmthunder_core = static_library('vmthunder.core', vm_sources, include_directories: inc) + +extra_libs = [] + +foreach lib : vm_libs + name = lib['name'] + sources = lib['sources'] + lib_includes = [] + lib_sources = [] + + foreach source : sources + lib_sources += lib['path'] + '/' + source + endforeach + + if 'includes' in lib + lib_includes = include_directories(lib['includes']) + endif + + extra_libs += static_library(name, lib_sources, include_directories: [inc, lib_includes]) +endforeach + +linker_script = '@0@/build/arch/arm/bitthunder.lds'.format(meson.current_source_dir()) + +link_args = ['-T', linker_script, '-nostartfiles']# + meson.get_cross_property('link_args') + +# +# Main vmthunder kernel executable. +# +executable('vmthunder', vm_sources, include_directories: inc, link_args: link_args, link_with: [vmthunder_core, extra_libs]) diff --git a/meson/cross-files/arm.cross b/meson/cross-files/arm.cross new file mode 100644 index 00000000..f7984eb7 --- /dev/null +++ b/meson/cross-files/arm.cross @@ -0,0 +1,15 @@ +[binaries] +c = 'arm-none-eabi-gcc' +cpp = 'arm-none-eabi-g++' +ar = 'arm-none-eabi-ar' +strip = 'arm-none-eabi-strip' + +[host_machine] +system = 'none' +cpu_family = 'arm' +cpu = 'cortex-a9' +endian = 'little' + +[properties] +c_args = ['-march=armv7-a', '-mfloat-abi=soft', '-mfpu=neon'] +link_args = ['-march=armv7-a', '-mfloat-abi=soft', '-mfpu=neon'] \ No newline at end of file diff --git a/meson/meson b/meson/meson new file mode 160000 index 00000000..d272f23d --- /dev/null +++ b/meson/meson @@ -0,0 +1 @@ +Subproject commit d272f23dba57fa6d4f0bcd56ebb77e3889a3e81c diff --git a/os/Kconfig b/os/Kconfig index afa1e930..84eb4ff8 100755 --- a/os/Kconfig +++ b/os/Kconfig @@ -95,6 +95,8 @@ config DIR config I2C bool "I2C subsystem" + select SOFTIRQ + select TASKLETS default n config ADC diff --git a/os/meson.build b/os/meson.build new file mode 100644 index 00000000..721eb0a9 --- /dev/null +++ b/os/meson.build @@ -0,0 +1,16 @@ +vm_includes += 'os/include' + +vm_sources += 'os/src/bt_main.c' + +subdir('src/devman') +subdir('src/gpio') +subdir('src/fs') +subdir('src/helpers') +subdir('src/interfaces') +subdir('src/interrupts') +subdir('src/lib') +subdir('src/module') +subdir('src/mm') +subdir('src/process') +subdir('src/syslog') +subdir('src/timers') \ No newline at end of file diff --git a/os/src/devman/meson.build b/os/src/devman/meson.build new file mode 100644 index 00000000..a4a7acc7 --- /dev/null +++ b/os/src/devman/meson.build @@ -0,0 +1,6 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_devman.c' +vm_sources += pwd + 'bt_device.c' +vm_sources += pwd + 'bt_resources.c' +vm_sources += pwd + 'bt_i2c.c' diff --git a/os/src/fs/meson.build b/os/src/fs/meson.build new file mode 100644 index 00000000..2f8d285e --- /dev/null +++ b/os/src/fs/meson.build @@ -0,0 +1,4 @@ +pwd = meson.current_source_dir() + '/' + + +vm_sources += pwd + 'bt_file.c' diff --git a/os/src/gpio/meson.build b/os/src/gpio/meson.build new file mode 100644 index 00000000..fd73d215 --- /dev/null +++ b/os/src/gpio/meson.build @@ -0,0 +1,3 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_gpio.c' diff --git a/os/src/helpers/meson.build b/os/src/helpers/meson.build new file mode 100644 index 00000000..624a8ef9 --- /dev/null +++ b/os/src/helpers/meson.build @@ -0,0 +1,3 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_clkdiv.c' \ No newline at end of file diff --git a/os/src/interfaces/meson.build b/os/src/interfaces/meson.build new file mode 100644 index 00000000..1d9b2cb0 --- /dev/null +++ b/os/src/interfaces/meson.build @@ -0,0 +1,4 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_if_power.c' +vm_sources += pwd + 'bt_dev_if_uart.c' \ No newline at end of file diff --git a/os/src/interrupts/meson.build b/os/src/interrupts/meson.build new file mode 100644 index 00000000..cc7fba59 --- /dev/null +++ b/os/src/interrupts/meson.build @@ -0,0 +1,12 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_interrupts.c' + +if config.has('BT_CONFIG_INTERRUPTS_SOFTIRQ') +vm_sources += pwd + 'bt_softirq.c' +endif + +if config.has('BT_CONFIG_TASKLETS') +vm_sources += pwd + 'bt_tasklets.c' +endif + diff --git a/os/src/lib/meson.build b/os/src/lib/meson.build new file mode 100644 index 00000000..53249170 --- /dev/null +++ b/os/src/lib/meson.build @@ -0,0 +1,7 @@ +pwd = meson.current_source_dir() + '/' + + +vm_sources += pwd + 'ctype.c' +vm_sources += pwd + 'string.c' +vm_sources += pwd + 'printf.c' +vm_sources += pwd + 'putc.c' diff --git a/os/src/mm/meson.build b/os/src/mm/meson.build new file mode 100644 index 00000000..880c47ed --- /dev/null +++ b/os/src/mm/meson.build @@ -0,0 +1,20 @@ +if config.has('BT_CONFIG_OS') +vm_sources += 'os/src/mm/bt_mm.c' +endif + +if config.has('BT_CONFIG_MEM_PAGE_ALLOCATOR') +vm_sources += 'os/src/mm/bt_page.c' +endif + +if config.has('BT_CONFIG_MEM_KHEAP') +vm_sources += 'os/src/mm/bt_heap.c' +endif + +if config.has('BT_CONFIG_USE_VIRTUAL_ADDRESSING') +vm_sources += 'os/src/mm/bt_vm.c' +vm_sources += 'os/src/mm/bt_map.c' +endif + +if config.has('BT_CONFIG_MEM_SLAB_ALLOCATOR') +vm_sources += 'os/src/mm/slab.c' +endif diff --git a/os/src/module/meson.build b/os/src/module/meson.build new file mode 100644 index 00000000..3bef093e --- /dev/null +++ b/os/src/module/meson.build @@ -0,0 +1,3 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_module_init.c' \ No newline at end of file diff --git a/os/src/process/meson.build b/os/src/process/meson.build new file mode 100644 index 00000000..a8ae5995 --- /dev/null +++ b/os/src/process/meson.build @@ -0,0 +1,7 @@ +pwd = meson.current_source_dir() + '/' + + +vm_sources += pwd + 'bt_threads.c' +vm_sources += pwd + 'bt_process.c' +vm_sources += pwd + 'bt_queue.c' + diff --git a/os/src/syslog/meson.build b/os/src/syslog/meson.build new file mode 100644 index 00000000..9ef6b63a --- /dev/null +++ b/os/src/syslog/meson.build @@ -0,0 +1,3 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_printk.c' \ No newline at end of file diff --git a/os/src/timers/meson.build b/os/src/timers/meson.build new file mode 100644 index 00000000..5fb40d24 --- /dev/null +++ b/os/src/timers/meson.build @@ -0,0 +1,3 @@ +pwd = meson.current_source_dir() + '/' + +vm_sources += pwd + 'bt_timers.c' \ No newline at end of file