RTEMS 7.0-rc1
Loading...
Searching...
No Matches
cpu.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * This include file contains information pertaining to the XXX
14 * processor.
15 *
16 * @note This file is part of a porting template that is intended
17 * to be used as the starting point when porting RTEMS to a new
18 * CPU family. The following needs to be done when using this as
19 * the starting point for a new port:
20 *
21 * + Anywhere there is an XXX, it should be replaced
22 * with information about the CPU family being ported to.
23 *
24 * + At the end of each comment section, there is a heading which
25 * says "Port Specific Information:". When porting to RTEMS,
26 * add CPU family specific information in this section
27 */
28
29/*
30 * COPYRIGHT (c) 1989-2008.
31 * On-Line Applications Research Corporation (OAR).
32 *
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
35 * are met:
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
46 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52 * POSSIBILITY OF SUCH DAMAGE.
53 */
54
55#ifndef _RTEMS_SCORE_CPU_H
56#define _RTEMS_SCORE_CPU_H
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
63#include <rtems/score/no_cpu.h>
64
65/* conditional compilation parameters */
66
78#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
79
89#define CPU_ISR_PASSES_FRAME_POINTER FALSE
90
126#if ( NO_CPU_HAS_FPU == 1 )
127#define CPU_HARDWARE_FP TRUE
128#else
129#define CPU_HARDWARE_FP FALSE
130#endif
131#define CPU_SOFTWARE_FP FALSE
132
157#define CPU_ALL_TASKS_ARE_FP TRUE
158
174#define CPU_IDLE_TASK_IS_FP FALSE
175
205#define CPU_USE_DEFERRED_FP_SWITCH TRUE
206
217#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE
218
230#define CPU_STACK_GROWS_UP TRUE
231
237#define CPU_CACHE_LINE_BYTES 32
238
250#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES )
251
263#define CPU_MODES_INTERRUPT_MASK 0x00000001
264
269#define CPU_MAXIMUM_PROCESSORS 32
270
277#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
278
279/*
280 * Processor defined structures required for cpukit/score.
281 *
282 * Port Specific Information:
283 *
284 * XXX document implementation including references if appropriate
285 */
286
287/* may need to put some structures here. */
288
350typedef struct {
361
367
368#ifdef RTEMS_SMP
413 volatile bool is_executing;
414#endif
416
428#define _CPU_Context_Get_SP( _context ) \
429 (uintptr_t)(_context)->stack_pointer
430
437typedef struct {
441
449typedef struct {
455 uint32_t special_interrupt_register;
457
468extern Context_Control_fp _CPU_Null_fp_context;
469
488/*
489 * Nothing prevents the porter from declaring more CPU specific variables.
490 *
491 * Port Specific Information:
492 *
493 * XXX document implementation including references if appropriate
494 */
495
496/* XXX: if needed, put more variables here */
497
510#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )
511
521#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
522
533#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32
534
545#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)
546
553#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE
554
566#define CPU_STACK_MINIMUM_SIZE (1024*4)
567
575#define CPU_SIZEOF_POINTER 4
576
588#define CPU_ALIGNMENT 8
589
612#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT
613
626#define CPU_STACK_ALIGNMENT CPU_HEAP_ALIGNMENT
627
634#define CPU_INTERRUPT_STACK_ALIGNMENT CPU_CACHE_LINE_BYTES
635
636/*
637 * ISR handler macros
638 */
639
652#define _CPU_ISR_Disable( _isr_cookie ) \
653 { \
654 (_isr_cookie) = 0; /* do something to prevent warnings */ \
655 }
656
670#define _CPU_ISR_Enable( _isr_cookie ) \
671 { \
672 }
673
688#define _CPU_ISR_Flash( _isr_cookie ) \
689 { \
690 }
691
701static inline bool _CPU_ISR_Is_enabled( uint32_t level )
702{
703 return false;
704}
705
723#define _CPU_ISR_Set_level( new_level ) \
724 { \
725 }
726
739uint32_t _CPU_ISR_Get_level( void );
740
741/* end of ISR handler macros */
742
743/* Context handler macros */
744
760#define _CPU_Context_Destroy( _the_thread, _the_context ) \
761 { \
762 }
763
801#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \
802 _isr, _entry_point, _is_fp, _tls_area ) \
803 { \
804 }
805
821#define _CPU_Context_Restart_self( _the_context ) \
822 _CPU_Context_restore( (_the_context) );
823
842#define _CPU_Context_Initialize_fp( _destination ) \
843 { \
844 *(*(_destination)) = _CPU_Null_fp_context; \
845 }
846
847/* end of Context handler macros */
848
849/* Bitfield handler macros */
850
866#define CPU_USE_GENERIC_BITFIELD_CODE TRUE
867
932#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
933#define _CPU_Bitfield_Find_first_bit( _value, _output ) \
934 { \
935 (_output) = 0; /* do something to prevent warnings */ \
936 }
937#endif
938
941/* end of Bitfield handler macros */
942
952#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
953
954#define _CPU_Priority_Mask( _bit_number ) \
955 ( 1 << (_bit_number) )
956
957#endif
958
973#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE)
974
975#define _CPU_Priority_bits_index( _priority ) \
976 (_priority)
977
978#endif
979
980/* end of Priority handler macros */
981
982/* functions */
983
991void _CPU_Initialize(void);
992
993typedef void ( *CPU_ISR_raw_handler )( void );
994
1012 uint32_t vector,
1013 CPU_ISR_raw_handler new_handler,
1014 CPU_ISR_raw_handler *old_handler
1015);
1016
1017typedef void ( *CPU_ISR_handler )( uint32_t );
1018
1036 uint32_t vector,
1037 CPU_ISR_handler new_handler,
1038 CPU_ISR_handler *old_handler
1039);
1040
1048RTEMS_NO_RETURN void *_CPU_Thread_Idle_body( uintptr_t ignored );
1049
1067 Context_Control *executing,
1068 Context_Control *heir
1069);
1070
1086RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
1087 Context_Control *executing,
1088 Context_Control *heir
1089);
1090
1105RTEMS_NO_RETURN void _CPU_Context_restore( Context_Control *new_context );
1106
1123 Context_Control_fp **fp_context_ptr
1124);
1125
1142 Context_Control_fp **fp_context_ptr
1143);
1144
1154typedef struct {
1155 uint32_t processor_state_register;
1156 uint32_t integer_registers [1];
1157 double float_registers [1];
1159
1166
1167#ifdef RTEMS_EXCEPTION_EXTENSIONS
1177 RTEMS_NO_RETURN void _CPU_Exception_resume( CPU_Exception_frame *frame );
1178
1191 RTEMS_NO_RETURN void _CPU_Exception_dispatch_and_resume(
1192 CPU_Exception_frame *frame
1193 );
1194
1201 void _CPU_Exception_disable_thread_dispatch( void );
1202
1210 int _CPU_Exception_frame_get_signal( CPU_Exception_frame *frame );
1211
1218 void _CPU_Exception_frame_set_resume( CPU_Exception_frame *frame, void *address );
1219
1227 void _CPU_Exception_frame_make_resume_next_instruction( CPU_Exception_frame *frame );
1228#endif
1229
1267static inline uint32_t CPU_swap_u32(
1268 uint32_t value
1269)
1270{
1271 uint32_t byte1, byte2, byte3, byte4, swapped;
1272
1273 byte4 = (value >> 24) & 0xff;
1274 byte3 = (value >> 16) & 0xff;
1275 byte2 = (value >> 8) & 0xff;
1276 byte1 = value & 0xff;
1277
1278 swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4;
1279 return swapped;
1280}
1281
1288#define CPU_swap_u16( value ) \
1289 (((value&0xff) << 8) | ((value >> 8)&0xff))
1290
1296typedef uint32_t CPU_Counter_ticks;
1297
1303uint32_t _CPU_Counter_frequency( void );
1304
1318CPU_Counter_ticks _CPU_Counter_read( void );
1319
1320#ifdef RTEMS_SMP
1334 uint32_t _CPU_SMP_Initialize( void );
1335
1349 bool _CPU_SMP_Start_processor( uint32_t cpu_index );
1350
1365 void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
1366
1377 void _CPU_SMP_Prepare_start_multitasking( void );
1378
1386 static inline uint32_t _CPU_SMP_Get_current_processor( void )
1387 {
1388 return 123;
1389 }
1390
1399 void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
1400
1406 static inline bool _CPU_Context_Get_is_executing(
1407 const Context_Control *context
1408 )
1409 {
1410 return context->is_executing;
1411 }
1412
1419 static inline void _CPU_Context_Set_is_executing(
1420 Context_Control *context,
1421 bool is_executing
1422 )
1423 {
1424 context->is_executing = is_executing;
1425 }
1426
1428typedef uintptr_t CPU_Uint32ptr;
1429
1430#endif
1431
1432#ifdef __cplusplus
1433}
1434#endif
1435
1436#endif
This header file provides basic definitions used by the API and the implementation.
void _CPU_ISR_install_raw_handler(uint32_t vector, CPU_ISR_raw_handler new_handler, CPU_ISR_raw_handler *old_handler)
SPARC specific raw ISR installer.
Definition: cpu.c:120
#define RTEMS_NO_RETURN
Tells the compiler in a function declaration that this function does not return.
Definition: basedefs.h:386
uint32_t _CPU_ISR_Get_level(void)
Returns the interrupt level of the executing thread.
Definition: cpu.c:167
void * _CPU_Thread_Idle_body(uintptr_t ignored)
Definition: m68kidle.c:39
void _CPU_Initialize(void)
CPU initialization.
Definition: cpu.c:47
uintptr_t CPU_Uint32ptr
Definition: cpu.h:611
void _CPU_Exception_frame_print(const CPU_Exception_frame *frame)
Prints the exception frame via printk().
Definition: vectorexceptions.c:64
uint32_t _CPU_Counter_frequency(void)
Gets the current CPU counter frequency in Hz.
Definition: system-clocks.c:125
void _CPU_Context_switch(Context_Control *run, Context_Control *heir)
CPU switch context.
Definition: cpu_asm.c:110
CPU_Counter_ticks _CPU_Counter_read(void)
Gets the current CPU counter value.
Definition: system-clocks.c:130
void _CPU_ISR_install_vector(uint32_t vector, CPU_ISR_handler hdl, CPU_ISR_handler *oldHdl)
SPARC specific RTEMS ISR installer.
Definition: idt.c:108
#define _CPU_Context_restore_fp(_fp_context_ptr)
Nothing to do due to the synchronous or lazy floating point switch.
Definition: cpu.h:901
#define _CPU_Context_save_fp(_fp_context_ptr)
Nothing to do due to the synchronous or lazy floating point switch.
Definition: cpu.h:895
The set of registers that specifies the complete processor state.
Definition: cpu.h:500
Interrupt stack frame (ISF).
Definition: cpuimpl.h:64
SPARC basic context.
Definition: cpu.h:213
double some_float_register
Definition: cpu.h:439
Thread register context.
Definition: cpu.h:173
uint32_t some_integer_register
Definition: cpu.h:355
uint32_t some_system_register
Definition: cpu.h:360
uint32_t stack_pointer
Definition: cpu.h:366