Skip to content

Commit 216d72e

Browse files
HelloByeAllGuozhanxin
authored andcommitted
修改:启动过程和__start解耦,对于RT_AMP_SLAVE 跳过cpu 非0核等待
1 parent 0c29bed commit 216d72e

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

libcpu/aarch64/common/mmu.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,8 @@ unsigned long get_free_page(void)
535535
{
536536
if (!__init_page_array)
537537
{
538-
unsigned long temp_page_start;
539-
asm volatile("mov %0, sp" : "=r"(temp_page_start));
540-
__init_page_array =
541-
(struct page_table *)(temp_page_start & ~(ARCH_SECTION_MASK));
538+
extern unsigned char __bss_end;
539+
__init_page_array = (struct page_table *) RT_ALIGN((unsigned long) &__bss_end, 0x1000);
542540
__page_off = 2; /* 0, 1 for ttbr0, ttrb1 */
543541
}
544542
__page_off++;
@@ -778,7 +776,13 @@ void rt_hw_mem_setup_early(unsigned long *tbl0, unsigned long *tbl1,
778776
/* setup pv off */
779777
rt_kmem_pvoff_set(pv_off);
780778

779+
#ifdef RT_USING_SMART
781780
unsigned long va = KERNEL_VADDR_START;
781+
#else
782+
extern unsigned char __start;
783+
unsigned long va = (unsigned long) &__start;
784+
#endif
785+
782786
unsigned long count = (size + ARCH_SECTION_MASK) >> ARCH_SECTION_SHIFT;
783787
unsigned long normal_attr = MMU_MAP_CUSTOM(MMU_AP_KAUN, NORMAL_MEM);
784788

libcpu/aarch64/cortex-a/entry_point.S

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ __start:
2121
mrs x0, tpidr_el1
2222
cbz x0, .L__cpu_0 /* .L prefix is the local label in ELF */
2323

24+
#ifndef RT_AMP_SLAVE
2425
/* cpu id > 0, stop */
2526
/* cpu id == 0 will also goto here after returned from entry() if possible */
2627
.L__current_cpu_idle:
2728
wfe
2829
b .L__current_cpu_idle
30+
#endif
2931

3032
.L__cpu_0:
3133
/* set stack before our code, Define stack pointer for current exception level */
32-
adr x1, __start
34+
adr x1, .el_stack_top
3335

3436
/* set up EL1 */
3537
mrs x0, CurrentEL /* CurrentEL Register. bit 2, 3. Others reserved */
@@ -114,13 +116,11 @@ __start:
114116
sub x3, x3, #1
115117
b .L__clean_bss_loop_1
116118

117-
.L__jump_to_entry: /* jump to C code, should not return */
119+
.L__jump_to_entry: /* jump to C code, should not return */
118120
bl mmu_tcr_init
119121

120-
adr x1, __start /* install early page table */
121-
ldr x0, =~0x1fffff
122-
and x0, x1, x0
123-
add x1, x0, #0x1000
122+
adr x0, .early_mmu_table /* install early page table */
123+
add x1, x0, #0x1000
124124

125125
msr ttbr0_el1, x0
126126
msr ttbr1_el1, x1
@@ -133,8 +133,8 @@ __start:
133133
#else
134134
mov x3,0
135135
#endif
136-
137-
ldr x2, =0x40000000 /* map 1G memory for kernel space */
136+
137+
ldr x2, =0x01000000 /* map 16M memory for kernel space */
138138
bl rt_hw_mem_setup_early
139139

140140
ldr x30, =after_mmu_enable /* set LR to after_mmu_enable function, it's a v_addr */
@@ -168,7 +168,7 @@ after_mmu_enable:
168168

169169
mov x0, #1
170170
msr spsel, x0
171-
adr x1, __start
171+
adr x1, .el_stack_top
172172
mov sp, x1 /* sp_el1 set to _start */
173173

174174
b rtthread_startup
@@ -181,7 +181,7 @@ after_mmu_enable:
181181
.global _secondary_cpu_entry
182182
_secondary_cpu_entry:
183183
bl rt_hw_cpu_id_set
184-
adr x1, __start
184+
adr x1, .el_stack_top
185185

186186
/* set up EL1 */
187187
mrs x0, CurrentEL /* CurrentEL Register. bit 2, 3. Others reserved */
@@ -203,7 +203,7 @@ _secondary_cpu_entry:
203203
.L__not_in_el3_cpux: /* running at EL2 or EL1 */
204204
cmp x0, #4 /* 0x04 0100 EL1 */
205205
beq .L__in_el1_cpux /* EL1 -> 5: */
206-
206+
207207
mrs x0, hcr_el2
208208
bic x0, x0, #0xff
209209
msr hcr_el2, x0
@@ -246,9 +246,7 @@ _secondary_cpu_entry:
246246

247247
bl mmu_tcr_init
248248

249-
adr x1, __start /* GET & setup early page table */
250-
ldr x0, =~0x1fffff
251-
and x0, x1, x0
249+
adr x0, .early_mmu_table /* GET & setup early page table */
252250
add x1, x0, #0x1000
253251

254252
msr ttbr0_el1, x0
@@ -288,9 +286,18 @@ after_mmu_enable_cpux:
288286
msr spsel, x0
289287
mrs x0, tpidr_el1
290288
/* each cpu init stack is 8k */
291-
adr x1, __start
289+
adr x1, .el_stack_top
292290
sub x1, x1, x0, lsl #13
293291
mov sp, x1 /* in EL1. Set sp to _start */
294292

295293
b rt_hw_secondary_cpu_bsp_start
296294
#endif
295+
296+
.align 12
297+
.early_mmu_table:
298+
.space (4096 * 2)
299+
300+
.align 12
301+
.el_stack:
302+
.space (8192)
303+
.el_stack_top:

0 commit comments

Comments
 (0)