⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_nav_upgrade.c

📁 dvd里面的一个文件系统的代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*  Terry,2004/3/30 05:13PM
*/
#include "global.h"
#include "cmd.h"
#include "func.h" 
#include "memmap.h"
#include "memmap0.h"
#include "util.h" 
#include "kernel.h"
#include "cfont.h"
#include "vfdfunc.h"
#include "osd.h"
#include "image.h"
#include "iop.h"
#include "memcfg.h"

#include "ircode.h"

#include "user_init.h"

#include "fsNAV.h"
#include "fsGUI.h"
#include "setup.h"
#include "fs96602.h"

#include "fsGUI1.h"
#include "timer.h"

// Added by houyiwu 9/18/2004 for defining "SPHE1000"
#ifndef SPHE1000
#include "ver.h"
#endif

#if defined(SUPPORT_CARD_STORAGE)||defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)//liweihua mod 20031219
#include "cardfs.h"
extern CARD_FILE       cardFile;
extern CARD_INFO       cardP;
#if defined(CF_CARD_WRITE) || defined(SPHE8202_FAT_Write_Function)//|| defined(WRITE_USB)
extern BYTE read_card_sign,flag_cf2cd,flag_cd2cf;
#endif
extern BYTE IsCardMediaRemove(void);
#endif

extern const BYTE ir_mapcode[256];  //Jefftest 20020606
//OSD related
extern void     osd_init(void);
extern void     osd_draw_rect(UINT32 xStart, UINT32 yStart, UINT32 xLen, UINT32 yLen, BYTE bkColor);
extern void     osd_init_setup(void);
extern void     osd_DrawLine(UINT32 xStart, UINT32 yStart, UINT32 xEnd, UINT32 yEnd, BYTE color, BYTE lineWidth);
extern void     DrawOSD_XO(BYTE bXO);


//FLASH related
#include "flash.h"
//extern UINT16   giFlashReadID; //Jeff 20020708

#ifdef SUPPORT_28X_FLASH	//yaowh add 2006-1-17 0:08
extern int		Parallel_FlashEraseUpgrade_28X(unsigned char *pBuf, unsigned int dwSize);
#endif

#ifndef DVDRELEASE
#define FSNAV_DBG
#endif

#define fsnav_printf(s...)  ((void)0)

#ifdef  FSNAV_DBG
#include "sio.h"
#include "emuio.h"
#undef  fsnav_printf
#define fsnav_printf        printf_w
#endif


#ifdef UPGRADE_TRAYOUT  //joshua add    04-07-13
    int trayout_flag = 0;
#endif    

#ifdef SUPPORT_SPI
#include "spi.h"
#endif

#ifdef SPHE1000
#define SMART_UPLOAD_BASE		0x80a00000
#endif

#ifdef DVD_AUDIO//2004-4-27 1:11
	extern UINT32 g_nAKeyFileLoc;
	extern UINT32 g_nAKeyFileSize;
#endif

//move to fsNAV.h  //hongfeng 2007/5/29 11:16
/*
#ifdef INDIGO_STYLE_OSDUI
#define UPGRADE_FONT_COLOR_INDEX 5
#define UPGRADE_BACKGROUND_COLOR_INDEX 6
#else
#define UPGRADE_FONT_COLOR_INDEX 2
#define UPGRADE_BACKGROUND_COLOR_INDEX 6
#endif
*/

void FSNav_clear_I2C_data(void);

void FSNav_UpgradeCountDown(UINT32  iCount)
{
	#ifdef UPGRADE_NOT_COUNT//libing 2005-6-30 23:06
	return;
	#endif
    BYTE    buf[10];

    psprintf(buf, "%02d", iCount);
    osd_DrawString(6, 3, buf, UPGRADE_FONT_COLOR_INDEX, UPGRADE_BACKGROUND_COLOR_INDEX);
}


