标签:wince hdlc asynchronous 硬件 operating system
1、 WINCE的网络驱动结构
1.1 WINCE 网络结构
1)WINCE 的NDIS网络接口提供如下能力:
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:
Note Detailsmay vary depending on the CPU architecture.
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.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:
2) MINIPORT的主要工作
Typically, an NDIS miniport driver is a miniport NICdriver. An NDIS miniport driver the following two basic functions:
The following send and receive operations illustrate the interaction ofminiport NIC drivers with NDIS and with higher-level drivers:
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:
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 |
Called by the operating system to activate and initialize the miniport driver. |
Not applicable |
|
Checks the internal state of the NIC. |
No |
|
Disables the NIC from generating interrupts. |
No |
|
Enables the NIC to generate interrupts. |
No |
|
Deallocates and deregisters resources for the NIC and halts the NIC so that it is no longer functioning. |
No |
|
Deferred processing function called to complete interrupt-driven I/O processing. |
No |
|
Initializes the NIC. |
No |
|
Runs at a high priority as the interrupt service routine for the NIC. |
No |
|
Queries the capabilities and status of the miniport driver. |
Yes |
|
Currently, the NDIS library never calls this function, but a MiniportInitialize function can call a MiniportReconfigure function as an internal driver function. |
Not |
|
Issues a hardware reset to the NIC. |
Yes |
|
Receives a packet from an upper layer that was previously passed by a call to NdisMIndicateReceivePacket. |
No |
|
Transmits a packet through the NIC onto the network. Required if the driver has no MiniportSendPackets or MiniportWanSend function. |
Yes |
|
Transmits an array of packets through the NIC onto the network. |
Yes |
|
Changes information about the miniport driver or its NIC. |
Yes |
|
Restores a NIC to its initial state when the system is shut down. |
No |
|
Synchronizes access to resources shared with MiniportISR or MiniportDisableInterrupt. |
No |
|
Copies the contents of a packet received by the NIC into a given packet buffer. |
Yes |
|
Transmits a packet through the NIC onto the network. Required if the driver controls a WAN NIC. |
No |
标签:wince hdlc asynchronous 硬件 operating system
原文地址:http://blog.csdn.net/cnhighway/article/details/44520887