From f70a9af73f285124953b80b618f00ec4e99735e6 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Fri, 24 Jun 2022 16:59:41 +0000 Subject: [PATCH] Remove unused LogFibonacci component. This is now an app that can be loaded at runtime so remove the component. Change-Id: Ibb851a64902e69322465fc729cf6d1876ae7943b GitOrigin-RevId: b534499935f32dd7d7529af86dd5ee0843d9579a --- .../LogFibonacci/LogFibonacci.camkes | 7 -- .../components/LogFibonacci/assembly.camkes | 11 --- .../system/components/LogFibonacci/src/main.c | 98 ------------------- apps/system/system.camkes | 7 -- 4 files changed, 123 deletions(-) delete mode 100644 apps/system/components/LogFibonacci/LogFibonacci.camkes delete mode 100644 apps/system/components/LogFibonacci/assembly.camkes delete mode 100644 apps/system/components/LogFibonacci/src/main.c diff --git a/apps/system/components/LogFibonacci/LogFibonacci.camkes b/apps/system/components/LogFibonacci/LogFibonacci.camkes deleted file mode 100644 index d599660..0000000 --- a/apps/system/components/LogFibonacci/LogFibonacci.camkes +++ /dev/null @@ -1,7 +0,0 @@ -import ; - -component LogFibonacci { - control; - - uses LoggerInterface logger; -} diff --git a/apps/system/components/LogFibonacci/assembly.camkes b/apps/system/components/LogFibonacci/assembly.camkes deleted file mode 100644 index 093720b..0000000 --- a/apps/system/components/LogFibonacci/assembly.camkes +++ /dev/null @@ -1,11 +0,0 @@ -import "LogFibonacci.camkes"; - -assembly { - composition { - component LogFibonacci log_fibonacci; - - connection seL4RPCOverMultiSharedData log_fibonacci_logger( - from log_fibonacci.logger, - to debug_console.logger); - } -} diff --git a/apps/system/components/LogFibonacci/src/main.c b/apps/system/components/LogFibonacci/src/main.c deleted file mode 100644 index 7c466c5..0000000 --- a/apps/system/components/LogFibonacci/src/main.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2021, Google LLC - * - * Demo component to show that concurrent control threads can be running. - * - * This component logs the first LOG_FIBONACCI_LIMIT Fibonacci numbers using the - * LoggerInterface, waiting for INTERRUPTS_PER_WAIT interrupts between each - * number. The messages are logged at level TRACE, which can be enabled by - * issuing "loglevel trace" at the Kata prompt. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -// TODO(b/198360356): Remove this component when it is no longer needed for -// concurrency testing. - -#include -#include -#include - -// How many Fibonacci numbers to write to the log. -#define LOG_FIBONACCI_LIMIT 80 - -#define INTERRUPTS_PER_VIRT_SEC (1000 / CONFIG_TIMER_TICK_MS) -#define INTERRUPTS_PER_WAIT (2 * INTERRUPTS_PER_VIRT_SEC) -#define LOGGER_INTERFACE_LOG_LEVEL 5 - -typedef uint64_t interrupt_count_t; - -typedef struct { - uint64_t f1; - uint64_t f2; - uint64_t n; -} fibonacci_state_t; - -static void fibonacci_init(fibonacci_state_t *state) { - state->f1 = 0; - state->f2 = 1; - state->n = 0; -} - -static void fibonacci_increment(fibonacci_state_t *state) { - uint64_t swap = state->f2; - state->f2 = state->f1 + state->f2; - state->f1 = swap; - ++state->n; -} - -static void wait(interrupt_count_t interrupt_count_to_wait, - interrupt_count_t *counter) { - for (interrupt_count_t i = 0; i < interrupt_count_to_wait; ++i) { - asm volatile("wfi"); - ++*counter; - } -} - -static float virtual_seconds(interrupt_count_t interrupt_count) { - return interrupt_count / INTERRUPTS_PER_VIRT_SEC; -} - -static uint64_t rdtime(void) { - uint32_t upper, lower, upper_reread; - while (1) { - asm volatile( - "rdtimeh %0\n" - "rdtime %1\n" - "rdtimeh %2\n" - : "=r"(upper), "=r"(lower), "=r"(upper_reread)); - if (upper_reread == upper) { - return ((uint64_t)upper << 32) | lower; - } - } -} - -static void fibonacci_log(const fibonacci_state_t *fibonacci_state, - interrupt_count_t interrupt_count) { - char log_buf[128]; - snprintf(log_buf, sizeof(log_buf) / sizeof(char), - "log_fibonacci:control: n == %llu; f == %llu; interrupt_count == " - "%llu; rdtime == %llu; virt_sec ~= %.2f", - fibonacci_state->n, fibonacci_state->f1, interrupt_count, rdtime(), - virtual_seconds(interrupt_count)); - logger_log(LOGGER_INTERFACE_LOG_LEVEL, log_buf); -} - -int run(void) { - interrupt_count_t interrupt_count = 0; - fibonacci_state_t fibonacci_state; - fibonacci_init(&fibonacci_state); - while (1) { - wait(INTERRUPTS_PER_WAIT, &interrupt_count); - if (fibonacci_state.n >= LOG_FIBONACCI_LIMIT) { - fibonacci_init(&fibonacci_state); - } - fibonacci_log(&fibonacci_state, interrupt_count); - fibonacci_increment(&fibonacci_state); - } -} diff --git a/apps/system/system.camkes b/apps/system/system.camkes index 0716326..f22b2ff 100644 --- a/apps/system/system.camkes +++ b/apps/system/system.camkes @@ -232,10 +232,3 @@ assembly { uart.integrity_label = "opentitan_uart_driver"; } } - -// Uncomment to run a concurrency test component that is runnable every time -// the scheduler checks and which periodically calls logger.log. -// -// (Needs to be at the bottom of file because CAmkES ADL does not have forward -// declaration.) -// import "components/LogFibonacci/assembly.camkes";