HDLC WINCE6驱动设计

来源:互联网 发布:怎么连接kad电骡网络 编辑:程序博客网 时间:2024/06/08 00:49

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 ofProtocolXXXfunctions 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 aMiniportXXX 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 theNdisSendor NdisSendPacketsfunction. A protocol driver must call theNdisRequestfunction 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 NdisXXXfunction exported by the NDIS library. NDIS then passes the packet to the miniport by calling the appropriateMiniportXXX function exported by the miniport. The miniport driver then forwards the packet to the NIC for transmission by calling the appropriateNdisXXX 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 appropriateMiniportXXX 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 appropriateNdisXXX 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 theDriverEntry 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 theNdisMInitializeWrapper function, and then theNdisMRegisterMiniport function.DriverEntryfirst calls NdisMInitializeWrapper with the parameters that are passedtoDriverEntry, which returns a wrapper handle. DriverEntry thenpasses the handle toNdisMRegisterMiniport.

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 toNdisMIndicateReceivePacket.

No

MiniportSend

Transmits a packet through the NIC onto the network. Required if the driver has noMiniportSendPackets 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 orMiniportDisableInterrupt.

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



0 0
原创粉丝点击