summaryrefslogtreecommitdiff
path: root/framework/main.c
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2014-10-15 15:13:29 +0100
committerSandrine Bailleux <sandrine.bailleux@arm.com>2014-10-15 15:33:36 +0100
commit3fc8e6cfabfb95621847c8e5e11a8d2d4eca4a5b (patch)
tree51e3a141378fbeba00087f16541deb0ca796b08c /framework/main.c
parent805d828a79e83908ba97100e86fa3b950883c11a (diff)
Remove dispatcher and TFTF state machine
* Remove synchronisations based on the TFTF state machine * Remove task dispatcher Also: * Do not power up secondary CPUs in the framework, the test will be responsible of powering up the cores it needs. * Disable hotplug support for now, the warm boot path code needs to be reworked. Secondary CPUs can still be powered on but they will spin forever in the framework and won't be let in the test. Change-Id: I29c54b31be148a8dd0a4be618e25fd596813d172
Diffstat (limited to 'framework/main.c')
-rw-r--r--framework/main.c196
1 files changed, 21 insertions, 175 deletions
diff --git a/framework/main.c b/framework/main.c
index aa8ddd8..9b79cc9 100644
--- a/framework/main.c
+++ b/framework/main.c
@@ -27,19 +27,9 @@
#include <platform.h>
#include <platform_def.h>
#include <mmio.h>
-#include <dispatcher.h>
#include <nvm.h>
#include <tests_api.h>
-void main_test_loop(void);
-void auxiliary_test_loop(void);
-
-/* Hack: silent debug messages related to the dispatcher */
-#ifndef DEBUG_DISPATCHER
-#undef pr_debug
-#define pr_debug(...) /* do nothing */
-#endif
-
// Index of the current testsuite and the current testcase.
unsigned int cur_testsuite;
unsigned int cur_testcase;
@@ -66,8 +56,6 @@ static char *testcase_output_ptr;
static spinlock_t testcase_output_lock;
-#define GET_TASK(core_pos) (TFTF_TASK)mmio_read_64((UINTN)&(mp_task_entries[core_pos].task))
-
void tftf_testcase_output(const char* string) {
unsigned string_length = strlen(string);
@@ -76,7 +64,7 @@ void tftf_testcase_output(const char* string) {
/* If the pointer is outside of the buffer do not copy the output */
if (testcase_output_ptr >=
testcase_output + TESTCASE_OUTPUT_MAX_SIZE) {
- printf("Warning: the buffer cannot handle the test output.\n");
+ mp_printf("Warning: the buffer cannot handle the test output\n");
/* TESTCASE_OUTPUT_MAX_SIZE could need to be increased */
goto release_lock;
}
@@ -169,139 +157,32 @@ static const TESTCASE *move_to_next_test(void) {
return current_testcase();
}
-// That's where the real work begins.
-// All CPUs enter this function once they have finished their initialisations.
-void main_test_loop(void)
+void run_tests(void)
{
- while (1) {
- if (i_am_dispatcher()) {
- pr_debug("I am the dispatcher!\n");
+ while (1) {
+ mp_printf("Starting unittest '%s - %s'\n",
+ current_testsuite()->name, current_testcase()->name);
- tftf_task_change_state(TFTF_TASK_SETUP, TFTF_TASK_WAITING);
+ tftf_testcase_start(current_testcase());
- /* Boot all the cores in the device */
- tftf_bring_up_cores();
-
- for (unsigned int i = 0; i < PLATFORM_CORE_COUNT; i++) {
- if (tftf_platform_is_core_pos_present(i))
- tftf_task_wait_state(i, TFTF_TASK_WAITING);
+ /* The test is finished, let's move to the next one, if any */
+ if (move_to_next_test() == NULL)
+ break;
}
- printf("Starting unittest '%s - %s'\n",
- current_testsuite()->name, current_testcase()->name);
- tftf_testcase_start(current_testcase());
-
- /*
- * TODO: Ensure all CPUs are in the WAITING state, otherwise it means
- * the test function is not well written.
- */
-
-#if TEST_JUNO_DISPATCHER
- void update_dispatcher(void);
- update_dispatcher();
-#endif /* TEST_JUNO_DISPATCHER */
-
- /* Dispatch the END_OF_TEST special task to signal the end of the test */
- tftf_dispatch_task_multi_core_pos(~0,
- END_OF_TEST,
- NULL,
- 1);
- tftf_task_change_state(TFTF_TASK_WAITING, TFTF_TASK_SETUP);
-
- /* ToDo: Check for tests in progress (submitted with wait) before shutdown */
-
- /* Tests have completed, shutdown all cores except the dispatcher */
- tftf_shutdown_all_other_cores();
-
- /* The test is finished, let's move to the next one, if any */
- if (move_to_next_test() == NULL)
- break;
-
- } else {
- /* I am not the dispatcher */
- auxiliary_test_loop();
- }
- }
-
- /*
- * Test session has finished.
- * Only the dispatcher will execute the following code.
- * All other cores have been shut down.
- */
-
- // Generate the test report
- tftf_report_generate();
+ /*
+ * Test session has finished.
+ * Let's generate the test report.
+ */
+ tftf_report_generate();
}
-void auxiliary_test_loop(void)
-{
- TFTF_TASK task = NULL;
- unsigned int mpid, core_pos;
-
- mpid = read_mpidr();
- core_pos = platform_get_core_pos(mpid);
-
- // Signal that we are ready to receive tasks
- tftf_task_change_state(TFTF_TASK_SETUP, TFTF_TASK_WAITING);
-
- while (task != END_OF_TEST) {
- /* The dispatcher CPU will send an event to signal the task dispatching */
- wfe();
- dsb();
-
- task = GET_TASK(core_pos);
-
- if (task != NULL) {
- if (task != END_OF_TEST) {
- // We are going to start the task
- tftf_task_change_state(TFTF_TASK_WAITING, TFTF_TASK_RUNNING);
-
- // Run the test
- mp_task_entries[core_pos].result = task(core_pos, mp_task_entries[core_pos].arguments);
-
- // Signal we have completed the task
- tftf_task_change_state(TFTF_TASK_RUNNING, TFTF_TASK_COMPLETED);
- } else {
- /* Nothing to execute, signal the task is completed */
- tftf_task_change_state(TFTF_TASK_WAITING, TFTF_TASK_COMPLETED);
- }
-
- // Wait for the dispatcher to acknowledge that we completed the test.
- // It will do so by resetting our task pointer.
- task = GET_TASK(core_pos);
- while (task != NULL) {
- wfe();
- task = GET_TASK(core_pos);
- }
-
- if (task != END_OF_TEST) {
- // Signal we are ready to receive a new task.
- tftf_task_change_state(TFTF_TASK_COMPLETED, TFTF_TASK_WAITING);
- } else {
- tftf_task_change_state(TFTF_TASK_COMPLETED, TFTF_TASK_SETUP);
- }
- }
-
- /*
- * All other events are spurious, ignore them and wait for meaningful
- * events.
- */
- }
-}
void tftf_warm_boot_main(void)
{
- unsigned int primary_core_mpid, primary_core_pos;
- unsigned int rc;
+ int rc;
tftf_arch_setup();
-
- /*
- * Enable this debug printf to trace the test progress.
- * It may generate a lot of messages so it is commented out by default.
- */
- /* pr_debug("Entering TFTF: tftf_warm_boot_main\n"); */
-
tftf_register_gic_id();
arm_gic_cpuif_setup();
@@ -315,35 +196,11 @@ void tftf_warm_boot_main(void)
enable_irq();
- /*
- * Before changing the state of the secondary core, we need to wait for the
- * primary core to have initialised its internal dispatcher data structure.
- * Without this synchronisation point, secondary cores might reach this
- * function before the primary core initialised the mp_task_entries[] array
- * in tftf_dispatcher_init() and so their state will be overwritten.
- */
- primary_core_mpid = platform_get_primary_core_mpid();
- primary_core_pos = platform_get_core_pos(primary_core_mpid);
- tftf_task_wait_state(primary_core_pos, TFTF_TASK_ARCH_INIT | TFTF_TASK_SETUP |
- TFTF_TASK_WAITING);
-
- // State initialization
- tftf_task_change_state(TFTF_TASK_OFF, TFTF_TASK_ARCH_INIT);
-
- // Signal we are ready to start the test session.
- tftf_task_change_state(TFTF_TASK_ARCH_INIT, TFTF_TASK_SETUP);
-
- // Wait for the primary core to finish all its initialisations, including the
- // dispatcher internal structure initialisations.
- tftf_task_wait_state(primary_core_pos, TFTF_TASK_SETUP | TFTF_TASK_WAITING);
-
- /*
- * Always go to the main test loop.
- * One of the secondary cores may be the dispatcher,
- * so go to the main_test_loop.
- * Do not presume that this core will jump to the auxiliary_test_loop.
- */
- main_test_loop();
+ /* TODO: Let the core in the test session */
+ /* For now, make it spin in an infinite loop */
+ pr_debug("CPU initialised, now spin in a loop\n");
+ while (1)
+ continue;
}
void tftf_cold_boot_main(void)
@@ -376,13 +233,6 @@ void tftf_cold_boot_main(void)
tftf_abort();
}
- // Initialize the dispatcher
- status = tftf_dispatcher_init();
- if (status != STATUS_SUCCESS) {
- printf("Error: Failed to initialize the task dispatcher (%d).\n", status);
- tftf_abort();
- }
-
// Initialize NVM if necessary.
status = tftf_init_nvm();
if (status != STATUS_SUCCESS) {
@@ -426,13 +276,9 @@ void tftf_cold_boot_main(void)
tftf_testcase_set_result_as_crashed(crashed_testcase_function);
}
- // Signal the secondary CPUs that the primary has finished all initialisations
- // and the test session can begin.
- tftf_task_change_state(TFTF_TASK_ARCH_INIT, TFTF_TASK_SETUP);
-
enable_irq();
- main_test_loop();
+ run_tests();
clean_nvm:
if (tftf_clean_nvm() != STATUS_SUCCESS)