Skip to content

Commit

Permalink
[B57XX] Driver boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
nothotscott authored and DarkFire01 committed Nov 11, 2024
1 parent c99e246 commit 292b4b6
Show file tree
Hide file tree
Showing 12 changed files with 1,632 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/network/dd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

add_subdirectory(dc21x4)
add_subdirectory(b57xx)
add_subdirectory(e1000)
add_subdirectory(ne2000)
add_subdirectory(netkvm)
Expand Down
20 changes: 20 additions & 0 deletions drivers/network/dd/b57xx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

add_definitions(
-DNDIS50_MINIPORT
-DNDIS_MINIPORT_DRIVER
-DNDIS_LEGACY_MINIPORT)

list(APPEND SOURCE
ndis.c
hardware.c
info.c
interrupt.c
nic.h
send.c)

add_library(b57xx MODULE ${SOURCE} b57xx.rc)
add_pch(b57xx nic.h SOURCE)
set_module_type(b57xx kernelmodedriver)
add_importlibs(b57xx ndis ntoskrnl hal)
add_cd_file(TARGET b57xx DESTINATION reactos/system32/drivers FOR all)
add_driver_inf(b57xx netb57xx.inf)
5 changes: 5 additions & 0 deletions drivers/network/dd/b57xx/b57xx.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Broadcom NetXtreme Driver"
#define REACTOS_STR_INTERNAL_NAME "b57xx"
#define REACTOS_STR_ORIGINAL_FILENAME "b57xx.sys"
#include <reactos/version.rc>
22 changes: 22 additions & 0 deletions drivers/network/dd/b57xx/b57xxhw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* PROJECT: ReactOS Broadcom NetXtreme Driver
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Hardware specific definitions
* COPYRIGHT: Copyright 2021 Scott Maday <[email protected]>
*/
#pragma once

#define IEEE_802_ADDR_LENGTH 6

#define MAX_RESET_ATTEMPTS 10
#define MAX_EEPROM_READ_ATTEMPTS 10000

#define MAXIMUM_MULTICAST_ADDRESSES 16

/* Ethernet frame header */
typedef struct _ETH_HEADER
{
UCHAR Destination[IEEE_802_ADDR_LENGTH];
UCHAR Source[IEEE_802_ADDR_LENGTH];
USHORT PayloadType;
} ETH_HEADER, *PETH_HEADER;
92 changes: 92 additions & 0 deletions drivers/network/dd/b57xx/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* PROJECT: ReactOS Broadcom NetXtreme Driver
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Debugging support macros
* DEFINES: DBG - Enable debug output
* NASSERT - Disable assertions
*/
#pragma once

#define NORMAL_MASK 0x000000FF
#define SPECIAL_MASK 0xFFFFFF00
#define MIN_TRACE 0x00000001
#define MID_TRACE 0x00000002
#define MAX_TRACE 0x00000003

#define DEBUG_MEMORY 0x00000100
#define DEBUG_ULTRA 0xFFFFFFFF

#if DBG

extern ULONG DebugTraceLevel;

#ifdef _MSC_VER

#define NDIS_DbgPrint(_t_, _x_) \
if ((_t_ > NORMAL_MASK) \
? (DebugTraceLevel & _t_) > NORMAL_MASK \
: (DebugTraceLevel & NORMAL_MASK) >= _t_) { \
DbgPrint("(%s:%d) ", __FILE__, __LINE__); \
DbgPrint _x_ ; \
}

#else /* _MSC_VER */

#define NDIS_DbgPrint(_t_, _x_) \
if ((_t_ > NORMAL_MASK) \
? (DebugTraceLevel & _t_) > NORMAL_MASK \
: (DebugTraceLevel & NORMAL_MASK) >= _t_) { \
DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
DbgPrint _x_ ; \
}

#endif /* _MSC_VER */


#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql() == (x))

#else /* DBG */

#define NDIS_DbgPrint(_t_, _x_)

#define ASSERT_IRQL(x)
#define ASSERT_IRQL_EQUAL(x)
/* #define ASSERT(x) */ /* ndis.h */

#endif /* DBG */


#define assert(x) ASSERT(x)
#define assert_irql(x) ASSERT_IRQL(x)


#ifdef _MSC_VER

#define UNIMPLEMENTED \
NDIS_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \
but come back another day.\n", __FILE__, __LINE__));

#else /* _MSC_VER */

#define UNIMPLEMENTED \
NDIS_DbgPrint(MIN_TRACE, ("%s at %s:%d is unimplemented, \
but come back another day.\n", __FUNCTION__, __FILE__, __LINE__));

#endif /* _MSC_VER */

#define UNIMPLEMENTED_DBGBREAK(...) \
do { \
NDIS_DbgPrint(MIN_TRACE, ("UNIMPLEMENTED.\n")); \
DbgPrint("" __VA_ARGS__); \
DbgBreakPoint(); \
} while (0)


#define CHECKPOINT \
do { NDIS_DbgPrint(MIN_TRACE, ("%s:%d\n", __FILE__, __LINE__)); } while(0);


#define NDIS_MinDbgPrint(...) NDIS_DbgPrint(MIN_TRACE, (__VA_ARGS__))

/* EOF */
Loading

0 comments on commit 292b4b6

Please sign in to comment.