[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rt-smart] PV_OFFSET as a variable #6904

Merged
merged 9 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[pvoff] pvoff as interfaces
  • Loading branch information
polarvid committed Feb 11, 2023
commit d88d58f6309e201bda942087f7f0f10425f89858
6 changes: 0 additions & 6 deletions components/mm/mm_aspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ static void *_find_free(rt_aspace_t aspace, void *prefer, rt_size_t req_size,
mm_flag_t flags);

struct rt_aspace rt_kernel_space;
const rt_ubase_t rt_pv_offset;

rt_varea_t _varea_create(void *start, rt_size_t size)
{
Expand Down Expand Up @@ -758,8 +757,3 @@ void rt_aspace_print_all(rt_aspace_t aspace)
{
rt_aspace_traversal(aspace, _dump, NULL);
}

rt_ubase_t rt_get_pvoff(void)
{
return rt_pv_offset;
}
7 changes: 4 additions & 3 deletions components/mm/mm_aspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define MM_PAGE_SHIFT 12
#define MM_PA_TO_OFF(pa) ((uintptr_t)(pa) >> MM_PAGE_SHIFT)
#define PV_OFFSET (rt_get_pvoff())
#define PV_OFFSET (rt_kmem_pvoff())

#ifndef RT_USING_SMP
typedef rt_spinlock_t mm_spinlock;
Expand All @@ -43,7 +43,6 @@ struct rt_varea;
struct rt_mem_obj;

extern struct rt_aspace rt_kernel_space;
extern const rt_ubase_t rt_pv_offset;

typedef struct rt_aspace
{
Expand Down Expand Up @@ -203,6 +202,8 @@ void rt_varea_free_pages(rt_varea_t varea);

void rt_varea_offload_page(rt_varea_t varea, void *vaddr, rt_size_t size);

rt_ubase_t rt_get_pvoff(void);
rt_ubase_t rt_kmem_pvoff(void);

void rt_kmem_pvoff_set(rt_ubase_t pvoff);

#endif /* __MM_ASPACE_H__ */
12 changes: 12 additions & 0 deletions components/mm/mm_kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ static void list_kernel_space(void)
MSH_CMD_EXPORT(list_kernel_space, List varea in kernel space);

void rt_kmem_list_varea(void) __attribute__((alias("list_kernel_space")));

static rt_ubase_t rt_pv_offset;

rt_ubase_t rt_kmem_pvoff(void)
{
return rt_pv_offset;
}

void rt_kmem_pvoff_set(rt_ubase_t pvoff)
{
rt_pv_offset = pvoff;
}
6 changes: 5 additions & 1 deletion libcpu/aarch64/common/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,14 @@ int rt_hw_mmu_control(struct rt_aspace *aspace, void *vaddr, size_t size,
return err;
}

void rt_hw_mmu_setup_early(unsigned long *tbl0, unsigned long *tbl1,
void rt_hw_mem_setup_early(unsigned long *tbl0, unsigned long *tbl1,
unsigned long size, unsigned long pv_off)
{
int ret;

/* setup pv off */
rt_kmem_pvoff_set(pv_off);

unsigned long va = KERNEL_VADDR_START;
unsigned long count = (size + ARCH_SECTION_MASK) >> ARCH_SECTION_SHIFT;
unsigned long normal_attr = MMU_MAP_CUSTOM(MMU_AP_KAUN, NORMAL_MEM);
Expand Down
2 changes: 1 addition & 1 deletion libcpu/aarch64/common/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct mem_desc
struct rt_aspace;

void rt_hw_mmu_ktbl_set(unsigned long tbl);
void rt_hw_mmu_setup_early(unsigned long *tbl0, unsigned long *tbl1,
void rt_hw_mem_setup_early(unsigned long *tbl0, unsigned long *tbl1,
unsigned long size, unsigned long pv_off);
void rt_hw_mmu_setup(struct rt_aspace *aspace, struct mem_desc *mdesc,
int desc_nr);
Expand Down
6 changes: 2 additions & 4 deletions libcpu/aarch64/cortex-a/entry_point.S
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ __start:
ldr x2, =__start
GET_PHY x3, __start
sub x3, x3, x2
GET_PHY x5, rt_pv_offset
str x3, [x5]
#endif
ldr x2, =0x40000000 /* map 1G memory for kernel space */
bl rt_hw_mmu_setup_early
bl rt_hw_mem_setup_early

ldr x30, =after_mmu_enable /* set LR to after_mmu_enable function, it's a v_addr */

Expand Down Expand Up @@ -242,7 +240,7 @@ _secondary_cpu_entry:

bl mmu_tcr_init

adr x1, __start
adr x1, __start /* GET & setup early page table */
ldr x0, =~0x1fffff
and x0, x1, x0
add x1, x0, #0x1000
Expand Down
12 changes: 7 additions & 5 deletions libcpu/arm/cortex-a/start_gcc.S
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,20 @@ bss_loop:
strlo r0,[r1],#4 /* clear 4 bytes */
blo bss_loop /* loop until done */

mov r0, r5
bl rt_kmem_pvoff_set

#ifdef RT_USING_SMP
mrc p15, 0, r1, c1, c0, 1
mov r0, #(1<<6)
orr r1, r0
mcr p15, 0, r1, c1, c0, 1 /* enable smp */
#endif

ldr r8, =rt_pv_offset
add r8, r8, r5
str r5, [r8]

/* initialize the mmu table and enable mmu */
/**
* void rt_hw_init_mmu_table(struct mem_desc *mdesc, rt_uint32_t size)
* initialize the mmu table and enable mmu
*/
ldr r0, =platform_mem_desc
ldr r1, =platform_mem_desc_size
ldr r1, [r1]
Expand Down