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  *  COPYRIGHT (c) 1989-2011.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include "system.h"
0034 
0035 rtems_task Task_1(
0036   rtems_task_argument argument
0037 )
0038 {
0039   void                   *address_1;
0040   void                   *address_2;
0041   void                   *address_3;
0042   void                   *address_4;
0043   void                   *address_5;
0044   void                   *address_6;
0045   void                   *address_7;
0046   void                   *address_8;
0047   rtems_id                region_id;
0048   Heap_Information_block  region_info;
0049   uintptr_t               segment_size;
0050   rtems_status_code       status;
0051 
0052   /* Obtain the region id */
0053   status = rtems_region_ident(Region_name[ 1 ], &region_id);
0054   printf( "TA1 - rtems_region_ident - 0x%08" PRIxrtems_id "\n", region_id );
0055   directive_failed(status, "rtems_region_ident of RN01");
0056 
0057   /* Get a 64 byte segment from the region */
0058   puts(
0059     "TA1 - rtems_region_get_segment - wait on 64 byte segment from region 1"
0060   );
0061   rtems_region_get_segment(
0062     Region_id[ 1 ],
0063     64,
0064     RTEMS_DEFAULT_OPTIONS,
0065     RTEMS_NO_TIMEOUT,
0066     &address_1
0067   );
0068   directive_failed( status, "rtems_region_get_segment" );
0069   puts_nocr( "TA1 - got segment from region 1 - " );
0070   Put_address_from_area_1( address_1 );
0071   new_line;
0072 
0073   /* Get the size of segment_1 */
0074   puts_nocr( "TA1 - rtems_region_get_segment_size from - " );
0075   Put_address_from_area_1( address_1 );
0076   new_line;
0077   status = rtems_region_get_segment_size(region_id, address_1, &segment_size);
0078   directive_failed(status, "rtems_region_get_segment_size of segment 1");
0079   printf( "TA1 - got segment size of %" PRIuPTR "\n", segment_size );
0080 
0081   /* Get a 128 byte segment from the region */
0082   puts(
0083     "TA1 - rtems_region_get_segment - wait on 128 byte segment from region 1"
0084   );
0085   rtems_region_get_segment(
0086     Region_id[ 1 ],
0087     128,
0088     RTEMS_DEFAULT_OPTIONS,
0089     RTEMS_NO_TIMEOUT,
0090     &address_2
0091   );
0092   directive_failed( status, "rtems_region_get_segment" );
0093   puts_nocr( "TA1 - got segment from region 1 - " );
0094   Put_address_from_area_1( address_2 );
0095   new_line;
0096 
0097   /* Get a 256 byte segment from the region */
0098   puts(
0099     "TA1 - rtems_region_get_segment - wait on 256 byte segment from region 1"
0100   );
0101   rtems_region_get_segment(
0102     Region_id[ 1 ],
0103     256,
0104     RTEMS_DEFAULT_OPTIONS,
0105     RTEMS_NO_TIMEOUT,
0106     &address_3
0107   );
0108   directive_failed( status, "rtems_region_get_segment" );
0109   puts_nocr( "TA1 - got segment from region 1 - " );
0110   Put_address_from_area_1( address_3 );
0111   new_line;
0112 
0113   /* Get a 512 byte segment from the region */
0114   puts(
0115     "TA1 - rtems_region_get_segment - wait on 512 byte segment from region 1"
0116   );
0117   rtems_region_get_segment(
0118     Region_id[ 1 ],
0119     512,
0120     RTEMS_DEFAULT_OPTIONS,
0121     RTEMS_NO_TIMEOUT,
0122     &address_4
0123   );
0124   directive_failed( status, "rtems_region_get_segment" );
0125   puts_nocr( "TA1 - got segment from region 1 - " );
0126   Put_address_from_area_1( address_4 );
0127   new_line;
0128 
0129   /* Get a 1024 byte segment from the region */
0130   puts(
0131     "TA1 - rtems_region_get_segment - wait on 1024 byte segment from region 1"
0132   );
0133   rtems_region_get_segment(
0134     Region_id[ 1 ],
0135     1024,
0136     RTEMS_DEFAULT_OPTIONS,
0137     RTEMS_NO_TIMEOUT,
0138     &address_5
0139   );
0140   directive_failed( status, "rtems_region_get_segment" );
0141   puts_nocr( "TA1 - got segment from region 1 - " );
0142   Put_address_from_area_1( address_5 );
0143   new_line;
0144 
0145   /* Get a 2048 byte segment from the region */
0146   puts(
0147     "TA1 - rtems_region_get_segment - wait on 2048 byte segment from region 1"
0148   );
0149   rtems_region_get_segment(
0150     Region_id[ 1 ],
0151     2048,
0152     RTEMS_DEFAULT_OPTIONS,
0153     RTEMS_NO_TIMEOUT,
0154     &address_6
0155   );
0156   directive_failed( status, "rtems_region_get_segment" );
0157   puts_nocr( "TA1 - got segment from region 1 - " );
0158   Put_address_from_area_1( address_6 );
0159   new_line;
0160 
0161   /* Get a 4096 byte segment from the region */
0162   puts(
0163     "TA1 - rtems_region_get_segment - wait on 4096 byte segment from region 1"
0164   );
0165   rtems_region_get_segment(
0166     Region_id[ 1 ],
0167     4096,
0168     RTEMS_DEFAULT_OPTIONS,
0169     RTEMS_NO_TIMEOUT,
0170     &address_7
0171   );
0172   directive_failed( status, "rtems_region_get_segment" );
0173   puts_nocr( "TA1 - got segment from region 1 - " );
0174   Put_address_from_area_1( address_7 );
0175   new_line;
0176 
0177   /* Get a 8192 byte segment from the region */
0178   puts(
0179     "TA1 - rtems_region_get_segment - wait on 8192 byte segment from region 1"
0180   );
0181   rtems_region_get_segment(
0182     Region_id[ 1 ],
0183     8192,
0184     RTEMS_DEFAULT_OPTIONS,
0185     RTEMS_NO_TIMEOUT,
0186     &address_8
0187   );
0188   directive_failed( status, "rtems_region_get_segment" );
0189   puts_nocr( "TA1 - got segment from region 1 - " );
0190   Put_address_from_area_1( address_8 );
0191   new_line;
0192 
0193   /* Get the size of segment_8 */
0194   puts_nocr( "TA1 - rtems_region_get_segment_size from - " );
0195   Put_address_from_area_1( address_8 );
0196   new_line;
0197   status = rtems_region_get_segment_size(region_id, address_8, &segment_size);
0198   directive_failed(status, "rtems_region_get_segment_size of segment 8");
0199   printf( "TA1 - got segment size of %" PRIuPTR "\n", segment_size );
0200 
0201   /* Get information about the region */
0202   printf(
0203     "TA1 - rtems_region_get_information - 0x%08" PRIxrtems_id "\n",
0204     region_id
0205   );
0206   status = rtems_region_get_information(region_id, &region_info);
0207   directive_failed(status, "rtems_region_get_information of RN01");
0208   printf(
0209     "TA1 - got information - free = %" PRIuPTR ", used = %" PRIuPTR "\n",
0210     region_info.Free.number,
0211     region_info.Used.number
0212   );
0213 
0214   printf(
0215     "TA1 - rtems_region_get_free_information - 0x%08" PRIxrtems_id "\n",
0216     region_id
0217   );
0218   status = rtems_region_get_free_information(region_id, &region_info);
0219   directive_failed(status, "rtems_region_get_free_information of RN01");
0220   printf(
0221     "TA1 - got free information - free = %" PRIuPTR ", used = %" PRIuPTR "\n",
0222     region_info.Free.number,
0223     region_info.Used.number
0224   );
0225 
0226   puts_nocr(
0227     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0228   );
0229   Put_address_from_area_1( address_3 );
0230   status = rtems_region_return_segment( Region_id[ 1 ], address_3 );
0231   directive_failed( status, "rtems_region_return_segment" );
0232   new_line;
0233   address_3 = 0;
0234 
0235   puts_nocr(
0236     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0237   );
0238   Put_address_from_area_1( address_4 );
0239   status = rtems_region_return_segment( Region_id[ 1 ], address_4 );
0240   directive_failed( status, "rtems_region_return_segment" );
0241   new_line;
0242   address_4 = 0;
0243 
0244   puts_nocr(
0245     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0246   );
0247   Put_address_from_area_1( address_1 );
0248   status = rtems_region_return_segment( Region_id[ 1 ], address_1 );
0249   directive_failed( status, "rtems_region_return_segment" );
0250   new_line;
0251   address_1 = 0;
0252 
0253   puts_nocr(
0254     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0255   );
0256   Put_address_from_area_1( address_2 );
0257   status = rtems_region_return_segment( Region_id[ 1 ], address_2 );
0258   directive_failed( status, "rtems_region_return_segment" );
0259   new_line;
0260   address_2 = 0;
0261 
0262   puts_nocr(
0263     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0264   );
0265   Put_address_from_area_1( address_7 );
0266   status = rtems_region_return_segment( Region_id[ 1 ], address_7 );
0267   directive_failed( status, "rtems_region_return_segment" );
0268   new_line;
0269   address_7 = 0;
0270 
0271   puts_nocr(
0272     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0273   );
0274   Put_address_from_area_1( address_6 );
0275   status = rtems_region_return_segment( Region_id[ 1 ], address_6 );
0276   directive_failed( status, "rtems_region_return_segment" );
0277   new_line;
0278   address_6 = 0;
0279 
0280   puts_nocr(
0281     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0282   );
0283   Put_address_from_area_1( address_8 );
0284   status = rtems_region_return_segment( Region_id[ 1 ], address_8 );
0285   directive_failed( status, "rtems_region_return_segment" );
0286   new_line;
0287   address_8 = 0;
0288 
0289   puts_nocr(
0290     "TA1 - rtems_region_return_segment - return segment to region 1 - "
0291   );
0292   Put_address_from_area_1( address_5 );
0293   status = rtems_region_return_segment( Region_id[ 1 ], address_5 );
0294   directive_failed( status, "rtems_region_return_segment" );
0295   new_line;
0296   address_5 = 0;
0297 
0298   puts( "TA1 - rtems_region_delete - walks heap if debug enabled" );
0299   rtems_region_delete(Region_id[ 1 ]);
0300 
0301   TEST_END();
0302   rtems_test_exit( 0 );
0303 }