1 | /*
|
---|
2 | * Copyright (c) 2010 Jakub Jermar
|
---|
3 | * Copyright (c) 2013 Jakub Klama
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup sparc32
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 | /** @file
|
---|
34 | */
|
---|
35 |
|
---|
36 | #include <stacktrace.h>
|
---|
37 | #include <syscall/copy.h>
|
---|
38 | #include <typedefs.h>
|
---|
39 | #include <arch.h>
|
---|
40 | #include <arch/stack.h>
|
---|
41 | #include <proc/thread.h>
|
---|
42 |
|
---|
43 | #define FRAME_OFFSET_FP_PREV 14
|
---|
44 | #define FRAME_OFFSET_RA 15
|
---|
45 |
|
---|
46 | static void alloc_window_and_flush(void)
|
---|
47 | {
|
---|
48 | // FIXME TODO
|
---|
49 | }
|
---|
50 |
|
---|
51 | bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
|
---|
52 | {
|
---|
53 | uintptr_t kstack;
|
---|
54 | uint32_t l1;
|
---|
55 | uint32_t l2;
|
---|
56 |
|
---|
57 | read_from_invalid(&kstack, &l1, &l2);
|
---|
58 | kstack -= 128;
|
---|
59 |
|
---|
60 | if ((THREAD) && (ctx->fp == kstack))
|
---|
61 | return false;
|
---|
62 |
|
---|
63 | return (ctx->fp != 0);
|
---|
64 | }
|
---|
65 |
|
---|
66 | bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
|
---|
67 | {
|
---|
68 | uint32_t *stack = (void *) ctx->fp;
|
---|
69 | alloc_window_and_flush();
|
---|
70 | *prev = stack[FRAME_OFFSET_FP_PREV];
|
---|
71 | return true;
|
---|
72 | }
|
---|
73 |
|
---|
74 | bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
|
---|
75 | {
|
---|
76 | uint32_t *stack = (void *) ctx->fp;
|
---|
77 | alloc_window_and_flush();
|
---|
78 | *ra = stack[FRAME_OFFSET_RA];
|
---|
79 | return true;
|
---|
80 | }
|
---|
81 |
|
---|
82 | bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx)
|
---|
83 | {
|
---|
84 | return false;
|
---|
85 | }
|
---|
86 |
|
---|
87 | bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
|
---|
88 | {
|
---|
89 | return false;
|
---|
90 | }
|
---|
91 |
|
---|
92 | bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra)
|
---|
93 | {
|
---|
94 | return false;
|
---|
95 | }
|
---|
96 |
|
---|
97 | uintptr_t frame_pointer_get(void)
|
---|
98 | {
|
---|
99 | // FIXME TODO
|
---|
100 | return 0;
|
---|
101 | }
|
---|
102 |
|
---|
103 | uintptr_t program_counter_get(void)
|
---|
104 | {
|
---|
105 | // FIXME TODO
|
---|
106 | return 0;
|
---|
107 | }
|
---|
108 |
|
---|
109 | /** @}
|
---|
110 | */
|
---|