/* ----------------------------------------------------------------------------
 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
 * Description: Runstop HeadFile
 * 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.
 * --------------------------------------------------------------------------- */
/*该函数定义提供了运行停止功能所需的接口和参数类型，为嵌入式系统中的运行停止操作提供了基本的支持
/**
 * @defgroup los_runstop Wakeup
 * @ingroup kernel
 */

#ifndef _LOS_RUNSTOP_H 组的定义：该组包含了一些与运行停止有关的函数和宏定义。
#define _LOS_RUNSTOP_H

#include "los_typedef.h"包含了 LOS Kernel 所需的基本类型定义。

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

/**
 * @ingroup  los_runstop         ##该回调函数类型定义用于在唤醒阶段调用。它允许用户定义一个函数，当系统从休眠状态唤醒时，该函数将被调用
 * @brief Define the type of a runstop callback function.
 *
 * @par Description:
 * This API is used to define the type of a runstop callback function,
 * so that it can be called in the phase of wake-up.
 *
 * @attention
 * <ul>
 * <li>None.</li>
 * </ul>
 *
 * @param  None.
 *
 * @retval None.
 * @par Dependency:
 * <ul><li>los_runstop.h: the header file that contains the API declaration.</li></ul>
 * @see None.
 * @since Huawei LiteOS V100R001C00
 */
typedef VOID (*RUNSTOP_CALLBACK_FUNC)(VOID);/*函数指针类型RUNSTOP_CALLBACK_FUNC，用于定义运行停止时的回调函数，没有参数和返回值

/**
 * @ingroup  los_runstop
 * @brief Define the type of a flash-reading function.
 *
 * @par Description:
 * This API is used to define the type of a flash-reading function,
 * so that it can be called to read data from a certain flash.
 *
 * @attention
 * <ul>
 * <li>None.</li>
 * </ul>
 *
 * @param  memAddr [IN] The memory starting address where to write the data reading from a certain flash.
 * @param  start   [IN] The starting address to read data from a certain flash.
 * @param  size    [IN] The size of data reading from a certain flash.
 *
 * @retval #INT32         The size of data read from flash.
 * @par Dependency:
 * <ul><li>los_runstop.h: the header file that contains the API declaration.</li></ul>
 * @see None.
 * @since Huawei LiteOS V100R001C00
 */
typedef INT32 (*FLASH_READ_FUNC)(VOID *memAddr, size_t start, size_t size);/*定义了一个名为FLASH_READ_FUNC的函数指针类型，用于定义一个从Flash中读取数据的函数
memAddr：用于存储从Flash中读取数据的内存起始地址
start：从Flash中读取数据的起始地址
size：从Flash中读取的数据大小。

/**
 * @ingroup  los_runstop
 * @brief Define the type of a flash-writing function.
 *
 * @par Description:
 * This API is used to define the type of a flash-writing function,
 * so that it can be called to write data to a certain flash.
 *
 * @attention
 * <ul>
 * <li>None.</li>
 * </ul>
 *
 * @param  memAddr [IN] The memory starting address where to read data and be wrote to a certain flash.
 * @param  start   [IN] The starting address of a certain flash to write data.
 * @param  size    [IN] The size of data writing to a certain flash.
 *
 * @retval #INT32         The size of data write to flash.
 * @par Dependency:
 * <ul><li>los_runstop.h: the header file that contains the API declaration.</li></ul>
 * @see None.
 * @since Huawei LiteOS V100R001C00
 */
typedef INT32 (*FLASH_WRITE_FUNC)(VOID *memAddr, size_t start, size_t size);/*定义一个用于写入flash数据的函数类
memAddr：要从中读取数据并写入到某个flash的内存起始地址。
start：要写入数据的某个flash的起始地址。
size：要写入到某个flash的数据的大小

/**
 * @ingroup los_runstop
 * Define the structure of the parameters used for runstop.
 *
 * Information of specified parameters passed in during runstop.
 */
typedef struct tagRunstopParam {
    RUNSTOP_CALLBACK_FUNC pfIdleWakeupCallback;   /*< 空闲任务中的唤醒回调函数 */
    RUNSTOP_CALLBACK_FUNC pfWakeupCallback;       /*< 唤醒回调函数 */
    RUNSTOP_CALLBACK_FUNC pfImageDoneCallback;    /*< 内存存储完成后的回调函数 */
    FLASH_READ_FUNC pfFlashReadFunc;              /*< 从某个闪存中读取数据的抽象函数 */
    FLASH_WRITE_FUNC pfFlashWriteFunc;            /*< 向某个闪存中写入数据的抽象函数 */
    size_t uwFlashReadAlignSize;                  /*< 从某个闪存中读取数据时的块对齐大小 */
    size_t uwFlashEraseAlignSize;                 /*< 擦除某个闪存中数据时的块对齐大小 */
    size_t uwFlashWriteAlignSize;                 /*< 向某个闪存中写入数据时的块对齐大小 */
    UINTPTR uwWowFlashAddr;                     /* < 存储内存的闪存起始地址，地址应与闪存写入对齐长度对齐 */
    UINTPTR uwImageFlashAddr;                   /* < 整个应用程序镜像烧录到的闪存起始地址 */
} RUNSTOP_PARAM_S;/*是用于传递和配置运行停止功能所需的参数信息 

/**
 * @ingroup los_runstop
 * @brief Store the memory image on a flash.
 *
 * @par Description:
 * This API is used to store the memory image to the flash starting address passed in by a user.
 * @attention
 * <ul>
 * <li>uwWowFlashAddr in runstopParam specifies the flash starting address to which the memory image
 * is to be stored.It needs to be ensured that the flash starting address and the flash of the memory image
 * size after the starting address are not occupied.</li>
 * </ul>
 *
 * @param runstopParam [IN] Parameter which contains key information for runstop to use, including flash starting
 *                          address to which the memory image is to be stored, etc.
 *
 * @retval None.
 * @par Dependency:
 * <ul><li>los_runstop.h: the header file that contains the API declaration.</li></ul>
 * @see
 * @since Huawei LiteOS V100R001C00
 */
extern VOID LOS_MakeImage(const RUNSTOP_PARAM_S *runstopParam);/*定义了一个名为LOS_MakeImage的函数，用于将内存映像存储到flash中。
函数接受一个名为runstopParam的参数，该参数包含了一些关键信息，用于runstop使用，包括要存储内存映像的flash起始地址等。
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

#endif /* _LOS_RUNSTOP_H */
