[b6b02c0] | 1 | /*
|
---|
| 2 | * Copyright (c) 2010 Jakub Jermar
|
---|
[382fb4ba] | 3 | * Copyright (c) 2013 Jakub Klama
|
---|
[b6b02c0] | 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 |
|
---|
[382fb4ba] | 30 | /** @addtogroup sparc32
|
---|
[b6b02c0] | 31 | * @{
|
---|
| 32 | */
|
---|
| 33 | /** @file
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | #include <stacktrace.h>
|
---|
| 37 | #include <syscall/copy.h>
|
---|
| 38 | #include <typedefs.h>
|
---|
[382fb4ba] | 39 | #include <arch.h>
|
---|
| 40 | #include <arch/stack.h>
|
---|
[e8f3637] | 41 | #include <proc/thread.h>
|
---|
[382fb4ba] | 42 |
|
---|
[32e8cd1] | 43 | #define FRAME_OFFSET_FP_PREV 14
|
---|
| 44 | #define FRAME_OFFSET_RA 15
|
---|
[382fb4ba] | 45 |
|
---|
[32e8cd1] | 46 | static void alloc_window_and_flush(void)
|
---|
| 47 | {
|
---|
| 48 | // FIXME TODO
|
---|
| 49 | }
|
---|
[382fb4ba] | 50 |
|
---|
[b6b02c0] | 51 | bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
|
---|
| 52 | {
|
---|
[382fb4ba] | 53 | uintptr_t kstack;
|
---|
[d18ad61] | 54 | uint32_t l1;
|
---|
[32e8cd1] | 55 | uint32_t l2;
|
---|
[382fb4ba] | 56 |
|
---|
[32e8cd1] | 57 | read_from_invalid(&kstack, &l1, &l2);
|
---|
[382fb4ba] | 58 | kstack -= 128;
|
---|
[32e8cd1] | 59 |
|
---|
| 60 | if ((THREAD) && (ctx->fp == kstack))
|
---|
[382fb4ba] | 61 | return false;
|
---|
[32e8cd1] | 62 |
|
---|
| 63 | return (ctx->fp != 0);
|
---|
[b6b02c0] | 64 | }
|
---|
| 65 |
|
---|
| 66 | bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
|
---|
| 67 | {
|
---|
[208b5f5] | 68 | uint32_t *stack = (void *) ctx->fp;
|
---|
[382fb4ba] | 69 | alloc_window_and_flush();
|
---|
| 70 | *prev = stack[FRAME_OFFSET_FP_PREV];
|
---|
[b6b02c0] | 71 | return true;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
|
---|
| 75 | {
|
---|
[208b5f5] | 76 | uint32_t *stack = (void *) ctx->fp;
|
---|
[382fb4ba] | 77 | alloc_window_and_flush();
|
---|
| 78 | *ra = stack[FRAME_OFFSET_RA];
|
---|
[b6b02c0] | 79 | return true;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx)
|
---|
| 83 | {
|
---|
[382fb4ba] | 84 | return false;
|
---|
[b6b02c0] | 85 | }
|
---|
| 86 |
|
---|
| 87 | bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
|
---|
| 88 | {
|
---|
[382fb4ba] | 89 | return false;
|
---|
[b6b02c0] | 90 | }
|
---|
| 91 |
|
---|
[382fb4ba] | 92 | bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra)
|
---|
[b6b02c0] | 93 | {
|
---|
[382fb4ba] | 94 | return false;
|
---|
[b6b02c0] | 95 | }
|
---|
| 96 |
|
---|
[ceb5757] | 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 |
|
---|
[b6b02c0] | 109 | /** @}
|
---|
| 110 | */
|
---|