coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mcall.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _MCALL_H
4 #define _MCALL_H
5 
6 // NOTE: this is the size of hls_t below. A static_assert would be
7 // nice to have.
8 #if __riscv_xlen == 64
9 #define HLS_SIZE 88
10 #endif
11 
12 #if __riscv_xlen == 32
13 #define HLS_SIZE 52
14 #endif
15 
16 /* We save 37 registers, currently. */
17 #define MENTRY_FRAME_SIZE (HLS_SIZE + 37 * __SIZEOF_POINTER__)
18 
19 #ifndef __ASSEMBLER__
20 
21 #include <arch/encoding.h>
22 #include <arch/smp/atomic.h>
23 #include <stdint.h>
24 
25 typedef struct {
26  unsigned long dev;
27  unsigned long cmd;
28  unsigned long data;
29  unsigned long sbi_private_data;
31 
32 struct blocker {
33  void *arg;
34  void (*fn)(void *arg);
37 };
38 
39 typedef struct {
44 
45  int hart_id;
49  void *fdt;
50  struct blocker entry;
51 } hls_t;
52 
54  sizeof(hls_t) == HLS_SIZE,
55  "HLS_SIZE must equal to sizeof(hls_t)");
56 
57 #define MACHINE_STACK_TOP() ({ \
58  /* coverity[uninit_use] : FALSE */ \
59  register uintptr_t sp asm ("sp"); \
60  (void*)((sp + RISCV_PGSIZE) & -RISCV_PGSIZE); })
61 
62 // hart-local storage, at top of stack
63 #define HLS() ((hls_t*)(MACHINE_STACK_TOP() - HLS_SIZE))
64 #define OTHER_HLS(id) ((hls_t*)((void*)HLS() + RISCV_PGSIZE * ((id) - HLS()->hart_id)))
65 
66 #define MACHINE_STACK_SIZE RISCV_PGSIZE
67 
68 // need to call this before launching linux
69 void hls_init(uint32_t hart_id, void *fdt);
70 
71 /* This function is used to initialize HLS()->time/HLS()->timecmp */
72 void mtime_init(void);
73 
74 /*
75  * This function needs be implement by SoC code.
76  * Although the privileged instruction set defines that MSIP will be
77  * memory-mapped, but does not define how to map. SoC can be implemented as
78  * a bit, a byte, a word, and so on.
79  * So we can't provide code that is related to implementation.
80  */
81 void set_msip(int hartid, int val);
82 
83 #endif // __ASSEMBLER__
84 
85 #endif
void set_msip(int hartid, int val)
Definition: clint.c:15
_Static_assert(sizeof(hls_t)==HLS_SIZE, "HLS_SIZE must equal to sizeof(hls_t)")
void mtime_init(void)
Definition: clint.c:8
void hls_init(uint32_t hart_id, void *fdt)
Definition: mcall.c:7
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
Definition: atomic.h:8
Definition: mcall.h:32
atomic_t sync_b
Definition: mcall.h:36
void * arg
Definition: mcall.h:33
void(* fn)(void *arg)
Definition: mcall.h:34
atomic_t sync_a
Definition: mcall.h:35
Definition: mcall.h:39
sbi_device_message * device_response_queue_tail
Definition: mcall.h:43
sbi_device_message * device_response_queue_head
Definition: mcall.h:42
int ipi_pending
Definition: mcall.h:46
uint64_t * time
Definition: mcall.h:48
sbi_device_message * device_request_queue_head
Definition: mcall.h:40
uint64_t * timecmp
Definition: mcall.h:47
int hart_id
Definition: mcall.h:45
unsigned long device_request_queue_size
Definition: mcall.h:41
unsigned long dev
Definition: mcall.h:26
unsigned long data
Definition: mcall.h:28
unsigned long sbi_private_data
Definition: mcall.h:29
unsigned long cmd
Definition: mcall.h:27
u8 val
Definition: sys.c:300
typedef void(X86APIP X86EMU_intrFuncs)(int num)