baseport/syborg/serial/syborg_serial.h
changeset 63 84dca1410127
parent 2 d55eb581a87c
--- a/baseport/syborg/serial/syborg_serial.h	Thu Apr 22 14:59:02 2010 +0100
+++ b/baseport/syborg/serial/syborg_serial.h	Sun May 02 23:03:18 2010 +0100
@@ -10,6 +10,7 @@
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
+* NTT DOCOMO, INC. -- Fix bug 2186 - QEMU baseport serial driver doesn't work with multiple UARTs and is unreliable
 *
 * Description: Minimalistic serial driver
 *
@@ -26,52 +27,75 @@
 const TInt KMinimumLddMinorVersion=1;
 const TInt KMinimumLddBuild=1;
 
+/**
+ * Serial Ports Device Driver
+ *
+ *
+ **/
 class DDriverSyborgComm : public DPhysicalDevice
-{
+	{
 public:
   DDriverSyborgComm();
+  ~DDriverSyborgComm();
   virtual TInt Install();
   virtual void GetCaps(TDes8 &aDes) const;
   virtual TInt Create(DBase*& aChannel, TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
   virtual TInt Validate(TInt aUnit, const TDesC8* anInfo, const TVersion &aVer);
-};
 
-class DCommSyborgSoc : public DComm
-{
-public:
-  DCommSyborgSoc();
-  ~DCommSyborgSoc();
-  TInt DoCreate(TInt aUnit, const TDesC8* anInfo);
+// interface for single comm port.
 public:
-  virtual TInt Start();
-  virtual void Stop(TStopMode aMode);
-  virtual void Break(TBool aState);
-  virtual void EnableTransmit();
-  virtual TUint Signals() const;
-  virtual void SetSignals(TUint aSetMask, TUint aClearMask);
-  virtual TInt ValidateConfig(const TCommConfigV01 &aConfig) const;
-  virtual void Configure(TCommConfigV01 &aConfig);
-  virtual void Caps(TDes8 &aCaps) const;
-  virtual TInt DisableIrqs();
-  virtual void RestoreIrqs(TInt aIrq);
-  virtual TDfcQue* DfcQ(TInt aUnit);
-  virtual void CheckConfig(TCommConfigV01& aConfig);  
-  static void Isr(TAny* aPtr);
+  TInt OpenDfcQueue();
+  void CloseDfcQueue();
+  TDfcQue* DfcQueue();
+
+private:
+	TDynamicDfcQue* 	iDfcQueue;				// single Dfc queue for all comm ports
+	TUint8  			iDfcQRefCount;			// reference count for dfc queue
+	};
+
+
+
+/**
+ * Driver for a single Comm port
+ **/
+class DCommSyborgSoc : public DComm
+	{
+public:
+	DCommSyborgSoc(DDriverSyborgComm* aDriverSyborgComm);
+	~DCommSyborgSoc();
+	TInt DoCreate(TInt aUnit, const TDesC8* anInfo);
+public:
+	virtual TInt Start();
+	virtual void Stop(TStopMode aMode);
+	virtual void Break(TBool aState);
+	virtual void EnableTransmit();
+	virtual TUint Signals() const;
+	virtual void SetSignals(TUint aSetMask, TUint aClearMask);
+	virtual TInt ValidateConfig(const TCommConfigV01 &aConfig) const;
+	virtual void Configure(TCommConfigV01 &aConfig);
+	virtual void Caps(TDes8 &aCaps) const;
+	virtual TInt DisableIrqs();
+	virtual void RestoreIrqs(TInt aIrq);
+	virtual TDfcQue* DfcQ(TInt aUnit);
+	virtual void CheckConfig(TCommConfigV01& aConfig);
+	static void Isr(TAny* aPtr);
 
 public:
-  TLinAddr iPortAddr;
-  TInt iIrq;
+	DDriverSyborgComm* iDriverSyborgComm;
+	TLinAddr iPortAddr;
+	TInt iIrq;
+	TBool iDfcQueueOpened;
 
-  enum {
-    SERIAL_ID           = 0,
-    SERIAL_DATA         = 1,
-    SERIAL_FIFO_COUNT   = 2,
-    SERIAL_INT_ENABLE   = 3,
-    SERIAL_DMA_TX_ADDR  = 4,
-    SERIAL_DMA_TX_COUNT = 5, /* triggers dma */
-    SERIAL_DMA_RX_ADDR  = 6,
-    SERIAL_DMA_RX_COUNT = 7 /* triggers dma */
-  };
-};
+	enum {
+		SERIAL_ID           = 0,
+		SERIAL_DATA         = 1,
+		SERIAL_FIFO_COUNT   = 2,
+		SERIAL_INT_ENABLE   = 3,
+		SERIAL_DMA_TX_ADDR  = 4,
+		SERIAL_DMA_TX_COUNT = 5, /* triggers dma */
+		SERIAL_DMA_RX_ADDR  = 6,
+		SERIAL_DMA_RX_COUNT = 7 /* triggers dma */
+		};
+	};
 
 #endif