Esempio n. 1
0
status_t OpenSoundDeviceEngine::Open(int mode)
{
	int omode, v;
	CALLED();

	switch (mode) {
	case OPEN_READ:
		if (!(Caps() & DSP_CAP_INPUT))
			return EINVAL;
		omode = O_RDONLY;
		break;
	case OPEN_WRITE:
		if (!(Caps() & DSP_CAP_OUTPUT))
			return EINVAL;
		omode = O_WRONLY;
		break;
	case OPEN_READWRITE:
		if (!(Caps() & DSP_CAP_OUTPUT) || !(Caps() & DSP_CAP_INPUT))
			return EINVAL;
		omode = O_RDWR;
		break;
	default:
		return EINVAL;
	}
	// O_EXCL = bypass soft mixer = direct access
	omode |= O_EXCL;

	Close();
	fOpenMode = mode;
	fFD = open(fAudioInfo.devnode, omode);
	if (fFD < 0) {
		fInitCheckStatus = errno;
		return EIO;
	}
	// disable format convertions
	v = 0;
	if (ioctl(fFD, SNDCTL_DSP_COOKEDMODE, &v, sizeof(int)) < 0) {
		fInitCheckStatus = errno;
		Close();
		return EIO;
	}

	// set driver buffer size by using the "fragments" API
	// TODO: export this setting as a BParameter?
	uint32 bufferCount = 4;
	uint32 bufferSize = 0x000b; // 1024 bytes
	v = (bufferCount << 16) | bufferSize;
	if (ioctl(fFD, SNDCTL_DSP_SETFRAGMENT, &v, sizeof(int)) < 0) {
		fInitCheckStatus = errno;
		Close();
		return EIO;
	}

	fDriverBufferSize = 2048;
		// preliminary, adjusted in AcceptFormat()
	return B_OK;
}
	bool begin()
	{
		bool Validated = this->checkExtension("GL_ARB_texture_barrier");

		glm::vec2 WindowSize(this->getWindowSize());
		this->Viewports.resize(1000);
		for (std::size_t i = 0; i < this->Viewports.size(); ++i)
		{
			this->Viewports[i] = glm::vec4(
				glm::linearRand(-WindowSize.x, WindowSize.x * 2.0f), 
				glm::linearRand(-WindowSize.y, WindowSize.y * 2.0f),
				WindowSize * glm::linearRand(0.0f, 1.0f));
		}

		caps Caps(caps::CORE);

		if (Validated)
			Validated = initProgram();
		if (Validated)
			Validated = initBuffer();
		if (Validated)
			Validated = initVertexArray();
		if (Validated)
			Validated = initTexture();
		if (Validated)
			Validated = initFramebuffer();

		return Validated;
	}
