MOS Source Code
Loading...
Searching...
No Matches
riscv64_platform_api.cpp File Reference
#include "mos/assert.hpp"
#include "mos/platform/platform.hpp"
#include "mos/platform/platform_defs.hpp"
#include "mos/riscv64/cpu/cpu.hpp"
#include "mos/syslog/syslog.hpp"
#include "mos/tasks/signal.hpp"
#include "mos/tasks/task_types.hpp"
#include <mos/platform_syscall.h>
#include <mos/shared_ptr.hpp>
#include <mos_stdlib.hpp>
Include dependency graph for riscv64_platform_api.cpp:

Go to the source code of this file.

Macros

#define FLEN   64
#define f_op(reg, val)
#define f_op(reg, val)

Typedefs

typedef void(* switch_func_t) ()

Functions

void riscv64_do_context_switch (ptr_t *old_stack, ptr_t new_stack, switch_func_t switcher, bool *lock)
void riscv64_normal_switch_impl ()
static void riscv64_start_user_thread ()
static void riscv64_start_kernel_thread ()
void platform_shutdown ()
u32 platform_current_cpu_id ()
void platform_cpu_idle ()
void platform_dump_regs (const platform_regs_t *regs)
platform_regs_tplatform_thread_regs (Thread *thread)
static void thread_setup_common (Thread *thread)
void platform_context_setup_main_thread (Thread *thread, ptr_t entry, ptr_t sp, int argc, ptr_t argv, ptr_t envp)
void platform_context_setup_child_thread (Thread *thread, thread_entry_t entry, void *arg)
void platform_context_clone (Thread *from, Thread *to)
void platform_context_cleanup (Thread *thread)
void platform_interrupt_disable ()
void platform_interrupt_enable ()
void platform_switch_mm (const MMContext *new_mm)
static void do_save_fp_context (Thread *thread)
void do_restore_fp_context (Thread *thread)
void platform_switch_to_thread (Thread *current, Thread *new_thread, ContextSwitchBehaviorFlags switch_flags)
void platform_return_to_userspace (platform_regs_t *regs)
u64 platform_arch_syscall (u64 syscall, u64 arg1, u64 arg2, u64 arg3, u64 arg4)
void platform_ipi_send (u8 target_cpu, ipi_type_t type)
void platform_dump_stack (const platform_regs_t *regs)
void platform_syscall_setup_restart_context (platform_regs_t *regs, reg_t syscall_nr)
void platform_syscall_store_retval (platform_regs_t *regs, reg_t result)
ptr< platform_regs_tplatform_setup_signal_handler_regs (const platform_regs_t *regs, const sigreturn_data_t *sigreturn_data, const sigaction_t *sa)
void platform_restore_from_signal_handler (void *sp)
u64 platform_get_timestamp ()
void platform_get_time (timeval_t *tv)
void platform_get_unix_timestamp (u64 *timestamp)
void platform_dump_current_stack ()

Macro Definition Documentation

◆ FLEN

#define FLEN   64

Definition at line 154 of file riscv64_platform_api.cpp.

◆ f_op [1/2]

