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

core: introduce get_core_pos_mpidr() #1817

Merged
merged 1 commit into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions core/arch/arm/include/kernel/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <kernel/thread.h>

size_t get_core_pos(void);
size_t get_core_pos_mpidr(uint32_t mpidr);

uint32_t read_mode_sp(int cpu_mode);
uint32_t read_mode_lr(int cpu_mode);
Expand Down
12 changes: 10 additions & 2 deletions core/arch/arm/kernel/misc_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,26 @@
#include <kernel/unwind.h>

/* Let platforms override this if needed */
.weak get_core_pos
.weak get_core_pos_mpidr

/* size_t get_core_pos(void); */
FUNC get_core_pos , :
UNWIND( .fnstart)
read_mpidr r0
b get_core_pos_mpidr
UNWIND( .fnend)
END_FUNC get_core_pos

/* size_t get_core_pos_mpidr(uint32_t mpidr); */
FUNC get_core_pos_mpidr , :
UNWIND( .fnstart)
/* Calculate CorePos = (ClusterId * 4) + CoreId */
and r1, r0, #MPIDR_CPU_MASK
and r0, r0, #MPIDR_CLUSTER_MASK
add r0, r1, r0, LSR #6
bx lr
UNWIND( .fnend)
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr

/*
* uint32_t temp_set_mode(int cpu_mode)
Expand Down
10 changes: 8 additions & 2 deletions core/arch/arm/kernel/misc_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@
#include <arm.h>

/* Let platforms override this if needed */
.weak get_core_pos
.weak get_core_pos_mpidr

/* size_t get_core_pos(void); */
FUNC get_core_pos , :
mrs x0, mpidr_el1
b get_core_pos_mpidr
END_FUNC get_core_pos

/* size_t get_core_pos_mpidr(uint32_t mpidr); */
FUNC get_core_pos_mpidr , :
/* Calculate CorePos = (ClusterId * 4) + CoreId */
and x1, x0, #MPIDR_CPU_MASK
and x0, x0, #MPIDR_CLUSTER_MASK
add x0, x1, x0, LSR #6
ret
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr
5 changes: 2 additions & 3 deletions core/arch/arm/plat-ls/ls_core_pos_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
#include <kernel/unwind.h>

/* Layerscape platform specific function to calculate core position. */
FUNC get_core_pos , :
FUNC get_core_pos_mpidr , :
UNWIND( .fnstart)
read_mpidr r0
/* Calculate CorePos = CoreId */
and r0, r0, #MPIDR_CPU_MASK
bx lr
UNWIND( .fnend)
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr
5 changes: 2 additions & 3 deletions core/arch/arm/plat-ls/ls_core_pos_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
#include <arm.h>

/* Layerscape platform specific function to calculate core position. */
FUNC get_core_pos , :
mrs x0, mpidr_el1
FUNC get_core_pos_mpidr , :
and x0, x0, #MPIDR_CPU_MASK
ret
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr
6 changes: 2 additions & 4 deletions core/arch/arm/plat-mediatek/mt8173_core_pos_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
#include <arm32_macros.S>
#include <kernel/unwind.h>

FUNC get_core_pos , :
FUNC get_core_pos_mpidr , :
UNWIND( .fnstart)
read_mpidr r0
and r1, r0, #MPIDR_CPU_MASK
and r0, r0, #MPIDR_CLUSTER_MASK
/*
Expand All @@ -47,5 +46,4 @@ UNWIND( .fnstart)
add r0, r1, r0, LSR #7
bx lr
UNWIND( .fnend)
END_FUNC get_core_pos

END_FUNC get_core_pos_mpidr
5 changes: 2 additions & 3 deletions core/arch/arm/plat-mediatek/mt8173_core_pos_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#include <asm.S>
#include <arm.h>

FUNC get_core_pos , :
mrs x0, mpidr_el1
FUNC get_core_pos_mpidr , :
and x1, x0, #MPIDR_CPU_MASK
and x0, x0, #MPIDR_CLUSTER_MASK
/*
Expand All @@ -43,5 +42,5 @@ FUNC get_core_pos , :
*/
add x0, x1, x0, LSR #7
ret
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr

5 changes: 2 additions & 3 deletions core/arch/arm/plat-rockchip/core_pos_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
#include <arm32_macros.S>
#include <kernel/unwind.h>

FUNC get_core_pos , :
FUNC get_core_pos_mpidr , :
UNWIND( .fnstart)
/*
* Because mpidr is designed mistake in hardware, ie. core0 is 0xf00,
* core1 is 0xf01..., so we need implement the function to correct this.
*/
read_mpidr r0
and r0, r0, #MPIDR_CPU_MASK
bx lr
UNWIND( .fnend)
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr

5 changes: 2 additions & 3 deletions core/arch/arm/plat-vexpress/juno_core_pos_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
#include <kernel/unwind.h>

/* For Juno number the two A57s as 4 to 5 and A53s as 0 to 3 */
FUNC get_core_pos , :
FUNC get_core_pos_mpidr , :
UNWIND( .fnstart)
read_mpidr r0
/* Calculate CorePos = ((ClusterId ^ 1) * 4) + CoreId */
and r1, r0, #MPIDR_CPU_MASK
and r0, r0, #MPIDR_CLUSTER_MASK
eor r0, r0, #(1 << MPIDR_CLUSTER_SHIFT)
add r0, r1, r0, LSR #6
bx lr
UNWIND( .fnend)
END_FUNC get_core_pos
END_FUNC get_core_pos_mpidr

7 changes: 2 additions & 5 deletions core/arch/arm/plat-vexpress/juno_core_pos_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@
#include <arm.h>

/* For Juno number the two A57s as 4 to 5 and A53s as 0 to 3 */
FUNC get_core_pos , :
mrs x0, mpidr_el1
FUNC get_core_pos_mpidr , :
/* Calculate CorePos = ((ClusterId ^ 1) * 4) + CoreId */
and x1, x0, #MPIDR_CPU_MASK
and x0, x0, #MPIDR_CLUSTER_MASK
eor x0, x0, #(1 << MPIDR_CLUSTER_SHIFT)
add x0, x1, x0, LSR #6
ret
END_FUNC get_core_pos


END_FUNC get_core_pos_mpidr