/*************************************************************** ** ** Broadcom Corp. Confidential ** Copyright 1998-2000 Broadcom Corp. All Rights Reserved. ** ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ** ** File: main.c ** Description: main entry point ** Created: 04/18/02 Jeffrey P. Fisher ** ****************************************************************/ #define BDISPATCH_BYPASS #include "bsettop_decode.h" #include "bsettop_tuner.h" #include "fstore.h" #ifdef GFX_DEBUG #include "bsettop_gfx.h" #endif #ifndef CONFIG_HAS_STREAM #undef BDISPATCH_BYPASS #endif #include "bsettop_stream.h" #include "bsettop_message.h" #undef BDISPATCH_BYPASS #include "ministd.h" #include "bstd.h" #include "bsettop.h" #include "cache_util.h" #include "ts_psi.h" #include "ts_pat.h" #include "ts_pmt.h" #include "psip_mgt.h" #include "psip_stt.h" #if MINISTD_RAM #include "bint.h" #endif #if PROFILE #include "bkni.h" #include "bprofile.h" #endif #include "bsettop_gfx.h" #ifdef CONFIG_DTA_CABLE #include "bapp.h" #else #include "bapp.h" #endif #include "bpwr.h" BDBG_MODULE(ram); #ifdef CONFIG_FSTORE static const bfstore_t s_fstore = { fstore_init, fstore_update, fstore_get }; #endif #ifdef GFX_DEBUG static const bgfx_api_t s_bgfx = { bgfx_init, bgfx_done, bgfx_create, bgfx_destroy, bgfx_get_info, bgfx_get_palette, bgfx_set_palette, bgfx_set_pixel, bgfx_get_pixel, bgfx_h_draw_line, bgfx_v_draw_line, bgfx_fill_rect, bgfx_draw_text, bgfx_draw_text_box, bgfx_render_file, bgfx_blit, bgfx_blit_rect, bgfx_free_font, bgfx_get_glyph, bgfx_string_info, bgfx_load_font, }; #endif #ifdef CONFIG_HAS_STREAM static const bmessage_api s_bmessage_api = { bmessage_init, bmessage_uninit, bmessage_open, bmessage_stream_params_init, bmessage_start, bmessage_get_buffer, bmessage_read_complete, bmessage_stop, bmessage_close }; static const bstream_api s_stream_api = { bstream_mpeg_init, bstream_open, bstream_close, bstreamer_attach, bstream_get_status, bstream_get_config, bstream_set_config, bstream_callback }; #endif #ifdef CONFIG_HAS_MVPI const bdecode_api_t g_bdecode_api = { bdecode_open, bdecode_close, bdecode_start, bdecode_stop, bdecode_get_status, bdecode_set_config, bdecode_get_config }; #endif #if !defined(CONFIG_COMPRESSED_DECODER_FW) extern unsigned short BMVD_P_MTPMV_DataRamImage[]; extern unsigned short BMVD_P_MTPMV_CodeRamImage[]; #if (BCHP_CHIP == 3543) || (BCHP_CHIP == 3560) extern unsigned short BMVD_P_MTPT_DataRamImage[]; extern unsigned short BMVD_P_MTPT_CodeRamImage[]; #endif #endif #if (CONFIG_HAS_AUDIO == 2) extern const baudio_decode_api g_baudio_decode_api; #endif #if MINISTD_RAM extern const bint_t g_bint_api; extern const bministd_t g_ministd_api; extern const bpcm_t g_bpcm_api; #endif #ifdef CONFIG_HAS_TUNER static btuner_api_t s_btuner_api = { btuner_open, btuner_close, btuner_ds_params_init, btuner_tune_ds, btuner_get_ds_status }; #if !defined(CONFIG_COMPRESSED_VSB_FW) #if (BCHP_CHIP == 3543) extern uint8_t vsb_acq[]; extern uint16_t scr_table[]; extern uint8_t vsb_config[]; #endif #endif #endif /* Extern font arrays and sizes */ #ifdef CONFIG_FONTS_RAM extern const unsigned int g_FrancophilB_22_mono_size; extern const unsigned int g_FrancophilB_28_mono_size; extern const unsigned int g_FrancophilB_40_mono_size; extern const unsigned char g_FrancophilB_22_mono[]; extern const unsigned char g_FrancophilB_28_mono[]; extern const unsigned char g_FrancophilB_40_mono[]; #ifdef CONFIG_CHINESE_FONTS_RAM extern const unsigned int g_HDZB_75_16_mono_size; extern const unsigned char g_HDZB_75_16_mono[]; extern const unsigned int g_HDZB_75_24_mono_size; extern const unsigned char g_HDZB_75_24_mono[]; extern const unsigned int g_HDZB_75_28_mono_size; extern const unsigned char g_HDZB_75_28_mono[]; #endif #endif extern unsigned int _fbss; extern unsigned int _end; extern void fupdate(void); /****************************************************************************** * void ram_start(void) * * INPUTS: none * OUTPUTS: none. * RETURNS: none * FUNCTION: Main C program entry point ******************************************************************************/ void ram_start(void) { #if !defined(RAM_BUILD) unsigned int *ptr = &_fbss; #endif static bapp_t app; /* Declare static so it it is not on the stack */ #if !defined(RAM_BUILD) while (ptr != (unsigned int*)&_end) { *ptr = 0; ptr++; } #endif printf("CONFIG0 = 0x%08x\n",bcm_read_cp0($16,0)); printf("BCMCONFIG0 = 0x%08x\n",bcm_read_cp0($22,0)); /* patch these performance critical functions */ #if BDBG_DEBUG_BUILD #warning "***Debug Build***" BDBG_Init(); BDBG_SetLevel(BDBG_eWrn); #endif { unsigned int memory_size; memory_size = bos_ram_size(); if(MEMORY_SIZE > memory_size){ BDBG_ERR(("Not enough memory to run software.")); while(1) bos_sleep(1000); } } #if CONFIG_SYMTABLE #warning "*** SYMTABLE BUILD***" bsymtable_init(); #endif #if MINISTD_RAM #warning "***MINISTD RAM BUILD***" console_shutdown(); memcpy(&g_p_dsp->ministd, &g_ministd_api, sizeof(g_ministd_api)); memcpy(&g_p_dsp->bpcm, &g_bpcm_api, sizeof(g_bpcm_api)); memcpy(&g_p_dsp->bint, &g_bint_api, sizeof(g_bint_api)); bint_init(); #undef flush_dcache_all #undef flush_dcache g_p_dsp->cache.dflush_all = flush_dcache_all; g_p_dsp->cache.dflush = flush_dcache; console_init(CONSOLE_UART); #endif #ifdef GFX_DEBUG #warning "***GFX_DEBUG RAM BUILD***" memcpy(&g_p_dsp->bgfx, &s_bgfx, sizeof(bgfx_api_t)); #endif #ifdef CONFIG_HAS_STREAM #warning "***BSTREAM RAM BUILD***" memcpy(&g_p_dsp->bstream, &s_stream_api, sizeof(s_stream_api)); memcpy(&g_p_dsp->bmessage, &s_bmessage_api, sizeof(s_bmessage_api)); #ifdef CONFIG_ENABLE_PSIS smessage_install_dispatch(); #endif #endif #ifdef CONFIG_HAS_MVPI #warning "***MVPI RAM BUILD***" memcpy(&g_p_dsp->bdecode, &g_bdecode_api, sizeof(g_bdecode_api)); #endif #if !defined(CONFIG_COMPRESSED_DECODER_FW) #warning "***DECODER FW RAM BUILD***" g_p_dsp->video_firmware.MTPMV_DataRamImage = BMVD_P_MTPMV_DataRamImage; g_p_dsp->video_firmware.MTPMV_CodeRamImage = BMVD_P_MTPMV_CodeRamImage; #if (BCHP_CHIP == 3543) || (BCHP_CHIP == 3560) g_p_dsp->video_firmware.MTPT_DataRamImage = BMVD_P_MTPT_DataRamImage; g_p_dsp->video_firmware.MTPT_CodeRamImage = BMVD_P_MTPT_CodeRamImage; #endif #endif #if (CONFIG_HAS_AUDIO == 2) #warning "***AUDIO RAM BUILD***" memcpy(&g_p_dsp->baudio_decode, &g_baudio_decode_api, sizeof(g_baudio_decode_api)); #endif #ifdef CONFIG_FSTORE #warning "***FSTORE RAM BUILD***" memcpy(&g_p_dsp->fstore, &s_fstore, sizeof(bfstore_t)); #endif #ifdef CONFIG_HAS_TUNER #warning "***TUNER RAM BUILD***" memcpy(&g_p_dsp->btuner,&s_btuner_api,sizeof(s_btuner_api)); #if !defined(CONFIG_COMPRESSED_VSB_FW) #warning "***VSB FW RAM BUILD***" #if (BCHP_CHIP == 3543) g_p_dsp->vsb_firmware.vsb_acq_fw = vsb_acq; g_p_dsp->vsb_firmware.scr_table_fw = scr_table; g_p_dsp->vsb_firmware.vsb_config_fw = vsb_config; #endif #endif #endif #ifdef CONFIG_FSTORE #warning "***FSTORE RAM BUILD***" memcpy(&g_p_dsp->fstore, &s_fstore, sizeof(bfstore_t)); #endif #ifdef CONFIG_FONTS_RAM #warning "***FONTS RAM BUILD***" #ifdef CONFIG_CHINESE_FONTS_RAM g_p_dsp->ui_comp.small_font = (unsigned char*)g_HDZB_75_16_mono; g_p_dsp->ui_comp.small_font_size = (unsigned int)g_HDZB_75_16_mono_size; g_p_dsp->ui_comp.medium_font = (unsigned char*)g_HDZB_75_24_mono; g_p_dsp->ui_comp.medium_font_size = (unsigned int)g_HDZB_75_24_mono_size; #ifndef CONFIG_DTA_CABLE g_p_dsp->ui_comp.large_font = (unsigned char*)g_HDZB_75_28_mono; g_p_dsp->ui_comp.large_font_size = (unsigned int)g_HDZB_75_28_mono_size; #endif #else g_p_dsp->ui_comp.small_font = (unsigned char*)g_FrancophilB_22_mono; g_p_dsp->ui_comp.small_font_size = (unsigned int)g_FrancophilB_22_mono_size; g_p_dsp->ui_comp.medium_font = (unsigned char*)g_FrancophilB_28_mono; g_p_dsp->ui_comp.medium_font_size = (unsigned int)g_FrancophilB_28_mono_size; #ifndef CONFIG_DTA_CABLE g_p_dsp->ui_comp.large_font = (unsigned char*)g_FrancophilB_40_mono; g_p_dsp->ui_comp.large_font_size = (unsigned int)g_FrancophilB_40_mono_size; #endif #endif #endif if ((ReadReg32(BUTTON_DATA_REG) & CH_UP_BUTTON_MASK) == CH_UP_BUTTON_MASK) { fupdate(); } b_pwr_configure_chip(); bapp_init(&app); bapp_run(&app); }