mirror of https://github.com/RT-Thread/rt-thread
[ARCH/AARCH64] Update Hypercall API
Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
parent
5e03e07c43
commit
8a4890a9e5
|
@ -1,16 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2022-02-24 GuEe-GUI first version
|
* 2022-02-24 GuEe-GUI first version
|
||||||
|
* 2023-02-21 GuEe-GUI update API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <hypercall.h>
|
#include <hypercall.h>
|
||||||
|
|
||||||
rt_err_t rt_hv_stage2_map(unsigned long paddr, unsigned long size)
|
rt_err_t rt_hv_version(rt_uint32_t *out_version)
|
||||||
{
|
{
|
||||||
return rt_hw_hypercall(120, paddr & (~4095), (paddr & (~4095)) + size, (1 << 0) | (1 << 1) | (1 << 4), 0, 0, 0, 0);
|
if (out_version)
|
||||||
|
{
|
||||||
|
*out_version = rt_hw_hypercall(HYPERCALL_START + 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
if ((int)*out_version < 0)
|
||||||
|
{
|
||||||
|
return *out_version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -RT_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_err_t rt_hv_debug(rt_uint32_t id, rt_uint32_t argc,
|
||||||
|
rt_ubase_t arg0, rt_ubase_t arg1, rt_ubase_t arg2,
|
||||||
|
rt_ubase_t arg3, rt_ubase_t arg4)
|
||||||
|
{
|
||||||
|
return rt_hw_hypercall(HYPERCALL_START + 1, id,
|
||||||
|
arg0, arg1, arg2, arg3, arg4, argc);
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_err_t rt_hv_console(char c)
|
||||||
|
{
|
||||||
|
return rt_hw_hypercall(HYPERCALL_START + 2, c, 0, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,37 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2022-02-24 GuEe-GUI first version
|
* 2022-02-24 GuEe-GUI first version
|
||||||
|
* 2023-02-21 GuEe-GUI update API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __HYPERCALL_H__
|
#ifndef __HYPERCALL_H__
|
||||||
#define __HYPERCALL_H__
|
#define __HYPERCALL_H__
|
||||||
|
|
||||||
#include <rtdef.h>
|
#include <rtdef.h>
|
||||||
|
#include <smccc.h>
|
||||||
|
|
||||||
|
#define HYPERCALL_START 0xc5000000 /* HVC64 */
|
||||||
|
#define HYPERCALL_END 0xc500ffff /* HVC64 */
|
||||||
|
|
||||||
rt_inline rt_uint32_t rt_hw_hypercall(rt_uint32_t w0, rt_uint64_t x1, rt_uint64_t x2,
|
rt_inline rt_uint32_t rt_hw_hypercall(rt_uint32_t w0, rt_uint64_t x1, rt_uint64_t x2,
|
||||||
rt_uint64_t x3, rt_uint64_t x4, rt_uint64_t x5, rt_uint64_t x6, rt_uint32_t w7)
|
rt_uint64_t x3, rt_uint64_t x4, rt_uint64_t x5, rt_uint64_t x6, rt_uint32_t w7)
|
||||||
{
|
{
|
||||||
register rt_uint64_t ret __asm__ ("x0");
|
struct arm_smccc_res_t res;
|
||||||
__asm__ volatile ("hvc #0");
|
|
||||||
|
|
||||||
return (rt_uint32_t)ret;
|
arm_smccc_hvc(w0, x1, x2, x3, x4, x5, x6, w7, &res, RT_NULL);
|
||||||
|
|
||||||
|
return res.a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_err_t rt_hv_stage2_map(unsigned long paddr, unsigned long size);
|
rt_err_t rt_hv_version(rt_uint32_t *out_version);
|
||||||
|
rt_err_t rt_hv_debug(rt_uint32_t id, rt_uint32_t argc,
|
||||||
|
rt_ubase_t arg0, rt_ubase_t arg1, rt_ubase_t arg2,
|
||||||
|
rt_ubase_t arg3, rt_ubase_t arg4);
|
||||||
|
rt_err_t rt_hv_console(char c);
|
||||||
|
|
||||||
#endif
|
#endif /* __HYPERCALL_H__ */
|
||||||
|
|
Loading…
Reference in New Issue