ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/b2ether/driver/b2ether_write.c
Revision: 1.1
Committed: 2012-04-21T16:23:07Z (12 years, 2 months ago) by asvitkine
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
Import b2ether driver sources from a 2001 source archive of BasiliskII.

File Contents

# Content
1 /*
2 * b2ether driver -- derived from DDK packet driver sample
3 *
4 * Basilisk II (C) 1997-1999 Christian Bauer
5 *
6 * Windows platform specific code copyright (C) Lauri Pesonen
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #include "stdarg.h"
24 #include "ntddk.h"
25 #include "ntiologc.h"
26 #include "ndis.h"
27 #include "b2ether.h"
28
29 #undef DBG
30 #define DBG 0
31 #include "debug.h"
32
33
34 NTSTATUS PacketWrite(
35 IN PDEVICE_OBJECT DeviceObject,
36 IN PIRP Irp
37 )
38 {
39 POPEN_INSTANCE Open;
40 PIO_STACK_LOCATION IrpSp;
41 PNDIS_PACKET pPacket;
42
43 NDIS_STATUS Status;
44
45 IF_LOUD(DbgPrint("Packet: SendAdapter\n");)
46
47 IrpSp = IoGetCurrentIrpStackLocation(Irp);
48
49 Open = IrpSp->FileObject->FsContext;
50
51 // Try to get a packet from our list of free ones
52 NdisAllocatePacket( &Status, &pPacket, Open->PacketPool );
53 if (Status != NDIS_STATUS_SUCCESS) {
54 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
55 Irp->IoStatus.Information = 0;
56 IoCompleteRequest(Irp, IO_NO_INCREMENT);
57 return STATUS_UNSUCCESSFUL;
58 }
59
60 RESERVED(pPacket)->Irp=Irp;
61
62 // Attach the writes buffer to the packet
63 NdisChainBufferAtFront(pPacket,Irp->MdlAddress);
64
65 IoMarkIrpPending(Irp);
66 Irp->IoStatus.Status = STATUS_PENDING;
67
68 // Call the MAC
69 NdisSend( &Status, Open->AdapterHandle, pPacket );
70
71 if (Status != NDIS_STATUS_PENDING) {
72 PacketSendComplete( Open, pPacket, Status );
73 }
74
75 return(STATUS_PENDING);
76 }
77
78
79 VOID PacketSendComplete(
80 IN NDIS_HANDLE ProtocolBindingContext,
81 IN PNDIS_PACKET pPacket,
82 IN NDIS_STATUS Status
83 )
84 {
85 PIRP Irp;
86
87 IF_LOUD(DbgPrint("Packet: SendComplete\n");)
88
89 Irp = RESERVED(pPacket)->Irp;
90
91 // recyle the packet
92 NdisReinitializePacket(pPacket);
93
94 // Put the packet back on the free list
95 NdisFreePacket(pPacket);
96
97 Irp->IoStatus.Status = Status;
98
99 // a known bug, but I don't need this information
100 Irp->IoStatus.Information = 0;
101
102 IoCompleteRequest(Irp, IO_NO_INCREMENT);
103 }