⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ep931xide.h

📁 EP931X系列的WinCE显卡驱动源代码
💻 H
字号:
//**********************************************************************
//                                                                      
// Filename: EP931xide.cpp
//                                                                      
// Description: IDE driver for the internal EP931x port.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Use of this source code is subject to the terms of the Cirrus end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to 
// use this source code. For a copy of the EULA, please see the 
// EULA.RTF on your install media.
//
// Copyright(c) Cirrus Logic Corporation 2002, All Rights Reserved                       
//                                                                      
//**********************************************************************
#ifndef _H_EP931XDISK
#define _H_EP931XDISK

//
// Only two ata device are supported.  A master and a slave device.
//
#define MAX_ATA_DEVICES     2

#if 0
struct  SGBuffInfo
{
    SG_BUF  m_Sg;

    //
    // This is the pointer mapped into Filesys space.
    //
    PULONG  m_pulBuffer;

    //
    // Physical Address
    //
    ULONG   m_ulPhyAddress;

    //
    // Is the Item Aligned
    //
    BOOL    m_fAligned;
};
#endif // 0

class CEP931xPort
{
    
    public:

        //
        // Constructor, Initialization and destructor functions.
        //
        CEP931xPort():  m_hIdeIntEvent(0), 
                        m_hDmaIntEvent(0),
                        m_pulDmaBase( DMA_M2M0_BASE),
                        m_bDMAState(FALSE)
        {
            InitializeCriticalSection( &m_CriticalSection);
        }

        ~CEP931xPort();
        BOOL        Init();


        //
        // Functions used for critical sections.
        //
        inline void TakeCS() { EnterCriticalSection( &m_CriticalSection); }
        inline void ReleaseCS() { LeaveCriticalSection( &m_CriticalSection); }


        //
        // Dma functions. 
        //
        BOOL SetupDMA( PSG_BUF pSgBuf, DWORD dwSgCount, BOOL fRead, ULONG ulCurrentMode);   
        BOOL BeginDMA(BOOL fRead);                                     
        BOOL EndDMA();                                                 
        BOOL AbortDMA();                                               
        BOOL CompleteDMA(PSG_BUF pSgBuf, DWORD dwSgCount, BOOL fRead); 

        void PIOMode(void);

        //
        // Debug functions.
        //
        void DumpDmaState(void);
        void DumpIDEState(void);

        HANDLE              m_hIdeIntEvent;
        BOOL                m_bDMAState;
    private:
        //
        // DMA base address
        //
        volatile ULONG  *   m_pulDmaBase;

        //
        // Critical section to prevent the master and slave from talking at
        // the same time.
        //
        CRITICAL_SECTION    m_CriticalSection;

        //
        // The M2M dma event.
        //
        HANDLE              m_hDmaIntEvent;

        //
        // These are physical and virtual pointers to a DMA buffer if the scatter
        // gather list that is passed in is unaligned.
        //
        // This buffer is static.
        //
        PUCHAR              m_pucStaticBuffer;
        ULONG               m_ulStaticPhysBuff;

        //
        // If the DMA buffer is aligned then just dma it into memory.
        //
        PUCHAR              m_pucDmaBuffer;
        ULONG               m_ulDmaPhysBuff;
        ULONG               m_ulDmaCount;

        //
        // Contains the value of the current dma control register.
        //
        ULONG               m_ulDmaCtrlReg;


        //
        // Current IDE mode.
        //
        DWORD               m_ulCurrentMode;


        //
        // Save the information for the scatter gather buffers.
        //
        PSG_BUF         m_pDMASgBuf;
        DWORD           m_dwDMASgCount;
        BOOL            m_fDMARead;
        BOOL            m_fAligned;

        //
        // Get the Page shift values so that I don't have to perform a
        // multiply
        //
        ULONG           m_ulPageShift;
};

class CEP931xDisk : public CDisk
{
    public:
        CEP931xDisk(CEP931xPort *pPort, HKEY hDevKey);
        
        //
        // Initialization function.
        //
        virtual BOOL Init(HKEY hActiveKey);

    
        //
        // Critical Section functions.
        //
        virtual void TakeCS()
        {
            m_pPort->TakeCS();
        }    
        virtual void ReleaseCS()
        {
            m_pPort->ReleaseCS();
        }    


        //
        // Dma functions. Currently only using PIO for Disk access.
        //
        virtual BOOL SetupDMA( PSG_BUF pSgBuf, DWORD dwSgCount, BOOL fRead)
        {
            return m_pPort->SetupDMA( pSgBuf, dwSgCount, fRead, m_dwTransferModeCurrent);
        }

        virtual BOOL BeginDMA(BOOL fRead)
        {
            return m_pPort->BeginDMA(fRead);
        }                                     
        virtual BOOL EndDMA()
        {
            return m_pPort->EndDMA();
        }                                                 
        virtual BOOL AbortDMA()
        {
            return m_pPort->AbortDMA();
        }                                               
        virtual BOOL CompleteDMA(PSG_BUF pSgBuf, DWORD dwSgCount, BOOL fRead)
        {
            return m_pPort->CompleteDMA(pSgBuf, dwSgCount, fRead);
        } 
        virtual void SetBestTransferMode();


        //
        // Interrupt functions.
        //
        virtual BOOL WaitForInterrupt(DWORD dwTimeOut); 
        virtual void EnableInterrupt();

        //
        // This status function ack's the interrupt
        virtual BYTE GetAltStatus();
        virtual BYTE GetBaseStatus();
        virtual BYTE GetError();
        virtual BYTE GetReason();
        virtual void SelectDevice();
        virtual void WriteDriveController(BYTE bData);
        virtual void WriteAltDriveController(BYTE bData);
        virtual void SetDriveHead(BYTE bDriveHead);
        virtual void WriteCommand(BYTE bCommand);
        virtual void WriteFeature(BYTE bFeature);
        virtual void WriteSectorCount(BYTE bValue);
        virtual void WriteDriveHeadReg(BYTE bValue);
        virtual void WriteSectorNumber(BYTE bValue);
        virtual void WriteLowCount(BYTE bValue);
        virtual void WriteHighCount(BYTE bValue);
        virtual BYTE GetLowCount();
        virtual BYTE GetHighCount();
        virtual void ReadWordBuffer( PWORD pBuffer, DWORD dwCount);
        virtual void WriteWordBuffer( PWORD pBuffer, DWORD dwCount);
        virtual void ReadByteBuffer( PBYTE pBuffer, DWORD dwCount);
        virtual void WriteByteBuffer( PBYTE pBuffer, DWORD dwCount);
        virtual void WriteWord(WORD wData);
        virtual WORD ReadWord();
        virtual void WriteByte(BYTE bData);
        virtual WORD ReadByte();
    private:

        void TestRoutines(void);
        CEP931xPort *   m_pPort;
        //SGBuffInfo *    m_pMySgBuff;
};


#endif // _H_EP931XDISK

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -