Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:43

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * Copyright (c) 2014 embedded brains GmbH & Co. KG
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0025  * POSSIBILITY OF SUCH DAMAGE.
0026  */
0027 
0028 #ifdef HAVE_CONFIG_H
0029 #include "config.h"
0030 #endif
0031 
0032 #include "tmacros.h"
0033 
0034 #include <rtems.h>
0035 #include <rtems/score/smpimpl.h>
0036 
0037 #include <bsp.h>
0038 #include <bsp/bootcard.h>
0039 
0040 #include <assert.h>
0041 #include <stdlib.h>
0042 
0043 const char rtems_test_name[] = "SMPFATAL 8";
0044 
0045 /*
0046  * This test is a hack since there is no easy way to test this fatal error path
0047  * without BSP support.
0048  */
0049 
0050 void bsp_start_on_secondary_processor(struct Per_CPU_Control *cpu_self)
0051 {
0052   /* Provided to avoid multiple definitions of the CPU SMP support functions */
0053   (void) cpu_self;
0054   /* Block secondary cpus if they are running to avoid clobbering output */
0055   (void) _CPU_Thread_Idle_body( 0 );
0056 }
0057 
0058 #if QORIQ_THREAD_COUNT > 1
0059 void qoriq_start_thread(Per_CPU_Control *cpu_self)
0060 {
0061   /* Provided to avoid multiple definitions of the CPU SMP support functions */
0062   (void) cpu_self;
0063 }
0064 #endif
0065 
0066 uint32_t _CPU_SMP_Initialize(void)
0067 {
0068   return 2;
0069 }
0070 
0071 bool _CPU_SMP_Start_processor(uint32_t cpu_index)
0072 {
0073   (void) cpu_index;
0074 
0075   return false;
0076 }
0077 
0078 void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
0079 {
0080   (void) cpu_count;
0081 
0082   assert(0);
0083 }
0084 
0085 void _CPU_SMP_Prepare_start_multitasking(void)
0086 {
0087   assert(0);
0088 }
0089 
0090 #if defined(RTEMS_PARAVIRT) \
0091   || (!defined(__leon__) && !defined(__PPC__) \
0092     && !defined(__arm__) && !defined(__riscv))
0093 uint32_t _CPU_SMP_Get_current_processor(void)
0094 {
0095   return 0;
0096 }
0097 #endif
0098 
0099 void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
0100 {
0101   (void) target_processor_index;
0102 }
0103 
0104 static void Init(rtems_task_argument arg)
0105 {
0106   assert(0);
0107 }
0108 
0109 static void fatal_extension(
0110   rtems_fatal_source source,
0111   bool always_set_to_false,
0112   rtems_fatal_code code
0113 )
0114 {
0115   TEST_BEGIN();
0116 
0117   if (
0118     source == RTEMS_FATAL_SOURCE_SMP
0119       && !always_set_to_false
0120       && code == SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
0121   ) {
0122     TEST_END();
0123   }
0124 }
0125 
0126 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0127 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0128 
0129 #define CONFIGURE_INITIAL_EXTENSIONS \
0130   { .fatal = fatal_extension }, \
0131   RTEMS_TEST_INITIAL_EXTENSION
0132 
0133 #define CONFIGURE_MAXIMUM_PROCESSORS 2
0134 
0135 #define CONFIGURE_SCHEDULER_SIMPLE_SMP
0136 
0137 #include <rtems/scheduler.h>
0138 
0139 RTEMS_SCHEDULER_SIMPLE_SMP(a);
0140 
0141 #define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
0142   RTEMS_SCHEDULER_TABLE_SIMPLE_SMP(a, rtems_build_name('S', 'I', 'M', 'P'))
0143 
0144 #define CONFIGURE_SCHEDULER_ASSIGNMENTS \
0145   RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
0146   RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY)
0147 
0148 #define CONFIGURE_MAXIMUM_TASKS 1
0149 
0150 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0151 
0152 #define CONFIGURE_INIT
0153 
0154 #include <rtems/confdefs.h>