ej_bbs.h

来自「ADI blackfin DSP的基于device friver的jpeg压缩算」· C头文件 代码 · 共 419 行 · 第 1/2 页

H
419
字号
{
public:
	EJ_BBS();
	virtual ~EJ_BBS();

	/*	init_core 
	 * 
	 *	Description: 
	 *		init the core system,including pll,sdram,timer, interrupt ...
	 *      but network setting is leave to user, may be add in later
	 *
	 *
	 */
	void init_core(void);

	/*	init_system_service 
	 * 
	 *	Description: 
	 *		init the system service provided by adi system service lib
	 *    u8 *pMemoryForSysService:
	 *                     point to the memory block that system service need,      
	 *    size_t *MemorySizeUsed:
	 *                     memory size used by system service,  MemorySizeUsed = (ADI_DMA_BASE_MEMORY + ADI_DMA_CHANNEL_MEMORY*DmaChannelNum)
	 * 																+ (ADI_INT_SECONDARY_MEMORY * SecHandlerNum)
	 *																+ (ADI_DCB_QUEUE_SIZE + (ADI_DCB_ENTRY_SIZE)*DcbCallbackNum);
	 *
	 *    note, if use mem DMA, always need 2 channels for a memory copy
	 *
	 *	Return:
	 *		EJ_ERR_NONE			success
	 *		!EJ_ERR_NONE			fail
	 */
	
	RESULT init_system_service(u8 *pMemoryForSysService, size_t *MemorySizeUsed , 
									const size_t DmaChannelNum, const size_t IntSecHandlerNum, const size_t DcbCallbackNum);

	/*	init_system_service 
	 * 
	 *	Description: 
	 *		init the device driver provided by adi device driver lib
	 *    u8 *pMemoryForSysService:
	 *                     point to the memory block that device driver need,      
	 *   size_t *MemorySizeUsed
	 *                     memory size used by ddr, MemorySizeUsed = ADI_DEV_BASE_MEMORY + (ADI_DEV_DEVICE_MEMORY * DevNum)
	 *
	 *	Return:
	 *		EJ_ERR_NONE			success
	 *		!EJ_ERR_NONE			fail
	 */
	RESULT init_device_driver(u8 *pMemoryForDDR, size_t *MemorySizeUsed , const size_t DevNum);

	/*	config_device 
	 * 
	 *	Description: 
	 *		config the device indicated by devType, using the ADI_DEV_CMD_VALUE_PAIR structure.
	 *    u16 devType:
	 *                     device type, all the candicate list in enum: DEV_TYPE_ID,      
	 *    ADI_DEV_CMD_VALUE_PAIR *configurationTable:
	 *                     ADI_DEV_CMD_VALUE_PAIR structure used to configure device.
	 *
	 *	Return:
	 *		EJ_ERR_NONE			success
	 *		!EJ_ERR_NONE			fail
	 */
	RESULT config_device(u16 devType, ADI_DEV_CMD_VALUE_PAIR *configurationTable, ADI_DCB_CALLBACK_FN ClientCallback);
	
	void set_dma_callback(u16 dma_type, ADI_DCB_CALLBACK_FN ClientCallback);

	/*	set_dev_buffer 
	 * 
	 *	Description: 
	 *		when use a device to inbound/outbound data, caller must tell the device which kind buffer type he used, and provide the buffer structure.
	 *    u16 devType:
	 *                     device type, all the candicate list in enum: DEV_TYPE_ID,      
	 *    ADI_DEV_BUFFER * devBuffer:
	 *                     ADI device driver provide 3 kind of data flow method( 3 buffer type), circular, chained and chained with loopback.
	 *    ADI_DEV_BUFFER_TYPE BufferType:
	 *   			   the buffer type used.
	 *
	 *	Return:
	 *		EJ_ERR_NONE			success
	 *		!EJ_ERR_NONE			fail
	 */
	RESULT set_dev_buffer(u16 devType, ADI_DEV_BUFFER * devBuffer, ADI_DEV_BUFFER_TYPE BufferType);

	/*	set_dev_start 
	 * 
	 *	Description: 
	 *		call this interface to start the data flow with the device specific
	 *    u16 devType:
	 *                     device type, all the candicate list in enum: DEV_TYPE_ID,      
	 *
	 *	Return: none
	 */
	void set_dev_start(u16 devType);

	/*	set_dev_stop 
	 * 
	 *	Description: 
	 *		call this interface to stop the data flow with the device specific
	 *    u16 devType:
	 *                     device type, all the candicate list in enum: DEV_TYPE_ID,      
	 *
	 *	Return: none
	 */
	void set_dev_stop(u16 devType );

	/*	config_memdma 
	 * 
	 *	Description: 
	 *		config the memory dma stream, this call will open 2 dma channel.
	 *  ADI_DMA_STREAM_ID StreamID:
	 *		stream id
	 *                           
	 *		EJ_ERR_NONE			success
	 *		!EJ_ERR_NONE			fail
	 */
	RESULT config_memdma(ADI_DMA_STREAM_ID StreamID);
	
	/*	start_memdma 
	 * 
	 *	Description: 
	 *		start the memory dma transfer on stream, with the specific 2 ADI_DMA_2D_TRANSFER struct.
	 *  and the ElementWidth and callback.
	 * 
	 *  NOTE:
	 *		if the element strid (Xmodify) is different between pDest and pSrc, the ElementWidth should be 1.
	 *  the memory dma is set to stop mode, when the current work unit completes, the DMA channel 
	 *  stops automatically, after signaling an interrupt(if selected)
	 *  return:                          
	 *		EJ_ERR_NONE			success
	 *		!EJ_ERR_NONE			fail
	 */
	 
	RESULT start_memdma(ADI_DMA_STREAM_ID StreamID, ADI_DMA_2D_TRANSFER *pDest, ADI_DMA_2D_TRANSFER *pSrc, 
		u32 ElementWidth , ADI_DCB_CALLBACK_FN	ClientCallback);
		
	int creat_alternate_heap(void* heap_base_addr, u32 heap_size);
	
	void set_data_cache(void);
	void set_instruction_cache(void);

private:
	// data cache utilities
	// L1 Data Memory Control Register
	inline void disable_data_cache(void)	
	{	
		*pDMEM_CONTROL &= ~0xA;		//disable CPLB's, DMC in reserved mode
		ssync();
	}
	
	inline void enable_data_cache(void)
	{
		*pDMEM_CONTROL |= 0xA;		//enable CPLB's, Data Bank A is lower 16K byte SRAM, upper 16K byte cache, Data Bank B is SRAM
		ssync();
	}

	// instruction cache utilities
	// L1 Instruction Memory Control Register
	inline void disable_instruction_cache(void)
	{
		*pIMEM_CONTROL &= ~0x4;		// disable CPLB's, All cacheways locked
		ssync();
	}

	inline void enable_instruction_cache(void)
	{
		*pIMEM_CONTROL |= 0x4;		// enable CPLB's, Upper 16K byte of L1 instruction memory configured as cache
		ssync();
	}
	
private:
	// DMA Manager data (base memory + memory for 1 DMA channel)
	void *m_pDMAMgrData;
	// Deferred Callback Manager data (memory for 1 service plus 4 posted callbacks)
	void *m_pDCBMgrData;
	// Device Manager data (base memory + memory for 1 device)
	void *m_pDevMgrData;
	// storage for interrupt manager data
	void *m_pIntMgrData;

	//handles
	ADI_DCB_HANDLE				m_DCBManagerHandle;
	ADI_DMA_MANAGER_HANDLE 		m_DMAManagerHandle;		// handle to the DMA Manager
	ADI_DEV_MANAGER_HANDLE 		m_DeviceManagerHandle;	// handle to the Device Manager
	
#if defined(__ADSP_TETON__)	
	ADI_DEV_DEVICE_HANDLE 		m_ppiDeviceHandle_1;	// handle to the device driver ppi1
	ADI_DEV_DEVICE_HANDLE 		m_ppiDeviceHandle_2;	// handle to the device driver ppi2
	ADI_DMA_STREAM_HANDLE 	 	m_mdma_1_Handle0;		// for stream 1
	ADI_DMA_STREAM_HANDLE 	 	m_mdma_1_Handle1;		// for stream 2
	ADI_DMA_STREAM_HANDLE 	 	m_mdma_2_Handle0;		// for stream 3
	ADI_DMA_STREAM_HANDLE 	 	m_mdma_2_Handle1;		// for stream 4
#else
	ADI_DEV_DEVICE_HANDLE 		m_ppiDeviceHandle;	// handle to the device driver
	ADI_DMA_STREAM_HANDLE 	 	m_mdmaHandle0;
	ADI_DMA_STREAM_HANDLE 	 	m_mdmaHandle1;
#endif

//	ADI_DEV_BUFFER * m_devBuffer;


	
// heap userid
	u16 m_userid;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?