[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>
|
---|
| 41 |
|
---|
[32e8cd1] | 42 | #define FRAME_OFFSET_FP_PREV 14
|
---|
| 43 | #define FRAME_OFFSET_RA 15
|
---|
[382fb4ba] | 44 |
|
---|
[32e8cd1] | 45 | static void alloc_window_and_flush(void)
|
---|
| 46 | {
|
---|
| 47 | // FIXME TODO
|
---|
| 48 | }
|
---|
[382fb4ba] | 49 |
|
---|
[b6b02c0] | 50 | bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx)
|
---|
| 51 | {
|
---|
[382fb4ba] | 52 | uintptr_t kstack;
|
---|
[d18ad61] | 53 | uint32_t l1;
|
---|
[32e8cd1] | 54 | uint32_t l2;
|
---|
[382fb4ba] | 55 |
|
---|
[32e8cd1] | 56 | read_from_invalid(&kstack, &l1, &l2);
|
---|
[382fb4ba] | 57 | kstack -= 128;
|
---|
[32e8cd1] | 58 |
|
---|
| 59 | if ((THREAD) && (ctx->fp == kstack))
|
---|
[382fb4ba] | 60 | return false;
|
---|
[32e8cd1] | 61 |
|
---|
| 62 | return (ctx->fp != 0);
|
---|
[b6b02c0] | 63 | }
|
---|
| 64 |
|
---|
| 65 | bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
|
---|
| 66 | {
|
---|
[382fb4ba] | 67 | uint64_t *stack = (void *) ctx->fp;
|
---|
| 68 | alloc_window_and_flush();
|
---|
| 69 | *prev = stack[FRAME_OFFSET_FP_PREV];
|
---|
[b6b02c0] | 70 | return true;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra)
|
---|
| 74 | {
|
---|
[382fb4ba] | 75 | uint64_t *stack = (void *) ctx->fp;
|
---|
| 76 | alloc_window_and_flush();
|
---|
| 77 | *ra = stack[FRAME_OFFSET_RA];
|
---|
[b6b02c0] | 78 | return true;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx)
|
---|
| 82 | {
|
---|
[382fb4ba] | 83 | return false;
|
---|
[b6b02c0] | 84 | }
|
---|
| 85 |
|
---|
| 86 | bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev)
|
---|
| 87 | {
|
---|
[382fb4ba] | 88 | return false;
|
---|
[b6b02c0] | 89 | }
|
---|
| 90 |
|
---|
[382fb4ba] | 91 | bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra)
|
---|
[b6b02c0] | 92 | {
|
---|
[382fb4ba] | 93 | return false;
|
---|
[b6b02c0] | 94 | }
|
---|
| 95 |
|
---|
| 96 | /** @}
|
---|
| 97 | */
|
---|