Skip to content

Commit

Permalink
Module-level includes support
Browse files Browse the repository at this point in the history
  • Loading branch information
djphoenix committed May 18, 2019
1 parent 844fbd2 commit 2beb77f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmake/modules.cmake
Expand Up @@ -6,11 +6,13 @@ list(TRANSFORM MODDIRS REPLACE "/${MODDIR_TAG}$" "")
file(WRITE ${CMAKE_BINARY_DIR}/modules.s ".section .modules, \"a\"\n")
file(APPEND ${CMAKE_BINARY_DIR}/modules.s ".global __modules_start__\n__modules_start__:\n")
add_library(modules-linked STATIC ${CMAKE_BINARY_DIR}/modules.s)
file(GLOB MODINC ${SRCDIR}/modules/include)
foreach(moddir ${MODDIRS})
string(REPLACE "/" "." mod ${moddir})
set(ROOT_${mod} ${SRCDIR}/${moddir})
file(GLOB SRCS_${mod} ${ROOT_${mod}}/*.s ${ROOT_${mod}}/*.c ${ROOT_${mod}}/*.cpp)
add_library(mod_${mod} SHARED ${SRCS_${mod}})
target_include_directories(mod_${mod} PRIVATE ${MODINC})
add_custom_command(
TARGET mod_${mod} POST_BUILD
COMMAND ${CMAKE_LLVM_OBJCOPY} --strip-non-alloc --strip-debug --strip-unneeded libmod_${mod}.so libmod_${mod}.strip.so
Expand Down
19 changes: 19 additions & 0 deletions src/modules/include/kernmod.hpp
@@ -0,0 +1,19 @@
// PhoeniX OS module includes
// Copyright © 2019 Yury Popov a.k.a. PhoeniX

#include <stdint.h>
#include <stddef.h>

#define MODDESC(k, v) \
extern const char \
__attribute__((section(".module"),aligned(1))) \
module_ ## k[] = v;

extern "C" {
// Syscalls
void puts(const char *);
void exit(int);

// Entry point
void module();
}

0 comments on commit 2beb77f

Please sign in to comment.