summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ndiscvt
Commit message (Collapse)AuthorAgeFilesLines
* Use NO_WCAST_ALIGN for usr.sbin/ndiscvt; because this is only built fordim2011-12-172-0/+2
| | | | | | | x86, any alignment warnings can be safely ignored. Define YY_NO_INPUT in usr.sbin/ndiscvt/inf-token.l, so no unused lex functions are defined. MFC after: 1 week
* Use new output format 'elf64-x86-64-freebsd' instead of 'elf64-x86-64',dim2010-11-011-2/+2
| | | | and similarly 'elf64-sparc-freebsd' instead of 'elf64-sparc'.
* ANSIfy some more tools in usr.sbin/.ed2010-01-021-4/+2
| | | | | Most of these tools build with WARNS=6, except for their use of K&R function declarations.
* Integrate the NDIS USB support code to CURRENT.weongyo2008-12-272-0/+139
| | | | | | | | | | | | | | | | | | | | | | | | Now the NDISulator supports NDIS USB drivers that it've tested with devices as follows: - Anygate XM-142 (Conexant) - Netgear WG111v2 (Realtek) - U-Khan UW-2054u (Marvell) - Shuttle XPC Accessory PN20 (Realtek) - ipTIME G054U2 (Ralink) - UNiCORN WL-54G (ZyDAS) - ZyXEL G-200v2 (ZyDAS) All of them succeeded to attach and worked though there are still some problems that it's expected to be solved. To use NDIS USB support, you should rebuild and install ndiscvt(8) and if you encounter a problem to attach please set `hw.ndisusb.halt' to 0 then retry. I expect no changes of the NDIS code for PCI, PCMCIA devices. Obtained from: //depot/projects/ndisusb/...
* remove reference for unexisting ndisapi(9)weongyo2008-07-231-2/+1
|
* handle .INF files for PCMCIA correctly that specify multiple entries inweongyo2008-06-181-7/+13
| | | | | | their [Manufacturer] sections and prevent a case that NDIS_PCI_DEV_TABLE definition was always emitted that it's only emitted once if a .INF file is for PCI.
* If the .inf file did not have a Default entry for the registry key then writethompsa2008-04-151-1/+3
| | | | out a blank value and close the brackets on the ndis_regvals array.
* Use a ndis_ prefix on the C variable instead of directly using the .systhompsa2008-04-152-7/+7
| | | | | | | filename, this would fail if the filename started with a number. PR: bin/84911 Submitted by: Fredrik Lindberg
* Remove ndisapi.9 Xref.trhodes2006-10-101-2/+1
| | | | PR: 97375
* Silence GCC4 signed/unsigned pointer mismatch warning.kan2006-09-211-1/+1
|
* Clean up and apply the fix for PR 83477. The calculation for locatingwpaul2005-10-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | the start of the section headers has to take into account the fact that the image_nt_header is really variable sized. It happens that the existing calculation is correct for _most_ production binaries produced by the Windows DDK, but if we get a binary with oddball offsets, the PE loader could crash. Changes from the supplied patch are: - We don't really need to use the IMAGE_SIZEOF_NT_HEADER() macro when computing how much of the header to return to callers of pe_get_optional_header(). While it's important to take the variable size of the header into account in other calculations, we never actually look at anything outside the non-variable portion of the header. This saves callers from having to allocate a variable sized buffer off the heap (I purposely tried to avoid using malloc() in subr_pe.c to make it easier to compile in both the -D_KERNEL and !-D_KERNEL case), and since we're copying into a buffer on the stack, we always have to copy the same amount of data or else we'll trash the stack something fierce. - We need <stddef.h> to get offsetof() in the !-D_KERNEL case. - ndiscvt.c needs the IMAGE_FIRST_SECTION() macro too, since it does a little bit of section pre-processing. PR: kern/83477
* Fix all the spelling mistakes I could find in the man pages for wordskeramida2005-07-311-1/+1
| | | | | | | | that have at least 3 characters. MFC after: 1 week Thanks to: Music band ``Chingon'' for keeping me company while searching for these.
* (More thoroughly) fix the problem with the EGREP lines that was reporteddougb2005-07-232-26/+45
| | | | | | | on -current by Ben Kaduk <minimarmot@gmail.com>. Add a hack of my own to allow the user to supply the paths to the INF and SYS files on the command line.
* Use "FreeBSD/i386" over "FreeBSD/ia32" to avoid any confusion.ceri2005-07-221-1/+1
|
* Correct some spelling and grammatical errors.ceri2005-07-221-7/+7
|
* Fix ndisgen(8) for amd64jkim2005-07-221-72/+116
| | | | | | | | | | | | | | | - file(1) does not recognize UTF-16 encoded .INF file: netbc564.inf: MPEG ADTS, layer I, v1, 96 kBits, 32 kHz, Stereo Use egrep(1) to match two strings, i. e., `Signature' and `Class=Net'. - Fix linking failure. Generate a temporary Makefile to emluate official kernel module build process. - Some minor typo/style fixes. Reviewed by: obrien
* Markup fixes.ru2005-06-162-9/+9
| | | | Approved by: re
* Update ndiscvt to handle .INF files that specify multiple entries inwpaul2005-05-151-8/+56
| | | | their [Manufacturer] sections.
* Fix support for Windows drivers that support both PCI and PCMCIA devices atwpaul2005-05-081-13/+15
| | | | | | | | | | | | | the same time. Fix if_ndis_pccard.c so that it sets sc->ndis_dobj and sc->ndis_regvals. Correct IMPORT_SFUNC() macros for the READ_PORT_BUFFER_xxx() routines, which take 3 arguments, not 2. This fixes it so that the Windows driver for my Cisco Aironet 340 PCMCIA card works again. (Yes, I know the an(4) driver supports this card natively, but it's the only PCMCIA device I have with a Windows XP driver.)
* Throw the switch on the new driver generation/loading mechanism. Fromwpaul2005-04-244-0/+834
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | here on in, if_ndis.ko will be pre-built as a module, and can be built into a static kernel (though it's not part of GENERIC). Drivers are created using the new ndisgen(8) script, which uses ndiscvt(8) under the covers, along with a few other tools. The result is a driver module that can be kldloaded into the kernel. A driver with foo.inf and foo.sys files will be converted into foo_sys.ko (and foo_sys.o, for those who want/need to make static kernels). This module contains all of the necessary info from the .INF file and the driver binary image, converted into an ELF module. You can kldload this module (or add it to /boot/loader.conf) to have it loaded automatically. Any required firmware files can be bundled into the module as well (or converted/loaded separately). Also, add a workaround for a problem in NdisMSleep(). During system bootstrap (cold == 1), msleep() always returns 0 without actually sleeping. The Intel 2200BG driver uses NdisMSleep() to wait for the NIC's firmware to come to life, and fails to load if NdisMSleep() doesn't actually delay. As a workaround, if msleep() (and hence ndis_thsuspend()) returns 0, use a hard DELAY() to sleep instead). This is not really the right thing to do, but we can't really do much else. At the very least, this makes the Intel driver happy. There are probably other drivers that fail in this way during bootstrap. Unfortunately, the only workaround for those is to avoid pre-loading them and kldload them once the system is running instead.
* Fix a small bug in firmcvt: outfile must be strdup()ed.wpaul2005-02-191-1/+11
| | | | | | Also, add conditional code to allow different invokations for objcopy depending on whether we're compiled on an i386 arch or amd64 arch, so that we can produce x86-64 object files on amd64.
* Re-staticize a few functions I un-staticized for debugging purposeswpaul2005-02-161-2/+2
| | | | | on amd64 and accidentally forgot to put back. (Have I mentioned that gdb on amd64 needs work? It does. Boy howdy.)
* Add support for Windows/x86-64 binaries to Project Evil.wpaul2005-02-161-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ville-Pertti Keinonen (will at exomi dot comohmygodnospampleasekthx) deserves a big thanks for submitting initial patches to make it work. I have mangled his contributions appropriately. The main gotcha with Windows/x86-64 is that Microsoft uses a different calling convention than everyone else. The standard ABI requires using 6 registers for argument passing, with other arguments on the stack. Microsoft uses only 4 registers, and requires the caller to leave room on the stack for the register arguments incase the callee needs to spill them. Unlike x86, where Microsoft uses a mix of _cdecl, _stdcall and _fastcall, all routines on Windows/x86-64 uses the same convention. This unfortunately means that all the functions we export to the driver require an intermediate translation wrapper. Similarly, we have to wrap all calls back into the driver binary itself. The original patches provided macros to wrap every single routine at compile time, providing a secondary jump table with a customized wrapper for each exported routine. I decided to use a different approach: the call wrapper for each function is created from a template at runtime, and the routine to jump to is patched into the wrapper as it is created. The subr_pe module has been modified to patch in the wrapped function instead of the original. (On x86, the wrapping routine is a no-op.) There are some minor API differences that had to be accounted for: - KeAcquireSpinLock() is a real function on amd64, not a macro wrapper around KfAcquireSpinLock() - NdisFreeBuffer() is actually IoFreeMdl(). I had to change the whole NDIS_BUFFER API a bit to accomodate this. Bugs fixed along the way: - IoAllocateMdl() always returned NULL - kern_windrv.c:windrv_unload() wasn't releasing private driver object extensions correctly (found thanks to memguard) This has only been tested with the driver for the Broadcom 802.11g chipset, which was the only Windows/x86-64 driver I could find.
* Next step on the road to IRPs: create and use an imitation of thewpaul2005-02-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows DRIVER_OBJECT and DEVICE_OBJECT mechanism so that we can simulate driver stacking. In Windows, each loaded driver image is attached to a DRIVER_OBJECT structure. Windows uses the registry to match up a given vendor/device ID combination with a corresponding DRIVER_OBJECT. When a driver image is first loaded, its DriverEntry() routine is invoked, which sets up the AddDevice() function pointer in the DRIVER_OBJECT and creates a dispatch table (based on IRP major codes). When a Windows bus driver detects a new device, it creates a Physical Device Object (PDO) for it. This is a DEVICE_OBJECT structure, with semantics analagous to that of a device_t in FreeBSD. The Windows PNP manager will invoke the driver's AddDevice() function and pass it pointers to the DRIVER_OBJECT and the PDO. The AddDevice() function then creates a new DRIVER_OBJECT structure of its own. This is known as the Functional Device Object (FDO) and corresponds roughly to a private softc instance. The driver uses IoAttachDeviceToDeviceStack() to add this device object to the driver stack for this PDO. Subsequent drivers (called filter drivers in Windows-speak) can be loaded which add themselves to the stack. When someone issues an IRP to a device, it travel along the stack passing through several possible filter drivers until it reaches the functional driver (which actually knows how to talk to the hardware) at which point it will be completed. This is how Windows achieves driver layering. Project Evil now simulates most of this. if_ndis now has a modevent handler which will use MOD_LOAD and MOD_UNLOAD events to drive the creation and destruction of DRIVER_OBJECTs. (The load event also does the relocation/dynalinking of the image.) We don't have a registry, so the DRIVER_OBJECTS are stored in a linked list for now. Eventually, the list entry will contain the vendor/device ID list extracted from the .INF file. When ndis_probe() is called and detectes a supported device, it will create a PDO for the device instance and attach it to the DRIVER_OBJECT just as in Windows. ndis_attach() will then call our NdisAddDevice() handler to create the FDO. The NDIS miniport block is now a device extension hung off the FDO, just as it is in Windows. The miniport characteristics table is now an extension hung off the DRIVER_OBJECT as well (the characteristics are the same for all devices handled by a given driver, so they don't need to be per-instance.) We also do an IoAttachDeviceToDeviceStack() to put the FDO on the stack for the PDO. There are a couple of fake bus drivers created for the PCI and pccard buses. Eventually, there will be one for USB, which will actually accept USB IRP.s Things should still work just as before, only now we do things in the proper order and maintain the correct framework to support passing IRPs between drivers. Various changes: - corrected the comments about IRQL handling in subr_hal.c to more accurately reflect reality - update ndiscvt to make the drv_data symbol in ndis_driver_data.h a global so that if_ndis_pci.o and/or if_ndis_pccard.o can see it. - Obtain the softc pointer from the miniport block by referencing the PDO rather than a private pointer of our own (nmb_ifp is no longer used) - implement IoAttachDeviceToDeviceStack(), IoDetachDevice(), IoGetAttachedDevice(), IoAllocateDriverObjectExtension(), IoGetDriverObjectExtension(), IoCreateDevice(), IoDeleteDevice(), IoAllocateIrp(), IoReuseIrp(), IoMakeAssociatedIrp(), IoFreeIrp(), IoInitializeIrp() - fix a few mistakes in the driver_object and device_object definitions - add a new module, kern_windrv.c, to handle the driver registration and relocation/dynalinkign duties (which don't really belong in kern_ndis.c). - made ndis_block and ndis_chars in the ndis_softc stucture pointers and modified all references to it - fixed NdisMRegisterMiniport() and NdisInitializeWrapper() so they work correctly with the new driver_object mechanism - changed ndis_attach() to call NdisAddDevice() instead of ndis_load_driver() (which is now deprecated) - used ExAllocatePoolWithTag()/ExFreePool() in lookaside list routines instead of kludged up alloc/free routines - added kern_windrv.c to sys/modules/ndis/Makefile and files.i386.
* Scheduled mdoc(7) sweep.ru2005-01-111-37/+34
|
* Get rid of obsolete MAN[0-9] syntax.ru2004-09-261-1/+1
|
* Today, RealTek sent me a driver to test which had been compiled withwpaul2004-08-021-45/+43
| | | | | | | | | | | | | some debug support turned on. It turns out the sections in this driver binary had relative virtual addresses (RVAs) that were different from the raw addresses, and it had a .data section where the virtual size was much larger than the raw size. (Most production binaries produced with the Microsoft DDK have RVA == PA.) There's code in the ndiscvt(8) utility that's supposed to handle the vsize != rsize case, but it turns out it was slightly broken, and it failed to handle the RVA != RA case at all. Hopefully, this commit will fix all that.
* Big mess 'o changes:wpaul2004-08-012-12/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Give ndiscvt(8) the ability to process a .SYS file directly into a .o file so that we don't have to emit big messy char arrays into the ndis_driver_data.h file. This behavior is currently optional, but may become the default some day. - Give ndiscvt(8) the ability to turn arbitrary files into .ko files so that they can be pre-loaded or kldloaded. (Both this and the previous change involve using objcopy(1)). - Give NdisOpenFile() the ability to 'read' files out of kernel memory that have been kldloaded or pre-loaded, and disallow the use of the normal vn_open() file opening method during bootstrap (when no filesystems have been mounted yet). Some people have reported that kldloading if_ndis.ko works fine when the system is running multiuser but causes a panic when the modile is pre-loaded by /boot/loader. This happens with drivers that need to use NdisOpenFile() to access external files (i.e. firmware images). NdisOpenFile() won't work during kernel bootstrapping because no filesystems have been mounted. To get around this, you can now do the following: o Say you have a firmware file called firmware.img o Do: ndiscvt -f firmware.img -- this creates firmware.img.ko o Put the firmware.img.ko in /boot/kernel o add firmware.img_load="YES" in /boot/loader.conf o add if_ndis_load="YES" and ndis_load="YES" as well Now the loader will suck the additional file into memory as a .ko. The phony .ko has two symbols in it: filename_start and filename_end, which are generated by objcopy(1). ndis_open_file() will traverse each module in the module list looking for these symbols and, if it finds them, it'll use them to generate the file mapping address and length values that the caller of NdisOpenFile() wants. As a bonus, this will even work if the file has been statically linked into the kernel itself, since the "kernel" module is searched too. (ndiscvt(8) will generate both filename.o and filename.ko for you). - Modify the mechanism used to provide make-pretend FASTCALL support. Rather than using inline assembly to yank the first two arguments out of %ecx and %edx, we now use the __regparm__(3) attribute (and the __stdcall__ attribute) and use some macro magic to re-order the arguments and provide dummy arguments as needed so that the arguments passed in registers end up in the right place. Change taken from DragonflyBSD version of the NDISulator.
* Assorted markup, grammar, and spelling fixes.ru2004-06-131-32/+66
|
* Add preliminary support for PCMCIA devices in addition to PCI/cardbus.wpaul2004-03-072-9/+159
| | | | | | | | | | | | if_ndis.c has been split into if_ndis_pci.c and if_ndis_pccard.c. The ndiscvt(8) utility should be able to parse device info for PCMCIA devices now. The ndis_alloc_amem() has moved from kern_ndis.c to if_ndis_pccard.c so that kern_ndis.c no longer depends on pccard. NOTE: this stuff is not guaranteed to work 100% correctly yet. So far I have been able to load/init my PCMCIA Cisco Aironet 340 card, but it crashes in the interrupt handler. The existing support for PCI/cardbus devices should still work as before.
* style.Makefile(5):johan2004-02-231-1/+1
| | | | Use WARNS?= instead of WARNS=.
* Some Windows .INF files are deliberately sabotaged to prevent them fromwpaul2004-01-271-1/+22
| | | | | | | | | | | | | | | | | | | | | | | loading on a particular version of Windows. For example, a .INF file for a Windows 2000 driver may have an empty [foo.NT.5.1] section which will be ingored on Win2K (whose .INF parser won't look for sections decorated with .NT.5.1) in favor of a [foo] section. Likewise, a WinXP file will have an empty [foo] section which will be ignored in favor of [foo.NT.5.1]. The problem is, we can handle both Win2K and WinXP drivers, and we don't want to exclude either one. As a workaround, we try to pretend we are WinXP by default and search for sections decorated with .NT.5.1, but if we don't turn up any records, we assume that maybe we're being fooled by a sabotaged .INF file and make one more pass looking for undecorated sections instead. This allows us to parse the .INF files for both the Win2K and the WinXP Centrino wireless drivers. I'd give anything for 5 minutes alone in a room with whoever wrote Microsoft's .INF file parser. Just 5 minutes. That's all.
* Deal with keys with descriptions that have empty fields in some ofwpaul2004-01-231-4/+12
| | | | | | | | their lines. Properly discard PCMCIA device declarations. I plan to support PCMCIA cards, but they don't work yet, and it appears some .INF files declare both PCI and PCMCIA device instances.
* Yet another inf file handling tweak: when checking for Ndi\Params\foowpaul2004-01-131-2/+2
| | | | | | | | keys, don't just do a substring match on "Ndi\Params". Instead, check explicitly for strings that begin with "Ndi\Params". Why? Because it's possible to create your own keys with different paths, like "PROSetNdi\NdiExt\Params" which is what Intel does in their PRO/1000 driver's .INF file.
* - Handle doubled double quotes:mdodd2004-01-111-1/+11
| | | | | | | `"""foo"" bar"' -> `"foo" bar' - Handle C++ style comments. Requested by: wpaul
* Tweak ndiscvt to support yet another flavor of .INF files (look forwpaul2004-01-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the NTx86 section decoration). subr_ndis.c: correct the behavior of ndis_query_resources(): if the caller doesn't provide enough space to return the resources, tell it how much it needs to provide and return an error. subr_hal.c & subr_ntoskrnl.c: implement/stub a bunch of new routines; ntoskrnl: KefAcquireSpinLockAtDpcLevel KefReleaseSpinLockFromDpcLevel MmMapLockedPages InterlockedDecrement InterlockedIncrement IoFreeMdl KeInitializeSpinLock HAL: KfReleaseSpinLock KeGetCurrentIrql KfAcquireSpinLock Lastly, correct spelling of "_aullshr" in the ntoskrnl functable.
* Fix usage() (-d is really -n).green2004-01-021-1/+1
|
* Handle WinNT .inf files with a $windows nt$ signature but no .NT decoratedwpaul2004-01-022-2/+10
| | | | | | AddReg sections. Also insert extra newline after emitting device name overrides.
* Clean up ndiscvt a bit (leaving out the -i flag didn't work) and addwpaul2004-01-025-8/+115
| | | | | | | | | | | | | | | | | | copyrights to the inf parser files. Add a -n flag to ndiscvt to allow the user to override the default device name of NDIS devices. Instead of "ndis0, ndis1, etc..." you can have "foo0, foo1, etc..." This allows you to have more than one kind of NDIS device in the kernel at the same time. Convert from printf() to device_printf() in if_ndis.c, kern_ndis.c and subr_ndis.c. Create UMA zones for ndis_packet and ndis_buffer structs allocated on transmit. The zones are created and destroyed in the modevent handler in kern_ndis.c. printf() and UMA changes submitted by green@freebsd.org
* Remember to use stringcvt() to expand %foo% strings in registry values inwpaul2003-12-301-1/+1
| | | | | | dump_defaultinfo(). Noticed by: green@freebsd.org
* Correct a typo in the text.wpaul2003-12-231-9/+2
| | | | | Remove BUGS section since the bug it describes has been fixed. Spell Matt Dodd's name correctly. (Oops.)
* Make ndiscvt(8) emit the binary image array as inline assembly code ratherwpaul2003-12-181-8/+16
| | | | | | | | | | | | | | | | | | | than a char array. Emitting the data as a big char array works fine in the typical case, where a .sys file may be ~50K in size. Unfortunately, some .sys files can be several hundred Kbytes in size, or even several megabytes in size. One extreme case is the Intel centrino wireless driver, which is 2.4MB. This causes us to emit an ndis_driver_data.h file that's on the order of 15MB in size, and gcc consumes enormous amounts of virtual memory while trying to compile it. On my laptop, with 128MB of RAM and 256MB of swap space, gcc consumed all available VM and crashed without being able to compile if_ndis.o. By emitting the array as assembler, we bypass the C compiler and consume much less memory. I was able to easily test compile if_ndis.ko with the centrino driver on my laptop after this change. This is merely a convenience, and should not have any operational effect on the NDISulator itself.
* Grrrr. Remove -g flag that snuck in.wpaul2003-12-181-1/+1
|
* Deal with the duplicate sysctl leaf problem. A .inf file may containwpaul2003-12-182-33/+27
| | | | | | | | | | | | | | | | | | definitions for more than one device (usually differentiated by the PCI subvendor/subdevice ID). Each device also has its own tree of registry keys. In some cases, each device has the same keys, but sometimes each device has a unique tree but with overlap. Originally, I just had ndiscvt(8) dump out all the keys it could find, and we would try to apply them to every device we could find. Now, each key has an index number that matches it to a device in the device ID list. This lets us create just the keys that apply to a particular device. I also added an extra field to the device list to hold the subvendor and subdevice ID. Some devices are generic, i.e. there is no subsystem definition. If we have a device that doesn't match a specific subsystem value and we have a generic entry, we use the generic entry.
* Support yet another variant of WinXP .INF files.wpaul2003-12-131-5/+11
|
* Attempt to handle WinXP .INF files. Also, in dump_regvals(), handlewpaul2003-12-121-9/+36
| | | | | | | | | | | | the case where there's an entry in the manufacturer's device list but no corresponding installation section (and hence no AddReg assignments), i.e. if dev = find_assign(sname, "AddReg"); returns NULL, then don't try to dereference dev. There is a fundamental problem with the handling of .INF files that contain definitions for multiple devices: right now we dump all the AddReg sections that we find, but don't distinguish what device they belong to. This often results in duplicate keys.
* Fix handling of .INF files with more than one PCI ID defined.wpaul2003-12-111-2/+3
|
* Fix getopt() string so -o works.wpaul2003-12-111-1/+1
|
* Grrr. Put the right .PATH statements in the right Makefiles.wpaul2003-12-111-1/+1
|
* Commit the ndiscvt(8) utility too. (Missed it in the last import.)wpaul2003-12-117-0/+1138
OpenPOWER on IntegriCloud