coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
svc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include "svc.h"
4 
5 #include <assert.h>
6 #include <bl_uapp/bl_syscall_public.h>
7 #include <psp_verstage.h>
8 #include <stddef.h>
9 #include <string.h>
10 
11 void svc_exit(uint32_t status)
12 {
13  uint32_t unused = 0;
14  SVC_CALL0(SVC_EXIT, unused);
15 }
16 
17 void svc_debug_print(const char *string)
18 {
19  uint32_t unused = 0;
20  struct cmd_param_debug param = {
21  .debug_buffer = (char *)string,
22  .debug_buffer_len = strlen(string),
23  };
24  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_DEBUG_PRINT, (void *)&param, unused);
25 }
26 
28  uint32_t dword1, uint32_t dword2, uint32_t dword3)
29 {
30  uint32_t unused = 0;
31  struct cmd_param_debug_ex param = {
32  .word0 = dword0,
33  .word1 = dword1,
34  .word2 = dword2,
35  .word3 = dword3,
36  };
37  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_DEBUG_PRINT_EX, (void *)&param, unused);
38 }
39 
41 {
42  uint32_t retval = 0;
43  struct cmd_param_get_boot_mode param = {
44  .ptr_boot_mode = boot_mode,
45  };
46  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_GET_BOOT_MODE, (void *)&param, retval);
47  return retval;
48 }
49 
51 {
52  uint32_t unused = 0;
53  struct cmd_param_delay_in_micro_second param = {
54  .delay = delay,
55  };
56  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_DELAY_IN_MICRO_SECONDS, (void *)&param, unused);
57 }
58 
59 uint32_t svc_get_spi_rom_info(struct spirom_info *spi_rom_info)
60 {
61  uint32_t retval = 0;
62  struct cmd_param_spirom_info param = {
63  .ptr_spirom_info = spi_rom_info,
64  };
65  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_GET_SPI_INFO, (void *)&param, retval);
66  return retval;
67 }
68 
69 uint32_t svc_map_fch_dev(enum fch_io_device io_device,
70  uint32_t arg1, uint32_t arg2, void **io_device_axi_addr)
71 {
72  uint32_t retval = 0;
73  struct cmd_param_map_fch_io_device param = {
75  .arg1 = arg1,
76  .arg2 = arg2,
77  .pptr_io_device_addr_axi = io_device_axi_addr,
78  };
79  assert(io_device < FCH_IO_DEVICE_END);
80  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_MAP_FCH_IO_DEVICE, (void *)&param, retval);
81  return retval;
82 }
83 
84 uint32_t svc_unmap_fch_dev(enum fch_io_device io_device, void *io_device_axi_addr)
85 {
86  uint32_t retval = 0;
87  struct cmd_param_unmap_fch_io_device param = {
89  .ptr_io_device_addr_axi = io_device_axi_addr,
90  };
91  assert(io_device < FCH_IO_DEVICE_END);
92  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_UNMAP_FCH_IO_DEVICE, (void *)&param, retval);
93  return retval;
94 }
95 
96 uint32_t svc_map_spi_rom(void *spi_rom_addr,
97  uint32_t size, void **spi_rom_axi_addr)
98 {
99  uint32_t retval = 0;
100  struct cmd_param_map_spirom param = {
101  .spirom_addr = (uintptr_t)spi_rom_addr,
102  .size = size,
103  .ppspirom_addr_axi = spi_rom_axi_addr,
104  };
105  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_MAP_SPIROM_DEVICE, (void *)&param, retval);
106  return retval;
107 }
108 
109 uint32_t svc_unmap_spi_rom(void *spi_rom_addr)
110 {
111  uint32_t retval = 0;
112  struct cmd_param_unmap_spirom param = {
113  .ptr_spirom_addr_axi = spi_rom_addr,
114  };
115  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_UNMAP_SPIROM_DEVICE, (void *)&param, retval);
116  return retval;
117 }
118 
120  uint32_t *bios_dir_offset)
121 {
122  uint32_t retval = 0;
123  struct cmd_param_psp_update param = {
124  .ptr_psp_dir_addr = psp_dir_offset,
125  };
126  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_UPDATE_PSP_BIOS_DIR, (void *)&param, retval);
127  return retval;
128 }
129 
131 {
132  uint32_t retval = 0;
133  struct cmd_param_copy_data_from_uapp param = {
135  .size = size,
136  };
137  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_COPY_DATA_FROM_UAPP, (void *)&param, retval);
138  return retval;
139 }
140 
141 uint32_t svc_read_timer_val(enum psp_timer_type type, uint64_t *counter_value)
142 {
143  unsigned int retval = 0;
144  struct cmd_param_read_timer_val param = {
145  .timer_type = type,
146  .ptr_counter_value = counter_value,
147  };
148  assert(type < PSP_TIMER_TYPE_MAX);
149  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_READ_TIMER_VAL, (void *)&param, retval);
150  return retval;
151 }
152 
154 {
155  unsigned int retval = 0;
156  struct cmd_param_reset_system param = {
158  };
159  assert(reset_type < RESET_TYPE_MAX);
160  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_RESET_SYSTEM, (void *)&param, retval);
161  return retval;
162 }
163 
164 uint32_t svc_crypto_sha(struct sha_generic_data *sha_op, enum sha_operation_mode sha_mode)
165 {
166  uint32_t retval = 0;
167  struct cmd_param_sha param = {
168  .ptr_sha_op = sha_op,
169  .sha_mode = sha_mode,
170  };
171  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_SHA, (void *)&param, retval);
172  return retval;
173 }
174 
175 uint32_t svc_modexp(struct mod_exp_params *mod_exp_param)
176 {
177  uint32_t retval = 0;
178  struct cmd_param_modexp param = {
179  .ptr_modexp = mod_exp_param,
180  };
181  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_MODEXP, (void *)&param, retval);
182  return retval;
183 }
184 
185 uint32_t svc_ccp_dma(uint32_t spi_rom_offset, void *dest, uint32_t size)
186 {
187  uint32_t retval = 0;
188  struct cmd_param_ccp_dma param = {
189  .spi_offset = spi_rom_offset,
190  .dst_addr = (uintptr_t)dest,
191  .size = size,
192  };
193  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_CCP_DMA, (void *)&param, retval);
194  return retval;
195 }
196 
197 uint32_t svc_set_platform_boot_mode(enum chrome_platform_boot_mode boot_mode)
198 {
199  uint32_t retval = 0;
200  struct cmd_param_set_platform_boot_mode param = {
201  .boot_mode = boot_mode,
202  };
203  SVC_CALL2(SVC_VERSTAGE_CMD, CMD_SET_PLATFORM_BOOT_MODE, (void *)&param, retval);
204  return retval;
205 }
reset_type
Definition: acpi_fm350gl.c:31
#define assert(statement)
Definition: assert.h:74
void svc_delay_in_usec(uint32_t delay)
Definition: svc.c:36
uint32_t svc_ccp_dma(uint32_t spi_rom_offset, void *dest, uint32_t size)
Definition: svc.c:130
uint32_t svc_crypto_sha(struct sha_generic_data *sha_op, enum sha_operation_mode sha_mode)
Definition: svc.c:116
uint32_t svc_get_spi_rom_info(struct spirom_info *spi_rom_info)
Definition: svc.c:42
uint32_t svc_modexp(struct mod_exp_params *mod_exp_param)
Definition: svc.c:123
uint32_t svc_read_timer_val(enum psp_timer_type type, uint64_t *counter_value)
Definition: svc.c:100
uint32_t svc_update_psp_bios_dir(uint32_t *psp_dir_offset, uint32_t *bios_dir_offset)
Definition: svc.c:84
uint32_t svc_set_platform_boot_mode(enum chrome_platform_boot_mode boot_mode)
Definition: svc.c:137
uint32_t svc_unmap_spi_rom(void *spi_rom_addr)
Definition: svc.c:77
uint32_t svc_reset_system(enum reset_type reset_type)
Definition: svc.c:108
void svc_debug_print(const char *string)
Definition: svc.c:16
uint32_t svc_map_fch_dev(enum fch_io_device io_device, uint32_t arg1, uint32_t arg2, void **io_device_axi_addr)
Definition: svc.c:49
void svc_debug_print_ex(uint32_t dword0, uint32_t dword1, uint32_t dword2, uint32_t dword3)
Definition: svc.c:22
uint32_t svc_unmap_fch_dev(enum fch_io_device io_device, void *io_device_axi_addr)
Definition: svc.c:59
void svc_exit(uint32_t status)
Definition: svc.c:10
uint32_t svc_get_boot_mode(uint32_t *boot_mode)
Definition: svc.c:29
uint32_t svc_map_spi_rom(void *spi_rom_addr, uint32_t size, void **spi_rom_axi_addr)
Definition: svc.c:68
uint32_t svc_save_uapp_data(void *address, uint32_t size)
Definition: svc.c:93
#define SVC_CALL2(SVC_ID, R0, R1, Ret)
Definition: svc.h:30
#define SVC_CALL0(SVC_ID, Ret)
Definition: svc.h:49
void delay(unsigned int secs)
Definition: delay.c:8
uint64_t address
Definition: fw_cfg_if.h:0
unsigned int type
Definition: edid.c:57
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:17
size_t strlen(const char *src)
Definition: string.c:42
uint32_t size
Definition: svc.h:138
uint32_t spi_offset
Definition: svc.h:136
unsigned int address
Definition: svc.h:119
uint32_t word0
Definition: svc.h:73
uint32_t debug_buffer_len
Definition: svc.h:69
char * debug_buffer
Definition: svc.h:68
unsigned int * ptr_boot_mode
Definition: svc.h:115
unsigned int arg1
Definition: svc.h:125
unsigned int arg2
Definition: svc.h:126
enum fch_io_device io_device
Definition: svc.h:124
unsigned int size
Definition: svc.h:93
unsigned int spirom_addr
Definition: svc.h:92
void ** ppspirom_addr_axi
Definition: svc.h:94
struct mod_exp_params * ptr_modexp
Definition: svc.h:80
unsigned int * ptr_psp_dir_addr
Definition: svc.h:84
enum psp_timer_type timer_type
Definition: svc.h:102
enum reset_type reset_type
Definition: svc.h:111
struct sha_generic_data * ptr_sha_op
Definition: svc.h:63
enum sha_operation_mode sha_mode
Definition: svc.h:64
struct spirom_info * ptr_spirom_info
Definition: svc.h:88
enum fch_io_device io_device
Definition: svc.h:131
void * ptr_spirom_addr_axi
Definition: svc.h:98
static struct sha_generic_data sha_op
Definition: vboot_crypto.c:14