blob: 05e797510a027548d8e88b01e58f3314b0524c0a [file] [log] [blame]
Ronald G. Minnich9764d4c2012-06-12 16:29:32 -07001/*
2This software and ancillary information (herein called SOFTWARE )
3called LinuxBIOS is made available under the terms described
4here. The SOFTWARE has been approved for release with associated
5LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
6been authored by an employee or employees of the University of
7California, operator of the Los Alamos National Laboratory under
8Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
9U.S. Government has rights to use, reproduce, and distribute this
10SOFTWARE. The public may copy, distribute, prepare derivative works
11and publicly display this SOFTWARE without charge, provided that this
12Notice and any statement of authorship are reproduced on all copies.
13Neither the Government nor the University makes any warranty, express
14or implied, or assumes any liability or responsibility for the use of
15this SOFTWARE. If SOFTWARE is modified to produce derivative works,
16such modified SOFTWARE should be clearly marked, so as not to confuse
17it with the version available from LANL.
18 */
19/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
20 * rminnich@lanl.gov
21 */
22
23#include <lib.h>
24#include <console/console.h>
25
26int checkstack(void *top_of_stack, int core)
27{
28 int i;
29 u32 *stack = (u32 *) (top_of_stack - CONFIG_STACK_SIZE);
30
31 if (stack[0] != 0xDEADBEEF){
Stefan Reinauer1b54cc92013-11-13 15:41:13 -080032 printk(BIOS_ERR, "Stack overrun on CPU%d. "
Ronald G. Minnich9764d4c2012-06-12 16:29:32 -070033 "Increase stack from current %d bytes\n",
David Hendricks9a000162013-02-11 19:05:36 -080034 core, CONFIG_STACK_SIZE);
Ronald G. Minnich9764d4c2012-06-12 16:29:32 -070035 return -1;
36 }
37
Stefan Reinauer75dbc382012-10-15 15:19:43 -070038 for(i = 1; i < CONFIG_STACK_SIZE/sizeof(stack[0]); i++){
Ronald G. Minnich9764d4c2012-06-12 16:29:32 -070039 if (stack[i] == 0xDEADBEEF)
40 continue;
Stefan Reinauer75dbc382012-10-15 15:19:43 -070041 printk(BIOS_SPEW, "CPU%d: stack: %p - %p, ",
42 core, stack,
Ronald G. Minnich9764d4c2012-06-12 16:29:32 -070043 &stack[CONFIG_STACK_SIZE/sizeof(stack[0])]);
Stefan Reinauer75dbc382012-10-15 15:19:43 -070044 printk(BIOS_SPEW, "lowest used address %p, ", &stack[i]);
45 printk(BIOS_SPEW, "stack used: %ld bytes\n",
46 (unsigned long)&stack[CONFIG_STACK_SIZE /
47 sizeof(stack[0])] - (unsigned long)&stack[i]);
48 return 0;
Ronald G. Minnich9764d4c2012-06-12 16:29:32 -070049 }
50
51 return 0;
52
53}