Esempio n. 3
0
	bool begin()
	{
		caps Caps(caps::CORE);

		bool Validated = true;

		Validated = Validated && Caps.Limits.MAX_VERTEX_UNIFORM_BLOCKS >= 12;
		Validated = Validated && Caps.Limits.MAX_GEOMETRY_UNIFORM_BLOCKS >= 12;
		Validated = Validated && Caps.Limits.MAX_FRAGMENT_UNIFORM_BLOCKS >= 12;

		Validated = Validated && Caps.Limits.MAX_VERTEX_UNIFORM_COMPONENTS >= 1024;
		Validated = Validated && Caps.Limits.MAX_GEOMETRY_UNIFORM_COMPONENTS >= 1024;
		Validated = Validated && Caps.Limits.MAX_FRAGMENT_UNIFORM_COMPONENTS >= 1024;

		Validated = Validated && Caps.Limits.MAX_COMBINED_UNIFORM_BLOCKS >= 36;
		Validated = Validated && Caps.Limits.MAX_UNIFORM_BUFFER_BINDINGS >= 36;
		Validated = Validated && Caps.Limits.MAX_UNIFORM_BLOCK_SIZE >= 16384;

		std::uint64_t const CombinedVertUniformCount(Caps.Limits.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
		std::uint64_t const CombinedGeomUniformCount(Caps.Limits.MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS);
		std::uint64_t const CombinedFragUniformCount(Caps.Limits.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);

		std::uint64_t const VertUniformCount((static_cast<std::uint64_t>(Caps.Limits.MAX_VERTEX_UNIFORM_BLOCKS) * static_cast<std::uint64_t>(Caps.Limits.MAX_UNIFORM_BLOCK_SIZE) / 4) + static_cast<std::uint64_t>(Caps.Limits.MAX_VERTEX_UNIFORM_COMPONENTS));
		std::uint64_t const GeomUniformCount((static_cast<std::uint64_t>(Caps.Limits.MAX_GEOMETRY_UNIFORM_BLOCKS) * static_cast<std::uint64_t>(Caps.Limits.MAX_UNIFORM_BLOCK_SIZE) / 4) + static_cast<std::uint64_t>(Caps.Limits.MAX_GEOMETRY_UNIFORM_COMPONENTS));
		std::uint64_t const FragUniformCount((static_cast<std::uint64_t>(Caps.Limits.MAX_FRAGMENT_UNIFORM_BLOCKS) * static_cast<std::uint64_t>(Caps.Limits.MAX_UNIFORM_BLOCK_SIZE) / 4) + static_cast<std::uint64_t>(Caps.Limits.MAX_FRAGMENT_UNIFORM_COMPONENTS));

		Validated = Validated && CombinedVertUniformCount <= VertUniformCount;
		Validated = Validated && CombinedGeomUniformCount <= GeomUniformCount;
		Validated = Validated && CombinedFragUniformCount <= FragUniformCount;

		return Validated;
	}
	bool begin()
	{
		bool Validated(true);

		caps Caps(caps::CORE);

		if(Validated)
			Validated = initProgram();
		if(Validated)
			Validated = initBuffer();
		if(Validated)
			Validated = initVertexArray();
		if(Validated)
			Validated = initTexture();
		if(Validated)
			Validated = initFramebuffer();

		GLint SubPixelBiasX = 0;
		GLint SubPixelBiasY = 0;
		GLint MaxSubPixelBias = 0;
		glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV, &SubPixelBiasX);
		glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV, &SubPixelBiasY);
		glGetIntegerv(GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV, &MaxSubPixelBias);

		return Validated;
	}
Esempio n. 5
0
	bool checkCaps()
	{
		caps Caps(caps::CORE);

		if(Caps.Limits.MAX_SHADER_STORAGE_BLOCK_SIZE < (2 << 27))
			return false;

		return true;
	}
Esempio n. 6
0
/** 
A function called by the local media subsystem to deal with a request;
this is implemented by the generic layer of the LFFS media driver.

The implementation delegates the handling of reading, writing and erasing
to the specific layer's DoRead(), DoWrite() and DoErase() functions 
respectively.
	
@param aRequest An object that encapsulates information about the request.
    
@return A value indicating the result:
        KErrNone, if the request has been sucessfully initiated;
        KErrNotSupported, if the request cannot be handled by the device;
        KMediaDriverDeferRequest, if the request cannot be handled
        immediately because of an outstanding request (this request will be
        deferred until the outstanding request has completed);
        otherwise one of the other system-wide error codes.
        
@see DMediaDriverFlash::DoRead()        
@see DMediaDriverFlash::DoWrite()
@see DMediaDriverFlash::DoErase()
*/
TInt DMediaDriverFlash::Request(TLocDrvRequest& m)
	{
	TInt r=KErrNotSupported;
	TInt id=m.Id();
	__KTRACE_OPT(KLOCDRV,Kern::Printf(">DMediaDriverFlash::Request %d",id));
	if (id==DLocalDrive::ECaps)
		{
  		TLocalDriveCapsV4& c=*(TLocalDriveCapsV4*)m.RemoteDes();
		r=Caps(c);
		c.iSize=m.Drive()->iPartitionLen;
		c.iPartitionType=m.Drive()->iPartitionType;
		SetTotalSizeInBytes(c);
		return r;
		}
	switch (id)
		{
		case DLocalDrive::ERead:
			if (iReadReq)
				return KMediaDriverDeferRequest;	// read already in progress so defer this one
			iReadReq=&m;
			r=DoRead();
			if (r!=KErrNone)
				iReadReq=NULL;
			break;
		case DLocalDrive::EWrite:
			if (iWriteReq)
				return KMediaDriverDeferRequest;	// write already in progress so defer this one
			iWriteReq=&m;
			r=DoWrite();
			if (r!=KErrNone)
				iWriteReq=NULL;
			break;
		case DLocalDrive::EFormat:
			if (iEraseReq)
				return KMediaDriverDeferRequest;	// erase already in progress so defer this one
			iEraseReq=&m;
			r=DoErase();
			if (r!=KErrNone)
				iEraseReq=NULL;
			break;
		case DLocalDrive::EEnlarge:
		case DLocalDrive::EReduce:
		default:
			r=KErrNotSupported;
			break;
		}
	__KTRACE_OPT(KLOCDRV,Kern::Printf("<DMediaDriverFlash::Request %d",r));
	if (r<0)
		DMediaDriver::Complete(m,r);
	return r;
	}
