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

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)
 
static void riscv64_start_user_thread ()
 
static void riscv64_start_kernel_thread ()
 
void riscv64_normal_switch_impl ()
 
void platform_shutdown ()
 
u32 platform_current_cpu_id ()
 
void platform_cpu_idle ()
 
void platform_dump_regs (platform_regs_t *regs)
 
platform_regs_tplatform_thread_regs (const thread_t *thread)
 
static void thread_setup_common (thread_t *thread)
 
void platform_context_setup_main_thread (thread_t *thread, ptr_t entry, ptr_t sp, int argc, ptr_t argv, ptr_t envp)
 
void platform_context_setup_child_thread (thread_t *thread, thread_entry_t entry, void *arg)
 
void platform_context_clone (const thread_t *from, thread_t *to)
 
void platform_context_cleanup (thread_t *thread)
 
void platform_interrupt_disable ()
 
void platform_interrupt_enable ()
 
void platform_switch_mm (const mm_context_t *new_mm)
 
static void do_save_fp_context (thread_t *thread)
 
void do_restore_fp_context (thread_t *thread)
 
void platform_switch_to_thread (thread_t *current, thread_t *new_thread, switch_flags_t 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 (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)
 
void platform_jump_to_signal_handler (const platform_regs_t *regs, const sigreturn_data_t *sigreturn_data, const sigaction_t *sa)
 
void platform_restore_from_signal_handler (void *sp)
 

Macro Definition Documentation

◆ FLEN

#define FLEN   64

Definition at line 143 of file riscv64_platform_api.c.

◆ 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 13 of file riscv64_platform_api.c.

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 )
extern

◆ riscv64_start_user_thread()

static void riscv64_start_user_thread ( )
static

Definition at line 16 of file riscv64_platform_api.c.

Referenced by platform_switch_to_thread().

+ Here is the call graph for this function:

◆ riscv64_start_kernel_thread()

static void riscv64_start_kernel_thread ( )
static

Definition at line 23 of file riscv64_platform_api.c.

Referenced by platform_switch_to_thread().

+ Here is the call graph for this function:

◆ riscv64_normal_switch_impl()

void riscv64_normal_switch_impl ( )
extern

◆ platform_shutdown()

void platform_shutdown ( void )

Definition at line 34 of file riscv64_platform_api.c.

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 41 of file riscv64_platform_api.c.

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

◆ platform_cpu_idle()

void platform_cpu_idle ( void )

Definition at line 46 of file riscv64_platform_api.c.

Referenced by idle_task(), and platform_shutdown().

◆ platform_dump_regs()

void platform_dump_regs ( platform_regs_t * regs)

◆ platform_thread_regs()

◆ thread_setup_common()

static void thread_setup_common ( thread_t * thread)
static

◆ platform_context_setup_main_thread()

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

Definition at line 75 of file riscv64_platform_api.c.

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_t * thread,
thread_entry_t entry,
void * arg )

Definition at line 86 of file riscv64_platform_api.c.

Referenced by create_thread(), and kthread_create_no_sched().

+ Here is the call graph for this function:

◆ platform_context_clone()

void platform_context_clone ( const thread_t * from,
thread_t * to )

Definition at line 106 of file riscv64_platform_api.c.

Referenced by process_do_fork().

+ Here is the call graph for this function:

◆ platform_context_cleanup()

void platform_context_cleanup ( thread_t * thread)

Definition at line 119 of file riscv64_platform_api.c.

Referenced by process_do_execveat(), and thread_destroy().

◆ platform_interrupt_disable()

void platform_interrupt_disable ( void )

Definition at line 125 of file riscv64_platform_api.c.

Referenced by try_handle_kernel_panics_at().

◆ platform_interrupt_enable()

void platform_interrupt_enable ( void )

Definition at line 131 of file riscv64_platform_api.c.

Referenced by idle_task().

◆ platform_switch_mm()

void platform_switch_mm ( const mm_context_t * new_mm)

Definition at line 137 of file riscv64_platform_api.c.

Referenced by mm_switch_context(), mos_start_kernel(), and platform_ap_entry().

◆ do_save_fp_context()

static void do_save_fp_context ( thread_t * thread)
static

Definition at line 145 of file riscv64_platform_api.c.

Referenced by platform_switch_to_thread().

◆ do_restore_fp_context()

void do_restore_fp_context ( thread_t * thread)

Definition at line 187 of file riscv64_platform_api.c.

Referenced by platform_switch_to_thread().

◆ platform_switch_to_thread()

void platform_switch_to_thread ( thread_t * current,
thread_t * new_thread,
switch_flags_t switch_flags )

Definition at line 228 of file riscv64_platform_api.c.

Referenced by reschedule().

+ Here is the call graph for this function:

◆ platform_return_to_userspace()

void platform_return_to_userspace ( platform_regs_t * regs)

◆ platform_arch_syscall()

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

Definition at line 265 of file riscv64_platform_api.c.

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 283 of file riscv64_platform_api.c.

◆ platform_dump_stack()

void platform_dump_stack ( 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 303 of file riscv64_platform_api.c.

Referenced by signal_exit_to_user_prepare_syscall().

◆ platform_syscall_store_retval()

void platform_syscall_store_retval ( platform_regs_t * regs,
reg_t result )

Definition at line 309 of file riscv64_platform_api.c.

Referenced by signal_exit_to_user_prepare_syscall().

◆ platform_jump_to_signal_handler()

void platform_jump_to_signal_handler ( const platform_regs_t * regs,
const sigreturn_data_t * sigreturn_data,
const sigaction_t * sa )

Definition at line 314 of file riscv64_platform_api.c.

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 331 of file riscv64_platform_api.c.

Referenced by MOS_STATIC_ASSERT().

+ Here is the call graph for this function: