Back out the last batch of changes until I have a chance to properly

evaluate them. Whatever they're meant to do, they're doing it wrong.

Also:

- Clean up last bits of NULL fallout in subr_pe
- Don't let ndis_ifmedia_sts() do anything if the IFF_UP flag isn't set
- Implement NdisSystemProcessorCount() and NdisQueryMapRegisterCount().
This commit is contained in:
Bill Paul 2003-12-26 03:31:34 +00:00
parent ac0e70c401
commit 1e642180fe
5 changed files with 69 additions and 61 deletions

View File

@ -81,7 +81,6 @@ __stdcall static void ndis_statusdone_func(ndis_handle);
__stdcall static void ndis_setdone_func(ndis_handle, ndis_status);
__stdcall static void ndis_getdone_func(ndis_handle, ndis_status);
__stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
static void ndis_free_packet_and_bufs(ndis_packet *);
/*
* This allows us to export our symbols to other modules.
@ -328,38 +327,6 @@ ndis_flush_sysctls(arg)
return(0);
}
void
ndis_free_bufs(b0)
ndis_buffer *b0;
{
ndis_buffer *next;
if (b0 == NULL)
return;
while(b0 != NULL) {
next = b0->nb_next;
ndis_free_buf(b0);
b0 = next;
}
return;
}
static void
ndis_free_packet_and_bufs(p)
ndis_packet *p;
{
if (p == NULL)
return;
ndis_free_bufs(p->np_private.npp_head);
p->np_private.npp_head = NULL;
ndis_free_packet(p);
return;
}
void
ndis_return_packet(buf, arg)
void *buf; /* not used */
@ -385,13 +352,44 @@ ndis_return_packet(buf, arg)
sc = p->np_softc;
returnfunc = sc->ndis_chars.nmc_return_packet_func;
adapter = sc->ndis_block.nmb_miniportadapterctx;
if (returnfunc == NULL || p->np_oob.npo_status != NDIS_STATUS_PENDING)
ndis_free_packet_and_bufs(p);
if (returnfunc == NULL)
ndis_free_packet(p);
else
returnfunc(adapter, p);
return;
}
void
ndis_free_bufs(b0)
ndis_buffer *b0;
{
ndis_buffer *next;
if (b0 == NULL)
return;
while(b0 != NULL) {
next = b0->nb_next;
free (b0, M_DEVBUF);
b0 = next;
}
return;
}
void
ndis_free_packet(p)
ndis_packet *p;
{
if (p == NULL)
return;
ndis_free_bufs(p->np_private.npp_head);
free(p, M_DEVBUF);
return;
}
int
ndis_convert_res(arg)
void *arg;

View File

