/*************************************************************************** * Copyright (c) 2003-2008, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * 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. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * * ***************************************************************************/ #include "ministd.h" #include "serial.h" #include "bos.h" #include "cache_util.h" #include "bstd.h" #include "bkni.h" #include "ucos_ii.h" #include "bcmuart.h" #include "bchp_timer.h" //#include "bmem_debug.h" #include "serial.h" #include "bchp_sun_top_ctrl.h" #define APP_PRIORITY 24 #define CONSOLE_STK_SIZE 4096 /* in words */ #define REG_RW_STK_SIZE 128 /* in words */ #define TEST_TASKINFO_STK_SIZE 512 /* in words */ #define APP_STK_SIZE 2048 /* in words */ #ifdef CONFIG_ENABLE_EMU #define TASKINFO_SLEEP_ms 100 #else #define TASKINFO_SLEEP_ms 2000 #endif BDBG_MODULE(ram_start); extern unsigned int _fbss; extern unsigned int _end; extern unsigned long ram1_start_address; extern void console_main(void *data); void test_taskinfo_main(void *data); unsigned get_opt(void); extern void ram_start(void); static b_task_t app_task_h; static b_task_t info_task_h; static unsigned int *info_stack; #define CONSOLE_PRIORITY 52 bool s_printing_enabled; /***********************************************************************/ /* static inline void s_do_putc(volatile UartChannel *uart, int c) */ /***********************************************************************/ static inline void s_do_putc(volatile UartChannel *uart, int c) { while (!(uart->sdw_lsr & THRE)); uart->sdw_rbr_thr_dll = (unsigned char)c; } /***********************************************************************/ /* serial_putc(UartChannel *uart, unsigned int c)*/ /***********************************************************************/ void print_string(char *str) { unsigned int idx = 0; while(str[idx]) serial_putc(CONSOLE_UART,str[idx++]); } #define BPRINT_PRIORITY 35 #define BPRINT_STK_SIZE 0x400 static unsigned int bprint_stack[BPRINT_STK_SIZE]; static b_task_t bprint_task; static void bprint_entry(void *data); void bcm_main(void) { b_task_params console_params; b_task_t console_task_h; BERR_Code berr; bos_init(); /* kni and dbg must be initialized after os since they use os primitives */ berr = BKNI_Init(); BKNI_Print_Init(); berr = BDBG_Init(); /* test message for BDBG routines */ BDBG_ERR(("### BOS INIT DONE ###")); calc_cache_sizes(); print_cache_sizes(); console_params.name="console"; console_params.priority = CONSOLE_PRIORITY; console_params.stack_size = CONSOLE_STK_SIZE; console_params.stack = (unsigned int*)malloc(console_params.stack_size * sizeof(unsigned int)); printf("%s stack @ 0x%08x\n",console_params.name, console_params.stack); bos_start_task(&console_task_h,&console_params,console_main,&console_task_h); console_params.name="bprint"; console_params.priority = BPRINT_PRIORITY; console_params.stack_size = BPRINT_STK_SIZE; console_params.stack = bprint_stack; bos_start_task(&bprint_task, &console_params, bprint_entry,&console_task_h); bos_start(); printf("%s..SHOULD NEVER GET HERE.\n",__FUNCTION__); __asm__("break 2"); } /* this two functions probably should be moved somewhere more suitable */ static size_t out_string(const void * buf, size_t count) { size_t i; const unsigned char * pc = buf; for(i = 0; i <= count; i++){ if (pc[i]=='\n') { serial_putc(CONSOLE_UART, '\r'); } serial_putc(CONSOLE_UART, pc[i]); } return count; } void bprint_entry(void *data) { BDBG_ERR(("PRINT TASK ONLINE")); s_printing_enabled = true; while (1) { if (s_printing_enabled) { BKNI_Print_Worker(out_string); } else { bos_sleep(200); } } __asm__("sdbbp"); } void bprint_flush(void) { BKNI_Print_Flush(out_string); }