sysmain.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:11k
- /*
- ** FILE
- ** sysmain.c
- **
- ** DESCRIPTION
- **
- ** sysmain.c now contains system-level init functions, which
- ** must resides in ROM (well, non-volatile devices that is
- ** reliable through failure.)
- */
- #include "config.h"
- #include "global.h"
- #include "regmap.h"
- #include "pu8560.h"
- #include "reset.h"
- #include "drv.h"
- #include "emuio.h"
- #include "kernel.h"
- #include "ata.h"
- #include "macro.h"
- #include "viddec.h"
- #include "nav.h"
- #include "image.h"
- #include "tvif.h"
- #include "user_init.h"
- #include "cardfs.h"
- #include "lbc.h"
- #include "sinf.h"
- //#include "memmap0.h"
- #include "gpio.h"
- #include "LanguageUtil.h" // 2004/09/19 yltseng
- #ifdef SUPPORT_SPI
- #include "spi.h"
- #endif
- #ifndef DVDRELEASE
- //#define SYSMAIN_DBG 1
- #endif
- #ifdef SUPPORT_CARD_STORAGE
- extern void CardReset(void);
- #endif
- //#define ERROR_CONCEALMENT
- //#define RUN_TESTS
- //#define TEST_ROM
- //#define TEST_JPEG
- //#define TEST_CPPM
- #ifdef HDMI
- extern void ResetAuthentStates();
- #endif
- #ifdef SUPPORT_USB//liweihua 2003-9-25
- #ifdef HOST_UHCI
- extern void sl811h_init(void);
- #else
- extern void uhci_reset(void);
- #endif
- #endif
- extern void ShowTitle();
- extern void InitVar(void); // in sysmain2.c
- extern void set_default_value(void);
- extern void ap_main(void); //Jeff 20010717
- extern int font_decompress(void); // in osdfont_decompress.c
- extern void init_I2C_panel(void);
- #ifndef RUN_TESTS
- #define run_tests() ((void)0)
- #else
- //
- // FUNCTION
- // run_tests()
- //
- // DESCRIPTION
- // run test programs after booting
- //
- void
- run_tests()
- {
- //tv_setup_output(TVOUT_SVIDEO);//set S-video output(composited+S-Video)(0x00:D0-D1-D2-D3=CVBS-C-Y-CVBS)
-
- #ifdef TEST_ROM
- test_rom_based_video();
- #endif
- #ifdef TEST_CPPM
- test_cppm();
- #endif
- #ifdef TEST_JPEG
- test_jpeg();
- #endif
- }
- #endif
- share share_data;
- DataSaved *pDSV;
- FSJPEGDATA *pFsJpeg;
- UINT8 srv_on = 0;
- UINT8 power_on_mute = 1;
- #ifdef SPHE1000 //MIKEY
- extern UINT8 f_drv_init; // run drv_init
- #endif
- #define GET_RTC_15_0() (regs0->rtc_15_0)
- #include "sysmain_inc.h"//terry,2004/1/28 10:24AM
- #ifdef DVD_SERVO
- #include "system_servo.c"
- #endif
- #include "system_sleep.c"
- //#include "system_jpeg_logo.c" // 2004/10/07 yltseng
- #include "system_util.c"
- #include "system_mjpeg.c"
- #include "system_mp4.c"
- #include "system_game16.c"
- //#include "jpegeffect_help.c"// liulifeng ,2004-6-30 14:28//nono mark it.4-7-15 0:56
- #ifdef SUPPORT_HDD_ACCESS
- int load_hdd_init()
- {
- int i;
- UINT32 lbaRoot;
- watchdog_onoff(0);
- atapi_share_rom_bus();
- MIPS_flush_LBC_cache();
- delay_1ms(3000);
- for(i=0;i<10;i++) {
- // if(CardIsExist()) {
- if(FSIsExist()) {
- printf("Sunplus DVD load HDD driver OK!!n");
- break;
- }
- delay_1ms(100);
- }
- // lbaRoot = CardGetRoot();
- lbaRoot = FSGetRoot();
- }
- #endif
- //
- //
- // main proc.
- //
- //
- int dvd_main(void)
- {
- #ifdef PORTABLE_POWER_ON_MUTE
- regs0->sft_cfg3 &=~((0x01<<6));//CHENZZ FOR LRCK=0.for power on noise
- #endif
- #ifdef SUPPORT_MIDI //Jeff 20040420
- if ( chipid_check_midi() == 0)
- {
- volatile int *buf;
- buf = (volatile int *)(0xBFFE8008);
- *buf = -1;
- }
- #endif
- #ifdef PULIANG_DVD //yaowh add 04-12-17
- regs0->gpio_master[35 / 16] |= (0x1 << (35 % 16));
- GPIO_E_SET(35,1);
- GPIO_O_SET(35,1);
- #endif
- #if defined(SUPPORT_AUDIO_RESET)&&defined(HANYANG_4340_AUDRESET)
- regs0->sft_cfg3 &= ~(0x1 << 4);
- regs0->gpio_master[60 / 16] |= (0x01 << (60 % 16));
- regs0->gpio_oe[60 / 16] |= (0x01 << (60 % 16));
- regs0->gpio_out[60 / 16] |= (0x01 << (60 % 16));
- delay_srv_10ms(30);
- #endif
-
- #ifdef SUPPORT_SPI
- regs0->sft_cfg0 &= ~(0x3fff << 1); //pin 129~131, pin 133~136 is GPIO
- regs0->gpio_master[SPI_DATAIN / 16] |= (0x1 << (SPI_DATAIN % 16));
- regs0->gpio_oe[SPI_DATAIN / 16] |= (0x1 << (SPI_DATAIN % 16));
- regs0->gpio_out[SPI_DATAIN / 16] |= (0x1 << (SPI_DATAIN % 16));
- #endif
-
- //
- //
- #ifdef ROM_SDRAM_SHARE_BUS
- regs0->sdctrl_gclk_dis = 8 << 8;
- regs0->stamp = 0x01;
- #endif
-
- pDSV = &(share_data.DSV);
- // pFsJpeg.cdg = &(share_data.VCD);
- //#ifdef SHARE_NAV_VAR
- pFsJpeg = &(share_data.JPEG);
- //#endif
- //#if defined(SUPPORT_CARD_STORAGE)||defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
- #if defined(SUPPORT_CARD_STORAGE)//liweihua mod 20040324
- media_type = MEDIA_CARD;
- #endif
- //
- // setup FPGA-emulation system related controls.
- #ifdef EMULATION
- setup_emu();
- #endif
- #ifdef STBY_CONTROLLER_IO_61PIN_12GPIO
- GPIO_M_SET(12,1); //pin 61 gpio 12 s-by
- GPIO_E_SET(12,1); //pin 61 gpio 12 s-by
- GPIO_O_SET(12,1); //pin 61 gpio 12 s-by
- #endif
- //
- // initialize system hardware.
- reset_all();
- #ifdef DVI_I2C_SET
- #ifdef SPHE8202
- // i2c_init_io_risc();
- #else
- // select GPIO 0,1 for mips I2C tjf 04-04-29
- regs0->gpio_master[0]|=0x3; //gpio 0,1 for risc
- regs0->gpio_oe[0]|=0x03;
- #endif
- #endif
- #ifdef RESET_TO_DVI311//tjf 04-05-06
- #ifdef SPHE8202
- regs0->sft_cfg3 &= (~(0x01<<7));
- regs0->sft_cfg8 &= (~(0x03<<8));
- regs0->sft_cfg3 &= (~(0x01<<4));
- //regs0->sft_cfg8 &= (~(0x03<<8));
-
- #else
- #define RESET_DVI311_GPIO 40
- // regs0->gpio_master[2]|=(1<<8);
- // regs0->gpio_oe[2]|=(1<<8);
- //GPIO_M_SET(RESET_DVI311_GPIO, 1); //dvi311_reset is gpio 37,pin129
- //GPIO_E_SET(RESET_DVI311_GPIO, 1);
- // GPIO_O_SET(RESET_DVI311_GPIO, 1);
- GPIO_O_SET(RESET_DVI311_GPIO, 1);
- delay_1ms(200);
- delay_1ms(200);
- GPIO_O_SET(RESET_DVI311_GPIO, 0);
- #endif
- #endif
- //
- // MUTE
- GPIO_MUTE();//terry 20030805
- //
- // enable ROM-bus shared ATAPI-interface
- atapi_share_rom_bus();
- #ifdef OSD_FONT_COMPRESS
- //
- // decompress osd font
- if (font_decompress()<0) {
- printf("***ERROR*** font de_compress fail!!nn");
- delay(1000);
- }
- #endif
- #ifdef SUPPORT_FONT_UTIL
- SetCurrentFont( 0 ); // 2004/09/19 yltseng
- #endif
- //
- // write-out copyright
- sysmain_boot_message();
- //
- // set/load setup
- sysmain_load_setup();
- //
- // initialize variables
- InitVar();
- #ifdef SUPPORT_FUNCTION_MENU
- #ifdef SUPPORT_SPI
- pdvd_mode = PDVD_MODE;
- #endif
- #endif
-
- //
- // setup hardware (in additional to reset_all())
- #ifdef EASTWIN
- check_customer_default();
- init_lcd_display_mode();
- #endif
- sysmain_setup_hardware();
- #ifdef ERROR_CONCEALMENT
- setup_error_mb_limit(ERROR_MB_LIMIT_NUM); // ERROR_MB_LIMIT_NUM*16 MB default=4
- setup_error_concealment(ERROR_CONCEALMENT_MODE); // detect error and skip
- #endif
- #ifdef EMU_MODE
- UserSet.ParentalLvl=8;
- #endif
- #ifdef SPHE1000 //MIKEY 2004.07.15
- read_profile();
- #endif
- //
- // run tests if required
- run_tests();
- #ifdef DVD_SERVO
- //
- // Initialize different types of loader OPU
- system_init_servo_var();
- #endif
- counter_down = 5;//terry,2003/8/11 11:42AM,move here
- //
- // first time display DVD player title
- #ifndef SLEEP_WHEN_POWER_ON
- #ifdef QSI_PORTABLE_DVD
- //psprintf(RegionValStr[1],"CVBS_SVideo ON");
- //PrintOsdMsg(72,1,1,1);
- sp8200tv_setup_custom_output(TV_OUT_CScCSc);
- tv_dacoff(TV_DAC_A|TV_DAC_E|TV_DAC_F);
- #endif
-
- ShowTitle();
- #endif//#ifndef SLEEP_WHEN_POWER_ON
- #ifdef SUPPORT_I2C_LCD_Panel
- init_I2C_panel();
- #endif
-
- #if defined(SPHE1000) && !defined(DVB1000_NON_OS)
- boot_linux(); //MIKEY 2004.04.15
- #endif
- //
- // servo/hdd/atapi/avb/cf card init...
- //srv_on =1;//terry 3-8-8 4:17 move it behind ShowTitle();
- servo_test();
- //
- // initialize hd
- //hdd_init();
- //
- // initialize atapi(main)
- #ifndef SP1000_NO_DVD
- #ifndef SETUP_ATAPI_EPP
- #if defined(SPHE1000) && !defined(DVB1000_NON_OS)
- if(f_drv_init==1) { //MIKEY
- drv_init();
- }
- #else
- drv_init();
- #endif
- #endif //#ifndef SETUP_ATAPI_EPP
- #endif //#ifndef SP1000_NO_DVD
- #ifdef SUPPORT_USB//liweihua 2003-9-25
- #ifdef HOST_UHCI //wthsin, 2004/1/12 02:09pm
- regs0->reset2 &= 0xEFFF; //wthsin, Enable UHCI register R/W access
- extern UINT16 uhci_usb_driver;
- #ifdef IC_8202E
- uhci_usb_driver=0x6f1f;
- #else
- uhci_usb_driver=0x3e3e;
- #endif
- uhci_reset();
- card_plug_state = USER_DO_PLUG_OUT;
- #else
- sl811h_init();
- #endif
- #endif
- #ifdef SUPPORT_CARD_STORAGE
- #ifdef SUPPORT_HDD_ACCESS
- load_hdd_init();
- #endif
- CardReset();
- #endif
- #ifdef AD_TCL//2004-3-31 14:24 lijd
- #ifdef SLEEP_WHEN_POWER_ON
- {
- volatile int *iMagic=(int *)(DATA_RAM_BASE|0x80);
- if (*iMagic != 0x1234abcd)
- {
- #ifdef TCL_STANDBY
- regs0->gpio_master[4 / 16] |= (0x1 << (4 % 16));
- regs0->gpio_oe[ 4/16 ] |= (0x1 << (4%16));//output
- regs0->gpio_out[4/16 ] |= (0x1 << (4%16));
- ircmd_power();
- #else
- #if defined(POWER_RESUME)&&defined(SLEEP_WHEN_POWER_ON)
- ircmd_power();
- #endif
-
- #endif
- }
- else
- {
- #ifdef TCL_STANDBY
- regs0->gpio_master[4 / 16] |= (0x1 << (4 % 16));
- regs0->gpio_oe[ 4/16 ] |= (0x1 << (4%16));//output
- regs0->gpio_out[ 4/16 ] &= ~(0x1 << (4%16));
- #endif
- }
- *iMagic = 0;
- //yanlb move it here;04/05/12 PM 10:15
- tv_dacoff(0); // dac f/e/d/c/b/a on
- ShowTitle();
- }
- #endif
- #else
- #ifndef AFTER_UPGRADE_TRAYOUT
- sleep_when_power_on();
- #else
- //tray out after updata,fist time don't sleep .move from sysmain2.c
- #if defined( RESET_AFTER_UPGRADE ) || defined( RISC_ALIVE_STANDBY ) // 2004/10/01 yltseng
- {
- volatile int *iMagic = (int *)(DATA_RAM_BASE|0x80);
- if (*iMagic == 0x1881)ircmd_trayout();
- else sleep_when_power_on();
- *iMagic = 0;
- }
- #endif
- #endif
- #endif
-
- //yanlb move it to sleep_when_power_on();04/05/12 PM 2:00
- //#ifdef SLEEP_WHEN_POWER_ON //hq,3-11-25 22:36
- // tv_dacoff(0); // dac f/e/d/c/b/a on
- // ShowTitle();
- //#endif
- srv_on =1;//terry 3-8-8 4:17
-
- #ifndef DVDRELEASE
- disable_uop = 0;
- #endif
- #ifdef HDMI
- ResetAuthentStates();
- #endif
- // jump to AP
- while (1)
- {
- // benson move call ap_main_receiver() 2004/3/1 03:35