@ -1177,7 +1177,6 @@ extern int ndis_convert_res(void *);
extern int ndis_alloc_amem(void *);
extern void ndis_free_packet(ndis_packet *);
extern void ndis_free_bufs(ndis_buffer *);
extern void ndis_free_buf(ndis_buffer *);
extern int ndis_reset_nic(void *);
extern int ndis_halt_nic(void *);
extern int ndis_shutdown_nic(void *);

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/timespec.h>
#include <sys/smp.h>
#include <net/if.h>
#include <net/if_arp.h>
@ -150,6 +151,7 @@ __stdcall static void ndis_deregister_ioport(ndis_handle,
uint32_t, uint32_t, void *);
__stdcall static void ndis_read_netaddr(ndis_status *, void **,
uint32_t *, ndis_handle);
__stdcall static ndis_status ndis_mapreg_cnt(uint32_t, uint32_t *);
__stdcall static ndis_status ndis_alloc_mapreg(ndis_handle,
uint32_t, uint8_t, uint32_t, uint32_t);
__stdcall static void ndis_free_mapreg(ndis_handle);
@ -242,6 +244,7 @@ __stdcall static void ndis_open_file(ndis_status *, ndis_handle *, uint32_t *,
__stdcall static void ndis_map_file(ndis_status *, void **, ndis_handle);
__stdcall static void ndis_unmap_file(ndis_handle);
__stdcall static void ndis_close_file(ndis_handle);
__stdcall static u_int8_t ndis_cpu_cnt(void);
__stdcall static void dummy(void);
@ -1085,6 +1088,15 @@ ndis_read_netaddr(status, addr, addrlen, adapter)
return;
}
__stdcall static ndis_status
ndis_mapreg_cnt(bustype, cnt)
uint32_t bustype;
uint32_t *cnt;
{
*cnt = 64;
return(NDIS_STATUS_SUCCESS);
}
__stdcall static ndis_status
ndis_alloc_mapreg(adapter, dmachannel, dmasize, physmapneeded, maxmap)
ndis_handle adapter;
@ -1477,8 +1489,8 @@ ndis_alloc_packet(status, packet, pool)
return;
}
void
ndis_free_packet(packet)
__stdcall static void
ndis_release_packet(packet)
ndis_packet *packet;
{
ndis_packet *head;
@ -1497,14 +1509,6 @@ ndis_free_packet(packet)
return;
}
__stdcall static void
ndis_release_packet(packet)
ndis_packet *packet;
{
ndis_free_packet(packet);
return;
}
__stdcall static void
ndis_unchain_headbuf(packet, buf)
ndis_packet *packet;
@ -1644,8 +1648,8 @@ ndis_alloc_buf(status, buffer, pool, vaddr, len)
return;
}
void
ndis_free_buf(buf)
__stdcall static void
ndis_release_buf(buf)
ndis_buffer *buf;
{
ndis_buffer *head;
@ -1664,14 +1668,6 @@ ndis_free_buf(buf)
return;
}
__stdcall static void
ndis_release_buf(buf)
ndis_buffer *buf;
{
ndis_free_buf(buf);
return;
}
/*
* Get the virtual address and length of a buffer.
* Note: the vaddr argument is optional.
@ -2265,6 +2261,16 @@ ndis_close_file(filehandle)
return;
}
__stdcall static uint8_t
ndis_cpu_cnt()
{
#ifdef SMP
return(mp_ncpus);
#else
return(1);
#endif
};
__stdcall static void
dummy()
{
@ -2273,6 +2279,7 @@ dummy()
}
image_patch_table ndis_functbl[] = {
{ "NdisSystemProcessorCount", (FUNC)ndis_cpu_cnt },
{ "NdisUnchainBufferAtBack", (FUNC)ndis_unchain_tailbuf, },
{ "NdisGetFirstBufferFromPacket", (FUNC)ndis_firstbuf },
{ "NdisGetFirstBufferFromPacketSafe", (FUNC)ndis_firstbuf_safe },
@ -2322,8 +2329,9 @@ image_patch_table ndis_functbl[] = {
{ "NdisMRegisterIoPortRange", (FUNC)ndis_register_ioport },
{ "NdisMDeregisterIoPortRange", (FUNC)ndis_deregister_ioport },
{ "NdisReadNetworkAddress", (FUNC)ndis_read_netaddr },
{ "NdisQueryMapRegisterCount", (FUNC)ndis_mapreg_cnt },
{ "NdisMAllocateMapRegisters", (FUNC)ndis_alloc_mapreg },
{ "NdisMFreeMapRegisters", (FUNC)ndis_free_mapreg },
{ "NdisMFreeMapRegisters", (FUNC)ndis_free_mapreg },
{ "NdisMAllocateSharedMemory", (FUNC)ndis_alloc_sharedmem },
{ "NdisMMapIoSpace", (FUNC)ndis_map_iospace },
{ "NdisMUnmapIoSpace", (FUNC)ndis_unmap_iospace },

View File

@ -520,7 +520,7 @@ pe_patch_imports(imgbase, module, functbl)
fptr = (vm_offset_t *)pe_translate_addr(imgbase,
imp_desc.iid_import_address_table_addr);
while (nptr != NULL && pe_translate_addr(imgbase, *nptr) != NULL) {
while (nptr != NULL && pe_translate_addr(imgbase, *nptr)) {
fname = (char *)pe_translate_addr(imgbase, (*nptr) + 2);
func = pe_functbl_match(functbl, fname);
if (func)

View File

@ -1048,6 +1048,12 @@ ndis_ifmedia_sts(ifp, ifmr)
ndis_media_state linkstate;
int error, len;
ifmr->ifm_status = IFM_AVALID;
ifmr->ifm_active = IFM_ETHER;
if (!(ifp->if_flags & IFF_UP))
return;
sc = ifp->if_softc;
len = sizeof(linkstate);
@ -1058,9 +1064,6 @@ ndis_ifmedia_sts(ifp, ifmr)
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;