Esempio n. 7
0
void
SpdyConnectTransaction::MapStreamToHttpConnection(nsISocketTransport *aTransport,
                                                  nsHttpConnectionInfo *aConnInfo)
{
  mConnInfo = aConnInfo;

  mTunnelTransport = new SocketTransportShim(aTransport);
  mTunnelStreamIn = new InputStreamShim(this);
  mTunnelStreamOut = new OutputStreamShim(this);
  mTunneledConn = new nsHttpConnection();

  // this new http connection has a specific hashkey (i.e. to a particular
  // host via the tunnel) and is associated with the tunnel streams
  LOG(("SpdyConnectTransaction new httpconnection %p %s\n",
       mTunneledConn.get(), aConnInfo->HashKey().get()));

  nsCOMPtr<nsIInterfaceRequestor> callbacks;
  GetSecurityCallbacks(getter_AddRefs(callbacks));
  mTunneledConn->SetTransactionCaps(Caps());
  MOZ_ASSERT(aConnInfo->UsingHttpsProxy());
  TimeDuration rtt = TimeStamp::Now() - mTimestampSyn;
  mTunneledConn->Init(aConnInfo,
                      gHttpHandler->ConnMgr()->MaxRequestDelay(),
                      mTunnelTransport, mTunnelStreamIn, mTunnelStreamOut,
                      true, callbacks,
                      PR_MillisecondsToInterval(
                        static_cast<uint32_t>(rtt.ToMilliseconds())));
  if (mForcePlainText) {
      mTunneledConn->ForcePlainText();
  } else {
    mTunneledConn->SetupSecondaryTLS();
    mTunneledConn->SetInSpdyTunnel(true);
  }

  // make the originating transaction stick to the tunneled conn
  nsRefPtr<nsAHttpConnection> wrappedConn =
    gHttpHandler->ConnMgr()->MakeConnectionHandle(mTunneledConn);
  mDrivingTransaction->SetConnection(wrappedConn);
  mDrivingTransaction->MakeSticky();

  // jump the priority and start the dispatcher
  gHttpHandler->InitiateTransaction(
    mDrivingTransaction, nsISupportsPriority::PRIORITY_HIGHEST - 60);
  mDrivingTransaction = nullptr;
}
Esempio n. 8
0
	bool begin()
	{
		caps Caps(caps::CORE);

		bool Validated = true;

		if(Validated)
			Validated = initProgram();
		if(Validated)
			Validated = initBuffer();
		if(Validated)
			Validated = initVertexArray();
		if(Validated)
			Validated = initTexture();
		if(Validated)
			Validated = initFramebuffer();

		return Validated && this->checkError("begin");
	}
	bool begin()
	{
		bool Validated = this->checkExtension("GL_NV_shader_thread_group");

		caps Caps(caps::CORE);

		if(Validated)
			Validated = initProgram();
		if(Validated)
			Validated = initBuffer();
		if(Validated)
			Validated = initVertexArray();
		if(Validated)
			Validated = initTexture();
		if(Validated)
			Validated = initFramebuffer();

		return Validated;
	}
Esempio n. 10
0
	bool begin()
	{
		bool Validated = this->checkExtension("GL_ARB_texture_barrier");

		glm::vec2 const WindowSize(this->getWindowSize());
		glm::vec2 const WindowRange = WindowSize * 3.f;

		this->Viewports.resize(1000);
		for (std::size_t i = 0; i < this->Viewports.size(); ++i)
		{
			glm::vec2 const ViewportPos(i % 17u, i % 13u);
			glm::vec2 const ViewportSize(i % 11u);
			this->Viewports[i] = glm::vec4(ViewportPos / glm::vec2(17, 13) * WindowRange - WindowSize, WindowSize * ViewportSize / glm::vec2(11));
		}
/*
		glm::vec2 WindowSize(this->getWindowSize());
		this->Viewports.resize(1000);
		for (std::size_t i = 0; i < this->Viewports.size(); ++i)
		{
			this->Viewports[i] = glm::vec4(
				glm::linearRand(-WindowSize.x, WindowSize.x * 2.0f), 
				glm::linearRand(-WindowSize.y, WindowSize.y * 2.0f),
				WindowSize * glm::linearRand(0.0f, 1.0f));
		}
*/
		caps Caps(caps::CORE);

		if (Validated)
			Validated = initProgram();
		if (Validated)
			Validated = initBuffer();
		if (Validated)
			Validated = initVertexArray();
		if (Validated)
			Validated = initTexture();
		if (Validated)
			Validated = initFramebuffer();

		return Validated;
	}
