HDLC WINCE6驅動設計

1、 WINCE的網絡驅動結構

1.1  WINCE 網絡結構

1)WINCE 的NDIS網絡接口提供如下能力:

  • miniport 網卡驅動接口
  • 支持802.3(MAC),802.5(RING),IRDA
  • 支持廣域網
  • 動態綁定網卡和Plug and Play
  • 支持同一個協議綁定多個網卡
  • 支持網卡的MediaSense

2)WINCE的網絡結構圖

從該通信結構中可以看到,所有的通信協議都使用NDIS WRAPPER 作爲中介和下層的硬件綁定,實現各種不同的通信。

3)NDIS Wrapper的結構

The operating system providesprotocol drivers for TCP/IP, Point-to-Point Protocol (PPP), and Infrared DataAssociation (IrDA). A protocol driver exports a set of ProtocolXXXfunctions at its lower edge. It communicates with NDIS to send and receivenetwork packets and to bind to an underlying miniport network adapter driver orintermediate NDIS driver that exports a MiniportXXX interface atits upper edge.

Protocol drivers that communicate with underlying NDISdrivers call NDIS library functions to send and receive packets. To send apacket to an underlying NDIS driver, a protocol driver must call the NdisSendor NdisSendPacketsfunction. A protocol driver must call the NdisRequestfunction to forward a request to the underlying driver that it queries for thecapabilities or status of its network adapter or that it set the state of itsnetwork adapter.

An NDIS protocol driver can support Transport DriverInterface (TDI) at its upper edge, or it could export a private interface to ahigher-level kernel-mode driver, possibly through a transport stack of drivers,including one that supports TDI at the top of the stack. For example, an NDISprotocol driver can be the lowest module of a multi-module transportimplementation of a standard protocol, such as TCP/IP, with TDI support in thehighest module.

1.2   WINCE 中斷結構

 典型的中斷流程如下:

The following list shows an example interrupt handling sequence:

  1. If the kernel's exception-trapping code receives a hardware interrupt and then the kernel detects an exception, the kernel handles the hardware interrupt. Otherwise, go to the next step.
  2. The kernel's interrupt support handler notifies the ISR to disable the specific interrupt until the required handling completes. All other interrupts remain enabled.
  3. The exception handler calls the ISR to determine how to handle the interrupt.

Note   Detailsmay vary depending on the CPU architecture.

  1. The kernel receives the return value from the ISR, which lets the kernel know what to do about the interrupt. The following table shows the possible responses from the kernel.

Response

Description

SYSINTR_NOP

The kernel does nothing.

SYSINTR_RESCHED

The interrupt was for the thread scheduling timer tick.

SYSINTR_XXX, logical interrupt value for that specific interrupt source.

The kernel triggers its interrupt support handler so the IST wakes up and does its work. Then the IST creates an event and then waits on it.

  1. When the IST wakes up, the IST does whatever work it needs to do to handle the interrupt. This could mean moving data into a buffer or interpreting the data in some meaningful way.
  2. As needed, the IST calls various I/O routines to access the hardware to do its work.
  3. When the IST finishes its work, it notifies the kernel by calling InterruptDone.
Thekernel calls the OAL function OEMInterruptDone to complete all handling for theinterrupt. The OAL notifies the hardware to re-enable the interrupt.


1.1  MINIPORT接口介紹

1) MINIPORT 定義

Miniportdrivers directly manage network adapters that are installed on a device. At thelower edge, miniport drivers use NDIS to communicate with the adapter hardware.At the upper edge, miniport drivers present an interface to allow protocoldrivers to configure the adapter and to send and receive packets over thenetwork.

Windows CE currently supports miniport drivers for thefollowing medium types:

  • Ethernet (802.3)
  • Token Ring (802.5)
  • IrDA
  • WAN

 

2) MINIPORT的主要工作

Typically, an NDIS miniport driver is a miniport NICdriver. An NDIS miniport driver the following two basic functions:

  • Manages a network interface card (NIC), including sending and receiving data through the NIC
  • Interfaces with higher-level drivers, such as intermediate drivers and transport protocol drivers

The following send and receive operations illustrate the interaction ofminiport NIC drivers with NDIS and with higher-level drivers:

  • When a transport driver has a packet to transmit, it calls an NdisXXX function exported by the NDIS library. NDIS then passes the packet to the miniport by calling the appropriate MiniportXXX function exported by the miniport. The miniport driver then forwards the packet to the NIC for transmission by calling the appropriate NdisXXX function.
  • When a NIC receives a packet addressed to the NIC, it can post a hardware interrupt that is handled by NDIS or the NIC's miniport. NDIS notifies the NIC's miniport by calling the appropriate MiniportXXX function. The miniport sets up the transfer of data from the NIC and then indicates the presence of the received packet to bound higher-level drivers by calling the appropriate NdisXXX function.

 

3) Miniport驅動的加載

All NDIS miniport and intermediate drivers must provide a DriverEntry function. When a miniport driver isloaded, the operating system creates a driver object for the miniport driverand calls the DriverEntry function, which creates an association betweenthe miniport driver and the NDIS library and registers the miniport with NDIS.

The following parameters are passed to the DriverEntry function:

  • A pointer to the driver object, which was created by the I/O system
  • A pointer to the registry path, which specifies where driver-specific parameters are stored

Within the context of DriverEntry, the miniport calls the NdisMInitializeWrapper function, and then the NdisMRegisterMiniport function. DriverEntryfirst calls NdisMInitializeWrapper with the parameters that are passedto DriverEntry, which returns a wrapper handle. DriverEntry thenpasses the handle to NdisMRegisterMiniport.

The following illustration shows the process for registering a miniportdriver and initializing the NDIS library.

 

1) Miniport需要實現的函數

Function

Description

Asynchronous operation

DriverEntry

Called by the operating system to activate and initialize the miniport driver.

Not applicable

MiniportCheckForHang

Checks the internal state of the NIC.

No

MiniportDisableInterrupt

Disables the NIC from generating interrupts.

No

MiniportEnableInterrupt

Enables the NIC to generate interrupts.

No

MiniportHalt

Deallocates and deregisters resources for the NIC and halts the NIC so that it is no longer functioning.

No

MiniportHandleInterrupt

Deferred processing function called to complete interrupt-driven I/O processing.

No

MiniportInitialize

Initializes the NIC.

No

MiniportISR

Runs at a high priority as the interrupt service routine for the NIC.

No

MiniportQueryInformation

Queries the capabilities and status of the miniport driver.

Yes

MiniportReconfigure

Currently, the NDIS library never calls this function, but a MiniportInitialize function can call a MiniportReconfigure function as an internal driver function.

Not
Applicable

MiniportReset

Issues a hardware reset to the NIC.

Yes

MiniportReturnPacket

Receives a packet from an upper layer that was previously passed by a call to NdisMIndicateReceivePacket.

No

MiniportSend

Transmits a packet through the NIC onto the network. Required if the driver has no MiniportSendPackets or MiniportWanSend function.

Yes

MiniportSendPackets

Transmits an array of packets through the NIC onto the network.

Yes

MiniportSetInformation

Changes information about the miniport driver or its NIC.

Yes

MiniportShutdown

Restores a NIC to its initial state when the system is shut down.

No

MiniportSynchronizeISR

Synchronizes access to resources shared with MiniportISR or MiniportDisableInterrupt.

No

MiniportTransferData

Copies the contents of a packet received by the NIC into a given packet buffer.

Yes

MiniportWanSend

Transmits a packet through the NIC onto the network. Required if the driver controls a WAN NIC.

No



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章