LiteOS学习第三篇——los_config.h 配置文件的理解

来源:互联网 发布:如何做淘宝推广赚钱 编辑:程序博客网 时间:2024/05/21 23:34

配置文件是操作系统裁剪移植的核心部分,所以先来看看看这里面涉及到哪些内容

/****************************** System clock module configuration****************************/

/**
 * @ingroup los_config
 * System clock (unit: HZ)
 */     

#define OS_SYS_CLOCK                                   16000000                         //这里是系统时钟的配置,要根据不同的CPU以及CPU初始化的时钟频率来修改

 

/**
* @ingroup los_config
* limit addr range when search for  'funclocal(frame pointer)' or 'func name'
*/
extern char __data_end;
extern char __bss_start;
#define OS_SYS_FUNC_ADDR_START                        &__bss_start
#define OS_SYS_FUNC_ADDR_END                          &__data_end               //这个宏定义有什么作用还不太清楚

 

/* default LiteOS ram size level 
         RAM_SIZE_LEVEL_0means kernel ram < 8k  , 
         RAM_SIZE_LEVEL_1means kernel ram < 16k, 
         RAM_SIZE_LEVEL_2means means kernel ram>=32k 
*/               //这里说明你RAM的大小在操作系统中所说的级别,后面的有些定义也许用的到

/**
 * @ingroup los_config
 * Number of Ticks in one second
 */
#define LOSCFG_BASE_CORE_TICK_PER_SECOND               1000               //这里是指1秒钟的滴答数,1000肯定是固定的

 

/****************************** Hardware interrupt moduleconfiguration ******************************/

/**
 * @ingroup los_config
 * Configuration item for hardware interrupt tailoring
 */
#if defined (RAM_SIZE_LEVEL_0)
#define LOSCFG_PLATFORM_HWI                            NO
#elif defined(RAM_SIZE_LEVEL_1)
#define LOSCFG_PLATFORM_HWI                            YES
#elif defined(RAM_SIZE_LEVEL_2)
#define LOSCFG_PLATFORM_HWI                            YES
#else
#define LOSCFG_PLATFORM_HWI                            YES
#endif                                                      //硬件中断的初始化为什么跟RAM大小有关,说明硬件中断的管理需要耗费一定RAM,可做裁剪

/**
 * @ingroup los_config
 * Maximum number of used hardware interrupts, including Tick timerinterrupts.
 */
#define LOSCFG_PLATFORM_HWI_LIMIT                      96            //硬件中断的最多数量,具体有什么用还不知道,也许可用于裁剪

 

/****************************** Task module configuration********************************/

/**
 * @ingroup los_config
 * Default task priority
 */
#define LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO              10     //基本内核任务优先级,具体指哪个任务再细看,也许是统计任务,或者空闲任务或者只是个默认优先级定义,方便在开任务的时候从这个优先级开始

/**
 * @ingroup los_config
 * Maximum supported number of tasks except the idle task rather than thenumber of usable tasks
 */
#if defined (RAM_SIZE_LEVEL_0)
#define LOSCFG_BASE_CORE_TSK_LIMIT                     4             // max num task
#elif defined (RAM_SIZE_LEVEL_1)
#define LOSCFG_BASE_CORE_TSK_LIMIT                     7             // max num task
#elif defined (RAM_SIZE_LEVEL_2)
#define LOSCFG_BASE_CORE_TSK_LIMIT                     15             // max num task
#else
#define LOSCFG_BASE_CORE_TSK_LIMIT                     15             // max num task
#endif                          //最多任务数量,这里可以根据情况裁剪

/**
 * @ingroup los_config
 * Size of the idle task stack
 */
#if defined (RAM_SIZE_LEVEL_0)
#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE           SIZE(0x2D0)     // IDLE task stack
#elif defined (RAM_SIZE_LEVEL_1)
#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE           SIZE(0x300)     // IDLE task stack
#elif defined (RAM_SIZE_LEVEL_2)
#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE           SIZE(0x500)     // IDLE task stack
#else
#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE           SIZE(0x500)     // IDLE task stack
#endif                 //内核空闲任务的堆栈大小,按默认就好,应该也可以裁剪,后面再来看

/**
 * @ingroup los_config
 * Default task stack size
 */
#if defined (RAM_SIZE_LEVEL_0)
#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE        SIZE(0x200)     // default stack
#elif defined (RAM_SIZE_LEVEL_1)
#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE         SIZE(0x2D0)    // default stack
#elif defined (RAM_SIZE_LEVEL_2)
#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE        SIZE(0x2D0)     // default stack
#else
#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE        SIZE(0x2D0)     // default stack
#endif             //默认任务大小,在创建任务时可能会用到,当然也可以自己根据情况来定义

 

/**

 *@ingroup los_config

 *Minimum stack size.

 */

#define LOS_TASK_MIN_STACK_SIZE                         (ALIGN(0x130, 16))  //最小任务堆栈大小,用于创建任务时检测,这里是不是可以缩小,有待考察

 

/**

 * @ingroup los_config

 * Configuration item fortask Robin tailoring

 */

#define LOSCFG_BASE_CORE_TIMESLICE                      YES             // task-ROBIN moduel cuttingswitch       //时间片轮使能

 

/**

 *@ingroup los_config

 *Longest execution time of tasks with the same priorities

 */

#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT              10     //同一优先级最长运行时间

/**

 *@ingroup los_config

 *Configuration item for task (stack) monitoring module tailoring

 */

#define LOSCFG_BASE_CORE_TSK_MONITOR                    YES     //任务的监测功能是不是要开启,具体监测什么有待考察

/**

 *@ingroup los_config

 *Configuration item for performance moniter unit

 */

#define OS_INCLUDE_PERF                                 YES          //性能检测使能

 

/**

 *@ingroup los_config

 *Define a usable task priority.Highest task priority.

 */

#define LOS_TASK_PRIORITY_HIGHEST                       0      //最大优先级

 

/**

 *@ingroup los_config

 *Define a usable task priority.Lowest task priority.

 */

#define LOS_TASK_PRIORITY_LOWEST                        31       //最小优先级

 

/****************************** Semaphoremodule configuration ******************************/

/**

 *@ingroup los_config

 *Configuration item for semaphore module tailoring

 */

#define LOSCFG_BASE_IPC_SEM                             YES

 

/**

 *@ingroup los_config

 *Maximum supported number of semaphores

 */

#if defined (RAM_SIZE_LEVEL_0)

#define LOSCFG_BASE_IPC_SEM_LIMIT                       5              // the max sem-numb

#else

#define LOSCFG_BASE_IPC_SEM_LIMIT                       10              // the max sem-numb

#endif    //信号量的一些配置

/****************************** mutex moduleconfiguration ******************************/

/**

 *@ingroup los_config

 *Configuration item for mutex module tailoring

 */

#define LOSCFG_BASE_IPC_MUX                             YES

 

/**

 *@ingroup los_config

 *Maximum supported number of mutexes

 */

#if defined (RAM_SIZE_LEVEL_0)

#define LOSCFG_BASE_IPC_MUX_LIMIT                       5              // the max mutex-num

#else

#define LOSCFG_BASE_IPC_MUX_LIMIT                       10              // the max mutex-num

#endif           //互斥信号量配置

/****************************** Queue moduleconfiguration ********************************/

/**

 *@ingroup los_config

 *Configuration item for queue module tailoring

 */

#define LOSCFG_BASE_IPC_QUEUE                           YES

 

/**

 *@ingroup los_config

 *Maximum supported number of queues rather than the number of usable queues

 */

#if defined (RAM_SIZE_LEVEL_0)

#define LOSCFG_BASE_IPC_QUEUE_LIMIT                     5             //the max queue-numb

#elif defined (RAM_SIZE_LEVEL_1)

#define LOSCFG_BASE_IPC_QUEUE_LIMIT                     7              //the max queue-numb

#elif defined (RAM_SIZE_LEVEL_2)

#define LOSCFG_BASE_IPC_QUEUE_LIMIT                     10              //the max queue-numb

#else

#define LOSCFG_BASE_IPC_QUEUE_LIMIT                     10              //the max queue-numb

#endif    //消息队列配置

/****************************** Softwaretimer module configuration **************************/

#if (LOSCFG_BASE_IPC_QUEUE == YES)

/**

 *@ingroup los_config

 *Configuration item for software timer module tailoring

 */

#define LOSCFG_BASE_CORE_SWTMR                          YES

 

/**

 *@ingroup los_config

 *Maximum supported number of software timers rather than the number of usablesoftware timers

 */

#if defined (RAM_SIZE_LEVEL_0)

#define LOSCFG_BASE_CORE_SWTMR_LIMIT                    4                                      // the max SWTMR numb

#elif defined (RAM_SIZE_LEVEL_1)

#define LOSCFG_BASE_CORE_SWTMR_LIMIT                    7                                      // the max SWTMR numb

#elif defined (RAM_SIZE_LEVEL_2)

#define LOSCFG_BASE_CORE_SWTMR_LIMIT                    16                                             // the max SWTMR numb

#else

#define LOSCFG_BASE_CORE_SWTMR_LIMIT                    16                                             // the max SWTMR numb

#endif

/**

 *@ingroup los_config

 * Maxnumber of software timers ID

 */

#define OS_SWTMR_MAX_TIMERID                           ((65535/LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT)

 

/**

 *@ingroup los_config

 *Maximum size of a software timer queue

 */

#define OS_SWTMR_HANDLE_QUEUE_SIZE                     (LOSCFG_BASE_CORE_SWTMR_LIMIT + 0)

 

/**

 *@ingroup los_config

 *Minimum divisor of software timer multiple alignment

 */

 #define LOS_COMMON_DIVISOR                             10

#endif

/****************************** fw Interfaceconfiguration **************************/

/**

 *@ingroup los_config

 *Configuration item for the monitoring of task communication

 */

#define LOSCFG_COMPAT_CMSIS_FW                              YES

/****************************** proc moduleconfiguration **************************/

/**

 *@ingroup los_config

 *Version number

 */

#define VER                                                "Huawei LiteOS KernelV100R001c00B021"

/****************************** others**************************/

/**

 *@ingroup los_config

 *Configuration system wake-up info to open

 */

#define OS_SR_WAKEUP_INFO                                   YES   //配置唤醒信息,应该是通过串口打印,可裁剪

/**

 *@ingroup los_config

 *Configuration library function is included

 */

#ifndef LOSCFG_LIB_LIBC

#define LOSCFG_LIB_LIBC

#endif

 

/* Declaration of Huawei LiteOS moduleinitialization functions*/

 

