riscv64: Fill in more bulk architecture items around libroot/kernel

Change-Id: Ia2a86d8814d06950ea2d2d19d966c642d26f81d6
Reviewed-on: https://review.haiku-os.org/c/1302
Reviewed-by: Alex von Gluck IV <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Alexander von Gluck IV
2019-03-25 17:16:03 +00:00
committed by Alex von Gluck IV
parent 7f94422796
commit c085f38639
34 changed files with 1847 additions and 5 deletions
@@ -0,0 +1,52 @@
/*
* Copyright 2005, Ingo Weinhold, [email protected].
* Copyright 2012, Alex Smith, [email protected].
* Distributed under the terms of the MIT License.
*/
#include <debug_support.h>
#include "arch_debug_support.h"
struct stack_frame {
struct stack_frame *previous;
void *return_address;
};
status_t
arch_debug_get_instruction_pointer(debug_context *context, thread_id thread,
void **ip, void **stackFrameAddress)
{
// get the CPU state
debug_cpu_state cpuState;
status_t error = debug_get_cpu_state(context, thread, NULL, &cpuState);
if (error != B_OK)
return error;
*ip = (void*)cpuState.rip;
*stackFrameAddress = (void*)cpuState.rbp;
return B_OK;
}
status_t
arch_debug_get_stack_frame(debug_context *context, void *stackFrameAddress,
debug_stack_frame_info *stackFrameInfo)
{
stack_frame stackFrame;
ssize_t bytesRead = debug_read_memory(context, stackFrameAddress,
&stackFrame, sizeof(stackFrame));
if (bytesRead < B_OK)
return bytesRead;
if (bytesRead != sizeof(stackFrame))
return B_ERROR;
stackFrameInfo->frame = stackFrameAddress;
stackFrameInfo->parent_frame = stackFrame.previous;
stackFrameInfo->return_address = stackFrame.return_address;
return B_OK;
}