⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spdc_callbacks.c

📁 Sigma SMP8634 Mrua v. 2.8.2.0
💻 C
字号:
/* * * Copyright (c) Sigma Designs, Inc. 2006. All rights reserved. * */#include "cps_context.h"/* SPDC Callbacks */static RMstatus spdc_applicationlayer (void *ctx, RMuint32 resource, RMuint32 direction, RMuint32 *dataPtr){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->bdp_app_layer_callback(cps->callback_context, resource, direction, dataPtr);}static RMstatus spdc_getclock (void *ctx, RMuint32 dstPtr[3]){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	/* getclock callback can be NULL - default to valid values */	if(cps->callbacks->bdp_getclock_callback)		return cps->callbacks->bdp_getclock_callback(cps->callback_context, dstPtr);	else {		dstPtr[0]=0xffffffff;		dstPtr[1]=0xffffffff;		dstPtr[2]=0x0000ffff; // Fliped! 0xffff0000;		return RM_OK;	}}static RMstatus spdc_getmediainfobits (void *ctx, RMuint32 dstPtr[10]){	RMstatus rc;	struct cps_context_s *cps=(struct cps_context_s *)ctx;	/* We assume that aacs returns all FF if volume id or pmsn is	 * not present on disc.	 * Its not clear if aacs can differentiate between an error condition	 * and the absence of those values - which are optionnal for BD-ROM	 * according to BD specs.	 */	dstPtr[0]=cps->media_info_bits_0; /* calculated by cps_media_initialize */	dstPtr[9]=0; /* reserved - set to 0 */	rc=aacs_get_volume_id(cps->aacs_context, (RMuint8 *)(dstPtr+1));		if(rc!=RM_OK) return rc;		return aacs_get_pmsn(cps->aacs_context, (RMuint8 *)(dstPtr+5));}static RMstatus spdc_getportinfo (void *ctx, RMuint32 index, RMuint32 dstPtr[32]){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->bdp_getportinfo_callback(cps->callback_context, index, dstPtr);}static RMstatus spdc_discoveryram (void *ctx, RMuint32 addr, RMuint8 *dstptr, RMuint32 len){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->bdp_discoveryram_callback(cps->callback_context, addr, dstptr, len);}static RMstatus spdc_runnative (void *ctx, RMuint8 *code, RMint32 len, RMuint32 mode){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->bdp_runnative_callback(cps->callback_context, code, len, mode);}static RMstatus spdc_sendfixuptable (void *ctx, RMuint8 *fixupTable, RMuint32 size){	RMstatus err;	struct cps_context_s *cps=(struct cps_context_s *)ctx;		RMDBGLOG((ENABLE,"spdc_sendfixuptable (0x%08lx, %ld)!\n",fixupTable,size));	if( cps->aacs_context ) {		err =  aacs_send_fut(cps->aacs_context, fixupTable, size); 	}	else {		/* For testing BD+ only, do nothing */		err = RM_OK;	}			return err;}static RMstatus spdc_readfile (void *ctx, RMuint8 *filename, RMuint64 offset, RMuint32 *length, RMuint8* dstPtr){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->file_read_callback(cps->callback_context, (const RMascii*)filename, offset, dstPtr, length);}static void spdc_sleep (void *ctx){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	/* Sleep if defined */	if(cps->callbacks->bdp_sleep_vm_callback) {			cps->callbacks->bdp_sleep_vm_callback(cps->callback_context);	}}static RMstatus spdc_slotrw (void* ctx, RMint32 direction, RMuint8* memptr, RMuint32 slot){	RMuint32         length;	RMuint32         offset;	const RMascii    slotFile[]    = "slot_file.nvs";	const RMascii    counterFile[] = "slot_counter.nvs";	RMascii         *filename;	struct cps_context_s *cps=(struct cps_context_s *)ctx;	if( (memptr == NULL) || (slot < 0) || (slot > 500) )		return RM_ERROR;	if( slot == 500 ) {		/* Counter File */		filename  = (RMascii*)counterFile;		length    = 5;		offset    = 0;	}	else {		/* Slot */		filename  = (RMascii*)slotFile;		length    = 256;		offset = 256*slot;	}		if(direction == 0) {		//Read		//RMDBGLOG((ENABLE," Getting ready to call the Slot read callback! - filename = %s, length= %d, offset=%ld\n",filename, length, offset));		return cps->callbacks->nvs_read_callback( cps->callback_context, filename, memptr, &length, offset);	}	else if( direction == 1) {		// Write		//RMDBGLOG((ENABLE," Getting ready to call the Slot write callback! - filename = %s, length= %d, offset=%ld\n",filename, length, offset));		return cps->callbacks->nvs_write_callback( cps->callback_context, filename, memptr, &length, offset);	}	else {		RMDBGLOG((ENABLE," INvalid direction for the slot callback ! direction = %d\n",direction));		return RM_ERROR;	}	}static void spdc_interrupt_done (void* ctx, union SVMINTRP* intrp, RMuint32 intrpID){	intrp->base.InterruptID=0xffffffff;}static RMstatus spdc_lock_q( void* ctx ){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->bdp_lock_q_callback(cps->callback_context);}static RMstatus spdc_unlock_q( void* ctx ){	struct cps_context_s *cps=(struct cps_context_s *)ctx;	return cps->callbacks->bdp_unlock_q_callback(cps->callback_context);}/* spdc callbacks: */struct SVM_Callbacks g_spdc_callbacks = {	.applicationlayer_callback   = &spdc_applicationlayer,	.getclock_callback           = &spdc_getclock,	.getmediainfobits_callback   = &spdc_getmediainfobits,	.getportinfo_callback        = &spdc_getportinfo,	.discoveryram_callback       = &spdc_discoveryram,	.runnative_callback          = &spdc_runnative,	.sendfixuptable_callback     = &spdc_sendfixuptable,	.readfile_callback           = &spdc_readfile,	.sleep_callback              = &spdc_sleep,	.slotrw_callback             = &spdc_slotrw,	.interrupt_done_callback     = &spdc_interrupt_done,        .lock_q_semaphore_callback   = &spdc_lock_q,	.unlock_q_semaphore_callback = &spdc_unlock_q,};

⌨️ 快捷键说明

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