baseport/syborg/serial/syborg_serial.cpp
author andrew.jordan <>
Sun, 02 May 2010 23:03:18 +0100
changeset 63 84dca1410127
parent 16 73107a0bc259
permissions -rw-r--r--
Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     1
/*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     3
* All rights reserved.
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     8
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
     9
* Initial Contributors:
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    11
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    12
* Contributors:
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    13
* NTT DOCOMO, INC. -- Fix bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    14
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    15
* Description: Minimalistic serial driver
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    16
*
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    17
*/
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    18
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    19
#include "syborg_serial.h"
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    20
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    21
//#define DPRINT(x) Kern::Printf(x)
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    22
//#define DPRINT2(x,y) Kern::Printf(x,y)
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    23
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    24
#define DPRINT(x)
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    25
#define DPRINT2(x,y)
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    26
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    27
_LIT(KSerialDfcQName,"SerialDFC");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    28
const TInt KDfcQuePriority = 27;
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    29
// ---------------------------------------------------------------
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    30
// ---------------------------------------------------------------
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    31
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    32
DDriverSyborgComm::DDriverSyborgComm()
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    33
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    34
	DPRINT("DDriverSyborgComm::DDriverSyborgComm()");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    35
	iVersion=TVersion(KCommsMajorVersionNumber, KCommsMinorVersionNumber, KCommsBuildVersionNumber);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    36
	}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    37
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    38
 DDriverSyborgComm::~DDriverSyborgComm()
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    39
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    40
	DPRINT("~DDriverSyborgComm::DDriverSyborgComm()");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    41
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    42
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    43
TInt DDriverSyborgComm::Install()
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    44
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    45
	DPRINT("DDriverSyborgComm::Install");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    46
	return SetName(&KPddName);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    47
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    48
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    49
void DDriverSyborgComm::GetCaps(TDes8 &aDes) const
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    50
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    51
	DPRINT("DDriverSyborgComm::GetCaps");
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    52
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    53
	TCommCaps3 capsBuf;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    54
	TCommCapsV03 &c=capsBuf();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    55
	c.iRate=KCapsBps110|KCapsBps150|KCapsBps300|KCapsBps600|KCapsBps1200|KCapsBps2400|KCapsBps4800|KCapsBps9600|KCapsBps19200|KCapsBps38400|KCapsBps57600|KCapsBps115200|KCapsBps230400;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    56
	c.iDataBits=KCapsData5|KCapsData6|KCapsData7|KCapsData8;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    57
	c.iStopBits=KCapsStop1|KCapsStop2;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    58
	c.iParity=KCapsParityNone|KCapsParityEven|KCapsParityOdd;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    59
	c.iHandshake=KCapsObeyXoffSupported|KCapsSendXoffSupported|KCapsObeyCTSSupported|KCapsFailCTSSupported|KCapsObeyDSRSupported|KCapsFailDSRSupported|KCapsObeyDCDSupported|KCapsFailDCDSupported|KCapsFreeRTSSupported|KCapsFreeDTRSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    60
	c.iSignals=KCapsSignalCTSSupported|KCapsSignalDSRSupported|KCapsSignalDCDSupported|KCapsSignalRTSSupported|KCapsSignalDTRSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    61
	c.iSIR=0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    62
	c.iNotificationCaps=KNotifyDataAvailableSupported|KNotifySignalsChangeSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    63
	c.iFifo=KCapsHasFifo;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    64
	c.iRoleCaps=0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    65
	c.iFlowControlCaps=0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    66
	c.iBreakSupported=ETrue;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    67
	aDes.FillZ(aDes.MaxLength());
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    68
	aDes=capsBuf.Left(Min(capsBuf.Length(),aDes.MaxLength()));
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    69
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    70
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    71
TInt DDriverSyborgComm::Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion& aVer)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    72
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    73
	DPRINT("DDriverSyborgComm::Create");
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    74
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    75
	DCommSyborgSoc* pD=new DCommSyborgSoc(this);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    76
	aChannel=pD;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    77
	TInt r=KErrNoMemory;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    78
	if (pD)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    79
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    80
		r=pD->DoCreate(aUnit,anInfo);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    81
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    82
	return r;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    83
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    84
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    85
TInt DDriverSyborgComm::Validate(TInt aUnit, const TDesC8* /*anInfo*/, const TVersion& aVer)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    86
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    87
	DPRINT("DDriverSyborgComm::Validate");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    88
	if ((!Kern::QueryVersionSupported(iVersion,aVer)) ||
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
    89
	  (!Kern::QueryVersionSupported(aVer,TVersion(KMinimumLddMajorVersion,KMinimumLddMinorVersion,KMinimumLddBuild))))
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    90
		return KErrNotSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    91
	return KErrNone;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    92
	}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    93
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    94
/* Reference counted open on Serial Block Drivers DfcQueue */
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    95
TInt DDriverSyborgComm::OpenDfcQueue()
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    96
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    97
	DPRINT("DDriverSyborgComm::OpenDfcQueue()");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    98
	if (iDfcQRefCount > 0)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
    99
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   100
		iDfcQRefCount++;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   101
		return KErrNone;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   102
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   103
		
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   104
	TInt err = Kern::DynamicDfcQCreate(iDfcQueue, KDfcQuePriority, KSerialDfcQName);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   105
 
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   106
    if (!err)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   107
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   108
		iDfcQRefCount++;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   109
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   110
    return err;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   111
  }
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   112
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   113
/*  Reference counted open on Serial Block Drivers DfcQueue */
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   114
void DDriverSyborgComm::CloseDfcQueue()
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   115
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   116
	DPRINT("DDriverSyborgComm::CloseDfcQueue()");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   117
    iDfcQRefCount--;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   118
    if (iDfcQRefCount == 0)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   119
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   120
		iDfcQueue->Destroy();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   121
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   122
	}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   123
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   124
TDfcQue* DDriverSyborgComm::DfcQueue()
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   125
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   126
    return iDfcQueue;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   127
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   128
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   129
// ---------------------------------------------------------------
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   130
// ---------------------------------------------------------------
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   131
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   132
DCommSyborgSoc::DCommSyborgSoc(DDriverSyborgComm* aDriverSyborgComm)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   133
	:iDriverSyborgComm(aDriverSyborgComm)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   134
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   135
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   136
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   137
DCommSyborgSoc::~DCommSyborgSoc()
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   138
	{
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   139
	(TInt)Interrupt::Unbind(iIrq);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   140
	if (iDfcQueueOpened)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   141
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   142
		iDriverSyborgComm->CloseDfcQueue();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   143
		}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   144
	}
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   145
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   146
TInt DCommSyborgSoc::DoCreate(TInt aUnit, const TDesC8* /*anInfo*/)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   147
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   148
	DPRINT2("DCommSyborgSoc::DoCreate %d",aUnit);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   149
	TInt err = KErrNone;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   150
	switch(aUnit)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   151
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   152
		case 0:
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   153
			iPortAddr = KHwBaseUart0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   154
			iIrq = EIntSerial0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   155
			break;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   156
		case 1:
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   157
			iPortAddr = KHwBaseUart1;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   158
			iIrq = EIntSerial1;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   159
			break;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   160
		case 2:
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   161
			iPortAddr = KHwBaseUart2;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   162
			iIrq = EIntSerial2;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   163
			break;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   164
		case 3:
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   165
			iPortAddr = KHwBaseUart3;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   166
			iIrq = EIntSerial3;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   167
			break;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   168
		default:
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   169
			err = KErrNotSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   170
		break;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   171
		}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   172
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   173
	if (!err)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   174
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   175
		err = iDriverSyborgComm->OpenDfcQueue();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   176
		iDfcQueueOpened = ETrue;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   177
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   178
	if (!err)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   179
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   180
		err = Interrupt::Bind(iIrq,Isr,this);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   181
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   182
	return err;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   183
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   184
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   185
TInt DCommSyborgSoc::Start()
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   186
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   187
	DPRINT("DCommSyborgSoc::Start");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   188
	WriteReg(iPortAddr, SERIAL_INT_ENABLE, 0x1);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   189
	TInt err = Interrupt::Enable(iIrq);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   190
	return err;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   191
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   192
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   193
void DCommSyborgSoc::Stop(TStopMode aMode)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   194
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   195
	DPRINT("DCommSyborgSoc::Stop");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   196
	WriteReg(iPortAddr, SERIAL_INT_ENABLE, 0x0);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   197
	(TInt)Interrupt::Disable(iIrq);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   198
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   199
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   200
void DCommSyborgSoc::Break(TBool aState)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   201
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   202
	DPRINT("DCommSyborgSoc::Break");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   203
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   204
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   205
void DCommSyborgSoc::EnableTransmit()
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   206
	{
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   207
	DPRINT("DCommSyborgSoc::EnableTransmit");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   208
	while (Kern::PowerGood())
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   209
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   210
		TInt r=TransmitIsr();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   211
		if (r<0)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   212
			{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   213
			break;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   214
			}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   215
		WriteReg(iPortAddr, SERIAL_DATA, r);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   216
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   217
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   218
	// Request LDD to check if more data is available in the client buffer.
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   219
	// TransmitISR only copies data from the LDD buffer which is 1k.
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   220
	iLdd->CheckTxBuffer();
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   221
	}
