/*
 * @file hv_boot_Common.h
 * @brief Header file of ddr .
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+)
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-18
 */

#ifndef __HV_BOOT_COMMON_H
#define __HV_BOOT_COMMON_H

#define BOOT_DEBUG_LEVEL_VERBOSE 0
#define BOOT_DEBUG_LEVEL_DEBUG   1
#define BOOT_DEBUG_LEVEL_INFO    2
#define BOOT_DEBUG_LEVEL_WAR     3
#define BOOT_DEBUG_LEVEL_ERR     4
#define BOOT_DEBUG_CONTR_LEVELL  3

#define BOOT_RD32(addr)        (*(volatile unsigned int*)((addr) | 0xa0000000))
#define BOOT_WT32(addr, value) (*(volatile unsigned int*)((addr) | 0xa0000000) = (value))

#define BOOT_W32_FIELD(addr, field, value) do {          \
    unsigned int _val = BOOT_RD32(addr);                 \
    ((addr##_struct*)&(_val))->field = value;           \
    BOOT_WT32(addr, _val);                               \
} while (0)

#define BOOT_R32_DECL_VAR() unsigned int _reg_val

#define BOOT_R32_FIELD(addr, field)                      \
    (_reg_val = BOOT_RD32(addr), ((addr##_struct*)(void*)&(_reg_val))->field)

void Hv_Boot_PrintHex(unsigned int Level, unsigned int uiVal);
void Hv_Boot_Print_String(unsigned int Level, const char *pcString);
void Hv_Boot_Wait_Us(unsigned int Us);
void Hv_Boot_Wait_Ms(unsigned int Ms);
#endif
