void bsp_pretasking_hook(void)
{
    void         *heapStart;
    unsigned long heapSize = (unsigned long)_HeapSize;
    unsigned long ramSpace;

    heapStart =  (void *)
       ((unsigned long)_WorkspaceBase + BSP_Configuration.work_space_size);
    ramSpace = (unsigned long)_RamBase + _M68k_Ramsize - (unsigned long)heapStart;

    /*
     * Can't use 'if(heapSize==0)' because the compiler "knows" that nothing
     * can have an address of 0 and proceeds to optimize-away the test.
     */
    if (heapSize < 10)
        heapSize = ramSpace;
    else if (heapSize > ramSpace)
        rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P');

    bsp_libc_init(heapStart, heapSize, 0);

#ifdef RTEMS_DEBUG
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif

}
Beispiel #2
0
rtems_task Init(
  rtems_task_argument ignored
)
{
  bool                  is_set;

  puts( "\n\n*** TEST 10 ***" );

  puts( "Init - clear debug level" );
  _Debug_Level = 0;

  puts( "Init - rtems_debug_is_enabled - is 0x1 set? No" );
  is_set = rtems_debug_is_enabled( 0x1 );
  rtems_test_assert(is_set == false);

  puts( "Init - rtems_debug_enable - set 0x1" );
  rtems_debug_enable(0x1);
  rtems_test_assert(_Debug_Level == 0x1);

  puts( "Init - rtems_debug_is_enabled - is 0x1 set? Yes" );
  is_set = rtems_debug_is_enabled( 0x1 );
  rtems_test_assert(is_set == true);

  puts( "Init - rtems_debug_disable - clear 0x1" );
  rtems_debug_disable(0x1);
  rtems_test_assert(_Debug_Level == 0x0);

  puts( "Init - rtems_debug_is_enabled - is 0x1 set? No" );
  is_set = rtems_debug_is_enabled( 0x1 );
  rtems_test_assert(is_set == false);

  puts( "*** END OF TEST 10 ***" );
  rtems_test_exit(0);
}
void
bsp_pretasking_hook(void)
{
  /*
   *  These are assigned addresses in the linkcmds file for the BSP. This
   *  approach is better than having these defined as manifest constants and
   *  compiled into the kernel, but it is still not ideal when dealing with
   *  multiprocessor configuration in which each board as a different memory
   *  map. A better place for defining these symbols might be the makefiles.
   *  Consideration should also be given to developing an approach in which
   *  the kernel and the application can be linked and burned into ROM
   *  independently of each other.
   */
    extern unsigned char _HeapStart;
    extern unsigned char _HeapEnd;

    bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );

#ifdef STACK_CHECKER_ON
  /*
   *  Initialize the stack bounds checker
   *  We can either turn it on here or from the app.
   */

  Stack_check_Initialize();
#endif

#ifdef RTEMS_DEBUG
  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
}
void bsp_pretasking_hook(void)
{
    bsp_libc_init(&HeapStart, (char *)&HeapEnd - (char *)&HeapStart, 0);

#ifdef RTEMS_DEBUG
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
}
void bsp_pretasking_hook(void)
{
    void         *heapStart;
    unsigned long heapSize;
    extern int WorkspaceBase;

    heapStart =  (void *)
       ((unsigned long)&WorkspaceBase + BSP_Configuration.work_space_size);
    if ( (unsigned long) heapStart > (256 * 1024) )
       rtems_fatal_error_occurred (('H'<<24) | ('E'<<16) | ('A'<<8) | 'P');
    heapSize = (256 * 1024) - (unsigned long)(heapStart);
    bsp_libc_init(heapStart, heapSize, 0);

#ifdef RTEMS_DEBUG
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif

}
/*-------------------------------------------------------------------------+
|         Function: bsp_pretasking_hook
|      Description: BSP pretasking hook.  Called just before drivers are
|                   initialized. Used to setup libc and install any BSP
|                   extensions. NOTE: Must not use libc (to do io) from here,
|                   since drivers are not yet initialized.
| Global Variables: None.
|        Arguments: None.
|          Returns: Nothing.
+--------------------------------------------------------------------------*/
void bsp_pretasking_hook(void)
{

    unsigned32 heap_start;
    unsigned32 heap_size;


    /*
     * Set up the heap.
     */
    heap_start =  free_mem_start;
    heap_size = free_mem_end - free_mem_start;

    /* call rtems lib init - malloc stuff */
    bsp_libc_init((void *)heap_start, heap_size, 0);

#ifdef RTEMS_DEBUG

    rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);

