From a5ca02b0e705e9e23e339dedcce504a6bf89869c Mon Sep 17 00:00:00 2001 From: June Tate-Gans Date: Mon, 15 Aug 2022 14:48:03 -0500 Subject: [PATCH] cbindgen: Dynamically generate header files during toplevel build Change-Id: I9e62df409506f9e9e79c984f966b34cf09c1b95f GitOrigin-RevId: 319803d00536e972f6aa65eacb5c471db97be9af --- apps/system/CMakeLists.txt | 14 +++++ .../kata-memory-interface/Makefile | 3 +- .../MlCoordinator/kata-ml-interface/Makefile | 2 +- .../kata-proc-interface/Makefile | 2 +- .../kata-security-interface/Makefile | 2 +- .../kata-storage-interface/Makefile | 2 +- .../kata-timer-interface/Makefile | 2 +- .../kata-os-common/src/camkes/Makefile | 2 +- .../system/interfaces/MemoryManagerBindings.h | 39 ------------- apps/system/interfaces/MlCoordBindings.h | 22 -------- .../interfaces/ProcessManagerBindings.h | 34 ------------ .../interfaces/SecurityCoordinatorBindings.h | 55 ------------------- .../interfaces/StorageManagerBindings.h | 26 --------- apps/system/interfaces/TimerServiceBindings.h | 17 ------ 14 files changed, 22 insertions(+), 200 deletions(-) delete mode 100644 apps/system/interfaces/MemoryManagerBindings.h delete mode 100644 apps/system/interfaces/MlCoordBindings.h delete mode 100644 apps/system/interfaces/ProcessManagerBindings.h delete mode 100644 apps/system/interfaces/SecurityCoordinatorBindings.h delete mode 100644 apps/system/interfaces/StorageManagerBindings.h delete mode 100644 apps/system/interfaces/TimerServiceBindings.h diff --git a/apps/system/CMakeLists.txt b/apps/system/CMakeLists.txt index 21d241b..17a8211 100644 --- a/apps/system/CMakeLists.txt +++ b/apps/system/CMakeLists.txt @@ -19,6 +19,10 @@ CAmkESAddImportPath(interfaces) includeGlobalComponents() include(${CMAKE_CURRENT_LIST_DIR}/rust.cmake) +# Note: the includes generated for each CAmkES component listed here are +# generated separately from the CMake build scripts. See also build/kata.mk for +# details, specifically the kata-component-headers target. + RustAddLibrary( kata_debug_console SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/components/DebugConsole @@ -28,6 +32,7 @@ RustAddLibrary( DeclareCAmkESComponent(DebugConsole LIBS kata_debug_console INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -39,6 +44,7 @@ RustAddLibrary( DeclareCAmkESComponent(MemoryManager LIBS kata_memory_manager INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -50,6 +56,7 @@ RustAddLibrary( DeclareCAmkESComponent(MlCoordinator LIBS kata_ml_coordinator INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -61,6 +68,7 @@ RustAddLibrary( DeclareCAmkESComponent(ProcessManager LIBS kata_process_manager INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -72,6 +80,7 @@ RustAddLibrary( DeclareCAmkESComponent(SecurityCoordinator LIBS kata_security_coordinator INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -83,6 +92,7 @@ RustAddLibrary( DeclareCAmkESComponent(StorageManager LIBS kata_storage_manager INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -94,6 +104,7 @@ RustAddLibrary( DeclareCAmkESComponent(TimerService LIBS kata_timer_service INCLUDES interfaces + $ENV{OUT}/kata/components ) RustAddLibrary( @@ -105,6 +116,7 @@ RustAddLibrary( DeclareCAmkESComponent(MailboxDriver LIBS mailbox_driver INCLUDES interfaces + $ENV{OUT}/kata/components ) DeclareCAmkESComponent(LogFibonacci @@ -119,6 +131,7 @@ DeclareCAmkESComponent(OpenTitanUARTDriver INCLUDES opentitan-gen/include components/OpenTitanUARTDriver/include + $ENV{OUT}/kata/components ) DeclareCAmkESComponent(VectorCoreDriver @@ -126,6 +139,7 @@ DeclareCAmkESComponent(VectorCoreDriver components/VectorCoreDriver/src/driver.c INCLUDES vc_top-gen/include + $ENV{OUT}/kata/components ) DeclareCAmkESRootserver(system.camkes) diff --git a/apps/system/components/MemoryManager/kata-memory-interface/Makefile b/apps/system/components/MemoryManager/kata-memory-interface/Makefile index 649f102..b25bf13 100644 --- a/apps/system/components/MemoryManager/kata-memory-interface/Makefile +++ b/apps/system/components/MemoryManager/kata-memory-interface/Makefile @@ -1,4 +1,5 @@ -INTERFACES=../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/MemoryManagerBindings.h: src/lib.rs cbindgen.toml + mkdir -p ${INTERFACES} cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/components/MlCoordinator/kata-ml-interface/Makefile b/apps/system/components/MlCoordinator/kata-ml-interface/Makefile index ec9f9ac..28cb2a3 100644 --- a/apps/system/components/MlCoordinator/kata-ml-interface/Makefile +++ b/apps/system/components/MlCoordinator/kata-ml-interface/Makefile @@ -1,4 +1,4 @@ -INTERFACES=../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/MlCoordBindings.h: src/lib.rs cbindgen.toml cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/components/ProcessManager/kata-proc-interface/Makefile b/apps/system/components/ProcessManager/kata-proc-interface/Makefile index c79e279..7c5343f 100644 --- a/apps/system/components/ProcessManager/kata-proc-interface/Makefile +++ b/apps/system/components/ProcessManager/kata-proc-interface/Makefile @@ -1,4 +1,4 @@ -INTERFACES=../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/ProcessManagerBindings.h: src/lib.rs cbindgen.toml cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/components/SecurityCoordinator/kata-security-interface/Makefile b/apps/system/components/SecurityCoordinator/kata-security-interface/Makefile index 1cd6049..4a3136e 100644 --- a/apps/system/components/SecurityCoordinator/kata-security-interface/Makefile +++ b/apps/system/components/SecurityCoordinator/kata-security-interface/Makefile @@ -1,4 +1,4 @@ -INTERFACES=../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/SecurityCoordinatorBindings.h: src/lib.rs cbindgen.toml cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/components/StorageManager/kata-storage-interface/Makefile b/apps/system/components/StorageManager/kata-storage-interface/Makefile index 858e4d8..bce624d 100644 --- a/apps/system/components/StorageManager/kata-storage-interface/Makefile +++ b/apps/system/components/StorageManager/kata-storage-interface/Makefile @@ -1,4 +1,4 @@ -INTERFACES=../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/StorageManagerBindings.h: src/lib.rs cbindgen.toml cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/components/TimerService/kata-timer-interface/Makefile b/apps/system/components/TimerService/kata-timer-interface/Makefile index 2cf3af5..6492aee 100644 --- a/apps/system/components/TimerService/kata-timer-interface/Makefile +++ b/apps/system/components/TimerService/kata-timer-interface/Makefile @@ -1,4 +1,4 @@ -INTERFACES=../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/TimerServiceBindings.h: src/lib.rs cbindgen.toml cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/components/kata-os-common/src/camkes/Makefile b/apps/system/components/kata-os-common/src/camkes/Makefile index 1d5b0a3..de489e4 100644 --- a/apps/system/components/kata-os-common/src/camkes/Makefile +++ b/apps/system/components/kata-os-common/src/camkes/Makefile @@ -1,4 +1,4 @@ -INTERFACES=../../../../interfaces +INTERFACES=${OUT}/kata/components ${INTERFACES}/CamkesBindings.h: src/lib.rs cbindgen.toml cbindgen -c cbindgen.toml src/lib.rs -o $@ diff --git a/apps/system/interfaces/MemoryManagerBindings.h b/apps/system/interfaces/MemoryManagerBindings.h deleted file mode 100644 index 97329dc..0000000 --- a/apps/system/interfaces/MemoryManagerBindings.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __MEMORY_MANAGER_BINDINGS_H__ -#define __MEMORY_MANAGER_BINDINGS_H__ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. - */ - -#include "CamkesBindings.h" - -#define RAW_OBJ_DESC_DATA_SIZE 2048 - -#define RAW_MEMORY_STATS_DATA_SIZE 100 - -typedef enum MemoryManagerError { - MmeSuccess = 0, - MmeObjCountInvalid, - MmeObjTypeInvalid, - MmeObjCapInvalid, - MmeCapAllocFailed, - MmeSerializeFailed, - MmeDeserializeFailed, - MmeUnknownError, - MmeAllocFailed, - MmeFreeFailed, -} MemoryManagerError; - -typedef uint8_t RawMemoryStatsData[RAW_MEMORY_STATS_DATA_SIZE]; - -typedef struct MemoryManagerStats { - uintptr_t allocated_bytes; - uintptr_t free_bytes; - uintptr_t total_requested_bytes; - uintptr_t overhead_bytes; - uintptr_t allocated_objs; - uintptr_t total_requested_objs; - uintptr_t untyped_slab_too_small; - uintptr_t out_of_memory; -} MemoryManagerStats; - -#endif /* __MEMORY_MANAGER_BINDINGS_H__ */ diff --git a/apps/system/interfaces/MlCoordBindings.h b/apps/system/interfaces/MlCoordBindings.h deleted file mode 100644 index edbf2cc..0000000 --- a/apps/system/interfaces/MlCoordBindings.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __ML_COORDINATOR_BINDINGS_H__ -#define __ML_COORDINATOR_BINDINGS_H__ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. - */ - -#include "CamkesBindings.h" - -/** - * Errors that can occur when interacting with the MlCoordinator. - */ -typedef enum MlCoordError { - MlCoordOk, - InvalidModelId, - InvalidBundleId, - InvalidImage, - LoadModelFailed, - NoModelSlotsLeft, - NoSuchModel, -} MlCoordError; - -#endif /* __ML_COORDINATOR_BINDINGS_H__ */ diff --git a/apps/system/interfaces/ProcessManagerBindings.h b/apps/system/interfaces/ProcessManagerBindings.h deleted file mode 100644 index f0622a3..0000000 --- a/apps/system/interfaces/ProcessManagerBindings.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __PROCESS_MANAGER_BINDINGS_H__ -#define __PROCESS_MANAGER_BINDINGS_H__ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. - */ - -#include "CamkesBindings.h" - -#define RAW_BUNDLE_ID_DATA_SIZE 100 - -#define DEFAULT_BUNDLE_ID_CAPACITY 64 - -typedef enum ProcessManagerError { - Success = 0, - BundleIdInvalid, - PackageBufferLenInvalid, - BundleNotFound, - BundleFound, - BundleRunning, - UnknownError, - DeserializeError, - SerializeError, - ObjCapInvalid, - InstallFailed, - UninstallFailed, - StartFailed, - StopFailed, - SuspendFailed, - ResumeFailed, -} ProcessManagerError; - -typedef uint8_t RawBundleIdData[RAW_BUNDLE_ID_DATA_SIZE]; - -#endif /* __PROCESS_MANAGER_BINDINGS_H__ */ diff --git a/apps/system/interfaces/SecurityCoordinatorBindings.h b/apps/system/interfaces/SecurityCoordinatorBindings.h deleted file mode 100644 index a236f79..0000000 --- a/apps/system/interfaces/SecurityCoordinatorBindings.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __SECURITY_COORDINATOR_BINDINGS_H__ -#define __SECURITY_COORDINATOR_BINDINGS_H__ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. - */ - -#include "CamkesBindings.h" - -#define SECURITY_REPLY_DATA_SIZE 2048 - -typedef enum SecurityRequest { - SrEcho = 0, - SrInstall, - SrUninstall, - SrSizeBuffer, - SrGetManifest, - SrLoadApplication, - SrLoadModel, - SrReadKey, - SrWriteKey, - SrDeleteKey, - SrTestMailbox, -} SecurityRequest; - -typedef enum SecurityRequestError { - SreSuccess = 0, - SreBundleIdInvalid, - SreBundleDataInvalid, - SreBundleNotFound, - SreDeleteFirst, - SreKeyNotFound, - SrePackageBufferLenInvalid, - SreValueInvalid, - SreKeyInvalid, - SreDeserializeFailed, - SreSerializeFailed, - SreCapAllocFailed, - SreCapMoveFailed, - SreObjCapInvalid, - SreEchoFailed, - SreInstallFailed, - SreUninstallFailed, - SreSizeBufferFailed, - SreGetManifestFailed, - SreLoadApplicationFailed, - SreLoadModelFailed, - SreReadFailed, - SreWriteFailed, - SreDeleteFailed, - SreTestFailed, -} SecurityRequestError; - -typedef uint8_t SecurityReplyData[SECURITY_REPLY_DATA_SIZE]; - -#endif /* __SECURITY_COORDINATOR_BINDINGS_H__ */ diff --git a/apps/system/interfaces/StorageManagerBindings.h b/apps/system/interfaces/StorageManagerBindings.h deleted file mode 100644 index dc5a562..0000000 --- a/apps/system/interfaces/StorageManagerBindings.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __STORAGE_MANAGER_BINDINGS_H__ -#define __STORAGE_MANAGER_BINDINGS_H__ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. - */ - -#include "CamkesBindings.h" - -#define KEY_VALUE_DATA_SIZE 100 - -typedef enum StorageManagerError { - SmeSuccess = 0, - SmeBundleIdInvalid, - SmeBundleNotFound, - SmeKeyNotFound, - SmeValueInvalid, - SmeKeyInvalid, - SmeReadFailed, - SmeWriteFailed, - SmeDeleteFailed, - SmeUnknownError, -} StorageManagerError; - -typedef uint8_t KeyValueData[KEY_VALUE_DATA_SIZE]; - -#endif /* __STORAGE_MANAGER_BINDINGS_H__ */ diff --git a/apps/system/interfaces/TimerServiceBindings.h b/apps/system/interfaces/TimerServiceBindings.h deleted file mode 100644 index 39ed715..0000000 --- a/apps/system/interfaces/TimerServiceBindings.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __TIMER_SERVICE_BINDINGS_H__ -#define __TIMER_SERVICE_BINDINGS_H__ - -/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. - */ - -#include "CamkesBindings.h" - -typedef enum TimerServiceError { - TimerOk = 0, - NoSuchTimer, - TimerAlreadyExists, -} TimerServiceError; - -typedef uint32_t TimerId; - -#endif /* __TIMER_SERVICE_BINDINGS_H__ */