#include "inter_vector.h"
#include "ucps2-intrin.h"

#include "debug.h"



int sw_debug_enable;
struct ucp_task *sw_debug_addr;
struct ucp_task *sw_debug_info;

int no_idle_sw_op = 0;
struct ucp_task *no_idle_sw_info;


int smart_os_debug_init(uint32_t debug_base_addr, uint32_t len_bytes)
{
    if(debug_base_addr <= 0x10000000)
    {
        return -1;
    }
    if (len_bytes < 0x40)
    {
        return -2;
    }
  
    sw_debug_enable = 1;
    sw_debug_addr = (struct ucp_task *)debug_base_addr;
    sw_debug_info = (struct ucp_task *)sw_debug_addr;

    return 0;
}


void os_debug(void * addr , uint32_t v)
{
    if(sw_debug_enable != 0)
    {
        do_write(addr,v);
    }
}


int smart_no_idle_sw_init(uint32_t debug_base_addr, uint32_t lens)
{
    if(debug_base_addr <= 0x10000000)
    {
        return -1;
    }
    if (lens < 0x40)
    {
        return -2;
    }
  
    no_idle_sw_op = 1;
    no_idle_sw_info = (struct ucp_task *)debug_base_addr;

    return 0;
}

void no_idle_debug(void *addr,uint32_t v)
{
    if(no_idle_sw_op != 0)
    {
        do_write(addr,v);
    }
}
