Skip to content
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
10 changes: 8 additions & 2 deletions src/arch/xtensa/include/arch/lib/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ static inline int arch_cpu_get_id(void)
return prid;
}

#if !XCHAL_HAVE_THREADPTR
extern unsigned int _virtual_thread_start;
static unsigned int *virtual_thread_ptr =
(unsigned int *)&_virtual_thread_start;
#endif

static inline void cpu_write_threadptr(int threadptr)
{
#if XCHAL_HAVE_THREADPTR
__asm__ __volatile__(
"wur.threadptr %0" : : "a" (threadptr) : "memory");
#else
#error "Core support for XCHAL_HAVE_THREADPTR is required"
*virtual_thread_ptr = threadptr;
#endif
}

Expand All @@ -61,7 +67,7 @@ static inline int cpu_read_threadptr(void)
__asm__ __volatile__(
"rur.threadptr %0" : "=a"(threadptr));
#else
#error "Core support for XCHAL_HAVE_THREADPTR is required"
threadptr = *virtual_thread_ptr;
#endif
return threadptr;
}
Expand Down
38 changes: 31 additions & 7 deletions src/arch/xtensa/xtos/xtos-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <config.h>
#if CONFIG_SMP
#include <sof/lib/cpu.h>
#include <sof/lib/memory.h>
#endif
#include <sof/lib/memory.h>
#include <xtensa/config/core.h>
#include <xtensa/xtruntime.h>
#include <xtensa/xtruntime-frames.h>
Expand Down Expand Up @@ -405,32 +405,56 @@ XTOS_PENDING_OFS: .space 4 /* _xtos_pending variable */
.macro xtos_addr_percore ax, structure_name
#if XCHAL_HAVE_THREADPTR
rur.threadptr \ax
l32i \ax, \ax, XTOS_PTR_TO_\structure_name
#else
#error "SOF for Xtensa requires THREADPTR option"
j 1f
.align 4
.literal_position
2:
.word SOF_VIRTUAL_THREAD_BASE
1:
.align 4
l32r \ax, 2b
l32i \ax, \ax, 0
#endif
l32i \ax, \ax, XTOS_PTR_TO_\structure_name
.endm

// xtos_int_stack_addr_percore ax, int_level, stack_name
// Pointer to dedicated interrupt stack.
.macro xtos_int_stack_addr_percore ax, int_level, stack_name
#if XCHAL_HAVE_THREADPTR
rur.threadptr \ax
l32i \ax, \ax, XTOS_PTR_TO_\stack_name\()_&int_level
#else
#error "SOF for Xtensa requires THREADPTR option"
j 1f
.align 4
.literal_position
2:
.word SOF_VIRTUAL_THREAD_BASE
1:
.align 4
l32r \ax, 2b
l32i \ax, \ax, 0
#endif
l32i \ax, \ax, XTOS_PTR_TO_\stack_name\()_&int_level
.endm

// xtos_task_ctx_percore ax
// Pointer to structure per core.
.macro xtos_task_ctx_percore ax
#if XCHAL_HAVE_THREADPTR
rur.threadptr \ax
l32i \ax, \ax, XTOS_TASK_CONTEXT_OFFSET
#else
#error "SOF for Xtensa requires THREADPTR option"
j 1f
.align 4
.literal_position
2:
.word SOF_VIRTUAL_THREAD_BASE
1:
.align 4
l32r \ax, 2b
l32i \ax, \ax, 0
#endif
l32i \ax, \ax, XTOS_TASK_CONTEXT_OFFSET
.endm

#else /* !_ASMLANGUAGE && !__ASSEMBLER__ */
Expand Down
32 changes: 29 additions & 3 deletions src/platform/haswell/haswell.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ OUTPUT_ARCH(xtensa)
MEMORY
{
vector_reset_text :
org = XCHAL_RESET_VECTOR0_PADDR,
org = XCHAL_RESET_VECTOR_PADDR,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason of this change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change in core-isa.h, VECTOR0 no longer exists.

len = SOF_MEM_RESET_TEXT_SIZE
vector_reset_lit :
org = XCHAL_RESET_VECTOR0_PADDR + SOF_MEM_RESET_TEXT_SIZE,
org = XCHAL_RESET_VECTOR_PADDR + SOF_MEM_RESET_TEXT_SIZE,
len = SOF_MEM_RESET_LIT_SIZE
vector_base_text :
org = XCHAL_VECBASE_RESET_PADDR,
org = SOF_MEM_VECBASE_TEXT_BASE,
len = SOF_MEM_VECBASE_LIT_SIZE
vector_int2_lit :
org = XCHAL_INTLEVEL2_VECTOR_PADDR - SOF_MEM_VECT_LIT_SIZE,
Expand Down Expand Up @@ -101,6 +101,12 @@ MEMORY
sof_stack :
org = SOF_STACK_END,
len = SOF_STACK_BASE - SOF_STACK_END
mailbox :
org = MAILBOX_BASE,
len = MAILBOX_SIZE
virtual_thread :
org = SOF_VIRTUAL_THREAD_BASE,
len = SOF_VIRTUAL_THREAD_SIZE
static_log_entries_seg (!ari) :
org = LOG_ENTRY_ELF_BASE,
len = LOG_ENTRY_ELF_SIZE
Expand Down Expand Up @@ -138,6 +144,8 @@ PHDRS
system_runtime_heap_phdr PT_LOAD;
runtime_heap_phdr PT_LOAD;
buffer_heap_phdr PT_LOAD;
mailbox_phdr PT_LOAD;
virtual_thread_phdr PT_LOAD;
sof_stack_phdr PT_LOAD;
static_log_entries_phdr PT_NOTE;
}
Expand Down Expand Up @@ -436,6 +444,8 @@ SECTIONS
_stack_sentry = SOF_STACK_END;
__stack = SOF_STACK_BASE;

_virtual_thread_ptr = _virtual_thread_start;

.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
Expand Down Expand Up @@ -519,6 +529,22 @@ SECTIONS
_buffer_heap_end = ABSOLUTE(.);
} >buffer_heap :buffer_heap_phdr

.mailbox (NOLOAD) : ALIGN(8)
{
. = ALIGN (32);
_mailbox_start = ABSOLUTE(.);
. = . + MAILBOX_SIZE;
_mailbox_end = ABSOLUTE(.);
} >mailbox :mailbox_phdr

.virtual_thread (NOLOAD) : ALIGN(8)
{
. = ALIGN (32);
_virtual_thread_start = ABSOLUTE(.);
. = . + SOF_VIRTUAL_THREAD_SIZE;
_virtual_thread_end = ABSOLUTE(.);
} >virtual_thread :virtual_thread_phdr

.sof_stack (NOLOAD) : ALIGN(8)
{
. = ALIGN (4096);
Expand Down
Loading