#define f_op ( reg,
val )
Value:
__asm__ volatile("fld " #reg ", %0" : : "m"(thread->platform_options.f[val]))

Referenced by do_restore_fp_context(), and do_save_fp_context().

◆ f_op [2/2]

#define f_op ( reg,
val )
Value:
__asm__ volatile("fsd " #reg ", %0" : : "m"(thread->platform_options.f[val]))

Typedef Documentation

◆ switch_func_t

typedef void(* switch_func_t) ()

Definition at line 16 of file riscv64_platform_api.cpp.

Function Documentation

◆ riscv64_do_context_switch()

void riscv64_do_context_switch ( ptr_t * old_stack,
ptr_t new_stack,
switch_func_t switcher,
bool * lock )

◆ riscv64_normal_switch_impl()

void riscv64_normal_switch_impl ( )

◆ riscv64_start_user_thread()

void riscv64_start_user_thread ( )
static

Definition at line 20 of file riscv64_platform_api.cpp.

Referenced by platform_switch_to_thread().

Here is the call graph for this function:

◆ riscv64_start_kernel_thread()

void riscv64_start_kernel_thread ( )
static

Definition at line 35 of file riscv64_platform_api.cpp.

Referenced by platform_switch_to_thread().

Here is the call graph for this function:

◆ platform_shutdown()

void platform_shutdown ( void )

Definition at line 44 of file riscv64_platform_api.cpp.

Referenced by power_shutdown().

Here is the call graph for this function:

◆ platform_current_cpu_id()

u32 platform_current_cpu_id ( void )

Definition at line 51 of file riscv64_platform_api.cpp.

Referenced by do_syslog(), enter_scheduler(), and platform_ap_entry().

◆ platform_cpu_idle()

void platform_cpu_idle ( void )

Definition at line 56 of file riscv64_platform_api.cpp.

Referenced by idle_task(), and platform_shutdown().

◆ platform_dump_regs()

void platform_dump_regs ( const platform_regs_t * regs)

◆ platform_thread_regs()

◆ thread_setup_common()

void thread_setup_common ( Thread * thread)
static

◆ platform_context_setup_main_thread()

void platform_context_setup_main_thread ( Thread * thread,
ptr_t entry,
ptr_t sp,
int argc,
ptr_t argv,
ptr_t envp )

Definition at line 85 of file riscv64_platform_api.cpp.

Referenced by elf_do_fill_process().

Here is the call graph for this function:

◆ platform_context_setup_child_thread()

void platform_context_setup_child_thread ( Thread * thread,
thread_entry_t entry,
void * arg )

Definition at line 97 of file riscv64_platform_api.cpp.

Referenced by create_thread(), and kthread_create_no_sched().

Here is the call graph for this function:

◆ platform_context_clone()

void platform_context_clone ( Thread * from,
Thread * to )

Definition at line 117 of file riscv64_platform_api.cpp.

Referenced by process_do_fork().

Here is the call graph for this function:

◆ platform_context_cleanup()

void platform_context_cleanup ( Thread * thread)

Definition at line 130 of file riscv64_platform_api.cpp.

Referenced by process_do_execveat(), and thread_destroy().

◆ platform_interrupt_disable()

void platform_interrupt_disable ( void )

Definition at line 136 of file riscv64_platform_api.cpp.

Referenced by handle_kernel_panic().

◆ platform_interrupt_enable()

void platform_interrupt_enable ( void )

Definition at line 142 of file riscv64_platform_api.cpp.

Referenced by idle_task().

◆ platform_switch_mm()

void platform_switch_mm ( const MMContext * new_mm)

◆ do_save_fp_context()

void do_save_fp_context ( Thread * thread)
static

Definition at line 156 of file riscv64_platform_api.cpp.

Referenced by platform_switch_to_thread().

◆ do_restore_fp_context()

void do_restore_fp_context ( Thread * thread)

Definition at line 198 of file riscv64_platform_api.cpp.

Referenced by platform_switch_to_thread().

◆ platform_switch_to_thread()

void platform_switch_to_thread ( Thread * current,
Thread * new_thread,
ContextSwitchBehaviorFlags switch_flags )

Definition at line 239 of file riscv64_platform_api.cpp.

Referenced by reschedule().

Here is the call graph for this function:

◆ platform_return_to_userspace()

void platform_return_to_userspace ( platform_regs_t * regs)

Definition at line 263 of file riscv64_platform_api.cpp.

Referenced by platform_restore_from_signal_handler().

Here is the call graph for this function:

◆ platform_arch_syscall()

u64 platform_arch_syscall ( u64 syscall,
u64 arg1,
u64 arg2,
u64 arg3,
u64 arg4 )

Definition at line 276 of file riscv64_platform_api.cpp.

Referenced by arch_syscall().

Here is the call graph for this function:

◆ platform_ipi_send()

void platform_ipi_send ( u8 target_cpu,
ipi_type_t type )

Definition at line 294 of file riscv64_platform_api.cpp.

◆ platform_dump_stack()

void platform_dump_stack ( const platform_regs_t * regs)

◆ platform_syscall_setup_restart_context()

void platform_syscall_setup_restart_context ( platform_regs_t * regs,
reg_t syscall_nr )

Definition at line 314 of file riscv64_platform_api.cpp.

Referenced by signal_exit_to_user_prepare().

◆ platform_syscall_store_retval()

void platform_syscall_store_retval ( platform_regs_t * regs,
reg_t result )

Definition at line 320 of file riscv64_platform_api.cpp.

Referenced by signal_exit_to_user_prepare().

◆ platform_setup_signal_handler_regs()

ptr< platform_regs_t > platform_setup_signal_handler_regs ( const platform_regs_t * regs,
const sigreturn_data_t * sigreturn_data,
const sigaction_t * sa )

Definition at line 325 of file riscv64_platform_api.cpp.

Referenced by do_signal_exit_to_user_prepare().

Here is the call graph for this function:

◆ platform_restore_from_signal_handler()

void platform_restore_from_signal_handler ( void * sp)

Definition at line 342 of file riscv64_platform_api.cpp.

Referenced by MOS_STATIC_ASSERT().

Here is the call graph for this function:

◆ platform_get_timestamp()

u64 platform_get_timestamp ( void )

Definition at line 354 of file riscv64_platform_api.cpp.

Referenced by do_syslog(), and SyslogStreamWriter::SyslogStreamWriter().

◆ platform_get_time()

void platform_get_time ( timeval_t * tv)

Definition at line 359 of file riscv64_platform_api.cpp.

Referenced by clock_gettimeofday().

◆ platform_get_unix_timestamp()

void platform_get_unix_timestamp ( u64 * timestamp)

Definition at line 369 of file riscv64_platform_api.cpp.

Referenced by clock_gettimeofday().

◆ platform_dump_current_stack()

void platform_dump_current_stack ( void )

Definition at line 376 of file riscv64_platform_api.cpp.

Referenced by handle_kernel_panic(), and x86_handle_exception().