/* ----------------------------------------------------------------------------
 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
 * Description: Tables
 * Author: Huawei LiteOS Team
 * Create: 2013-01-01
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 * to endorse or promote products derived from this software without specific prior written
 * permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * --------------------------------------------------------------------------- */
/*以上代码是LiteOS系统中定义表格的头文件，其中定义了一些宏用于在汇编代码中生成指定名称和标签的全局符号，用于在LiteOS系统中实现一些底层硬件操作。
同时还定义了一些用于存储数据的节（section），以确保在可执行文件中包含该数据。此外，还定义了一些用于设置表的类型或属性的宏。*/
#ifndef _LOS_TABLES_H
#define _LOS_TABLES_H

#include "los_typedef.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */

#ifndef LOS_HAL_TABLE_WOW_BEGIN
#define LOS_HAL_TABLE_WOW_BEGIN(label, name)                                     \
    __asm__(".section \".liteos.table." X_STRING(name) ".wow.begin\",\"aw\"\n"   \
            ".globl " X_STRING(LOS_LABEL_DEFN(label)) "\n"                       \
            ".type    " X_STRING(LOS_LABEL_DEFN(label)) ",object\n"              \
            ".p2align " X_STRING(LOSARC_P2ALIGNMENT) "\n"                        \
            X_STRING(LOS_LABEL_DEFN(label)) ":\n"                                \
            ".previous\n"                                                        \
            )
#endif
/*这段代码定义了一个宏LOS_HAL_TABLE_WOW_BEGIN，用于在汇编代码中声明一个LiteOS的表格开始位置。该宏使用了一些特定的汇编指令和标签定义*/
#ifndef LOS_HAL_TABLE_WOW_END
#define LOS_HAL_TABLE_WOW_END(label, name)                                       \
    __asm__(".section \".liteos.table." X_STRING(name) ".wow.finish\",\"aw\"\n"  \
            ".globl " X_STRING(LOS_LABEL_DEFN(label)) "\n"                       \
            ".type    " X_STRING(LOS_LABEL_DEFN(label)) ",object\n"              \
            ".p2align " X_STRING(LOSARC_P2ALIGNMENT) "\n"                        \
            X_STRING(LOS_LABEL_DEFN(label)) ":\n"                                \
            ".previous\n"                                                        \
            )
#endif
/*。该代码定义了一个名为LOS_HAL_TABLE_WOW_END的宏，该宏的作用是在汇编代码中生成一个指定名称和标签的全局符号，用于在LiteOS系统中实现一些底层硬件操作。*/
#ifndef LOS_HAL_TABLE_SCATTER_BEGIN
#define LOS_HAL_TABLE_SCATTER_BEGIN(label, name)                                    \
    __asm__(".section \".liteos.table." X_STRING(name) ".scatter.begin\",\"aw\"\n"  \
            ".globl " X_STRING(LOS_LABEL_DEFN(label)) "\n"                          \
            ".type    " X_STRING(LOS_LABEL_DEFN(label)) ",object\n"                 \
            ".p2align " X_STRING(LOSARC_P2ALIGNMENT) "\n"                           \
            X_STRING(LOS_LABEL_DEFN(label)) ":\n"                                   \
            ".previous\n"                                                           \
            )
#endif
/*这是另一段C预处理器宏定义代码。该代码定义了一个名为LOS_HAL_TABLE_SCATTER_BEGIN的宏，该宏的作用是在汇编代码中生成一个指定名称和标签的全局符号，用于在LiteOS系统中实现一些底层硬件操作。*/
#ifndef LOS_HAL_TABLE_SCATTER_END
#define LOS_HAL_TABLE_SCATTER_END(label, name)                                      \
    __asm__(".section \".liteos.table." X_STRING(name) ".scatter.finish\",\"aw\"\n" \
            ".globl " X_STRING(LOS_LABEL_DEFN(label)) "\n"                          \
            ".type    " X_STRING(LOS_LABEL_DEFN(label)) ",object\n"                 \
            ".p2align " X_STRING(LOSARC_P2ALIGNMENT) "\n"                           \
            X_STRING(LOS_LABEL_DEFN(label)) ":\n"                                   \
            ".previous\n"                                                           \
            )
