Skip to content

Commit

Permalink
Fixes for PPC spin table based on ePAPR 1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Nov 14, 2023
1 parent 67a52a6 commit 5000fc7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions hal/nxp_p1021.ld
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ SECTIONS
{
_start_vector = .;
KEEP(*(.isr_vector))
. = ALIGN(256);
KEEP(*(.bootmp))
*(.text*)
*(.rodata*)
*(.sdata*)
Expand Down
10 changes: 8 additions & 2 deletions hal/nxp_ppc.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#define CPU_NUMCORES 4
#define CORES_PER_CLUSTER 4
#define LAW_MAX_ENTRIES 32
#define ENABLE_PPC64

#define CCSRBAR_DEF (0xFE000000UL) /* T2080RM 4.3.1 default base */
#define CCSRBAR_SIZE BOOKE_PAGESZ_16M
Expand Down Expand Up @@ -704,17 +705,22 @@ extern void dcache_disable(void);
#define r31 31
#endif

/* ePAPR 1.1 spin table */
/* For multiple core spin table communication */
#define EPAPR_MAGIC (0x45504150)
/* The spin table must be WING 0b001x (memory-coherence required) */
/* For older PPC compat use dcbf to flush spin table entry */
#define EPAPR_MAGIC (0x45504150) /* Book III-E CPUs */
#define ENTRY_ADDR_UPPER 0
#define ENTRY_ADDR_LOWER 4
#define ENTRY_R3_UPPER 8
#define ENTRY_R3_LOWER 12
#define ENTRY_RESV 16
#define ENTRY_PIR 20

/* not used for ePAPR 1.1 */
#define ENTRY_R6_UPPER 24
#define ENTRY_R6_LOWER 28
#define ENTRY_SIZE 32

#define ENTRY_SIZE CACHE_LINE_SIZE /* note: spin-table shall be cache-line size aligned in memory */

#endif /* !_NXP_PPC_H_ */
1 change: 1 addition & 0 deletions hal/nxp_t1024.ld
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SECTIONS
KEEP(*(.isr_vector))
. = ALIGN(256);
_start_text = .;
KEEP(*(.bootmp))
*(.text*)
*(.rodata*)
*(.sdata*)
Expand Down
1 change: 1 addition & 0 deletions hal/nxp_t2080.ld
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SECTIONS
_start_vector = .;
KEEP(*(.isr_vector))
. = ALIGN(256);
KEEP(*(.bootmp))
*(.text*)
*(.rodata*)
*(.sdata*)
Expand Down
7 changes: 6 additions & 1 deletion src/boot_ppc_mp.S
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/* Additional cores (mp) assembly code for core minimum startup and spin table.
* All code must fit in 4KB, which gets virtually mapped via the TLB1 (MMU) and
* loaded by core 0. Spin table entry TLB1(0) mapped for work is 64MB. */
.section .bootmp, "ax"
.globl _mp_page_start
.align 12
_mp_page_start:
Expand Down Expand Up @@ -111,7 +112,7 @@ _mp_page_start:
mr r4, r0
mr r5, r4
#endif
slwi r8, r5, 5 /* core number * ENTRY_SIZE */
slwi r8, r5, CACHE_LINE_SHIFT /* core number * ENTRY_SIZE */
add r10, r3, r8

mtspr SPRN_PIR, r4 /* write to PIR register */
Expand Down Expand Up @@ -228,7 +229,11 @@ _mp_page_start:
rlwinm r12, r4, 0, 0, 5

/* setup registers before jump */
#ifdef ENABLE_PPC64
ld r3, ENTRY_R3_UPPER(r10)
#else
lwz r3, ENTRY_R3_LOWER(r10)
#endif
li r4, 0
li r5, 0
lwz r6, ENTRY_R6_LOWER(r10)
Expand Down

0 comments on commit 5000fc7

Please sign in to comment.