# HG changeset patch # User Christophe Porcel # Date 1280334272 -3600 # Node ID f53839ff73b786a6038030fd306cecbdd64392f5 # Parent 28479eeba3fb363561c5811b1248298c176417e7 Broadcom H4 contribution diff -r 28479eeba3fb -r f53839ff73b7 bluetooth/btlogger/generic/group/BLD.INF --- a/bluetooth/btlogger/generic/group/BLD.INF Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btlogger/generic/group/BLD.INF Wed Jul 28 17:24:32 2010 +0100 @@ -21,7 +21,9 @@ PRJ_EXPORTS ../public/logger.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(bluetooth/logger.h) -../public/components.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(bluetooth/logger/components.h) +//../public/components.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(bluetooth/logger/components.h) +../public/components.h /epoc32/include/bluetooth/logger/components.h + btlogger.mmh SYMBIAN_OS_LAYER_PUBLIC_EXPORT_PATH(bluetooth/btlogger.mmh) btlogger.iby /epoc32/rom/include/btlogger.iby diff -r 28479eeba3fb -r f53839ff73b7 bluetooth/btlogger/generic/public/components.h --- a/bluetooth/btlogger/generic/public/components.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetooth/btlogger/generic/public/components.h Wed Jul 28 17:24:32 2010 +0100 @@ -53,7 +53,9 @@ #define LOG_COMPONENT_QDP_SYMBIAN "QdpSymbian" #define LOG_COMPONENT_INITIALISOR_SYMBIAN "InitSymbian" #define LOG_COMPONENT_INITIALISOR_TI "InitTi" +#define LOG_COMPONENT_INITIALISOR_BROADCOM "InitBroadcom" #define LOG_COMPONENT_HCTL_UART_ORIGINAL "HctlUartOriginal" +#define LOG_COMPONENT_HCTL_BCM_H4 "HctlBcmH4" #define LOG_COMPONENT_HCTL_TI "HctlTi" #define LOG_COMPONENT_HCTL_BCSP "HctlBcsp" #define LOG_COMPONENT_HCI_FACADE "HciFacade" diff -r 28479eeba3fb -r f53839ff73b7 bluetoothmgmt/btcommon/bld.inf --- a/bluetoothmgmt/btcommon/bld.inf Tue Feb 02 01:12:20 2010 +0200 +++ b/bluetoothmgmt/btcommon/bld.inf Wed Jul 28 17:24:32 2010 +0100 @@ -41,10 +41,10 @@ #include "../../bluetooth/btstack/bld.inf" // Remote Control -#include "../../../devicesrv/accessoryservices/remotecontrolfw/group/bld.inf" +//#include "../../../devicesrv/accessoryservices/remotecontrolfw/group/bld.inf" // Profiles -#include "../../bluetooth/gavdp/group/bld.inf" +//#include "../../bluetooth/gavdp/group/bld.inf" #include "../../bluetoothcommsprofiles/btpan/group/BLD.INF" @@ -67,7 +67,7 @@ #include "../../bluetooth/btexample/example/group/bld.inf" // Test UI -#include "../../bluetooth/btexample/testui/bld.inf" +//#include "../../bluetooth/btexample/testui/bld.inf" // Subsystem Test Code #include "../../bluetooth/btexample/test/group/bld.inf" diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/corehcis/symbian/group/bld.inf --- a/bthci/hci2implementations/corehcis/symbian/group/bld.inf Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/corehcis/symbian/group/bld.inf Wed Jul 28 17:24:32 2010 +0100 @@ -16,11 +16,15 @@ // PRJ_EXPORTS -corehci_symbian.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian.ini -corehci_symbian.ini /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/corehci_symbian.ini // For WINSCW debugging -corehci_symbian.ini /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/corehci_symbian.ini +//corehci_symbian.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian.ini +//corehci_symbian.ini /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/corehci_symbian.ini // For WINSCW debugging +//corehci_symbian.ini /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/corehci_symbian.ini -corehci_symbian_ti.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian_ti.ini // Preconfigured for TI hardware +//corehci_symbian_ti.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian_ti.ini // Preconfigured for TI hardware + +corehci_symbian_brcm.ini /epoc32/data/z/private/101f7989/bluetooth/corehci_symbian.ini +corehci_symbian_brcm.ini /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/corehci_symbian.ini // For WINSCW debugging +corehci_symbian_brcm.ini /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/corehci_symbian.ini corehci_symbian.iby /epoc32/rom/include/corehci_symbian.iby diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.iby --- a/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.iby Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.iby Wed Jul 28 17:24:32 2010 +0100 @@ -23,8 +23,10 @@ REM CoreHCI using TI onboard Bluetooth configuration data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian_ti.ini Private\101F7989\Bluetooth\corehci_symbian.ini debugport -2 +#elif defined (HCI_BRCM) +data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian_brcm.ini Private\101F7989\Bluetooth\corehci_symbian.ini #else data=ZPRIVATE\101F7989\Bluetooth\corehci_symbian.ini Private\101F7989\Bluetooth\corehci_symbian.ini #endif - -#endif // COREHCI_SYMBIAN_IBY + +#endif // COREHCI_SYMBIAN_IBY \ No newline at end of file diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.ini --- a/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.ini Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian.ini Wed Jul 28 17:24:32 2010 +0100 @@ -1,33 +1,37 @@ -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of the License "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; - -; UIDs for the HCTL and Initialisation plug-ins should be specified below. -; These UIDs to are found in the implementation_uid field of the .rss file corresponding to the plug-in. - -[Plugins] -;UART TI -;hctl_uid= 0x102736ED - -;UART Original -;hctl_uid= 0x102056BC - -;BCSP -hctl_uid= 0x102056BE - -;TI Initialisor -;initialisation_uid= 0x1027407B - -;Symbian Initialisor -initialisation_uid= 0x1027407D +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +; UIDs for the HCTL and Initialisation plug-ins should be specified below. +; These UIDs to are found in the implementation_uid field of the .rss file corresponding to the plug-in. + +[Plugins] +;UART TI +;hctl_uid= 0x102736ED + +;UART Original +;hctl_uid= 0x102056BC + +;BCSP +hctl_uid= 0x102056BE + +;TI Initialisor +;initialisation_uid= 0x1027407B + +;BRCM Intialisor +;initialisation_uid=0xE0000002 + + +;Symbian Initialisor +initialisation_uid= 0x1027407D diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/corehcis/symbian/group/corehci_symbian_brcm.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/corehcis/symbian/group/corehci_symbian_brcm.ini Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,42 @@ +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; + +; UIDs for the HCTL and Initialisation plug-ins should be specified below. +; These UIDs to are found in the implementation_uid field of the .rss file corresponding to the plug-in. + +[Plugins] +;UART TI +;hctl_uid= 0x102736ED + +;UART Original +;hctl_uid= 0x102056BC + +;BRCM H4 +hctl_uid= 0x2003011D + +;BCSP +;hctl_uid= 0x102056BE + +;TI Initialisor +;initialisation_uid= 0x1027407B + +;BRCM Initialisor +initialisation_uid= 0x2003011B + +;Symbian Initialisor +;initialisation_uid= 0x1027407D + + + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/corehcis/symbian/src/hcisession.cpp --- a/bthci/hci2implementations/corehcis/symbian/src/hcisession.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/corehcis/symbian/src/hcisession.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -19,7 +19,6 @@ @file @internalComponent */ - #include "hcisession.h" #include "hciserver.h" #include "corehciutil.h" diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/group/bld.inf --- a/bthci/hci2implementations/group/bld.inf Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/group/bld.inf Wed Jul 28 17:24:32 2010 +0100 @@ -18,8 +18,10 @@ #include "../hctls/bcsp/group/bld.inf" #include "../hctls/ti/group/bld.inf" #include "../hctls/uart_original/group/bld.inf" +#include "../hctls/brcmh4/group/bld.inf" #include "../initialisors/ti/group/bld.inf" +#include "../initialisors/brcm/group/bld.inf" #include "../initialisors/symbian/group/bld.inf" #include "../qdps/symbian/group/bld.inf" diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/group/hci_implementation.iby --- a/bthci/hci2implementations/group/hci_implementation.iby Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/group/hci_implementation.iby Wed Jul 28 17:24:32 2010 +0100 @@ -26,20 +26,25 @@ #define HCI_PLUGIN ECOM_PLUGIN #endif + #include #include #include #ifdef HCI_TI - #include #include - -#else // CSR + Default - +#elif defined HCI_BRCM +#include +#include +#else #include #include - #endif + #endif // HCI_IMPLMENTATION_IBY + + + + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/.cproject --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/.cproject Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/.project Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,20 @@ + + + Broadcom_Hctl_H4 + + + + + + com.nokia.carbide.cdt.builder.carbideCPPBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + com.nokia.carbide.cdt.builder.carbideCPPBuilderNature + com.nokia.carbide.cdt.builder.carbideSBSv2BuilderNature + + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/group/Broadcom_Hctl_H4.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/group/Broadcom_Hctl_H4.iby Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,25 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef BROADCOM_HCTL_H4_IBY +#define BROADCOM_HCTL_H4_IBY + +REM H4 HCTL implementation + +HCI_PLUGIN(broadcom_hctl_h4.dll, broadcom_hctl_h4.rsc) + +//data=ZPRIVATE\101F7989\Bluetooth\Broadcom_Hctl_H4.ini Private\101F7989\Bluetooth\hctl_broadcom.ini + +#endif // BROADCOM_HCTL_H4_IBY diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/group/Broadcom_Hctl_H4.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/group/Broadcom_Hctl_H4.ini Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,26 @@ +; Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; This file contains the port number and initial BAUD rate for +; the UART. +; +; + +[hctl] +port= 0 +baud_rate= 115200 +functional_baud_rate= 115200 + +[patch_ram] +path= z:\private\101f7989\Bluetooth\ +file= BCM2046B1.hcd \ No newline at end of file diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/group/Broadcom_Hctl_H4.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/group/Broadcom_Hctl_H4.mmp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,59 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Broadcom_Hctl_H4.dll Interface from Symbian OS device to Bluetooth host controller using the original uart ("h4") transport +// Broadcom_Hctl_H4.rsc Resource file for Broadcom_Hctl_H4 transport. +// +// + +/** + @file + @internalComponent +*/ + +TARGET broadcom_hctl_h4.dll +TARGETTYPE PLUGIN +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +UID 0x10009d8d 0x2003011C +VENDORID 0x70000001 +CAPABILITY CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData + +SOURCEPATH ../src + +RESOURCE Broadcom_Hctl_H4.rss + +NOEXPORTLIBRARY /* Ensures that DEF file can be safely shared + for RVCT builds */ + +SOURCE Broadcom_Hctl_H4_main.cpp +SOURCE Broadcom_Hctl_H4.cpp +SOURCE Broadcom_Hctl_H4_sender.cpp +SOURCE Broadcom_Hctl_H4_receiver.cpp +SOURCE controllermanager.cpp + +USERINCLUDE ../inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY esock.lib +LIBRARY euser.lib +LIBRARY hctl_base.lib +LIBRARY btlogger.lib + +MACRO ENABLE_HCI_FRAME_LOGGING // Enable the HCI logging + +OPTION cw -strict on -w pedantic,unused,hidevirtual,padding,ptrintconv + +UNPAGED + +SMPSAFE diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/group/bld.inf Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,27 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS +../inc/hctlbcmconfiginterface.h /epoc32/include/bluetooth/hci/hctlbcmconfiginterface.h + +Broadcom_Hctl_H4.ini /epoc32/data/z/private/101f7989/bluetooth/hctl_broadcom.ini + +Broadcom_Hctl_H4.ini /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/hctl_broadcom.ini // For WINSCW UDEB builds +Broadcom_Hctl_H4.ini /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/hctl_broadcom.ini // For WINSCW UREL builds + +Broadcom_Hctl_H4.iby /epoc32/rom/include/Broadcom_Hctl_H4.iby + +PRJ_MMPFILES +Broadcom_Hctl_H4.mmp diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,135 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#ifndef BROADCOMHCTLH4_H +#define BROADCOMHCTLH4_H + +#include +#include +#include + +#include + + +class CHCTLBcmH4Receiver; +class CHCTLBcmH4Sender; +class CControllerManager; + +// Define HCTL Packet Header Size +static const TInt KHctlHeaderSize = 1; +static const TInt KHctlPacketTypeOffset = 0; + +// UART HCI Framing constants for command frames +static const TInt KHCTLCommandHeaderSize = 1; +static const TInt KHCTLCommandTrailerSize = 0; + +// UART HCI Framing constants for ACL data frames +static const TInt KHCTLAclDataHeaderSize = 1; +static const TInt KHCTLAclDataTrailerSize = 0; + +// UART HCI Framing constants for Synchronous data frames +static const TInt KHCTLSynchronousDataHeaderSize = 1; +static const TInt KHCTLSynchronousDataTrailerSize = 0; + +_LIT(KIniFileName, "hctl_broadcom"); + +/** +This is the class that implements the UART specific HCTL. +*/ +NONSHARABLE_CLASS(CHCTLBcmH4) : public CHCTLUartBase, + public MHctlBcmConfigInterface + { +public: + static CHCTLBcmH4* NewL(); + ~CHCTLBcmH4(); + + void DoConfigL(); + virtual void ProcessACLData(const TDesC8& aData); + virtual void ProcessSynchronousData(const TDesC8& aData); + virtual void ProcessEvent(const TDesC8& aEvent); + + MQdpPluginInterfaceFinder* QdpPluginInterfaceFinder(); + + // From MHardResetInitiator + virtual void MhriStartHardReset(); + + // Called from the Controller Manager + void HandlePowerOff(); + void HandlePowerOn(); + + TBTPowerState CurrentPowerState() const; + //CHRIS MODIF + //void SetInitFlag(TBool flag); + +public: + // HCTL packet types as defined in Section 2, Part H: 4 of the + // bluetooth specification. + enum THctlPacketType + { + ECommandPacket = 0x01, + EACLDataPacket = 0x02, + ESynchronousDataPacket = 0x03, + EEventPacket = 0x04, + }; + +private: + CHCTLBcmH4(); + void ConstructL(); + TAny* Interface(TUid aUid); + + static void SetPacketIndicator(THctlPacketType aType, const TDesC8& aData); + + // From CHCTLUartBase + virtual void PortOpenedL(); + + // From MHCTLInterface + virtual TInt MhiWriteCommand(const TDesC8& aData); + virtual TInt MhiWriteAclData(const TDesC8& aData); + virtual TInt MhiWriteSynchronousData(const TDesC8& aData); + virtual void MhiGetAclDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const; + virtual void MhiGetSynchronousDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const; + virtual void MhiGetCommandTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const; + virtual void MhiSetChannelObserver(MHCTLChannelObserver& aChannelObserver); + virtual void MhiSetDataObserver(MHCTLDataObserver& aDataObserver); + virtual void MhiSetEventObserver(MHCTLEventObserver& aEventObserver); + virtual void MhiSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver); + virtual void MhiSetQdpPluginInterfaceFinder(MQdpPluginInterfaceFinder& aQdpPluginInterfaceFinder); + + // From MHCTLBcmConfigInterface + virtual TInt MhciUpdateBaudRate(TUint32 aBaudRate); + + virtual void MhciSetInitPluginState(TInitState InitState); +private: + CHCTLBcmH4Receiver* iReceiver; + CHCTLBcmH4Sender* iSender; + MQdpPluginInterfaceFinder* iQdpPluginInterfaceFinder; + TBTPowerState iCurrentPowerState; + + CControllerManager* iControllerMan; + //CHRIS MODIF + //TBool iInitFlag; +public: + TInitState iInitpluginState; + DECLARE_HCI_LOGGER + }; + + +#endif // BROADCOMHCTLH4_H + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4_receiver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4_receiver.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,88 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#ifndef BROADCOMHCTLH4RECEIVER_H +#define BROADCOMHCTLH4RECEIVER_H + +#include +#include +#include + + +class CHCTLBcmH4; +class RBusDevComm; + +/** + This is the class that implements the UART specifics of the Receiver AO and framer. + + This class is not intented for derivation. +*/ +NONSHARABLE_CLASS(CHCTLBcmH4Receiver) : public CActive + { +public: + static CHCTLBcmH4Receiver* NewL(CHCTLBcmH4& aHCTLBcmH4, RBusDevComm& aPort); + ~CHCTLBcmH4Receiver(); + + // Called to initiate the initial read on the port. + void Start(); + +private: + CHCTLBcmH4Receiver(CHCTLBcmH4& aHCTLBcmH4, RBusDevComm& aPort); + void ConstructL(); + + // Helper methods + void QueueReadForNextFrame(TUint16 aOffset, TUint16 aBytesRequired); + void ProcessData(); + + // From CActive + virtual void RunL(); + virtual void DoCancel(); + +private: + enum THctlReceiverState + { + EWaitingForHctlHeaderByte, + EWaitingForHciHeader, + EWaitingForHciPayload, + EInvalidDataReceived, + }; + + // Set the receive buffer equal to the 3-DH5 packet size. + // This value should be changed by licensees if the controller + // is exceeding this packet size. + + // 3-DH5. Payload = 1021 octets. + // Buffer length = payload + HCTL overhead + static const TUint16 KHCTLRecvBufSize = 1022; + + CHCTLBcmH4& iHCTLBcmH4; + THctlReceiverState iState; + + TUint8 iCurrentHCIPacketType; + + RBuf8 iReceiveBuffer; + TPtr8 iReceiveBufPtr; + + RBusDevComm& iPort; + DECLARE_HCI_LOGGER + }; + +#endif // BROADCOMHCTLH4RECEIVER_H + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4_sender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4_sender.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,51 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#ifndef BROADCOMHCTLH4SENDER_H +#define BROADCOMHCTLH4SENDER_H + +#include + +class RBusDevComm; +class MHCTLChannelObserver; + +NONSHARABLE_CLASS(CHCTLBcmH4Sender) : public CActive + { +public: + static CHCTLBcmH4Sender* NewL(RBusDevComm& aPort); + ~CHCTLBcmH4Sender(); + + TInt Write(const TDesC8& aData); + void SetChannelObserver(MHCTLChannelObserver& aObserver); + +private: + // From CActive + virtual void RunL(); + virtual void DoCancel(); + + CHCTLBcmH4Sender(RBusDevComm& aPort); + +private: + MHCTLChannelObserver* iChannelObserver; + RBusDevComm& iPort; + }; + +#endif // BROADCOMHCTLH4 + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4_utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/inc/Broadcom_Hctl_H4_utils.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,51 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + + +#ifndef BROADCOMHCTLH4UTILS_H +#define BROADCOMHCTLH4UTILS_H + +#include + +/** +The panic category for the UART ORIGINAL HCTL. +*/ +_LIT(KBcmHctlH4Panic, "Broadcom H4 Panic"); + +/** +Panic codes for UART_ORIGINAL HCTL. +*/ +enum TBcmH4Panic + { + EHctlReceiverBufferOverflow = 0, + EIllegalState = 1, + EPortNotOpen = 2, + EUnexpectedCtrlMgrPowerState = 3, + EUnexpectedReset = 4, + EPortReadAttemptWhenReadOutstanding = 5, + EAttemptToReadZeroBytes = 6, + EReadCompletedWithInsufficientBytes = 7, + EStateObserverNotAvailable = 8, + EStartCalledWhenReadOutstanding = 9, + ENoControllerManager = 10, + }; + +#endif // BROADCOMHCTLH4UTILS_H + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/inc/HCTLBcmConfigInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/inc/HCTLBcmConfigInterface.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,49 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalTechnology +*/ + +#ifndef HCTLBCMCONFIGINTERFACE_H +#define HCTLBCMCONFIGINTERFACE_H + +#include + +/** +The UID of the HCTL configuration interface. +*/ +const TInt KHctlBcmConfigInterfaceUid = 0xE0000030; + +/** +Mixin for the HCTL configuration interface. +*/ + +class MHctlBcmConfigInterface + { +public: + /** + Update the BAUD rate. + + @param aBaudRate New value for BAUD rate + @return Standard error value. + */ + virtual TInt MhciUpdateBaudRate(TUint32 aBaudRate) = 0; + + virtual void MhciSetInitPluginState(TInitState InitState) = 0; + }; + +#endif // HCTLBCMCONFIGINTERFACE_H diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/inc/controllermanager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/inc/controllermanager.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,56 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#ifndef CONTROLLERMANAGER_H +#define CONTROLLERMANAGER_H + +#include +#include + +class MControllerStateObserver; +class CHCTLBcmH4; + +/** +This is the class that implements a controller manager. +This is a class which provides a framework for managing the +power management and reset of the host controller. +*/ + +NONSHARABLE_CLASS(CControllerManager) : public CBase, public MHCTLPowerInterface + { +public: + static CControllerManager* NewL(CHCTLBcmH4& aHctl); + + void SetControllerStateObserver(MControllerStateObserver& aControllerStateObserver); + void HardReset(); + +private: + // From MHCTLPowerInterface + virtual TInt MhpiGetPower(TBTPowerState& aState); + virtual TInt MhpiSetPower(const TBTPowerState aState); + + CControllerManager(CHCTLBcmH4& aHctl); + +private: + MControllerStateObserver* iControllerStateObserver; + CHCTLBcmH4& iHctl; + }; + +#endif // CONTROLLERMANAGER_H diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,360 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include "Broadcom_Hctl_H4.h" + +#include "Broadcom_Hctl_H4_sender.h" +#include "Broadcom_Hctl_H4_receiver.h" +#include "controllermanager.h" + +#include "Broadcom_Hctl_H4_utils.h" + +#include +#include +#include +#include + + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_HCTL_BCM_H4); +#endif + +CHCTLBcmH4::CHCTLBcmH4() + { + LOG_FUNC + } + +CHCTLBcmH4::~CHCTLBcmH4() + { + LOG_FUNC + HCI_LOG_UNLOAD(this); + delete iReceiver; + delete iSender; + delete iControllerMan; + } + +CHCTLBcmH4* CHCTLBcmH4::NewL() + { + LOG_STATIC_FUNC + + CHCTLBcmH4* self = new(ELeave) CHCTLBcmH4(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CHCTLBcmH4::ConstructL() + { + LOG_FUNC + HCI_LOG_LOADL(this, KHCILoggerDatalinkTypeH4); + + // Initialises iSender and iReceiver via the PortOpenedL method. + BaseConstructL(KIniFileName()); + + + iControllerMan = CControllerManager::NewL(*this); + } + +TAny* CHCTLBcmH4::Interface(TUid aUid) + { + LOG_FUNC + + TAny* ret = NULL; + switch(aUid.iUid) + { + case KHCTLInterfaceUid: + ret = reinterpret_cast(static_cast(this)); + break; + + case KHCTLPowerInterfaceUid: + ret = reinterpret_cast(static_cast(iControllerMan)); + break; + + case KHCHardResetUid: + ret = reinterpret_cast(static_cast(this)); + break; + + case KHctlBcmConfigInterfaceUid: + ret = reinterpret_cast(static_cast(this)); + break; + + default: + break; + } + + return ret; + } + +void CHCTLBcmH4::DoConfigL() + { + LOG_FUNC + + Port().ResetBuffers(); + TCommConfig conf; + Port().Config(conf); + + // Get reference to TCommConfig config + TCommConfigV01& config = conf(); + + // Set Config to 8bit char, 1 stop bit and no parity + config.iDataBits = EData8; + config.iStopBits = EStop1; + config.iParity = EParityNone; + config.iParityError = KConfigParityErrorIgnore; + config.iHandshake = KConfigObeyCTS; + + LEAVEIFERRORL(Port().SetConfig(conf)); + + // allows HC to talk back to us! + Port().SetSignals(KSignalRTS, KSignalDTEInputs); + } + +//Implementation of pure virtuals from MHCTLInterface +TInt CHCTLBcmH4::MhiWriteAclData(const TDesC8& aData) + { + LOG_FUNC + + TInt rerr = KErrNotReady; + // Send if the power is on. + if(iCurrentPowerState == EBTOn) + { + // Add the packet indicator to the first byte of the buffer. + SetPacketIndicator(EACLDataPacket, aData); + rerr = iSender->Write(aData); + HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerACLDataFrame, aData); + } + + return rerr; + } + +TInt CHCTLBcmH4::MhiWriteSynchronousData(const TDesC8& aData) + { + LOG_FUNC + + TInt rerr = KErrNotReady; + // Send if the power is on. + if(iCurrentPowerState == EBTOn) + { + // Add the packet indicator to the first byte of the buffer. + SetPacketIndicator(ESynchronousDataPacket, aData); + rerr = iSender->Write(aData); + HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerSynchronousDataFrame, aData); + } + + return rerr; + } + +TInt CHCTLBcmH4::MhiWriteCommand(const TDesC8& aData) + { + LOG_FUNC + + TInt rerr = KErrNotReady; + // Send if the power is on. + if(iCurrentPowerState == EBTOn) + { + // Add the packet indicator to the first byte of the buffer. + SetPacketIndicator(ECommandPacket, aData); + rerr = iSender->Write(aData); + HCI_LOG_FRAME_IF_NO_ERROR(rerr, this, KHCILoggerHostToController | KHCILoggerCommandOrEvent, aData); + } + + return rerr; + } + +void CHCTLBcmH4::MhiSetQdpPluginInterfaceFinder(MQdpPluginInterfaceFinder& aQdpPluginInterfaceFinder) + { + iQdpPluginInterfaceFinder = &aQdpPluginInterfaceFinder; + } + +void CHCTLBcmH4::MhriStartHardReset() + { + __ASSERT_DEBUG(iControllerMan, PANIC(KBcmHctlH4Panic, ENoControllerManager)); + iControllerMan->HardReset(); + } + +void CHCTLBcmH4::MhiGetAclDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const + { + // Return the transport overhead for ACL data. + aHeaderSize = KHCTLAclDataHeaderSize; + aTrailerSize = KHCTLAclDataTrailerSize; + } + + +void CHCTLBcmH4::MhiGetSynchronousDataTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const + { + // Return the transport overhead for Synchronous data. + aHeaderSize = KHCTLSynchronousDataHeaderSize; + aTrailerSize = KHCTLSynchronousDataTrailerSize; + } + +void CHCTLBcmH4::MhiGetCommandTransportOverhead(TUint& aHeaderSize, TUint& aTrailerSize) const + { + // Return the transport overhead for HCI commands data. + aHeaderSize = KHCTLCommandHeaderSize; + aTrailerSize = KHCTLCommandTrailerSize; + } + +TInt CHCTLBcmH4::MhciUpdateBaudRate(TUint32 aBaudRate) + { + // Call the base class method to process this change. + TRAPD(rerr, SetPortBaudRateL(aBaudRate)); + return rerr; + } + +void CHCTLBcmH4::MhciSetInitPluginState(TInitState InitState) + { + iInitpluginState = InitState; + } + +/** +This function is used by the receiver for informing HCI that ACL data has been received +The receiver doesn't have reference to iDataObserver. So this is merely a wrapper for iDataObserver +*/ +void CHCTLBcmH4::ProcessACLData(const TDesC8& aData) + { + iDataObserver->MhdoProcessAclData(aData); + } + +/** +This function is used by the receiver for informing HCI that Synchronous data has been received +The receiver doesn't have reference to iDataObserver. So this is merely a wrapper for iDataObserver +*/ +void CHCTLBcmH4::ProcessSynchronousData(const TDesC8& aData) + { + iDataObserver->MhdoProcessSynchronousData(aData); + } + +/** +This function is used by the receiver for informing HCI that event has been received +The receiver doesn't have reference to iEventObserver. So this is merely a wrapper for iDataObserver +*/ +void CHCTLBcmH4::ProcessEvent(const TDesC8& aEvent) + { + iEventObserver->MheoProcessEvent(aEvent); + } + +/** +QdpPluginInterfaceFinder getter. + +@return returns iQdpPluginInterfaceFinder which could be NULL +if it has not been given one. +*/ +MQdpPluginInterfaceFinder* CHCTLBcmH4::QdpPluginInterfaceFinder() + { + return iQdpPluginInterfaceFinder; + } + +/** +Sets the packet type indicator at the begining of the HCI packet. + +Hence the HC can recognise whether this packet is a command, ACL/SCO data. +The packet preamble/indication is different between different HCTL +implementations and are totally dependent upon the meduim used (UART, R2232 etc). +*/ +/*static*/ void CHCTLBcmH4::SetPacketIndicator(THctlPacketType aType, const TDesC8& aData) + { + LOG_STATIC_FUNC + + TUint8* ptr = const_cast(aData.Ptr()); + *ptr = static_cast(aType); + } + +// Implementation of pure virtual from CHCTLUartBase +void CHCTLBcmH4::PortOpenedL() + { + LOG_FUNC + + __ASSERT_DEBUG(Port().Handle(), PANIC(KBcmHctlH4Panic, EPortNotOpen)); + + if (iSender || iReceiver) + { + LEAVEIFERRORL(KErrAlreadyExists); + } + + DoConfigL(); + iCurrentPowerState = EBTOn; + // The sender Active Object must be added to the Active Scheduler before + // the receiver Active Object so that it gets preferential treatment. It + // is reported that otherwise the response from a command can come in + // before the sending client is told that the send has completed! + iSender = CHCTLBcmH4Sender::NewL(Port()); + iReceiver = CHCTLBcmH4Receiver::NewL(*this, Port()); + + // Start reading from the UART + iReceiver->Start(); + } + + +void CHCTLBcmH4::MhiSetDataObserver(MHCTLDataObserver& aDataObserver) + { + iDataObserver = &aDataObserver; + } + +void CHCTLBcmH4::MhiSetEventObserver(MHCTLEventObserver& aEventObserver) + { + iEventObserver = &aEventObserver; + } + +void CHCTLBcmH4::MhiSetChannelObserver(MHCTLChannelObserver& aChannelObserver) + { + iChannelObserver = &aChannelObserver; + iSender->SetChannelObserver(aChannelObserver); + } + +void CHCTLBcmH4::MhiSetControllerStateObserver(MControllerStateObserver& aControllerStateObserver) + { + iControllerStateObserver = &aControllerStateObserver; + iControllerMan->SetControllerStateObserver(aControllerStateObserver); + } + +void CHCTLBcmH4::HandlePowerOff() + { + iCurrentPowerState = EBTOff; + // Close all channels and cancel the sender and receiver. + iSender->Cancel(); + iReceiver->Cancel(); + + iChannelObserver->MhcoChannelClosed(KHCITransportAllChannels); + } + +void CHCTLBcmH4::HandlePowerOn() + { + iCurrentPowerState = EBTOn; + iChannelObserver->MhcoChannelOpen(KHCITransportAllChannels); + + // Clear any spurious data from the buffer. + Port().ResetBuffers(); + + iReceiver->Start(); + // The sender will be activated when the first frame needs to be sent. + } + +TBTPowerState CHCTLBcmH4::CurrentPowerState() const + { + return iCurrentPowerState; + } + +//CHRIS MODIF +//void CHCTLBcmH4::SetInitFlag(TBool flag) + //{ + //iInitFlag = flag; + //} + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4.rss Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,48 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x2003011C; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KHCTLBaseEcomInterfaceUid; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2003011D; + version_no = 1; + display_name = "BROADCOM H4"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4_main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4_main.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,35 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include +#include "Broadcom_Hctl_H4.h" + +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x2003011D, CHCTLBcmH4::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; + } + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4_receiver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4_receiver.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,344 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include "Broadcom_Hctl_H4_receiver.h" + +#include "Broadcom_Hctl_H4.h" +#include "Broadcom_Hctl_H4_utils.h" + +#include +#include // For GetLittleEndian methods +#include + +// These files are included to get HCI specification defined constants. +#include +#include + + + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_HCTL_BCM_H4); +#endif + + +CHCTLBcmH4Receiver::CHCTLBcmH4Receiver(CHCTLBcmH4& aHCTLBcmH4,RBusDevComm& aPort) + : CActive(EPriorityStandard), + iHCTLBcmH4(aHCTLBcmH4), + iState(EWaitingForHctlHeaderByte), + iReceiveBufPtr(NULL,0), + iPort(aPort) + { + LOG_FUNC + CActiveScheduler::Add(this); + } + +CHCTLBcmH4Receiver::~CHCTLBcmH4Receiver() + { + LOG_FUNC + + Cancel(); + iReceiveBuffer.Close(); + + HCI_LOG_UNLOAD(this); + } + +CHCTLBcmH4Receiver* CHCTLBcmH4Receiver::NewL(CHCTLBcmH4& aHCTLBcmH4, RBusDevComm& aPort) + { + LOG_STATIC_FUNC + + CHCTLBcmH4Receiver* self=new(ELeave)CHCTLBcmH4Receiver(aHCTLBcmH4, aPort); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +void CHCTLBcmH4Receiver::ConstructL() + { + LOG_FUNC + + HCI_LOG_LOADL(this, KHCILoggerDatalinkTypeH4); + + // Create the receive buffer + HBufC8* buf = HBufC8::NewMaxL(KHCTLRecvBufSize); + + // HBufC8 is not modifiable. Create a RBuf8 object that + // allows the data to be modified. + iReceiveBuffer.Assign(buf); + } + +void CHCTLBcmH4Receiver::QueueReadForNextFrame(TUint16 aOffset, TUint16 aBytesRequired) + { + LOG_FUNC + + __ASSERT_DEBUG(!IsActive(), PANIC(KBcmHctlH4Panic, EPortReadAttemptWhenReadOutstanding)); + __ASSERT_DEBUG(aBytesRequired != 0, PANIC(KBcmHctlH4Panic, EAttemptToReadZeroBytes)); + __ASSERT_DEBUG(aOffset + aBytesRequired <= iReceiveBuffer.MaxLength(), PANIC(KBcmHctlH4Panic, EHctlReceiverBufferOverflow)); + + SetActive(); + + // Read the required number of bytes into the buffer starting at the specified offset. + iReceiveBufPtr.Set(iReceiveBuffer.MidTPtr(aOffset, aBytesRequired)); + iPort.Read(iStatus, iReceiveBufPtr, aBytesRequired); + } + +void CHCTLBcmH4Receiver::ProcessData() + { + LOG_FUNC + + TUint16 bytesRequiredForNextRead = 0; + TUint16 currentReadOffset = 0; + + switch (iState) + { + case EWaitingForHctlHeaderByte: + { + // reads the first byte of the Packet, to decide the + // type of Packet and set the next state + __ASSERT_ALWAYS(iReceiveBufPtr.Length() == KHctlHeaderSize, + PANIC(KBcmHctlH4Panic, EReadCompletedWithInsufficientBytes)); + + // Store the HCI packet. + iCurrentHCIPacketType = iReceiveBufPtr[KHctlPacketTypeOffset]; + iState = EWaitingForHciHeader; + + // Request the appropriate number of header bytes. The HCI packet + // type will be overwritten when the HCI header bytes are read. + switch(iCurrentHCIPacketType) + { + case CHCTLBcmH4::EACLDataPacket: + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerACLDataFrame | KHCILoggerFrameFragmented, + iReceiveBufPtr.Left(KHctlHeaderSize)); + + bytesRequiredForNextRead = CHctlAclDataFrame::KHCIACLDataPacketHeaderLength; + } + break; + + case CHCTLBcmH4::ESynchronousDataPacket: + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerSynchronousDataFrame | KHCILoggerFrameFragmented, + iReceiveBufPtr.Left(KHctlHeaderSize)); + + bytesRequiredForNextRead = CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength; + } + break; + + case CHCTLBcmH4::EEventPacket: + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerCommandOrEvent | KHCILoggerFrameFragmented, + iReceiveBufPtr.Left(KHctlHeaderSize)); + + bytesRequiredForNextRead = THCIEventBase::KEventCommonFieldsLength; + } + break; + + default: + /////////////////////////////////////// + //CHRIS MODIF + if((iHCTLBcmH4.iInitpluginState == EMiniDrvToHcdConfigFileDelay) || (iHCTLBcmH4.iInitpluginState == EMiniDrvToBinConfigFileDelay)) + { + if((iCurrentHCIPacketType == 0x34) || (iCurrentHCIPacketType == 0x31) ) + { + bytesRequiredForNextRead = 1; + iState = EWaitingForHctlHeaderByte; + break; + } + } + else + { + ///////////////////////////////////////// + // unexpected/unsupported data Received + iState = EInvalidDataReceived; + } + break; + }; + } + break; + + case EWaitingForHciHeader: + { + iState = EWaitingForHciPayload; + + // Read the packet length. + switch(iCurrentHCIPacketType) + { + case CHCTLBcmH4::EACLDataPacket: + { + __ASSERT_ALWAYS(iReceiveBufPtr.Length() == CHctlAclDataFrame::KHCIACLDataPacketHeaderLength, + PANIC(KBcmHctlH4Panic, EReadCompletedWithInsufficientBytes)); + + bytesRequiredForNextRead = LittleEndian::Get16(iReceiveBufPtr.Ptr() + CHctlDataFrameBase::KHCIDataPacketLengthFieldOffset); + + // Check that the size of the ACL data does not exceed the internal buffer. + if(bytesRequiredForNextRead > (KHCTLRecvBufSize - CHctlAclDataFrame::KHCIACLDataPacketHeaderLength)) + { + // This is unexpected from the controller. Try restarting it. + iState = EInvalidDataReceived; + } + else + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerACLDataFrame | KHCILoggerFrameFragmented, + iReceiveBufPtr.Left(CHctlAclDataFrame::KHCIACLDataPacketHeaderLength)); + currentReadOffset = CHctlAclDataFrame::KHCIACLDataPacketHeaderLength; + } + } + break; + + case CHCTLBcmH4::ESynchronousDataPacket: + { + __ASSERT_ALWAYS(iReceiveBufPtr.Length() == CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength, + PANIC(KBcmHctlH4Panic, EReadCompletedWithInsufficientBytes)); + + bytesRequiredForNextRead = iReceiveBufPtr[CHctlDataFrameBase::KHCIDataPacketLengthFieldOffset]; + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerSynchronousDataFrame | KHCILoggerFrameFragmented, + iReceiveBufPtr.Left(CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength)); + currentReadOffset = CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength; + } + break; + + case CHCTLBcmH4::EEventPacket: + { + __ASSERT_ALWAYS(iReceiveBufPtr.Length() == THCIEventBase::KEventCommonFieldsLength, + PANIC(KBcmHctlH4Panic, EReadCompletedWithInsufficientBytes)); + + bytesRequiredForNextRead = iReceiveBufPtr[THCIEventBase::KTotalParameterLengthOffset]; + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerCommandOrEvent | KHCILoggerFrameFragmented, + iReceiveBufPtr.Left(THCIEventBase::KEventCommonFieldsLength)); + currentReadOffset = THCIEventBase::KEventCommonFieldsLength; + } + break; + + default: + { + // Invalid state. + PANIC(KBcmHctlH4Panic, EIllegalState); + break; + } + }; + } + break; + + case EWaitingForHciPayload: + { + TUint16 payloadLength = iReceiveBufPtr.Length(); + switch(iCurrentHCIPacketType) + { + case CHCTLBcmH4::EACLDataPacket: + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerACLDataFrame, + iReceiveBufPtr); + iHCTLBcmH4.ProcessACLData(iReceiveBuffer.Left(payloadLength + CHctlAclDataFrame::KHCIACLDataPacketHeaderLength)); + } + break; + + case CHCTLBcmH4::ESynchronousDataPacket: + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerSynchronousDataFrame, + iReceiveBufPtr); + iHCTLBcmH4.ProcessSynchronousData(iReceiveBuffer.Left(payloadLength + CHctlSynchronousDataFrame::KHCISynchronousDataPacketHeaderLength)); + } + break; + + case CHCTLBcmH4::EEventPacket: + { + HCI_LOG_FRAME(this, + KHCILoggerControllerToHost | KHCILoggerCommandOrEvent, + iReceiveBufPtr); + iHCTLBcmH4.ProcessEvent(iReceiveBuffer.Left(payloadLength + THCIEventBase::KEventCommonFieldsLength)); + } + break; + + default: + // Invalid state + PANIC(KBcmHctlH4Panic, EIllegalState); + }; + + // Starting a new Packet. Bytes Required now is 1, offset is 0 + // We finished with this packet so we're back in 'wait for next mode' + currentReadOffset = 0; + bytesRequiredForNextRead = KHctlHeaderSize; + iState = EWaitingForHctlHeaderByte; + } + break; + + default: + // must never get here + PANIC(KBcmHctlH4Panic, EIllegalState); + break; + } + + if(iState == EInvalidDataReceived) + { + // The HCTL can not recover from this. Reset the controller and restart the host. + iHCTLBcmH4.MhriStartHardReset(); + } + else + { + // Request the next read on the port. + QueueReadForNextFrame(currentReadOffset, bytesRequiredForNextRead); + } + } + + +void CHCTLBcmH4Receiver::RunL() + { + LOG_FUNC + LOG1(_L8("\tiStatus = %d"), iStatus.Int()); + + // Only process the read if it has completed successfully. + if (iStatus.Int() == KErrNone) + { + ProcessData(); + } + else + { + // The HCTL can not recover from this. Reset the controller and restart the host. + iHCTLBcmH4.MhriStartHardReset(); + } + } + +void CHCTLBcmH4Receiver::DoCancel() + { + LOG_FUNC + + // Cancel the outstanding read request. + iPort.ReadCancel(); + } + +void CHCTLBcmH4Receiver::Start() + { + LOG_FUNC + __ASSERT_DEBUG(!IsActive(), PANIC(KBcmHctlH4Panic, EStartCalledWhenReadOutstanding)); + + // Reset this object state and make an initial read on the UART. + iState = EWaitingForHctlHeaderByte; + + // Read first byte on next frame (HCI packet type) into offset zero of the buffer. + QueueReadForNextFrame(0, KHctlHeaderSize); + } diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4_sender.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/src/Broadcom_Hctl_H4_sender.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,106 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include "Broadcom_Hctl_H4_sender.h" + +#include +#include +#include + + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_HCTL_BCM_H4); +#endif + +CHCTLBcmH4Sender::CHCTLBcmH4Sender(RBusDevComm& aPort) + : CActive(EPriorityStandard), + iPort(aPort) + { + LOG_FUNC + CActiveScheduler::Add(this); + } + + +CHCTLBcmH4Sender::~CHCTLBcmH4Sender() + { + LOG_FUNC + + Cancel(); + } + +CHCTLBcmH4Sender* CHCTLBcmH4Sender::NewL(RBusDevComm& aPort) + { + LOG_STATIC_FUNC + + CHCTLBcmH4Sender* self = new(ELeave)CHCTLBcmH4Sender(aPort); + return self; + } + +TInt CHCTLBcmH4Sender::Write(const TDesC8& aData) + { + LOG_FUNC + TInt rerr = KErrNone; + //Check whether we finished with the previous write + if(!IsActive()) + { + // The UART can't write anymore data until this write is complete. + // Close all channels. + iChannelObserver->MhcoChannelClosed(KHCITransportAllChannels); + + SetActive(); + iPort.Write(iStatus, aData); + } + else + { + LOG(_L8("ERROR: Sender is already active!!\r\n")); + rerr = KErrInUse; + } + + return rerr; + } + +void CHCTLBcmH4Sender::SetChannelObserver(MHCTLChannelObserver& aObserver) + { + LOG_FUNC + + iChannelObserver = &aObserver; + + if(!IsActive()) + { + // Asyncronously give the channel observer an initial kick + SetActive(); + TRequestStatus* status = &iStatus; + User::RequestComplete(status, KErrNone); + } + } + +void CHCTLBcmH4Sender::RunL() + { + LOG_FUNC + LOG1(_L8("\tiStatus = %d"), iStatus.Int()); + iChannelObserver->MhcoChannelOpen(KHCITransportAllChannels); + } + +void CHCTLBcmH4Sender::DoCancel() + { + LOG_FUNC + + iPort.WriteCancel(); + } diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/brcmh4/src/controllermanager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/brcmh4/src/controllermanager.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,122 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include "controllermanager.h" + +#include "broadcom_hctl_h4.h" +#include "broadcom_hctl_h4_utils.h" + +#include +#include +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_HCTL_BCM_H4); +#endif + + +CControllerManager* CControllerManager::NewL(CHCTLBcmH4& aHctl) + { + LOG_STATIC_FUNC + + CControllerManager* self = new(ELeave) CControllerManager(aHctl); + return self; + } + +CControllerManager::CControllerManager(CHCTLBcmH4& aHctl) + : iHctl(aHctl) + { + LOG_FUNC + } + +TInt CControllerManager::MhpiGetPower(TBTPowerState& aState) + { + LOG_FUNC + + // Return current state. + aState = iHctl.CurrentPowerState(); + return KErrNone; + } + +TInt CControllerManager::MhpiSetPower(TBTPowerState aState) + { + LOG_FUNC + + TInt rerr = KErrAlreadyExists; + // Check that the requested state differs from the current state. + if(aState != iHctl.CurrentPowerState()) + { + __ASSERT_ALWAYS(aState == EBTOff || aState == EBTOn, + PANIC(KBcmHctlH4Panic, EUnexpectedCtrlMgrPowerState)); + __ASSERT_ALWAYS(iControllerStateObserver, + PANIC(KBcmHctlH4Panic, EStateObserverNotAvailable)); + + iControllerStateObserver->McsoProcessPowerChange(KErrNone, + MControllerStateObserver::EBTFatalChange, + aState); + + if(aState == EBTOff) + { + // Cancel any reads / writes. + iHctl.HandlePowerOff(); + } + else + { + // Re-start the sender and receiver. + iHctl.HandlePowerOn(); + } + + rerr = KErrNone; + } + + return rerr; + } + + +void CControllerManager::HardReset() + { + LOG_FUNC + + // Check if the power is currently switched off. This takes priority over + // hard reset. + if(iHctl.CurrentPowerState() == EBTOn) + { + __ASSERT_ALWAYS(iControllerStateObserver, + PANIC(KBcmHctlH4Panic, EStateObserverNotAvailable)); + + // Switch the power off then on to perform the reset. + iControllerStateObserver->McsoProcessHardResetPhaseChange(KErrNone, MControllerStateObserver::EBTFatalChange, EBTResetStarted); + // Cancel any reads / writes. + iHctl.HandlePowerOff(); + + iHctl.HandlePowerOn(); + + // Reset is complete. + iControllerStateObserver->McsoProcessHardResetPhaseChange(KErrNone, MControllerStateObserver::EBTFatalChange, EBTResetComplete); + } + } + + +void CControllerManager::SetControllerStateObserver(MControllerStateObserver& aControllerStateObserver) + { + LOG_FUNC + + iControllerStateObserver = &aControllerStateObserver; + } diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/ti/inc/hctltireceiver.h --- a/bthci/hci2implementations/hctls/ti/inc/hctltireceiver.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/hctls/ti/inc/hctltireceiver.h Wed Jul 28 17:24:32 2010 +0100 @@ -25,7 +25,6 @@ #include #include - class CHCTLTi; class RBusDevComm; diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/uart_original/inc/hctluartoriginal.h --- a/bthci/hci2implementations/hctls/uart_original/inc/hctluartoriginal.h Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/hctls/uart_original/inc/hctluartoriginal.h Wed Jul 28 17:24:32 2010 +0100 @@ -72,6 +72,8 @@ void HandlePowerOn(); TBTPowerState CurrentPowerState() const; + //CHRIS MODIF + //void SetInitFlag(TBool flag); public: // HCTL packet types as defined in Section 2, Part H: 4 of the @@ -114,6 +116,8 @@ TBTPowerState iCurrentPowerState; CControllerManager* iControllerMan; + //CHRIS MODIF + //TBool iInitFlag; DECLARE_HCI_LOGGER }; diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/uart_original/src/hctluartoriginal.cpp --- a/bthci/hci2implementations/hctls/uart_original/src/hctluartoriginal.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/hctls/uart_original/src/hctluartoriginal.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -68,7 +68,9 @@ // Initialises iSender and iReceiver via the PortOpenedL method. BaseConstructL(KIniFileName()); - + //CHRIS MODIF + //iInitFlag = FALSE; + iControllerMan = CControllerManager::NewL(*this); } @@ -334,3 +336,10 @@ { return iCurrentPowerState; } + +//CHRIS MODIF +//void CHCTLUartOriginal::SetInitFlag(TBool flag) + //{ + //iInitFlag = flag; + //} + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/hctls/uart_original/src/hctluartoriginalreceiver.cpp --- a/bthci/hci2implementations/hctls/uart_original/src/hctluartoriginalreceiver.cpp Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hci2implementations/hctls/uart_original/src/hctluartoriginalreceiver.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -154,6 +154,18 @@ break; default: + /////////////////////////////////////// + //CHRIS MODIF + //if(iHCTLUartOriginal->iInitFlag == TRUE) + //{ + if((iCurrentHCIPacketType == 0x34) || (iCurrentHCIPacketType == 0x31) ) + { + bytesRequiredForNextRead = 1; + iState = EWaitingForHctlHeaderByte; + break; + } + //} + ///////////////////////////////////////// // unexpected/unsupported data Received iState = EInvalidDataReceived; break; diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/group/BCM2046B1.bin Binary file bthci/hci2implementations/initialisors/brcm/group/BCM2046B1.bin has changed diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/group/BCM2046B1.hcd Binary file bthci/hci2implementations/initialisors/brcm/group/BCM2046B1.hcd has changed diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/group/Initialisor_Brcm.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/group/Initialisor_Brcm.mmp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,31 @@ +TARGET Initialisor_brcm.dll +TARGETTYPE PLUGIN +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +UID 0x10009d8d 0x2003011A +VENDORID 0x70000001 +CAPABILITY CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData + +SOURCEPATH ../src + +RESOURCE Initialisor_brcm.rss + +SOURCE Initialisor_Broadcom_ConfigFile.cpp +SOURCE ControllerInitialisationPluginImpl.cpp +SOURCE Initialisor_Brcm_main.cpp + +USERINCLUDE ../inc +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib +LIBRARY initialisor_base.lib +LIBRARY btlogger.lib +LIBRARY efsrv.lib +LIBRARY cinidata.lib +LIBRARY commandsevents.lib + +OPTION cw -strict on -w pedantic,unused,hidevirtual,padding,ptrintconv + +UNPAGED + +SMPSAFE diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/group/bld.inf Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,30 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +PRJ_EXPORTS +../inc/BroadcomControllerInitialisor.h SYMBIAN_OS_LAYER_PLATFORM_EXPORT_PATH(bluetooth/hci/BroadcomControllerInitialisor.h) + +initialisor_brcm.iby /epoc32/rom/include/initialisor_brcm.iby + +BCM2046B1.bin /epoc32/data/z/private/101f7989/bluetooth/BCM2046B1.bin +BCM2046B1.bin /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/BCM2046B1.bin // For WINSCW debugging +BCM2046B1.bin /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/BCM2046B1.bin + +BCM2046B1.hcd /epoc32/data/z/private/101f7989/bluetooth/BCM2046B1.hcd +BCM2046B1.hcd /epoc32/release/winscw/udeb/z/private/101f7989/bluetooth/BCM2046B1.hcd // For WINSCW debugging +BCM2046B1.hcd /epoc32/release/winscw/urel/z/private/101f7989/bluetooth/BCM2046B1.hcd + +PRJ_MMPFILES +Initialisor_Brcm.mmp diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/group/initialisor_brcm.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/group/initialisor_brcm.iby Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,25 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#ifndef INITIALISOR_BRCM_IBY +#define INITIALISOR_BRCM_IBY + +REM Broadcom reference Bluetooth initialisor + +HCI_PLUGIN(Initialisor_Brcm.dll, Initialisor_Brcm.rsc) + +data=ZPRIVATE\101F7989\Bluetooth\BCM2046B1.bin Private\101F7989\Bluetooth\BCM2046B1.bin + +#endif // INITIALISOR_BRCM_IBY diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/inc/BroadcomControllerInitialisor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/inc/BroadcomControllerInitialisor.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,117 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#ifndef BROADCOMCONTROLLERINITIALISOR_H +#define BROADCOMCONTROLLERINITIALISOR_H + +#include +#include + +#include + +/** +The panic category for the Broadcom controller initialisor. +*/ +_LIT(KBroadcomControllerInitialisorPanic, "Broadcom Ctlr Init"); + +/** +Panic codes for the Symbian reference controller initialisor +*/ +enum TBroadcomControllerInitialisorPanic + { + EConfigInterfaceNull = 0, + EInvalidInitialisorState = 1, + ENullInitialisationObserver = 2, + EHciCommandQueueOverwritten = 3, + EInitialisationObserverOverwritten = 4, + ECoreHciOverwritten = 5 + }; + static const TUint8 KHcdConfigFileChunkSize = 0xff; + static const TUint8 KConfigFileChunkSize = 250; + +enum TInitState + { + EIdle, + EUpdateBaudRateBeforePrmDelay, + EloadingMiniDriver, + EMiniDrvToBinConfigFileDelay, + EMiniDrvToHcdConfigFileDelay, + ELoadingBinConfigFileData, + ELoadingHcdConfigFileData, + ELoadingconfigFileDataDone, + EWaitEndDelay, + EWaitUpdateBaudRateAfterPrm + }; + /** + Observer class for ConfigFileTimer +*/ +class MConfigFileTimerEventObserver + { +public: + virtual void ConfigFileTimerExpired() = 0; + }; + +/** + Timer class +*/ +class CConfigFileTimer : public CTimer + { +public: + static CConfigFileTimer* NewL(MConfigFileTimerEventObserver& aTimerObserver); + void Start(const TInt& aDuration); + +private: + CConfigFileTimer(MConfigFileTimerEventObserver& aTimerObserver); + void ConstructL(); + void RunL(); + +private: + MConfigFileTimerEventObserver& iTimerObserver; + }; + + +NONSHARABLE_CLASS(CConfigFileDownload) : public CBase + { +public: + static CConfigFileDownload* NewL(const TDesC& aConfigFile); + ~CConfigFileDownload(); + TInt ConfigFileSendDataChunk(TBuf8& aVendorCommandBuffer); + + TInt ConfigFileSendData(TBuf8& aVendorCommandBuffer,TUint8 DataChunkLen); + TInt ReadCommandOpcode(THCIOpcode & Opcode); + TInt ReadDataChunkLen(TUint8 & DataChunkLen); + TInt SetDataChunkAddress(TDes8 & AddressBuf); +// TInt SetDataChunkAddress(TBuf8<4> AddressBuf); + +private: + CConfigFileDownload(); + void ConstructL(const TDesC& aConfigFile); + +private: + + RFile iFile; + RFs iFs; + + + }; + + +#endif // BROADCOMCONTROLLERINITIALISOR_H + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/inc/ControllerInitialisationPluginImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/inc/ControllerInitialisationPluginImpl.h Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,104 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#ifndef CONTROLLERINITIALISATIONPLUGINIMPL_H +#define CONTROLLERINITIALISATIONPLUGINIMPL_H + +#include +#include + +#include +#include + +#include + +#include + +class TVendorDebugCompleteEvent; +class MCoreHci; + +const TUint16 KHciVSUpdateUartHCIBaudRate = 0xFC18; +const TUint16 KHciVSDownloadMiniDriver = 0xFC2E; //HCI_BRCM_DOWNLOAD_MINI_DRV +const TUint16 KHciVSWriteRam = 0xFC4C; //HCI_BRCM_WRITE_RAM +const TUint16 KHciVSLaunchRam = 0xFC4E; //HCI_BRCM_LAUNCH_RAM + +class CControllerInitialisationPluginImpl : public CControllerInitialisationPlugin, + public MControllerInitialisationInterface, + public MHCICommandQueueClient, + public MConfigFileTimerEventObserver + { + +private: + enum TPatchRamFormat + { + EUnknownFileFormat, + EHcdFileFormat, + EBinFileFormat + }; + +public: + static CControllerInitialisationPluginImpl* NewL(); + ~CControllerInitialisationPluginImpl(); + virtual TAny* Interface(TUid aUid); + +protected: + CControllerInitialisationPluginImpl(); + +private: + void ConstructL(); + + // Static async CallBack methods. + static TInt AsyncCallBackForPostReset(TAny* aInitPlugin); + + // MControllerInitialisationInterface + virtual void MciiPreResetCommand(); + virtual void MciiPostResetCommand(); + virtual void MciiSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue); + virtual void MciiSetControllerInitialisationObserver(MControllerInitialisationObserver& aObserver); + virtual void MciiSetCoreHci(MCoreHci& aCoreHci); + + // MHCICommandQueueClient + virtual void MhcqcCommandEventReceived(const THCIEventBase& aEvent, + const CHCICommandBase* aRelatedCommand); + virtual void MhcqcCommandErrored(TInt aErrorCode,const CHCICommandBase* aCommand); + virtual void ConfigFileTimerExpired(); + void HandleVendorSpecificCompleteEvent(const TVendorDebugCompleteEvent& aEvent); + void DoPostReset(); + void InitialiseAndLoadMiniDriver(); +// TInt MapBaudRate(TInt iMapfrom, TInt iMapTo); + +private: +// Async Callback + CAsyncCallBack* iAsyncCallBackForPostReset; + TInitState iInitState; + CConfigFileDownload* iCConfigFileDownload; + MHCICommandQueue* iHCICommandQueue; + MControllerInitialisationObserver* iControllerInitialisationObserver; + MCoreHci* iCoreHci; + TUint32 iDestRam; + TUint16 iTxPatchLength; + CConfigFileTimer* iMiniDrive2ConfigFileTimer; + + TPatchRamFormat iFileFormat ; + }; + + + +#endif diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/src/ControllerInitialisationPluginImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/src/ControllerInitialisationPluginImpl.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,971 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ +#include +#include "broadcomcontrollerinitialisor.h" +#include "controllerinitialisationpluginimpl.h" + +#include +#include + + +#include + +#include + +#include + +#include + +#include +#include +#include + +#define INITIALISOR_BCM_LOGGER +#define BCM_TRANSPORT +#define UPDATEBAUDRATE_AFTER_PRD + +#ifdef INITIALISOR_BCM_LOGGER +#define INITIALISOR_BCM_LOG(A) RDebug::Print(A); +#define INITIALISOR_BCM_LOG2(A,B) RDebug::Print(A,B); +#define INITIALISOR_BCM_LOG3(A,B,C) RDebug::Print(A,B,C); +#else +#define INITIALISOR_BCM_LOG(A) +#define INITIALISOR_BCM_LOG2(A,B) +#define INITIALISOR_BCM_LOG3(A,B,C) +#define INITIALISOR_BCM_LOG4(A,B,C,D) +#endif + +const TUint32 BCM2048_RAM_LOCATION = 0x00085D00; +const TUint32 BCM4325_RAM_LOCATION = 0x00086800; +const TUint32 BCM2046_RAM_LOCATION = 0x00086800 ; //0x00087AC8; + +TUint32 KDestRamLocation = BCM2048_RAM_LOCATION; // by default this location is for BCM2048 +// 50 mstimer. +const TInt KMiniDriverToPatchRamTimerDuration = 50000; // 50000; +const TInt KEndDelayTimerDuration = 750000; //250000; + +#define BAUDRATE_921600 921600 +#define BAUDRATE_115200 115200 +#define BAUDRATE_57600 BAUDRATE_921600 // for now we map the BR 57600 to 921600 +#define UART_24MHZ_CLOCK 24000000 + +TInt iBaudRate = BAUDRATE_115200; // default baudrate +TInt iBaudRateAfter = BAUDRATE_115200; // default baudrate +TInt iUartClock = UART_24MHZ_CLOCK; // default baudrate + +#ifdef BCM_TRANSPORT +_LIT(KDefaultIniFileName, "hctl_broadcom.ini"); +#else +_LIT(KDefaultIniFileName, "hctl_uart_original.ini"); +#endif + +_LIT(KConfigFileFileFormat, "%S%S"); +#if 0 +_LIT(KDefaultConfigFileFileFormat, "%S%S.bin"); +#else +_LIT(KDefaultConfigFileFileFormat, "%S%S.hcd"); +#endif +_LIT(KDefaultConfigFileName, "BCM2046B1"); +_LIT(KDefaultConfigFilePath, "z:\\private\\101f7989\\Bluetooth\\"); + +_LIT(KGlobalReadySemName, "BCM_BT_READY_010155"); +//RSemaphore BCM_DriverReadySem; + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_INITIALISOR_BROADCOM); +//_LIT8(KLogComponent, "InitBRCM"); +#endif + + + +/*static*/ CControllerInitialisationPluginImpl* CControllerInitialisationPluginImpl::NewL() + { + LOG_STATIC_FUNC + + CControllerInitialisationPluginImpl* self = new (ELeave) CControllerInitialisationPluginImpl(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CControllerInitialisationPluginImpl::~CControllerInitialisationPluginImpl() + { + LOG_FUNC + + // Delete async CallBacks. If running, these should be cancelled by the + // d'tor of CAsyncOneShot. + delete iAsyncCallBackForPostReset; + delete iCConfigFileDownload; + delete iMiniDrive2ConfigFileTimer; + } + +void CControllerInitialisationPluginImpl::ConstructL() + { + LOG_FUNC + + // Add Async Callbacks + TCallBack postResetCallBack(AsyncCallBackForPostReset, this); + iAsyncCallBackForPostReset = new (ELeave)CAsyncCallBack(postResetCallBack, CActive::EPriorityStandard); + iMiniDrive2ConfigFileTimer = CConfigFileTimer::NewL(*this); + } + +// Protected constructor. +CControllerInitialisationPluginImpl::CControllerInitialisationPluginImpl() + { + LOG_FUNC + + } + +/*virtual*/ void CControllerInitialisationPluginImpl::MciiPreResetCommand() + { + LOG_FUNC + + __ASSERT_DEBUG(iControllerInitialisationObserver, PANIC(KBroadcomControllerInitialisorPanic, ENullInitialisationObserver)); + // Do any pre-reset initialisation... +#ifndef __WINSCW__ + + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : Set Initial BaudRate to %d before reset"), iBaudRate) + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciUpdateBaudRate(iBaudRate); +#endif + + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : call McioPreResetCommandComplete(KErrNone)")) + // Inform stack that we have finished + iControllerInitialisationObserver->McioPreResetCommandComplete(KErrNone); + + } +/*virtual*/ TAny* CControllerInitialisationPluginImpl::Interface(TUid aUid) + { + LOG_FUNC + + TAny* ret = NULL; + switch(aUid.iUid) + { + case KControllerInitialisationInterfaceUid: + ret = reinterpret_cast(static_cast(this)); + break; + + default: + break; + }; + + return ret; + } + +/*static*/ TInt CControllerInitialisationPluginImpl::AsyncCallBackForPostReset(TAny* aInitPlugin) + { + LOG_STATIC_FUNC + + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : CControllerInitialisationPluginImpl::AsyncCallBackForPostReset(TAny* aInitPlugin)")) + + CControllerInitialisationPluginImpl* initPlugin = static_cast(aInitPlugin); + initPlugin->DoPostReset(); + return EFalse; // Don't call back any more. + } + +void CControllerInitialisationPluginImpl::InitialiseAndLoadMiniDriver() + { + LOG_FUNC + + CVendorDebugCommand* cmd = NULL; + TInt err = KErrNone; + + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : InitialiseAndLoadMiniDriver()")) + + // Chinda - Check for specific patch ram file in patch_ram section in hctl_bcm.ini file + TFileName fileName; + CIniData* pIniFile = NULL; + + TName name; + + name.Copy(KDefaultConfigFilePath); + name.Append(KDefaultIniFileName); + + _LIT(KFileHcdExtension,"*.hcd"); + _LIT(KFileBinExtension,"*.bin"); + + _LIT(KPatchramSection, "patch_ram"); + _LIT(KPatchramPath, "path"); + _LIT(KPatchramFile, "file"); + _LIT(KPatchramLocation, "location"); + TInt iRamLocation; + + + TRAP(err, pIniFile = CIniData::NewL(name)); + if (err != KErrNone) + { + // Attempt to open the config file. + fileName.Format(KDefaultConfigFileFileFormat,&KDefaultConfigFilePath, &KDefaultConfigFileName); + iBaudRate = BAUDRATE_115200; + iBaudRateAfter = BAUDRATE_115200; + } + else + { + // First read COM port and baudrate + if (pIniFile) + { + _LIT(KCOMPortSection, "hctl"); + _LIT(KCOMBaudRate, "baud_rate"); + _LIT(KCOMBaudRateAfter, "functional_baud_rate"); + _LIT(KCOMUARTClock, "uart_clock"); + + if (!pIniFile->FindVar(KCOMPortSection, KCOMBaudRate, iBaudRate)) + { + iBaudRate = BAUDRATE_115200; + } + + if (!pIniFile->FindVar(KCOMPortSection, KCOMBaudRateAfter, iBaudRateAfter)) + { + iBaudRateAfter = BAUDRATE_115200; + } + if (!pIniFile->FindVar(KCOMPortSection, KCOMUARTClock, iUartClock)) + { + iUartClock = UART_24MHZ_CLOCK; + } + + TPtrC PathText; + TPtrC FileText; + + //TBufC8<256> strFileExtension; + + if (!pIniFile->FindVar(KPatchramSection, KPatchramPath, PathText)) + { + PathText.Set(KDefaultConfigFilePath); + } +#if 1 + if (!pIniFile->FindVar(KPatchramSection, KPatchramFile, FileText)) + { + FileText.Set(KDefaultConfigFileName); + fileName.Format(KDefaultConfigFileFileFormat,&PathText, &FileText); + } + else + { + fileName.Format(KConfigFileFileFormat,&PathText, &FileText); + } + } + else + { + //FileText.Set(KDefaultConfigFileName); + fileName.Format(KDefaultConfigFileFileFormat,&KDefaultConfigFilePath, &KDefaultConfigFileName); + // ADD EXTENSION CHECK HERE + } + + // Check if we have an hcd file to download + if(fileName.Match(KFileHcdExtension) != KErrNotFound) + { + iFileFormat = EHcdFileFormat; + delete pIniFile; + } + else + { + // Check if we have a binary file to download + if(fileName.Match(KFileBinExtension) != KErrNotFound) + { + iFileFormat = EBinFileFormat; + // check for ram location in ini file + if (pIniFile->FindVar(KPatchramSection, KPatchramLocation, iRamLocation) != EFalse) + KDestRamLocation = iRamLocation; + else if (fileName.Find(_L("2048")) != KErrNotFound) + KDestRamLocation = BCM2048_RAM_LOCATION; + else if (fileName.Find(_L("4325")) != KErrNotFound) + KDestRamLocation = BCM4325_RAM_LOCATION; + else if (fileName.Find(_L("2046")) != KErrNotFound) + KDestRamLocation = BCM2046_RAM_LOCATION; + delete pIniFile; + } + else //Unknown file type SHOULD NEVER FALL IN THIS CONDITION + { + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + + iFileFormat = EUnknownFileFormat; + delete pIniFile; + return; + } + } + } + +#else + + if (!pIniFile->FindVar(KPatchramSection, KPatchramFile, FileText)) + { + FileText.Set(KDefaultConfigFileName); + fileName.Format(KDefaultConfigFileFileFormat,&PathText, &FileText); + } + else + { + fileName.Format(KConfigFileFileFormat,&PathText, &FileText); + } + + // check for ram location in ini file + if (pIniFile->FindVar(KPatchramSection, KPatchramLocation, iRamLocation) != EFalse) + KDestRamLocation = iRamLocation; + else if (fileName.Find(_L("2048")) != KErrNotFound) + KDestRamLocation = BCM2048_RAM_LOCATION; + else if (fileName.Find(_L("4325")) != KErrNotFound) + KDestRamLocation = BCM4325_RAM_LOCATION; + else if (fileName.Find(_L("2046")) != KErrNotFound) + KDestRamLocation = BCM2046_RAM_LOCATION; + delete pIniFile; + } + else + { + fileName.Format(KDefaultConfigFileFileFormat,&KDefaultConfigFilePath, &KDefaultConfigFileName); + } + + } + + +#endif + + + // Open the config file + TRAP(err, iCConfigFileDownload = CConfigFileDownload::NewL(fileName)); + + if (err != KErrNone) + { + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + + + } + else + { + // initiate Dwl config file + TRAP(err, cmd = CVendorDebugCommand::NewL(KHciVSDownloadMiniDriver)); + if (err == KErrNone) + { + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + if(err != KErrNone) + { + // Inform the stack of the initialisation status. + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + } + else + { + if(iFileFormat == EBinFileFormat) + { + iDestRam = KDestRamLocation; + iTxPatchLength = 0; + } + iInitState = EloadingMiniDriver; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EloadingMiniDriver); + + } + } + else + { + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + } + } + } + + +void CControllerInitialisationPluginImpl::DoPostReset() + { + LOG_FUNC + + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : CControllerInitialisationPluginImpl::DoPostReset()")) + + InitialiseAndLoadMiniDriver(); + + } + +/*virtual*/ void CControllerInitialisationPluginImpl::MciiPostResetCommand() + { + LOG_FUNC + + __ASSERT_DEBUG(iControllerInitialisationObserver, PANIC(KBroadcomControllerInitialisorPanic, ENullInitialisationObserver)); + + // Use async callback + iAsyncCallBackForPostReset->CallBack(); + } + +void CControllerInitialisationPluginImpl::HandleVendorSpecificCompleteEvent(const TVendorDebugCompleteEvent& aEvent) + { + LOG_FUNC + + CVendorDebugCommand* cmd = NULL; + TInt err = KErrNone; + THCIErrorCode hcierr = EOK; + + + switch(iInitState) + { + + case EloadingMiniDriver: + { + if (aEvent.CommandOpcode() == KHciVSDownloadMiniDriver ) + { + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : HCI VSC Download Mini Driver event (%04x)"), aEvent.CommandOpcode()) + + hcierr = aEvent.ErrorCode(); + if (hcierr == EOK) + { + // Delay before actual patch ram download + iMiniDrive2ConfigFileTimer->Start(KMiniDriverToPatchRamTimerDuration); + if(iFileFormat == EBinFileFormat) + { + iInitState = EMiniDrvToBinConfigFileDelay; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EMiniDrvToBinConfigFileDelay); + } + else if(iFileFormat == EHcdFileFormat) + { + iInitState = EMiniDrvToHcdConfigFileDelay; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EMiniDrvToHcdConfigFileDelay); + } + } + } + } + break; + + case ELoadingHcdConfigFileData: + { + INITIALISOR_BCM_LOG(_L("WRITE RAM COMPLETE EVENT")) + + if (aEvent.CommandOpcode() == KHciVSWriteRam ) + { + hcierr = aEvent.ErrorCode(); + if (hcierr == EOK) + { + THCIOpcode CommandOpcode; + TUint8 DataChunkLen = 0; + + iCConfigFileDownload->ReadCommandOpcode(CommandOpcode); + + TRAP(err, cmd = CVendorDebugCommand::NewL(CommandOpcode)); + if (err == KErrNone) + { + TDes8& cmdData = cmd->Command(); + + iCConfigFileDownload->ReadDataChunkLen(DataChunkLen); + + if(DataChunkLen != 0) + { + TBuf8<4> AddressBuf; + TBuf8 patchRamData; + if(CommandOpcode == KHciVSLaunchRam) + { + + err = iCConfigFileDownload->ConfigFileSendData(patchRamData,DataChunkLen); + if (KErrNone == err) + { + cmd->Reset(KHciVSLaunchRam); + cmdData.Append(patchRamData); + INITIALISOR_BCM_LOG(_L("LAUNCH RAM")) + iInitState = ELoadingconfigFileDataDone; + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(ELoadingconfigFileDataDone); + } + } + else + { + err = iCConfigFileDownload->SetDataChunkAddress(AddressBuf); + + if (KErrNone == err) + { + cmdData.FillZ(4); + cmdData[0] = AddressBuf[0]; + cmdData[1] = AddressBuf[1]; + cmdData[2] = AddressBuf[2]; + cmdData[3] = AddressBuf[3]; + + err = iCConfigFileDownload->ConfigFileSendData(patchRamData,(DataChunkLen-4)); + + if (KErrNone == err) + { + cmdData.Append(patchRamData); + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + INITIALISOR_BCM_LOG(_L("WRITE RAM")) + } + } + } + } + } + + if(KErrNone != err) + { + // something went wrong during the file read + delete cmd; //command was not sent due to read file error + + // Inform the stack of the initialisation status. + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + } + }//hcierr == EOK + }//aEvent.CommandOpcode() == KHciVSWriteRam + else + { + err = KErrGeneral; //complete event is not the expected one + } + } + break; + + case ELoadingBinConfigFileData: + { + if (aEvent.CommandOpcode() == KHciVSWriteRam ) + { + hcierr = aEvent.ErrorCode(); + if (hcierr == EOK) + { + //Update the Destination Ram address + iDestRam = iDestRam + iTxPatchLength; + + TRAP(err, cmd = CVendorDebugCommand::NewL(KHciVSWriteRam)); + if (err == KErrNone) + { + TBuf8 patchRamData; + + // Try to read config file data + err = iCConfigFileDownload->ConfigFileSendDataChunk(patchRamData); + if (KErrEof == err) + { + // EOF reached + iInitState = ELoadingconfigFileDataDone; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(ELoadingconfigFileDataDone); + + // Launch Patch ram + cmd->Reset(KHciVSLaunchRam); + // reuse allocated cmd + + TDes8& cmdData = cmd->Command(); + + cmdData.FillZ(4); + cmdData[0] = 0xFF; + cmdData[1] = 0xFF; + cmdData[2] = 0xFF; + cmdData[3] = 0xFF; + + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + // Wait for the launch config file complete event + + } + else if (KErrNone == err) + { + + TDes8& cmdData = cmd->Command(); + + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : HCI VSC Write RAM event (%04x)"), aEvent.CommandOpcode()) + + cmdData.FillZ(4); + cmdData[0] = (iDestRam) & 0xFF; + cmdData[1] = ((iDestRam) >> 8) & 0xFF; + cmdData[2] = ((iDestRam) >> 16) & 0xFF; + cmdData[3] = ((iDestRam) >> 24) & 0xFF; + + cmdData.Append(patchRamData); + + // Send another chunk of config file data + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + if (KErrNone == err) + { + // Update length of Tx'd data + iTxPatchLength = patchRamData.Length(); + iInitState = ELoadingBinConfigFileData; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(ELoadingBinConfigFileData); + // Wait for the VSC complete event + } + } + else if (KErrNone != err) + { + // something went wrong during the file read + delete cmd; //command was not sent due to read file error + } + } + } + else + { + err = KErrGeneral; //complete event is not the expected one + } + + if (err != KErrNone) + { + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + } + } + } + break; + + case ELoadingconfigFileDataDone: + { + INITIALISOR_BCM_LOG(_L("LAUNCH RAM COMPLETE EVENT")) + if (aEvent.CommandOpcode() == KHciVSLaunchRam) + { + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : HCI VSC Launch RAM event (%04x)"), aEvent.CommandOpcode()) + + hcierr = aEvent.ErrorCode(); + if (hcierr == EOK) + { + iMiniDrive2ConfigFileTimer->Start(KEndDelayTimerDuration); + iInitState = EWaitEndDelay; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EWaitEndDelay); + } + } + } + break; + + + case EWaitUpdateBaudRateAfterPrm: + { +#ifdef UPDATEBAUDRATE_AFTER_PRD + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : VSC Update BaudRate event (%04x)"), aEvent.CommandOpcode()) + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + if (aEvent.CommandOpcode() == KHciVSUpdateUartHCIBaudRate) + { + hcierr = aEvent.ErrorCode(); + if (hcierr == EOK) + { + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : Change UART BaudRate to %d bps after launching RAM"), iBaudRateAfter) + + err = hctlConfigInterface->MhciUpdateBaudRate(iBaudRateAfter); + } + else + { + err = KErrGeneral; + } + } + else + { + err = KErrGeneral; + } +#else + err = KErrNone; +#endif + // BCM initialisation is completed- resume generic init + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + hctlConfigInterface->MhciSetInitPluginState(EIdle); + + //iInitState = EReset; + // Signal to everyone that we are ready + //BCM_DriverReadySem.CreateGlobal(KGlobalReadySemName,1,EOwnerProcess); + } + break; + + default: + INITIALISOR_BCM_LOG2(_L("Broadcom: CControllerInitialisationPluginImpl::HandleVendorSpecificCompleteEvent - Default state (%d)"),iInitState) + + break; + } + } + +/*virtual*/ void CControllerInitialisationPluginImpl::ConfigFileTimerExpired() + { + LOG_FUNC + + TInt err = KErrNone; + CVendorDebugCommand* cmd = NULL; + + switch(iInitState) + { + case EMiniDrvToHcdConfigFileDelay: + { + THCIOpcode CommandOpcode; + TUint8 DataChunkLen = 0; + + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : Start patch ram download")) + + iCConfigFileDownload->ReadCommandOpcode(CommandOpcode); + + TRAP(err, cmd = CVendorDebugCommand::NewL(CommandOpcode)); + TDes8& cmdData = cmd->Command(); + + iCConfigFileDownload->ReadDataChunkLen(DataChunkLen); + + if(DataChunkLen != 0) + { + //TBuf8<4> AddressBuf; + TBuf8<4> AddressBuf; + + err = iCConfigFileDownload->SetDataChunkAddress(AddressBuf); + if (KErrNone == err) + { + cmdData.FillZ(4); + cmdData[0] = AddressBuf[0]; + cmdData[1] = AddressBuf[1]; + cmdData[2] = AddressBuf[2]; + cmdData[3] = AddressBuf[3]; + + TBuf8 HcdpatchRamData; + + // Substract 4 from DataChunkLen for download address + err = iCConfigFileDownload->ConfigFileSendData(HcdpatchRamData,(DataChunkLen-4)); + if (KErrNone == err) + { + cmdData.Append(HcdpatchRamData); + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + INITIALISOR_BCM_LOG(_L("FIRST WRITE RAM")) + if (KErrNone == err) + { + iInitState = ELoadingHcdConfigFileData; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(ELoadingHcdConfigFileData); + } + } + } + + if(KErrNone != err) + { + // something went wrong during the file read + delete cmd; //command was not sent due to read file error + + // Inform the stack of the initialisation status. + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + } + + } + } + break; + + case EMiniDrvToBinConfigFileDelay: + { + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : Waiting for Mini download Driver")) + // initiate actual downloading of the Config file + TRAP(err, cmd = CVendorDebugCommand::NewL(KHciVSWriteRam)); + if (err == KErrNone) + { + TBuf8 patchRamData; + TDes8& cmdData = cmd->Command(); + + err = iCConfigFileDownload->ConfigFileSendDataChunk(patchRamData); + + // Start sending config file data + if (KErrNone == err) + { + cmdData.FillZ(4); + cmdData[0] = (KDestRamLocation) & 0xFF; + cmdData[1] = ((KDestRamLocation) >> 8) & 0xFF; + cmdData[2] = ((KDestRamLocation) >> 16) & 0xFF; + cmdData[3] = ((KDestRamLocation) >> 24) & 0xFF; + + cmdData.Append(patchRamData); + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + if (KErrNone == err) + { + // Update length of Tx'd data + iTxPatchLength = iTxPatchLength + patchRamData.Length(); + iInitState = ELoadingBinConfigFileData; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(ELoadingBinConfigFileData); + // Wait for the VSC complete event + } + } + else + { + // something went wrong during the file read + delete cmd; //command was not sent due to read file error + } + } + + + if (KErrNone != err) + { + // Inform the stack of the initialisation status. + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + iInitState = EIdle; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + } + } + break; + + case EWaitEndDelay: + { +#ifdef UPDATEBAUDRATE_AFTER_PRD + // BCM initialisation is completed- resume generic init + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : END Initialisation steps (PatchRAM downloaded OK))")) + + // Request baud rate update. + CVendorDebugCommand* cmd = NULL; + TRAP(err, cmd = CVendorDebugCommand::NewL(KHciVSUpdateUartHCIBaudRate)); + TDes8& cmdData = cmd->Command(); + + if(err == KErrNone) + { + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : Change BaudRate to %d bps after launchRAM"), iBaudRateAfter) + INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : UART Clock is %d"), iUartClock) + cmdData.FillZ(6); + cmdData[2] = iBaudRateAfter & 0xFF; + cmdData[3] = (iBaudRateAfter >> 8) & 0xFF; + cmdData[4] = (iBaudRateAfter >> 16) & 0xFF; + cmdData[5] = (iBaudRateAfter >> 24) & 0xFF; + + TRAP(err, iHCICommandQueue->MhcqAddInitCommandL(cmd, *this)); + // error handling if the method above fails is handled in at the end of the function +// INITIALISOR_BCM_LOG2(_L("Initialisor_Broadcom : Send %x %x %x %x %x %x after launchRAM OK"), iBaudRateAfter) + RDebug::Print(_L("Initialisor_Broadcom : Send %x %x %x %x %x %x after launchRAM OK"), + cmdData[0], + cmdData[1], + cmdData[2], + cmdData[3], + cmdData[4], + cmdData[5]); + iInitState = EWaitUpdateBaudRateAfterPrm; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EWaitUpdateBaudRateAfterPrm); + } +#else + iInitState = EWaitUpdateBaudRateAfterPrm; + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EWaitUpdateBaudRateAfterPrm); + + iControllerInitialisationObserver->McioPostResetCommandComplete(err); +#endif + + + if(err != KErrNone) + { + iInitState = EIdle; + + MHctlBcmConfigInterface* hctlConfigInterface = static_cast(iCoreHci->MchHctlPluginInterface(TUid::Uid(KHctlBcmConfigInterfaceUid))); + __ASSERT_DEBUG(hctlConfigInterface, PANIC(KBroadcomControllerInitialisorPanic, EConfigInterfaceNull)); + hctlConfigInterface->MhciSetInitPluginState(EIdle); + + iControllerInitialisationObserver->McioPostResetCommandComplete(err); + } + + // Signal to everyone that we are ready + //BCM_DriverReadySem.CreateGlobal(KGlobalReadySemName,1,EOwnerProcess); + + } + break; + + default: + break; + } + } + + +/*virtual*/ void CControllerInitialisationPluginImpl::MciiSetHCICommandQueue(MHCICommandQueue& aHCICommandQueue) + { + LOG_FUNC + + __ASSERT_DEBUG(iHCICommandQueue == 0, PANIC(KBroadcomControllerInitialisorPanic, EHciCommandQueueOverwritten)); + iHCICommandQueue = &aHCICommandQueue; + } + +/*virtual*/ void CControllerInitialisationPluginImpl::MciiSetControllerInitialisationObserver(MControllerInitialisationObserver& aObserver) + { + LOG_FUNC + + __ASSERT_DEBUG(iControllerInitialisationObserver == 0, PANIC(KBroadcomControllerInitialisorPanic, EInitialisationObserverOverwritten)); + iControllerInitialisationObserver = &aObserver; + } +void CControllerInitialisationPluginImpl::MhcqcCommandErrored(TInt aErrorCode, + const CHCICommandBase* /*aCommand*/) + { + LOG_FUNC + + switch(iInitState) + { + default: + PANIC(KBroadcomControllerInitialisorPanic, EInvalidInitialisorState); + break; + }; + } + +void CControllerInitialisationPluginImpl::MhcqcCommandEventReceived(const THCIEventBase& aEvent, + const CHCICommandBase* /*aRelatedCommand*/) + { + LOG_FUNC + + if (aEvent.EventCode() == ECommandCompleteEvent) + { + // Switch on the opcode. + THCICommandCompleteEvent& event = THCICommandCompleteEvent::Cast(aEvent); + switch(event.CommandOpcode()) + { + + default: + // Check for VS commands. + if((event.CommandOpcode() & KVendorDebugOGF) == KVendorDebugOGF) + { + TVendorDebugCompleteEvent& vEvent = TVendorDebugCompleteEvent::Cast(event); + HandleVendorSpecificCompleteEvent(vEvent); + } + break; + } + } + } + +/*virtual*/ void CControllerInitialisationPluginImpl::MciiSetCoreHci(MCoreHci& aCoreHci) + { + LOG_FUNC + + INITIALISOR_BCM_LOG(_L("Initialisor_Broadcom : Setting Core HCI")) + __ASSERT_DEBUG(iCoreHci == 0, PANIC(KBroadcomControllerInitialisorPanic, ECoreHciOverwritten)); + iCoreHci = &aCoreHci; + } + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/src/Initialisor_Brcm_main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/src/Initialisor_Brcm_main.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,35 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include +#include "ControllerInitialisationPluginImpl.h" + +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x2003011B, CControllerInitialisationPluginImpl::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/src/Initialisor_Broadcom_ConfigFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/src/Initialisor_Broadcom_ConfigFile.cpp Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,223 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include "BroadcomControllerInitialisor.h" +#include "ControllerInitialisationPluginImpl.h" + +#include + + + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, LOG_COMPONENT_INITIALISOR_BROADCOM); +//_LIT8(KLogComponent, "InitBRCM"); + +#endif + +/*static*/ CConfigFileDownload* CConfigFileDownload::NewL(const TDesC& aConfigFile) + { + LOG_STATIC_FUNC + + CConfigFileDownload* self = new(ELeave) CConfigFileDownload; + CleanupStack::PushL(self); + self->ConstructL(aConfigFile); + CleanupStack::Pop(self); + return self; + } + +void CConfigFileDownload::ConstructL(const TDesC& aConfigFile) + { + LOG_FUNC + + LEAVEIFERRORL(iFs.Connect()); + LEAVEIFERRORL(iFile.Open(iFs, aConfigFile, EFileRead || EFileShareReadersOnly || EFileStream)); + + } + +CConfigFileDownload::~CConfigFileDownload() + { + LOG_FUNC + + iFile.Close(); + iFs.Close(); + } + +// Private Constructor +CConfigFileDownload::CConfigFileDownload() + { + LOG_FUNC + } + +TInt CConfigFileDownload::ConfigFileSendDataChunk(TBuf8& aVendorCommandBuffer) + { + LOG_STATIC_FUNC + + TInt err = KErrNone; + TInt len; + + // read Config file data + err = iFile.Read(aVendorCommandBuffer, KConfigFileChunkSize); + len = aVendorCommandBuffer.Length(); + if (KErrNone == err) + { + if (aVendorCommandBuffer.Length() == 0) + { + // EOF was reached: stop sending HCI commands force err to EOF + err = KErrEof; + } + } + + return err; + } + +TInt CConfigFileDownload::ConfigFileSendData(TBuf8& aVendorCommandBuffer,TUint8 DataChunkLen) + { + LOG_STATIC_FUNC + + TInt err = KErrNone; + TInt len; + + aVendorCommandBuffer.SetLength(DataChunkLen); + + // read Config file data + err = iFile.Read(aVendorCommandBuffer, DataChunkLen); + + + //ONLY FOR TEST + len = aVendorCommandBuffer.Length(); + + if (KErrNone == err) + { + if (aVendorCommandBuffer.Length() == 0) + { + // EOF was reached: stop sending HCI commands force err to EOF + err = KErrEof; + } + } + //ONLY FOR TEST + return err; + } + +TInt CConfigFileDownload::ReadCommandOpcode(THCIOpcode & Opcode) + { + LOG_STATIC_FUNC + + TInt err = KErrNone; + + TBuf8<2> OpcodeBytes ; + //TDes8<2> OpcodeBytes; + //THCIOpcode Opcode = 0; + + + // read Config file data + err = iFile.Read(OpcodeBytes, 2); + + if(err == KErrNone) + { + Opcode = (OpcodeBytes[1]<<8) |OpcodeBytes[0]; + } + + return err; + } + +TInt CConfigFileDownload::ReadDataChunkLen(TUint8& DataChunkLen) + { + LOG_STATIC_FUNC + + TInt err = KErrNone; + TBuf8<1> DataLen; + //TUint8 DataChunkLen= 0; + + + // read Config file data + err = iFile.Read(DataLen, 1); + //err = iFile.Read(DataChunkLen, 1); + + DataChunkLen = DataLen[0]; + + return err ; + } + +//TInt CConfigFileDownload::SetDataChunkAddress(TBuf8<4> AddressBuf) +TInt CConfigFileDownload::SetDataChunkAddress(TDes8 & AddressBuf) + { + LOG_STATIC_FUNC + + TInt err = KErrNone; + //TBuf8 AddressBuf(AddressDesC); + //TBuf8<4> AddressBuf; + + + // read Config file data + err = iFile.Read(AddressBuf, 4); + + + //DataChunkLen = DataLen[0]; + + return err ; + } +////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////// +CConfigFileTimer* CConfigFileTimer::NewL(MConfigFileTimerEventObserver& aTimerObserver) + { + LOG_STATIC_FUNC + + CConfigFileTimer* self = new (ELeave) CConfigFileTimer(aTimerObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void CConfigFileTimer::ConstructL() + { + LOG_FUNC + + CTimer::ConstructL(); + CActiveScheduler::Add(this); + } + +CConfigFileTimer::CConfigFileTimer(MConfigFileTimerEventObserver& aTimerObserver) + : CTimer(EPriorityStandard), + iTimerObserver(aTimerObserver) + { + LOG_FUNC + } + +void CConfigFileTimer::Start(const TInt& aDuration) + { + LOG_FUNC + + if(!IsActive()) + { + After(aDuration); + // After(KMiniDriverToPatchRamTimerDuration); + // TTimeIntervalMicroSeconds32 + } + } + +void CConfigFileTimer::RunL() + { + LOG_FUNC + + iTimerObserver.ConfigFileTimerExpired(); + } + + diff -r 28479eeba3fb -r f53839ff73b7 bthci/hci2implementations/initialisors/brcm/src/Initialisor_brcm.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/initialisors/brcm/src/Initialisor_brcm.rss Wed Jul 28 17:24:32 2010 +0100 @@ -0,0 +1,48 @@ +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#include +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x2003011A; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KControllerInitialisationEcomInterfaceUid; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2003011B; + version_no = 1; + display_name = "broadcom_initialisor"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } + +// +// End of file diff -r 28479eeba3fb -r f53839ff73b7 bthci/hciextensioninterface/tsrc/tproxycorehci/group/corehci_tproxy.ini --- a/bthci/hciextensioninterface/tsrc/tproxycorehci/group/corehci_tproxy.ini Tue Feb 02 01:12:20 2010 +0200 +++ b/bthci/hciextensioninterface/tsrc/tproxycorehci/group/corehci_tproxy.ini Wed Jul 28 17:24:32 2010 +0100 @@ -30,9 +30,11 @@ ;initialisation_uid= 0x1027407B ;Symbian Initialisor -initialisation_uid= 0x1027407D +;initialisation_uid= 0x1027407D + +;Brcm Initialisor +initialisation_uid= 0xE000002 - diff -r 28479eeba3fb -r f53839ff73b7 group/bld.inf --- a/group/bld.inf Tue Feb 02 01:12:20 2010 +0200 +++ b/group/bld.inf Wed Jul 28 17:24:32 2010 +0100 @@ -22,3 +22,7 @@ /* include subsystems build info */ #include "../atext/group/bld.inf" #include "../bt_plat/group/bld.inf" +#include "../bluetoothmgmt/btcommon/bld.inf" + + +PRJ_MMPFILES