#endif
/*该代码定义了一个名为LOS_HAL_TABLE_SCATTER_END的宏，用于在LiteOS系统中生成汇编代码中的全局符号*/
#ifndef LOS_HAL_TABLE_BEGIN
#define LOS_HAL_TABLE_BEGIN(label, name)                                     \
    __asm__(".section \".liteos.table." X_STRING(name) ".begin\",\"aw\"\n"   \
            ".globl " X_STRING(LOS_LABEL_DEFN(label)) "\n"                   \
            ".type    " X_STRING(LOS_LABEL_DEFN(label)) ",object\n"          \
            ".p2align " X_STRING(LOSARC_P2ALIGNMENT) "\n"                    \
            X_STRING(LOS_LABEL_DEFN(label)) ":\n"                            \
            ".previous\n"                                                    \
            )
#endif
/*该代码定义了一个名为LOS_HAL_TABLE_BEGIN的宏，该宏的作用是在汇编代码中生成一个指定名称和标签的全局符号，用于在LiteOS系统中实现一些底层硬件操作。*/
#ifndef LOS_HAL_TABLE_END
#define LOS_HAL_TABLE_END(label, name)                                       \
    __asm__(".section \".liteos.table." X_STRING(name) ".finish\",\"aw\"\n"  \
            ".globl " X_STRING(LOS_LABEL_DEFN(label)) "\n"                   \
            ".type    " X_STRING(LOS_LABEL_DEFN(label)) ",object\n"          \
            ".p2align " X_STRING(LOSARC_P2ALIGNMENT) "\n"                    \
            X_STRING(LOS_LABEL_DEFN(label)) ":\n"                            \
            ".previous\n"                                                    \
            )
#endif
/*该代码定义了一个名为LOS_HAL_TABLE_END的宏，用于在LiteOS系统中生成汇编代码中的全局符号*/
/* This macro must be applied to any types whose objects are to be placed in tables */
#ifndef LOS_HAL_TABLE_TYPE
#define LOS_HAL_TABLE_TYPE LOSBLD_ATTRIB_ALIGN(LOSARC_ALIGNMENT)
#endif
/*通过这个宏的定义，可以在代码中统一设置表的类型或属性，使得系统中使用的表在对齐等方面具有统一的特性*/
#ifndef LOS_HAL_TABLE_EXTRA
#define LOS_HAL_TABLE_EXTRA(name) \
    LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".extra")
#endif
/*该代码定义了一个名为LOS_HAL_TABLE_EXTRA的宏，用于在LiteOS系统中生成汇编代码中的节（section）名称*/
#ifndef LOS_HAL_TABLE_WOW_ENTRY
#define LOS_HAL_TABLE_WOW_ENTRY(name)                                  \
    LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".wow.data") \
    LOSBLD_ATTRIB_USED
#endif
/*这段代码定义了一个名为LOS_HAL_TABLE_WOW_ENTRY的宏，用于在LiteOS系统中生成汇编代码中的节（section）名称，并将该符号标记为被使用。*/
#ifndef LOS_HAL_TABLE_SCATTER_ENTRY
#define LOS_HAL_TABLE_SCATTER_ENTRY(name)                                  \
    LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".scatter.data") \
    LOSBLD_ATTRIB_USED
#endif
/*这段代码定义了一个名为LOS_HAL_TABLE_SCATTER_ENTRY的宏，用于在LiteOS系统中生成汇编代码中的节（section）名称，并将该符号标记为被使用*/
#ifndef LOS_HAL_TABLE_ENTRY
#define LOS_HAL_TABLE_ENTRY(name)                                  \
    LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".data") \
    LOSBLD_ATTRIB_USED
#endif
/*该宏的作用是定义一个通用的节（section），用于存储数据，并确保相关符号被正确使用和链接到系统的可执行文件中*/
#ifndef LOS_HAL_TABLE_QUALIFIED_ENTRY
#define LOS_HAL_TABLE_QUALIFIED_ENTRY(name, _qual)                                  \
    LOSBLD_ATTRIB_SECTION(".liteos.table." X_STRING(name) ".data." X_STRING(_qual)) \
    LOSBLD_ATTRIB_USED
#endif
/*该宏的作用是定义一个用于存储特定类型数据的节（section），并将相关符号标记为被使用，以确保可执行文件中包含该数据*/
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

#endif /* _LOS_TABLES_H */
