sbi.h (a1ff5a7d78a036d6c2178ee5acd6ba4946243800) sbi.h (1ff95eb2bebda50c4c5406caaf201e0fcb24cc8f)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2015 Regents of the University of California
4 * Copyright (c) 2020 Western Digital Corporation or its affiliates.
5 */
6
7#ifndef _ASM_RISCV_SBI_H
8#define _ASM_RISCV_SBI_H
9
10#include <linux/types.h>
11#include <linux/cpumask.h>
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2015 Regents of the University of California
4 * Copyright (c) 2020 Western Digital Corporation or its affiliates.
5 */
6
7#ifndef _ASM_RISCV_SBI_H
8#define _ASM_RISCV_SBI_H
9
10#include <linux/types.h>
11#include <linux/cpumask.h>
12#include <linux/jump_label.h>
12
13#ifdef CONFIG_RISCV_SBI
14enum sbi_ext_id {
15#ifdef CONFIG_RISCV_SBI_V01
16 SBI_EXT_0_1_SET_TIMER = 0x0,
17 SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
18 SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
19 SBI_EXT_0_1_CLEAR_IPI = 0x3,

--- 279 unchanged lines hidden (view full) ---

299
300extern unsigned long sbi_spec_version;
301struct sbiret {
302 long error;
303 long value;
304};
305
306void sbi_init(void);
13
14#ifdef CONFIG_RISCV_SBI
15enum sbi_ext_id {
16#ifdef CONFIG_RISCV_SBI_V01
17 SBI_EXT_0_1_SET_TIMER = 0x0,
18 SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
19 SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
20 SBI_EXT_0_1_CLEAR_IPI = 0x3,

--- 279 unchanged lines hidden (view full) ---

300
301extern unsigned long sbi_spec_version;
302struct sbiret {
303 long error;
304 long value;
305};
306
307void sbi_init(void);
308long __sbi_base_ecall(int fid);
307struct sbiret __sbi_ecall(unsigned long arg0, unsigned long arg1,
308 unsigned long arg2, unsigned long arg3,
309 unsigned long arg4, unsigned long arg5,
310 int fid, int ext);
311#define sbi_ecall(e, f, a0, a1, a2, a3, a4, a5) \
312 __sbi_ecall(a0, a1, a2, a3, a4, a5, f, e)
313
314#ifdef CONFIG_RISCV_SBI_V01

--- 53 unchanged lines hidden (view full) ---

368/* Make SBI version */
369static inline unsigned long sbi_mk_version(unsigned long major,
370 unsigned long minor)
371{
372 return ((major & SBI_SPEC_VERSION_MAJOR_MASK) << SBI_SPEC_VERSION_MAJOR_SHIFT)
373 | (minor & SBI_SPEC_VERSION_MINOR_MASK);
374}
375
309struct sbiret __sbi_ecall(unsigned long arg0, unsigned long arg1,
310 unsigned long arg2, unsigned long arg3,
311 unsigned long arg4, unsigned long arg5,
312 int fid, int ext);
313#define sbi_ecall(e, f, a0, a1, a2, a3, a4, a5) \
314 __sbi_ecall(a0, a1, a2, a3, a4, a5, f, e)
315
316#ifdef CONFIG_RISCV_SBI_V01

--- 53 unchanged lines hidden (view full) ---

370/* Make SBI version */
371static inline unsigned long sbi_mk_version(unsigned long major,
372 unsigned long minor)
373{
374 return ((major & SBI_SPEC_VERSION_MAJOR_MASK) << SBI_SPEC_VERSION_MAJOR_SHIFT)
375 | (minor & SBI_SPEC_VERSION_MINOR_MASK);
376}
377
376int sbi_err_map_linux_errno(int err);
378static inline int sbi_err_map_linux_errno(int err)
379{
380 switch (err) {
381 case SBI_SUCCESS:
382 return 0;
383 case SBI_ERR_DENIED:
384 return -EPERM;
385 case SBI_ERR_INVALID_PARAM:
386 return -EINVAL;
387 case SBI_ERR_INVALID_ADDRESS:
388 return -EFAULT;
389 case SBI_ERR_NOT_SUPPORTED:
390 case SBI_ERR_FAILURE:
391 default:
392 return -ENOTSUPP;
393 };
394}
377
378extern bool sbi_debug_console_available;
379int sbi_debug_console_write(const char *bytes, unsigned int num_bytes);
380int sbi_debug_console_read(char *bytes, unsigned int num_bytes);
381
382#else /* CONFIG_RISCV_SBI */
383static inline int sbi_remote_fence_i(const struct cpumask *cpu_mask) { return -1; }
384static inline void sbi_init(void) {}

--- 19 unchanged lines hidden ---
395
396extern bool sbi_debug_console_available;
397int sbi_debug_console_write(const char *bytes, unsigned int num_bytes);
398int sbi_debug_console_read(char *bytes, unsigned int num_bytes);
399
400#else /* CONFIG_RISCV_SBI */
401static inline int sbi_remote_fence_i(const struct cpumask *cpu_mask) { return -1; }
402static inline void sbi_init(void) {}

--- 19 unchanged lines hidden ---