// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 SmartLogic.
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : main.c
// Author        : xianfeng.du
// Created On    : 2022-06-25
// Last Modified :
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

#define _GNU_SOURCE
#include <sched.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "ospLog.h"
#include "ospShell.h"
#include "ucp_printf.h"
#include "drv_init.h"

int32_t test_case(uint32_t argc, int32_t* argvp);

extern OSP_STATUS osp_init();
extern uint8_t osp_sw_queue_init();

#ifdef ENABLE_JESD_TEST
extern int32_t UCP_API_RFIC_CellInit(void);
#endif


#define MAX_PARA_NUM 4
int32_t main(int32_t argc, char* argvp[])
{
    //uint32_t stc_cnt = 0, stc_cnt1 = 0;

    UCP_PRINT_DEBUG("Hello world from A72.");

    cpu_set_t mask;
    CPU_ZERO(&mask);
    CPU_SET(4,&mask);
    sched_setaffinity(0,sizeof(cpu_set_t),&mask);

#ifdef ENABLE_JESD_TEST
    UCP_API_RFIC_CellInit();
#endif
    osp_init();
    drv_init();

#ifdef PALLADIUM_TEST
    UCP_PRINT_DEBUG("entered testmode.");

    int32_t args[MAX_PARA_NUM];
    uint32_t count = argc - 1;
    if(count > MAX_PARA_NUM) {
        UCP_PRINT_ERROR("parameter number[%d] error",count);
        return -1;
    }

    for (uint32_t i=0; i<count;i++) {
        args[i] = (int32_t)strtoul(argvp[i+1],NULL,0);
    }

    test_case(count, args);
#endif

    while (1)
    {
        usleep(100);
    }

    return 0;
}