16
73107a0bc259 Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents: 2
diff changeset
   222
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   223
TUint DCommSyborgSoc::Signals() const
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   224
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   225
	DPRINT("DCommSyborgSoc::Signals");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   226
	return(0);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   227
	}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   228
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   229
void DCommSyborgSoc::SetSignals(TUint aSetMask, TUint aClearMask)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   230
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   231
	DPRINT("DCommSyborgSoc::SetSignals");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   232
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   233
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   234
TInt DCommSyborgSoc::ValidateConfig(const TCommConfigV01 &aConfig) const
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   235
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   236
	DPRINT("DCommSyborgSoc::ValidateConfig");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   237
	return KErrNone;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   238
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   239
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   240
void DCommSyborgSoc::Configure(TCommConfigV01 &aConfig)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   241
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   242
	DPRINT("DCommSyborgSoc::Configure");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   243
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   244
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   245
void DCommSyborgSoc::Caps(TDes8 &aCaps) const
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   246
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   247
	DPRINT("DCommSyborgSoc::Caps");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   248
	TCommCaps3 capsBuf;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   249
	TCommCapsV03 &c=capsBuf();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   250
	c.iRate=KCapsBps110|KCapsBps150|KCapsBps300|KCapsBps600|KCapsBps1200|KCapsBps2400|KCapsBps4800|KCapsBps9600|KCapsBps19200|KCapsBps38400|KCapsBps57600|KCapsBps115200|KCapsBps230400;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   251
	c.iDataBits=KCapsData5|KCapsData6|KCapsData7|KCapsData8;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   252
	c.iStopBits=KCapsStop1|KCapsStop2;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   253
	c.iParity=KCapsParityNone|KCapsParityEven|KCapsParityOdd;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   254
	c.iHandshake=KCapsObeyXoffSupported|KCapsSendXoffSupported|KCapsObeyCTSSupported|KCapsFailCTSSupported|KCapsObeyDSRSupported|KCapsFailDSRSupported|KCapsObeyDCDSupported|KCapsFailDCDSupported|KCapsFreeRTSSupported|KCapsFreeDTRSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   255
	c.iSignals=KCapsSignalCTSSupported|KCapsSignalDSRSupported|KCapsSignalDCDSupported|KCapsSignalRTSSupported|KCapsSignalDTRSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   256
	c.iSIR=0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   257
	c.iNotificationCaps=KNotifyDataAvailableSupported|KNotifySignalsChangeSupported;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   258
	c.iFifo=KCapsHasFifo;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   259
	c.iRoleCaps=0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   260
	c.iFlowControlCaps=0;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   261
	c.iBreakSupported=ETrue;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   262
	aCaps.FillZ(aCaps.MaxLength());
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   263
	aCaps=capsBuf.Left(Min(capsBuf.Length(),aCaps.MaxLength()));
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   264
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   265
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   266
TInt DCommSyborgSoc::DisableIrqs()
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   267
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   268
	DPRINT("DCommSyborgSoc::DisableIrqs");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   269
	return NKern::DisableAllInterrupts();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   270
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   271
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   272
void DCommSyborgSoc::RestoreIrqs(TInt aIrq)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   273
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   274
	DPRINT("DCommSyborgSoc::RestoreIrqs");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   275
	NKern::RestoreInterrupts(aIrq);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   276
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   277
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   278
TDfcQue* DCommSyborgSoc::DfcQ(TInt aUnit)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   279
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   280
	return iDriverSyborgComm->DfcQueue();
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   281
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   282
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   283
void DCommSyborgSoc::CheckConfig(TCommConfigV01& aConfig)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   284
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   285
	DPRINT("DCommSyborgSoc::CheckConfig");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   286
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   287
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   288
void DCommSyborgSoc::Isr(TAny* aPtr)
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   289
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   290
	DCommSyborgSoc& d=*(DCommSyborgSoc*)aPtr;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   291
	TUint rx[32];
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   292
	TInt rxi=0;
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   293
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   294
	TInt fifo = ReadReg(d.iPortAddr, SERIAL_FIFO_COUNT );
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   295
	while(fifo > 0 && rxi<32)
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   296
		{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   297
		TUint ch = ReadReg(d.iPortAddr, SERIAL_DATA);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   298
		rx[rxi++]=ch;
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   299
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   300
		fifo = ReadReg(d.iPortAddr, SERIAL_FIFO_COUNT );
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   301
		}
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   302
	d.ReceiveIsr(rx,rxi,0);
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   303
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   304
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   305
DECLARE_STANDARD_PDD()
63
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   306
	{
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   307
	DPRINT("DECLARE_STANDARD_PDD()");
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   308
	return new DDriverSyborgComm;
84dca1410127 Fix for Bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
andrew.jordan <>
parents: 16
diff changeset
   309
	}
0
ffa851df0825 Initial syborg (baseport) and documentation import
martin.trojer@nokia.com
parents:
diff changeset
   310