source: rtems/testsuites/libtests/stackchk/blow.c @ e4a19f5

Last change on this file since e4a19f5 was eaa5ea84, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 20, 2018 at 3:22:56 PM

score: Introduce <rtems/score/heapinfo.h>

Move Heap_Information_block to separate header file to hide heap
implementation details from <rtems.h>.

Update #3598.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*  task1.c
2 *
3 *  This set of three tasks do some simple task switching for about
4 *  15 seconds and then call a routine to "blow the stack".
5 *
6 *  COPYRIGHT (c) 1989-2012.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems.h>
19#include <rtems/stackchk.h>
20#include <rtems/score/heap.h>
21#include <rtems/score/percpu.h>
22
23/* forward declarations to avoid warnings */
24void b(void);
25void blow_stack(void);
26
27void b(void)
28{
29}
30
31void blow_stack(void)
32{
33  volatile uint32_t   *low, *high;
34  unsigned char *area;
35  Thread_Control *executing;
36
37  b();
38
39  /*
40   *  Destroy the first and last 16 bytes of our stack... Hope it
41   *  does not cause problems :)
42   */
43
44  executing = _Thread_Get_executing();
45  area = (unsigned char *)executing->Start.Initial_stack.area;
46
47  /* Look in the stack checker implementation for this magic offset */
48  low  = (volatile uint32_t *) \
49     (area + sizeof(Heap_Block) - HEAP_BLOCK_HEADER_SIZE);
50  high = (volatile uint32_t *)
51             (area + executing->Start.Initial_stack.size - 16);
52
53  low[0] = 0x11111111;
54  low[1] = 0x22222222;
55  low[2] = 0x33333333;
56  low[3] = 0x44444444;
57
58  high[0] = 0x55555555;
59  high[1] = 0x66666666;
60  high[2] = 0x77777777;
61  high[3] = 0x88888888;
62  rtems_stack_checker_report_usage();
63}
Note: See TracBrowser for help on using the repository browser.