The Pedigree Project  0.1
armv7/StackFrame.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #if defined(DEBUGGER)
21 
22 #include "pedigree/kernel/processor/StackFrame.h"
23 
24 uintptr_t ARMV7StackFrame::getParameter(size_t n)
25 {
27  return 0;
28 }
29 
31  ProcessorState &state, uintptr_t returnAddress, unsigned int nParams, ...)
32 {
33  // Obtain the stack pointer.
34  uintptr_t *pStack = reinterpret_cast<uintptr_t *>(state.getStackPointer());
35 
36  // How many parameters do we need to push?
37  // We push in reverse order but must iterate through the va_list in forward
38  // order, so we decrement the stack pointer here.
39  pStack -= nParams + 1; // +1 for return address.
40  uintptr_t *pStackLowWaterMark = pStack;
41 
42  *pStack++ = returnAddress;
43 
44  va_list list;
45  va_start(list, nParams);
46 
47  for (int i = nParams - 1; i >= 0; i--)
48  {
49  *pStack++ = va_arg(list, uintptr_t);
50  }
51 
52  va_end(list);
53 
54  // Write the new stack pointer back.
55  state.setStackPointer(reinterpret_cast<uintptr_t>(pStackLowWaterMark));
56 }
57 
58 #endif
static void construct(ProcessorState &state, uintptr_t returnAddress, unsigned int nParams,...)
virtual uintptr_t getParameter(size_t n)