cbindgen: Dynamically generate header files during toplevel build

Change-Id: I9e62df409506f9e9e79c984f966b34cf09c1b95f
GitOrigin-RevId: 319803d00536e972f6aa65eacb5c471db97be9af
This commit is contained in:
June Tate-Gans 2022-08-15 14:48:03 -05:00 committed by Sam Leffler
parent d890571c5e
commit a5ca02b0e7
14 changed files with 22 additions and 200 deletions

View File

@ -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)

View File

@ -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 $@

View File

@ -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 $@

View File

@ -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 $@

View File

@ -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 $@

View File

@ -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 $@

View File

@ -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 $@

View File

@ -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 $@

View File

@ -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__ */

View File

@ -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__ */

View File

@ -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__ */

View File

@ -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__ */

View File

@ -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__ */

View File

@ -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__ */