os/kernelhwsrv/kernel/eka/drivers/pbus/pccard/epoc/pccd_socket.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\drivers\pbus\pccard\epoc\pccd_socket.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <pccd_socket.h>
sl@0
    19
sl@0
    20
DPlatPcCardSocket::DPlatPcCardSocket(TSocket aSocketNum)
sl@0
    21
//
sl@0
    22
// Constructor.
sl@0
    23
//
sl@0
    24
	: DPcCardSocket(aSocketNum)
sl@0
    25
	{
sl@0
    26
	}
sl@0
    27
sl@0
    28
TInt DPlatPcCardSocket::Create(const TDesC* aName)
sl@0
    29
//
sl@0
    30
// Allocate any resources.
sl@0
    31
//
sl@0
    32
	{
sl@0
    33
sl@0
    34
	__KTRACE_OPT(KPBUS1,Kern::Printf(">PlatSkt:Create"));
sl@0
    35
	TInt r=DPcCardSocket::Create(aName);
sl@0
    36
	if (r!=KErrNone)
sl@0
    37
		return r;
sl@0
    38
sl@0
    39
	// Bind to the PC card interrupts for this socket
sl@0
    40
	iCardIReqIntId=ThePccdCntrlInterface->IntIdIReq(iSocketNumber);
sl@0
    41
	iStatusChangeIntId=ThePccdCntrlInterface->IntIdStsC(iSocketNumber);
sl@0
    42
	iReadyChangeIntId=ThePccdCntrlInterface->IntIdRdyC(iSocketNumber);
sl@0
    43
	if (iCardIReqIntId!=-1)
sl@0
    44
		{
sl@0
    45
		r=Interrupt::Bind(iCardIReqIntId,CardIReqIsr,this);
sl@0
    46
		if (r!=KErrNone)
sl@0
    47
			return r;
sl@0
    48
		}
sl@0
    49
	if (iStatusChangeIntId!=-1)
sl@0
    50
		{
sl@0
    51
		r=Interrupt::Bind(iStatusChangeIntId,StatusChangeIsr,this);
sl@0
    52
		if (r!=KErrNone)
sl@0
    53
			return r;
sl@0
    54
		}
sl@0
    55
	if (iReadyChangeIntId!=-1)
sl@0
    56
		{
sl@0
    57
		r=Interrupt::Bind(iReadyChangeIntId,ReadyChangeIsr,this);
sl@0
    58
		if (r!=KErrNone)
sl@0
    59
			return r;
sl@0
    60
		}
sl@0
    61
	return KErrNone;
sl@0
    62
	}
sl@0
    63
sl@0
    64
void DPlatPcCardSocket::Reset1()
sl@0
    65
//
sl@0
    66
// Reset the socket
sl@0
    67
//
sl@0
    68
	{
sl@0
    69
sl@0
    70
	__KTRACE_OPT(KPBUS1,Kern::Printf(">PlatSkt(%d):Rst1",iSocketNumber));
sl@0
    71
	if (iCardIReqIntId!=-1)
sl@0
    72
		Interrupt::Disable(iCardIReqIntId);
sl@0
    73
	ThePccdCntrlInterface->InterfaceOff(iSocketNumber);
sl@0
    74
	DPcCardSocket::Reset1();
sl@0
    75
	}
sl@0
    76
sl@0
    77
DPccdChunkBase *DPlatPcCardSocket::NewPccdChunk(TPccdMemType aType)
sl@0
    78
//
sl@0
    79
// Create a new pc card hw chunk.
sl@0
    80
//
sl@0
    81
	{
sl@0
    82
	return PccdIfc::NewChunk(aType);
sl@0
    83
	}
sl@0
    84
sl@0
    85
TInt DPlatPcCardSocket::Indicators(TSocketIndicators &anInd)
sl@0
    86
//
sl@0
    87
// Return the current state of this sockets indicators
sl@0
    88
