Commit the first cut of Project Evil, also known as the NDISulator.
Yes, it's what you think it is. Yes, you should run away now. This is a special compatibility module for allowing Windows NDIS miniport network drivers to be used with FreeBSD/x86. This provides _binary_ NDIS compatibility (not source): you can run NDIS driver code, but you can't build it. There are three main parts: sys/compat/ndis: the NDIS compat API, which provides binary compatibility functions for many routines in NDIS.SYS, HAL.dll and ntoskrnl.exe in Windows (these are the three modules that most NDIS miniport drivers use). The compat module also contains a small PE relocator/dynalinker which relocates the Windows .SYS image and then patches in our native routines. sys/dev/if_ndis: the if_ndis driver wrapper. This module makes use of the ndis compat API and can be compiled with a specially prepared binary image file (ndis_driver_data.h) containing the Windows .SYS image and registry key information parsed out of the accompanying .INF file. Once if_ndis.ko is built, it can be loaded and unloaded just like a native FreeBSD kenrel module. usr.sbin/ndiscvt: a special utility that converts foo.sys and foo.inf into an ndis_driver_data.h file that can be compiled into if_ndis.o. Contains an .inf file parser graciously provided by Matt Dodd (and mercilessly hacked upon by me) that strips out device ID info and registry key info from a .INF file and packages it up with a binary image array. The ndiscvt(8) utility also does some manipulation of the segments within the .sys file to make life easier for the kernel loader. (Doing the manipulation here saves the kernel code from having to move things around later, which would waste memory.) ndiscvt is only built for the i386 arch. Only files.i386 has been updated, and none of this is turned on in GENERIC. It should probably work on pc98. I have no idea about amd64 or ia64 at this point. This is still a work in progress. I estimate it's about %85 done, but I want it under CVS control so I can track subsequent changes. It has been tested with exactly three drivers: the LinkSys LNE100TX v4 driver (Lne100v4.sys), the sample Intel 82559 driver from the Windows DDK (e100bex.sys) and the Broadcom BCM43xx wireless driver (bcmwl5.sys). It still needs to have a net80211 stuff added to it. To use it, you would do something like this: # cd /sys/modules/ndis # make; make load # cd /sys/modules/if_ndis # ndiscvt -i /path/to/foo.inf -s /path/to/foo.sys -o ndis_driver_data.h # make; make load # sysctl -a | grep ndis All registry keys are mapped to sysctl nodes. Sometimes drivers refer to registry keys that aren't mentioned in foo.inf. If this happens, the NDIS API module creates sysctl nodes for these keys on the fly so you can tweak them. An example usage of the Broadcom wireless driver would be: # sysctl hw.ndis0.EnableAutoConnect=1 # sysctl hw.ndis0.SSID="MY_SSID" # sysctl hw.ndis0.NetworkType=0 (0 for bss, 1 for adhoc) # ifconfig ndis0 <my ipaddr> netmask 0xffffff00 up Things to be done: - get rid of debug messages - add in ndis80211 support - defer transmissions until after a status update with NDIS_STATUS_CONNECTED occurs - Create smarter lookaside list support - Split off if_ndis_pci.c and if_ndis_pccard.c attachments - Make sure PCMCIA support works - Fix ndiscvt to properly parse PCMCIA device IDs from INF files - write ndisapi.9 man page
This commit is contained in:
parent
0d27d14070
commit
c854fc1092
@ -4,7 +4,7 @@ MAN= aic.4 alpm.4 amdpm.4 apm.4 ar.4 asc.4 \
|
||||
CPU_ELAN.4 cs.4 cx.4 cy.4 \
|
||||
el.4 ep.4 ex.4 fe.4 gsc.4 \
|
||||
ie.4 io.4 le.4 linux.4 lnc.4 longrun.4 mcd.4 \
|
||||
mse.4 npx.4 \
|
||||
mse.4 ndis.4 npx.4 \
|
||||
pae.4 pcf.4 perfmon.4 pnp.4 pnpbios.4 \
|
||||
ray.4 rdp.4 sbni.4 smapi.4 scd.4 \
|
||||
spkr.4 sr.4 streams.4 svr4.4 \
|
||||
|
124
share/man/man4/man4.i386/ndis.4
Normal file
124
share/man/man4/man4.i386/ndis.4
Normal file
@ -0,0 +1,124 @@
|
||||
.\" Copyright (c) 2003
|
||||
.\" Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by Bill Paul.
|
||||
.\" 4. Neither the name of the author nor the names of any co-contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
.\" THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 10, 2003
|
||||
.Dt NDIS 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm ndis
|
||||
.Nd NDIS miniport driver wrapper
|
||||
.Sh SYNOPSIS
|
||||
.Cd "options NDISAPI"
|
||||
.Cd "device ndis"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver is a wrapper designed to allow binary Windows(r) NDIS miniport
|
||||
network drivers to be used with
|
||||
.Fx .
|
||||
The
|
||||
.Nm
|
||||
driver is provided in source code form and must be combined with
|
||||
the Windows(r) driver supplied with your network adapter. The
|
||||
.Nm
|
||||
driver uses the
|
||||
.Xr ndisapi 9
|
||||
kernel subsystem to relocate and link the Windows(r) binary so
|
||||
that it can be used in conjunction with native code. The
|
||||
.Xr ndisapi 9
|
||||
subsystem provides an interface between the NDIS API and the
|
||||
.Fx
|
||||
networking infrastructure. The Windows(r) driver is essentially
|
||||
fooled into thinking it's running on Windows(r). Note that this
|
||||
means the
|
||||
.Nm
|
||||
driver is only useful on x86 machines.
|
||||
.Pp
|
||||
To build a functional driver, the user must have a copy of the
|
||||
driver distribution media for his or her card. From this distribution,
|
||||
the user must extract two files: the .SYS file containing the driver
|
||||
binary code, and its companion .INF file, which contains the
|
||||
definitions for driver-specific registry keys and other installation
|
||||
data such as device identifiers. These two files can be converted
|
||||
into a
|
||||
.Pa ndis_driver_data.h
|
||||
file using the
|
||||
.Xr ndiscvt 8
|
||||
utility. This file contains a binary image of the driver plus
|
||||
registry key data. When the
|
||||
.Nm
|
||||
driver loads, it will create
|
||||
.Xr sysctl 9
|
||||
nodes for each registry key extracted from the .INF file.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver is designed to support mainly ethernet and wireless
|
||||
network devices with PCI and PCMCIA bus attachments. (Cardbus
|
||||
devices are also supported as a subset of PCI.) It there can
|
||||
support many different media types and speeds. One limitation
|
||||
however, is that there is no consistent way to learn if an
|
||||
ethernet device is operating in full or half duplex mode.
|
||||
The NDIS API allows for a generic means for determining link
|
||||
state and speed, but not the duplex setting. There may be
|
||||
driver-specific registry keys to control the media setting
|
||||
which can be configured via the
|
||||
.Xr sysctl 8
|
||||
command.
|
||||
.Sh DIAGNOSTICS
|
||||
.Bl -diag
|
||||
.It "ndis%d: watchdog timeout"
|
||||
A packet was queued for transmission and a transmit command was
|
||||
issued, however the device failed to acknowledge the transmission
|
||||
before a timeout expired.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr arp 4 ,
|
||||
.Xr netintro 4 ,
|
||||
.Xr ng_ether 4 ,
|
||||
.Xr ifconfig 8 ,
|
||||
.Xr ndisapi 9,
|
||||
.Xr ndiscvt 8
|
||||
.Rs
|
||||
.%T "NDIS 5.1 specification"
|
||||
.%O http://www.microsoft.com
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 5.3 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Bill Paul Aq wpaul@windriver.com .
|
46
sys/compat/ndis/cfg_var.h
Normal file
46
sys/compat/ndis/cfg_var.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _CFG_VAR_H_
|
||||
#define _CFG_VAR_H_
|
||||
|
||||
struct ndis_cfg {
|
||||
char *nc_cfgkey;
|
||||
char *nc_cfgdesc;
|
||||
char nc_val[256];
|
||||
};
|
||||
|
||||
typedef struct ndis_cfg ndis_cfg;
|
||||
|
||||
#endif /* _CFG_VAR_H_ */
|
40
sys/compat/ndis/hal_var.h
Normal file
40
sys/compat/ndis/hal_var.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _HAL_VAR_H_
|
||||
#define _HAL_VAR_H_
|
||||
|
||||
extern image_patch_table hal_functbl[];
|
||||
|
||||
#endif /* _HAL_VAR_H_ */
|
1049
sys/compat/ndis/kern_ndis.c
Normal file
1049
sys/compat/ndis/kern_ndis.c
Normal file
File diff suppressed because it is too large
Load Diff
1174
sys/compat/ndis/ndis_var.h
Normal file
1174
sys/compat/ndis/ndis_var.h
Normal file
File diff suppressed because it is too large
Load Diff
105
sys/compat/ndis/ntoskrnl_var.h
Normal file
105
sys/compat/ndis/ntoskrnl_var.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _NTOSKRNL_VAR_H_
|
||||
#define _NTOSKRNL_VAR_H_
|
||||
|
||||
typedef uint32_t kspin_lock;
|
||||
|
||||
struct slist_entry {
|
||||
struct slist_entry *sl_next;
|
||||
};
|
||||
|
||||
typedef struct slist_entry slist_entry;
|
||||
|
||||
union slist_header {
|
||||
uint64_t slh_align;
|
||||
struct {
|
||||
struct slist_entry *slh_next;
|
||||
uint16_t slh_depth;
|
||||
uint16_t slh_seq;
|
||||
} slh_list;
|
||||
};
|
||||
|
||||
typedef union slist_header slist_header;
|
||||
|
||||
struct general_lookaside {
|
||||
slist_header gl_listhead;
|
||||
uint16_t gl_depth;
|
||||
uint16_t gl_maxdepth;
|
||||
uint32_t gl_totallocs;
|
||||
union {
|
||||
uint32_t gl_allocmisses;
|
||||
uint32_t gl_allochits;
|
||||
} u_a;
|
||||
uint32_t gl_totalfrees;
|
||||
union {
|
||||
uint32_t gl_freemisses;
|
||||
uint32_t gl_freehits;
|
||||
} u_m;
|
||||
uint32_t gl_type;
|
||||
uint32_t gl_tag;
|
||||
uint32_t gl_size;
|
||||
void *gl_allocfunc;
|
||||
void *gl_freefunc;
|
||||
uint32_t gl_lasttotallocs;
|
||||
union {
|
||||
uint32_t gl_lastallocmisses;
|
||||
uint32_t gl_lastallochits;
|
||||
} u_l;
|
||||
uint32_t gl_rsvd[2];
|
||||
};
|
||||
|
||||
typedef struct general_lookaside general_lookaside;
|
||||
|
||||
struct npaged_lookaside_list {
|
||||
general_lookaside nll_l;
|
||||
kspin_lock nll_obsoletelock;
|
||||
};
|
||||
|
||||
typedef struct npaged_lookaside_list npaged_lookaside_list;
|
||||
typedef struct npaged_lookaside_list paged_lookaside_list;
|
||||
|
||||
typedef void * (*lookaside_alloc_func)(uint32_t, size_t, uint32_t);
|
||||
typedef void (*lookaside_free_func)(void *);
|
||||
|
||||
|
||||
extern image_patch_table ntoskrnl_functbl[];
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern int ntoskrnl_libinit(void);
|
||||
extern int ntoskrnl_libfini(void);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _NTOSKRNL_VAR_H_ */
|
330
sys/compat/ndis/pe_var.h
Normal file
330
sys/compat/ndis/pe_var.h
Normal file
@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _PE_VAR_H_
|
||||
#define _PE_VAR_H_
|
||||
|
||||
/*
|
||||
* Image Format
|
||||
*/
|
||||
|
||||
#define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
|
||||
#define IMAGE_OS2_SIGNATURE 0x454E /* NE */
|
||||
#define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
|
||||
#define IMAGE_VXD_SIGNATURE 0x454C /* LE */
|
||||
#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
|
||||
|
||||
/*
|
||||
* All PE files have one of these, just so if you attempt to
|
||||
* run them, they'll print out a message telling you they can
|
||||
* only be run in Windows.
|
||||
*/
|
||||
|
||||
struct image_dos_header {
|
||||
uint16_t idh_magic; /* Magic number */
|
||||
uint16_t idh_cblp; /* Bytes on last page of file */
|
||||
uint16_t idh_cp; /* Pages in file */
|
||||
uint16_t idh_crlc; /* Relocations */
|
||||
uint16_t idh_cparhdr; /* Size of header in paragraphs */
|
||||
uint16_t idh_minalloc; /* Minimum extra paragraphs needed */
|
||||
uint16_t idh_maxalloc; /* Maximum extra paragraphs needed */
|
||||
uint16_t idh_ss; /* Initial (relative) SS value */
|
||||
uint16_t idh_sp; /* Initial SP value */
|
||||
uint16_t idh_csum; /* Checksum */
|
||||
uint16_t idh_ip; /* Initial IP value */
|
||||
uint16_t idh_cs; /* Initial (relative) CS value */
|
||||
uint16_t idh_lfarlc; /* File address of relocation table */
|
||||
uint16_t idh_ovno; /* Overlay number */
|
||||
uint16_t idh_rsvd1[4]; /* Reserved words */
|
||||
uint16_t idh_oemid; /* OEM identifier (for idh_oeminfo) */
|
||||
uint16_t idh_oeminfo; /* OEM information; oemid specific */
|
||||
uint16_t idh_rsvd2[10]; /* Reserved words */
|
||||
uint32_t idh_lfanew; /* File address of new exe header */
|
||||
};
|
||||
|
||||
typedef struct image_dos_header image_dos_header;
|
||||
|
||||
/*
|
||||
* File header format.
|
||||
*/
|
||||
|
||||
struct image_file_header {
|
||||
uint16_t ifh_machine; /* Machine type */
|
||||
uint16_t ifh_numsections; /* # of sections */
|
||||
uint32_t ifh_timestamp; /* Date/time stamp */
|
||||
uint32_t ifh_symtblptr; /* Offset to symbol table */
|
||||
uint32_t ifh_numsyms; /* # of symbols */
|
||||
uint16_t ifh_optionalhdrlen; /* Size of optional header */
|
||||
uint16_t ifh_characteristics; /* Characteristics */
|
||||
};
|
||||
|
||||
typedef struct image_file_header image_file_header;
|
||||
|
||||
/* Machine types */
|
||||
|
||||
#define IMAGE_FILE_MACHINE_UNKNOWN 0
|
||||
#define IMAGE_FILE_MACHINE_I860 0x014d
|
||||
#define IMAGE_FILE_MACHINE_I386 0x014c
|
||||
#define IMAGE_FILE_MACHINE_R3000 0x0162
|
||||
#define IMAGE_FILE_MACHINE_R4000 0x0166
|
||||
#define IMAGE_FILE_MACHINE_R10000 0x0168
|
||||
#define IMAGE_FILE_MACHINE_WCEMIPSV2 0x0169
|
||||
#define IMAGE_FILE_MACHINE_ALPHA 0x0184
|
||||
#define IMAGE_FILE_MACHINE_SH3 0x01a2
|
||||
#define IMAGE_FILE_MACHINE_SH3DSP 0x01a3
|
||||
#define IMAGE_FILE_MACHINE_SH3E 0x01a4
|
||||
#define IMAGE_FILE_MACHINE_SH4 0x01a6
|
||||
#define IMAGE_FILE_MACHINE_SH5 0x01a8
|
||||
#define IMAGE_FILE_MACHINE_ARM 0x01c0
|
||||
#define IMAGE_FILE_MACHINE_THUMB 0x01c2
|
||||
#define IMAGE_FILE_MACHINE_AM33 0x01d3
|
||||
#define IMAGE_FILE_MACHINE_POWERPC 0x01f0
|
||||
#define IMAGE_FILE_MACHINE_POWERPCFP 0x01f1
|
||||
#define IMAGE_FILE_MACHINE_IA64 0x0200
|
||||
#define IMAGE_FILE_MACHINE_MIPS16 0x0266
|
||||
#define IMAGE_FILE_MACHINE_ALPHA64 0x0284
|
||||
#define IMAGE_FILE_MACHINE_MIPSFPU 0x0366
|
||||
#define IMAGE_FILE_MACHINE_MIPSFPU16 0x0466
|
||||
#define IMAGE_FILE_MACHINE_AXP64 IMAGE_FILE_MACHINE_ALPHA64
|
||||
#define IMAGE_FILE_MACHINE_TRICORE 0x0520
|
||||
#define IMAGE_FILE_MACHINE_CEF 0x0cef
|
||||
#define IMAGE_FILE_MACHINE_EBC 0x0ebc
|
||||
#define IMAGE_FILE_MACHINE_AMD64 0x8664
|
||||
#define IMAGE_FILE_MACHINE_M32R 0x9041
|
||||
#define IMAGE_FILE_MACHINE_CEE 0xc0ee
|
||||
|
||||
/* Characteristics */
|
||||
|
||||
#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 /* No relocation info */
|
||||
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
|
||||
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
|
||||
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
|
||||
#define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
|
||||
#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
|
||||
#define IMAGE_FILE_16BIT_MACHINE 0x0040
|
||||
#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
|
||||
#define IMAGE_FILE_32BIT_MACHINE 0x0100
|
||||
#define IMAGE_FILE_DEBUG_STRIPPED 0x0200
|
||||
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
|
||||
#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
|
||||
#define IMAGE_FILE_SYSTEM 0x1000
|
||||
#define IMAGE_FILE_DLL 0x2000
|
||||
#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
|
||||
#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
|
||||
|
||||
#define IMAGE_SIZEOF_FILE_HEADER 20
|
||||
|
||||
/*
|
||||
* Directory format.
|
||||
*/
|
||||
|
||||
struct image_data_directory {
|
||||
uint32_t idd_vaddr; /* virtual address */
|
||||
uint32_t idd_size; /* size */
|
||||
};
|
||||
|
||||
typedef struct image_data_directory image_data_directory;
|
||||
|
||||
#define IMAGE_DIRECTORY_ENTRIES_MAX 16
|
||||
|
||||
/*
|
||||
* Optional header format.
|
||||
*/
|
||||
|
||||
struct image_optional_header {
|
||||
|
||||
/* Standard fields */
|
||||
|
||||
uint16_t ioh_magic;
|
||||
uint8_t ioh_linkerver_major;
|
||||
uint8_t ioh_linkerver_minor;
|
||||
uint32_t ioh_codesize;
|
||||
uint32_t ioh_datasize;
|
||||
uint32_t ioh_bsssize;
|
||||
uint32_t ioh_entryaddr;
|
||||
uint32_t ioh_codebaseaddr;
|
||||
uint32_t ioh_databaseaddr;
|
||||
|
||||
/* NT-specific fields */
|
||||
|
||||
uint32_t ioh_imagebase;
|
||||
uint32_t ioh_sectalign;
|
||||
uint32_t ioh_filealign;
|
||||
uint16_t ioh_osver_major;
|
||||
uint16_t ioh_osver_minor;
|
||||
uint16_t ioh_imagever_major;
|
||||
uint16_t ioh_imagever_minor;
|
||||
uint16_t ioh_subsys_major;
|
||||
uint16_t ioh_subsys_minor;
|
||||
uint32_t ioh_win32ver;
|
||||
uint32_t ioh_imagesize;
|
||||
uint32_t ioh_headersize;
|
||||
uint32_t ioh_csum;
|
||||
uint16_t ioh_subsys;
|
||||
uint16_t ioh_dll_characteristics;
|
||||
uint32_t ioh_stackreservesize;
|
||||
uint32_t ioh_stackcommitsize;
|
||||
uint32_t ioh_heapreservesize;
|
||||
uint32_t ioh_heapcommitsize;
|
||||
uint16_t ioh_loaderflags;
|
||||
uint32_t ioh_rva_size_cnt;
|
||||
image_data_directory ioh_datadir[IMAGE_DIRECTORY_ENTRIES_MAX];
|
||||
};
|
||||
|
||||
typedef struct image_optional_header image_optional_header;
|
||||
|
||||
struct image_nt_header {
|
||||
uint32_t inh_signature;
|
||||
image_file_header inh_filehdr;
|
||||
image_optional_header inh_optionalhdr;
|
||||
};
|
||||
|
||||
typedef struct image_nt_header image_nt_header;
|
||||
|
||||
/* Directory Entries */
|
||||
|
||||
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 /* Export Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 /* Import Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 /* Resource Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 /* Exception Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 /* Security Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 /* Base Relocation Table */
|
||||
#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 /* Debug Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 /* Description String */
|
||||
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* Machine Value (MIPS GP) */
|
||||
#define IMAGE_DIRECTORY_ENTRY_TLS 9 /* TLS Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 /* Load Configuration Directory */
|
||||
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 /* Bound Import Directory in headers */
|
||||
#define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
|
||||
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13
|
||||
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14
|
||||
|
||||
/*
|
||||
* Section header format.
|
||||
*/
|
||||
|
||||
#define IMAGE_SHORT_NAME_LEN 8
|
||||
|
||||
struct image_section_header {
|
||||
uint8_t ish_name[IMAGE_SHORT_NAME_LEN];
|
||||
union {
|
||||
uint32_t ish_paddr;
|
||||
uint32_t ish_vsize;
|
||||
} ish_misc;
|
||||
uint32_t ish_vaddr;
|
||||
uint32_t ish_rawdatasize;
|
||||
uint32_t ish_rawdataaddr;
|
||||
uint32_t ish_relocaddr;
|
||||
uint32_t ish_linenumaddr;
|
||||
uint16_t ish_numrelocs;
|
||||
uint16_t ish_numlinenums;
|
||||
uint32_t ish_characteristics;
|
||||
};
|
||||
|
||||
typedef struct image_section_header image_section_header;
|
||||
|
||||
#define IMAGE_SIZEOF_SECTION_HEADER 40
|
||||
|
||||
/*
|
||||
* Import format
|
||||
*/
|
||||
|
||||
struct image_import_by_name {
|
||||
uint16_t iibn_hint;
|
||||
u_int8_t iibn_name[1];
|
||||
};
|
||||
|
||||
#define IMAGE_ORDINAL_FLAG 0x80000000
|
||||
#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
|
||||
|
||||
struct image_import_descriptor {
|
||||
uint32_t iid_import_name_table_addr;
|
||||
uint32_t iid_timestamp;
|
||||
uint32_t iid_forwardchain;
|
||||
uint32_t iid_nameaddr;
|
||||
uint32_t iid_import_address_table_addr;
|
||||
};
|
||||
|
||||
typedef struct image_import_descriptor image_import_descriptor;
|
||||
|
||||
struct image_base_reloc {
|
||||
uint32_t ibr_vaddr;
|
||||
uint32_t ibr_blocksize;
|
||||
uint16_t ibr_rel[1];
|
||||
};
|
||||
|
||||
typedef struct image_base_reloc image_base_reloc;
|
||||
|
||||
#define IMR_RELTYPE(x) ((x >> 12) & 0xF)
|
||||
#define IMR_RELOFFSET(x) (x & 0xFFF)
|
||||
|
||||
/* generic relocation types */
|
||||
#define IMAGE_REL_BASED_ABSOLUTE 0
|
||||
#define IMAGE_REL_BASED_HIGH 1
|
||||
#define IMAGE_REL_BASED_LOW 2
|
||||
#define IMAGE_REL_BASED_HIGHLOW 3
|
||||
#define IMAGE_REL_BASED_HIGHADJ 4
|
||||
#define IMAGE_REL_BASED_MIPS_JMPADDR 5
|
||||
#define IMAGE_REL_BASED_SECTION 6
|
||||
#define IMAGE_REL_BASED_REL 7
|
||||
#define IMAGE_REL_BASED_MIPS_JMPADDR16 9
|
||||
#define IMAGE_REL_BASED_IA64_IMM64 9 /* yes, 9 too */
|
||||
#define IMAGE_REL_BASED_DIR64 10
|
||||
#define IMAGE_REL_BASED_HIGH3ADJ 11
|
||||
|
||||
|
||||
struct image_patch_table {
|
||||
char *ipt_name;
|
||||
void (*ipt_func)(void);
|
||||
};
|
||||
|
||||
typedef struct image_patch_table image_patch_table;
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern int pe_get_dos_header(vm_offset_t, image_dos_header *);
|
||||
extern int pe_is_nt_image(vm_offset_t);
|
||||
extern int pe_get_optional_header(vm_offset_t, image_optional_header *);
|
||||
extern int pe_get_file_header(vm_offset_t, image_file_header *);
|
||||
extern int pe_get_section_header(vm_offset_t, image_section_header *);
|
||||
extern int pe_numsections(vm_offset_t);
|
||||
extern vm_offset_t pe_imagebase(vm_offset_t);
|
||||
extern vm_offset_t pe_directory_offset(vm_offset_t, uint32_t);
|
||||
extern vm_offset_t pe_translate_addr (vm_offset_t, uint32_t);
|
||||
extern int pe_get_section(vm_offset_t, image_section_header *, const char *);
|
||||
extern int pe_relocate(vm_offset_t);
|
||||
extern int pe_get_import_descriptor(vm_offset_t, image_import_descriptor *, char *);
|
||||
extern int pe_patch_imports(vm_offset_t, char *, image_patch_table *);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _PE_VAR_H_ */
|
160
sys/compat/ndis/resource_var.h
Normal file
160
sys/compat/ndis/resource_var.h
Normal file
@ -0,0 +1,160 @@
|
||||
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
typedef int cm_resource_type;
|
||||
|
||||
struct physaddr {
|
||||
uint64_t np_quad;
|
||||
};
|
||||
|
||||
typedef struct physaddr physaddr;
|
||||
|
||||
enum interface_type {
|
||||
InterfaceTypeUndefined = -1,
|
||||
Internal,
|
||||
Isa,
|
||||
Eisa,
|
||||
MicroChannel,
|
||||
TurboChannel,
|
||||
PCIBus,
|
||||
VMEBus,
|
||||
NuBus,
|
||||
PCMCIABus,
|
||||
CBus,
|
||||
MPIBus,
|
||||
MPSABus,
|
||||
ProcessorInternal,
|
||||
InternalPowerBus,
|
||||
PNPISABus,
|
||||
PNPBus,
|
||||
MaximumInterfaceType
|
||||
};
|
||||
|
||||
typedef enum interface_type interface_type;
|
||||
|
||||
#define CmResourceTypeNull 0 /* ResType_All or ResType_None (0x0000) */
|
||||
#define CmResourceTypePort 1 /* ResType_IO (0x0002) */
|
||||
#define CmResourceTypeInterrupt 2 /* ResType_IRQ (0x0004) */
|
||||
#define CmResourceTypeMemory 3 /* ResType_Mem (0x0001) */
|
||||
#define CmResourceTypeDma 4 /* ResType_DMA (0x0003) */
|
||||
#define CmResourceTypeDeviceSpecific 5 /* ResType_ClassSpecific (0xFFFF) */
|
||||
#define CmResourceTypeBusNumber 6 /* ResType_BusNumber (0x0006) */
|
||||
#define CmResourceTypeMaximum 7
|
||||
#define CmResourceTypeNonArbitrated 128 /* Not arbitrated if 0x80 bit set */
|
||||
#define CmResourceTypeConfigData 128 /* ResType_Reserved (0x8000) */
|
||||
#define CmResourceTypeDevicePrivate 129 /* ResType_DevicePrivate (0x8001) */
|
||||
#define CmResourceTypePcCardConfig 130 /* ResType_PcCardConfig (0x8002) */
|
||||
|
||||
enum cm_share_disposition {
|
||||
CmResourceShareUndetermined = 0, /* Reserved */
|
||||
CmResourceShareDeviceExclusive,
|
||||
CmResourceShareDriverExclusive,
|
||||
CmResourceShareShared
|
||||
};
|
||||
|
||||
typedef enum cm_share_disposition cm_share_disposition;
|
||||
|
||||
/* Define the bit masks for Flags when type is CmResourceTypeInterrupt */
|
||||
|
||||
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
|
||||
#define CM_RESOURCE_INTERRUPT_LATCHED 1
|
||||
|
||||
/* Define the bit masks for Flags when type is CmResourceTypeMemory */
|
||||
|
||||
#define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
|
||||
#define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
|
||||
#define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
|
||||
#define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
|
||||
|
||||
#define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
|
||||
#define CM_RESOURCE_MEMORY_24 0x0010
|
||||
#define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
|
||||
|
||||
/* Define the bit masks for Flags when type is CmResourceTypePort */
|
||||
|
||||
#define CM_RESOURCE_PORT_MEMORY 0x0000
|
||||
#define CM_RESOURCE_PORT_IO 0x0001
|
||||
#define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
|
||||
#define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
|
||||
#define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
|
||||
#define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
|
||||
#define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
|
||||
#define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
|
||||
|
||||
/* Define the bit masks for Flags when type is CmResourceTypeDma */
|
||||
|
||||
#define CM_RESOURCE_DMA_8 0x0000
|
||||
#define CM_RESOURCE_DMA_16 0x0001
|
||||
#define CM_RESOURCE_DMA_32 0x0002
|
||||
#define CM_RESOURCE_DMA_8_AND_16 0x0004
|
||||
#define CM_RESOURCE_DMA_BUS_MASTER 0x0008
|
||||
#define CM_RESOURCE_DMA_TYPE_A 0x0010
|
||||
#define CM_RESOURCE_DMA_TYPE_B 0x0020
|
||||
#define CM_RESOURCE_DMA_TYPE_F 0x0040
|
||||
|
||||
struct cm_partial_resource_desc {
|
||||
uint8_t cprd_type;
|
||||
uint8_t cprd_sharedisp;
|
||||
union {
|
||||
struct {
|
||||
physaddr cprd_start;
|
||||
uint32_t cprd_len;
|
||||
} cprd_generic;
|
||||
struct {
|
||||
physaddr cprd_start;
|
||||
uint32_t cprd_len;
|
||||
} cprd_port;
|
||||
struct {
|
||||
uint32_t cprd_level;
|
||||
uint32_t cprd_vector;
|
||||
uint32_t cprd_affinity;
|
||||
} cprd_intr;
|
||||
struct {
|
||||
physaddr cprd_start;
|
||||
uint32_t cprd_len;
|
||||
} cprd_mem;
|
||||
struct {
|
||||
uint32_t cprd_chan;
|
||||
uint32_t cprd_port;
|
||||
uint32_t cprd_rsvd;
|
||||
} cprd_dmachan;
|
||||
struct {
|
||||
uint32_t cprd_data[3];
|
||||
} cprd_devpriv;
|
||||
struct {
|
||||
uint32_t cprd_datasize;
|
||||
uint32_t cprd_rsvd1;
|
||||
uint32_t cprd_rsvd2;
|
||||
} cprd_devspec;
|
||||
} u;
|
||||
};
|
||||
|
||||
typedef struct cm_partial_resource_desc cm_partial_resource_desc;
|
||||
|
||||
struct cm_partial_resource_list {
|
||||
uint16_t cprl_version;
|
||||
uint16_t cprl_revision;
|
||||
uint32_t cprl_count;
|
||||
cm_partial_resource_desc cprl_partial_descs[1];
|
||||
};
|
||||
|
||||
typedef struct cm_partial_resource_list cm_partial_resource_list;
|
||||
|
||||
struct cm_full_resource_list {
|
||||
interface_type cfrl_type;
|
||||
uint32_t cfrl_busnum;
|
||||
cm_partial_resource_desc cfrl_partiallist;
|
||||
};
|
||||
|
||||
typedef struct cm_full_resource_list cm_full_resource_list;
|
||||
|
||||
struct cm_resource_list {
|
||||
uint32_t crl_count;
|
||||
cm_full_resource_list crl_rlist;
|
||||
};
|
||||
|
||||
typedef struct cm_resource_list cm_resource_list;
|
||||
|
||||
typedef cm_partial_resource_list ndis_resource_list;
|
152
sys/compat/ndis/subr_hal.c
Normal file
152
sys/compat/ndis/subr_hal.c
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <sys/callout.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <sys/systm.h>
|
||||
#include <machine/clock.h>
|
||||
#include <machine/bus_memio.h>
|
||||
#include <machine/bus_pio.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <compat/ndis/pe_var.h>
|
||||
#include <compat/ndis/hal_var.h>
|
||||
|
||||
#define __stdcall __attribute__((__stdcall__))
|
||||
#define FUNC void(*)(void)
|
||||
|
||||
__stdcall static void hal_stall_exec_cpu(uint32_t);
|
||||
__stdcall static void hal_writeport_ulong(uint32_t *, uint32_t);
|
||||
__stdcall static void hal_writeport_ushort(uint16_t *, uint16_t);
|
||||
__stdcall static void hal_writeport_uchar(uint8_t *, uint8_t);
|
||||
__stdcall static uint32_t hal_readport_ulong(uint32_t *);
|
||||
__stdcall static uint16_t hal_readport_ushort(uint16_t *);
|
||||
__stdcall static uint8_t hal_readport_uchar(uint8_t *);
|
||||
__stdcall static void dummy (void);
|
||||
|
||||
__stdcall static void
|
||||
hal_stall_exec_cpu(usecs)
|
||||
uint32_t usecs;
|
||||
{
|
||||
DELAY(usecs);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
hal_writeport_ulong(port, val)
|
||||
uint32_t *port;
|
||||
uint32_t val;
|
||||
{
|
||||
bus_space_write_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
hal_writeport_ushort(port, val)
|
||||
uint16_t *port;
|
||||
uint16_t val;
|
||||
{
|
||||
bus_space_write_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
hal_writeport_uchar(port, val)
|
||||
uint8_t *port;
|
||||
uint8_t val;
|
||||
{
|
||||
bus_space_write_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port, val);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static uint16_t
|
||||
hal_readport_ushort(port)
|
||||
uint16_t *port;
|
||||
{
|
||||
return(bus_space_read_2(I386_BUS_SPACE_IO, 0x0, (uint32_t)port));
|
||||
}
|
||||
|
||||
__stdcall static uint32_t
|
||||
hal_readport_ulong(port)
|
||||
uint32_t *port;
|
||||
{
|
||||
return(bus_space_read_4(I386_BUS_SPACE_IO, 0x0, (uint32_t)port));
|
||||
}
|
||||
|
||||
__stdcall static uint8_t
|
||||
hal_readport_uchar(port)
|
||||
uint8_t *port;
|
||||
{
|
||||
return(bus_space_read_1(I386_BUS_SPACE_IO, 0x0, (uint32_t)port));
|
||||
}
|
||||
|
||||
__stdcall
|
||||
static void dummy()
|
||||
{
|
||||
printf ("hal dummy called...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
image_patch_table hal_functbl[] = {
|
||||
{ "KeStallExecutionProcessor", (FUNC)hal_stall_exec_cpu },
|
||||
{ "WRITE_PORT_ULONG", (FUNC)hal_writeport_ulong },
|
||||
{ "WRITE_PORT_USHORT", (FUNC)hal_writeport_ushort },
|
||||
{ "WRITE_PORT_UCHAR", (FUNC)hal_writeport_uchar },
|
||||
{ "READ_PORT_ULONG", (FUNC)hal_readport_ulong },
|
||||
{ "READ_PORT_USHORT", (FUNC)hal_readport_ushort },
|
||||
{ "READ_PORT_UCHAR", (FUNC)hal_readport_uchar },
|
||||
|
||||
/*
|
||||
* This last entry is a catch-all for any function we haven't
|
||||
* implemented yet. The PE import list patching routine will
|
||||
* use it for any function that doesn't have an explicit match
|
||||
* in this table.
|
||||
*/
|
||||
|
||||
{ NULL, (FUNC)dummy },
|
||||
|
||||
/* End of list. */
|
||||
|
||||
{ NULL, NULL },
|
||||
};
|
1930
sys/compat/ndis/subr_ndis.c
Normal file
1930
sys/compat/ndis/subr_ndis.c
Normal file
File diff suppressed because it is too large
Load Diff
497
sys/compat/ndis/subr_ntoskrnl.c
Normal file
497
sys/compat/ndis/subr_ntoskrnl.c
Normal file
@ -0,0 +1,497 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <sys/callout.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <machine/clock.h>
|
||||
#include <machine/bus_memio.h>
|
||||
#include <machine/bus_pio.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <compat/ndis/pe_var.h>
|
||||
#include <compat/ndis/resource_var.h>
|
||||
#include <compat/ndis/ndis_var.h>
|
||||
#include <compat/ndis/ntoskrnl_var.h>
|
||||
|
||||
#define __stdcall __attribute__((__stdcall__))
|
||||
#define FUNC void(*)(void)
|
||||
|
||||
__stdcall static uint32_t ntoskrnl_unicode_equal(ndis_unicode_string *,
|
||||
ndis_unicode_string *, uint32_t);
|
||||
__stdcall static void *ntoskrnl_iobuildsynchfsdreq(uint32_t, void *,
|
||||
void *, uint32_t, uint32_t *, void *, void *);
|
||||
__stdcall static uint32_t ntoskrnl_iofcalldriver(void *, void *);
|
||||
__stdcall static uint32_t ntoskrnl_waitforobj(void *, uint32_t,
|
||||
uint32_t, uint8_t, void *);
|
||||
__stdcall static void ntoskrnl_initevent(void *, uint32_t, uint8_t);
|
||||
__stdcall static void ntoskrnl_writereg_ushort(uint16_t *, uint16_t);
|
||||
__stdcall static uint16_t ntoskrnl_readreg_ushort(uint16_t *);
|
||||
__stdcall static void ntoskrnl_writereg_ulong(uint32_t *, uint32_t);
|
||||
__stdcall static uint32_t ntoskrnl_readreg_ulong(uint32_t *);
|
||||
__stdcall static void ntoskrnl_writereg_uchar(uint8_t *, uint8_t);
|
||||
__stdcall static uint8_t ntoskrnl_readreg_uchar(uint8_t *);
|
||||
__stdcall static int64_t _allmul(int64_t, int64_t);
|
||||
__stdcall static int64_t _alldiv(int64_t, int64_t);
|
||||
__stdcall static int64_t _allrem(int64_t, int64_t);
|
||||
__stdcall static int64_t _allshr(int64_t, int);
|
||||
__stdcall static int64_t _allshl(int64_t, int);
|
||||
__stdcall static uint64_t _aullmul(uint64_t, uint64_t);
|
||||
__stdcall static uint64_t _aulldiv(uint64_t, uint64_t);
|
||||
__stdcall static uint64_t _aullrem(uint64_t, uint64_t);
|
||||
__stdcall static uint64_t _aullshr(uint64_t, int);
|
||||
__stdcall static uint64_t _aullshl(uint64_t, int);
|
||||
__stdcall static void *ntoskrnl_allocfunc(uint32_t, size_t, uint32_t);
|
||||
__stdcall static void ntoskrnl_freefunc(void *);
|
||||
__stdcall static void ntoskrnl_init_lookaside(paged_lookaside_list *,
|
||||
lookaside_alloc_func *, lookaside_free_func *,
|
||||
uint32_t, size_t, uint32_t, uint16_t);
|
||||
__stdcall static void ntoskrnl_delete_lookaside(paged_lookaside_list *);
|
||||
__stdcall static void ntoskrnl_init_nplookaside(npaged_lookaside_list *,
|
||||
lookaside_alloc_func *, lookaside_free_func *,
|
||||
uint32_t, size_t, uint32_t, uint16_t);
|
||||
__stdcall static void ntoskrnl_delete_nplookaside(npaged_lookaside_list *);
|
||||
static slist_entry *ntoskrnl_push_slist(slist_entry *, slist_entry *);
|
||||
static slist_entry *ntoskrnl_pop_slist(slist_entry *);
|
||||
__stdcall static void dummy(void);
|
||||
|
||||
static struct mtx ntoskrnl_interlock;
|
||||
static int ntoskrnl_inits = 0;
|
||||
|
||||
int
|
||||
ntoskrnl_libinit()
|
||||
{
|
||||
if (ntoskrnl_inits) {
|
||||
ntoskrnl_inits++;
|
||||
return(0);
|
||||
}
|
||||
|
||||
mtx_init(&ntoskrnl_interlock, "ntoskrnllock", MTX_NETWORK_LOCK,
|
||||
MTX_DEF | MTX_RECURSE);
|
||||
|
||||
ntoskrnl_inits++;
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
ntoskrnl_libfini()
|
||||
{
|
||||
if (ntoskrnl_inits != 1) {
|
||||
ntoskrnl_inits--;
|
||||
return(0);
|
||||
}
|
||||
|
||||
mtx_destroy(&ntoskrnl_interlock);
|
||||
ntoskrnl_inits--;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
__stdcall static uint32_t
|
||||
ntoskrnl_unicode_equal(str1, str2, casesensitive)
|
||||
ndis_unicode_string *str1;
|
||||
ndis_unicode_string *str2;
|
||||
uint32_t casesensitive;
|
||||
{
|
||||
char *astr1 = NULL, *astr2 = NULL;
|
||||
int rval = 1;
|
||||
|
||||
ndis_unicode_to_ascii(str1->nus_buf, str2->nus_len, &astr1);
|
||||
ndis_unicode_to_ascii(str2->nus_buf, str2->nus_len, &astr2);
|
||||
|
||||
if (casesensitive)
|
||||
rval = strcmp(astr1, astr2);
|
||||
#ifdef notdef
|
||||
else
|
||||
rval = strcasecmp(astr1, astr2);
|
||||
#endif
|
||||
|
||||
free(astr1, M_DEVBUF);
|
||||
free(astr2, M_DEVBUF);
|
||||
|
||||
return(rval);
|
||||
}
|
||||
|
||||
__stdcall static void *
|
||||
ntoskrnl_iobuildsynchfsdreq(func, dobj, buf, len, off, event, status)
|
||||
uint32_t func;
|
||||
void *dobj;
|
||||
void *buf;
|
||||
uint32_t len;
|
||||
uint32_t *off;
|
||||
void *event;
|
||||
void *status;
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
__stdcall static uint32_t
|
||||
ntoskrnl_iofcalldriver(dobj, irp)
|
||||
void *dobj;
|
||||
void *irp;
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
__stdcall static uint32_t
|
||||
ntoskrnl_waitforobj(obj, reason, mode, alertable, timeout)
|
||||
void *obj;
|
||||
uint32_t reason;
|
||||
uint32_t mode;
|
||||
uint8_t alertable;
|
||||
void *timeout;
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_initevent(event, type, state)
|
||||
void *event;
|
||||
uint32_t type;
|
||||
uint8_t state;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_writereg_ushort(reg, val)
|
||||
uint16_t *reg;
|
||||
uint16_t val;
|
||||
{
|
||||
bus_space_write_2(I386_BUS_SPACE_MEM, 0x0, (uint32_t)reg, val);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static uint16_t
|
||||
ntoskrnl_readreg_ushort(reg)
|
||||
uint16_t *reg;
|
||||
{
|
||||
return(bus_space_read_2(I386_BUS_SPACE_MEM, 0x0, (uint32_t)reg));
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_writereg_ulong(reg, val)
|
||||
uint32_t *reg;
|
||||
uint32_t val;
|
||||
{
|
||||
bus_space_write_4(I386_BUS_SPACE_MEM, 0x0, (uint32_t)reg, val);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static uint32_t
|
||||
ntoskrnl_readreg_ulong(reg)
|
||||
uint32_t *reg;
|
||||
{
|
||||
return(bus_space_read_4(I386_BUS_SPACE_MEM, 0x0, (uint32_t)reg));
|
||||
}
|
||||
|
||||
__stdcall static uint8_t
|
||||
ntoskrnl_readreg_uchar(reg)
|
||||
uint8_t *reg;
|
||||
{
|
||||
return(bus_space_read_1(I386_BUS_SPACE_MEM, 0x0, (uint32_t)reg));
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_writereg_uchar(reg, val)
|
||||
uint8_t *reg;
|
||||
uint8_t val;
|
||||
{
|
||||
bus_space_write_1(I386_BUS_SPACE_MEM, 0x0, (uint32_t)reg, val);
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static int64_t
|
||||
_allmul(a, b)
|
||||
int64_t a;
|
||||
int64_t b;
|
||||
{
|
||||
return (a * b);
|
||||
}
|
||||
|
||||
__stdcall static int64_t
|
||||
_alldiv(a, b)
|
||||
int64_t a;
|
||||
int64_t b;
|
||||
{
|
||||
return (a / b);
|
||||
}
|
||||
|
||||
__stdcall static int64_t
|
||||
_allrem(a, b)
|
||||
int64_t a;
|
||||
int64_t b;
|
||||
{
|
||||
return (a % b);
|
||||
}
|
||||
|
||||
__stdcall static uint64_t
|
||||
_aullmul(a, b)
|
||||
uint64_t a;
|
||||
uint64_t b;
|
||||
{
|
||||
return (a * b);
|
||||
}
|
||||
|
||||
__stdcall static uint64_t
|
||||
_aulldiv(a, b)
|
||||
uint64_t a;
|
||||
uint64_t b;
|
||||
{
|
||||
return (a / b);
|
||||
}
|
||||
|
||||
__stdcall static uint64_t
|
||||
_aullrem(a, b)
|
||||
uint64_t a;
|
||||
uint64_t b;
|
||||
{
|
||||
return (a % b);
|
||||
}
|
||||
|
||||
__stdcall static int64_t
|
||||
_allshl(a, b)
|
||||
int64_t a;
|
||||
int b;
|
||||
{
|
||||
return (a << b);
|
||||
}
|
||||
|
||||
__stdcall static uint64_t
|
||||
_aullshl(a, b)
|
||||
uint64_t a;
|
||||
int b;
|
||||
{
|
||||
return (a << b);
|
||||
}
|
||||
|
||||
__stdcall static int64_t
|
||||
_allshr(a, b)
|
||||
int64_t a;
|
||||
int b;
|
||||
{
|
||||
return (a >> b);
|
||||
}
|
||||
|
||||
__stdcall static uint64_t
|
||||
_aullshr(a, b)
|
||||
uint64_t a;
|
||||
int b;
|
||||
{
|
||||
return (a >> b);
|
||||
}
|
||||
|
||||
__stdcall static void *
|
||||
ntoskrnl_allocfunc(pooltype, size, tag)
|
||||
uint32_t pooltype;
|
||||
size_t size;
|
||||
uint32_t tag;
|
||||
{
|
||||
return(malloc(size, M_DEVBUF, M_NOWAIT));
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_freefunc(buf)
|
||||
void *buf;
|
||||
{
|
||||
free(buf, M_DEVBUF);
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_init_lookaside(lookaside, allocfunc, freefunc,
|
||||
flags, size, tag, depth)
|
||||
paged_lookaside_list *lookaside;
|
||||
lookaside_alloc_func *allocfunc;
|
||||
lookaside_free_func *freefunc;
|
||||
uint32_t flags;
|
||||
size_t size;
|
||||
uint32_t tag;
|
||||
uint16_t depth;
|
||||
{
|
||||
lookaside->nll_l.gl_size = size;
|
||||
lookaside->nll_l.gl_tag = tag;
|
||||
if (allocfunc == NULL)
|
||||
lookaside->nll_l.gl_allocfunc = ntoskrnl_allocfunc;
|
||||
else
|
||||
lookaside->nll_l.gl_allocfunc = allocfunc;
|
||||
|
||||
if (freefunc == NULL)
|
||||
lookaside->nll_l.gl_freefunc = ntoskrnl_freefunc;
|
||||
else
|
||||
lookaside->nll_l.gl_freefunc = freefunc;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_delete_lookaside(lookaside)
|
||||
paged_lookaside_list *lookaside;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_init_nplookaside(lookaside, allocfunc, freefunc,
|
||||
flags, size, tag, depth)
|
||||
npaged_lookaside_list *lookaside;
|
||||
lookaside_alloc_func *allocfunc;
|
||||
lookaside_free_func *freefunc;
|
||||
uint32_t flags;
|
||||
size_t size;
|
||||
uint32_t tag;
|
||||
uint16_t depth;
|
||||
{
|
||||
lookaside->nll_l.gl_size = size;
|
||||
lookaside->nll_l.gl_tag = tag;
|
||||
if (allocfunc == NULL)
|
||||
lookaside->nll_l.gl_allocfunc = ntoskrnl_allocfunc;
|
||||
else
|
||||
lookaside->nll_l.gl_allocfunc = allocfunc;
|
||||
|
||||
if (freefunc == NULL)
|
||||
lookaside->nll_l.gl_freefunc = ntoskrnl_freefunc;
|
||||
else
|
||||
lookaside->nll_l.gl_freefunc = freefunc;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
ntoskrnl_delete_nplookaside(lookaside)
|
||||
npaged_lookaside_list *lookaside;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: the interlocked slist push and pop routines are
|
||||
* declared to be _fastcall in Windows, which means they
|
||||
* use the _cdecl calling convention here.
|
||||
*/
|
||||
static slist_entry *
|
||||
ntoskrnl_push_slist(head, entry)
|
||||
slist_entry *head;
|
||||
slist_entry *entry;
|
||||
{
|
||||
slist_entry *oldhead;
|
||||
mtx_lock(&ntoskrnl_interlock);
|
||||
oldhead = head->sl_next;
|
||||
entry->sl_next = head->sl_next;
|
||||
head->sl_next = entry;
|
||||
mtx_unlock(&ntoskrnl_interlock);
|
||||
return(oldhead);
|
||||
}
|
||||
|
||||
static slist_entry *
|
||||
ntoskrnl_pop_slist(head)
|
||||
slist_entry *head;
|
||||
{
|
||||
slist_entry *first;
|
||||
mtx_lock(&ntoskrnl_interlock);
|
||||
first = head->sl_next;
|
||||
if (first != NULL)
|
||||
head->sl_next = first->sl_next;
|
||||
mtx_unlock(&ntoskrnl_interlock);
|
||||
return(first);
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
dummy()
|
||||
{
|
||||
printf ("ntoskrnl dummy called...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
image_patch_table ntoskrnl_functbl[] = {
|
||||
{ "RtlEqualUnicodeString", (FUNC)ntoskrnl_unicode_equal },
|
||||
{ "sprintf", (FUNC)sprintf },
|
||||
{ "DbgPrint", (FUNC)printf },
|
||||
{ "strncmp", (FUNC)strncmp },
|
||||
{ "strcmp", (FUNC)strcmp },
|
||||
{ "strncpy", (FUNC)strncpy },
|
||||
{ "strcpy", (FUNC)strcpy },
|
||||
{ "IofCallDriver", (FUNC)ntoskrnl_iofcalldriver },
|
||||
{ "IoBuildSynchronousFsdRequest", (FUNC)ntoskrnl_iobuildsynchfsdreq },
|
||||
{ "KeWaitForSingleObject", (FUNC)ntoskrnl_waitforobj },
|
||||
{ "KeInitializeEvent", (FUNC)ntoskrnl_initevent },
|
||||
{ "_allmul", (FUNC)_allmul },
|
||||
{ "_alldiv", (FUNC)_alldiv },
|
||||
{ "_allrem", (FUNC)_allrem },
|
||||
{ "_allshr", (FUNC)_allshr },
|
||||
{ "_allshl", (FUNC)_allshl },
|
||||
{ "_aullmul", (FUNC)_aullmul },
|
||||
{ "_aulldiv", (FUNC)_aulldiv },
|
||||
{ "_aullrem", (FUNC)_aullrem },
|
||||
{ "_aullushr", (FUNC)_aullshr },
|
||||
{ "_aullshl", (FUNC)_aullshl },
|
||||
{ "WRITE_REGISTER_USHORT", (FUNC)ntoskrnl_writereg_ushort },
|
||||
{ "READ_REGISTER_USHORT", (FUNC)ntoskrnl_readreg_ushort },
|
||||
{ "WRITE_REGISTER_ULONG", (FUNC)ntoskrnl_writereg_ulong },
|
||||
{ "READ_REGISTER_ULONG", (FUNC)ntoskrnl_readreg_ulong },
|
||||
{ "READ_REGISTER_UCHAR", (FUNC)ntoskrnl_readreg_uchar },
|
||||
{ "WRITE_REGISTER_UCHAR", (FUNC)ntoskrnl_writereg_uchar },
|
||||
{ "ExInitializePagedLookasideList", (FUNC)ntoskrnl_init_lookaside },
|
||||
{ "ExDeletePagedLookasideList", (FUNC)ntoskrnl_delete_lookaside },
|
||||
{ "ExInitializeNPagedLookasideList", (FUNC)ntoskrnl_init_nplookaside },
|
||||
{ "ExDeleteNPagedLookasideList", (FUNC)ntoskrnl_delete_nplookaside },
|
||||
{ "InterlockedPopEntrySList", (FUNC)ntoskrnl_pop_slist },
|
||||
{ "InterlockedPushEntrySList", (FUNC)ntoskrnl_push_slist },
|
||||
|
||||
/*
|
||||
* This last entry is a catch-all for any function we haven't
|
||||
* implemented yet. The PE import list patching routine will
|
||||
* use it for any function that doesn't have an explicit match
|
||||
* in this table.
|
||||
*/
|
||||
|
||||
{ NULL, (FUNC)dummy },
|
||||
|
||||
/* End of list. */
|
||||
|
||||
{ NULL, NULL },
|
||||
};
|
537
sys/compat/ndis/subr_pe.c
Normal file
537
sys/compat/ndis/subr_pe.c
Normal file
@ -0,0 +1,537 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* This file contains routines for relocating and dynamically linking
|
||||
* executable object code files in the Windows(r) PE (Portable Executable)
|
||||
* format. In Windows, anything with a .EXE, .DLL or .SYS extention is
|
||||
* considered an executable, and all such files have some structures in
|
||||
* common. The PE format was apparently based largely on COFF but has
|
||||
* mutated significantly over time. We are mainly concerned with .SYS files,
|
||||
* so this module implements only enough routines to be able to parse the
|
||||
* headers and sections of a .SYS object file and perform the necessary
|
||||
* relocations and jump table patching to allow us to call into it
|
||||
* (and to have it call back to us). Note that while this module
|
||||
* can handle fixups for imported symbols, it knows nothing about
|
||||
* exporting them.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#ifdef _KERNEL
|
||||
#include <sys/systm.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <compat/ndis/pe_var.h>
|
||||
|
||||
static u_int32_t pe_functbl_match(image_patch_table *, char *);
|
||||
|
||||
/*
|
||||
* Check for an MS-DOS executable header. All Windows binaries
|
||||
* have a small MS-DOS executable prepended to them to print out
|
||||
* the "This program requires Windows" message. Even .SYS files
|
||||
* have this header, in spite of the fact that you're can't actually
|
||||
* run them directly.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_get_dos_header(imgbase, hdr)
|
||||
vm_offset_t imgbase;
|
||||
image_dos_header *hdr;
|
||||
{
|
||||
uint16_t signature;
|
||||
|
||||
if (imgbase == NULL || hdr == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
signature = *(uint16_t *)imgbase;
|
||||
if (signature != IMAGE_DOS_SIGNATURE)
|
||||
return (ENOEXEC);
|
||||
|
||||
bcopy ((char *)imgbase, (char *)hdr, sizeof(image_dos_header));
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that this image has a Windows NT PE signature.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_is_nt_image(imgbase)
|
||||
vm_offset_t imgbase;
|
||||
{
|
||||
uint32_t signature;
|
||||
image_dos_header *dos_hdr;
|
||||
|
||||
if (imgbase == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
signature = *(uint16_t *)imgbase;
|
||||
if (signature == IMAGE_DOS_SIGNATURE) {
|
||||
dos_hdr = (image_dos_header *)imgbase;
|
||||
signature = *(uint32_t *)(imgbase + dos_hdr->idh_lfanew);
|
||||
if (signature == IMAGE_NT_SIGNATURE)
|
||||
return(0);
|
||||
}
|
||||
|
||||
return(ENOEXEC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a copy of the optional header. This contains the
|
||||
* executable entry point and the directory listing which we
|
||||
* need to find the relocations and imports later.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_get_optional_header(imgbase, hdr)
|
||||
vm_offset_t imgbase;
|
||||
image_optional_header *hdr;
|
||||
{
|
||||
image_dos_header *dos_hdr;
|
||||
image_nt_header *nt_hdr;
|
||||
|
||||
if (imgbase == NULL || hdr == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
if (pe_is_nt_image(imgbase))
|
||||
return (EINVAL);
|
||||
|
||||
dos_hdr = (image_dos_header *)(imgbase);
|
||||
nt_hdr = (image_nt_header *)(imgbase + dos_hdr->idh_lfanew);
|
||||
|
||||
bcopy ((char *)&nt_hdr->inh_optionalhdr, (char *)hdr,
|
||||
sizeof(image_optional_header));
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a copy of the file header. Contains the number of
|
||||
* sections in this image.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_get_file_header(imgbase, hdr)
|
||||
vm_offset_t imgbase;
|
||||
image_file_header *hdr;
|
||||
{
|
||||
image_dos_header *dos_hdr;
|
||||
image_nt_header *nt_hdr;
|
||||
|
||||
if (imgbase == NULL || hdr == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
if (pe_is_nt_image(imgbase))
|
||||
return (EINVAL);
|
||||
|
||||
dos_hdr = (image_dos_header *)imgbase;
|
||||
nt_hdr = (image_nt_header *)(imgbase + dos_hdr->idh_lfanew);
|
||||
|
||||
bcopy ((char *)&nt_hdr->inh_filehdr, (char *)hdr,
|
||||
sizeof(image_file_header));
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the header of the first section in this image (usually
|
||||
* .text).
|
||||
*/
|
||||
|
||||
int
|
||||
pe_get_section_header(imgbase, hdr)
|
||||
vm_offset_t imgbase;
|
||||
image_section_header *hdr;
|
||||
{
|
||||
image_dos_header *dos_hdr;
|
||||
image_nt_header *nt_hdr;
|
||||
image_section_header *sect_hdr;
|
||||
|
||||
if (imgbase == NULL || hdr == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
if (pe_is_nt_image(imgbase))
|
||||
return (EINVAL);
|
||||
|
||||
dos_hdr = (image_dos_header *)imgbase;
|
||||
nt_hdr = (image_nt_header *)(imgbase + dos_hdr->idh_lfanew);
|
||||
sect_hdr = (image_section_header *)((vm_offset_t)nt_hdr +
|
||||
sizeof(image_nt_header));
|
||||
|
||||
bcopy ((char *)sect_hdr, (char *)hdr, sizeof(image_section_header));
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of sections in this executable, or 0 on error.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_numsections(imgbase)
|
||||
vm_offset_t imgbase;
|
||||
{
|
||||
image_file_header file_hdr;
|
||||
|
||||
if (pe_get_file_header(imgbase, &file_hdr))
|
||||
return(0);
|
||||
|
||||
return (file_hdr.ifh_numsections);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the base address that this image was linked for.
|
||||
* This helps us calculate relocation addresses later.
|
||||
*/
|
||||
|
||||
vm_offset_t
|
||||
pe_imagebase(imgbase)
|
||||
vm_offset_t imgbase;
|
||||
{
|
||||
image_optional_header optional_hdr;
|
||||
|
||||
if (pe_get_optional_header(imgbase, &optional_hdr))
|
||||
return(0);
|
||||
|
||||
return (optional_hdr.ioh_imagebase);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the offset of a given directory structure within the
|
||||
* image. Directories reside within sections.
|
||||
*/
|
||||
|
||||
vm_offset_t
|
||||
pe_directory_offset(imgbase, diridx)
|
||||
vm_offset_t imgbase;
|
||||
uint32_t diridx;
|
||||
{
|
||||
image_optional_header opt_hdr;
|
||||
vm_offset_t dir;
|
||||
|
||||
if (pe_get_optional_header(imgbase, &opt_hdr))
|
||||
return(0);
|
||||
|
||||
if (diridx >= opt_hdr.ioh_rva_size_cnt)
|
||||
return(0);
|
||||
|
||||
dir = opt_hdr.ioh_datadir[diridx].idd_vaddr;
|
||||
|
||||
return(pe_translate_addr(imgbase, dir));
|
||||
}
|
||||
|
||||
vm_offset_t
|
||||
pe_translate_addr(imgbase, rva)
|
||||
vm_offset_t imgbase;
|
||||
uint32_t rva;
|
||||
{
|
||||
image_optional_header opt_hdr;
|
||||
image_section_header *sect_hdr;
|
||||
image_dos_header *dos_hdr;
|
||||
image_nt_header *nt_hdr;
|
||||
int i = 0, sections, fixedlen;
|
||||
|
||||
if (pe_get_optional_header(imgbase, &opt_hdr))
|
||||
return(0);
|
||||
|
||||
sections = pe_numsections(imgbase);
|
||||
|
||||
dos_hdr = (image_dos_header *)imgbase;
|
||||
nt_hdr = (image_nt_header *)(imgbase + dos_hdr->idh_lfanew);
|
||||
sect_hdr = (image_section_header *)((vm_offset_t)nt_hdr +
|
||||
sizeof(image_nt_header));
|
||||
|
||||
/*
|
||||
* The test here is to see if the RVA falls somewhere
|
||||
* inside the section, based on the section's start RVA
|
||||
* and its length. However it seems sometimes the
|
||||
* virtual length isn't enough to cover the entire
|
||||
* area of the section. We fudge by taking into account
|
||||
* the section alignment and rounding the section length
|
||||
* up to a page boundary.
|
||||
*/
|
||||
while (i++ < sections) {
|
||||
fixedlen = sect_hdr->ish_misc.ish_vsize;
|
||||
fixedlen += ((opt_hdr.ioh_sectalign - 1) -
|
||||
sect_hdr->ish_misc.ish_vsize) &
|
||||
(opt_hdr.ioh_sectalign - 1);
|
||||
if (sect_hdr->ish_vaddr <= (u_int32_t)rva &&
|
||||
(sect_hdr->ish_vaddr + fixedlen) >
|
||||
(u_int32_t)rva)
|
||||
break;
|
||||
sect_hdr++;
|
||||
}
|
||||
|
||||
if (i > sections)
|
||||
return(0);
|
||||
|
||||
return((vm_offset_t)(imgbase + rva - sect_hdr->ish_vaddr +
|
||||
sect_hdr->ish_rawdataaddr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the section header for a particular section. Note that
|
||||
* section names can be anything, but there are some standard
|
||||
* ones (.text, .data, .rdata, .reloc).
|
||||
*/
|
||||
|
||||
int
|
||||
pe_get_section(imgbase, hdr, name)
|
||||
vm_offset_t imgbase;
|
||||
image_section_header *hdr;
|
||||
const char *name;
|
||||
{
|
||||
image_dos_header *dos_hdr;
|
||||
image_nt_header *nt_hdr;
|
||||
image_section_header *sect_hdr;
|
||||
|
||||
int i, sections;
|
||||
|
||||
if (imgbase == NULL || hdr == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
if (pe_is_nt_image(imgbase))
|
||||
return (EINVAL);
|
||||
|
||||
sections = pe_numsections(imgbase);
|
||||
|
||||
dos_hdr = (image_dos_header *)imgbase;
|
||||
nt_hdr = (image_nt_header *)(imgbase + dos_hdr->idh_lfanew);
|
||||
sect_hdr = (image_section_header *)((vm_offset_t)nt_hdr +
|
||||
sizeof(image_nt_header));
|
||||
|
||||
for (i = 0; i < sections; i++) {
|
||||
if (!strcmp ((char *)§_hdr->ish_name, name)) {
|
||||
bcopy((char *)sect_hdr, (char *)hdr,
|
||||
sizeof(image_section_header));
|
||||
return(0);
|
||||
} else
|
||||
sect_hdr++;
|
||||
}
|
||||
|
||||
return (ENOEXEC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Apply the base relocations to this image. The relocation table
|
||||
* resides within the .reloc section. Relocations are specified in
|
||||
* blocks which refer to a particular page. We apply the relocations
|
||||
* one page block at a time.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_relocate(imgbase)
|
||||
vm_offset_t imgbase;
|
||||
{
|
||||
image_section_header sect;
|
||||
image_base_reloc *relhdr;
|
||||
uint16_t rel, *sloc;
|
||||
uint32_t base, delta, *lloc;
|
||||
int i, count;
|
||||
vm_offset_t txt;
|
||||
|
||||
base = pe_imagebase(imgbase);
|
||||
pe_get_section(imgbase, §, ".text");
|
||||
txt = pe_translate_addr(imgbase, sect.ish_vaddr);
|
||||
delta = (uint32_t)(txt) - base - sect.ish_vaddr;
|
||||
|
||||
pe_get_section(imgbase, §, ".reloc");
|
||||
|
||||
relhdr = (image_base_reloc *)(imgbase + sect.ish_rawdataaddr);
|
||||
|
||||
do {
|
||||
count = (relhdr->ibr_blocksize -
|
||||
(sizeof(uint32_t) * 2)) / sizeof(uint16_t);
|
||||
for (i = 0; i < count; i++) {
|
||||
rel = relhdr->ibr_rel[i];
|
||||
switch (IMR_RELTYPE(rel)) {
|
||||
case IMAGE_REL_BASED_ABSOLUTE:
|
||||
break;
|
||||
case IMAGE_REL_BASED_HIGHLOW:
|
||||
lloc = (uint32_t *)pe_translate_addr(imgbase,
|
||||
relhdr->ibr_vaddr + IMR_RELOFFSET(rel));
|
||||
*lloc = pe_translate_addr(imgbase,
|
||||
(*lloc - base));
|
||||
break;
|
||||
case IMAGE_REL_BASED_HIGH:
|
||||
sloc = (uint16_t *)pe_translate_addr(imgbase,
|
||||
relhdr->ibr_vaddr + IMR_RELOFFSET(rel));
|
||||
*sloc += (delta & 0xFFFF0000) >> 16;
|
||||
break;
|
||||
case IMAGE_REL_BASED_LOW:
|
||||
sloc = (uint16_t *)pe_translate_addr(imgbase,
|
||||
relhdr->ibr_vaddr + IMR_RELOFFSET(rel));
|
||||
*sloc += (delta & 0xFFFF);
|
||||
break;
|
||||
default:
|
||||
printf ("[%d]reloc type: %d\n",i,
|
||||
IMR_RELTYPE(rel));
|
||||
break;
|
||||
}
|
||||
}
|
||||
relhdr = (image_base_reloc *)((vm_offset_t)relhdr +
|
||||
relhdr->ibr_blocksize);
|
||||
} while (relhdr->ibr_blocksize);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the import descriptor for a particular module. An image
|
||||
* may be linked against several modules, typically HAL.dll, ntoskrnl.exe
|
||||
* and NDIS.SYS. For each module, there is a list of imported function
|
||||
* names and their addresses.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_get_import_descriptor(imgbase, desc, module)
|
||||
vm_offset_t imgbase;
|
||||
image_import_descriptor *desc;
|
||||
char *module;
|
||||
{
|
||||
vm_offset_t offset;
|
||||
image_import_descriptor *imp_desc;
|
||||
char *modname;
|
||||
|
||||
if (imgbase == NULL || module == NULL || desc == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
offset = pe_directory_offset(imgbase, IMAGE_DIRECTORY_ENTRY_IMPORT);
|
||||
if (offset == 0)
|
||||
return (ENOENT);
|
||||
|
||||
imp_desc = (void *)offset;
|
||||
|
||||
while (imp_desc->iid_nameaddr) {
|
||||
modname = (char *)pe_translate_addr(imgbase,
|
||||
imp_desc->iid_nameaddr);
|
||||
if (!strncmp(module, modname, strlen(module))) {
|
||||
bcopy((char *)imp_desc, (char *)desc,
|
||||
sizeof(image_import_descriptor));
|
||||
return(0);
|
||||
}
|
||||
imp_desc++;
|
||||
}
|
||||
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the function that matches a particular name. This doesn't
|
||||
* need to be particularly speedy since it's only run when loading
|
||||
* a module for the first time.
|
||||
*/
|
||||
|
||||
static vm_offset_t
|
||||
pe_functbl_match(functbl, name)
|
||||
image_patch_table *functbl;
|
||||
char *name;
|
||||
{
|
||||
image_patch_table *p;
|
||||
|
||||
if (functbl == NULL || name == NULL)
|
||||
return(0);
|
||||
|
||||
p = functbl;
|
||||
|
||||
while (p->ipt_name != NULL) {
|
||||
if (!strcmp(p->ipt_name, name))
|
||||
return((uint32_t)p->ipt_func);
|
||||
p++;
|
||||
}
|
||||
printf ("no match for %s\n", name);
|
||||
return((vm_offset_t)p->ipt_func);
|
||||
}
|
||||
|
||||
/*
|
||||
* Patch the imported function addresses for a given module.
|
||||
* The caller must specify the module name and provide a table
|
||||
* of function pointers that will be patched into the jump table.
|
||||
* Note that there are actually two copies of the jump table: one
|
||||
* copy is left alone. In a .SYS file, the jump tables are usually
|
||||
* merged into the INIT segment.
|
||||
*
|
||||
* Note: Windows uses the _stdcall calling convention. This means
|
||||
* that the callback functions provided in the function table must
|
||||
* be declared using __attribute__((__stdcall__)), otherwise the
|
||||
* Windows code will likely screw up the %esp register and cause
|
||||
* us to jump to an invalid address when it returns.
|
||||
*/
|
||||
|
||||
int
|
||||
pe_patch_imports(imgbase, module, functbl)
|
||||
vm_offset_t imgbase;
|
||||
char *module;
|
||||
image_patch_table *functbl;
|
||||
{
|
||||
image_import_descriptor imp_desc;
|
||||
char *fname;
|
||||
vm_offset_t *nptr, *fptr;
|
||||
vm_offset_t func;
|
||||
|
||||
if (imgbase == NULL || module == NULL || functbl == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
if (pe_get_import_descriptor(imgbase, &imp_desc, module))
|
||||
return(ENOEXEC);
|
||||
|
||||
nptr = (vm_offset_t *)pe_translate_addr(imgbase,
|
||||
imp_desc.iid_import_name_table_addr);
|
||||
fptr = (vm_offset_t *)pe_translate_addr(imgbase,
|
||||
imp_desc.iid_import_address_table_addr);
|
||||
|
||||
while (nptr != NULL && pe_translate_addr(imgbase, *nptr) != NULL) {
|
||||
fname = (char *)pe_translate_addr(imgbase, (*nptr) + 2);
|
||||
func = pe_functbl_match(functbl, fname);
|
||||
if (func)
|
||||
*fptr = func;
|
||||
#ifdef notdef
|
||||
if (*fptr == 0)
|
||||
return(ENOENT);
|
||||
#endif
|
||||
nptr++;
|
||||
fptr++;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
@ -74,6 +74,11 @@ compat/linux/linux_stats.c optional compat_linux
|
||||
compat/linux/linux_sysctl.c optional compat_linux
|
||||
compat/linux/linux_uid16.c optional compat_linux
|
||||
compat/linux/linux_util.c optional compat_linux
|
||||
compat/ndis/kern_ndis.c optional ndisapi pci pccard
|
||||
compat/ndis/subr_hal.c optional ndisapi pci pccard
|
||||
compat/ndis/subr_ndis.c optional ndisapi pci pccard
|
||||
compat/ndis/subr_ntoskrnl.c optional ndisapi pci pccard
|
||||
compat/ndis/subr_pe.c optional ndisapi pci pccard
|
||||
compat/pecoff/imgact_pecoff.c optional pecoff_support
|
||||
compat/svr4/imgact_svr4.c optional compat_svr4
|
||||
compat/svr4/svr4_fcntl.c optional compat_svr4
|
||||
@ -127,6 +132,7 @@ dev/fb/fb.c optional vga
|
||||
dev/fb/splash.c optional splash
|
||||
dev/fb/vga.c optional vga
|
||||
dev/fe/if_fe_isa.c optional fe isa
|
||||
dev/if_ndis/if_ndis.c optional ndis pci pccard
|
||||
dev/kbd/atkbd.c optional atkbd
|
||||
dev/kbd/atkbdc.c optional atkbdc
|
||||
dev/kbd/kbd.c optional atkbd
|
||||
|
961
sys/dev/if_ndis/if_ndis.c
Normal file
961
sys/dev/if_ndis/if_ndis.c
Normal file
@ -0,0 +1,961 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_bdg.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
|
||||
#include <vm/vm.h> /* for vtophys */
|
||||
#include <vm/pmap.h> /* for vtophys */
|
||||
#include <machine/bus_memio.h>
|
||||
#include <machine/bus_pio.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <compat/ndis/pe_var.h>
|
||||
#include <compat/ndis/resource_var.h>
|
||||
#include <compat/ndis/ndis_var.h>
|
||||
#include <compat/ndis/cfg_var.h>
|
||||
#include <dev/if_ndis/if_ndisvar.h>
|
||||
|
||||
#include "ndis_driver_data.h"
|
||||
|
||||
MODULE_DEPEND(ndis, pci, 1, 1, 1);
|
||||
MODULE_DEPEND(ndis, ether, 1, 1, 1);
|
||||
MODULE_DEPEND(ndis, ndisapi, 1, 1, 1);
|
||||
|
||||
/*
|
||||
* Various supported device vendors/types and their names.
|
||||
* These are defined in the ndis_driver_data.h file.
|
||||
*/
|
||||
static struct ndis_type ndis_devs[] = {
|
||||
#ifdef NDIS_DEV_TABLE
|
||||
NDIS_DEV_TABLE
|
||||
#endif
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
#define __stdcall __attribute__((__stdcall__))
|
||||
|
||||
static int ndis_probe (device_t);
|
||||
static int ndis_attach (device_t);
|
||||
static int ndis_detach (device_t);
|
||||
|
||||
static __stdcall void ndis_txeof (ndis_handle,
|
||||
ndis_packet *, ndis_status);
|
||||
static __stdcall void ndis_rxeof (ndis_handle,
|
||||
ndis_packet **, uint32_t);
|
||||
static void ndis_intr (void *);
|
||||
static void ndis_tick (void *);
|
||||
static void ndis_start (struct ifnet *);
|
||||
static int ndis_ioctl (struct ifnet *, u_long, caddr_t);
|
||||
static void ndis_init (void *);
|
||||
static void ndis_stop (struct ndis_softc *);
|
||||
static void ndis_watchdog (struct ifnet *);
|
||||
static void ndis_shutdown (device_t);
|
||||
static int ndis_ifmedia_upd (struct ifnet *);
|
||||
static void ndis_ifmedia_sts (struct ifnet *, struct ifmediareq *);
|
||||
|
||||
static void ndis_reset (struct ndis_softc *);
|
||||
static void ndis_setmulti (struct ndis_softc *);
|
||||
static void ndis_map_sclist (void *, bus_dma_segment_t *,
|
||||
int, bus_size_t, int);
|
||||
|
||||
#ifdef NDIS_USEIOSPACE
|
||||
#define NDIS_RES SYS_RES_IOPORT
|
||||
#define NDIS_RID NDIS_PCI_LOIO
|
||||
#else
|
||||
#define NDIS_RES SYS_RES_MEMORY
|
||||
#define NDIS_RID NDIS_PCI_LOMEM
|
||||
#endif
|
||||
|
||||
static device_method_t ndis_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, ndis_probe),
|
||||
DEVMETHOD(device_attach, ndis_attach),
|
||||
DEVMETHOD(device_detach, ndis_detach),
|
||||
DEVMETHOD(device_shutdown, ndis_shutdown),
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t ndis_driver = {
|
||||
"ndis",
|
||||
ndis_methods,
|
||||
sizeof(struct ndis_softc)
|
||||
};
|
||||
|
||||
static devclass_t ndis_devclass;
|
||||
|
||||
DRIVER_MODULE(ndis, pci, ndis_driver, ndis_devclass, 0, 0);
|
||||
|
||||
/*
|
||||
* Program the 64-bit multicast hash filter.
|
||||
*/
|
||||
static void
|
||||
ndis_setmulti(sc)
|
||||
struct ndis_softc *sc;
|
||||
{
|
||||
#ifdef notyet
|
||||
uint32_t ndis_filter;
|
||||
int len;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ndis_reset(sc)
|
||||
struct ndis_softc *sc;
|
||||
{
|
||||
ndis_reset_nic(sc);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Probe for an NDIS device. Check the PCI vendor and device
|
||||
* IDs against our list and return a device name if we find a match.
|
||||
*/
|
||||
static int
|
||||
ndis_probe(dev)
|
||||
device_t dev;
|
||||
{
|
||||
struct ndis_type *t;
|
||||
|
||||
t = ndis_devs;
|
||||
|
||||
while(t->ndis_name != NULL) {
|
||||
if ((pci_get_vendor(dev) == t->ndis_vid) &&
|
||||
(pci_get_device(dev) == t->ndis_did)) {
|
||||
device_set_desc(dev, t->ndis_name);
|
||||
return(0);
|
||||
}
|
||||
t++;
|
||||
}
|
||||
|
||||
return(ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach the interface. Allocate softc structures, do ifmedia
|
||||
* setup and ethernet/BPF attach.
|
||||
*/
|
||||
static int
|
||||
ndis_attach(dev)
|
||||
device_t dev;
|
||||
{
|
||||
u_char eaddr[ETHER_ADDR_LEN];
|
||||
struct ndis_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
int unit, error = 0, rid, len;
|
||||
void *img;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
unit = device_get_unit(dev);
|
||||
|
||||
mtx_init(&sc->ndis_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
||||
MTX_DEF | MTX_RECURSE);
|
||||
|
||||
/*
|
||||
* Map control/status registers.
|
||||
*/
|
||||
pci_enable_busmaster(dev);
|
||||
|
||||
/* Try to map iospace */
|
||||
|
||||
sc->ndis_io_rid = NDIS_PCI_LOIO;
|
||||
sc->ndis_res_io = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
||||
&sc->ndis_io_rid, 0, ~0, 1, RF_ACTIVE);
|
||||
|
||||
/*
|
||||
* Sometimes the iospace and memspace BARs are swapped.
|
||||
* Make one more try to map I/O space using a different
|
||||
* RID.
|
||||
*/
|
||||
if (sc->ndis_res_io == NULL) {
|
||||
sc->ndis_io_rid = NDIS_PCI_LOMEM;
|
||||
sc->ndis_res_io = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
||||
&sc->ndis_io_rid, 0, ~0, 1, RF_ACTIVE);
|
||||
}
|
||||
|
||||
if (sc->ndis_res_io != NULL)
|
||||
sc->ndis_rescnt++;
|
||||
|
||||
/* Now try to mem memory space */
|
||||
sc->ndis_mem_rid = NDIS_PCI_LOMEM;
|
||||
sc->ndis_res_mem = bus_alloc_resource(dev, SYS_RES_MEMORY,
|
||||
&sc->ndis_mem_rid, 0, ~0, 1, RF_ACTIVE);
|
||||
|
||||
/*
|
||||
* If the first attempt fails, try again with another
|
||||
* BAR.
|
||||
*/
|
||||
if (sc->ndis_res_mem == NULL) {
|
||||
sc->ndis_mem_rid = NDIS_PCI_LOIO;
|
||||
sc->ndis_res_mem = bus_alloc_resource(dev, SYS_RES_MEMORY,
|
||||
&sc->ndis_mem_rid, 0, ~0, 1, RF_ACTIVE);
|
||||
}
|
||||
|
||||
if (sc->ndis_res_mem != NULL)
|
||||
sc->ndis_rescnt++;
|
||||
|
||||
if (!sc->ndis_rescnt) {
|
||||
printf("ndis%d: couldn't map ports/memory\n", unit);
|
||||
error = ENXIO;
|
||||
goto fail;
|
||||
}
|
||||
#ifdef notdef
|
||||
sc->ndis_btag = rman_get_bustag(sc->ndis_res);
|
||||
sc->ndis_bhandle = rman_get_bushandle(sc->ndis_res);
|
||||
#endif
|
||||
|
||||
/* Allocate interrupt */
|
||||
rid = 0;
|
||||
sc->ndis_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
|
||||
RF_SHAREABLE | RF_ACTIVE);
|
||||
|
||||
if (sc->ndis_irq == NULL) {
|
||||
printf("ndis%d: couldn't map interrupt\n", unit);
|
||||
error = ENXIO;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sc->ndis_rescnt++;
|
||||
|
||||
/*
|
||||
* Allocate the parent bus DMA tag appropriate for PCI.
|
||||
*/
|
||||
#define NDIS_NSEG_NEW 32
|
||||
error = bus_dma_tag_create(NULL, /* parent */
|
||||
1, 0, /* alignment, boundary */
|
||||
BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
MAXBSIZE, NDIS_NSEG_NEW,/* maxsize, nsegments */
|
||||
BUS_SPACE_MAXSIZE_32BIT,/* maxsegsize */
|
||||
BUS_DMA_ALLOCNOW, /* flags */
|
||||
NULL, NULL, /* lockfunc, lockarg */
|
||||
&sc->ndis_parent_tag);
|
||||
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
img = drv_data;
|
||||
sc->ndis_dev = dev;
|
||||
sc->ndis_regvals = ndis_regvals;
|
||||
sc->ndis_iftype = PCIBus;
|
||||
|
||||
sysctl_ctx_init(&sc->ndis_ctx);
|
||||
|
||||
/* Create sysctl registry nodes */
|
||||
ndis_create_sysctls(sc);
|
||||
|
||||
/* Set up driver image in memory. */
|
||||
ndis_load_driver((vm_offset_t)img, sc);
|
||||
|
||||
/* Do resource conversion. */
|
||||
ndis_convert_res(sc);
|
||||
|
||||
/* Install our RX and TX interrupt handlers. */
|
||||
sc->ndis_block.nmb_senddone_func = ndis_txeof;
|
||||
sc->ndis_block.nmb_pktind_func = ndis_rxeof;
|
||||
|
||||
/* Call driver's init routine. */
|
||||
if (ndis_init_nic(sc)) {
|
||||
printf ("ndis%d: init handler failed\n", sc->ndis_unit);
|
||||
error = ENXIO;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Reset the adapter. */
|
||||
ndis_reset(sc);
|
||||
|
||||
/*
|
||||
* Get station address from the driver.
|
||||
*/
|
||||
len = sizeof(eaddr);
|
||||
ndis_get_info(sc, OID_802_3_CURRENT_ADDRESS, &eaddr, &len);
|
||||
|
||||
/*
|
||||
* An NDIS device was detected. Inform the world.
|
||||
*/
|
||||
printf("ndis%d: Ethernet address: %6D\n", unit, eaddr, ":");
|
||||
|
||||
sc->ndis_unit = unit;
|
||||
bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
|
||||
|
||||
/*
|
||||
* Figure out of we're allowed to use multipacket sends
|
||||
* with this driver, and if so, how many.
|
||||
*/
|
||||
|
||||
if (sc->ndis_chars.nmc_sendsingle_func)
|
||||
sc->ndis_maxpkts = 1;
|
||||
else {
|
||||
len = sizeof(sc->ndis_maxpkts);
|
||||
ndis_get_info(sc, OID_GEN_MAXIMUM_SEND_PACKETS,
|
||||
&sc->ndis_maxpkts, &len);
|
||||
sc->ndis_txarray = malloc(sizeof(ndis_packet *) *
|
||||
sc->ndis_maxpkts, M_DEVBUF, M_NOWAIT);
|
||||
bzero((char *)sc->ndis_txarray, sizeof(ndis_packet *) *
|
||||
sc->ndis_maxpkts);
|
||||
}
|
||||
|
||||
sc->ndis_txpending = sc->ndis_maxpkts;
|
||||
sc->ndis_mbufs = malloc(sizeof(struct mbuf) * sc->ndis_maxpkts,
|
||||
M_DEVBUF, M_NOWAIT);
|
||||
|
||||
if (sc->ndis_mbufs == NULL)
|
||||
goto fail;
|
||||
|
||||
sc->ndis_oidcnt = 0;
|
||||
/* Get supported oid list. */
|
||||
ndis_get_supported_oids(sc, &sc->ndis_oids, &sc->ndis_oidcnt);
|
||||
|
||||
/* If the NDIS module requested scatter/gather, init maps. */
|
||||
if (sc->ndis_sc)
|
||||
ndis_init_dma(sc);
|
||||
|
||||
ifmedia_init(&sc->ifmedia, IFM_IMASK, ndis_ifmedia_upd,
|
||||
ndis_ifmedia_sts);
|
||||
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL);
|
||||
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL);
|
||||
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_100_TX, 0, NULL);
|
||||
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_100_TX|IFM_FDX, 0, NULL);
|
||||
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL);
|
||||
ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO);
|
||||
|
||||
ifp = &sc->arpcom.ac_if;
|
||||
ifp->if_softc = sc;
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
ifp->if_mtu = ETHERMTU;
|
||||
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
||||
ifp->if_ioctl = ndis_ioctl;
|
||||
ifp->if_output = ether_output;
|
||||
ifp->if_start = ndis_start;
|
||||
ifp->if_watchdog = ndis_watchdog;
|
||||
ifp->if_init = ndis_init;
|
||||
ifp->if_baudrate = 10000000;
|
||||
ifp->if_snd.ifq_maxlen = 50;
|
||||
|
||||
/*
|
||||
* Call MI attach routine.
|
||||
*/
|
||||
ether_ifattach(ifp, eaddr);
|
||||
|
||||
/* Hook interrupt last to avoid having to lock softc */
|
||||
error = bus_setup_intr(dev, sc->ndis_irq, INTR_TYPE_NET,
|
||||
ndis_intr, sc, &sc->ndis_intrhand);
|
||||
|
||||
if (error) {
|
||||
printf("ndis%d: couldn't set up irq\n", unit);
|
||||
ether_ifdetach(ifp);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fail:
|
||||
if (error)
|
||||
ndis_detach(dev);
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown hardware and free up resources. This can be called any
|
||||
* time after the mutex has been initialized. It is called in both
|
||||
* the error case in attach and the normal detach case so it needs
|
||||
* to be careful about only freeing resources that have actually been
|
||||
* allocated.
|
||||
*/
|
||||
static int
|
||||
ndis_detach(dev)
|
||||
device_t dev;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
KASSERT(mtx_initialized(&sc->ndis_mtx), ("ndis mutex not initialized"));
|
||||
NDIS_LOCK(sc);
|
||||
ifp = &sc->arpcom.ac_if;
|
||||
|
||||
if (device_is_attached(dev)) {
|
||||
NDIS_UNLOCK(sc);
|
||||
ndis_stop(sc);
|
||||
ether_ifdetach(ifp);
|
||||
NDIS_LOCK(sc);
|
||||
}
|
||||
|
||||
bus_generic_detach(dev);
|
||||
|
||||
if (sc->ndis_intrhand)
|
||||
bus_teardown_intr(dev, sc->ndis_irq, sc->ndis_intrhand);
|
||||
if (sc->ndis_irq)
|
||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq);
|
||||
if (sc->ndis_res_io)
|
||||
bus_release_resource(dev, SYS_RES_IOPORT,
|
||||
sc->ndis_io_rid, sc->ndis_res_io);
|
||||
if (sc->ndis_res_mem)
|
||||
bus_release_resource(dev, SYS_RES_MEMORY,
|
||||
sc->ndis_mem_rid, sc->ndis_res_mem);
|
||||
|
||||
if (sc->ndis_sc)
|
||||
ndis_destroy_dma(sc);
|
||||
|
||||
ndis_unload_driver((void *)ifp);
|
||||
|
||||
bus_dma_tag_destroy(sc->ndis_parent_tag);
|
||||
|
||||
sysctl_ctx_free(&sc->ndis_ctx);
|
||||
|
||||
NDIS_UNLOCK(sc);
|
||||
mtx_destroy(&sc->ndis_mtx);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* A frame has been uploaded: pass the resulting mbuf chain up to
|
||||
* the higher level protocols.
|
||||
*/
|
||||
__stdcall static void
|
||||
ndis_rxeof(adapter, packets, pktcnt)
|
||||
ndis_handle adapter;
|
||||
ndis_packet **packets;
|
||||
uint32_t pktcnt;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
ndis_miniport_block *block;
|
||||
ndis_packet *p;
|
||||
struct ifnet *ifp;
|
||||
struct mbuf *m0;
|
||||
int i;
|
||||
|
||||
block = (ndis_miniport_block *)adapter;
|
||||
sc = (struct ndis_softc *)(block->nmb_ifp);
|
||||
ifp = block->nmb_ifp;
|
||||
|
||||
for (i = 0; i < pktcnt; i++) {
|
||||
p = packets[i];
|
||||
if (ndis_ptom(&m0, p)) {
|
||||
printf ("ndis%d: ptom failed\n", sc->ndis_unit);
|
||||
ndis_return_packet(sc, p);
|
||||
} else {
|
||||
MEXTADD(m0, m0->m_data, m0->m_pkthdr.len,
|
||||
ndis_return_packet, sc, 0, EXT_NET_DRV);
|
||||
m0->m_ext.ext_buf = (void *)p; /* XXX */
|
||||
m0->m_pkthdr.rcvif = ifp;
|
||||
ifp->if_ipackets++;
|
||||
(*ifp->if_input)(ifp, m0);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* A frame was downloaded to the chip. It's safe for us to clean up
|
||||
* the list buffers.
|
||||
*/
|
||||
__stdcall static void
|
||||
ndis_txeof(adapter, packet, status)
|
||||
ndis_handle adapter;
|
||||
ndis_packet *packet;
|
||||
ndis_status status;
|
||||
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
ndis_miniport_block *block;
|
||||
struct ifnet *ifp;
|
||||
int idx;
|
||||
|
||||
block = (ndis_miniport_block *)adapter;
|
||||
sc = (struct ndis_softc *)block->nmb_ifp;
|
||||
ifp = block->nmb_ifp;
|
||||
|
||||
if (packet->np_rsvd[1] != NULL) {
|
||||
idx = (int)packet->np_rsvd[1];
|
||||
ifp->if_opackets++;
|
||||
if (sc->ndis_mbufs[idx] != NULL) {
|
||||
m_freem(sc->ndis_mbufs[idx]);
|
||||
sc->ndis_mbufs[idx] = NULL;
|
||||
}
|
||||
if (sc->ndis_sc)
|
||||
bus_dmamap_unload(sc->ndis_ttag, sc->ndis_tmaps[idx]);
|
||||
}
|
||||
|
||||
ndis_free_packet(packet);
|
||||
sc->ndis_txpending++;
|
||||
|
||||
ifp->if_timer = 0;
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
|
||||
if (ifp->if_snd.ifq_head != NULL)
|
||||
ndis_start(ifp);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ndis_intr(arg)
|
||||
void *arg;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
int is_our_intr = 0;
|
||||
int call_isr = 0;
|
||||
|
||||
sc = arg;
|
||||
/*NDIS_LOCK(sc);*/
|
||||
ifp = &sc->arpcom.ac_if;
|
||||
|
||||
/*
|
||||
if (!(ifp->if_flags & IFF_UP)) {
|
||||
NDIS_UNLOCK(sc);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
ndis_isr(sc, &is_our_intr, &call_isr);
|
||||
|
||||
if (is_our_intr || call_isr)
|
||||
ndis_intrhand(sc);
|
||||
|
||||
if (ifp->if_snd.ifq_head != NULL)
|
||||
ndis_start(ifp);
|
||||
|
||||
/*NDIS_UNLOCK(sc);*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ndis_tick(xsc)
|
||||
void *xsc;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
__stdcall ndis_checkforhang_handler hangfunc;
|
||||
uint8_t rval;
|
||||
|
||||
sc = xsc;
|
||||
NDIS_LOCK(sc);
|
||||
|
||||
hangfunc = sc->ndis_chars.nmc_checkhang_func;
|
||||
|
||||
if (hangfunc != NULL) {
|
||||
rval = hangfunc(sc->ndis_block.nmb_miniportadapterctx);
|
||||
if (rval == TRUE)
|
||||
ndis_reset_nic(sc);
|
||||
}
|
||||
|
||||
sc->ndis_stat_ch = timeout(ndis_tick, sc, hz *
|
||||
sc->ndis_block.nmb_checkforhangsecs);
|
||||
|
||||
NDIS_UNLOCK(sc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ndis_map_sclist(arg, segs, nseg, mapsize, error)
|
||||
void *arg;
|
||||
bus_dma_segment_t *segs;
|
||||
int nseg;
|
||||
bus_size_t mapsize;
|
||||
int error;
|
||||
|
||||
{
|
||||
struct ndis_sc_list *sclist;
|
||||
int i;
|
||||
|
||||
if (error || arg == NULL)
|
||||
return;
|
||||
|
||||
sclist = arg;
|
||||
|
||||
sclist->nsl_frags = nseg;
|
||||
|
||||
for (i = 0; i < nseg; i++) {
|
||||
sclist->nsl_elements[i].nse_addr.np_quad = segs[i].ds_addr;
|
||||
sclist->nsl_elements[i].nse_len = segs[i].ds_len;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Main transmit routine. To make NDIS drivers happy, we need to
|
||||
* transform mbuf chains into NDIS packets and feed them to the
|
||||
* send packet routines. Most drivers allow you to send several
|
||||
* packets at once (up to the maxpkts limit). Unfortunately, rather
|
||||
* that accepting them in the form of a linked list, they expect
|
||||
* a contiguous array of pointers to packets.
|
||||
*
|
||||
* For those drivers which use the NDIS scatter/gather DMA mechanism,
|
||||
* we need to perform busdma work here. Those that use map registers
|
||||
* will do the mapping themselves on a buffer by buffer basis.
|
||||
*/
|
||||
|
||||
static void
|
||||
ndis_start(ifp)
|
||||
struct ifnet *ifp;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
struct mbuf *m = NULL;
|
||||
ndis_packet **p0 = NULL, *p = NULL;
|
||||
int pcnt = 0;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
|
||||
p0 = &sc->ndis_txarray[sc->ndis_txidx];
|
||||
|
||||
while(sc->ndis_txpending) {
|
||||
IF_DEQUEUE(&ifp->if_snd, m);
|
||||
if (m == NULL)
|
||||
break;
|
||||
|
||||
NDIS_LOCK(sc);
|
||||
sc->ndis_txarray[sc->ndis_txidx] = NULL;
|
||||
if (ndis_mtop(m, &sc->ndis_txarray[sc->ndis_txidx])) {
|
||||
NDIS_UNLOCK(sc);
|
||||
IF_PREPEND(&ifp->if_snd, m);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save pointer to original mbuf
|
||||
* so we can free it later.
|
||||
*/
|
||||
|
||||
sc->ndis_mbufs[sc->ndis_txidx] = m;
|
||||
(sc->ndis_txarray[sc->ndis_txidx])->np_rsvd[1] =
|
||||
(uint32_t *)sc->ndis_txidx;
|
||||
|
||||
/*
|
||||
* Do scatter/gather processing, if driver requested it.
|
||||
*/
|
||||
if (sc->ndis_sc) {
|
||||
p = sc->ndis_txarray[sc->ndis_txidx];
|
||||
bus_dmamap_load_mbuf(sc->ndis_ttag,
|
||||
sc->ndis_tmaps[sc->ndis_txidx], m,
|
||||
ndis_map_sclist, &p->np_sclist, BUS_DMA_NOWAIT);
|
||||
bus_dmamap_sync(sc->ndis_ttag,
|
||||
sc->ndis_tmaps[sc->ndis_txidx],
|
||||
BUS_DMASYNC_PREREAD);
|
||||
p->np_ext.npe_info[ndis_sclist_info] = &p->np_sclist;
|
||||
}
|
||||
|
||||
NDIS_INC(sc);
|
||||
sc->ndis_txpending--;
|
||||
NDIS_UNLOCK(sc);
|
||||
|
||||
pcnt++;
|
||||
|
||||
/*
|
||||
* If there's a BPF listener, bounce a copy of this frame
|
||||
* to him.
|
||||
*/
|
||||
|
||||
BPF_MTAP(ifp, m);
|
||||
|
||||
/*
|
||||
* The array that p0 points to must appear contiguous,
|
||||
* so we must not wrap past the end of sc->ndis_txarray[].
|
||||
* If it looks like we're about to wrap, break out here
|
||||
* so the this batch of packets can be transmitted, then
|
||||
* wait for txeof to ask us to send the rest.
|
||||
*/
|
||||
|
||||
if (sc->ndis_txidx == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (sc->ndis_txpending == 0)
|
||||
ifp->if_flags |= IFF_OACTIVE;
|
||||
|
||||
ndis_send_packets(sc, p0, pcnt);
|
||||
|
||||
/*
|
||||
* Set a timeout in case the chip goes out to lunch.
|
||||
*/
|
||||
ifp->if_timer = 5;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ndis_init(xsc)
|
||||
void *xsc;
|
||||
{
|
||||
struct ndis_softc *sc = xsc;
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
int i, error;
|
||||
uint32_t ndis_filter = 0;
|
||||
|
||||
/*NDIS_LOCK(sc);*/
|
||||
|
||||
/*
|
||||
* Cancel pending I/O and free all RX/TX buffers.
|
||||
*/
|
||||
ndis_reset(sc);
|
||||
ndis_stop(sc);
|
||||
ndis_init_nic(sc);
|
||||
|
||||
/* Init our MAC address */
|
||||
#ifdef notdef
|
||||
/*
|
||||
* Program the multicast filter, if necessary.
|
||||
*/
|
||||
ndis_setmulti(sc);
|
||||
#endif
|
||||
|
||||
/* Program the packet filter */
|
||||
|
||||
ndis_filter = NDIS_PACKET_TYPE_DIRECTED;
|
||||
|
||||
if (ifp->if_flags & IFF_BROADCAST)
|
||||
ndis_filter |= NDIS_PACKET_TYPE_BROADCAST;
|
||||
|
||||
if (ifp->if_flags & IFF_PROMISC)
|
||||
ndis_filter |= NDIS_PACKET_TYPE_PROMISCUOUS;
|
||||
|
||||
if (ifp->if_flags & IFF_MULTICAST)
|
||||
ndis_filter |= NDIS_PACKET_TYPE_MULTICAST;
|
||||
|
||||
i = sizeof(ndis_filter);
|
||||
|
||||
error = ndis_set_info(sc, OID_GEN_CURRENT_PACKET_FILTER,
|
||||
&ndis_filter, &i);
|
||||
|
||||
if (error)
|
||||
printf ("set filter failed: %d\n", error);
|
||||
|
||||
ifp->if_flags |= IFF_RUNNING;
|
||||
ifp->if_flags &= ~IFF_OACTIVE;
|
||||
|
||||
if (sc->ndis_chars.nmc_checkhang_func != NULL)
|
||||
sc->ndis_stat_ch = timeout(ndis_tick, sc,
|
||||
hz * sc->ndis_block.nmb_checkforhangsecs);
|
||||
|
||||
/*NDIS_UNLOCK(sc);*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set media options.
|
||||
*/
|
||||
static int
|
||||
ndis_ifmedia_upd(ifp)
|
||||
struct ifnet *ifp;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
|
||||
if (ifp->if_flags & IFF_UP)
|
||||
ndis_init(sc);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Report current media status.
|
||||
*/
|
||||
static void
|
||||
ndis_ifmedia_sts(ifp, ifmr)
|
||||
struct ifnet *ifp;
|
||||
struct ifmediareq *ifmr;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
uint32_t media_info;
|
||||
ndis_media_state linkstate;
|
||||
int error, len;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
|
||||
len = sizeof(linkstate);
|
||||
error = ndis_get_info(sc, OID_GEN_MEDIA_CONNECT_STATUS,
|
||||
(void *)&linkstate, &len);
|
||||
|
||||
len = sizeof(media_info);
|
||||
error = ndis_get_info(sc, OID_GEN_LINK_SPEED,
|
||||
(void *)&media_info, &len);
|
||||
|
||||
ifmr->ifm_status = IFM_AVALID;
|
||||
ifmr->ifm_active = IFM_ETHER;
|
||||
|
||||
if (linkstate == nmc_connected)
|
||||
ifmr->ifm_status |= IFM_ACTIVE;
|
||||
|
||||
switch(media_info) {
|
||||
case 100000:
|
||||
ifmr->ifm_active |= IFM_10_T;
|
||||
break;
|
||||
case 1000000:
|
||||
ifmr->ifm_active |= IFM_100_TX;
|
||||
break;
|
||||
case 10000000:
|
||||
ifmr->ifm_active |= IFM_1000_T;
|
||||
break;
|
||||
default:
|
||||
printf("ndis%d: unknown speed: %d\n",
|
||||
sc->ndis_unit, media_info);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
ndis_ioctl(ifp, command, data)
|
||||
struct ifnet *ifp;
|
||||
u_long command;
|
||||
caddr_t data;
|
||||
{
|
||||
struct ndis_softc *sc = ifp->if_softc;
|
||||
struct ifreq *ifr = (struct ifreq *) data;
|
||||
int error = 0;
|
||||
|
||||
/*NDIS_LOCK(sc);*/
|
||||
|
||||
switch(command) {
|
||||
case SIOCSIFFLAGS:
|
||||
if (ifp->if_flags & IFF_UP) {
|
||||
ndis_init(sc);
|
||||
} else {
|
||||
if (ifp->if_flags & IFF_RUNNING)
|
||||
ndis_stop(sc);
|
||||
}
|
||||
error = 0;
|
||||
break;
|
||||
case SIOCADDMULTI:
|
||||
case SIOCDELMULTI:
|
||||
ndis_setmulti(sc);
|
||||
error = 0;
|
||||
break;
|
||||
case SIOCGIFMEDIA:
|
||||
case SIOCSIFMEDIA:
|
||||
error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command);
|
||||
break;
|
||||
default:
|
||||
error = ether_ioctl(ifp, command, data);
|
||||
break;
|
||||
}
|
||||
|
||||
/*NDIS_UNLOCK(sc);*/
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
||||
static void
|
||||
ndis_watchdog(ifp)
|
||||
struct ifnet *ifp;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
|
||||
sc = ifp->if_softc;
|
||||
|
||||
NDIS_LOCK(sc);
|
||||
ifp->if_oerrors++;
|
||||
printf("ndis%d: watchdog timeout\n", sc->ndis_unit);
|
||||
|
||||
ndis_reset(sc);
|
||||
|
||||
if (ifp->if_snd.ifq_head != NULL)
|
||||
ndis_start(ifp);
|
||||
NDIS_UNLOCK(sc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop the adapter and free any mbufs allocated to the
|
||||
* RX and TX lists.
|
||||
*/
|
||||
static void
|
||||
ndis_stop(sc)
|
||||
struct ndis_softc *sc;
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
/* NDIS_LOCK(sc);*/
|
||||
ifp = &sc->arpcom.ac_if;
|
||||
ifp->if_timer = 0;
|
||||
|
||||
untimeout(ndis_tick, sc, sc->ndis_stat_ch);
|
||||
|
||||
ndis_halt_nic(sc);
|
||||
|
||||
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
|
||||
/*NDIS_UNLOCK(sc);*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop all chip I/O so that the kernel's probe routines don't
|
||||
* get confused by errant DMAs when rebooting.
|
||||
*/
|
||||
static void
|
||||
ndis_shutdown(dev)
|
||||
device_t dev;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
/* ndis_shutdown_nic(sc); */
|
||||
|
||||
return;
|
||||
}
|
121
sys/dev/if_ndis/if_ndisvar.h
Normal file
121
sys/dev/if_ndis/if_ndisvar.h
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#define NDIS_PCI_LOIO 0x10
|
||||
#define NDIS_PCI_LOMEM 0x14
|
||||
|
||||
|
||||
struct ndis_chain_onefrag {
|
||||
void *dummy;
|
||||
};
|
||||
|
||||
struct ndis_chain {
|
||||
void *dummy;
|
||||
};
|
||||
|
||||
struct ndis_type {
|
||||
uint16_t ndis_vid;
|
||||
uint16_t ndis_did;
|
||||
char *ndis_name;
|
||||
};
|
||||
|
||||
struct ndis_shmem {
|
||||
bus_dma_tag_t ndis_stag;
|
||||
bus_dmamap_t ndis_smap;
|
||||
void *ndis_saddr;
|
||||
struct ndis_shmem *ndis_next;
|
||||
};
|
||||
|
||||
struct ndis_cfglist {
|
||||
ndis_cfg ndis_cfg;
|
||||
TAILQ_ENTRY(ndis_cfglist) link;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(nch, ndis_cfglist);
|
||||
|
||||
#define NDIS_INC(x) \
|
||||
(x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
|
||||
|
||||
struct ndis_softc {
|
||||
struct arpcom arpcom; /* interface info */
|
||||
struct ifmedia ifmedia; /* media info */
|
||||
bus_space_handle_t ndis_bhandle;
|
||||
bus_space_tag_t ndis_btag;
|
||||
void *ndis_intrhand;
|
||||
struct resource *ndis_irq;
|
||||
struct resource *ndis_res;
|
||||
struct resource *ndis_res_io;
|
||||
int ndis_io_rid;
|
||||
struct resource *ndis_res_mem;
|
||||
int ndis_mem_rid;
|
||||
struct resource *ndis_res_altmem;
|
||||
int ndis_altmem_rid;
|
||||
struct resource *ndis_res_am; /* attribute mem (pccard) */
|
||||
struct resource *ndis_res_cm; /* common mem (pccard) */
|
||||
int ndis_rescnt;
|
||||
struct mtx ndis_mtx;
|
||||
device_t ndis_dev;
|
||||
int ndis_unit;
|
||||
ndis_miniport_block ndis_block;
|
||||
ndis_miniport_characteristics ndis_chars;
|
||||
interface_type ndis_type;
|
||||
struct callout_handle ndis_stat_ch;
|
||||
int ndis_maxpkts;
|
||||
ndis_oid *ndis_oids;
|
||||
int ndis_oidcnt;
|
||||
int ndis_txidx;
|
||||
int ndis_txpending;
|
||||
ndis_packet **ndis_txarray;
|
||||
int ndis_sc;
|
||||
ndis_cfg *ndis_regvals;
|
||||
struct nch ndis_cfglist_head;
|
||||
|
||||
struct sysctl_ctx_list ndis_ctx;
|
||||
struct sysctl_oid *ndis_tree;
|
||||
interface_type ndis_iftype;
|
||||
|
||||
bus_dma_tag_t ndis_parent_tag;
|
||||
struct ndis_shmem *ndis_shlist;
|
||||
bus_dma_tag_t ndis_mtag;
|
||||
bus_dma_tag_t ndis_ttag;
|
||||
bus_dmamap_t *ndis_mmaps;
|
||||
bus_dmamap_t *ndis_tmaps;
|
||||
struct mbuf **ndis_mbufs;
|
||||
int ndis_mmapcnt;
|
||||
|
||||
};
|
||||
|
||||
#define NDIS_LOCK(_sc) mtx_lock(&(_sc)->ndis_mtx)
|
||||
#define NDIS_UNLOCK(_sc) mtx_unlock(&(_sc)->ndis_mtx)
|
||||
|
@ -53,6 +53,7 @@ SUBDIR= accf_data \
|
||||
if_faith \
|
||||
if_gif \
|
||||
if_gre \
|
||||
if_ndis \
|
||||
if_ppp \
|
||||
if_sl \
|
||||
if_stf \
|
||||
@ -90,6 +91,7 @@ SUBDIR= accf_data \
|
||||
msdosfs \
|
||||
msdosfs_iconv \
|
||||
my \
|
||||
ndis \
|
||||
nfsclient \
|
||||
nfsserver \
|
||||
nge \
|
||||
|
9
sys/modules/if_ndis/Makefile
Normal file
9
sys/modules/if_ndis/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../compat/ndis
|
||||
|
||||
KMOD= if_ndis
|
||||
SRCS= if_ndis.c
|
||||
SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h card_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
9
sys/modules/ndis/Makefile
Normal file
9
sys/modules/ndis/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../dev/if_ndis
|
||||
|
||||
KMOD= ndis
|
||||
SRCS= subr_pe.c subr_ndis.c subr_hal.c subr_ntoskrnl.c kern_ndis.c
|
||||
SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h card_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
x
Reference in New Issue
Block a user