nucleus plus代码学习

int.S:
  1. ;************************************************************************
  2. ;*
  3. ;* FUNCTION
  4. ;*
  5. ;* INT_Initialize
  6. ;*
  7. ;* DESCRIPTION
  8. ;*
  9. ;* This function sets up the global system stack variable and
  10. ;* transfers control to the target independent initialization
  11. ;* function INC_Initialize. Responsibilities of this function
  12. ;* include the following:
  13. ;*
  14. ;* - Setup necessary processor/system control registers
  15. ;* - Initialize the vector table
  16. ;* - Setup the system stack pointers
  17. ;* - Setup the timer interrupt
  18. ;* - Calculate the timer HISR stack and priority
  19. ;* - Calculate the first available memory address
  20. ;* - Transfer control to INC_Initialize to initialize all of
  21. ;* the system components.
  22. ;*
  23. ;* Major Revision:
  24. ;*
  25. ;* M. Kyle Craig, Accelerated Technology, Inc.
  26. ;*
  27. ;*
  28. ;*
  29. ;*
  30. ;* CALLED BY
  31. ;*
  32. ;* Nothing. This function is the ENTRY point for Nucleus PLUS.
  33. ;*
  34. ;* CALLS
  35. ;*
  36. ;* INC_Initialize Common initialization
  37. ;*
  38. ;* INPUTS
  39. ;*
  40. ;* None
  41. ;*
  42. ;* OUTPUTS
  43. ;*
  44. ;* None
  45. ;*
  46. ;* HISTORY
  47. ;*
  48. ;* NAME DATE REMARKS
  49. ;*
  50. ;* W. Lamie 08-27-1994 Created initial version 1.0
  51. ;* D. Lamie 08-27-1994 Verified version 1.0
  52. ;*
  53. ;************************************************************************
  54. ;VOID INT_Initialize(void)
  55. ;{

  56.     .def _c_int00
  57. _c_int00

  58.     .def _INT_Initialize
  59. _INT_Initialize:

  60.     ; Insure that the processor is in supervisor mode.                                                                    //设置了arm的svc模式
  61.     MRS r0,CPSR ; Pickup current CPSR
  62.     BIC r0,r0,#MODE_MASK ; Clear the mode bits
  63.     ORR r0,r0,#SUP_MODE ; Set the supervisor mode bits
  64.     ORR r0,r0,#LOCKOUT ; Insure IRQ/FIQ interrupts are                                                                   //关闭中断
  65.                                         ; locked out
  66.     MSR CPSR,r0 ; Setup the new CPSR

  67.     ; Clear the un-initialized global and static C data areas.
  68.     LDR r0,BSS_Start ; Pickup the start of the BSS area
  69.     MOV r2,#0 ; Clear value in r2
  70.     LDR r1,BSS_End ; Pickup the end of the BSS area

  71. INT_BSS_Clear_Loop
  72.     STR r2,[r0],#4 ; Clear a word                                                                                      //初始化Bss段

  73. INT_BSS_Clear_Check
  74.     CMP r0,r1 ; Are the start and end equal?
  75.     BNE INT_BSS_Clear_Loop ; If so, continue with BSS clear

  76.     ; Perform auto-initialization. if cinit is -1, then there is none.
  77.     LDR r0, c_cinit
  78.     CMN r0, #1
  79.     BLNE _auto_init


  80.     ; Turn-on the I-Cache for the TI 925T Processor                                                                    //开启I-Cache

  81.     MRC p15,#0,r1,C1,C0,#0 ; Read the control register.
  82.     ORR r1,r1,#0x1000 ; Set the I bit to enable Instruction Cache
  83.     NOP
  84.     MCR p15,#0,r1,C1,C0,#0 ; Write the control register.


  85. ; Setup the vectors loaded flag to indicate to other routines in the
  86. ; system whether or not all of the default vectors have been loaded.
  87. ; If INT_Loaded_Flag is 1, all of the default vectors have been loaded.
  88. ; Otherwise, if INT_Loaded_Flag is 0, registering an LISR cause the
  89. ; default vector to be loaded. In the ARM60 this variable is always
  90. ; set to 1. All vectors must be setup by this function.
  91. ; INT_Loaded_Flag = 0;

  92.     MOV r0,#1 ; All vectors are assumed loaded
  93.     LDR r1,Loaded_Flag ; Build address of loaded flag
  94.     STR r0,[r1,#0] ; Initialize loaded flag


  95. ; Initialize the system stack pointers. This is done after the BSS is
  96. ; clear because the TCD_System_Stack pointer is a BSS It is
  97. ; assumed that available memory starts immediately after the end of the
  98. ; BSS section.                                                                                                                       //建立sys stack

  99.     LDR r10,System_Stk_Limit ; Pickup the system stack limit (bottom of system stack)
  100.     LDR r3,System_Limit ; Pickup sys stack limit addr
  101.     STR r10,[r3, #0] ; Save stack limit

  102.     LDR sp,System_Stack_SP ; Set-up the system stack pointer
  103.     LDR r3,System_Stack ; Pickup system stack address
  104.     STR sp,[r3, #0] ; Save stack pointer

  105.     MRS r0,CPSR ; Pickup current CPSR
  106.     BIC r0,r0,#MODE_MASK ; Clear the mode bits
  107.     ORR r0,r0,#IRQ_MODE ; Set the IRQ mode bits
  108.     MSR CPSR,r0 ; Move to IRQ mode

  109.     LDR sp,IRQ_Stack_SP ; Setup IRQ stack pointer

  110.     MRS r0,CPSR ; Pickup current CPSR
  111.     BIC r0,r0,#MODE_MASK ; Clear the mode bits
  112.     ORR r0,r0,#FIQ_MODE ; Set the FIQ mode bits
  113.     MSR CPSR,r0 ; Move to the FIQ mode

  114.     LDR sp,FIQ_Stack_SP ; Setup FIQ stack pointer

  115.     MRS r0,CPSR ; Pickup current CPSR
  116.     BIC r0,r0,#MODE_MASK ; Clear mode bits
  117.     ORR r0,r0,#SUP_MODE ; Set the supervisor mode bits
  118.     MSR CPSR,r0 ; All interrupt stacks are setup,
  119.                                             ; return to supervisor mode

  120. ; Define the global data structures that need to be initialized by this                                                                  //设置中断
  121. ; routine. These structures are used to define the system timer
  122. ; management HISR.
  123. ; TMD_HISR_Stack_Ptr = (VOID *) r2;
  124. ; TMD_HISR_Stack_Size = TIMER_SIZE;
  125. ; TMD_HISR_Priority = TIMER_PRIORITY;

  126.     LDR r2,HISR_Stack_Mem ; Get HISR stack memory address
  127.     LDR r3,HISR_Stack_Ptr ; Pickup variable's address
  128.     STR r2,[r3, #0] ; Setup timer HISR stack pointer
  129.     MOV r1,#HISR_STACK_SIZE ; Pickup the timer HISR stack size
  130.     LDR r3,HISR_Stack_Size ; Pickup variable's address
  131.     STR r1,[r3, #0] ; Setup timer HISR stack size
  132.     MOV r1,#HISR_PRIORITY ; Pickup timer HISR priority (0-2)
  133.     LDR r3,HISR_Priority ; Pickup variable's address
  134.     STR r1,[r3, #0] ; Setup timer HISR priority

  135. ; Make a call to begin all board specific initialization.                                                                                //初始化时钟
  136. ; Begin with Initializing the Vector table and replacing
  137. ; default interrupts with Plus IRQs. Then setup the timer
  138. ; and begin the system clock.

  139.     .if $$isdefed("NU_ROM_SUPPORT")

  140.     BL _INT_Timer_Initialize ; Initialize the timer

  141.     .else

  142.     BL INT_Install_Vector_Table ; Install the vector table
  143.     BL _INT_Timer_Initialize ; Initialize the timer

  144.     .endif

  145. ; Call INC_Initialize with a pointer to the first available memory
  146. ; address after the compiler's global data. This memory may be used
  147. ; by the application.
  148. ; INC_Initialize(first_available_memory);

  149.     LDR r0,First_Avail_Mem ; Get address of first available memory
  150.       
  151.     B _INC_Initialize ; to high-level initialization                                                                                       //最后跳转到_INC_Initialize,找不到函数在哪
  152. ;}

  153.    。。。。。。
  154.    。。。。。。
初始化组件由三个部分组成,硬件在reset后首先进入INT_initialize(),进行板级的相关初始化,首先设置SVC mode,关中断,然后将内核从rom中拷贝至ram中,建立bss段,依次建立sys stack, irq stack和fiq stack,最后初始化timer,建立timer HISR的栈空间,看了一下2410平台的代码,一个tick大概是15.8ms,完成板级的初始化后就进入了INC_initialize。
inc.c:

  1. /*************************************************************************/
  2. /* */
  3. /* Copyright Mentor Graphics Corporation 2002 */
  4. /* All Rights Reserved. */
  5. /* */
  6. /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */
  7. /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */
  8. /* SUBJECT TO LICENSE TERMS. */
  9. /* */
  10. /*************************************************************************/

  11. /*************************************************************************/
  12. /* */
  13. /* FILE NAME VERSION */
  14. /* */
  15. /* inc.c Nucleus PLUS 1.14 */
  16. /* */
  17. /* COMPONENT */
  18. /* */
  19. /* IN - Initialization */
  20. /* */
  21. /* DESCRIPTION */
  22. /* */
  23. /* This file contains initialization and setup routines associated */
  24. /* with the initialization component. */
  25. /* */
  26. /* DATA STRUCTURES */
  27. /* */
  28. /* None */
  29. /* */
  30. /* FUNCTIONS */
  31. /* */
  32. /* INC_Initialize Common system initialization */
  33. /* */
  34. /* DEPENDENCIES */
  35. /* */
  36. /* in_extr.h Initialization functions */
  37. /* er_extr.h Error handling function */
  38. /* hi_extr.h History functions */
  39. /* tc_extr.h Thread Control functions */
  40. /* mb_extr.h Mailbox functions */
  41. /* qu_extr.h Queue functions */
  42. /* pi_extr.h Pipe functions */
  43. /* sm_extr.h Semaphore functions */
  44. /* ev_extr.h Event group functions */
  45. /* pm_extr.h Partition memory functions */
  46. /* dm_extr.h Dynamic memory functions */
  47. /* tm_extr.h Timer functions */
  48. /* io_extr.h I/O Driver functions */
  49. /* */
  50. /* HISTORY */
  51. /* */
  52. /* DATE REMARKS */
  53. /* */
  54. /* 03-01-1993 Created initial version 1.0 */
  55. /* 04-19-1993 Verified version 1.0 */
  56. /* 03-01-1994 Replaced void with VOID, */
  57. /* resulting in version 1.1 */
  58. /* */
  59. /* 03-18-1994 Verified version 1.1 */
  60. /* 04-17-1996 updated to version 1.2 */
  61. /* 03-20-1998 Moved the INC_Initialize_State */
  62. /* define values into their own */
  63. /* in_defs.h include file as part */
  64. /* of SPR455. This creates */
  65. /* version 1.2a. */
  66. /* 03-24-1998 Released version 1.3. */
  67. /* 03-26-1999 Released 1.11m (new release */
  68. /* numbering scheme) */
  69. /* 04-17-2002 Released version 1.13m */
  70. /* 11-07-2002 Released version 1.14 */
  71. /*************************************************************************/
  72. #define NU_SOURCE_FILE


  73. #include "in_defs.h" /* Initialization defines */
  74. #include "in_extr.h" /* Initialization functions */
  75. #include "hi_extr.h" /* History functions */
  76. #include "er_extr.h" /* Error handling function */
  77. #include "tc_extr.h" /* Thread Control functions */
  78. #include "mb_extr.h" /* Mailbox functions */
  79. #include "qu_extr.h" /* Queue functions */
  80. #include "pi_extr.h" /* Pipe functions */
  81. #include "sm_extr.h" /* Semaphore functions */
  82. #include "ev_extr.h" /* Event group functions */
  83. #include "pm_extr.h" /* Partition memory functions*/
  84. #include "dm_extr.h" /* Dynamic memory functions */
  85. #include "tm_extr.h" /* Timer functions */
  86. #include "io_extr.h" /* I/O Driver functions */


  87. /* Define global variable that contains the state of initialization. This
  88.    flag is for information use only. */

  89. INT INC_Initialize_State;


  90. /* Define external functions that access the release and license
  91.    information. */

  92. CHAR *RLC_Release_Information(VOID);
  93. CHAR *LIC_License_Information(VOID);

  94. #if defined(NU_MODULE_SUPPORT) && (NU_MODULE_SUPPORT > 0)

  95. /* Prototypes for Module Initialization funcitons */
  96. STATUS MRC_Initialize(VOID);
  97. STATUS MSC_Initialize(VOID);

  98. #endif

  99. /*************************************************************************/
  100. /* */
  101. /* FUNCTION */
  102. /* */
  103. /* INC_Initialize */
  104. /* */
  105. /* DESCRIPTION */
  106. /* */
  107. /* This function is the main initialization function of the system. */
  108. /* All components are initialized by this function. After system */
  109. /* initialization is complete, the Application_Initialize routine */
  110. /* is called. After all initialization is complete, this function */
  111. /* calls TCT_Schedule to start scheduling tasks. */
  112. /* */
  113. /* CALLED BY */
  114. /* */
  115. /* INT_Initialize Target dependent initialize */
  116. /* */
  117. /* CALLS */
  118. /* */
  119. /* Application_Initialize Application initialize */
  120. /* RLC_Release_Information Release information */
  121. /* LIC_License_Information License information */
  122. /* ERI_Initialize Error handling initialize */
  123. /* HII_Initialize History initialization */
  124. /* TCI_Initialize Thread control initialize */
  125. /* MBI_Initialize Mailbox initialize */
  126. /* QUI_Initialize Queue initialize */
  127. /* PII_Initialize Pipe initialize */
  128. /* SMI_Initialize Semaphore initialize */
  129. /* EVI_Initialize Event flag initialize */
  130. /* PMI_Initialize Partition memory initialize */
  131. /* DMI_Initialize Dynamic memory initialize */
  132. /* TMI_Initialize Timer initialize */
  133. /* IOI_Initialize I/O Driver initialize */
  134. /* MRC_Initialize Memory Region initialize */
  135. /* MSC_Initialize Module Support initialize */
  136. /* TCT_Schedule Thread scheduling loop */
  137. /* */
  138. /* INPUTS */
  139. /* */
  140. /* first_available_memory Pointer to available memory */
  141. /* */
  142. /* OUTPUTS */
  143. /* */
  144. /* None */
  145. /* */
  146. /* HISTORY */
  147. /* */
  148. /* DATE REMARKS */
  149. /* */
  150. /* 03-01-1993 Created initial version 1.0 */
  151. /* 04-19-1993 Verified version 1.0 */
  152. /* */
  153. /*************************************************************************/
  154. VOID INC_Initialize(VOID *first_available_memory)
  155. {

  156.     /* Indicate that initialization is starting. */
  157.     INC_Initialize_State = INC_START_INITIALIZE;

  158.     /* Call release information function. */
  159.     RLC_Release_Information();

  160.     /* Call license information function. */
  161.     LIC_License_Information();

  162.     /* Initialize the Error handling (ER) component. */
  163.     ERI_Initialize();

  164.     /* Initialize the History (HI) component. */
  165.     HII_Initialize();

  166. #if defined(NU_MODULE_SUPPORT) && (NU_MODULE_SUPPORT > 0)

  167.     MRC_Initialize(); /* Initialize Memory Region component */
  168.     MSC_Initialize(); /* Initialize Module Support component */

  169. #endif

  170.     /* Initialize the Thread Control (TC) component. */
  171.     TCI_Initialize();

  172.     /* Initialize the Mailbox (MB) component. */
  173.     MBI_Initialize();

  174.     /* Initialize the Queue (QU) component. */
  175.     QUI_Initialize();

  176.     /* Initialize the Pipe (PI) component. */
  177.     PII_Initialize();

  178.     /* Initialize the Semaphore (SM) component. */
  179.     SMI_Initialize();

  180.     /* Initialize the Event Group (EV) component. */
  181.     EVI_Initialize();

  182.     /* Initialize the Partition memory (PM) component. */
  183.     PMI_Initialize();

  184.     /* Initialize the Dynamic memory (DM) component. */
  185.     DMI_Initialize();

  186.     /* Initialize the Timer (TM) component. */
  187.     TMI_Initialize();

  188.     /* Initialize the I/O Driver (IO) component. */
  189.     IOI_Initialize();

  190.     /* Invoke the application-supplied initialization function. */
  191.     Application_Initialize(first_available_memory);                                            //应用程序初始化

  192.     /* Indicate that initialization is finished. */
  193.     INC_Initialize_State = INC_END_INITIALIZE;

  194.     /* Start scheduling threads of execution. */
  195.     TCT_Schedule();
  196. }
到这里找不到函数了。。。
csc.c:包含nucleus plus系统中使用的连接表处理工具,采用双向循环链表(doubley-linked circulat lists)

dmc.c:包含动态内存管理组件的 核心事务
dmce.c:包含动态内存管理组件中的函数错误检查例程,可以关闭?
dmd.c:包含动态内存管理组件中的全局数据结构
dmf.c:包含获取管理动态内存管理组件的事实的例程
dmi.c:包含动态内存管理组件的初始化例程
dms.c:包含动态内存管理组件的补充例程

erc.c:包含错误管理组件的 核心事务
erd.c:包含错误管理组件的官居数据结构
eri.c:包含错误管理组件初始化例程

evc.c:包含事件组管理组件 核心事务
evce.c:包含事件组错误检查
evd.c:事件组全局数据结构
evf.c
evi.c

hic.c:包含历史管理组件的 核心事务
hid.c
hii.c

inc.c
int.s

ioc.c:I/O驱动管理 核心事务
ioce.c
iod.c
iof.c
ioi.c

lic.c:license informations组件 核心事务
lid.c

mbc.c:邮箱管理组件 核心事务
mbce.c
mbd.c
mbf.c
mbi.c
mbs.c
mbse.c

pic.c:管道管理核心事务
pice.c
pid.c
pif.c
pii.c
pis.c
pise.c

pmc.c:内存管理划分(partition)核心事务
pmce.c
pmd.c
pmf.c
pmi.c

quc.c:队列管理核心事务
quce.c
qud.c
quf.c
qui.c
qus.c
quse.c

rlc.c:版本信息(Release Information)核心事务
rld.c

sdc.c:包含串行驱动特定功能

smc.c:信号量管理核心事务
smce.c
smd.c
smd.c
smf.c
smi.c
sms.c
smse.c

tcc.c:进程控制
tcce.c
tcd.c
tcf.c
tci.c
tcs.c
tcse.c
tct.s

tmc.c:此函数负责提供初始化的任务定时器,此程序必须在svc/usr模式下内核切换成svc模式运行。
tmd.c
tmf.c
tmi.c
tms.c
tmse.c
tmt.s

文件命名前2个字母是组件的缩写,后面的字母是不同的文件。
d包含了相关全局变量,i是初始化部分,f是组件管理的对象的信息,c是核心函数,ce是错误处理,se是补充。




<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(70) | 评论(0) | 转发(0) |
0

上一篇:sed编辑器基础

下一篇:nucleus学习

给主人留下些什么吧!~~
评论热议
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

习惯就好zz

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值