//
sl@0
    89
	{
sl@0
    90
sl@0
    91
	ThePccdCntrlInterface->Indicators(iSocketNumber,anInd);
sl@0
    92
	__KTRACE_OPT(KPBUS1,Kern::Printf("<PlatSkt:Indicators(C:%dV:%dW:%dB:%d)",anInd.iCardDetected,anInd.iVoltSense,anInd.iBatState,anInd.iWriteProtected));
sl@0
    93
	return(KErrNone) ;
sl@0
    94
	}
sl@0
    95
sl@0
    96
void DPlatPcCardSocket::HwReset(TBool anAssert)
sl@0
    97
//
sl@0
    98
// Apply/remove h/w reset.
sl@0
    99
//
sl@0
   100
	{
sl@0
   101
sl@0
   102
	__KTRACE_OPT(KPBUS1,Kern::Printf(">PlatSkt:HwRst(%d)",anAssert));
sl@0
   103
    ThePccdCntrlInterface->CardReset(iSocketNumber,anAssert);
sl@0
   104
	}
sl@0
   105
sl@0
   106
TBool DPlatPcCardSocket::Ready(TInt aCardFunc)
sl@0
   107
//
sl@0
   108
// Return the current state of the Card Ready signal. When a function
sl@0
   109
// isn't specified then it always reads the Ready pin.
sl@0
   110
//
sl@0
   111
	{
sl@0
   112
	// If a function has been specified and this is in I/O mode then read from
sl@0
   113
	// the configuration register (Pin replacement register).
sl@0
   114
//	if (aCardFunc!=KInvalidFuncNum)
sl@0
   115
//		{
sl@0
   116
//		if ( iStatus==ESocketReady && CardFunc(aCardFunc)->IsConfigured() )
sl@0
   117
//			{
sl@0
   118
//			TUint8 reg;
sl@0
   119
//			if ( ReadConfigReg(aCardFunc,KPinReplacementReg,reg) != KErrNone)
sl@0
   120
//				return(EFalse);
sl@0
   121
//			else
sl@0
   122
//				return(reg&KPinRepReadyM);
sl@0
   123
//			}
sl@0
   124
//		}
sl@0
   125
	TBool rdy=ThePccdCntrlInterface->CardReady(iSocketNumber);
sl@0
   126
	__KTRACE_OPT(KPBUS1,Kern::Printf("<PlatSkt:Rdy-%d",(TInt)rdy));
sl@0
   127
	return(rdy);
sl@0
   128
	}
sl@0
   129
sl@0
   130
TInt DPlatPcCardSocket::InterruptEnable(TPccdInt anInt, TUint aFlag)
sl@0
   131
//
sl@0
   132
// Enable the specified interrupt
sl@0
   133
//
sl@0
   134
	{
sl@0
   135
sl@0
   136
	TInt err=KErrNone;
sl@0
   137
	switch(anInt)
sl@0
   138
		{
sl@0
   139
		case EPccdIntIReq:
sl@0
   140
			{
sl@0
   141
			if (iCardIReqIntId==-1)
sl@0
   142
				break;
sl@0
   143
			if (aFlag&KPccdEvFlagReserved)
sl@0
   144
				iIReqLevelMode=(aFlag&KPccdEvFlagIReqLevelMode);
sl@0
   145
			TInt irqLevel=NKern::DisableAllInterrupts(); // Disable FIQs while we enable IREQ.
sl@0
   146
			// IREQ must never be active when Vpc off. Need to check that emergency
sl@0
   147
			// power down hasn't just happened since this removes Vpc without altering iStatus.
sl@0
   148
			if (iState==EPBusOn && Kern::PowerGood())
sl@0
   149
				Interrupt::Enable(iCardIReqIntId);
sl@0
   150
			else
sl@0
   151
				err=KErrGeneral;
sl@0
   152
			NKern::RestoreInterrupts(irqLevel);
sl@0
   153
			break;
sl@0
   154
			}
sl@0
   155
		case EPccdIntRdyChange:
sl@0
   156
			if (iReadyChangeIntId!=-1)
sl@0
   157
				Interrupt::Enable(iReadyChangeIntId);
sl@0
   158
			break;
sl@0
   159
		case EPccdIntIndChange:
sl@0
   160
			if (iStatusChangeIntId!=-1)
sl@0
   161
				Interrupt::Enable(iStatusChangeIntId);
sl@0
   162
			break;
sl@0
   163
		default:
sl@0
   164
			break;
sl@0
   165
		}
sl@0
   166
	return(err);
sl@0
   167
	}