int FSNav_DoUpgrade(BYTE* strVersion)
{
#ifdef UPGRADE_TRAYOUT    
    trayout_flag = 1;
#endif    
    BYTE buf[30];
    BYTE len, bOK = 1;
    BYTE *pDVDROM;
    int iRes = 0;
    UINT32  iCount;

#ifdef SUPPORT_28X_FLASH
	unsigned char	idM, idD;
	//UINT16			uFlashID;
#endif

#if defined(SUPPORT_CARD_STORAGE) || defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
   watchdog_onoff(0);    //fengjl add 2004-05-20 09:39  for usb upgrade
#endif

#ifdef DVD_AUDIO
	BYTE* pKeyFile;
	UINT32 nKeyAmount = 0;
	UINT32 nKeySize = 0;
	UINT32 nEnterNum = 0;
	UINT32 nPos = 0;
	BYTE b0, b1, b2, b3, b4;

	b0 = b1 = b2 = b3 = b4 = 0;
	pKeyFile = (BYTE *)(SDRAM_BASE + (A_JPEG_SERVO_YA + JPEG_SERVO_SIZE) * 1024);
#endif

#if defined(QSI_PORTABLE_DVD) && defined(QSI_PLATFORM)	 //qsi: added by johnson 20040720
	printf("FSNav_DoUpgrade> New Firmware Version = %s\n",strVersion);
#endif

#if defined(QSI_PORTABLE_DVD) && defined(QSI_PLATFORM)//qsi: modify by johnson 20040720
	#define COUNTDOWN_MAX   QSI_QUERY_FW_UPGRADE_WAITING_TIME
#else
	#define COUNTDOWN_MAX   3
#endif 
    
    ircmd_callback_check = NULL;
    cd_subtype = CDROM_BIN;

#ifdef SDRAM_16Mb_Mode//3-12-9 0:31 nono
    //find a good place for osd...  kevinmonkey 050926
    #if defined(COMPRESS_ROM_CODE_040) && defined(SUPPORT_DVD_FULL_SUBTITLE)
        #ifdef SUPPORT_MP4
    regs0->osd_base_addr = P_BIDIR_LUMA;
        #else   //COMPRESS_ROM_CODE_040&& SUPPORT_DVD_FULL_SUBTITLE but !SUPPORT_MP4
    regs0->osd_base_addr = (CDROM_CODE_YA+CDROM_CODE_SIZE);
        #endif
    #else   //!defined(COMPRESS_ROM_CODE_040) || !defined(SUPPORT_DVD_FULL_SUBTITLE)
    regs0->osd_base_addr = P_BIDIR_LUMA;
    #endif  //#if defined(COMPRESS_ROM_CODE_040) && defined(SUPPORT_DVD_FULL_SUBTITLE)*/
  	//if dvdrom.bin <= 1M Byte.//zhangkaiji add for bin>987k down proble. 
  	regs0->osd_base_addr = ((UINT32)(A_UDF_WORK_BUF+UDF_WORK_BUF_SIZE)+0x400); 
#endif//SDRAM_16Mb_Mode
   
    osd_init_setup();
	
    if (IsOSDChinese())
        psprintf(buf, "         %s           ", &_OsdMessegeFont1[osd_font_mode][STR_OS_SMART_UPGRADE][0]);
    else
        psprintf(buf, "        %s       ", &_OsdMessegeFont1[osd_font_mode][STR_OS_SMART_UPGRADE][0]);
	
    len = strlen(buf);
	
    osd_draw_rect(4*16, 3*26, 28*16, 9*26, UPGRADE_BACKGROUND_COLOR_INDEX);
    
    //top
    osd_DrawLine(4*16, 3*26, 4*16+28*16, 3*26, 2, 1);
    //left
    osd_DrawLine(4*16-2, 3*26, 4*16-2, 3*26+9*26, 2, 1);
    //bottom
    osd_DrawLine(4*16, 3*26+9*26, 4*16+28*16, 3*26+7*26, 11, 1);
    //right
    osd_DrawLine(4*16+28*16, 3*26, 4*16+9*26, 3*26+28*16, 11, 1);
	
    osd_DrawString(4, 3, buf, UPGRADE_FONT_COLOR_INDEX, UPGRADE_BACKGROUND_COLOR_INDEX); //2:font color, 6:background color
	
    psprintf(buf, "%s", &_OsdMessegeFont1[osd_font_mode][STR_OS_READ][0]); //Jeff 20020527
    len = strlen(buf);

    osd_DrawString(6, 5, buf, UPGRADE_FONT_COLOR_INDEX, UPGRADE_BACKGROUND_COLOR_INDEX); //2:font color, 6:background color
    
    
    #if defined(SPHE1000) && !defined(DVB1000_NON_OS)
    pDVDROM = (BYTE *)(SMART_UPLOAD_BASE);
    	
    #else
    //Move system image to DRAM
      #ifdef MEM_GRAPH_LARGE
    //note:when define MP3_LARGE_GUI,A_UDF_WORK_BUF = GP_REF1_CHROMA + GP_CHROMA_SIZE,JPEG PS is not enough;
    //when NTSC mode,"dvdrom.bin" is not put into UDF buf,but put buf after GP chroma.suqiaoli add 2004-10-16
        pDVDROM = (BYTE *)(SDRAM_BASE + (GP_REF0_CHROMA + GP_CHROMA_SIZE) * 1024);
    #else
    pDVDROM = (BYTE *)(SDRAM_BASE + (A_UDF_WORK_BUF+UDF_WORK_BUF_SIZE) * 1024);
    #endif
	
    #endif
	
#if defined(SUPPORT_CARD_STORAGE)||defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
    if (media_type==MEDIA_CARD) {
        UINT32  nLBA;
		
        cardFile.stLBA = msf2l(pFsJpeg->gifsMSFDVDRom);
//        cardFile.stClus = CardLBA2Clus( cardFile.stLBA );
        cardFile.stClus = FSLBA2Clus( cardFile.stLBA );//linrc rename.20041204
        cardFile.iFileSize = pFsJpeg->gifsDVDRomSize;
        cardFile.curLBA = cardFile.stLBA;
        cardFile.curClus = cardFile.stClus;
        cardFile.iLeaveSize = cardFile.iFileSize;
		
        nLBA = (pFsJpeg->gifsDVDRomSize + cardP.bytePerSec - 1) / cardP.bytePerSec;
		
//        CardReadStream(&cardFile, nLBA, pDVDROM);
        FSReadStream(&cardFile, nLBA, pDVDROM);//linrc rename.20041205
    } else
#endif
    {
		ran_read(pDVDROM, pFsJpeg->gifsMSFDVDRom, pFsJpeg->gifsDVDRomSize);
    }

	// read DVD_AUDIO key file, Robert 030820
#ifdef DVD_AUDIO
	if (g_nAKeyFileLoc != 0)
	{
		ran_read(pKeyFile, g_nAKeyFileLoc, 2048); // robert 2004/02/18, read 2048 bytes only to identify file header
	}
#endif
	
    //Calculate CheckSum
    {
        BYTE    *p, bl, bh;
        UINT32  *pSum, iSum = 0, iNext = 0;
        UINT32  iIndex = 0x4f;
		
        //we store check in 0x20th byte
        pSum = (UINT32 *)(pDVDROM + 0x20);
        //printf("Origional checksum=%08x\n", *pSum);
		
        //from 0x50th byte to caculate checksum
        p = (BYTE *)(pDVDROM + 0x50);
		
        while (iIndex < pFsJpeg->gifsDVDRomSize)
        {
            bl = *p++;
            iIndex++;
            
            if (iIndex < pFsJpeg->gifsDVDRomSize)
            {
                bh = *p++;
                iIndex++;
            }
            else
            {
                bl = 0;
                bh = 0;
            }
			
            iSum = iSum + iNext;
            iNext = (unsigned int)bh * 256U + (unsigned int)bl;
        }
        iNext &= 0xFF;
        iSum += iNext;
		
        //printf("Read checksum=%08x\n", iSum);
        
        
        if (*pSum != iSum)
        {
            printf("Checksum Error\n");
            return -1;
        }
        else if((*pSum == 0)&&(iSum == 0))  //hongfeng add for when read rom.bin error 2006/9/28 19:46
        {
            printf("read rom.bin Error\n");
            return -1;
        }

    }
    
    #if defined(UPGRADE_TRAYOUT)&&(!defined(EASTECH_DVD)) //jwk mark 050811
            ircmd_trayout();
            delay_srv_10ms(500);
            trayout_flag = 0;
    #endif

#ifdef DVD_AUDIO
	if (g_nAKeyFileLoc != 0)
	{
		BYTE buf[10];

		// check key numbers
		nKeyAmount = getUINT32(pKeyFile + 5);
		nKeySize = getUINT32(pKeyFile + 9);

		if (nKeyAmount > 99999) // max key counts up to 99999
			nKeyAmount = 99999;

		//psprintf(buf, "%d %d", nKeyAmount, nKeySize);
		//osd_DrawString(23, 3, buf, 2, 6);

		psprintf(buf, "ENTER 0~%d:", nKeyAmount);
		osd_DrawString(8, 6, buf, 2, 6);

		// show a region to enter number
		psprintf(buf, "%d", b4);
		osd_DrawString(23, 6, buf, 2, 5);
		psprintf(buf, "%d", b3);
		osd_DrawString(24, 6, buf, 2, 4);
		psprintf(buf, "%d", b2);
		osd_DrawString(25, 6, buf, 2, 4);
		psprintf(buf, "%d", b1);
		osd_DrawString(26, 6, buf, 2, 4);
		psprintf(buf, "%d", b0);
		osd_DrawString(27, 6, buf, 2, 4);
	}
#endif

#ifdef QSI_PLATFORM
#ifdef QSI_SUPPORT_QSIVER_INFO_WHEN_UPGRADE
    psprintf(buf," OLD VER: %s%s",QSI_MASTER_VER,QSI_SLAVE_VER);
    osd_DrawString(4, 5, buf, 2, 6);
    
    if (IsOSDChinese())
        #ifdef USE_KOREAN_OSD       //clead korean 2003-10-23 
        psprintf(buf, " %s%s %s", &_OsdMessegeFont1[osd_font_mode][STR_OS_UPGRADE_TO][0], strVersion, Ch_question);
        #else
        psprintf(buf, " %s%s%s %s", &_OsdMessegeFont1[osd_font_mode][STR_OS_UPGRADE_TO][0], strVersion, Ch_ban, Ch_question);
        #endif
    else
        psprintf(buf, " %s%s %s", &_OsdMessegeFont1[osd_font_mode][STR_OS_UPGRADE_TO][0], strVersion, Ch_question);
    
    len = strlen(buf);
    
    //osd_DrawString(6, 5, buf, 2, 6); //2:font color, 6:background color
    osd_DrawString(4, 6, buf, UPGRADE_FONT_COLOR_INDEX, UPGRADE_BACKGROUND_COLOR_INDEX); //2:font color, 6:background color

#else
    if (IsOSDChinese())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -