kernel_samsung_a34x-permissive/drivers/uh/rkp.c

81 lines
1.8 KiB
C
Raw Normal View History

#include <linux/rkp.h>
#include <linux/mm.h>
#include <asm/pgtable.h>
bool rkp_started __rkp_ro = false;
static u64 robuffer_base __rkp_ro = 0;
static u64 robuffer_size __rkp_ro = 0;
/* init/main.c */
void __init rkp_init(void)
{
struct rkp_init init_data;
memset((void *)&init_data, 0, sizeof(struct rkp_init));
/* initialized rkp_init struct */
init_data.magic = RKP_INIT_MAGIC;
init_data.vmalloc_start = VMALLOC_START;
init_data.no_fimc_verify = 1;
init_data.fimc_phys_addr = 0;
init_data._text = (u64)_text;
init_data._etext = (u64)_etext;
init_data._srodata = (u64)__start_rodata;
init_data._erodata = (u64)__end_rodata;
init_data.large_memory = 0;
init_data.vmalloc_end = (u64)high_memory;
init_data.init_mm_pgd = (u64)__pa(swapper_pg_dir);
init_data.id_map_pgd = (u64)__pa(idmap_pg_dir);
init_data.zero_pg_addr = (u64)__pa(empty_zero_page);
uh_call(UH_APP_RKP, RKP_START, (u64)&init_data, (u64)kimage_voffset, 0, 0);
rkp_started = true;
}
/* init/main.c */
void rkp_deferred_init(void)
{
uh_call(UH_APP_RKP, RKP_DEFERRED_START, 0, 0, 0, 0);
}
/* RO BUFFER */
void rkp_robuffer_init(void)
{
uh_call(UH_APP_RKP, RKP_GET_RO_INFO, (u64)&robuffer_base, (u64)&robuffer_size, 0, 0);
}
/* allocation */
inline phys_addr_t rkp_ro_alloc_phys(void)
{
phys_addr_t alloc_addr = 0;
uh_call(UH_APP_RKP, RKP_ROBUFFER_ALLOC, (u64)&alloc_addr, 1, 0, 0);
return alloc_addr;
}
inline void *rkp_ro_alloc(void)
{
void *addr = NULL;
uh_call(UH_APP_RKP, RKP_ROBUFFER_ALLOC, (u64)&addr, 1, 0, 0);
if (!addr)
return 0;
return (void *)__phys_to_virt(addr);
}
inline void rkp_ro_free(void *addr)
{
uh_call(UH_APP_RKP, RKP_ROBUFFER_FREE, (u64)addr, 0, 0, 0);
}
inline bool is_rkp_ro_buffer(u64 addr)
{
u64 pa = (u64)virt_to_phys((void *)addr);
if ((robuffer_base <= pa) && (pa < robuffer_base + robuffer_size))
return true;
else
return false;
}