Changes between Version 49 and Version 50 of Developer/Projects/SequencedInitialization


Ignore:
Timestamp:
06/15/10 16:26:24 (14 years ago)
Author:
Sh
Comment:

Order domain changes

Legend:

Unmodified
Added
Removed
Modified
  • Developer/Projects/SequencedInitialization

    v49 v50  
    177177there is no similar call like rtems_message_queue_creat which the application must call or
    178178it will fail. So we must consider another method to solve this problem.
    179 =  Components Of Rtems Sequenced Initialization API  =
    180 
    181 
    182 # The rule of sort order
    183 
    184 # The definition of rtems Sysinit_Entry struct and its reference
    185 
    186 # The method of referencing the Sysinit_Entry struct
    187 
    188 ; Rule of sort order
    189 
    190 We use a combination of three domains to define the order of initialization sequence, the three
    191 domains are {subsystem, order, index}. Every domain is an key word to sort.
    192 
    193 Sort order API:
    194  /**
    195   * @brief the first domain is subsystem
    196   */
    197  #define SYSINIT_CLASS_API  0001
    198  /**
    199   * @brief the second domain is order like before,nomal,after
    200   */
    201  #define SYSINIT_ORDER_BEFORE    0
    202  #define SYSINIT_ORDER_NOMAL     1
    203  #define SYSINIT_ORDER_AFTER     2
    204  /**
    205   * @brief the third domain is index
    206   */
    207  #define SYSINIT_INDEX_FIRST    0000   /* first*/
    208  #define SYSINIT_INDEX_SECOND   0001   /* second*/
    209  #define SYSINIT_INDEX_THIRD    0002   /* third*/
    210  #define SYSINIT_INDEX_FOURTH   0003   /* fourth*/
    211  #define SYSINIT_INDEX_FIFTH    0004   /* fifth*/
    212  #define SYSINIT_INDEX_SIXTH    0005   /* sixth*/
    213  #define SYSINIT_INDEX_SEVENTH  0006   /* seventh*/
    214  #define SYSINIT_INDEX_EIGHTH   0007   /* eighth*/
    215  #define SYSINIT_INDEX_NINTH    0008   /* ninth*/
    216  #define SYSINIT_INDEX_TENTH    0009   /* tenth*/
    217  #define SYSINIT_INDEX_ELEVENTH  0010   /* eleventh*/
    218  #define SYSINIT_INDEX_TWELFTH   0011   /* twelfth */
    219 
    220 ; The definition of rtems sysinit_core struct and its reference:
    221 
    222 The field of struct Sysinit_Entry will be extended in the futurn, now there is only one field filling in the struct. the field handler is the entry function of rtems sequenced initialization or termination.
     179=  Components of the API  =
     180
     181
     182We use a combination of three domains to define the order of initialization sequence, the two
     183domains are (group, index). Every domain is an key word to sort.
     184
     185The fields of Sysinit_Entry may be extended in the future, now there is only one field filling in the structure. The field handler is the entry function of RTEMS sequenced initialization or termination.
    223186
    224187 /**
     
    243206
    244207 #define SYSINIT_MAKE_ORDER(group, index) \
    245    #group "." #index
    246  
     208   group "." index
     209 
     210 #define SYSINIT_MAKE_INDEX(i3, i2, i1, i0) \
     211   #i3 #i2 #i1 #i0
     212 
     213 #define SYSINIT_INDEX_FIRST SYSINIT_MAKE_INDEX(0, 0, 0, 0)
     214 #define SYSINIT_INDEX_MIDDLE SYSINIT_MAKE_INDEX(5, 0, 0, 0)
     215 #define SYSINIT_INDEX_LAST SYSINIT_MAKE_INDEX(9, 9, 9, 9)
     216 
     217 #define SYSINIT_GROUP_FIRST "0000"
     218 #define SYSINIT_GROUP_EVENT "0110"
     219 #define SYSINIT_GROUP_SEMAPHORE "0120"
     220 #define SYSINIT_GROUP_LAST "9999"
     221
    247222 #define SYSINIT_ENTRY_NAME(handler) \
    248223   _Sysinit_Entry_ ## handler
     
    254229   extern const Sysinit_Entry SYSINIT_ENTRY_NAME(handler)
    255230 
    256  #define SYSINIT_ENTRY(handler) \
     231 #define SYSINIT_ENTRY(handler, group) \
    257232   SYSINIT_DECLARE_ENTRY(handler); \
    258233   const Sysinit_Entry SYSINIT_ENTRY_NAME(handler) \
    259    __attribute__((section(".score.sysinit." SYSINIT_MAKE_ORDER(0, 0)))) \
     234   __attribute__((section(".score.sysinit." SYSINIT_MAKE_ORDER(group, SYSINIT_INDEX_MIDDLE)))) \
    260235   = { handler }
    261236 
     
    266241   = &SYSINIT_ENTRY_NAME(handler)
    267242
    268 ; The method of referencing the Sysinit_Entry struct
    269 
    270243The implement of referencing the sequenced initialization struct. In the every C source code file include initialization function we define a sequenced initialization struct which contain the init function entry. And then a reference function point will be defined in the another file include a function which will be called if this object is used by application. For example
    271244,consider the RTEMS Message API. In the RTEMS Message API's initialization call's source file we create a structure Sysinit_Entry include the field of the RTEMS Message API's initialization call entry. Then we reference this variable from the source file containing the rtems_message_queue_create code. Because the application must make a call to rtems_message_queue_create or all the other Message API calls will fail therefore this API needs only one reference from a single source file. But there is also a exception that if the application use RTEMS Event and RTEMS Signal API there is no similar call like rtems_message_queue_creat which the application must call or it will fail. '''So we must consider another method to solve this problem. Now we donot have a better way to fix it.'''