mainboard: Clean up boot_option/reboot_bits in cmos.layout
[coreboot.git] / src / lib / stack.c
blobbebeea2c61a81de8b2afecdd80e5da3e73efa24b
1 /*
2 This software and ancillary information (herein called SOFTWARE )
3 called LinuxBIOS is made available under the terms described
4 here. The SOFTWARE has been approved for release with associated
5 LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
6 been authored by an employee or employees of the University of
7 California, operator of the Los Alamos National Laboratory under
8 Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
9 U.S. Government has rights to use, reproduce, and distribute this
10 SOFTWARE. The public may copy, distribute, prepare derivative works
11 and publicly display this SOFTWARE without charge, provided that this
12 Notice and any statement of authorship are reproduced on all copies.
13 Neither the Government nor the University makes any warranty, express
14 or implied, or assumes any liability or responsibility for the use of
15 this SOFTWARE. If SOFTWARE is modified to produce derivative works,
16 such modified SOFTWARE should be clearly marked, so as not to confuse
17 it with the version available from LANL.
19 /* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
20 * rminnich@lanl.gov
21 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
24 #include <assert.h>
25 #include <lib.h>
26 #include <console/console.h>
27 #include <symbols.h>
29 int checkstack(void *top_of_stack, int core)
31 /* Not all archs use CONFIG_STACK_SIZE, those who don't set it to 0. */
32 size_t stack_size = CONFIG_STACK_SIZE ? CONFIG_STACK_SIZE : _stack_size;
33 int i;
34 u32 *stack = (u32 *) (top_of_stack - stack_size);
36 if (stack[0] != 0xDEADBEEF){
37 printk(BIOS_ERR, "Stack overrun on CPU%d (address %p overwritten). "
38 "Increase stack from current %zu bytes\n",
39 core, stack, stack_size);
40 BUG();
41 return -1;
44 for(i = 1; i < stack_size/sizeof(stack[0]); i++){
45 if (stack[i] == 0xDEADBEEF)
46 continue;
47 printk(BIOS_SPEW, "CPU%d: stack: %p - %p, ",
48 core, stack, &stack[stack_size/sizeof(stack[0])]);
49 printk(BIOS_SPEW, "lowest used address %p, ", &stack[i]);
50 printk(BIOS_SPEW, "stack used: %ld bytes\n",
51 (unsigned long)&stack[stack_size / sizeof(stack[0])]
52 - (unsigned long)&stack[i]);
53 return 0;
56 return 0;