/**
 * @file hv_vos_Cache.c
 * @brief vos cache source code
 * @details 
 * @author HiView SoC Software Team
 * @version 0.0.1
 * @date 20230301
 * @copyright Copyright(c),2023-3, Hiview Software. All rights reserved.
 * @par History: 
 * <table>
 * <tr><th>author                     <th>date           <th>description
 * <tr><td>HiView SoC Software Team   <td>20230301       <td>Create and first Version.
 * </table>
**/

#include <mips/cpu.h>

#include "hv_vos_Types.h"
#include "hv_vos_Cache.h"


__attribute__((long_call)) void mips_flush_dcache (void);
__attribute__((long_call)) void mips_flush_icache (void);
__attribute__((long_call)) void mips_clean_icache (vaddr_t kva, size_t n);
__attribute__((long_call)) void mips_clean_dcache (vaddr_t kva, size_t n);

/* ##########################  Cache functions  #################################### */

/**
  \brief   Enable I-Cache
  \details Turns on I-Cache
  */
void Hv_Vos_EnableICache(void)
{
    return;
}


/**
  \brief   Disable I-Cache
  \details Turns off I-Cache
  */
void Hv_Vos_DisableICache(void)
{
    return;
}


/**
  \brief   Invalidate I-Cache
  \details Invalidates I-Cache
  */
void Hv_Vos_InvalidAllICache(void)
{
    mips_flush_icache();
}


/**
  \brief   Enable D-Cache
  \details Turns on D-Cache
  \note    I-Cache also turns on.
  */
void Hv_Vos_EnableDCache(void)
{
    return;
}


/**
  \brief   Disable D-Cache
  \details Turns off D-Cache
  \note    I-Cache also turns off.
  */
void Hv_Vos_DisableDCache(void)
{
    return;
}


/**
  \brief   Invalidate D-Cache
  \details Invalidates D-Cache
  \note    I-Cache also invalid
  */
void Hv_Vos_InvalidAllDCache(void)
{
    mips_flush_dcache();
}

void Hv_Vos_InvalidAllCache(void){
    mips_flush_cache();
}

void Hv_Vos_InvalidICache(UINT32 uiVaddr, UINT32 uiSize)
{
    mips_clean_icache(uiVaddr, uiSize);
}

void Hv_Vos_InvalidDCache(UINT32 uiVaddr, UINT32 uiSize)
{
    mips_clean_dcache(uiVaddr, uiSize);
}

void Hv_Vos_InvalidCache(UINT32 uiVaddr, UINT32 uiSize)
{
    mips_clean_cache(uiVaddr, uiSize);
}

