--- /dev/null
+/*
+ * Copyright (c) 2018 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ * Anup Patel <anup.patel@wdc.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef __SBI_ECALL_INTERFACE_H__
+#define __SBI_ECALL_INTERFACE_H__
+
+#define SBI_ECALL_SET_TIMER 0
+#define SBI_ECALL_CONSOLE_PUTCHAR 1
+#define SBI_ECALL_CONSOLE_GETCHAR 2
+#define SBI_ECALL_CLEAR_IPI 3
+#define SBI_ECALL_SEND_IPI 4
+#define SBI_ECALL_REMOTE_FENCE_I 5
+#define SBI_ECALL_REMOTE_SFENCE_VMA 6
+#define SBI_ECALL_REMOTE_SFENCE_VMA_ASID 7
+#define SBI_ECALL_SHUTDOWN 8
+
+#define SBI_ECALL(__num, __a0, __a1, __a2) ({ \
+ register unsigned long a0 asm ("a0") = (unsigned long)(__a0); \
+ register unsigned long a1 asm ("a1") = (unsigned long)(__a1); \
+ register unsigned long a2 asm ("a2") = (unsigned long)(__a2); \
+ register unsigned long a7 asm ("a7") = (unsigned long)(__num);\
+ asm volatile ("ecall" \
+ : "+r" (a0) \
+ : "r" (a1), "r" (a2), "r" (a7) \
+ : "memory"); \
+ a0; \
+})
+
+#define SBI_ECALL_0(__num) SBI_ECALL(__num, 0, 0, 0)
+#define SBI_ECALL_1(__num, __a0) SBI_ECALL(__num, __a0, 0, 0)
+#define SBI_ECALL_2(__num, __a0, __a1) SBI_ECALL(__num, __a0, __a1, 0)
+
+#endif
#include <sbi/sbi_console.h>
#include <sbi/sbi_ecall.h>
+#include <sbi/sbi_ecall_interface.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_ipi.h>
#include <sbi/sbi_system.h>
#define SBI_ECALL_VERSION_MAJOR 0
#define SBI_ECALL_VERSION_MINOR 1
-#define SBI_ECALL_SET_TIMER 0
-#define SBI_ECALL_CONSOLE_PUTCHAR 1
-#define SBI_ECALL_CONSOLE_GETCHAR 2
-#define SBI_ECALL_CLEAR_IPI 3
-#define SBI_ECALL_SEND_IPI 4
-#define SBI_ECALL_REMOTE_FENCE_I 5
-#define SBI_ECALL_REMOTE_SFENCE_VMA 6
-#define SBI_ECALL_REMOTE_SFENCE_VMA_ASID 7
-#define SBI_ECALL_SHUTDOWN 8
-
u16 sbi_ecall_version_major(void)
{
return SBI_ECALL_VERSION_MAJOR;