/*************************************************************************** * Copyright (c) 2011, 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 "gist.h" #include "bos_task_priorities.h" #include "bcmuart.h" #include "bchp_timer.h" #include "bmem_debug.h" #include "zlib.h" #include "bfds.h" #include "bchp_sun_top_ctrl.h" #include "bstd_defs.h" #include "bkni_print.h" #include "ramheader.h" BDBG_MODULE(main_decode); #define CONSOLE_STK_SIZE (1024*3) /* 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 */ /* external declarations */ void do_test(void * data); /* forward declarations */ void console_main(void *data); #define BPRINT_STK_SIZE 0x400 static unsigned int bprint_stack[BPRINT_STK_SIZE]; static b_task_t bprint_task; static bool s_printing_enabled = true; static void bprint_entry(void *data); /* main entry point from CRT */ void bcm_main(void) { b_task_params console_params; b_task_t console_task_h; b_task_t print_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,&print_task_h); bos_start(); printf("%s..SHOULD NEVER GET HERE.\n",__FUNCTION__); __asm__("break 2"); } void console_main(void *data) { gist_init(); serial_init(CONSOLE_UART,115200); bos_calibrate(); printf("Calculated MIPS = %dHz:\n", 2 * g_running_clock.clock_freq); do_test(data); while (1){ BKNI_Sleep(1000); } } /* 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); }