arch: riscv: pmp: reorder function definitions

Reorder the memory domain async functions to:
  arch_mem_domain_partition_add()
  arch_mem_domain_partition_remove()
  arch_mem_domain_thread_add()
  arch_mem_domain_thread_remove()

Signed-off-by: Jim Shu <cwshu@andestech.com>
This commit is contained in:
Jim Shu 2021-06-21 13:38:42 +08:00 committed by Carles Cufí
commit 9683c9e71c

View file

@ -596,6 +596,31 @@ int arch_mem_domain_max_partitions_get(void)
return PMP_MAX_DYNAMIC_REGION;
}
int arch_mem_domain_partition_add(struct k_mem_domain *domain,
uint32_t partition_id)
{
sys_dnode_t *node, *next_node;
struct k_thread *thread;
struct k_mem_partition *partition;
int ret = 0, ret2;
partition = &domain->partitions[partition_id];
SYS_DLIST_FOR_EACH_NODE_SAFE(&domain->mem_domain_q, node, next_node) {
thread = CONTAINER_OF(node, struct k_thread, mem_domain_info);
ret2 = z_riscv_pmp_add_dynamic(thread,
(ulong_t) partition->start,
(ulong_t) partition->size, partition->attr.pmp_attr);
ARG_UNUSED(ret2);
CHECKIF(ret2 != 0) {
ret = ret2;
}
}
return ret;
}
int arch_mem_domain_partition_remove(struct k_mem_domain *domain,
uint32_t partition_id)
{
@ -717,31 +742,6 @@ int arch_mem_domain_thread_add(struct k_thread *thread)
return ret;
}
int arch_mem_domain_partition_add(struct k_mem_domain *domain,
uint32_t partition_id)
{
sys_dnode_t *node, *next_node;
struct k_thread *thread;
struct k_mem_partition *partition;
int ret = 0, ret2;
partition = &domain->partitions[partition_id];
SYS_DLIST_FOR_EACH_NODE_SAFE(&domain->mem_domain_q, node, next_node) {
thread = CONTAINER_OF(node, struct k_thread, mem_domain_info);
ret2 = z_riscv_pmp_add_dynamic(thread,
(ulong_t) partition->start,
(ulong_t) partition->size, partition->attr.pmp_attr);
ARG_UNUSED(ret2);
CHECKIF(ret2 != 0) {
ret = ret2;
}
}
return ret;
}
int arch_mem_domain_thread_remove(struct k_thread *thread)
{
uint32_t i;