Skip to content

Commit 8a4890a

Browse files
GuEe-GUIRbb666
authored andcommitted
[ARCH/AARCH64] Update Hypercall API
Signed-off-by: GuEe-GUI <[email protected]>
1 parent 5e03e07 commit 8a4890a

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

libcpu/aarch64/common/hypercall.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
11
/*
2-
* Copyright (c) 2006-2020, RT-Thread Development Team
2+
* Copyright (c) 2006-2023, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2022-02-24 GuEe-GUI first version
9+
* 2023-02-21 GuEe-GUI update API
910
*/
1011

1112
#include <hypercall.h>
1213

13-
rt_err_t rt_hv_stage2_map(unsigned long paddr, unsigned long size)
14+
rt_err_t rt_hv_version(rt_uint32_t *out_version)
1415
{
15-
return rt_hw_hypercall(120, paddr & (~4095), (paddr & (~4095)) + size, (1 << 0) | (1 << 1) | (1 << 4), 0, 0, 0, 0);
16+
if (out_version)
17+
{
18+
*out_version = rt_hw_hypercall(HYPERCALL_START + 0, 0, 0, 0, 0, 0, 0, 0);
19+
20+
if ((int)*out_version < 0)
21+
{
22+
return *out_version;
23+
}
24+
}
25+
26+
return -RT_EINVAL;
27+
}
28+
29+
rt_err_t rt_hv_debug(rt_uint32_t id, rt_uint32_t argc,
30+
rt_ubase_t arg0, rt_ubase_t arg1, rt_ubase_t arg2,
31+
rt_ubase_t arg3, rt_ubase_t arg4)
32+
{
33+
return rt_hw_hypercall(HYPERCALL_START + 1, id,
34+
arg0, arg1, arg2, arg3, arg4, argc);
35+
}
36+
37+
rt_err_t rt_hv_console(char c)
38+
{
39+
return rt_hw_hypercall(HYPERCALL_START + 2, c, 0, 0, 0, 0, 0, 0);
1640
}
Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
/*
2-
* Copyright (c) 2006-2020, RT-Thread Development Team
2+
* Copyright (c) 2006-2023, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2022-02-24 GuEe-GUI first version
9+
* 2023-02-21 GuEe-GUI update API
910
*/
1011

1112
#ifndef __HYPERCALL_H__
1213
#define __HYPERCALL_H__
1314

1415
#include <rtdef.h>
16+
#include <smccc.h>
17+
18+
#define HYPERCALL_START 0xc5000000 /* HVC64 */
19+
#define HYPERCALL_END 0xc500ffff /* HVC64 */
1520

1621
rt_inline rt_uint32_t rt_hw_hypercall(rt_uint32_t w0, rt_uint64_t x1, rt_uint64_t x2,
1722
rt_uint64_t x3, rt_uint64_t x4, rt_uint64_t x5, rt_uint64_t x6, rt_uint32_t w7)
1823
{
19-
register rt_uint64_t ret __asm__ ("x0");
20-
__asm__ volatile ("hvc #0");
24+
struct arm_smccc_res_t res;
25+
26+
arm_smccc_hvc(w0, x1, x2, x3, x4, x5, x6, w7, &res, RT_NULL);
2127

22-
return (rt_uint32_t)ret;
28+
return res.a0;
2329
}
2430

25-
rt_err_t rt_hv_stage2_map(unsigned long paddr, unsigned long size);
31+
rt_err_t rt_hv_version(rt_uint32_t *out_version);
32+
rt_err_t rt_hv_debug(rt_uint32_t id, rt_uint32_t argc,
33+
rt_ubase_t arg0, rt_ubase_t arg1, rt_ubase_t arg2,
34+
rt_ubase_t arg3, rt_ubase_t arg4);
35+
rt_err_t rt_hv_console(char c);
2636

27-
#endif
37+
#endif /* __HYPERCALL_H__ */

0 commit comments

Comments
 (0)