#endif /* RTEMS_DEBUG */

} /* bsp_pretasking_hook */
/*
 *  bsp_pretasking_hook
 *
 *  Called when RTEMS initialization is complete but before interrupts and
 *  tasking are enabled. Used to setup libc and install any BSP extensions.
 *
 *  Must not use libc (to do io) from here, since drivers are not yet
 *  initialized.
 *
 *  Installed in the rtems_cpu_table defined in
 *  rtems/c/src/exec/score/cpu/powerpc/rtems/new-exceptions/cpu.h by main()
 *  below.  Called from rtems_initialize_executive() defined in
 *  rtems/c/src/exec/sapi/src/init.c
 *
 *  Input parameters: NONE
 *
 *  Output parameters: NONE
 *
 *  Return values: NONE
 */
void bsp_pretasking_hook(void)
{
  /*
   *  These are assigned addresses in the linkcmds file for the BSP. This
   *  approach is better than having these defined as manifest constants and
   *  compiled into the kernel, but it is still not ideal when dealing with
   *  multiprocessor configuration in which each board as a different memory
   *  map. A better place for defining these symbols might be the makefiles.
   *  Consideration should also be given to developing an approach in which
   *  the kernel and the application can be linked and burned into ROM
   *  independently of each other.
   */
    uint8_t *_HeapStart =
      (uint8_t *)BSP_Configuration.work_space_start
           + BSP_Configuration.work_space_size;
    extern uint8_t _HeapEnd[];

    bsp_libc_init( _HeapStart, _HeapEnd - _HeapStart, 0 );

#ifdef RTEMS_DEBUG
  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif
}
void bsp_pretasking_hook(void)
{
    uint32_t   heap_start;
    uint32_t   heap_size;

    /*
     * Set up the heap. It uses all free SDRAM except that reserved
     * for non-cached uses.
     */
    heap_start =  free_mem_start;

    /*   heap_size = (free_mem_end - heap_start - MEM_NOCACHE_SIZE); */
    heap_size = 0x200000;

    bsp_libc_init((void *)heap_start, heap_size, 0);

#ifdef RTEMS_DEBUG

  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);