Esempio n. 11
0
TInt DMediaDriverIRam::Request(TLocDrvRequest& m)
	{
	TInt request=m.Id();
	__KTRACE_OPT(KLOCDRV,Kern::Printf(">DMediaDriverIRam::Request %d",request));
	TInt r=KErrNotSupported;
	NKern::ThreadEnterCS();
	TInternalRamDrive::Wait();
	switch (request)
		{
		case DLocalDrive::ECaps:
			r=Caps(m);
			break;
		case DLocalDrive::ERead:
			r=Read(m);
			break;
		case DLocalDrive::EWrite:
			r=Write(m);
			break;
		case DLocalDrive::EFormat:
			r=Format(m);
			break;
		case DLocalDrive::EEnlarge:
			r=Enlarge(m);
			break;
		case DLocalDrive::EReduce:
			r=Reduce(m);
			break;
		default:
			r=KErrNotSupported;
			break;
		}
	TInternalRamDrive::Signal();
	NKern::ThreadLeaveCS();
	__KTRACE_OPT(KLOCDRV,Kern::Printf("<DMediaDriverIRam::Request %d",r));
	return r;
	}
Esempio n. 12
0
/** 
 Handle Synchronous Requests. This is called from Request() to process
 synchronous requests, that perform the action quickly and returns.
 Handling these requests is implementation specific. However, if it needs
 any hardware operation, then PDD function can be invoked from here.
 
 @param 	aFunction
 		  	Request number
 @param 	a1
 			parameter1 passed by user for the request
 @param 	a2
 			parameter2 passed by user for the request
 			
 @return	KErrNone or standard error code
 */	
TInt DExDriverLogicalChannel::DoControl(TInt aFunction, TAny* a1,
										TAny* /*a2*/) // a2 is not being used
	{
	KEXDEBUG(Kern::Printf("++DExDriverLogicalChannel::DoControl"));

	TInt r;

	// Switch over the request type. Typically the requests that are
	// passed here will be RExdDriver::TControl enumerated requests
	// sent by the user in user side DoControl() request
	//
	switch(aFunction)
		{
		// User request to read the channel capabilities of Uart driver
		//
		case RExDriverChannel::EControlCaps:
			
			// Call Caps() to retrieve capabilities to a1
			r = Caps((TDes8*)a1);
			
			break;
		// User request to configure the device (uart)
		//
		case RExDriverChannel::EControlSetConfig:
			// Call SetConfig function by passing the first argument
			r = SetConfig((const TDesC8*)a1);
			break;
		// User request to enable or disable the device's internal loopback mode
		//
		case RExDriverChannel::EControlSetIntLoopback:
			// Call SetIntLoopback function by passing the first argument
			r = SetIntLoopback((const TInt*)a1);
			break;
		case RExDriverChannel::ERequestTransmitData:
			// Call TransmitData function
			
			// Check if already transmit is going on this channel by some other
			// user thread. If yes then return KErrInUse.
			WaitOnTxFMutex();
			if (iTxProgress)
				{
				SignalTxFMutex();
				return KErrInUse;
				}
			
			// Mark Transmit Data progress flag as true.
			iTxProgress = ETrue;
			SignalTxFMutex();
			r = TransmitData((const TDesC8*)a1);
			break;

		case RExDriverChannel::ERequestReceiveData:
			// Call receive data function
			
			// Check if already receive data is going on this channel by some other
			// user thread. If yes then return KErrInUse.
			WaitOnRxFMutex();
			if (iRxProgress)
				{
				SignalRxFMutex();
				return KErrInUse;
				}
			
			// Mark Receive Data progress flag as true.
			iRxProgress = ETrue;
			SignalRxFMutex();
			r = ReceiveData((TDes8*)a1);
			break;
		
		default:
			// Unknown request and therefore not supported
			//
			r = KErrNotSupported;
		}
	return r;
	}
