Ejemplo n.º 1
0
void MsApi_kernelProtect(void)

{
    MS_U32 u32LxStart=0,u32Size=0;
    char lx1[32],lx2[32],lx3[32], *start=0;
    char dram_size1[32], dram_size2[32];
    MS_U8 u8BlockMiu0Index=0;
    MS_U8 u8BlockMiu1Index=0;
//LX_MEM=0x9C00000 EMAC_MEM=0x100000 DRAM_LEN=0x20000000 LX_MEM2=0x50E00000,0xC200000 LX_MEM3=0xB0000000,0x0000000
    char * tok;
//MIU_INTERVAL
    char *s = getenv("MS_MEM");

    MDrv_MIU_Init();
    if (s != NULL)
    {
        u32Lx1Start = CONFIG_KERNEL_START_ADDRESS;
        u32LxStart = MsOS_VA2PA(CONFIG_KERNEL_START_ADDRESS);

        tok = strtok (s," ");
        while (tok != NULL)
        {
            if((start = strstr (tok, "LX_MEM=")) != NULL)
            {
                memset(lx1, 0, sizeof(lx1));
                strncpy(lx1, tok+7, strlen(lx1)-7);
            }
            else if((start = strstr (tok, "LX_MEM2=")) != NULL)
            {
                memset(lx2, 0, sizeof(lx2));
                strncpy(lx2, tok+8, strlen(lx2)-8);
            }
            else if((start = strstr (tok, "LX_MEM3=")) != NULL)
            {
                memset(lx3, 0, sizeof(lx3));
                strncpy(lx3, tok+8, strlen(lx3)-8);
            }
            else if((start = strstr (tok, "DRAM_SIZE1=")) != NULL)
            {
                memset(dram_size1, 0, sizeof(dram_size1));
                strncpy(dram_size1, tok+11, strlen(dram_size1)-8);
                u32DramSize1=(simple_strtoul(dram_size1, NULL, 16));
                MDrv_MIU_Dram_Size(E_MIU_0, dram_size_to_enum(u32DramSize1));
            }
            else if((start = strstr (tok, "DRAM_SIZE2=")) != NULL)
            {
                memset(dram_size2,0,sizeof(dram_size2));
                strncpy(dram_size2, tok+11, strlen(dram_size2)-8);
                u32DramSize2=(simple_strtoul(dram_size2, NULL, 16));
                MDrv_MIU_Dram_Size(E_MIU_1, dram_size_to_enum(u32DramSize2));
            }
            tok = strtok (NULL, " ");
        }

        // decide whether to do kernel protect or not
        s = getenv("KERNEL_PROTECT");
        if (s != NULL)
        {
            tok = strtok (s," ");
            while (tok != NULL)
            {
                if((start = strstr (tok, "DRAM_SIZE1=")) != NULL)
                {
                    memset(dram_size1, 0, sizeof(dram_size1));
                    strncpy(dram_size1, tok+11, strlen(dram_size1)-8);
                    u32DramSize1=(simple_strtoul(dram_size1, NULL, 16));
                    MDrv_MIU_Dram_Size(E_MIU_0, dram_size_to_enum(u32DramSize1));
                }
                else if((start = strstr (tok, "DRAM_SIZE2=")) != NULL)
                {
                    memset(dram_size2,0,sizeof(dram_size2));
                    strncpy(dram_size2, tok+11, strlen(dram_size2)-8);
                    u32DramSize2=(simple_strtoul(dram_size2, NULL, 16));
                    MDrv_MIU_Dram_Size(E_MIU_1, dram_size_to_enum(u32DramSize2));
                }
                tok = strtok (NULL, " ");
            }
        }


        //if(lx1!= NULL)
        {
            u32Lx1Size = u32Size = (simple_strtoul(lx1, NULL, 16));
            if(u32Size>0)
            {

                if(u32LxStart>=MIU_INTERVAL)
                {
                    MsDrv_kernelProtect(u8BlockMiu1Index,u32LxStart,(u32LxStart + u32Size));
                    u8BlockMiu1Index+=1;
                }
                else
                {
                    MsDrv_kernelProtect(u8BlockMiu0Index,u32LxStart,(u32LxStart + u32Size));
                    u8BlockMiu0Index+=1;
                }
            }
        }
        // if(lx2 != NULL)
        {
            tok=strtok(lx2,",");
            u32Lx2Start = u32LxStart = (simple_strtoul(tok, NULL, 16));
            tok = strtok (NULL, ",");
            u32Lx2Size = u32Size = (simple_strtoul(tok, NULL, 16));
            if(u32LxStart!=0 && u32Size!=0)
            {
                if(u32DramSize1==0x40000000)
                {
                    u32LxStart=(u32LxStart-0x40000000);
                }
                else
                {
                    u32LxStart=MsOS_VA2PA(u32LxStart);
                }
                if(u32LxStart>=MIU_INTERVAL)
                {
                    MsDrv_kernelProtect(u8BlockMiu1Index,u32LxStart,(u32LxStart + u32Size));
                    u8BlockMiu1Index+=1;
                }
                else
                {
                    MsDrv_kernelProtect(u8BlockMiu0Index,u32LxStart,(u32LxStart + u32Size));
                    u8BlockMiu0Index+=1;
                }
            }

        }

        //if(lx3 != NULL)
        {
            tok=strtok(lx3,",");
            u32Lx3Start = u32LxStart = (simple_strtoul(tok, NULL, 16));
            tok = strtok (NULL, ",");
            u32Lx3Size = u32Size = (simple_strtoul(tok, NULL, 16));
            if(u32LxStart!=0 && u32Size!=0)
            {
                if(u32DramSize1==0x40000000)
                {
                    u32LxStart=(u32LxStart-0x40000000);
                }
                else
                {
                    u32LxStart=MsOS_VA2PA(u32LxStart);
                }
                if(u32LxStart>=MIU_INTERVAL)
                {
                    MsDrv_kernelProtect(u8BlockMiu1Index,u32LxStart,(u32LxStart + u32Size));
                    u8BlockMiu1Index+=1;
                }
                else
                {
                    MsDrv_kernelProtect(u8BlockMiu0Index,u32LxStart,(u32LxStart + u32Size));
                    u8BlockMiu0Index+=1;
                }
            }
        }

         if(ENABLE_MSTAR_PM_SWIR==1)
        {
            MsDrv_PMProtect(3,0x0,0x10000); //64K run time PM
        }
    }



    // decide whether to do kernel protect bist or not
    s = getenv("kernelProtectBist");
    tok = strtok (s," ");
    if (tok != NULL && 0 == strcmp(tok, "block"))
        u32Block = 1;
}
Ejemplo n.º 2
0
/*
 * Subroutine:  do_tuner
 *
 * Description: Handler for 'tuner' command..
 *
 * Inputs:	argv[1] contains the subcommand
 *
 * Return:      None
 *
 */
