Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# created by some language servers
.cache

# used by language servers, can be autogenerated with bear
compile_commands.json
# CMake build dir used by convention
build/

# nix store symlinks
result
124 changes: 124 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# SPDX-FileCopyrightText: 2025 wucke13
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# Note: formatted using gersemi

#
### Global project setup
#

cmake_minimum_required(VERSION 3.23)
project(a653lib)
set(CMAKE_C_STANDARD 99)
set(CMAKE_EXPORT_COMPILE_COMMANDS true)

#
### Utility and helper functions
#

# Make the compiler as strict as possible
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wextra -Wpedantic) # TODO add -Werror eventually
endif()

# Function to add a new ARINC 653 Partition executable
#
# Arguments:
#
# - Name of the CMake executable to be declared
# - (optional) Main source file containing the entry point. Defaults to the name from the first
# argument with the suffix `.c`
macro(add_653_partition)
# check number of args to be one or 2, fail otherwise
if(${ARGC} EQUAL 1)
set(ARGV1 ${ARGV0}.c)
elseif(NOT ${ARGC} EQUAL 2)
message(
FATAL_ERROR
"add_653_partition must be called with one or two arguments."
)
endif()

add_executable(${ARGV0} ${ARGV1})
target_link_libraries(${ARGV0} PRIVATE a653lib a653lib_partition_init)
list(APPEND EXECUTABLES ${ARGV0})
endmacro()

#
### Declare the a653lib related libraries
#

set(PRIVATE_INCLUDE_DIRS a653_lib)

# ARINC 653 library to be used by partitions developers. Comes with public interface via header
# files.
add_library(a653lib)
target_sources(
a653lib
PRIVATE
a653_lib/a653_i_error.c
a653_lib/a653_i_partition.c
a653_lib/a653_i_process.c
a653_lib/a653_i_queuing.c
a653_lib/a653_i_sampling.c
a653_lib/a653_i_semaphore.c
a653_lib/a653_i_shm_if.c
a653_lib/a653_i_sync.c
a653_lib/a653_i_time.c
a653_lib/a653_i_time_lib.c
a653_lib/a653Init.c
PUBLIC
FILE_SET a653lib_headers
TYPE HEADERS
BASE_DIRS a653_inc
FILES
a653_inc/a653Error.h
a653_inc/a653Init.h
a653_inc/a653Lib.h
a653_inc/a653Partition.h
a653_inc/a653Process.h
a653_inc/a653Queuing.h
a653_inc/a653Sampling.h
a653_inc/a653Semaphore.h
a653_inc/a653Time.h
a653_inc/a653Type.h
)

# Implementation dependent initialization code, to be linked into partitions. This lib has no
# public interface.
add_library(a653lib_partition_init)
target_sources(a653lib_partition_init PRIVATE init.c)
target_include_directories(
a653lib_partition_init
PRIVATE ${PRIVATE_INCLUDE_DIRS}
)
target_link_libraries(a653lib_partition_init PUBLIC a653lib)

#
### Main executable
#

add_executable(a653lib_main main.c)
target_link_libraries(a653lib_main PUBLIC a653lib)
target_include_directories(a653lib_main PRIVATE ${PRIVATE_INCLUDE_DIRS})
list(APPEND EXECUTABLES a653lib_main)

#
## Partitions
#

add_653_partition(partition_a)
add_653_partition(partition_b partition_b.c)

#
### Declare installables
#

# install the executables
install(TARGETS ${EXECUTABLES} DESTINATION bin)

# install the base and the partition init library, and the public header files
install(TARGETS a653lib a653lib_partition_init FILE_SET a653lib_headers)
File renamed without changes.
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,29 @@ can by used with the same interface as `printf()` with a leading debug level

## Compilation

call Make in base directory to build `liba653.a` and bind to demo implementation. Result will be located at `~/bin` in your home
directory. There will be the files:
call CMake in base directory to build `liba653.a` and bind to demo implementation. Result will be located in `build` in the current working
directory.

- `a635_main`
```bash
cmake -Bbuild
cmake --build build --parallel
```

There will be the following files in the `build` dir:

- `a653lib_main`
- `liba653lib.a`
- `liba653lib_partition_init.a`
- `Makefile`
- `partition_a`
- `partition_b`
- ...

You can change code and re-run just `make` from within the `build` dir to quickly iterate.

## Run Demo

go to `~/bin` and start `./a653_main`
go to `build` and start `./a653lib_main`

this will generate following output:

Expand All @@ -73,16 +86,6 @@ pid: 578773 <1702486050.349254883>: > taskset --cpu-list 1 ./partition_b & :

......

## Useful targets

| target | Purpose |
| :---------- | :--------------------- |
| `all` | Build everything. This is the default target. |
| `amain` | Only build the main program (scheduler a653_main). |
| `part_a` | Only build the partition a. |
| `part_b` | Only build the partition b. |
| `alib` | Only build the `liba653.a`. |

## Handle version

## Tests debugging
Expand Down
File renamed without changes.
21 changes: 3 additions & 18 deletions pkgs/a653lib.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
{
stdenv,
bintools,
cmake,
}:

stdenv.mkDerivation {
pname = "a653lib";
version = "unstable-2024-04-17";
version = "unstable-2025-11-26";

src = ./..;

preConfigure = ''
mkdir home
export HOME="$PWD/home"
'';
nativeBuildInputs = [ cmake ];

buildInputs = [ bintools ];

makeFlags = [
"CC=${stdenv.cc.targetPrefix}gcc"
"AR=${stdenv.cc.targetPrefix}ar"
"RANLIB=${stdenv.cc.targetPrefix}ranlib"
];

installPhase = ''
mkdir --parent -- $out/bin
mv $HOME/bin/* $out/bin
'';
dontStrip = true;

# TODO investigate why hardening causes crashes
Expand Down
Loading