找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2567|回复: 0
收起左侧

华为liteos kernal包源码

[复制链接]
ID:394966 发表于 2018-9-7 13:48 | 显示全部楼层 |阅读模式
华为liteos, kernal部分 0.png

源程序如下:
  1. /*----------------------------------------------------------------------------
  2. * Copyright (c) <2013-2015>, <Huawei Technologies Co., Ltd>
  3. * All rights reserved.
  4. * Redistribution and use in source and binary forms, with or without modification,
  5. * are permitted provided that the following conditions are met:
  6. * 1. Redistributions of source code must retain the above copyright notice, this list of
  7. * conditions and the following disclaimer.
  8. * 2. Redistributions in binary form must reproduce the above copyright notice, this list
  9. * of conditions and the following disclaimer in the documentation and/or other materials
  10. * provided with the distribution.
  11. * 3. Neither the name of the copyright holder nor the names of its contributors may be used
  12. * to endorse or promote products derived from this software without specific prior written
  13. * permission.
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  21. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  22. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  23. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  24. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *---------------------------------------------------------------------------*/
  26. /*----------------------------------------------------------------------------
  27. * Notice of Export Control Law
  28. * ===============================================
  29. * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
  30. * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
  31. * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
  32. * applicable export control laws and regulations.
  33. *---------------------------------------------------------------------------*/

  34. #include "los_sys.h"
  35. #include "los_tick.h"
  36. #include "los_task.ph"
  37. #include "los_config.h"

  38. #ifdef __cplusplus
  39. #if __cplusplus
  40. extern "C" {
  41. #endif /* __cpluscplus */
  42. #endif /* __cpluscplus */

  43. #pragma data_alignment=8
  44. UINT8 *m_aucSysMem0;
  45. UINT32 g_sys_mem_addr_end = 0;
  46. extern UINT8 g_ucMemStart[];
  47. extern UINT32 osTickInit(UINT32 uwSystemClock, UINT32 uwTickPerSecond);
  48. extern UINT32   g_uwTskMaxNum;

  49. void osEnableFPU(void)
  50. {
  51.     *(volatile UINT32 *)0xE000ED88 |= ((3UL << 10*2)|(3UL << 11*2));
  52.     //SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));
  53. }
  54. /*****************************************************************************
  55. Function    : osRegister
  56. Description : Configuring the maximum number of tasks
  57. Input       : None
  58. Output      : None
  59. Return      : None
  60. *****************************************************************************/
  61. LITE_OS_SEC_TEXT_INIT VOID osRegister(VOID)
  62. {
  63.     g_uwTskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
  64.     g_sys_mem_addr_end = (UINT32)g_ucMemStart + OS_SYS_MEM_SIZE;
  65.     return;
  66. }

  67. /*****************************************************************************
  68. Function    : LOS_Start
  69. Description : Task start function
  70. Input       : None
  71. Output      : None
  72. Return      : LOS_OK
  73. *****************************************************************************/
  74. LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start()
  75. {
  76.     UINT32 uwRet;
  77. #if (LOSCFG_BASE_CORE_TICK_HW_TIME == NO)
  78.     uwRet = osTickStart();

  79.     if (uwRet != LOS_OK)
  80.     {
  81.         PRINT_ERR("osTickStart error\n");
  82.         return uwRet;
  83.     }
  84. #else
  85.     os_timer_init();
  86. #endif
  87.     LOS_StartToRun();

  88.     return uwRet;
  89. }

  90. /*****************************************************************************
  91. Function    : osMain
  92. Description : System kernel initialization function, configure all system modules
  93. Input       : None
  94. Output      : None
  95. Return      : LOS_OK
  96. *****************************************************************************/
  97. LITE_OS_SEC_TEXT_INIT int osMain(void)
  98. {
  99.     UINT32 uwRet;

  100.     osRegister();

  101.     uwRet = osMemSystemInit();
  102.     if (uwRet != LOS_OK)
  103.     {
  104.         PRINT_ERR("osMemSystemInit error %d\n", uwRet);
  105.         return uwRet;
  106.     }

  107. #if (LOSCFG_PLATFORM_HWI == YES)
  108.     {
  109.         osHwiInit();
  110.     }
  111. #endif

  112.     uwRet =osTaskInit();
  113.     if (uwRet != LOS_OK)
  114.     {
  115.         PRINT_ERR("osTaskInit error\n");
  116.         return uwRet;
  117.     }

  118. #if (LOSCFG_BASE_IPC_SEM == YES)
  119.     {
  120.         uwRet = osSemInit();
  121.         if (uwRet != LOS_OK)
  122.         {
  123.             return uwRet;
  124.         }
  125.     }
  126. #endif

  127. #if (LOSCFG_BASE_IPC_MUX == YES)
  128.     {
  129.         uwRet = osMuxInit();
  130.         if (uwRet != LOS_OK)
  131.         {
  132.             return uwRet;
  133.         }
  134.     }
  135. #endif

  136. #if (LOSCFG_BASE_IPC_QUEUE == YES)
  137.     {
  138.         uwRet = osQueueInit();
  139.         if (uwRet != LOS_OK)
  140.         {
  141.             PRINT_ERR("osQueueInit error\n");
  142.             return uwRet;
  143.         }
  144.     }
  145. #endif

  146. #if (LOSCFG_BASE_CORE_SWTMR == YES)
  147.     {
  148.         uwRet = osSwTmrInit();
  149.         if (uwRet != LOS_OK)
  150.         {
  151.             PRINT_ERR("osSwTmrInit error\n");
  152.             return uwRet;
  153.         }
  154.     }
  155. #endif

  156.     #if(LOSCFG_BASE_CORE_TIMESLICE == YES)
  157.     osTimesliceInit();
  158.     #endif

  159.     uwRet = osIdleTaskCreate();
  160.     if (uwRet != LOS_OK) {
  161.         return uwRet;
  162.     }

  163.     return LOS_OK;
  164. }


  165. /*****************************************************************************
  166. Function    : main
  167. Description : Main function entry
  168. Input       : None
  169. Output      : None
  170. ……………………

  171. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
Huawei_LiteOS_Kernel.rar (462.64 KB, 下载次数: 13)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表