int do_dmx_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
    MS_PHYADDR      phyFW;
    MS_U8*          pu8FW;
    DMX_FLOW_INPUT inSrc;
    if (argc<1)
    {
        printf ("Usage:\n%s\n", cmdtp->usage);
        return 1;
    }
    inSrc = (DMX_FLOW_INPUT)simple_strtoul(argv[1], NULL, 10);
    MDrv_MMIO_Init(); // must init MMI before init DMX

    pu8FW = (MS_U8*)(((int)u8TSFwBuf + 0x7F) & (~0x7F));
    pu8FW = (MS_U8*)MsOS_VA2PA((MS_U32)pu8FW);
    pu8FW = (MS_U8*)MsOS_PA2KSEG1((MS_U32)pu8FW);
    memcpy(pu8FW, u8TSPFirmware, sizeof(u8TSPFirmware));
    MsOS_FlushMemory();

    phyFW = (MS_PHYADDR)MsOS_VA2PA((MS_U32)pu8FW);
    if (DMX_FILTER_STATUS_ERROR == MApi_DMX_SetFW(phyFW, sizeof(u8TSPFirmware)))
    {
        printf("DeMux>>ERROR! SetFW fail\n");
        return -1;
    }
    MApi_DMX_SetHK(TRUE);
    if (DMX_FILTER_STATUS_ERROR == MApi_DMX_Init())
    {
        printf("DeMux>>ERROR! TSP init fail\n");
        return -1;
    }

#if defined(CONFIG_URANUS4) || defined(CONFIG_KRONUS) || defined(CONFIG_KAISERIN) || defined(CONFIG_KENYA)
    // set VQ for TSP, set FW/VQ for TSP2
    MS_U8*          pu8VQ;
    MS_PHYADDR      phyVQ;
    DMX_TSPParam    param;

    memset(&param,0,sizeof(param));
    pu8VQ = (MS_U8*)(((int)u8TSVQBuf + 0x7) & (~0x7));
    phyVQ = (MS_PHYADDR)MsOS_VA2PA((MS_U32)pu8VQ);

    // printf("[%s][%d] (fw, vq) = (0x%08x 0x%08x)\n", __FUNCTION__, __LINE__,
    // phyFW, phyVQ);
    param.phyFWAddr = (MS_PHYADDR)phyFW;
    param.u32FWSize = TSP_FW_SIZE;
    param.phyVQAddr = (MS_PHYADDR)phyVQ;
    param.u32VQSize = TSP_VQ_SIZE;//(200*16 + 200*8 + 200*8);

    if (DMX_FILTER_STATUS_ERROR == MApi_DMX_TSPInit(&param))
    {
        printf("DeMux>>ERROR! TSP set fw/vq fail\n");
        return -1;
    }
#endif

    if (DMX_FILTER_STATUS_OK!= MApi_DMX_FlowSet(DMX_FLOW_PLAYBACK, inSrc, TS_CLK_INV, TRUE, TS_PARALLEL_OUTPUT))
    {
        printf("DeMux>>ERROR! switch to demod fail\n");
        return -1;
    }

    return 0;
}