los_base.h

浏览该文件的文档。
00001 /*----------------------------------------------------------------------------
00002  * Copyright (c) <2013-2015>, <Huawei Technologies Co., Ltd>
00003  * All rights reserved.
00004  * Redistribution and use in source and binary forms, with or without modification,
00005  * are permitted provided that the following conditions are met:
00006  * 1. Redistributions of source code must retain the above copyright notice, this list of
00007  * conditions and the following disclaimer.
00008  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
00009  * of conditions and the following disclaimer in the documentation and/or other materials
00010  * provided with the distribution.
00011  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
00012  * to endorse or promote products derived from this software without specific prior written
00013  * permission.
00014  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00015  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00016  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00018  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00021  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00022  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00023  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00024  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025  *---------------------------------------------------------------------------*/
00026 /*----------------------------------------------------------------------------
00027  * Notice of Export Control Law
00028  * ===============================================
00029  * Huawei LiteOS may be subject to applicable export control laws and regulations, which might
00030  * include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
00031  * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
00032  * applicable export control laws and regulations.
00033  *---------------------------------------------------------------------------*/
00034 
00035 /**@defgroup kernel Kernel
00036  * @defgroup los_base Basic definitions
00037  * @ingroup kernel
00038  */
00039 
00040 #ifndef _LOS_BASE_H
00041 #define _LOS_BASE_H
00042 
00043 #ifdef LOSCFG_LIB_LIBCMINI
00044 #include "libcmini.h"
00045 #endif
00046 #include "los_builddef.h"
00047 #include "los_typedef.h"
00048 #include "los_config.h"
00049 #include "los_printf.h"
00050 #include "los_list.h"
00051 #include "los_errno.h"
00052 #include "los_compiler.h"
00053 
00054 #ifdef __cplusplus
00055 #if __cplusplus
00056 extern "C" {
00057 #endif /* __cplusplus */
00058 #endif /* __cplusplus */
00059 
00060 
00061 #define SIZE(a)             (a)
00062 
00063 #define LOS_ASSERT_COND(expression)
00064 
00065 /**
00066  * @ingroup los_base
00067  * Define the timeout interval as LOS_NO_WAIT.
00068  */
00069 #define LOS_NO_WAIT                                 0
00070 
00071 /**
00072  * @ingroup los_base
00073  * Define the timeout interval as LOS_WAIT_FOREVER.
00074  */
00075 #define LOS_WAIT_FOREVER                            0xFFFFFFFF
00076 
00077 /**
00078  * @ingroup los_base
00079  * Align the beginning of the object with the base address uwAddr, with uwBoundary bytes being the smallest unit of alignment.
00080  */
00081 #ifndef ALIGN
00082 #define ALIGN(uwAddr, uwBoundary)                   LOS_Align(uwAddr, uwBoundary)
00083 #endif
00084 /**
00085  * @ingroup los_base
00086  * Align the tail of the object with the base address uwAddr, with uwSize bytes being the smallest unit of alignment.
00087  */
00088 #define TRUNCATE(uwAddr, uwSize)                    ((uwAddr) & ~((uwSize) - 1))
00089 
00090 /**
00091  * @ingroup los_base
00092  * Read a UINT8 value from ucAddr and stroed in ucValue.
00093  */
00094 #define READ_UINT8(ucValue, ucAddr)                   ((ucValue) = *((volatile UINT8 *)(ucAddr)))
00095 /**
00096  * @ingroup los_base
00097  * Read a UINT16 value from usAddr and stroed in usAddr.
00098  */
00099 #define READ_UINT16(usValue, usAddr)                  ((usValue) = *((volatile UINT16 *)(usAddr)))
00100 /**
00101  * @ingroup los_base
00102  * Read a UINT32 value from uwAddr and stroed in uwValue.
00103  */
00104 #define READ_UINT32(uwValue, uwAddr)                  ((uwValue) = *((volatile UINT32 *)(uwAddr)))
00105 /**
00106  * @ingroup los_base
00107  * Read a UINT64 value from ullAddr and stroed in ullValue.
00108  */
00109 #define READ_UINT64(ullValue, ullAddr)                ((ullValue) = *((volatile UINT64 *)(ullAddr)))
00110 
00111 
00112 /**
00113  * @ingroup los_base
00114  * Get a UINT8 value from ucAddr.
00115  */
00116 #define GET_UINT8(ucAddr)                            (*((volatile UINT8 *)(ucAddr)))
00117 /**
00118  * @ingroup los_base
00119  * Get a UINT16 value from usAddr.
00120  */
00121 #define GET_UINT16(usAddr)                           (*((volatile UINT16 *)(usAddr)))
00122 /**
00123  * @ingroup los_base
00124  * Get a UINT32 value from uwAddr.
00125  */
00126 #define GET_UINT32(uwAddr)                           (*((volatile UINT32 *)(uwAddr)))
00127 /**
00128  * @ingroup los_base
00129  * Get a UINT64 value from ullAddr.
00130  */
00131 #define GET_UINT64(ullAddr)                          (*((volatile UINT64 *)(ullAddr)))
00132 
00133 /**
00134  * @ingroup los_base
00135  * Write a UINT8 ucValue to ucAddr.
00136  */
00137 #define WRITE_UINT8(ucValue, ucAddr)                 (*((volatile UINT8 *)(ucAddr)) = (ucValue))
00138 /**
00139  * @ingroup los_base
00140  * Write a UINT16 usValue to usAddr.
00141  */
00142 #define WRITE_UINT16(usValue, usAddr)                (*((volatile UINT16 *)(usAddr)) = (usValue))
00143 /**
00144  * @ingroup los_base
00145  * Write a UINT32 uwValue to uwAddr.
00146  */
00147 #define WRITE_UINT32(uwValue, uwAddr)                (*((volatile UINT32 *)(uwAddr)) = (uwValue))
00148 /**
00149  * @ingroup los_base
00150  * Write a UINT64 ullAddr to ullAddr.
00151  */
00152 #define WRITE_UINT64(ullValue, ullAddr)              (*((volatile UINT64 *)(ullAddr)) = (ullValue))
00153 
00154 /*lint -e40*/
00155 #if PRINT_LEVEL < LOS_ERR_LEVEL
00156 #define LOS_ASSERT(judge)
00157 #else
00158 #define LOS_ASSERT(judge) \
00159     do { \
00160         if ((judge) == 0) \
00161         { \
00162             (void)LOS_IntLock(); \
00163             PRINT_ERR("ASSERT ERROR! %s, %d, %s\n", __FILE__, __LINE__, __func__); \
00164             while(1); \
00165         } \
00166     } while(0)
00167 #endif
00168 /*lint +e40*/
00169 
00170 /**
00171  *@ingroup los_base
00172  *@brief Align the value (uwAddr) by some bytes (uwBoundary) you specify.
00173  *
00174  * @par Description:
00175  * This API is used to align the value (uwAddr) by some bytes (uwBoundary) you specify.
00176  *
00177  * @attention
00178  * <ul>
00179  * <li>the value of uwBoundary usually is 4,8,16,32.</li>
00180  * </ul>
00181  *
00182  *@param uwAddr     [IN]  The variable what you want to align.
00183  *@param uwBoundary [IN]  The align size what you want to align.
00184  *
00185  *@retval #UINT32 The variable what have been aligned.
00186  *@par Dependency:
00187  *<ul><li>los_base.h: the header file that contains the API declaration.</li></ul>
00188  *@see
00189  *@since Huawei LiteOS V100R001C00
00190  */
00191 extern UINT32 LOS_Align(UINT32 uwAddr, UINT32 uwBoundary);
00192 
00193 /**
00194  *@ingroup los_base
00195  *@brief Sleep the current task.
00196  *
00197  * @par Description:
00198  * This API is used to delay the execution of the current task. The task is able to be scheduled after it is delayed for a specified number of Ticks.
00199  *
00200  * @attention
00201  * <ul>
00202  * <li>The task fails to be delayed if it is being delayed during interrupt processing or it is locked.</li>
00203  * <li>If 0 is passed in and the task scheduling is not locked, execute the next task in the queue of tasks with the priority of the current task.
00204  * If no ready task with the priority of the current task is available, the task scheduling will not occur, and the current task continues to be executed.</li>
00205  * <li>The parameter passed in can not be equal to LOS_WAIT_FOREVER(0xFFFFFFFF).
00206  * If that happens, the task will not sleep 0xFFFFFFFF milliseconds or sleep forever but sleep 0xFFFFFFFF Ticks.</li>
00207  * </ul>
00208  *
00209  *@param uwMsecs [IN] Type #UINT32 Number of MS for which the task is delayed.
00210  *
00211  *@retval None
00212  *@par Dependency:
00213  *<ul><li>los_base.h: the header file that contains the API declaration.</li></ul>
00214  *@see None
00215  *@since Huawei LiteOS V100R001C00
00216  */
00217 extern VOID LOS_Msleep(UINT32 uwMsecs);
00218 
00219 /**
00220  *@ingroup los_base
00221  *@brief System kernel initialization function.
00222  *
00223  *@par Description:
00224  *This API is used to start liteOS .
00225  *
00226  *@attention
00227  *<ul>
00228  *<li>None.</li>
00229  *</ul>
00230  *
00231  *@param: None.
00232  *
00233  *@retval #LOS_OK                                  0:LiteOS start success.
00234  *
00235  *@par Dependency:
00236  *<ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
00237  *@see
00238  *@since Huawei LiteOS V100R001C00
00239  */
00240 extern  UINT32 LOS_Start(VOID);
00241 
00242 /**
00243  *@ingroup los_base
00244  *@brief System kernel initialization function.
00245  *
00246  *@par Description:
00247  *This API is used to Initialize kernel ,configure all system modules.
00248  *
00249  *@attention
00250  *<ul>
00251  *<li>None.</li>
00252  *</ul>
00253  *
00254  *@param: None.
00255  *
00256  *@retval #LOS_OK                                  0:System kernel initialization success.
00257  *
00258  *@par Dependency:
00259  *<ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
00260  *@see
00261  *@since Huawei LiteOS V100R001C00
00262  */
00263 extern  UINT32 LOS_KernelInit(VOID);
00264 
00265 #ifdef __cplusplus
00266 #if __cplusplus
00267 }
00268 #endif /* __cplusplus */
00269 #endif /* __cplusplus */
00270 
00271 #endif /* _LOS_BASE_H */