#endif /* RTEMS_DEBUG */

} /* bsp_pretasking_hook */
Beispiel #9
0
void region_error_tests(void)
{
  void                   *segment_address_1;
  void                   *segment_address_2;
  void                   *segment_address_3;
  uintptr_t               segment_size;
  rtems_status_code       status;
  Heap_Information_block  the_info;
  rtems_id                junk_id;

  Region_name[ 1 ]     =  rtems_build_name( 'R', 'N', '1', ' ' );

  /* Check invalid name error case */
  status = rtems_region_create(
    0,
    Region_good_area,
    0x40,
    32,
    RTEMS_DEFAULT_ATTRIBUTES,
    &junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_region_create with illegal name"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_NAME" );

  /* Check NULL starting address error case */
  status = rtems_region_create(
    Region_name[ 1 ],
    NULL,
    0x40,
    32,
    RTEMS_DEFAULT_ATTRIBUTES,
    &junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_create with NULL address"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );

  /* Invalid size */
  status = rtems_region_create(
    Region_name[ 1 ],
    Region_good_area,
    0,
    0,
    RTEMS_DEFAULT_ATTRIBUTES,
    &junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_SIZE,
    "rtems_region_create with illegal size"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_SIZE" );

  /* Check NULL id error case */
  status = rtems_region_create(
    Region_name[ 1 ],
    Region_good_area,
    REGION_LENGTH,
    0x40,
    RTEMS_DEFAULT_ATTRIBUTES,
    NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_create with NULL id"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_create(
    Region_name[ 1 ],
    &Region_good_area[ REGION_START_OFFSET ],
    REGION_LENGTH,
    0x40,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Region_id[ 1 ]
  );
  directive_failed( status, "rtems_region_create" );
  puts( "TA1 - rtems_region_create - RTEMS_SUCCESSFUL" );

  /* extend NULL address */
  status = rtems_region_extend(
    Region_id[ 1 ],
    NULL,
    REGION_LENGTH - 1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_extend with NULL"
  );
  puts( "TA1 - rtems_region_extend - NULL address - RTEMS_INVALID_ADDRESS" );

  /* extend within heap */
  status = rtems_region_extend(
    Region_id[ 1 ],
    &Region_good_area[ REGION_START_OFFSET ],
    REGION_LENGTH - 1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_extend with address in heap"
  );
  puts( "TA1 - rtems_region_extend - address within - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_create(
    Region_name[ 1 ],
    Region_good_area,
    REGION_LENGTH,
    0x40,
    RTEMS_DEFAULT_ATTRIBUTES,
    &junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_TOO_MANY,
    "rtems_region_create of too many"
  );
  puts( "TA1 - rtems_region_create - RTEMS_TOO_MANY" );

  status = rtems_region_delete( 100 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_delete with illegal id"
  );
  puts( "TA1 - rtems_region_delete - unknown RTEMS_INVALID_ID" );

  status = rtems_region_delete( rtems_build_id( 1, 1, 1, 256 ) );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_delete with illegal id"
  );
  puts( "TA1 - rtems_region_delete - local RTEMS_INVALID_ID" );

  status = rtems_region_ident( 0, &junk_id );
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_region_ident with illegal name"
  );
  puts( "TA1 - rtems_region_ident - RTEMS_INVALID_NAME" );

  /* Check get_information errors */
  status = rtems_region_get_information( Region_id[ 1 ], NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_information with NULL information"
  );
  puts( "TA1 - rtems_region_get_information - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_information( 100, &the_info );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_information with illegal id"
  );
  puts( "TA1 - rtems_region_get_information - unknown RTEMS_INVALID_ID" );

  /* Check get_free_information errors */
  status = rtems_region_get_free_information( Region_id[ 1 ], NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_free_information with NULL information"
  );
  puts( "TA1 - rtems_region_get_free_information - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_free_information( 100, &the_info );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_free_information with illegal id"
  );
  puts( "TA1 - rtems_region_get_free_information - unknown RTEMS_INVALID_ID" );

  /* get segment illegal id */
  status = rtems_region_get_segment(
    100,
    0x40,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &segment_address_1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_segment with illegal id"
  );
  puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ID" );

  /* get_segment with NULL param */
  status = rtems_region_get_segment(
     Region_id[ 1 ],
     2,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_segment with NULL param"
  );
  puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ADDRESS" );

  /* get_segment with illegal 0 size */
  status = rtems_region_get_segment(
     Region_id[ 1 ],
     0,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     &segment_address_1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_SIZE,
    "rtems_region_get_segment with 0 size"
  );
  puts( "TA1 - rtems_region_get_segment - 0 size - RTEMS_INVALID_SIZE" );

  /* get_segment with illegal big size */
  status = rtems_region_get_segment(
     Region_id[ 1 ],
     sizeof( Region_good_area ) * 2,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     &segment_address_1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_SIZE,
    "rtems_region_get_segment with big size"
  );
  puts( "TA1 - rtems_region_get_segment - too big - RTEMS_INVALID_SIZE" );

  status = rtems_region_get_segment(
     Region_id[ 1 ],
     REGION_LENGTH / 2,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     &segment_address_1
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts( "TA1 - rtems_region_get_segment - RTEMS_SUCCESSFUL" );

  status = rtems_region_get_segment(
     Region_id[ 1 ],
     REGION_LENGTH / 2,
     RTEMS_NO_WAIT,
     RTEMS_NO_TIMEOUT,
     &segment_address_2
  );
  fatal_directive_status(
    status,
    RTEMS_UNSATISFIED,
    "rtems_region_get_segment unsatisfied"
  );
  puts( "TA1 - rtems_region_get_segment - RTEMS_UNSATISFIED" );

  puts( "TA1 - rtems_region_get_segment - timeout in 3 seconds" );
  status = rtems_region_get_segment(
    Region_id[ 1 ],
    REGION_LENGTH / 2,
    RTEMS_DEFAULT_OPTIONS,
    3 * rtems_clock_get_ticks_per_second(),
    &segment_address_3
  );
  fatal_directive_status(
    status,
    RTEMS_TIMEOUT,
    "rtems_region_get_segment timeout"
  );
  puts( "TA1 - rtems_region_get_segment - woke up with RTEMS_TIMEOUT" );

  /* Check get_segment_size errors */
  status = rtems_region_get_segment_size( Region_id[ 1 ], NULL, &segment_size );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_segment_size with NULL segment"
  );
  puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_segment_size(
    Region_id[ 1 ], segment_address_1, NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_segment_size with NULL size"
  );
  puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_segment_size(
    100, segment_address_1, &segment_size
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_segment_size with illegal id"
  );
  puts( "TA1 - rtems_region_get_segment_size - unknown RTEMS_INVALID_ID" );

  status = rtems_region_delete( Region_id[ 1 ] );
  fatal_directive_status(
    status,
    RTEMS_RESOURCE_IN_USE,
    "rtems_region_delete with buffers in use"
  );
  puts( "TA1 - rtems_region_delete - RTEMS_RESOURCE_IN_USE" );

  /* Check resize_segment errors */
  status = rtems_region_resize_segment(
    Region_id[ 1 ], segment_address_3, 256, NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_resize_segment with NULL old size"
  );
  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_resize_segment(
    Region_id[ 1 ], NULL, 256, &segment_size
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_resize_segment with NULL segment"
  );
  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_resize_segment(
    100, segment_address_3, 256, &segment_size
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_resize_segment with illegal id"
  );
  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ID" );

  /* Check return_segment errors */
  status = rtems_region_return_segment( 100, segment_address_1 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_return_segment with illegal id"
  );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ID" );

  status = rtems_region_return_segment( Region_id[ 1 ], Region_good_area );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_return_segment with illegal segment"
  );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );

/*
 *  The following generate internal heap errors.  Thus this code
 *  is subject to change if the heap code changes.
 */

  puts( "TA1 - rtems_debug_disable - RTEMS_DEBUG_REGION" );
  rtems_debug_disable( RTEMS_DEBUG_REGION );

  puts( "TA1 - rtems_debug_enable - RTEMS_DEBUG_REGION" );
  rtems_debug_enable( RTEMS_DEBUG_REGION );

  status = rtems_region_extend(
    100,
    Region_good_area,
    128
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_extend with illegal id"
  );
  puts( "TA1 - rtems_region_extend - RTEMS_INVALID_ID" );

  status = rtems_region_extend(
    Region_id[ 1 ],
    &Region_good_area[ REGION_START_OFFSET + 16 ],
    128
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_extend with illegal starting address"
  );
  puts( "TA1 - rtems_region_extend - within heap - RTEMS_INVALID_ADDRESS" );
}
Beispiel #10
0
/*
 *  This is the initialization framework routine that weaves together
 *  calls to RTEMS and the BSP in the proper sequence to initialize
 *  the system while maximizing shared code and keeping BSP code in C
 *  as much as possible.
 */
int boot_card(
    const char *cmdline
)
{
    rtems_interrupt_level  bsp_isr_level;
    void                  *work_area_start = NULL;
    uintptr_t              work_area_size = 0;
    void                  *heap_start = NULL;
    uintptr_t              heap_size = 0;

    /*
     * Special case for PowerPC: The interrupt disable mask is stored in SPRG0.
     * It must be valid before we can use rtems_interrupt_disable().
     */
#ifdef PPC_INTERRUPT_DISABLE_MASK_DEFAULT
    ppc_interrupt_set_disable_mask( PPC_INTERRUPT_DISABLE_MASK_DEFAULT );
#endif /* PPC_INTERRUPT_DISABLE_MASK_DEFAULT */

    /*
     *  Make sure interrupts are disabled.
     */
    rtems_interrupt_disable( bsp_isr_level );

    bsp_boot_cmdline = cmdline;

    /*
     * Invoke Board Support Package initialization routine written in C.
     */
    bsp_start();

    /*
     *  Find out where the block of memory the BSP will use for
     *  the RTEMS Workspace and the C Program Heap is.
     */
    bsp_get_work_area(&work_area_start, &work_area_size,
                      &heap_start, &heap_size);

    if ( work_area_size <= Configuration.work_space_size ) {
        printk(
            "bootcard: work space too big for work area: %p > %p\n",
            (void *) Configuration.work_space_size,
            (void *) work_area_size
        );
        bsp_cleanup();
        return -1;
    }

    if ( rtems_unified_work_area ) {
        Configuration.work_space_start = work_area_start;
        Configuration.work_space_size  = work_area_size;
    } else {
        Configuration.work_space_start = work_area_start;
    }

#if (BSP_DIRTY_MEMORY == 1)
    memset( work_area_start, 0xCF,  work_area_size );
#endif

    /*
     *  Initialize RTEMS data structures
     */
    rtems_initialize_data_structures();

    /*
     *  Initialize the C library for those BSPs using the shared
     *  framework.
     */
    bootcard_bsp_libc_helper(
        work_area_start,
        work_area_size,
        heap_start,
        heap_size
    );

    /*
     *  All BSP to do any required initialization now that RTEMS
     *  data structures are initialized.  In older BSPs or those
     *  which do not use the shared framework, this is the typical
     *  time when the C Library is initialized so malloc()
     *  can be called by device drivers.  For BSPs using the shared
     *  framework, this routine can be empty.
     */
    bsp_pretasking_hook();

    /*
     *  If debug is enabled, then enable all dynamic RTEMS debug
     *  capabilities.
     *
     *  NOTE: Most debug features are conditionally compiled in
     *        or enabled via configure time plugins.
     */
#ifdef RTEMS_DEBUG
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
#endif

    /*
     *  Let RTEMS perform initialization it requires before drivers
     *  are allowed to be initialized.
     */
    rtems_initialize_before_drivers();

    /*
     *  Execute BSP specific pre-driver hook. Drivers haven't gotten
     *  to initialize yet so this is a good chance to initialize
     *  buses, spurious interrupt handlers, etc..
     *
     *  NOTE: Many BSPs do not require this handler and use the
     *        shared stub.
     */
    bsp_predriver_hook();

    /*
     *  Initialize all device drivers.
     */
    rtems_initialize_device_drivers();

    /*
     *  Invoke the postdriver hook.  This normally opens /dev/console
     *  for use as stdin, stdout, and stderr.
     */
    bsp_postdriver_hook();

    /*
     *  Complete initialization of RTEMS and switch to the first task.
     *  Global C++ constructors will be executed in the context of that task.
     */
    rtems_initialize_start_multitasking();

    /***************************************************************
     ***************************************************************
     *  APPLICATION RUNS HERE!!!  When it shuts down, we return!!! *
     ***************************************************************
     ***************************************************************
     */

    /*
     *  Perform any BSP specific shutdown actions which are written in C.
     */
    bsp_cleanup();

    /*
     *  Now return to the start code.
     */
    return 0;
}
Beispiel #11
0
/*
 *  This is the initialization framework routine that weaves together
 *  calls to RTEMS and the BSP in the proper sequence to initialize
 *  the system while maximizing shared code and keeping BSP code in C
 *  as much as possible.
 */
void boot_card(
  const char *cmdline
)
{
  rtems_interrupt_level  bsp_isr_level;

  /*
   *  Make sure interrupts are disabled.
   */
  (void) bsp_isr_level;
  rtems_interrupt_local_disable( bsp_isr_level );

  bsp_boot_cmdline = cmdline;

  /*
   * Invoke Board Support Package initialization routine written in C.
   */
  bsp_start();

  /*
   *  Initialize the RTEMS Workspace and the C Program Heap.
   */
  bsp_work_area_initialize();

  /*
   *  Initialize RTEMS data structures
   */
  rtems_initialize_data_structures();

  /*
   *  Initialize the C library for those BSPs using the shared
   *  framework.
   */
  bsp_libc_init();

  /*
   *  Let the BSP do any required initialization now that RTEMS
   *  data structures are initialized.  In older BSPs or those
   *  which do not use the shared framework, this is the typical
   *  time when the C Library is initialized so malloc()
   *  can be called by device drivers.  For BSPs using the shared
   *  framework, this routine can be empty.
   */
  bsp_pretasking_hook();

  /*
   *  If debug is enabled, then enable all dynamic RTEMS debug
   *  capabilities.
   *
   *  NOTE: Most debug features are conditionally compiled in
   *        or enabled via configure time plugins.
   */
  #ifdef RTEMS_DEBUG
    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
  #endif

  /*
   *  Let RTEMS perform initialization it requires before drivers
   *  are allowed to be initialized.
   */
  rtems_initialize_before_drivers();

  /*
   *  Execute BSP specific pre-driver hook. Drivers haven't gotten
   *  to initialize yet so this is a good chance to initialize
   *  buses, spurious interrupt handlers, etc..
   *
   *  NOTE: Many BSPs do not require this handler and use the
   *        shared stub.
   */
  bsp_predriver_hook();

  /*
   *  Initialize all device drivers.
   */
  rtems_initialize_device_drivers();

  /*
   *  Invoke the postdriver hook.  This normally opens /dev/console
   *  for use as stdin, stdout, and stderr.
   */
  bsp_postdriver_hook();

  /*
   *  Complete initialization of RTEMS and switch to the first task.
   *  Global C++ constructors will be executed in the context of that task.
   */
  rtems_initialize_start_multitasking();

  /***************************************************************
   ***************************************************************
   *  APPLICATION RUNS NOW!!!  We will not return to here!!!     *
   ***************************************************************
   ***************************************************************/
}
Beispiel #12
0
void Screen12()
{
  void                   *segment_address_1;
  void                   *segment_address_2;
  void                   *segment_address_3;
  uint32_t                good_back_flag;
  uint32_t                good_front_flag;
  uint32_t                offset;
  uintptr_t               segment_size;
  rtems_status_code       status;
  Heap_Information_block  the_info;

  /* Check invalid name error case */
  status = rtems_region_create(
    0,
    Region_good_area,
    0x40,
    32,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_region_create with illegal name"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_NAME" );

  /* Check NULL starting address error case */
  status = rtems_region_create(
    Region_name[ 1 ],
    NULL,
    0x40,
    32,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_create with NULL address"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );

#if defined(_C3x) || defined(_C4x)
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS - SKIPPED" );
#else
  status = rtems_region_create(
    Region_name[ 1 ],
    Region_bad_area,
    0x40,
    32,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_create with illegal address"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );
#endif

#if defined(_C3x) || defined(_C4x)
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_SIZE - SKIPPED" );
#else
  status = rtems_region_create(
    Region_name[ 1 ],
    Region_good_area,
    34,
    34,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_SIZE,
    "rtems_region_create with illegal size"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_SIZE" );
#endif

  /* Check NULL id error case */
  status = rtems_region_create(
    Region_name[ 1 ],
    Region_good_area,
    REGION_LENGTH,
    0x40,
    RTEMS_DEFAULT_ATTRIBUTES,
    NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_create with NULL id"
  );
  puts( "TA1 - rtems_region_create - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_create(
    Region_name[ 1 ],
    &Region_good_area[ REGION_START_OFFSET ],
    REGION_LENGTH,
    0x40,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Region_id[ 1 ]
  );
  directive_failed( status, "rtems_region_create" );
  puts( "TA1 - rtems_region_create - RTEMS_SUCCESSFUL" );

  /* extend NULL address */
  status = rtems_region_extend(
    Region_id[ 1 ],
    NULL,
    REGION_LENGTH - 1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_extend with NULL"
  );
  puts( "TA1 - rtems_region_extend - NULL address - RTEMS_INVALID_ADDRESS" );

  /* extend within heap */
  status = rtems_region_extend(
    Region_id[ 1 ],
    &Region_good_area[ REGION_START_OFFSET ],
    REGION_LENGTH - 1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_extend with address in heap"
  );
  puts( "TA1 - rtems_region_extend - address within - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_create(
    Region_name[ 1 ],
    Region_good_area,
    REGION_LENGTH,
    0x40,
    RTEMS_DEFAULT_ATTRIBUTES,
    &Junk_id
  );
  fatal_directive_status(
    status,
    RTEMS_TOO_MANY,
    "rtems_region_create of too many"
  );
  puts( "TA1 - rtems_region_create - RTEMS_TOO_MANY" );

  status = rtems_region_delete( 100 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_delete with illegal id"
  );
  puts( "TA1 - rtems_region_delete - unknown RTEMS_INVALID_ID" );

  status = rtems_region_delete( rtems_build_id( 1, 1, 1, 256 ) );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_delete with illegal id"
  );
  puts( "TA1 - rtems_region_delete - local RTEMS_INVALID_ID" );

  status = rtems_region_ident( 0, &Junk_id );
  fatal_directive_status(
    status,
    RTEMS_INVALID_NAME,
    "rtems_region_ident with illegal name"
  );
  puts( "TA1 - rtems_region_ident - RTEMS_INVALID_NAME" );

  /* Check get_information errors */
  status = rtems_region_get_information( Region_id[ 1 ], NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_information with NULL information"
  );
  puts( "TA1 - rtems_region_get_information - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_information( 100, &the_info );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_information with illegal id"
  );
  puts( "TA1 - rtems_region_get_information - unknown RTEMS_INVALID_ID" );

  /* Check get_free_information errors */
  status = rtems_region_get_free_information( Region_id[ 1 ], NULL );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_free_information with NULL information"
  );
  puts( "TA1 - rtems_region_get_free_information - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_free_information( 100, &the_info );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_free_information with illegal id"
  );
  puts( "TA1 - rtems_region_get_free_information - unknown RTEMS_INVALID_ID" );

  /* get segment illegal id */
  status = rtems_region_get_segment(
    100,
    0x40,
    RTEMS_DEFAULT_OPTIONS,
    RTEMS_NO_TIMEOUT,
    &segment_address_1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_segment with illegal id"
  );
  puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ID" );

  /* get_segment with NULL param */
  status = rtems_region_get_segment(
     Region_id[ 1 ],
     2,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_segment with NULL param"
  );
  puts( "TA1 - rtems_region_get_segment - RTEMS_INVALID_ADDRESS" );

  /* get_segment with illegal 0 size */
  status = rtems_region_get_segment(
     Region_id[ 1 ],
     0,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     &segment_address_1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_SIZE,
    "rtems_region_get_segment with 0 size"
  );
  puts( "TA1 - rtems_region_get_segment - 0 size - RTEMS_INVALID_SIZE" );

  /* get_segment with illegal big size */
  status = rtems_region_get_segment(
     Region_id[ 1 ],
     sizeof( Region_good_area ) * 2,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     &segment_address_1
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_SIZE,
    "rtems_region_get_segment with big size"
  );
  puts( "TA1 - rtems_region_get_segment - too big - RTEMS_INVALID_SIZE" );

  status = rtems_region_get_segment(
     Region_id[ 1 ],
     384,
     RTEMS_DEFAULT_OPTIONS,
     RTEMS_NO_TIMEOUT,
     &segment_address_1
  );
  directive_failed( status, "rtems_region_get_segment" );
  puts( "TA1 - rtems_region_get_segment - RTEMS_SUCCESSFUL" );

  status = rtems_region_get_segment(
     Region_id[ 1 ],
     REGION_LENGTH / 2,
     RTEMS_NO_WAIT,
     RTEMS_NO_TIMEOUT,
     &segment_address_2
  );
  fatal_directive_status(
    status,
    RTEMS_UNSATISFIED,
    "rtems_region_get_segment unsatisfied"
  );
  puts( "TA1 - rtems_region_get_segment - RTEMS_UNSATISFIED" );

  puts( "TA1 - rtems_region_get_segment - timeout in 3 seconds" );
  status = rtems_region_get_segment(
    Region_id[ 1 ],
    128,
    RTEMS_DEFAULT_OPTIONS,
    3 * rtems_clock_get_ticks_per_second(),
    &segment_address_3
  );
  fatal_directive_status(
    status,
    RTEMS_TIMEOUT,
    "rtems_region_get_segment timeout"
  );
  puts( "TA1 - rtems_region_get_segment - woke up with RTEMS_TIMEOUT" );

  /* Check get_segment_size errors */
  status = rtems_region_get_segment_size( Region_id[ 1 ], NULL, &segment_size );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_segment_size with NULL segment"
  );
  puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_segment_size(
    Region_id[ 1 ], segment_address_1, NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_get_segment_size with NULL size"
  );
  puts( "TA1 - rtems_region_get_segment_size - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_get_segment_size(
    100, segment_address_1, &segment_size
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_get_segment_size with illegal id"
  );
  puts( "TA1 - rtems_region_get_segment_size - unknown RTEMS_INVALID_ID" );

  status = rtems_region_delete( Region_id[ 1 ] );
  fatal_directive_status(
    status,
    RTEMS_RESOURCE_IN_USE,
    "rtems_region_delete with buffers in use"
  );
  puts( "TA1 - rtems_region_delete - RTEMS_RESOURCE_IN_USE" );

  /* Check resize_segment errors */
  status = rtems_region_resize_segment(
    Region_id[ 1 ], segment_address_3, 256, NULL
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_resize_segment with NULL old size"
  );
  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_resize_segment(
    Region_id[ 1 ], NULL, 256, &segment_size
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_resize_segment with NULL segment"
  );
  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_resize_segment(
    100, segment_address_3, 256, &segment_size
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_resize_segment with illegal id"
  );
  puts( "TA1 - rtems_region_resize_segment - RTEMS_INVALID_ID" );

  /* Check return_segment errors */
  status = rtems_region_return_segment( 100, segment_address_1 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_return_segment with illegal id"
  );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ID" );

  status = rtems_region_return_segment( Region_id[ 1 ], Region_good_area );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_return_segment with illegal segment"
  );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );

/*
 *  The following generate internal heap errors.  Thus this code
 *  is subject to change if the heap code changes.
 */

  puts( "TA1 - rtems_debug_disable - RTEMS_DEBUG_REGION" );
  rtems_debug_disable( RTEMS_DEBUG_REGION );

#if 0

  offset = (segment_address_1 - (void *)Region_good_area) / 4;

/* bad FRONT_FLAG error */

  good_front_flag = Region_good_area[ offset - 1 ];
  Region_good_area[ offset - 1 ] = good_front_flag + 2;

  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_1 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_return_segment with back_flag != front_flag"
  );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );

  Region_good_area[ offset - 1 ] = good_front_flag;

/* bad FRONT_FLAG error */

  good_back_flag = Region_good_area[ offset - 2 ];
  Region_good_area[ offset - 2 ] = 1024;

  status = rtems_region_return_segment( Region_id[ 1 ], segment_address_1 );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_return_segment with back_flag != front_flag"
  );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS" );

  Region_good_area[ offset - 2 ] = good_back_flag;

#else
  offset = 0;
  good_front_flag = 0;
  good_back_flag = 0;
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS - SKIPPED" );
  puts( "TA1 - rtems_region_return_segment - RTEMS_INVALID_ADDRESS - SKIPPED" );
#endif

  puts( "TA1 - rtems_debug_enable - RTEMS_DEBUG_REGION" );
  rtems_debug_enable( RTEMS_DEBUG_REGION );

  status = rtems_region_extend(
    100,
    Region_good_area,
    128
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ID,
    "rtems_region_extend with illegal id"
  );
  puts( "TA1 - rtems_region_extend - RTEMS_INVALID_ID" );

  status = rtems_region_extend(
    Region_id[ 1 ],
    &Region_good_area[ REGION_START_OFFSET + 16 ],
    128
  );
  fatal_directive_status(
    status,
    RTEMS_INVALID_ADDRESS,
    "rtems_region_extend with illegal starting address"
  );
  puts( "TA1 - rtems_region_extend - within heap - RTEMS_INVALID_ADDRESS" );

  status = rtems_region_extend(
    Region_id[ 1 ],
    Region_bad_area,
    128
  );
  fatal_directive_status(
    status,
    RTEMS_NOT_IMPLEMENTED,
    "rtems_region_extend with unsupported starting address"
  );
  puts(
    "TA1 - rtems_region_extend - non-contiguous lower - RTEMS_NOT_IMPLEMENTED"
  );

  status = rtems_region_extend(
    Region_id[ 1 ],
    &Region_good_area[ REGION_START_OFFSET - REGION_LENGTH ],
    128
  );
  fatal_directive_status(
    status,
    RTEMS_NOT_IMPLEMENTED,
    "rtems_region_extend with unsupported starting address"
  );
  puts(
    "TA1 - rtems_region_extend - contiguous lower - RTEMS_NOT_IMPLEMENTED"
  );

  status = rtems_region_extend(
    Region_id[ 1 ],
    &Region_good_area[ REGION_START_OFFSET + REGION_LENGTH + 16 ],
    128
  );
  fatal_directive_status(
    status,
    RTEMS_NOT_IMPLEMENTED,
    "rtems_region_extend with unsupported starting address"
  );
  puts(
    "TA1 - rtems_region_extend - non-contiguous higher - RTEMS_NOT_IMPLEMENTED"
  );

}