Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  *  @@file
0005  *
0006  *  Odd Id Cases where API configured but No Threads
0007  *    + Possibly Valid Id passed to directive
0008  */
0009 
0010 /*
0011  *  COPYRIGHT (c) 1989-2012.
0012  *  On-Line Applications Research Corporation (OAR).
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifdef HAVE_CONFIG_H
0037 #include "config.h"
0038 #endif
0039 
0040 #include <rtems/sysinit.h>
0041 #include <rtems/score/memory.h>
0042 #include <rtems/score/thread.h>
0043 
0044 #include <tmacros.h>
0045 
0046 const char rtems_test_name[] = "SP 54";
0047 
0048 static void *Init( uintptr_t ignored )
0049 {
0050   rtems_status_code                    status;
0051   rtems_task_priority                  pri;
0052   rtems_id                             id;
0053   const rtems_api_configuration_table *config;
0054 
0055   puts( "Init - use valid id of API class with no objects" );
0056   status = rtems_task_set_priority(
0057     rtems_build_id(0x2,0x1,0x01,0x0001) /* 0xa010001 */,
0058     RTEMS_CURRENT_PRIORITY,
0059     &pri
0060   );
0061   fatal_directive_status( status, RTEMS_INVALID_ID, "rtems_task_set_priority" );
0062 
0063   puts( "Init - lookup name within API class with no objects" );
0064   status = rtems_task_ident(
0065     rtems_build_id( 0, 0, 0x12, 0x3456) /* 0x123456 */,
0066     RTEMS_SEARCH_ALL_NODES,
0067     &id
0068   );
0069   fatal_directive_status( status, RTEMS_INVALID_NAME, "rtems_task_ident" );
0070 
0071   rtems_test_assert( rtems_configuration_get_do_zero_of_workspace() );
0072 
0073   config = rtems_configuration_get_rtems_api_configuration();
0074   rtems_test_assert( config->number_of_initialization_tasks == 0 );
0075   rtems_test_assert( config->User_initialization_tasks_table == NULL );
0076 
0077   TEST_END();
0078   rtems_test_exit(0);
0079 }
0080 
0081 static void check_dirty_memory( void )
0082 {
0083   unsigned char *p;
0084 
0085   TEST_BEGIN();
0086 
0087   p = _Memory_Allocate( _Memory_Get(), sizeof( *p ), RTEMS_ALIGNOF( *p ) );
0088   rtems_test_assert( p != NULL );
0089   rtems_test_assert( *p == 0xcf );
0090 
0091   p = (unsigned char *) _Thread_Information.Objects.initial_objects;
0092   rtems_test_assert( *p == 0xcf );
0093 }
0094 
0095 RTEMS_SYSINIT_ITEM(
0096   check_dirty_memory,
0097   RTEMS_SYSINIT_DIRTY_MEMORY,
0098   RTEMS_SYSINIT_ORDER_LAST
0099 );
0100 
0101 static void check_zero_workspace_automatically( void )
0102 {
0103   unsigned char *p;
0104 
0105   p = _Memory_Allocate( _Memory_Get(), sizeof( *p ), RTEMS_ALIGNOF( *p ) );
0106   rtems_test_assert( p != NULL );
0107   rtems_test_assert( *p == 0 );
0108 
0109   p = (unsigned char *) _Thread_Information.Objects.initial_objects;
0110   rtems_test_assert( *p == 0 );
0111 }
0112 
0113 RTEMS_SYSINIT_ITEM(
0114   check_zero_workspace_automatically,
0115   RTEMS_SYSINIT_ZERO_MEMORY,
0116   RTEMS_SYSINIT_ORDER_LAST
0117 );
0118 
0119 /* configuration information */
0120 
0121 #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
0122 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0123 
0124 /*
0125  *  In this application, the initialization task performs the system
0126  *  initialization and then transforms itself into the idle task.
0127  */
0128 #define CONFIGURE_IDLE_TASK_BODY Init
0129 #define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
0130 
0131 #define CONFIGURE_DIRTY_MEMORY
0132 
0133 /*
0134  *  Ensure we test the case where memory is zero.
0135  */
0136 #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY
0137 
0138 #define CONFIGURE_INIT
0139 #include <rtems/confdefs.h>
0140 
0141 /* global variables */