550W Document
550W, a high-end OS
sbi.h
浏览该文件的文档.
1 #pragma once
2 
3 #include <asm/sbidef.h>
4 #include <common/types.h>
5 
6 /* clang-format off */
7 
8 #define SBI_CALL(which, arg0, arg1, arg2) \
9  ({ \
10  register uintptr_t a0 asm("a0") = (uintptr_t)(arg0); \
11  register uintptr_t a1 asm("a1") = (uintptr_t)(arg1); \
12  register uintptr_t a2 asm("a2") = (uintptr_t)(arg2); \
13  register uintptr_t a6 asm("a6") = (uintptr_t)(0); \
14  register uintptr_t a7 asm("a7") = (uintptr_t)(which); \
15  asm volatile("ecall" \
16  : "+r"(a0) \
17  : "r"(a1), "r"(a2), "r"(a6), "r"(a7) \
18  : "memory"); \
19  a0; \
20  })
21 
22 /* clang-format on */
23 
24 /* Lazy implementations until SBI is finalized */
25 #define SBI_CALL_0(which) SBI_CALL(which, 0, 0, 0)
26 #define SBI_CALL_1(which, arg0) SBI_CALL(which, arg0, 0, 0)
27 #define SBI_CALL_2(which, arg0, arg1) SBI_CALL(which, arg0, arg1, 0)
28 #define SBI_CALL_3(which, arg0, arg1, arg2) SBI_CALL(which, arg0, arg1, arg2)
29 
30 static inline void sbi_console_putstr(char *str) {
31  while (*str != '\0') {
33  }
34 }
35 
36 static inline void sbi_console_putchar(int ch) {
38 }
39 
40 static inline int sbi_console_getchar(void) {
42 }
43 
44 static inline void sbi_set_timer(uint64_t stime_value) {
45  SBI_CALL_1(SBI_EXT_TIME, stime_value);
46 }
47 
48 static inline void sbi_set_mode(uint64_t hart_id, uint64_t addr) {
49  SBI_CALL_2(SBI_EXT_HSM, hart_id, addr);
50 }
51 
52 static inline void sbi_shutdown(void) {
54 }
55 
56 static inline void sbi_clear_ipi(void) {
58 }
59 
60 static inline void sbi_send_ipi(const unsigned long *hart_mask) {
61  SBI_CALL_1(SBI_EXT_0_1_SEND_IPI, hart_mask);
62 }
63 
64 static inline void sbi_remote_fence_i(const unsigned long *hart_mask) {
66 }
67 
68 static inline void sbi_remote_sfence_vma(const unsigned long *hart_mask, unsigned long start, unsigned long size) {
70 }
71 
72 static inline void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask, unsigned long start, unsigned long size, unsigned long asid) {
74 }
#define SBI_CALL_1(which, arg0)
Definition: sbi.h:26
#define SBI_CALL_2(which, arg0, arg1)
Definition: sbi.h:27
#define SBI_CALL_0(which)
Definition: sbi.h:25
#define SBI_EXT_TIME
Definition: sbidef.h:14
#define SBI_EXT_0_1_SHUTDOWN
Definition: sbidef.h:12
#define SBI_EXT_0_1_CONSOLE_GETCHAR
Definition: sbidef.h:6
#define SBI_EXT_HSM
Definition: sbidef.h:17
#define SBI_EXT_0_1_CONSOLE_PUTCHAR
Definition: sbidef.h:5
#define SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID
Definition: sbidef.h:11
#define SBI_EXT_0_1_REMOTE_SFENCE_VMA
Definition: sbidef.h:10
#define SBI_EXT_0_1_SEND_IPI
Definition: sbidef.h:8
#define SBI_EXT_0_1_REMOTE_FENCE_I
Definition: sbidef.h:9
#define SBI_EXT_0_1_CLEAR_IPI
Definition: sbidef.h:7