1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#include "mos/platform/platform.h"
4
5#include "mos/misc/panic.h"
6#include "mos/syslog/printk.h"
7
8#include <mos/mos_global.h>
9#include <mos/types.h>
10
11#define __weak__ [[gnu::weak]]
12
13__weak__ [[noreturn]] void platform_ap_entry(u64 arg)
14{
15 MOS_UNUSED(arg);
16 mos_panic("platform_ap_entry not implemented");
17}
18
19// Platform Machine APIs
20__weak__ [[noreturn]] void platform_shutdown(void)
21{
22 mos_panic("platform_shutdown not implemented");
23}
24
25__weak__ void platform_dump_regs(platform_regs_t *regs)
26{
27 MOS_UNUSED(regs);
28 pr_emerg("platform_dump_regs() not implemented");
29}
30
31__weak__ void platform_dump_stack(platform_regs_t *regs)
32{
33 MOS_UNUSED(regs);
34 pr_emerg("platform_dump_stack() not implemented");
35}
36
37__weak__ void platform_dump_current_stack()
38{
39 pr_emerg("platform_dump_current_stack() not implemented");
40}
41
42__weak__ void platform_dump_thread_kernel_stack(const thread_t *thread)
43{
44 MOS_UNUSED(thread);
45 pr_emerg("platform_dump_thread_kernel_stack() not implemented");
46}
47
48// Platform Timer/Clock APIs
49__weak__ void platform_get_time(timeval_t *val)
50{
51 MOS_UNUSED(val);
52 pr_emerg("platform_get_time() not implemented");
53}
54
55// Platform CPU APIs
56__weak__ [[noreturn]] void platform_halt_cpu(void)
57{
58 pr_emerg("platform_halt_cpu() not implemented");
59 while (1)
60 ;
61}
62
63__weak__ void platform_invalidate_tlb(ptr_t vaddr)
64{
65 MOS_UNUSED(vaddr);
66 pr_emerg("platform_invalidate_tlb() not implemented");
67}
68
69__weak__ u32 platform_current_cpu_id(void)
70{
71 return 0;
72}
73
74__weak__ void platform_cpu_idle(void)
75{
76 pr_emerg("platform_cpu_idle() not implemented");
77}
78
79__weak__ u64 platform_get_timestamp(void)
80{
81 return 0;
82}
83
84__weak__ datetime_str_t *platform_get_datetime_str(void)
85{
86 return nullptr;
87}
88
89// Platform Interrupt APIs, default implementation does nothing
90__weak__ void platform_interrupt_enable(void)
91{
92 pr_emerg("platform_interrupt_enable() not implemented");
93}
94
95__weak__ void platform_interrupt_disable(void)
96{
97 pr_emerg("platform_interrupt_disable() not implemented");
98}
99
100// Platform-Specific syscall APIs, does nothing by default
101__weak__ u64 platform_arch_syscall(u64 syscall, u64 arg1, u64 arg2, u64 arg3, u64 arg4)
102{
103 MOS_UNUSED(syscall);
104 MOS_UNUSED(arg1);
105 MOS_UNUSED(arg2);
106 MOS_UNUSED(arg3);
107 MOS_UNUSED(arg4);
108 pr_emerg("platform_arch_syscall() not implemented");
109 return 0;
110}
111
112// Platform-Specific IPI (Inter-Processor Interrupt) APIs
113__weak__ void platform_ipi_send(u8 target_cpu, ipi_type_t type)
114{
115 MOS_UNUSED(target_cpu);
116 MOS_UNUSED(type);
117 pr_emerg("platform_ipi_send() not implemented");
118}
119
120// Signal Handler APIs, panic if not implemented
121
122__weak__ [[noreturn]] void platform_jump_to_signal_handler(const platform_regs_t *regs, const sigreturn_data_t *sigreturn_data, const sigaction_t *sa)
123{
124 MOS_UNUSED(regs);
125 MOS_UNUSED(sigreturn_data);
126 MOS_UNUSED(sa);
127 mos_panic("platform_jump_to_signal_handler() not implemented");
128}
129
130__weak__ [[noreturn]] void platform_restore_from_signal_handler(void *sp)
131{
132 MOS_UNUSED(sp);
133 mos_panic("platform_restore_from_signal_handler() not implemented");
134}
135
136__weak__ void platform_syscall_setup_restart_context(platform_regs_t *regs, reg_t syscall_nr)
137{
138 MOS_UNUSED(regs);
139 MOS_UNUSED(syscall_nr);
140 mos_panic("platform_syscall_setup_restart_context() not implemented");
141}
142
143__weak__ void platform_syscall_store_retval(platform_regs_t *regs, reg_t result)
144{
145 MOS_UNUSED(regs);
146 MOS_UNUSED(result);
147 mos_panic("platform_syscall_store_retval() not implemented");
148}
149