sl@0
   168
sl@0
   169
void DPlatPcCardSocket::InterruptDisable(TPccdInt anInt)
sl@0
   170
//
sl@0
   171
// Disable the specified event callback
sl@0
   172
//
sl@0
   173
	{
sl@0
   174
sl@0
   175
	switch(anInt)
sl@0
   176
		{
sl@0
   177
		case EPccdIntIReq:
sl@0
   178
			if (iCardIReqIntId!=-1)
sl@0
   179
				Interrupt::Disable(iCardIReqIntId);
sl@0
   180
			break;
sl@0
   181
		case EPccdIntRdyChange:
sl@0
   182
			if (iReadyChangeIntId!=-1)
sl@0
   183
				Interrupt::Disable(iReadyChangeIntId);
sl@0
   184
			break;
sl@0
   185
		case EPccdIntIndChange:
sl@0
   186
			if (iStatusChangeIntId!=-1)
sl@0
   187
				Interrupt::Disable(iStatusChangeIntId);
sl@0
   188
			break;
sl@0
   189
		default:
sl@0
   190
			break;
sl@0
   191
		}
sl@0
   192
	}
sl@0
   193
sl@0
   194
sl@0
   195
void DPlatPcCardSocket::SocketInfo(TPcCardSocketInfo& anInfo)
sl@0
   196
//
sl@0
   197
// Return machine info relating to a particular Pc Card socket 
sl@0
   198
//
sl@0
   199
	{
sl@0
   200
sl@0
   201
	ThePccdCntrlInterface->SocketInfo(iSocketNumber,anInfo);
sl@0
   202
	}
sl@0
   203
sl@0
   204
TBool DPlatPcCardSocket::CardIsPresent()
sl@0
   205
	{
sl@0
   206
sl@0
   207
	return ThePccdCntrlInterface->CardIsPresent(iSocketNumber);
sl@0
   208
	}
sl@0
   209
sl@0
   210
void DPlatPcCardSocket::CardIReqIsr(TAny* aPtr)
sl@0
   211
	{
sl@0
   212
	DPlatPcCardSocket* pS=(DPlatPcCardSocket*)aPtr;
sl@0
   213
	if (pS->iIReqLevelMode)
sl@0
   214
		{
sl@0
   215
		pS->Isr(EPccdIntIReq);
sl@0
   216
		Interrupt::Clear(pS->iCardIReqIntId);
sl@0
   217
		}
sl@0
   218
	else
sl@0
   219
		{
sl@0
   220
		Interrupt::Clear(pS->iCardIReqIntId);
sl@0
   221
		pS->Isr(EPccdIntIReq);
sl@0
   222
		}
sl@0
   223
	}
sl@0
   224
sl@0
   225
void DPlatPcCardSocket::ReadyChangeIsr(TAny* aPtr)
sl@0
   226
	{
sl@0
   227
	DPlatPcCardSocket* pS=(DPlatPcCardSocket*)aPtr;
sl@0
   228
	Interrupt::Clear(pS->iReadyChangeIntId);
sl@0
   229
	pS->Isr(EPccdIntRdyChange);
sl@0
   230
	}
sl@0
   231
sl@0
   232
void DPlatPcCardSocket::StatusChangeIsr(TAny* aPtr)
sl@0
   233
	{
sl@0
   234
	DPlatPcCardSocket* pS=(DPlatPcCardSocket*)aPtr;
sl@0
   235
	Interrupt::Clear(pS->iStatusChangeIntId);
sl@0
   236
	pS->Isr(EPccdIntIndChange);
sl@0
   237
	}
sl@0
   238