Esempio n. 13
0
	bool checkCaps()
	{
		caps Caps(caps::CORE);

		GLint NumCompressedTextureFormats = 0;
		glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &NumCompressedTextureFormats);
		std::vector<GLint> CompressedTextureFormats(NumCompressedTextureFormats);
		glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, &CompressedTextureFormats[0]);

		if(this->checkExtension("GL_EXT_texture_compression_s3tc"))
		{
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGB_S3TC_DXT1_EXT) == CompressedTextureFormats.end())
				return false;
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) == CompressedTextureFormats.end())
				return false;
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) == CompressedTextureFormats.end())
				return false;
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) == CompressedTextureFormats.end())
				return false;
		}

		if(this->checkExtension("GL_EXT_texture_sRGB") && this->checkExtension("GL_EXT_texture_compression_s3tc"))
		{
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB_S3TC_DXT1_EXT) == CompressedTextureFormats.end())
				return false;
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT) == CompressedTextureFormats.end())
				return false;
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT) == CompressedTextureFormats.end())
				return false;
			if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) == CompressedTextureFormats.end())
				return false;
		}

		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RED_RGTC1) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SIGNED_RED_RGTC1) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RG_RGTC2) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SIGNED_RG_RGTC2) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGBA_BPTC_UNORM) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGB8_ETC2) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB8_ETC2) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RGBA8_ETC2_EAC) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_R11_EAC) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SIGNED_R11_EAC) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_RG11_EAC) == CompressedTextureFormats.end())
			return false;
		if(std::find(CompressedTextureFormats.begin(), CompressedTextureFormats.end(), GL_COMPRESSED_SIGNED_RG11_EAC) == CompressedTextureFormats.end())
			return false;

		return true;
	}
TInt DMediaDriverNVMemory::Request(TLocDrvRequest& m)
	{
	TInt request=m.Id();
	__DEBUG_PRINT(">DMediaDriverNVMemory::Request %d",request);
	TInt r=KErrNone;
	
	// Requests that can be handled synchronously
	if( request == DLocalDrive::ECaps ) 
		{
		r=Caps(m);
		return r;
		}

	// All other requests must be deferred if a request is currently in progress
	if (iCurrentRequest)
		{
		// a request is already in progress, so hold on to this one
		r = KMediaDriverDeferRequest;
		}
	else
		{

		iCurrentRequest=&m;
		iProsessedLength = 0;

//  SF BUG 3759 - NVM drives do not support operations larger than 262144 bytes correctly - start
		iSplitLength = 0; // New variable for split operation housekeeping
//  SF BUG 3759 - NVM drives do not support operations larger than 262144 bytes correctly - end

		iHead = 0;
		iTail = 0;
		iSplitted = 0;
		iAlignmentOverhead = 0;

		iPos = m.Pos();
		iTotalLength = m.Length();


		__DEBUG_PRINT(">DMediaDriverNVMemory::Request pos:0x%lx len:0x%lx", iPos, iTotalLength);
		if( iTotalLength<0 || iPos<0 )
			{
			Kern::Fault("DMediaDriverNVMemory::Request: illegal access!", 0);
			}
		// Handle unaligned operations
		iHead = iPos % KDiskSectorSize;
		TUint32 tailAlignment = ((iHead + iTotalLength) % KDiskSectorSize);
		if( tailAlignment )
			{
			iTail = KDiskSectorSize - tailAlignment;
			}

		iSplitted = (iTotalLength + iHead + iTail) / KNVMemTransferBufferSize;

		__DEBUG_PRINT(">DMediaDriverNVMemory::Request head: %d tail: %d splitted: %d\n", iHead, iTail, iSplitted );
		__DEBUG_PRINT(">DMediaDriverNVMemory::Request partitionlen: %lx", iCurrentRequest->Drive()->iPartitionLen );

		if( (iTotalLength + iPos) > iCurrentRequest->Drive()->iPartitionLen )
			{
			Kern::Fault("DMediaDriverNVMemory::Request: Access over partition boundary!", 0);
			}
		if( iTotalLength > KMaxTInt32 )
			{
			Kern::Fault("DMediaDriverNVMemory::Request: Access length overflow!", 0);
			}
		switch (request)
			{
			case DLocalDrive::ERead:
			case DLocalDrive::EWrite:
			case DLocalDrive::EFormat:
				__DEBUG_PRINT("DMediaDriverNVMemory::Request iTransactionLaunchDfc.Enque()>");
				iTransactionLaunchDfc.Enque();
				__DEBUG_PRINT("DMediaDriverNVMemory::Request iTransactionLaunchDfc.Enque()<");
			break;
			case DLocalDrive::EEnlarge:
			case DLocalDrive::EReduce:
			default:
				r=KErrNotSupported;
			break;
			}
		}

	__DEBUG_PRINT("<DMediaDriverNVMemory::Request %d",r);
	return r;
	}
Esempio n. 15
0
/** 
 Handle Synchronous Requests. This is called from HandleMsg() to process
 synchronous requests, that perform the action quickly and returns.
 Handling these requests is implementation specific. However, if it needs
 any hardware operation, then PDD function can be invoked from here.
 
 @param 	aFunction
 		  	Request number
 @param 	a1
 			parameter1 passed by user for the request
 @param 	a2
 			parameter2 passed by user for the request
 			
 @return	KErrNone or standard error code
 */	
TInt DExDriverLogicalChannel::DoControl(TInt aFunction, TAny* a1) // a2 is not being used
	{
	KEXDEBUG(Kern::Printf("++DExDriverLogicalChannel::DoControl"));

	TInt r;
	
	// Switch over the request type. Typically the requests that are
	// passed here will be RExdDriver::TControl enumerated requests
	// sent by the user in user side DoControl() request
	//
	switch(aFunction)
		{
		// User request to read the channel capabilities of Uart driver
		//
		case RExDriverChannel::EControlCaps:
			// Check if the client thread has ECapabilityCommDD capability
			// for the driver to process this request. Driver can enforce
			// more capability checks (other than those checked during channel
			// creation), for individual requests.
			//
			// Any API specific capability can be checked this way. Capability
			// that has already been checked while opening need not be checked
			// again here.
			//
			if(iClient->HasCapability(ECapabilityCommDD,
					__PLATSEC_DIAGNOSTIC_STRING("Checked by Tutorial Driver")))
				{
				// Call Caps() to retrieve capabilities to a1
				r = Caps((TDes8*)a1);
				}
            else
            	{
            	// If the required capability is not present for the user
            	// thread to process this request, then deny the request.
            	//
            	r=KErrPermissionDenied;
            	}
			break;
			
		// User request to configure the device (uart)
		//
		case RExDriverChannel::EControlSetConfig:
			// Call SetConfig function by passing the first argument
			r = SetConfig((const TDesC8*)a1);
			break;
			
		// User request to enable or disable the device's internal loopback mode
		//
		case RExDriverChannel::EControlSetIntLoopback:
			// Call SetIntLoopback function by passing the first argument
			r = SetIntLoopback((const TInt*)a1);
			break;
			
		// User request to get the handle for Tx chunk. This will actually
		// create and return the handle created.	
		//
		case RExDriverChannel::EGetTxChunkHandle:
			// This is a synchronous request and a1 will hold the chunk 
			// handle value (>0 if success) after return 
			//
			r = GetTxChunkHandle((TInt*)a1);
			break;	
				
		// User request to get the handle for Rx chunk. This will actually
		// create and return the handle created.	
		//
		case RExDriverChannel::EGetRxChunkHandle:
			// This is a synchronous request and a1 will hold the chunk 
			// handle value (>0 if success) after return 
			//						
			r = GetRxChunkHandle((TInt*)a1);
			break;
			
		// User request to pass the handle for Tx chunk.
		// This shared chunk is created by other driver (Channel) and passed here.
		case RExDriverChannel::EPassTxChunkHandle:
			// This is a synchronous request and a1 will hold the chunk 
			// handle value (KErrNone if success) after return 
			//						
			r = PassTxChunkHandle((TInt*)a1);
			break;
			
		// User request to pass the handle for Rx chunk.
		// This shared chunk is created by other driver (Channel) and passed here.
		case RExDriverChannel::EPassRxChunkHandle:
			// This is a synchronous request and a1 will hold the chunk 
			// handle value (KErrNone if success) after return 
			//						
			r = PassRxChunkHandle((TInt*)a1);
			break;
						
		default:
			// Unknown request and therefore not supported
			//
			r = KErrNotSupported;			
	}
	
	return r;
	}
Esempio n. 16
0
	bool checkCaps()
	{
		caps Caps(caps::CORE);

		return true;
	}