/**

 *@ingroup  los_config

 *@brief: Task init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize task module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_ERRNO_TSK_NO_MEMORY           0x03000200:Insufficient memory for task creation.

 *@retval #LOS_OK                            0:Task initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osTaskInit(VOID);

 

 

 

/**

 *@ingroup  los_config

 *@brief: hardware interrupt init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize hardware interrupt module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                     0:Hardware interrupt initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern VOID osHwiInit(void);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Semaphore init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize Semaphore module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_ERRNO_SEM_NO_MEMORY    0x02000700:The memory is insufficient.

 *@retval #LOS_OK                      0:Semaphore initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osSemInit(void);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Mutex init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize mutex module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_ERRNO_MUX_NO_MEMORY    0x02001d00:The memory request fails.

 *@retval #LOS_OK                     0:Mutex initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osMuxInit(void);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Queue init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize Queue module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_ERRNO_QUEUE_MAXNUM_ZERO 0x02000600:The maximum number of queueresources is configured to 0.

 *@retval #LOS_ERRNO_QUEUE_NO_MEMORY  0x02000601:The queue block memory fails to be initialized.

 *@retval #LOS_OK                     0:Queue initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osQueueInit(void);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Software Timers init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize Software Timers module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_ERRNO_SWTMR_MAXSIZE_INVALID        0x02000308:Invalid configured number of software timers.

 *@retval #LOS_ERRNO_SWTMR_NO_MEMORY              0x02000307:Insufficient memory for software timer linked list creation.

 *@retval #LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM    0x0200030a:Insufficient memory allocated by membox.

 *@retval #LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED    0x0200030b:The software timer queue fails to be created.

 *@retval #LOS_ERRNO_SWTMR_TASK_CREATE_FAILED     0x0200030c:The software timer task fails to be created.

 *@retval #LOS_OK                                  0:Software Timersinitialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osSwTmrInit(void);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Task start running function.

 *

 * @parDescription:

 * ThisAPI is used to start a task.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval None.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern VOID LOS_StartToRun(VOID);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Test Task init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize Test Task.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                                 0:App_Task initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 los_TestInit(VOID);

 

 

/**

 *@ingroup  los_config

 *@brief: Task start function.

 *

 * @parDescription:

 * ThisAPI is used to start all tasks.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval None.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern VOID  osStart(void);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Hardware init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize Hardware module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval None.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern VOID  osHwInit(VOID);

 

 

 

/**

 *@ingroup los_config

 *@brief Configuring the maximum number oftasks.

 *

 *@parDescription:

 *ThisAPI is used to configuring the maximum number of tasks.

 *

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval None.

 *

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern VOID osRegister(VOID);

 

 

 

/**

 *@ingroup los_config

 *@brief System kernel initialization function.

 *

 *@parDescription:

 *ThisAPI is used to Initialize kernel ,configure all system modules.

 *

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                                  0:Systemkernel initialization success.

 *

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern int osMain(void);

 

/**

 *@ingroup los_config

 *@brief System kernel initialization function.

 *

 *@parDescription:

 *ThisAPI is used to Initialize kernel ,configure all system modules.

 *

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK  0:System kernel initialization success.

 *

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern int LOS_KernelInit(void);

 

/**

 *@ingroup los_config

 *@brief start system tick handler function.

 *

 *@parDescription:

 *ThisAPI is used to Start tick .

 *

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                                  0:Systemkernel initialization success.

 *

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 LOS_EnableTick(void);

 

/**

 *@ingroup los_config

 *@brief System kernel start function.

 *

 *@parDescription:

 *ThisAPI is used to Start run kernel .

 *

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                                  0:Systemkernel initialization success.

 *

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 LOS_Start(void);

 

/**

 *@ingroup los_config

 *@brief Configure Tick Interrupt Start.

 *

 *@parDescription:

 *ThisAPI is used to configure Tick Interrupt Start.

 *

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                               0:configure TickInterrupt success.

 *@retval #LOS_ERRNO_TICK_CFG_INVALID           0x02000400:configure Tick Interruptfailed.

 *

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osTickStart(VOID);

 

 

/**

 *@ingroup los_config

 *@brief Scheduling initialization.

 *

 *@parDescription:

 *<ul>

 *<li>This API is used to initializescheduling that is used for later task scheduling.</li>

 *</ul>

 *@attention

 *<ul>

 *<li>None.</li>

 *</ul>

 *

 *@param: None.

 *

 *@retval: None.

 *@parDependency:

 *<ul><li>los_config.h: the headerfile that contains the API declaration.</li></ul>

 *@see

 *@since Huawei LiteOS V100R001C00

 */

extern VOID osTimesliceInit(VOID);

 

 

 

/**

 *@ingroup  los_config

 *@brief: System memory init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize system memory module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                                 0:System memory initialization success.

 *@retval #OS_ERROR                               (UINT32)(-1):System memory initialization failed.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osMemSystemInit(VOID);

 

 

 

/**

 *@ingroup  los_config

 *@brief: Task Monitor init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize Task Monitor module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_OK                                 0:Task Monitor initialization success.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern VOID osTaskMonInit(VOID);

 

 

 

/**

 *@ingroup  los_config

 *@brief: CPUP init function.

 *

 * @parDescription:

 * ThisAPI is used to initialize CPUP module.

 *

 *@attention:

 *<ul><li>None.</li></ul>

 *

 *@param: None.

 *

 *@retval #LOS_ERRNO_CPUP_NO_MEMORY               0x02001e00:The request for memory fails.

 *@retval #LOS_OK                                 0:CPUP initializationsuccess.

 *

 * @parDependency:

 *<ul><li>los_config.h: the header file that contains the APIdeclaration.</li></ul>

 * @seeNone.

 *@since Huawei LiteOS V100R001C00

 */

extern UINT32 osCpupInit(VOID);

 

extern void osBackTrace(VOID);

 

#ifdef __cplusplus

#if __cplusplus

}

#endif /* __cplusplus */

#endif /* __cplusplus */

 

 

#endif /* _LOS_CONFIG_H *

 

 

 

0 0
原创粉丝点击