From fe95ea221b2b88e9cb52a6378ff2018ee752094b Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 22 Dec 2016 23:47:46 -0500 Subject: build: Define DECL_CONSTANT mechanism for defining exported constants Add a DECL_CONSTANT macro to allow the firmware to define constants that are to be exported to the host during the "identify" phase. This replaces the existing hardcoded mechanism of scanning the Kconfig header file for certain constants. Signed-off-by: Kevin O'Connor --- src/command.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/command.h') diff --git a/src/command.h b/src/command.h index 2bbe37f8..c6d8a69c 100644 --- a/src/command.h +++ b/src/command.h @@ -15,6 +15,10 @@ // Flags for command handler declarations. #define HF_IN_SHUTDOWN 0x01 // Handler can run even when in emergency stop +// Declare a constant exported to the host +#define DECL_CONSTANT(NAME, VALUE) \ + _DECL_CONSTANT(NAME, VALUE) + // Send an output message (and declare a static message type for it) #define output(FMT, args...) \ _sendf(_DECL_OUTPUT(FMT) , ##args ) @@ -59,6 +63,11 @@ extern const uint32_t command_identify_size; = "_DECL_COMMAND " __stringify(FUNC) " " __stringify(FLAGS) " " MSG; \ void __visible FUNC(uint32_t*) +#define _DECL_CONSTANT(NAME, VALUE) \ + char __PASTE(_DECLC_ ## NAME ## _, __LINE__) [] \ + __visible __section(".compile_time_request") \ + = "_DECL_CONSTANT " __stringify(NAME) " " __stringify(VALUE) + // Create a compile time request and return a unique (incrementing id) // for that request. #define _DECL_REQUEST_ID(REQUEST, ID_SECTION) ({ \ -- cgit v1.2.3-70-g09d2