From 7ef46e6d52ad31cc2773b7ca1c034497a11fde37 Mon Sep 17 00:00:00 2001 From: Alex Jones Date: Thu, 12 Sep 2024 12:51:43 +0100 Subject: [PATCH] Move CHERI auto demo to separate directory Reorganises the automotive demo to place the CHERI-specific code in its own CHERI directory, to mirror the organisation used for non-CHERIoT legacy firmware, and to more clearly modularise and separate the two implementations of the demo library. --- examples/automotive/{ => cheri}/common.hh | 0 examples/automotive/{ => cheri}/receive.cc | 4 +- examples/automotive/{ => cheri}/send.cc | 19 ++++---- examples/automotive/cheri/xmake.lua | 54 ++++++++++++++++++++++ examples/automotive/xmake.lua | 49 +------------------- 5 files changed, 66 insertions(+), 60 deletions(-) rename examples/automotive/{ => cheri}/common.hh (100%) rename examples/automotive/{ => cheri}/receive.cc (99%) rename examples/automotive/{ => cheri}/send.cc (97%) create mode 100644 examples/automotive/cheri/xmake.lua diff --git a/examples/automotive/common.hh b/examples/automotive/cheri/common.hh similarity index 100% rename from examples/automotive/common.hh rename to examples/automotive/cheri/common.hh diff --git a/examples/automotive/receive.cc b/examples/automotive/cheri/receive.cc similarity index 99% rename from examples/automotive/receive.cc rename to examples/automotive/cheri/receive.cc index a534da3..7a0fe71 100644 --- a/examples/automotive/receive.cc +++ b/examples/automotive/cheri/receive.cc @@ -7,9 +7,9 @@ #include #include -#include "../../libraries/lcd.hh" +#include "../../../libraries/lcd.hh" -#include "../../third_party/automotive_demo/automotive_common.h" +#include "../lib/automotive_common.h" #include "common.hh" diff --git a/examples/automotive/send.cc b/examples/automotive/cheri/send.cc similarity index 97% rename from examples/automotive/send.cc rename to examples/automotive/cheri/send.cc index 143cb16..b3ae8f8 100644 --- a/examples/automotive/send.cc +++ b/examples/automotive/cheri/send.cc @@ -7,16 +7,15 @@ #include #include -#include "../../libraries/lcd.hh" -#include "../snake/cherry_bitmap.h" - -#include "../../third_party/automotive_demo/analogue_pedal.h" -#include "../../third_party/automotive_demo/analogue_pedal.h" -#include "../../third_party/automotive_demo/automotive_common.h" -#include "../../third_party/automotive_demo/automotive_menu.h" -#include "../../third_party/automotive_demo/digital_pedal.h" -#include "../../third_party/automotive_demo/joystick_pedal.h" -#include "../../third_party/automotive_demo/no_pedal.h" +#include "../../../libraries/lcd.hh" +#include "../../snake/cherry_bitmap.h" + +#include "../lib/analogue_pedal.h" +#include "../lib/automotive_common.h" +#include "../lib/automotive_menu.h" +#include "../lib/digital_pedal.h" +#include "../lib/joystick_pedal.h" +#include "../lib/no_pedal.h" #include "common.hh" diff --git a/examples/automotive/cheri/xmake.lua b/examples/automotive/cheri/xmake.lua new file mode 100644 index 0000000..a3a02e5 --- /dev/null +++ b/examples/automotive/cheri/xmake.lua @@ -0,0 +1,54 @@ +-- Copyright lowRISC Contributors. +-- SPDX-License-Identifier: Apache-2.0 + +-- Compartments used for the automotive demo firmware +compartment("automotive_send") + add_deps("lcd", "debug") + add_files( + "../lib/automotive_common.c", + "../lib/automotive_menu.c", + "../lib/no_pedal.c", + "../lib/joystick_pedal.c", + "../lib/digital_pedal.c", + "../lib/analogue_pedal.c" + ) + add_files("send.cc") + +compartment("automotive_receive") + add_deps("lcd", "debug") + add_files("../lib/automotive_common.c") + add_files("receive.cc") + +-- Automotive demo: Sending Firmware (1st board) (CHERIoT version) +firmware("automotive_demo_send_cheriot") + add_deps("freestanding", "automotive_send") + on_load(function(target) + target:values_set("board", "$(board)") + target:values_set("threads", { + { + compartment = "automotive_send", + priority = 2, + entry_point = "entry", + stack_size = 0x1000, + trusted_stack_frames = 3 + } + }, {expand = false}) + end) + after_link(convert_to_uf2) + +-- Automotive Demo: Receiving Firmware (2nd board) +firmware("automotive_demo_receive") + add_deps("freestanding", "automotive_receive") + on_load(function(target) + target:values_set("board", "$(board)") + target:values_set("threads", { + { + compartment = "automotive_receive", + priority = 2, + entry_point = "entry", + stack_size = 0x1000, + trusted_stack_frames = 5 + } + }, {expand = false}) + end) + after_link(convert_to_uf2) diff --git a/examples/automotive/xmake.lua b/examples/automotive/xmake.lua index 7e7115b..d0d99fc 100644 --- a/examples/automotive/xmake.lua +++ b/examples/automotive/xmake.lua @@ -1,51 +1,4 @@ -- Copyright lowRISC Contributors. -- SPDX-License-Identifier: Apache-2.0 -compartment("automotive_send") - add_deps("lcd", "debug") - add_files("../../third_party/automotive_demo/automotive_common.c") - add_files("../../third_party/automotive_demo/automotive_menu.c") - add_files("../../third_party/automotive_demo/no_pedal.c") - add_files("../../third_party/automotive_demo/joystick_pedal.c") - add_files("../../third_party/automotive_demo/digital_pedal.c") - add_files("../../third_party/automotive_demo/analogue_pedal.c") - add_files("send.cc") - -compartment("automotive_receive") - add_deps("lcd", "debug") - add_files("../../third_party/automotive_demo/automotive_common.c") - add_files("receive.cc") - --- Automotive demo (CHERIoT version) -firmware("automotive_demo_send") - add_deps("freestanding", "automotive_send") - on_load(function(target) - target:values_set("board", "$(board)") - target:values_set("threads", { - { - compartment = "automotive_send", - priority = 2, - entry_point = "entry", - stack_size = 0x1000, - trusted_stack_frames = 3 - } - }, {expand = false}) - end) - after_link(convert_to_uf2) - --- Automotive Demo: Receive Firmware (2nd board) -firmware("automotive_demo_receive") - add_deps("freestanding", "automotive_receive") - on_load(function(target) - target:values_set("board", "$(board)") - target:values_set("threads", { - { - compartment = "automotive_receive", - priority = 2, - entry_point = "entry", - stack_size = 0x1000, - trusted_stack_frames = 5 - } - }, {expand = false}) - end) - after_link(convert_to_uf2) +includes("cheri", "legacy")