- //*****************************************************************************
- //File Name: kb_machblue_core_system.c
- //
- //Description: system function
- //
- // used by Machblue to initialize or delete the core porting layer
- // used by Machblue to access the platform's kernel panic api
- // used by Machblue to access the platform's system time api
- //
- //Author: steven
- //
- //Date: 2006.12.29
- //
- //Version: v1.0
- //*****************************************************************************
- #include "task.h"
- #include "time.h"
- #include "timeclk.h"
- #include "machblue_defines.h"
- #include "machblue_porting_core.h"
- extern mb_error_t mb_timer_init(void);
- extern mb_error_t mb_timer_delete(void);
- /**
- * Invoked by Machblue to initialize the porting layer. This
- * will be called before any calls to the porting layer.
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_porting_layer_init(void *init_client_data)
- {
- if(mb_timer_init()!=MB_SUCCESS)
- {
- mb_printf("n[Machblue]:mb_porting_layer_init timer error.");
- return MB_FAILURE;
- }
- return MB_SUCCESS;
- }
- /**
- * Invoked by Machblue to delete the porting layer. Machblue will
- * not make any calls to the porting layer after this call
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_porting_layer_delete( void )
- {
- if(mb_timer_delete()!=MB_SUCCESS)
- {
- mb_printf("n[Machblue]:mb_porting_layer_delete timer error.");
- return MB_FAILURE;
- }
- return MB_SUCCESS;
- }
- /**
- * Invokes by Machblue when an unrecoverable error has been encountered.
- * @return none.
- */
- void mb_panic(const mb_char_t *str)
- {
- mb_printf(str);
- task_exit(0);
- }
- /*
- * ======================= System Time API ===========================================
- */
- /**
- * Gets the current system time (UTC).
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_system_time_get(mb_system_time_t *system_time)
- {
- system_time->sec=KB_TimeGetCurGMTTime();
- system_time->nanosec=0;
- return MB_SUCCESS;
- }
- /**
- * Gets the system time zone.
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_timezone_get(mb_timezone_t *timezone)
- {
- unsigned char ret;
- signed char zone,swfZone;
- ret=KB_DBGetZone(&zone);
- if(ret!=KB_DB_DTV_SUCCESS)
- {
- mb_printf("n[Machblue]:System get zone error.");
- return MB_FAILURE;
- }
- #if MB_PLAYER_1_2
- swfZone=zone;
- #else
- swfZone=-zone;
- #endif
- timezone->daylight=1;
- timezone->offset=(long)((long)swfZone*3600);
- return MB_SUCCESS;
- }
- #if MB_PLAYER_1_2
- mb_error_t mb_monotonic_time_get(mb_monotonic_time_t *monotonic_time)
- {
- return MB_SUCCESS;
- }
- #endif