dart: Introduce dart_map_flags() and dart_translate_silent()

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2024-05-17 01:56:32 +09:00
parent 58090bb58c
commit 8c107bf80a
2 changed files with 16 additions and 4 deletions

View file

@ -503,7 +503,7 @@ static u64 *dart_get_l2(dart_dev_t *dart, u32 idx)
return tbl;
}
static int dart_map_page(dart_dev_t *dart, uintptr_t iova, uintptr_t paddr)
static int dart_map_page(dart_dev_t *dart, uintptr_t iova, uintptr_t paddr, u32 flags)
{
u32 l1_index = (iova >> 25) & 0x1fff;
u32 l2_index = (iova >> 14) & 0x7ff;
@ -521,12 +521,12 @@ static int dart_map_page(dart_dev_t *dart, uintptr_t iova, uintptr_t paddr)
u64 offset = FIELD_PREP(dart->params->offset_mask, paddr >> DART_PTE_OFFSET_SHIFT);
l2[l2_index] = offset | dart->params->pte_flags;
l2[l2_index] = offset | dart->params->pte_flags | flags;
return 0;
}
int dart_map(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len)
int dart_map_flags(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len, u32 flags)
{
uintptr_t paddr = (uintptr_t)bfr;
u64 offset = 0;
@ -539,7 +539,7 @@ int dart_map(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len)
return -1;
while (offset < len) {
int ret = dart_map_page(dart, iova + offset, paddr + offset);
int ret = dart_map_page(dart, iova + offset, paddr + offset, flags);
if (ret) {
dart_unmap(dart, iova, offset);
@ -553,6 +553,11 @@ int dart_map(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len)
return 0;
}
int dart_map(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len)
{
return dart_map_flags(dart, iova, bfr, len, 0);
}
static void dart_unmap_page(dart_dev_t *dart, uintptr_t iova)
{
u32 ttbr = (iova >> 36) & 0x3;
@ -651,6 +656,11 @@ void *dart_translate(dart_dev_t *dart, uintptr_t iova)
return dart_translate_internal(dart, iova, 0);
}
void *dart_translate_silent(dart_dev_t *dart, uintptr_t iova)
{
return dart_translate_internal(dart, iova, 1);
}
u64 dart_search(dart_dev_t *dart, void *paddr)
{
for (int ttbr = 0; ttbr < dart->params->ttbr_count; ++ttbr) {

View file

@ -22,9 +22,11 @@ void dart_lock_adt(const char *path, int instance);
dart_dev_t *dart_init_fdt(void *dt, u32 phandle, int device, bool keep_pts);
int dart_setup_pt_region(dart_dev_t *dart, const char *path, int device, u64 vm_base);
int dart_map(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len);
int dart_map_flags(dart_dev_t *dart, uintptr_t iova, void *bfr, size_t len, u32 flags);
void dart_unmap(dart_dev_t *dart, uintptr_t iova, size_t len);
void dart_free_l2(dart_dev_t *dart, uintptr_t iova);
void *dart_translate(dart_dev_t *dart, uintptr_t iova);
void *dart_translate_silent(dart_dev_t *dart, uintptr_t iova);
u64 dart_search(dart_dev_t *dart, void *paddr);
u64 dart_find_iova(dart_dev_t *dart, s64 start, size_t len);
void dart_shutdown(dart_dev_t *dart);