summaryrefslogtreecommitdiffstats
path: root/cpukit/score/cpu/microblaze/include
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/cpu/microblaze/include')
-rw-r--r--cpukit/score/cpu/microblaze/include/machine/elf_machdep.h83
-rw-r--r--cpukit/score/cpu/microblaze/include/rtems/score/cpu.h198
-rw-r--r--cpukit/score/cpu/microblaze/include/rtems/score/cpuatomic.h41
-rw-r--r--cpukit/score/cpu/microblaze/include/rtems/score/cpuimpl.h28
4 files changed, 288 insertions, 62 deletions
diff --git a/cpukit/score/cpu/microblaze/include/machine/elf_machdep.h b/cpukit/score/cpu/microblaze/include/machine/elf_machdep.h
new file mode 100644
index 0000000000..e6d661c596
--- /dev/null
+++ b/cpukit/score/cpu/microblaze/include/machine/elf_machdep.h
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 On-Line Applications Research Corporation (OAR)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MICROBLAZE_ELF_MACHDEP_H_
+#define _MICROBLAZE_ELF_MACHDEP_H_
+
+#define ELF64_MACHDEP_ID EM_MICROBLAZE
+#define ELF32_MACHDEP_ID EM_MICROBLAZE
+
+#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
+#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
+
+#define ELF32_MACHDEP_ID_CASES \
+ case EM_MICROBLAZE: \
+ break;
+
+#define ELF64_MACHDEP_ID_CASES \
+ case EM_MICROBLAZE: \
+ break;
+
+#define KERN_ELFSIZE 32
+#define ARCH_ELFSIZE 32 /* MD native binary size */
+
+/* Processor specific relocation types */
+
+#define R_MICROBLAZE_NONE 0
+#define R_MICROBLAZE_32 1
+#define R_MICROBLAZE_32_PCREL 2
+#define R_MICROBLAZE_64_PCREL 3
+#define R_MICROBLAZE_32_PCREL_LO 4
+#define R_MICROBLAZE_64 5
+#define R_MICROBLAZE_32_LO 6
+#define R_MICROBLAZE_SRO32 7
+#define R_MICROBLAZE_SRW32 8
+#define R_MICROBLAZE_64_NONE 9
+#define R_MICROBLAZE_32_SYM_OP_SYM 10
+#define R_MICROBLAZE_GNU_VTINHERIT 11
+#define R_MICROBLAZE_GNU_VTENTRY 12
+#define R_MICROBLAZE_GOTPC_64 13
+#define R_MICROBLAZE_GOT_64 14
+#define R_MICROBLAZE_PLT_64 15
+#define R_MICROBLAZE_REL 16
+#define R_MICROBLAZE_JUMP_SLOT 17
+#define R_MICROBLAZE_GLOB_DAT 18
+#define R_MICROBLAZE_GOTOFF_64 19
+#define R_MICROBLAZE_GOTOFF_32 20
+#define R_MICROBLAZE_COPY 21
+#define R_MICROBLAZE_TLS 22
+#define R_MICROBLAZE_TLSGD 23
+#define R_MICROBLAZE_TLSLD 24
+#define R_MICROBLAZE_TLSDTPMOD32 25
+#define R_MICROBLAZE_TLSDTPREL32 26
+#define R_MICROBLAZE_TLSDTPREL64 27
+#define R_MICROBLAZE_TLSGOTTPREL32 28
+#define R_MICROBLAZE_TLSTPREL32 29
+
+#define R_TYPE( name ) R_MICROBLAZE_##name
+
+#endif /* _MICROBLAZE_ELF_MACHDEP_H_ */
diff --git a/cpukit/score/cpu/microblaze/include/rtems/score/cpu.h b/cpukit/score/cpu/microblaze/include/rtems/score/cpu.h
index 4b11625463..3d865732d6 100644
--- a/cpukit/score/cpu/microblaze/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/microblaze/include/rtems/score/cpu.h
@@ -65,6 +65,44 @@
#define CPU_MODES_INTERRUPT_MASK 0x00000001
+#define MICROBLAZE_EXCEPTION_FRAME_R1 0
+#define MICROBLAZE_EXCEPTION_FRAME_R2 4
+#define MICROBLAZE_EXCEPTION_FRAME_R3 8
+#define MICROBLAZE_EXCEPTION_FRAME_R4 12
+#define MICROBLAZE_EXCEPTION_FRAME_R5 16
+#define MICROBLAZE_EXCEPTION_FRAME_R6 20
+#define MICROBLAZE_EXCEPTION_FRAME_R7 24
+#define MICROBLAZE_EXCEPTION_FRAME_R8 28
+#define MICROBLAZE_EXCEPTION_FRAME_R9 32
+#define MICROBLAZE_EXCEPTION_FRAME_R10 36
+#define MICROBLAZE_EXCEPTION_FRAME_R11 40
+#define MICROBLAZE_EXCEPTION_FRAME_R12 44
+#define MICROBLAZE_EXCEPTION_FRAME_R13 48
+#define MICROBLAZE_EXCEPTION_FRAME_R14 52
+#define MICROBLAZE_EXCEPTION_FRAME_R15 56
+#define MICROBLAZE_EXCEPTION_FRAME_R16 60
+#define MICROBLAZE_EXCEPTION_FRAME_R17 64
+#define MICROBLAZE_EXCEPTION_FRAME_R18 68
+#define MICROBLAZE_EXCEPTION_FRAME_R19 72
+#define MICROBLAZE_EXCEPTION_FRAME_R20 76
+#define MICROBLAZE_EXCEPTION_FRAME_R21 80
+#define MICROBLAZE_EXCEPTION_FRAME_R22 84
+#define MICROBLAZE_EXCEPTION_FRAME_R23 88
+#define MICROBLAZE_EXCEPTION_FRAME_R24 92
+#define MICROBLAZE_EXCEPTION_FRAME_R25 96
+#define MICROBLAZE_EXCEPTION_FRAME_R26 100
+#define MICROBLAZE_EXCEPTION_FRAME_R27 104
+#define MICROBLAZE_EXCEPTION_FRAME_R28 108
+#define MICROBLAZE_EXCEPTION_FRAME_R29 112
+#define MICROBLAZE_EXCEPTION_FRAME_R30 116
+#define MICROBLAZE_EXCEPTION_FRAME_R31 120
+#define MICROBLAZE_EXCEPTION_FRAME_MSR 124
+#define MICROBLAZE_EXCEPTION_FRAME_EAR 128
+#define MICROBLAZE_EXCEPTION_FRAME_ESR 132
+#define MICROBLAZE_EXCEPTION_FRAME_BTR 136
+
+#define CPU_EXCEPTION_FRAME_SIZE 140
+
#ifndef ASM
#ifdef __cplusplus
@@ -99,6 +137,7 @@ typedef struct {
uint32_t r30;
uint32_t r31;
uint32_t rmsr;
+ void *thread_pointer;
} Context_Control;
/**
@@ -139,8 +178,27 @@ typedef struct {
#define CPU_INTERRUPT_STACK_ALIGNMENT CPU_CACHE_LINE_BYTES
-#define MICROBLAZE_MSR_IE (1 << 1)
-#define MICROBLAZE_MSR_EE (1 << 8)
+/*
+ * bit definitions in the documentation are reversed for all special registers
+ * such that bit 0 is the most significant bit
+ */
+#define MICROBLAZE_MSR_VM ( 1 << 13 )
+#define MICROBLAZE_MSR_UM ( 1 << 11 )
+#define MICROBLAZE_MSR_PVR ( 1 << 10 )
+#define MICROBLAZE_MSR_EIP ( 1 << 9 )
+#define MICROBLAZE_MSR_EE ( 1 << 8 )
+#define MICROBLAZE_MSR_DCE ( 1 << 7 )
+#define MICROBLAZE_MSR_DZO ( 1 << 6 )
+#define MICROBLAZE_MSR_ICE ( 1 << 5 )
+#define MICROBLAZE_MSR_FSL ( 1 << 4 )
+#define MICROBLAZE_MSR_BIP ( 1 << 3 )
+#define MICROBLAZE_MSR_C ( 1 << 2 )
+#define MICROBLAZE_MSR_IE ( 1 << 1 )
+
+#define MICROBLAZE_ESR_DS ( 1 << 12 )
+#define MICROBLAZE_ESR_EC_MASK 0x1f
+#define MICROBLAZE_ESR_ESS_MASK 0x7f
+#define MICROBLAZE_ESR_ESS_SHIFT 5
#define _CPU_MSR_GET( _msr_value ) \
do { \
@@ -151,11 +209,35 @@ typedef struct {
#define _CPU_MSR_SET( _msr_value ) \
{ __asm__ volatile ("mts rmsr, %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); }
+#define MICROBLAZE_PVR0_VERSION_GET( _pvr0_value ) \
+ ( ( _pvr0_value >> 8 ) & 0xff )
+
+#define _CPU_PVR0_GET( _pvr0_value ) \
+ do { \
+ ( _pvr0_value ) = 0; \
+ __asm__ volatile ( "mfs %0, rpvr0" : "=&r" ( ( _pvr0_value ) ) ); \
+ } while ( 0 )
+
+#define MICROBLAZE_PVR3_BP_GET( _pvr3_value ) \
+ ( ( _pvr3_value >> 25 ) & 0xf )
+
+#define MICROBLAZE_PVR3_RWP_GET( _pvr3_value ) \
+ ( ( _pvr3_value >> 19 ) & 0x7 )
+
+#define MICROBLAZE_PVR3_WWP_GET( _pvr3_value ) \
+ ( ( _pvr3_value >> 13 ) & 0x7 )
+
+#define _CPU_PVR3_GET( _pvr3_value ) \
+ do { \
+ ( _pvr3_value ) = 0; \
+ __asm__ volatile ( "mfs %0, rpvr3" : "=&r" ( ( _pvr3_value ) ) ); \
+ } while ( 0 )
+
#define _CPU_ISR_Disable( _isr_cookie ) \
{ \
unsigned int _new_msr; \
_CPU_MSR_GET(_isr_cookie); \
- _new_msr = (_isr_cookie) & ~(MICROBLAZE_MSR_IE | MICROBLAZE_MSR_EE); \
+ _new_msr = (_isr_cookie) & ~(MICROBLAZE_MSR_IE); \
_CPU_MSR_SET(_new_msr); \
}
@@ -164,9 +246,9 @@ typedef struct {
uint32_t _microblaze_interrupt_enable; \
uint32_t _microblaze_switch_reg; \
\
- _microblaze_interrupt_enable = (_isr_cookie) & (MICROBLAZE_MSR_IE | MICROBLAZE_MSR_EE); \
+ _microblaze_interrupt_enable = (_isr_cookie) & (MICROBLAZE_MSR_IE); \
_CPU_MSR_GET(_microblaze_switch_reg); \
- _microblaze_switch_reg &= ~(MICROBLAZE_MSR_IE | MICROBLAZE_MSR_EE); \
+ _microblaze_switch_reg &= ~(MICROBLAZE_MSR_IE); \
_microblaze_switch_reg |= _microblaze_interrupt_enable; \
_CPU_MSR_SET(_microblaze_switch_reg); \
}
@@ -175,7 +257,7 @@ typedef struct {
{ \
unsigned int _new_msr; \
_CPU_MSR_SET(_isr_cookie); \
- _new_msr = (_isr_cookie) & ~(MICROBLAZE_MSR_IE | MICROBLAZE_MSR_EE); \
+ _new_msr = (_isr_cookie) & ~(MICROBLAZE_MSR_IE); \
_CPU_MSR_SET(_new_msr); \
}
@@ -183,9 +265,9 @@ void _CPU_ISR_Set_level( uint32_t level );
uint32_t _CPU_ISR_Get_level( void );
-RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level )
+static inline bool _CPU_ISR_Is_enabled( uint32_t level )
{
- return ( level & (MICROBLAZE_MSR_IE | MICROBLAZE_MSR_EE) ) != 0;
+ return ( level & MICROBLAZE_MSR_IE ) != 0;
}
void _CPU_Context_Initialize(
@@ -228,8 +310,42 @@ void _CPU_Context_Initialize(
#define CPU_PER_CPU_CONTROL_SIZE 0
typedef struct {
- /* TODO: enumerate registers */
- uint32_t r[32];
+ /* r0 is unnecessary since it is always 0 */
+ uint32_t r1;
+ uint32_t r2;
+ uint32_t r3; /* return 1/scratch */
+ uint32_t r4; /* return 2/scratch */
+ uint32_t r5; /* param 1/scratch */
+ uint32_t r6; /* param 2/scratch */
+ uint32_t r7; /* param 3/scratch */
+ uint32_t r8; /* param 4/scratch */
+ uint32_t r9; /* param 5/scratch */
+ uint32_t r10; /* param 6/scratch */
+ uint32_t r11; /* scratch */
+ uint32_t r12; /* scratch */
+ uint32_t r13;
+ uint32_t *r14; /* Interrupt Link Register */
+ uint32_t *r15; /* Link Register */
+ uint32_t *r16; /* Trap/Debug Link Register */
+ uint32_t *r17; /* Exception Link Register */
+ uint32_t r18;
+ uint32_t r19;
+ uint32_t r20;
+ uint32_t r21;
+ uint32_t r22;
+ uint32_t r23;
+ uint32_t r24;
+ uint32_t r25;
+ uint32_t r26;
+ uint32_t r27;
+ uint32_t r28;
+ uint32_t r29;
+ uint32_t r30;
+ uint32_t r31;
+ uint32_t msr; /* Machine Status Register */
+ uint32_t *ear; /* Exception Address Register */
+ uint32_t esr; /* Exception Status Register */
+ uint32_t *btr; /* Branch Target Register */
} CPU_Exception_frame;
/* end of Priority handler macros */
@@ -246,11 +362,65 @@ void _CPU_ISR_install_vector(
CPU_ISR_handler *old_handler
);
+typedef void ( *MicroBlaze_Exception_handler )( CPU_Exception_frame *ef );
+
+void _MicroBlaze_Exception_install_handler(
+ MicroBlaze_Exception_handler new_handler,
+ MicroBlaze_Exception_handler *old_handler
+);
+
+void _MicroBlaze_Exception_handle(
+ CPU_Exception_frame *ef
+);
+
+void _MicroBlaze_Debug_install_handler(
+ MicroBlaze_Exception_handler new_handler,
+ MicroBlaze_Exception_handler *old_handler
+);
+
+void _MicroBlaze_Debug_handle(
+ CPU_Exception_frame *ef
+);
+
void _CPU_Context_switch(
Context_Control *run,
Context_Control *heir
);
+/* Selects the appropriate resume function based on CEF state */
+RTEMS_NO_RETURN void _CPU_Exception_resume( CPU_Exception_frame *frame );
+
+RTEMS_NO_RETURN void _MicroBlaze_Exception_resume_from_exception(
+ CPU_Exception_frame *frame
+);
+
+RTEMS_NO_RETURN void _MicroBlaze_Exception_resume_from_break(
+ CPU_Exception_frame *frame
+);
+
+/*
+ * Only functions for exception cases since debug exception frames will never
+ * need dispatch
+ */
+RTEMS_NO_RETURN void _CPU_Exception_dispatch_and_resume(
+ CPU_Exception_frame *frame
+);
+
+void _CPU_Exception_disable_thread_dispatch( void );
+
+int _CPU_Exception_frame_get_signal( CPU_Exception_frame *frame );
+
+void _CPU_Exception_frame_set_resume(
+ CPU_Exception_frame *frame,
+ void *address
+);
+
+void _CPU_Exception_frame_make_resume_next_instruction(
+ CPU_Exception_frame *frame
+);
+
+uint32_t *_MicroBlaze_Get_return_address( CPU_Exception_frame *ef );
+
RTEMS_NO_RETURN void _CPU_Context_restore(
Context_Control *new_context
);
@@ -281,14 +451,6 @@ uint32_t _CPU_Counter_frequency( void );
CPU_Counter_ticks _CPU_Counter_read( void );
-static inline CPU_Counter_ticks _CPU_Counter_difference(
- CPU_Counter_ticks second,
- CPU_Counter_ticks first
-)
-{
- return second - first;
-}
-
void *_CPU_Thread_Idle_body( uintptr_t ignored );
void bsp_interrupt_dispatch( uint32_t source );
diff --git a/cpukit/score/cpu/microblaze/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/microblaze/include/rtems/score/cpuatomic.h
deleted file mode 100644
index 6dc769b95a..0000000000
--- a/cpukit/score/cpu/microblaze/include/rtems/score/cpuatomic.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* SPDX-License-Identifier: BSD-2-Clause */
-
-/**
- * @file
- *
- * @ingroup RTEMSScoreCPU
- *
- * @brief MicroBlaze atomic support
- */
-
-/*
- * Copyright (C) 2021 On-Line Applications Research Corporation (OAR)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _RTEMS_SCORE_ATOMIC_CPU_H
-#define _RTEMS_SCORE_ATOMIC_CPU_H
-
-#include <rtems/score/cpustdatomic.h>
-
-#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */
diff --git a/cpukit/score/cpu/microblaze/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/microblaze/include/rtems/score/cpuimpl.h
index 3d0167dd40..760ebbfbbb 100644
--- a/cpukit/score/cpu/microblaze/include/rtems/score/cpuimpl.h
+++ b/cpukit/score/cpu/microblaze/include/rtems/score/cpuimpl.h
@@ -49,7 +49,10 @@
*/
#define CPU_PER_CPU_CONTROL_SIZE 0
-#define CPU_INTERRUPT_FRAME_SIZE 52
+
+#define CPU_INTERRUPT_FRAME_SIZE 56
+
+#define CPU_THREAD_LOCAL_STORAGE_VARIANT 10
#define MICROBLAZE_INTERRUPT_FRAME_R3 0
#define MICROBLAZE_INTERRUPT_FRAME_R4 4
@@ -64,6 +67,7 @@
#define MICROBLAZE_INTERRUPT_FRAME_R14 40
#define MICROBLAZE_INTERRUPT_FRAME_R15 44
#define MICROBLAZE_INTERRUPT_FRAME_R18 48
+#define MICROBLAZE_INTERRUPT_FRAME_MSR 52
#ifndef ASM
@@ -75,16 +79,34 @@ void _CPU_Context_volatile_clobber( uintptr_t pattern );
void _CPU_Context_validate( uintptr_t pattern );
-RTEMS_INLINE_ROUTINE void _CPU_Instruction_illegal( void )
+static inline void _CPU_Instruction_illegal( void )
{
__asm__ volatile ( ".word 0x0" );
}
-RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void )
+static inline void _CPU_Instruction_no_operation( void )
{
__asm__ volatile ( "nop" );
}
+static inline void _CPU_Use_thread_local_storage(
+ const Context_Control *context
+)
+{
+ /*
+ * There is nothing to do since the thread-local storage area is obtained by
+ * calling __tls_get_addr().
+ */
+ (void) context;
+}
+
+static inline void *_CPU_Get_TLS_thread_pointer(
+ const Context_Control *context
+)
+{
+ return (void *) context->thread_pointer;
+}
+
#ifdef __cplusplus
}
#endif