1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /* task1.c |
---|
4 | * |
---|
5 | * This set of three tasks do some simple task switching for about |
---|
6 | * 15 seconds and then call a routine to "blow the stack". |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989-2012. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * Redistribution and use in source and binary forms, with or without |
---|
12 | * modification, are permitted provided that the following conditions |
---|
13 | * are met: |
---|
14 | * 1. Redistributions of source code must retain the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer. |
---|
16 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
17 | * notice, this list of conditions and the following disclaimer in the |
---|
18 | * documentation and/or other materials provided with the distribution. |
---|
19 | * |
---|
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
30 | * POSSIBILITY OF SUCH DAMAGE. |
---|
31 | */ |
---|
32 | |
---|
33 | #ifdef HAVE_CONFIG_H |
---|
34 | #include "config.h" |
---|
35 | #endif |
---|
36 | |
---|
37 | #include <rtems/stackchk.h> |
---|
38 | |
---|
39 | #include "system.h" |
---|
40 | |
---|
41 | void blow_stack(void) |
---|
42 | { |
---|
43 | Thread_Control *executing; |
---|
44 | char *area; |
---|
45 | volatile uintptr_t *low; |
---|
46 | volatile uintptr_t *high; |
---|
47 | |
---|
48 | executing = _Thread_Get_executing(); |
---|
49 | |
---|
50 | /* |
---|
51 | * Destroy the first and last 4 words of our stack area... Hope it |
---|
52 | * does not cause problems :) |
---|
53 | */ |
---|
54 | |
---|
55 | area = (char *) executing->Start.Initial_stack.area; |
---|
56 | low = (uintptr_t *) area; |
---|
57 | high = (uintptr_t *) |
---|
58 | (area + executing->Start.Initial_stack.size - 4 * sizeof(*high)); |
---|
59 | |
---|
60 | low[0] = 0x11111111; |
---|
61 | low[1] = 0x22222222; |
---|
62 | low[2] = 0x33333333; |
---|
63 | low[3] = 0x44444444; |
---|
64 | |
---|
65 | high[0] = 0x55555555; |
---|
66 | high[1] = 0x66666666; |
---|
67 | high[2] = 0x77777777; |
---|
68 | high[3] = 0x88888888; |
---|
69 | |
---|
70 | rtems_stack_checker_report_usage(); |
---|
71 | } |
---|