📄 dda_previewer.c
字号:
/*******************************************************************************
**+--------------------------------------------------------------------------+**
**| **** |**
**| **** |**
**| ******o*** |**
**| ********_///_**** |**
**| ***** /_//_/ **** |**
**| ** ** (__/ **** |**
**| ********* |**
**| **** |**
**| *** |**
**| |**
**| Copyright (c) 2006-2010 Texas Instruments Incorporated |**
**| ALL RIGHTS RESERVED |**
**| |**
**| Permission is hereby granted to licensees of Texas Instruments |**
**| Incorporated (TI) products to use this computer program for the sole |**
**| purpose of implementing a licensee product based on TI products. |**
**| No other rights to reproduce, use, or disseminate this computer |**
**| program, whether in part or in whole, are granted. |**
**| |**
**| TI makes no representation or warranties with respect to the |**
**| performance of this computer program, and specifically disclaims |**
**| any responsibility for any damages, special or consequential, |**
**| connected with the use of this program. |**
**| |**
**+--------------------------------------------------------------------------+**
*******************************************************************************/
/**
* \file dda_previewer.c
*
* \brief previewer implementaion of DDA layer
*
* This file contains the implementation of DDA layer of the previewer driver.
*
* (C) Copyright 2010, Texas Instruments, Inc
*
*
* \author EI2
*
* \version 0.1 Created
* 1.0 First Release
*/
/******************************************************************************
Header File Inclusion
******************************************************************************/
#include <tistdtypes.h>
#include <std.h>
#ifdef PREVIEWER_DEBUG
#ifdef DDA_PREVIEWER_DEBUG_PRINTF
#include "psputils.h"
#endif /* DDA_PREVIEWER_DEBUG_PRINTF */
#endif /* PREVIEWER_DEBUG */
#include <mem.h>
#include <ecm.h>
#include <c64.h>
#include <psp_common.h>
#include "soc.h"
#include "psp_previewer.h"
#include "dda_previewer.h"
#include "ddc_previewer.h"
#include "llc_previewer.h"
/******************************************************************************
BIOS SPECIFIC FUNCTIONS
******************************************************************************/
/**
* \brief DDA_prevSetInterrupt
*
* It registers interrupt handler for previewer.
*
* \param intNum [IN] interrupt number
* \param isrRoutine [IN] interrupt routine
* return void
*/
static void DDA_prevSetInterrupt(Uint8 intNum, ECM_Fxn isrRoutine);
/**
* \brief DDA_prevUnsetInterrupt
*
* It unregisters Interrupt handler for previewer.
*
* \param intNum [IN] interrupt number
* return void
*/
static void DDA_prevUnsetInterrupt(Uint8 intNum);
/******************************************************************************
Internal Functions
******************************************************************************/
/**
* \brief DDA_DDCtoDDAErrorCode
*
* It maps DDC error codes to PSP error codes.
*
* \param ddcErrorCode [IN] DDC error code
* return PSP error code, corresponding to DDC error code.
*/
static PSP_Result DDA_DDCtoDDAErrorCode(DDC_prevResult ddcErrorCode);
/******************************************************************************
Macros
******************************************************************************/
/* Debug Macros */
#ifdef PREVIEWER_DEBUG
/* macro to indicate DDA file */
#define DDA_PREVIEWER_DEBUG_FILE 3
#define PREVIEWER_DEBUG_ERROR_TRACE_SIZE 16
extern Uint32 prevDebugErrorTraceIndex;
extern Uint32 prevDebugErrorTraceArray[];
#define PREVIEWER_DEBUG_ERR_TRACE(LINENO) \
{\
prevDebugErrorTraceArray[prevDebugErrorTraceIndex] = (Uint32)(\
(DDA_PREVIEWER_DEBUG_FILE << 24) | (LINENO));\
prevDebugErrorTraceIndex++;\
prevDebugErrorTraceIndex %= PREVIEWER_DEBUG_ERROR_TRACE_SIZE;\
}
#ifdef DDA_PREVIEWER_DEBUG_ALL_TRACE
#define PREVIEWER_DEBUG_TRACE_SIZE 128
extern Uint32 prevDebugTraceIndex;
extern Uint32 prevDebugTraceArray[];
#define DDA_PREVIEWER_DEBUG_REG_TRACE(LINENO) \
{\
prevDebugTraceArray[prevDebugTraceIndex] = (Uint32)(\
(DDA_PREVIEWER_DEBUG_FILE << 24) | (LINENO));\
prevDebugTraceIndex++;\
prevDebugTraceIndex %= PREVIEWER_DEBUG_TRACE_SIZE;\
}
#else /* DDA_PREVIEWER_DEBUG_ALL_TRACE */
#define DDA_PREVIEWER_DEBUG_REG_TRACE(LINENO)
#endif /* DDA_PREVIEWER_DEBUG_ALL_TRACE */
#ifdef DDA_PREVIEWER_DEBUG_PRINTF
#define DDA_PREVIEWER_DEBUG_PRINT(STR) PSP_DEBUG1("DDA%s", (STR));
#else /* DDA_PREVIEWER_DEBUG_PRINTF */
#define DDA_PREVIEWER_DEBUG_PRINT(STR)
#endif /* DDA_PREVIEWER_DEBUG_PRINTF */
#else /* PREVIEWER_DEBUG */
#define DDA_PREVIEWER_DEBUG_REG_TRACE(LINENO)
#define PREVIEWER_DEBUG_ERR_TRACE(LINENO)
#define DDA_PREVIEWER_DEBUG_PRINT(STR)
#endif /* PREVIEWER_DEBUG */
/******************************************************************************
Data-Structures
******************************************************************************/
/**
* \brief previewer object of port structure
*/
DDA_prevPortObject ddaPrevPortObj =
{
NULL,
DDA_PREVIEWER_DEVICE_DELETED,
NULL
};
/**
* \brief to store interrupt mapping info.
*/
Uint8 ddaPrevInterruptMapInfo = 0xFF;
/**
* \brief to store interrupt mapping is needed or not
*/
Uint32 ddaPrevInterruptMapRequired = 0xFF;
/**
* \brief to store segment id where DDA memory is allocated
*/
Uint32 ddaPrevSegId = 0xFF;
/******************************************************************************
Functions
******************************************************************************/
/**
* \brief PSP_prevCreate
* It creates a given previewer device at DDA layer.
*/
PSP_Result PSP_prevCreate(PSP_Handle* devHandle)
{
PSP_Result prevCreateReturnCode = PSP_E_DRIVER_INIT;
DDC_prevResult prevCreateDDCRetCode = DDC_PREV_NOT_SUPPORTED;
DDA_PREVIEWER_DEBUG_REG_TRACE(__LINE__);
/* if device instance is already created, raise an error */
if (DDA_PREVIEWER_DEVICE_DELETED != ddaPrevPortObj.state)
{
prevCreateReturnCode = PSP_E_INVAL_STATE;
PREVIEWER_DEBUG_ERR_TRACE(__LINE__);
}
else /* if device instance is not created yet */
{
DDA_PREVIEWER_DEBUG_REG_TRACE(__LINE__);
/* call DDC level function to create device instance
* at DDC layer */
prevCreateDDCRetCode = DDC_prevDeviceCreate(
&(ddaPrevPortObj.ddcDeviceHandle));
/* if device is successfully created at DDC layer */
if (DDC_PREV_SOK == prevCreateDDCRetCode)
{
DDA_PREVIEWER_DEBUG_REG_TRACE(__LINE__);
/* as device instance has been created successfully,
* change state of device */
ddaPrevPortObj.state = DDA_PREVIEWER_DEVICE_CREATED;
*devHandle = &ddaPrevPortObj;
prevCreateReturnCode = PSP_SOK;
}
else /* device is not created at DDC layer */
{
/* as device instance has been failed to created,
* fill global instance of port structure with
* default values */
ddaPrevPortObj.state = DDA_PREVIEWER_DEVICE_DELETED;
ddaPrevPortObj.ddcDeviceHandle = NULL;
ddaPrevPortObj.channelHandle = NULL;
*devHandle = NULL;
prevCreateReturnCode
= DDA_DDCtoDDAErrorCode(prevCreateDDCRetCode);
PREVIEWER_DEBUG_ERR_TRACE(__LINE__);
}
} /* end if DDA_PREVIEWER_DEVICE_DELETED ... ddaPrevPortObj.state */
return prevCreateReturnCode;
}
/**
* \brief PSP_prevOpen
* It Open Channel of the previewer device.
*/
PSP_Result PSP_prevOpen(PSP_Handle *chanHandle,
PSP_Handle devHandle,
PSP_previewerChannelCreateMode *chanParams)
{
PSP_Result prevOpenReturnCode = PSP_E_DRIVER_INIT;
DDC_prevResult prevOpenDDCRetCode = DDC_PREV_NOT_SUPPORTED;
Ptr prevOpenChannelHandle = NULL;
ECM_Fxn prevCreateIsrFuncPtr = NULL;
DDA_prevPortHandle prevOpenPortHandle;
if ((NULL == devHandle) || (NULL == chanHandle))
{
prevOpenReturnCode = PSP_E_INVAL_PARAM;
DDA_PREVIEWER_DEBUG_PRINT("Invalid Parameter\n");
PREVIEWER_DEBUG_ERR_TRACE(__LINE__);
}
else
{
DDA_PREVIEWER_DEBUG_REG_TRACE(__LINE__);
prevOpenPortHandle = (DDA_prevPortHandle)devHandle;
/* if passed port structure is different then global port structure,
* raise an error */
if ((&ddaPrevPortObj) != prevOpenPortHandle)
{
prevOpenReturnCode = PSP_E_INVAL_PARAM;
DDA_PREVIEWER_DEBUG_PRINT("Invalid Parameter\n");
PREVIEWER_DEBUG_ERR_TRACE(__LINE__);
}
else /* if port structure is proper one */
{
DDA_PREVIEWER_DEBUG_REG_TRACE(__LINE__);
/* check that if device is deleted or channel is already open then
* raise an error */
if ((DDA_PREVIEWER_DEVICE_DELETED == prevOpenPortHandle->state)
|| (NULL != prevOpenPortHandle->channelHandle))
{
prevOpenReturnCode = PSP_E_INVAL_STATE;
DDA_PREVIEWER_DEBUG_PRINT("Invalid State\n");
PREVIEWER_DEBUG_ERR_TRACE(__LINE__);
}
else /* if device instance is created and channel is not
opened yet */
{
DDA_PREVIEWER_DEBUG_REG_TRACE(__LINE__);
/* allocate a memory for channel instance at DDA layer,
* alignment is not needed so 0 is passed as an alignment
* value */
prevOpenChannelHandle = MEM_alloc(chanParams->segId,
sizeof(DDA_prevChannelObject), 0);
/* if system is failed to allocate memory */
if (MEM_ILLEGAL == prevOpenChannelHandle)
{
prevOpenReturnCode = PSP_E_NO_MEMORY;
DDA_PREVIEWER_DEBUG_PRINT("Memory Error\n");
PREVIEWER_DEBUG_ERR_TRACE(__LINE__);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -