Skip to content

Commit

Permalink
Rename if_re_bsd.h and rtlhw.cpp to match BSD driver
Browse files Browse the repository at this point in the history
To make it easier to relate the BSD driver sources to the Windows driver
sources, restore the original BSD driver filenames:

- `rtlhw.cpp` -> `if_re.c`
- `if_re_bsd.h` -> `if_rereg.h`

Also, compile the BSD sources using C rules instead of C++ rules, which
hopefully make it easier to keep the BSD and Windows code aligned.

Compiling as C code requires a few fixes:

- Functions shared between C and C++ code need to be compiled as `extern
  "C"`.
- To use `bool` in C code, you have to include the `stdbool.h` header.
- During the build, the compiler can't use the same .pch for both C and
  C++ code, so only "precompile" the header for the C++ code (compile
  the C code without precompiled header acceleration).
  • Loading branch information
idigdoug committed Nov 4, 2024
1 parent 2d5ccf2 commit 0006406
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 139 deletions.
10 changes: 9 additions & 1 deletion adapter.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "bsd.h"
#include "if_re_bsd.h"
#include "if_rereg.h"
#include "bsdexport.h"

// multicast list size
Expand Down Expand Up @@ -136,9 +136,17 @@ void ConfigWrite16(_In_ RT_ADAPTER* adapter, UINT32 reg, UINT16 val);

void RtResetQueues(_In_ RT_ADAPTER* adapter);

#ifdef __cplusplus
extern "C" {
#endif

void
GetMulticastBit(
_In_ NET_ADAPTER_LINK_LAYER_ADDRESS const* address,
_Out_ _Post_satisfies_(*byte < MAX_NIC_MULTICAST_REG) UCHAR* byte,
_Out_ UCHAR* value
);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions bsdexport.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#define BSD_NT_WRAP(x) (x == 0 ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL)

#ifdef __cplusplus
extern "C" {
#endif

int re_check_mac_version(struct re_softc* sc);
void re_init_software_variable(struct re_softc* sc);
void re_exit_oob(struct re_softc* sc);
Expand All @@ -26,3 +30,7 @@ int re_ifmedia_upd_8125(struct re_softc* sc);

void re_rar_set(struct re_softc* sc, u_int8_t* eaddr);
void re_set_rx_packet_filter(struct re_softc* sc);

#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions rtlhw.cpp → if_re.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "trace.h"
#include "adapter.h"
#include <bcrypt.h>
#include <stdbool.h>
#endif // _WIN32

#ifndef _WIN32
Expand Down
9 changes: 7 additions & 2 deletions if_re.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
<ClInclude Include="ethernet.h" />
<ClInclude Include="forward.h" />
<ClInclude Include="if.h" />
<ClInclude Include="if_re_bsd.h" />
<ClInclude Include="if_rereg.h" />
<ClInclude Include="interrupt.h" />
<ClInclude Include="link.h" />
<ClInclude Include="mbuf.h" />
Expand Down Expand Up @@ -238,7 +238,12 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="rtlhw.cpp" />
<ClCompile Include="if_re.c">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="rxqueue.cpp" />
<ClCompile Include="txqueue.cpp" />
</ItemGroup>
Expand Down
275 changes: 139 additions & 136 deletions if_re.vcxproj.Filters
Original file line number Diff line number Diff line change
@@ -1,137 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
<UniqueIdentifier>{E10CB9FB-4852-4353-85F5-667D4D2A13DD}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
<UniqueIdentifier>{EC8940D8-5E2B-49AB-AB85-7CABCAE698D1}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
<UniqueIdentifier>{42A1FDF4-6DB4-41B2-9423-8002A20D1B0D}</UniqueIdentifier>
</Filter>
<Filter Include="Driver Files">
<Extensions>inf;inv;inx;mof;mc;</Extensions>
<UniqueIdentifier>{FD9F921C-D1EF-421B-A692-F23423B32E64}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\BSD">
<UniqueIdentifier>{6e28619c-acdf-4fd4-b4b4-2ffcb2d448ed}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\BSD">
<UniqueIdentifier>{88ff9f33-c59c-4c16-89a5-751652249ab0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Inf Include="if_re.inx">
<Filter>Driver Files</Filter>
</Inf>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="if_re.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="*.txt;*.htm;*.html" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="adapter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="device.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="driver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="power.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="rxqueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="txqueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="rtlhw.cpp">
<Filter>Source Files\BSD</Filter>
</ClCompile>
<ClCompile Include="pciconfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="interrupt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="link.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="configuration.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mcast.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="adapter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="device.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="forward.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="power.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="precomp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="rxqueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="trace.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="txqueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bsd.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="if_re_bsd.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="mii.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="ethernet.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="bsdexport.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="interrupt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="link.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="netringiterator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="configuration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="if.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="mbuf.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
<UniqueIdentifier>{E10CB9FB-4852-4353-85F5-667D4D2A13DD}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
<UniqueIdentifier>{EC8940D8-5E2B-49AB-AB85-7CABCAE698D1}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
<UniqueIdentifier>{42A1FDF4-6DB4-41B2-9423-8002A20D1B0D}</UniqueIdentifier>
</Filter>
<Filter Include="Driver Files">
<Extensions>inf;inv;inx;mof;mc;</Extensions>
<UniqueIdentifier>{FD9F921C-D1EF-421B-A692-F23423B32E64}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\BSD">
<UniqueIdentifier>{6e28619c-acdf-4fd4-b4b4-2ffcb2d448ed}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\BSD">
<UniqueIdentifier>{88ff9f33-c59c-4c16-89a5-751652249ab0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Inf Include="if_re.inx">
<Filter>Driver Files</Filter>
</Inf>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="if_re.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="*.txt;*.htm;*.html" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="adapter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="device.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="driver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="power.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="rxqueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="txqueue.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="if_re.c">
<Filter>Source Files\BSD</Filter>
</ClCompile>
<ClCompile Include="pciconfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="interrupt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="link.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="configuration.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mcast.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="precomp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="adapter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="device.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="forward.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="power.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="precomp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="rxqueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="trace.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="txqueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bsd.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="if_rereg.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="mii.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="ethernet.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="bsdexport.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="interrupt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="link.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="netringiterator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="configuration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="if.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
<ClInclude Include="mbuf.h">
<Filter>Header Files\BSD</Filter>
</ClInclude>
</ItemGroup>
</Project>
File renamed without changes.

0 comments on commit 0006406

Please sign in to comment.