MOS Source Code
|
#include "mos/interrupt/ipi.h"
#include "mos/misc/cmdline.h"
#include "mos/mm/paging/pml_types.h"
#include "mos/mm/physical/pmm.h"
#include "mos/platform/platform_defs.h"
#include <mos/lib/structures/list.h>
#include <mos/lib/sync/spinlock.h>
#include <mos/mm/mm_types.h>
#include <mos/mos_global.h>
#include <mos/tasks/signal_types.h>
Go to the source code of this file.
Classes | |
struct | mm_context_t |
struct | cpu_t |
struct | timeval_t |
struct | mos_platform_info_t |
struct | mos_platform_info_t::cpu |
Macros | |
#define | PER_CPU_DECLARE(type, name) |
#define | PER_CPU_VAR_INIT { .percpu_value = { 0 } } |
#define | per_cpu(var) |
#define | current_cpu per_cpu(platform_info->cpu) |
#define | current_thread (current_cpu->thread) |
#define | current_process (current_thread->owner) |
#define | current_mm (current_cpu->mm_context) |
#define | MOS_KERNEL_PFN(vaddr) |
#define | platform_alias(name) |
Typedefs | |
typedef void(* | irq_handler) (u32 irq) |
typedef struct _thread | thread_t |
typedef struct _console | console_t |
typedef struct _platform_regs | platform_regs_t |
typedef struct _platform_process_options | platform_process_options_t |
typedef struct _platform_thread_options | platform_thread_options_t |
typedef char | datetime_str_t[32] |
typedef struct _sigreturn_data | sigreturn_data_t |
Enumerations | |
enum | vm_flags { VM_READ = MEM_PERM_READ , VM_WRITE = MEM_PERM_WRITE , VM_EXEC = MEM_PERM_EXEC , VM_USER = 1 << 3 , VM_WRITE_THROUGH = 1 << 4 , VM_CACHE_DISABLED = 1 << 5 , VM_GLOBAL = 1 << 6 , VM_RW = VM_READ | VM_WRITE , VM_RX = VM_READ | VM_EXEC , VM_RWX = VM_READ | VM_WRITE | VM_EXEC , VM_USER_RW = VM_USER | VM_RW , VM_USER_RX = VM_USER | VM_RX , VM_USER_RO = VM_USER | VM_READ , VM_USER_RWX = VM_USER | VM_RWX } |
enum | thread_state_t { THREAD_STATE_CREATED , THREAD_STATE_READY , THREAD_STATE_RUNNING , THREAD_STATE_BLOCKED , THREAD_STATE_NONINTERRUPTIBLE , THREAD_STATE_DEAD } |
enum | switch_flags_t { SWITCH_REGULAR , SWITCH_TO_NEW_USER_THREAD , SWITCH_TO_NEW_KERNEL_THREAD } |
Variables | |
mos_platform_info_t *const | platform_info |
__BEGIN_DECLS const char | __MOS_KERNEL_CODE_START [] |
__BEGIN_DECLS const char | __MOS_KERNEL_CODE_END [] |
const char | __MOS_KERNEL_RODATA_START [] |
const char | __MOS_KERNEL_RODATA_END [] |
const char | __MOS_KERNEL_RW_START [] |
const char | __MOS_KERNEL_RW_END [] |
const char | __MOS_KERNEL_END [] |
#define PER_CPU_DECLARE | ( | type, | |
name ) |
Definition at line 23 of file platform.h.
Referenced by platform_get_datetime_str().
#define PER_CPU_VAR_INIT { .percpu_value = { 0 } } |
Definition at line 24 of file platform.h.
#define per_cpu | ( | var | ) |
Definition at line 25 of file platform.h.
Referenced by platform_get_datetime_str(), platform_switch_to_thread(), x86_cpu_initialise_caps(), x86_init_percpu_gdt(), and x86_init_percpu_tss().
#define current_cpu per_cpu(platform_info->cpu) |
Definition at line 29 of file platform.h.
Referenced by blocked_reschedule(), elf_setup_main_thread(), mm_dump_current_pagetable(), mm_switch_context(), mos_start_kernel(), platform_ap_entry(), platform_arch_syscall(), platform_startup_late(), platform_switch_to_thread(), reschedule(), reschedule_for_waitlist(), riscv64_trap_handler(), try_handle_kernel_panics_at(), x86_dump_stack_at(), and x86_interrupt_entry().
#define current_thread (current_cpu->thread) |
Definition at line 30 of file platform.h.
Referenced by dentry_from_fd(), do_signal_exit_to_user_prepare(), dump_process(), enter_scheduler(), futex_wait(), get_tid(), invalid_page_fault(), io_poll(), ksyscall_enter(), kthread_entry(), mm_dump_current_pagetable(), mm_handle_fault(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), naive_sched_select_next(), pipe_write(), platform_arch_syscall(), platform_arch_syscall(), platform_context_setup_child_thread(), platform_jump_to_signal_handler(), platform_restore_from_signal_handler(), platform_return_to_userspace(), process_do_execveat(), process_do_fork(), process_exit(), process_sysfs_thread_stat(), riscv64_start_kernel_thread(), riscv64_start_user_thread(), riscv64_trap_handler(), signal_do_ignore(), signal_do_terminate(), signal_exit_to_user_prepare(), signal_exit_to_user_prepare_syscall(), signal_get_next_pending(), signal_has_pending(), signal_on_returned(), signal_send_to_thread(), thread_destroy(), timer_msleep(), waitlist_append(), waitlist_remove_me(), x86_handle_exception(), x86_interrupt_entry(), x86_pit_timer_handler(), x86_start_kernel_thread(), and x86_start_user_thread().
#define current_process (current_thread->owner) |
Definition at line 31 of file platform.h.
Referenced by create_thread(), current_stdio(), dentry_from_fd(), do_signal_exit_to_user_prepare(), dump_process(), execveat(), exit(), fd_manipulate(), fork(), futex_get_key(), get_parent_pid(), get_pid(), invalid_page_fault(), io_close(), io_dup(), io_dup2(), io_pread(), io_read(), io_readv(), io_seek(), io_tell(), io_write(), ipc_accept(), ipc_connect(), ipc_create(), memfd_create(), mm_dump_current_pagetable(), mmap_file(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), MOS_STATIC_ASSERT(), munmap(), platform_arch_syscall(), platform_context_setup_child_thread(), process_destroy(), process_do_execveat(), process_sysfs_process_stat(), process_wait_for_pid(), riscv64_trap_handler(), signal_do_coredump(), signal_do_terminate(), signal_exit_to_user_prepare(), signal_exit_to_user_prepare_syscall(), thread_wait_for_tid(), vfs_chdirat(), vfs_fstatat(), and vfs_ipc_file_read().
#define current_mm (current_cpu->mm_context) |
Definition at line 32 of file platform.h.
Referenced by dmabuf_allocate(), dmabuf_free(), mm_handle_fault(), mmap_anonymous(), mmap_file(), MOS_STATIC_ASSERT(), platform_context_setup_child_thread(), process_destroy(), and process_sysfs_vmap_stat().
#define MOS_KERNEL_PFN | ( | vaddr | ) |
Definition at line 137 of file platform.h.
Referenced by mos_start_kernel().
#define platform_alias | ( | name | ) |
Definition at line 154 of file platform.h.
Definition at line 34 of file platform.h.
typedef struct _console console_t |
Definition at line 37 of file platform.h.
typedef struct _platform_regs platform_regs_t |
Definition at line 86 of file platform.h.
typedef struct _platform_process_options platform_process_options_t |
Definition at line 141 of file platform.h.
typedef struct _platform_thread_options platform_thread_options_t |
Definition at line 142 of file platform.h.
typedef char datetime_str_t[32] |
Definition at line 184 of file platform.h.
typedef struct _sigreturn_data sigreturn_data_t |
Definition at line 263 of file platform.h.
enum vm_flags |
Enumerator | |
---|---|
VM_READ | |
VM_WRITE | |
VM_EXEC | |
VM_USER | |
VM_WRITE_THROUGH | |
VM_CACHE_DISABLED | |
VM_GLOBAL | |
VM_RW | |
VM_RX | |
VM_RWX | |
VM_USER_RW | |
VM_USER_RX | |
VM_USER_RO | |
VM_USER_RWX |
Definition at line 39 of file platform.h.
enum thread_state_t |
Definition at line 60 of file platform.h.
enum switch_flags_t |
Enumerator | |
---|---|
SWITCH_REGULAR | |
SWITCH_TO_NEW_USER_THREAD | |
SWITCH_TO_NEW_KERNEL_THREAD |
Definition at line 70 of file platform.h.
Definition at line 102 of file kmain.c.
Referenced by limine_entry().
Definition at line 23 of file ap_entry.c.
Referenced by ap_entry().
void platform_startup_early | ( | ) |
Definition at line 47 of file riscv64_platform.c.
Referenced by mos_start_kernel().
void platform_startup_setup_kernel_mm | ( | ) |
Definition at line 60 of file riscv64_platform.c.
Referenced by mos_start_kernel().
void platform_startup_late | ( | ) |
Definition at line 79 of file riscv64_platform.c.
Referenced by mos_start_kernel().
Definition at line 34 of file riscv64_platform_api.c.
Referenced by power_shutdown().
void platform_dump_regs | ( | platform_regs_t * | regs | ) |
Definition at line 51 of file riscv64_platform_api.c.
Referenced by invalid_page_fault(), try_handle_kernel_panics_at(), x86_handle_exception(), and x86_handle_nmi().
void platform_dump_stack | ( | platform_regs_t * | regs | ) |
Definition at line 290 of file riscv64_platform_api.c.
Referenced by invalid_page_fault(), try_handle_kernel_panics_at(), and x86_handle_exception().
void platform_dump_current_stack | ( | ) |
Definition at line 181 of file x86_platform.c.
Referenced by try_handle_kernel_panics_at(), and x86_handle_exception().
Definition at line 197 of file x86_platform_api.c.
Referenced by clock_gettimeofday(), and platform_get_datetime_str().
Definition at line 65 of file mm.c.
Referenced by mos_test_engine_run_tests(), platform_ap_entry(), and try_handle_kernel_panics_at().
Definition at line 72 of file mm.c.
Referenced by pml1e_do_flag_callback(), pml1e_do_map_callback(), pml1e_do_mask_callback(), and pml1e_do_unmap_callback().
Definition at line 41 of file riscv64_platform_api.c.
Referenced by do_syslog(), enter_scheduler(), and platform_ap_entry().
Definition at line 46 of file riscv64_platform_api.c.
Referenced by idle_task(), and platform_shutdown().
Definition at line 61 of file x86_platform_api.c.
Referenced by do_syslog().
datetime_str_t * platform_get_datetime_str | ( | void | ) |
Definition at line 66 of file x86_platform_api.c.
Referenced by do_syslog().
Definition at line 131 of file riscv64_platform_api.c.
Referenced by idle_task().
Definition at line 125 of file riscv64_platform_api.c.
Referenced by platform_shutdown(), and try_handle_kernel_panics_at().
Definition at line 78 of file mm.c.
Referenced by pagetable_iter_next(), pagetable_iterator_start_current_range(), pml1e_do_copy_callback(), pml1e_do_unmap_callback(), and pml1e_get_pfn().
Definition at line 83 of file mm.c.
Referenced by pml1e_do_map_callback().
Definition at line 90 of file mm.c.
Referenced by pagetable_iter_next(), pagetable_iterator_start_current_range(), pml1e_do_copy_callback(), pml1e_do_flag_callback(), pml1e_do_mask_callback(), pml1e_do_unmap_callback(), and pml1e_is_present().
Definition at line 95 of file mm.c.
Referenced by pml1e_do_flag_callback(), pml1e_do_map_callback(), and pml1e_do_mask_callback().
Definition at line 101 of file mm.c.
Referenced by mm_do_get_flags(), pagetable_iter_next(), pagetable_iterator_start_current_range(), and pml1e_do_mask_callback().
platform_regs_t * platform_thread_regs | ( | const thread_t * | thread | ) |
Definition at line 64 of file riscv64_platform_api.c.
Referenced by platform_arch_syscall(), platform_arch_syscall(), platform_context_clone(), platform_context_setup_child_thread(), platform_context_setup_main_thread(), process_do_execveat(), riscv64_start_kernel_thread(), riscv64_start_user_thread(), x86_setup_thread_common(), x86_start_kernel_thread(), and x86_start_user_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().
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().
Definition at line 106 of file riscv64_platform_api.c.
Referenced by process_do_fork().
Definition at line 119 of file riscv64_platform_api.c.
Referenced by process_do_execveat(), and thread_destroy().
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().
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().
void platform_return_to_userspace | ( | platform_regs_t * | regs | ) |
Definition at line 252 of file riscv64_platform_api.c.
Referenced by platform_jump_to_signal_handler(), platform_restore_from_signal_handler(), process_do_execveat(), riscv64_start_user_thread(), riscv64_trap_handler(), and x86_start_user_thread().
Definition at line 265 of file riscv64_platform_api.c.
Referenced by arch_syscall().
void platform_ipi_send | ( | u8 | target_cpu, |
ipi_type_t | type ) |
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().
Definition at line 331 of file riscv64_platform_api.c.
Referenced by MOS_STATIC_ASSERT().
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().
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().
|
extern |
Definition at line 15 of file riscv64_platform.c.
Referenced by add_to_memmap(), cmdline_get_option(), create_idle_task(), initrd_read(), limine_entry(), mm_create_context(), mm_destroy_context(), mm_dump_current_pagetable(), mm_sysfs_init(), mos_cmdline_init(), mos_start_kernel(), platform_ap_entry(), platform_context_clone(), platform_startup_early(), platform_startup_late(), platform_startup_setup_kernel_mm(), pmm_find_reserved_region(), pmm_init(), process_allocate(), setup_xsave_slab(), vmap_create(), x86_cpu_initialise_caps(), x86_cpu_setup_xsave_area(), x86_paging_setup(), and x86_setup_direct_map().
|
extern |
Referenced by mos_start_kernel(), and x86_handle_exception().
__BEGIN_DECLS const char __MOS_KERNEL_CODE_END[] |
Definition at line 147 of file platform.h.
Referenced by mos_start_kernel(), and x86_handle_exception().
|
extern |
Referenced by mos_start_kernel().
const char __MOS_KERNEL_RODATA_END[] |
Definition at line 148 of file platform.h.
Referenced by mos_start_kernel().
|
extern |
Referenced by mos_start_kernel().
const char __MOS_KERNEL_RW_END[] |
Definition at line 149 of file platform.h.
Referenced by mos_start_kernel().
|
extern |