📄 ker_api.c
字号:
/* **************************************************************************************
* Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
* File: $Workfile: Ker_API.c $
*
* Description:
* ============
* Implementation of the Kernel-API
*
* Log:
* ====
* $Revision: 16 $
* Last Modified by $Author: Stephaneh $ at $Modtime: 1/30/04 11:28a $
****************************************************************************************
* Updates:
****************************************************************************************
* $Log: /SourceCode/I64_Common/I64_Reference/Kernel/Ker_API.c $
*
* 16 1/30/04 11:28a Stephaneh
* Added semaphore_check function for CDG feature.
* Semaphore_check verifies if semaphore is free, if yes, it will set this
* semaphore. Therefore, the system should free this semaphore afterwards.
*
* 15 1/07/04 3:56p Nmaurer
* Change prinout in case of IE_CORE_DRIVE_READ_FAIL
*
* 14 03-09-27 10:58 Angieh
* Add prototype.
*
* 13 9/23/03 8:58p Nmaurer
* Add include Decoder\Dec_Defs.h
*
* 12 03-08-07 19:53 Leslie
* Capture the Exception from FE for Aux Data mode
*
* 11 03-08-04 15:20 Fwang
* Don't send IE_CORE_DRIVE_READ_FAIL in case of reading VCD/DVD aux data.
*
* 10 7/29/03 8:34p Nmaurer
* Remove DriveDriver_install
*
* 9 03-07-28 17:02 Leslie
* Check in changes for Task Force
*
* 8 7/10/03 6:36p Mikex
* add a judgement about EXCEPTION_POWER_DOWN_REQUEST, that be for
* decreasing time into standby status when reading all files in disc.
*
* 7 5/26/03 8:50p Davidd
*
* 6 03-05-26 16:14 Leslie
* Allow only one Error Mesg in Message POOL
*
* 5 03-05-22 11:44 Leslie
* Change for new error recovery
*
* 4 03-05-19 13:39 Leslie
* Add IE_CORE_DRIVE_READ_FAIL
*
* 4 4/06/02 21:21 Nirm
* - ie_send_ex() returns a Boolean success/failure indication.
*
* 3 23/04/02 9:26 Nirm
* - Added dependency in "Config.h".
*
* 2 31/03/02 23:16 Nirm
* - Added installation of the Drive-Driver.
*
* 1 27/03/02 13:31 Nirm
* - Removed Task.c from uITRON;
* - Added Ker_API.c to Kernel;
* - Added SystemTasks.c to Kernel.
**************************************************************************************** */
#include "Config.h" // Global Configuration - do not remove!
#include "Kernel\Ker_API.h"
#include "Kernel\EventDef.h"
#include "Kernel\SystemTasks.h"
#include "Decoder\Dec_Defs.h"
#include "Drive\Drv_API.h"
#include "Drive\drv_defs.h"
#include "Playcore\Exception\Exception.h"
/////////////////////////////////////////////////////////////////////////////
// Constants and Enumerations
extern void TimersInit(void);
extern DEC_LL_CBSELECT get_cbselect(void);
/////////////////////////////////////////////////////////////////////////////
// Structrues and Types
typedef struct EventInfo_TAG {
EVENT eventID;
void* Param;
} EventInfo;
#ifdef WATCHDOG_TRIGGERED_BY_FE
BYTE ucDriveErrorMsgCount = 0;
#endif//WATCHDOG_TRIGGERED_BY_FE
/////////////////////////////////////////////////////////////////////////////
// Globals
#ifdef _DEBUG
extern int g_dbg_msg_pool;
#endif
/////////////////////////////////////////////////////////////////////////////
// Public Services
void kernel_init(void)
{
Ker_createSystemTasks();
TimersInit();
start_rtos();
Ker_startSystemTasks();
return;
}
BOOL ie_send_ex(EVENT uEvent, void *Param)
{
EventInfo *pEventInfo;
EXCEPTION excFatalException= EXCEPTION_NONE;
ER erResult;
#ifdef WATCHDOG_TRIGGERED_BY_FE
if ( ( IE_CORE_DRIVE_READ_FAIL == uEvent ) && ( DRV_READ_ERROR_ECC == (DRV_READ_ERROR_TYPE)Param ) ){
dbg_printf(("Get ECC Error, ignore\n"));
return;
}
#endif//WATCHDOG_TRIGGERED_BY_FE
// Throw an Exception in case the Event is a Fatal one
switch (uEvent)
{
#ifdef WATCHDOG_TRIGGERED_BY_FE
case IE_CORE_DRIVE_READ_FAIL:
tr_printf(("Error Type %d\n", (DRV_READ_ERROR_TYPE)Param));
if ( DRV_READ_ERROR_ECC == (DRV_READ_ERROR_TYPE)Param ) //Ignore ECC error
return;
if ( ( DEC_LL_CBSELECT_VCD_SECTOR != get_cbselect() ) &&
( DEC_LL_CBSELECT_DVD_SECTOR != get_cbselect() ) ){
if ( ucDriveErrorMsgCount == 0 )
ucDriveErrorMsgCount++;
else{
tr_printf(("Drive Error Msg already in Pool, ignore!!!. Msg Deep is %02x\n", ucDriveErrorMsgCount));
return;
}
}
else{
//For VCD/DVD aux data, set exception but not send event.
ucDriveErrorMsgCount = 0;
excFatalException = EXCEPTION_SECTOR_READ_FAIL;
if (EXCEPTION_NONE != excFatalException)
Exception_throw(excFatalException);
return;
}
break;
#endif//WATCHDOG_TRIGGERED_BY_FE
case IE_CORE_CMD_EJECT:
excFatalException= EXCEPTION_MEDIUM_EJECTED;
break;
case IE_CORE_CMD_POWER:
excFatalException=EXCEPTION_POWER_DOWN_REQUEST;
}
if (EXCEPTION_NONE != excFatalException)
Exception_throw(excFatalException);
// Allocate space for the Event-Info
erResult= pget_blf((VP *)&pEventInfo, MSG_POOL);
if (E_OK != erResult) {
tr_printf(("FATAL: ie_send_ex() Failed [1]: Message-Pool is empty.\n"));
#ifdef _DEBUG
g_dbg_msg_pool++;
#endif //_DEBUG
return FALSE;
}
// Post the message
pEventInfo->eventID= uEvent;
pEventInfo->Param= Param;
if (E_OK != snd_msg((uEvent >> 12), (T_MSG *)pEventInfo)) {
tr_printf(("FATAL: ie_send_ex() Failed [2]: Mailbox is full.\n"));
rel_blf(MSG_POOL, pEventInfo);
}
return TRUE;
}
EVENT ie_get_ex(EVENT_CLASS i_uEventClass, void **o_pParamContainer)
{
EventInfo *pEventInfo;
EVENT eventID;
rcv_msg((T_MSG*)&pEventInfo, (i_uEventClass >> 12));
if (NULL != o_pParamContainer)
*o_pParamContainer= pEventInfo->Param;
eventID= pEventInfo->eventID;
#ifdef WATCHDOG_TRIGGERED_BY_FE
if ( IE_CORE_DRIVE_READ_FAIL == eventID ){
if ( ucDriveErrorMsgCount > 0 )
ucDriveErrorMsgCount--;
}
#endif//WATCHDOG_TRIGGERED_BY_FE
// Free msg memory
rel_blf(MSG_POOL, pEventInfo);
return eventID;
}
void semaphore_set(ID semid)
{
wai_sem( semid );
}
void semaphore_clear(ID semid)
{
sig_sem( semid );
}
// <<< Stephane.Hollande.011703:Added to check Semaphore access for CDG
// Caution : If this function return TRUE, the function semaphore_clear()
// MUST be used to release the semaphore after usage !
#ifdef D_CD_GRAPHIC_ENABLED
BOOL semaphore_check(ID semid)
{
// If semaphore is currently free, then set it and return TRUE, or return FALSE otherwise
if( E_OK == check_sem(semid))
return TRUE;
else
return FALSE;
}
#endif
// Stephane.Hollande.011703 >>>
void sleep(unsigned long sec)
{
if (sec == 0)
dly_tsk(1);
else
dly_tsk((DLYTIME)sec*1000);
}
void usleep(unsigned long usec)
{
unsigned long us = usec/1000;
if (us == 0)
us = 1;
dly_tsk((DLYTIME)us);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -