⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpu.h

📁 RTEMS (Real-Time Executive for Multiprocessor Systems) is a free open source real-time operating sys
💻 H
📖 第 1 页 / 共 3 页
字号:
 *     1. Interrupt registers to save *     2. Task level registers to save * *  This means we have the following 3 context items: *     1. task level context stuff::  Context_Control *     2. floating point task stuff:: Context_Control_fp *     3. special interrupt level context :: Context_Control_interrupt * *  On some processors, it is cost-effective to save only the callee *  preserved registers during a task context switch.  This means *  that the ISR code needs to save those registers which do not *  persist across function calls.  It is not mandatory to make this *  distinctions between the caller/callee saves registers for the *  purpose of minimizing context saved during task switch and on interrupts. *  If the cost of saving extra registers is minimal, simplicity is the *  choice.  Save the same context on interrupt entry as for tasks in *  this case. * *  Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then *  care should be used in designing the context area. * *  On some CPUs with hardware floating point support, the Context_Control_fp *  structure will not be used or it simply consist of an array of a *  fixed number of bytes.   This is done when the floating point context *  is dumped by a "FP save context" type instruction and the format *  is not really defined by the CPU.  In this case, there is no need *  to figure out the exact format -- only the size.  Of course, although *  this is enough information for RTEMS, it is probably not enough for *  a debugger such as gdb.  But that is another problem. */typedef struct {    unsigned32 register_cpsr;    unsigned32 register_r4;    unsigned32 register_r5;    unsigned32 register_r6;    unsigned32 register_r7;    unsigned32 register_r8;    unsigned32 register_r9;    unsigned32 register_r10;    unsigned32 register_fp;    unsigned32 register_sp;    unsigned32 register_lr;    unsigned32 register_pc;} Context_Control;typedef struct {    double      some_float_register;} Context_Control_fp;typedef struct {    unsigned32 register_r0;    unsigned32 register_r1;    unsigned32 register_r2;    unsigned32 register_r3;    unsigned32 register_ip;    unsigned32 register_lr;} CPU_Exception_frame;typedef void (*cpuExcHandlerType) (CPU_Exception_frame*);extern cpuExcHandlerType _currentExcHandler;extern void rtems_exception_init_mngt();  /* *  The following structure defines the set of information saved *  on the current stack by RTEMS upon receipt of each interrupt *  that will lead to re-enter the kernel to signal the thread. */typedef CPU_Exception_frame CPU_Interrupt_frame;/* *  The following table contains the information required to configure *  the XXX processor specific parameters. */typedef struct {  void       (*pretasking_hook)( void );  void       (*predriver_hook)( void );  void       (*postdriver_hook)( void );  void       (*idle_task)( void );  boolean      do_zero_of_workspace;  unsigned32   idle_task_stack_size;  unsigned32   interrupt_stack_size;  unsigned32   extra_mpci_receive_server_stack;  void *     (*stack_allocate_hook)( unsigned32 );  void       (*stack_free_hook)( void* );  /* end of fields required on all CPUs */}   rtems_cpu_table;/* *  Macros to access required entires in the CPU Table are in  *  the file rtems/system.h. *//* *  Macros to access ARM specific additions to the CPU Table * *  none required *//* There are no CPU specific additions to the CPU Table for this port. *//* *  This variable is optional.  It is used on CPUs on which it is difficult *  to generate an "uninitialized" FP context.  It is filled in by *  _CPU_Initialize and copied into the task's FP context area during *  _CPU_Context_Initialize. */SCORE_EXTERN Context_Control_fp  _CPU_Null_fp_context;/* *  The size of the floating point context area.  On some CPUs this *  will not be a "sizeof" because the format of the floating point *  area is not defined -- only the size is.  This is usually on *  CPUs with a "floating point save context" instruction. */#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp )/* *  Amount of extra stack (above minimum stack size) required by *  MPCI receive server thread.  Remember that in a multiprocessor *  system this thread must exist and be able to process all directives. */#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0/* *  This defines the number of entries in the ISR_Vector_table managed *  by RTEMS. */#define CPU_INTERRUPT_NUMBER_OF_VECTORS      8#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER  (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1)/* *  This is defined if the port has a special way to report the ISR nesting *  level.  Most ports maintain the variable _ISR_Nest_level. */#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE/* *  Should be large enough to run all RTEMS tests.  This insures *  that a "reasonable" small application should not have any problems. */#define CPU_STACK_MINIMUM_SIZE          (1024*4)/* *  CPU's worst alignment requirement for data types on a byte boundary.  This *  alignment does not take into account the requirements for the stack. */#define CPU_ALIGNMENT              4/* *  This number corresponds to the byte alignment requirement for the *  heap handler.  This alignment requirement may be stricter than that *  for the data types alignment specified by CPU_ALIGNMENT.  It is *  common for the heap to follow the same alignment requirement as *  CPU_ALIGNMENT.  If the CPU_ALIGNMENT is strict enough for the heap, *  then this should be set to CPU_ALIGNMENT. * *  NOTE:  This does not have to be a power of 2.  It does have to *         be greater or equal to than CPU_ALIGNMENT. */#define CPU_HEAP_ALIGNMENT         CPU_ALIGNMENT/* *  This number corresponds to the byte alignment requirement for memory *  buffers allocated by the partition manager.  This alignment requirement *  may be stricter than that for the data types alignment specified by *  CPU_ALIGNMENT.  It is common for the partition to follow the same *  alignment requirement as CPU_ALIGNMENT.  If the CPU_ALIGNMENT is strict *  enough for the partition, then this should be set to CPU_ALIGNMENT. * *  NOTE:  This does not have to be a power of 2.  It does have to *         be greater or equal to than CPU_ALIGNMENT. */#define CPU_PARTITION_ALIGNMENT    CPU_ALIGNMENT/* *  This number corresponds to the byte alignment requirement for the *  stack.  This alignment requirement may be stricter than that for the *  data types alignment specified by CPU_ALIGNMENT.  If the CPU_ALIGNMENT *  is strict enough for the stack, then this should be set to 0. * *  NOTE:  This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. */#define CPU_STACK_ALIGNMENT        4/* ISR handler macros *//* *  Support routine to initialize the RTEMS vector table after it is allocated. */#define _CPU_Initialize_vectors() /* *  Disable all interrupts for an RTEMS critical section.  The previous *  level is returned in _level. */#define _CPU_ISR_Disable( _level )                \  {                                               \    int reg;                                       \    asm volatile ("MRS	%0, cpsr \n"               \                  "ORR  %1, %0, #0xc0 \n"          \                  "MSR  cpsr, %1 \n"               \                   : "=&r" (_level), "=&r" (reg)); \  }/* *  Enable interrupts to the previous level (returned by _CPU_ISR_Disable). *  This indicates the end of an RTEMS critical section.  The parameter *  _level is not modified. */#define _CPU_ISR_Enable( _level )               \  {                                             \    asm volatile ("MSR  cpsr, %0 \n"            \                  : : "r" (_level));            \  }/* *  This temporarily restores the interrupt to _level before immediately *  disabling them again.  This is used to divide long RTEMS critical *  sections into two or more parts.  The parameter _level is not * modified. */#define _CPU_ISR_Flash( _level ) \  { \    int reg;                                    \    asm volatile ("MRS	%0, cpsr \n"            \                  "MSR  cpsr, %1 \n"            \                  "MSR  cpsr, %0 \n"            \                  : "=&r" (reg)                 \                  : "r" (_level));              \  }/* *  Map interrupt level in task mode onto the hardware that the CPU *  actually provides.  Currently, interrupt levels which do not *  map onto the CPU in a generic fashion are undefined.  Someday, *  it would be nice if these were "mapped" by the application *  via a callout.  For example, m68k has 8 levels 0 - 7, levels *  8 - 255 would be available for bsp/application specific meaning. *  This could be used to manage a programmable interrupt controller *  via the rtems_task_mode directive. * *  The get routine usually must be implemented as a subroutine. */#define _CPU_ISR_Set_level( new_level )         \  {                                             \    int reg = 0; /* to avoid warning */         \    asm volatile ("MRS	%0, cpsr \n"            \                  "BIC  %0, %0, #0xc0 \n"       \                  "ORR  %0, %0, %2 \n"          \                  "MSR  cpsr_c, %0 \n"          \                  : "=r" (reg)                  \                  : "0" (reg), "r" (new_level)); \  }unsigned32 _CPU_ISR_Get_level( void );/* end of ISR handler macros *//* Context handler macros *//* *  Initialize the context to a state suitable for starting a *  task after a context restore operation.  Generally, this *  involves: * *     - setting a starting address *     - preparing the stack *     - preparing the stack and frame pointers *     - setting the proper interrupt level in the context *     - initializing the floating point context * *  This routine generally does not set any unnecessary register *  in the context.  The state of the "general data" registers is *  undefined at task start time. * *  NOTE: This is_fp parameter is TRUE if the thread is to be a floating *        point thread.  This is typically only used on CPUs where the *        FPU may be easily disabled by software such as on the SPARC *        where the PSR contains an enable FPU bit. */void _CPU_Context_Initialize(  Context_Control  *the_context,  unsigned32       *stack_base,  unsigned32        size,  unsigned32        new_level,  void             *entry_point,  boolean           is_fp);/* *  This routine is responsible for somehow restarting the currently *  executing task.  If you are lucky, then all that is necessary

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -