update for HEAD-2003091401
[reactos.git] / drivers / net / ndis / ndis / main.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS NDIS library
4  * FILE:        ndis/main.c
5  * PURPOSE:     Driver entry point
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  *              Vizzini (vizzini@plasmic.com)
8  * REVISIONS:
9  *   CSH 01/08-2000 Created
10  *   8/20/2003 Vizzini - NDIS4/5 revisions
11  */
12 #include <ndissys.h>
13 #include <protocol.h>
14 #include <miniport.h>
15
16
17 #ifdef DBG
18
19 /* See debug.h for debug/trace constants */
20 DWORD DebugTraceLevel = MIN_TRACE;
21
22 #endif /* DBG */
23
24 /* see miniport.c */
25 extern KSPIN_LOCK OrphanAdapterListLock;
26 extern LIST_ENTRY OrphanAdapterListHead;
27
28 VOID MainUnload(
29     PDRIVER_OBJECT DriverObject)
30 /*
31  * FUNCTION: Unloads the driver
32  * ARGUMENTS:
33  *     DriverObject = Pointer to driver object created by the system
34  */
35 {
36     NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
37 }
38
39 NTSTATUS
40 STDCALL
41 DriverEntry(
42     PDRIVER_OBJECT DriverObject,
43     PUNICODE_STRING RegistryPath)
44 /*
45  * FUNCTION: Main driver entry point
46  * ARGUMENTS:
47  *     DriverObject = Pointer to a driver object for this driver
48  *     RegistryPath = Registry node for configuration parameters
49  * RETURNS:
50  *     Status of driver initialization
51  */
52 {
53   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
54
55   InitializeListHead(&ProtocolListHead);
56   KeInitializeSpinLock(&ProtocolListLock);
57
58   InitializeListHead(&MiniportListHead);
59   KeInitializeSpinLock(&MiniportListLock);
60
61   InitializeListHead(&AdapterListHead);
62   KeInitializeSpinLock(&AdapterListLock);
63
64   InitializeListHead(&OrphanAdapterListHead);
65   KeInitializeSpinLock(&OrphanAdapterListLock);
66
67   DriverObject->DriverUnload = (PDRIVER_UNLOAD)MainUnload;
68
69   /* 
70    * until we have PNP support, query the enum key and NdisFindDevice() each one
71    * NOTE- this will load and start other services before this one returns STATUS_SUCCESS.
72    * I hope there aren't code reentrancy problems. :) 
73    */
74   NdisStartDevices();
75
76   return STATUS_SUCCESS;
77 }
78
79 /*
80  * @implemented
81  */
82 VOID
83 CDECL
84 NdisWriteErrorLogEntry(
85     IN  NDIS_HANDLE     NdisAdapterHandle,
86     IN  NDIS_ERROR_CODE ErrorCode,
87     IN  ULONG           NumberOfErrorValues,
88     IN  ULONG           ERROR_LOG_MAXIMUM_SIZE)
89 /*  IN  ULONG           ...) 
90  *  ERROR_LOG_MAXIMUM_SIZE = ... in MSDN
91  */
92 /*
93  * FUNCTION: Write a syslog error
94  * ARGUMENTS:
95  *     NdisAdapterHandle:  Handle passed into MiniportInitialize
96  *     ErrorCode:  32-bit error code to be logged
97  *     NumberOfErrorValues: number of errors to log
98  *     Variable: list of log items
99  * NOTES:
100  *     - THIS IS >CDECL<
101  *     - This needs to be fixed to do var args
102  *     - FIXME - this needs to be properly implemented once we have an event log
103  */
104 {
105   NDIS_DbgPrint(MIN_TRACE, ("ERROR: ErrorCode 0x%x\n", ErrorCode));
106
107 #if DBG
108   /* break into a debugger so we can see what's up */
109   __asm__("int $3\n");
110 #endif
111 }
112
113 /*
114  * @implemented
115  */
116 VOID
117 EXPORT
118 NdisInitializeReadWriteLock(
119     IN  PNDIS_RW_LOCK   Lock)
120 /*
121  * FUNCTION: Initialize a NDIS_RW_LOCK
122  * ARGUMENTS:
123  *     Lock: pointer to the lock to initialize
124  * NOTES:
125  *    NDIS 5.0
126  */
127 {
128   memset(Lock,0,sizeof(NDIS_RW_LOCK));
129 }
130
131 /*
132  * @implemented
133  */
134 NDIS_STATUS
135 EXPORT
136 NdisWriteEventLogEntry(
137     IN  PVOID       LogHandle,
138     IN  NDIS_STATUS EventCode,
139     IN  ULONG       UniqueEventValue,
140     IN  USHORT      NumStrings,
141     IN  PVOID       StringsList OPTIONAL,
142     IN  ULONG       DataSize,
143     IN  PVOID       Data        OPTIONAL)
144 /*
145  * FUNCTION: Log an event in the system event log
146  * ARGUMENTS:
147  *     LogHandle: pointer to the driver object of the protocol logging the event
148  *     EventCode: NDIS_STATUS_XXX describing the event
149  *     UniqueEventValue: identifiees this instance of the error value
150  *     NumStrings: number of strings in StringList
151  *     StringList: list of strings to log
152  *     DataSize: number of bytes in Data
153  *     Data: binary dump data to help analyzing the event
154  * NOTES:
155  *     - STDCALL, not CDECL like WriteError...
156  *     - FIXME Needs to use the real log interface, once there is one
157  */
158 {
159   /*
160    * just returning true until we have an event log
161    */
162   NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
163   return NDIS_STATUS_SUCCESS;
164 }
165
166 /* EOF */
167