Minor cleanup. When I see kernel code like this, I'm very tempted to delete

it altogether.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17992 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-07-01 11:43:01 +00:00
parent 3a41b03036
commit bf7d1aad69
2 changed files with 317 additions and 208 deletions
@@ -7,6 +7,8 @@
#include <ByteOrder.h> #include <ByteOrder.h>
#include <KernelExport.h> #include <KernelExport.h>
#include <stdio.h>
typedef vint32 MM_ATOMIC_T; typedef vint32 MM_ATOMIC_T;
//#define MM_SWAP_LE16(x) B_SWAP_INT16(x) //#define MM_SWAP_LE16(x) B_SWAP_INT16(x)
@@ -1,19 +1,30 @@
#include <PCI.h> /*
#include <Drivers.h> * Copyright 2006, Nathan Whitehorn.
#include <KernelExport.h> * Distributed under the terms of the GPL License.
#include <malloc.h> */
#include <string.h>
#include <ether_driver.h>
#include "b44mm.h" #include "b44mm.h"
#include "b44lm.h" #include "b44lm.h"
#include "mempool.h" #include "mempool.h"
#include <ether_driver.h>
#include <PCI.h>
#include <Drivers.h>
#include <KernelExport.h>
#include <malloc.h>
#include <string.h>
struct pci_module_info *pci = NULL; struct pci_module_info *pci = NULL;
const char *dev_list[11]; #define MAX_CARDS 4
struct be_b44_dev be_b44_dev_cards[10];
int cards_found = 0; static char *sDeviceNames[MAX_CARDS + 1];
static int sCardsFound = 0;
struct be_b44_dev be_b44_dev_cards[MAX_CARDS];
int b44_Packet_Desc_Size = sizeof(struct B_UM_PACKET); int b44_Packet_Desc_Size = sizeof(struct B_UM_PACKET);
@@ -30,65 +41,95 @@ status_t b44_write(void *cookie,off_t pos,const void *data,size_t *numBytes);
int32 b44_interrupt(void *cookie); int32 b44_interrupt(void *cookie);
int32 tx_cleanup_thread(void *us); int32 tx_cleanup_thread(void *us);
device_hooks b44_hooks = {b44_open,b44_close,b44_free,b44_ioctl,b44_read,b44_write,NULL,NULL,NULL,NULL};
status_t init_hardware(void) { status_t
init_hardware(void)
{
return B_OK; return B_OK;
} }
const char **publish_devices() {
return dev_list; const char **
publish_devices()
{
return (const char **)sDeviceNames;
} }
device_hooks *find_device(const char *name) {
device_hooks *
find_device(const char *name)
{
static device_hooks b44_hooks = {
b44_open,
b44_close,
b44_free,
b44_ioctl,
b44_read,
b44_write,
NULL,
NULL,
NULL,
NULL
};
return &b44_hooks; return &b44_hooks;
} }
status_t init_driver(void) {
status_t
init_driver(void)
{
int i = 0; int i = 0;
pci_info dev_info; pci_info dev_info;
if (pci == NULL) if (pci == NULL)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci); get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
while (pci->get_nth_pci_info(i++,&dev_info) == 0) { while (pci->get_nth_pci_info(i++, &dev_info) == 0) {
if (!((dev_info.class_base == PCI_network) && (dev_info.class_sub == PCI_ethernet) if (dev_info.class_base != PCI_network
&& (dev_info.vendor_id == 0x14e4) && ((dev_info.device_id == 0x4401) || (dev_info.device_id == 0x4402) || (dev_info.device_id == 0x170c)))) || dev_info.class_sub != PCI_ethernet
|| dev_info.vendor_id != 0x14e4
|| (dev_info.device_id != 0x4401
&& dev_info.device_id != 0x4402
&& dev_info.device_id != 0x170c))
continue; continue;
if (cards_found >= 10) if (sCardsFound >= MAX_CARDS)
break; break;
dev_list[cards_found] = (char *)malloc(16 /* net/bcm440x/xx */); sDeviceNames[sCardsFound] = (char *)malloc(16 /* net/bcm440x/xx */);
sprintf(dev_list[cards_found],"net/bcm440x/%d",cards_found); sprintf(sDeviceNames[sCardsFound], "net/bcm440x/%d", sCardsFound);
be_b44_dev_cards[cards_found].pci_data = dev_info; be_b44_dev_cards[sCardsFound].pci_data = dev_info;
be_b44_dev_cards[cards_found].packet_release_sem = create_sem(0,dev_list[cards_found]); be_b44_dev_cards[sCardsFound].packet_release_sem = create_sem(0,
be_b44_dev_cards[cards_found].mem_list_num = 0; sDeviceNames[sCardsFound]);
be_b44_dev_cards[cards_found].lockmem_list_num = 0; be_b44_dev_cards[sCardsFound].mem_list_num = 0;
be_b44_dev_cards[cards_found].opened = 0; be_b44_dev_cards[sCardsFound].lockmem_list_num = 0;
be_b44_dev_cards[cards_found].block = 1; be_b44_dev_cards[sCardsFound].opened = 0;
be_b44_dev_cards[cards_found].lock = 0; be_b44_dev_cards[sCardsFound].block = 1;
be_b44_dev_cards[sCardsFound].lock = 0;
if (b44_LM_GetAdapterInfo(&be_b44_dev_cards[cards_found].lm_dev) != LM_STATUS_SUCCESS) if (b44_LM_GetAdapterInfo(&be_b44_dev_cards[sCardsFound].lm_dev) != LM_STATUS_SUCCESS)
return ENODEV; return ENODEV;
QQ_InitQueue(&be_b44_dev_cards[cards_found].RxPacketReadQ.Container,MAX_RX_PACKET_DESC_COUNT); QQ_InitQueue(&be_b44_dev_cards[sCardsFound].RxPacketReadQ.Container,
MAX_RX_PACKET_DESC_COUNT);
cards_found++; sCardsFound++;
} }
mempool_init((MAX_RX_PACKET_DESC_COUNT+10) * cards_found); mempool_init((MAX_RX_PACKET_DESC_COUNT+10) * sCardsFound);
dev_list[cards_found] = NULL;
sDeviceNames[sCardsFound] = NULL;
return B_OK; return B_OK;
} }
void uninit_driver(void) {
int i,j;
struct be_b44_dev *pUmDevice;
for (j = 0; j < cards_found; j++) { void
uninit_driver(void)
{
struct be_b44_dev *pUmDevice;
int i, j;
for (j = 0; j < sCardsFound; j++) {
pUmDevice = &be_b44_dev_cards[j]; pUmDevice = &be_b44_dev_cards[j];
for (i = 0; i < pUmDevice->mem_list_num; i++) for (i = 0; i < pUmDevice->mem_list_num; i++)
free(pUmDevice->mem_list[i]); free(pUmDevice->mem_list[i]);
@@ -97,19 +138,22 @@ void uninit_driver(void) {
delete_area(pUmDevice->mem_base); delete_area(pUmDevice->mem_base);
free((void *)dev_list[j]); free((void *)sDeviceNames[j]);
} }
mempool_exit(); mempool_exit();
} }
status_t b44_open(const char *name, uint32 flags, void **cookie) {
status_t
b44_open(const char *name, uint32 flags, void **cookie)
{
struct be_b44_dev *pDevice = NULL; struct be_b44_dev *pDevice = NULL;
int i; int i;
*cookie = NULL; *cookie = NULL;
for (i = 0; i < cards_found; i++) { for (i = 0; i < sCardsFound; i++) {
if (strcmp(dev_list[i],name) == 0) { if (strcmp(sDeviceNames[i], name) == 0) {
*cookie = pDevice = &be_b44_dev_cards[i]; *cookie = pDevice = &be_b44_dev_cards[i];
break; break;
} }
@@ -123,10 +167,12 @@ status_t b44_open(const char *name, uint32 flags, void **cookie) {
return B_BUSY; return B_BUSY;
} }
install_io_interrupt_handler(pDevice->pci_data.u.h0.interrupt_line,b44_interrupt,*cookie,0); install_io_interrupt_handler(pDevice->pci_data.u.h0.interrupt_line,
b44_interrupt, *cookie, 0);
if (b44_LM_InitializeAdapter(&pDevice->lm_dev) != LM_STATUS_SUCCESS) { if (b44_LM_InitializeAdapter(&pDevice->lm_dev) != LM_STATUS_SUCCESS) {
atomic_and(&pDevice->opened,0); atomic_and(&pDevice->opened, 0);
remove_io_interrupt_handler(pDevice->pci_data.u.h0.interrupt_line,b44_interrupt,*cookie); remove_io_interrupt_handler(pDevice->pci_data.u.h0.interrupt_line,
b44_interrupt, *cookie);
*cookie = NULL; *cookie = NULL;
return B_ERROR; return B_ERROR;
} }
@@ -135,13 +181,14 @@ status_t b44_open(const char *name, uint32 flags, void **cookie) {
MAX_RX_PACKET_DESC_COUNT);*/ MAX_RX_PACKET_DESC_COUNT);*/
b44_LM_EnableInterrupt(&pDevice->lm_dev); b44_LM_EnableInterrupt(&pDevice->lm_dev);
return B_OK; return B_OK;
} }
status_t b44_close(void *cookie) {
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(cookie);
status_t
b44_close(void *cookie)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie;
if (cookie == NULL) if (cookie == NULL)
return B_OK; return B_OK;
@@ -151,18 +198,24 @@ status_t b44_close(void *cookie) {
return B_OK; return B_OK;
} }
status_t b44_free(void *cookie) {
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(cookie);
status_t
b44_free(void *cookie)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie;
if (cookie == NULL) if (cookie == NULL)
return B_OK; return B_OK;
remove_io_interrupt_handler(pUmDevice->pci_data.u.h0.interrupt_line,b44_interrupt,cookie); remove_io_interrupt_handler(pUmDevice->pci_data.u.h0.interrupt_line,
b44_interrupt, cookie);
return B_OK; return B_OK;
} }
status_t b44_ioctl(void *cookie,uint32 op,void *data,size_t len) {
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(cookie); status_t
b44_ioctl(void *cookie,uint32 op,void *data,size_t len)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie;
switch (op) { switch (op) {
case ETHER_INIT: case ETHER_INIT:
@@ -171,10 +224,10 @@ status_t b44_ioctl(void *cookie,uint32 op,void *data,size_t len) {
if (data == NULL) if (data == NULL)
return B_ERROR; return B_ERROR;
memcpy(data,pUmDevice->lm_dev.NodeAddress,6); memcpy(data, pUmDevice->lm_dev.NodeAddress, 6);
return B_OK; return B_OK;
case ETHER_NONBLOCK: case ETHER_NONBLOCK:
pUmDevice->block = !*((uint8 *)(data)); pUmDevice->block = !*((uint8 *)data);
return B_OK; return B_OK;
case ETHER_ADDMULTI: case ETHER_ADDMULTI:
return (b44_LM_MulticastAdd(&pUmDevice->lm_dev,(PLM_UINT8)(data)) == LM_STATUS_SUCCESS) ? B_OK : B_ERROR; return (b44_LM_MulticastAdd(&pUmDevice->lm_dev,(PLM_UINT8)(data)) == LM_STATUS_SUCCESS) ? B_OK : B_ERROR;
@@ -198,11 +251,13 @@ status_t b44_ioctl(void *cookie,uint32 op,void *data,size_t len) {
return B_ERROR; return B_ERROR;
} }
int32 b44_interrupt(void *cookie) {
int32
b44_interrupt(void *cookie)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie; struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie;
PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK) pUmDevice; PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK) pUmDevice;
if (!pDevice->InitDone) if (!pDevice->InitDone)
return B_UNHANDLED_INTERRUPT; return B_UNHANDLED_INTERRUPT;
@@ -217,7 +272,10 @@ int32 b44_interrupt(void *cookie) {
return B_HANDLED_INTERRUPT; return B_HANDLED_INTERRUPT;
} }
status_t b44_read(void *cookie,off_t pos,void *data,size_t *numBytes) {
status_t
b44_read(void *cookie, off_t pos, void *data, size_t *numBytes)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie; struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie;
PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK) pUmDevice; PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK) pUmDevice;
PLM_PACKET pPacket; PLM_PACKET pPacket;
@@ -243,10 +301,9 @@ status_t b44_read(void *cookie,off_t pos,void *data,size_t *numBytes) {
return B_ERROR; return B_ERROR;
} }
pUmPacket = (struct B_UM_PACKET *) pPacket; pUmPacket = (struct B_UM_PACKET *)pPacket;
if ((pPacket->PacketStatus != LM_STATUS_SUCCESS) || if (pPacket->PacketStatus != LM_STATUS_SUCCESS
((pPacket->PacketSize) > 1518)) { || pPacket->PacketSize > 1518) {
cpu = disable_interrupts(); cpu = disable_interrupts();
acquire_spinlock(&pUmDevice->lock); acquire_spinlock(&pUmDevice->lock);
@@ -258,10 +315,10 @@ status_t b44_read(void *cookie,off_t pos,void *data,size_t *numBytes) {
return B_ERROR; return B_ERROR;
} }
if ((pPacket->PacketSize/*-pDevice->rxoffset*/) < *numBytes) if (pPacket->PacketSize/*-pDevice->rxoffset*/ < *numBytes)
*numBytes = pPacket->PacketSize/*-pDevice->rxoffset*/; *numBytes = pPacket->PacketSize/*-pDevice->rxoffset*/;
memcpy(data,pUmPacket->data+pDevice->rxoffset,*numBytes); memcpy(data, pUmPacket->data + pDevice->rxoffset, *numBytes);
cpu = disable_interrupts(); cpu = disable_interrupts();
acquire_spinlock(&pUmDevice->lock); acquire_spinlock(&pUmDevice->lock);
@@ -273,7 +330,10 @@ status_t b44_read(void *cookie,off_t pos,void *data,size_t *numBytes) {
return B_OK; return B_OK;
} }
status_t b44_write(void *cookie,off_t pos,const void *data,size_t *numBytes) {
status_t
b44_write(void *cookie, off_t pos, const void *data, size_t *numBytes)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie; struct be_b44_dev *pUmDevice = (struct be_b44_dev *)cookie;
PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK) pUmDevice; PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK) pUmDevice;
PLM_PACKET pPacket; PLM_PACKET pPacket;
@@ -289,7 +349,7 @@ status_t b44_write(void *cookie,off_t pos,const void *data,size_t *numBytes) {
if (pPacket == 0) if (pPacket == 0)
return B_ERROR; return B_ERROR;
pUmPacket = (struct B_UM_PACKET *) pPacket; pUmPacket = (struct B_UM_PACKET *)pPacket;
pUmPacket->data = chunk_pool_get(); pUmPacket->data = chunk_pool_get();
memcpy(pUmPacket->data/*+pDevice->dataoffset*/,data,*numBytes); /* no guarantee data is contiguous, so we have to copy */ memcpy(pUmPacket->data/*+pDevice->dataoffset*/,data,*numBytes); /* no guarantee data is contiguous, so we have to copy */
@@ -300,14 +360,17 @@ status_t b44_write(void *cookie,off_t pos,const void *data,size_t *numBytes) {
tx_cleanup_thread(pUmDevice); tx_cleanup_thread(pUmDevice);
b44_LM_SendPacket(pDevice, pPacket); b44_LM_SendPacket(pDevice, pPacket);
return B_OK; return B_OK;
} }
/* -------- Broadcom MM hooks ----------- */
LM_STATUS b44_MM_ReadConfig16(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset, // #pragma mark - Broadcom MM hooks
LM_UINT16 *pValue16) {
LM_STATUS
b44_MM_ReadConfig16(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT16 *pValue16)
{
if (pci == NULL) if (pci == NULL)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci); get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
@@ -315,8 +378,11 @@ LM_STATUS b44_MM_ReadConfig16(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_WriteConfig16(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT16 Value16) { LM_STATUS
b44_MM_WriteConfig16(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT16 Value16)
{
if (pci == NULL) if (pci == NULL)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci); get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
@@ -324,8 +390,11 @@ LM_STATUS b44_MM_WriteConfig16(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_ReadConfig32(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT32 *pValue32) { LM_STATUS
b44_MM_ReadConfig32(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT32 *pValue32)
{
if (pci == NULL) if (pci == NULL)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci); get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
@@ -333,8 +402,11 @@ LM_STATUS b44_MM_ReadConfig32(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_WriteConfig32(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT32 Value32){ LM_STATUS
b44_MM_WriteConfig32(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
LM_UINT32 Value32)
{
if (pci == NULL) if (pci == NULL)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci); get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
@@ -342,7 +414,10 @@ LM_STATUS b44_MM_WriteConfig32(PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset,
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_MapMemBase(PLM_DEVICE_BLOCK pDevice) {
LM_STATUS
b44_MM_MapMemBase(PLM_DEVICE_BLOCK pDevice)
{
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(pDevice); struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(pDevice);
size_t size = pUmDevice->pci_data.u.h0.base_register_sizes[0]; size_t size = pUmDevice->pci_data.u.h0.base_register_sizes[0];
@@ -355,15 +430,23 @@ LM_STATUS b44_MM_MapMemBase(PLM_DEVICE_BLOCK pDevice) {
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
/*LM_STATUS b44_MM_MapIoBase(PLM_DEVICE_BLOCK pDevice) {
/*
LM_STATUS
b44_MM_MapIoBase(PLM_DEVICE_BLOCK pDevice)
{
if (pci == NULL) if (pci == NULL)
get_module(B_PCI_MODULE_NAME,(module_info **)&pci); get_module(B_PCI_MODULE_NAME,(module_info **)&pci);
pDevice->pMappedMemBase = pci->ram_address(((struct be_b44_dev *)(pDevice))->pci_data.memory_base); pDevice->pMappedMemBase = pci->ram_address(((struct be_b44_dev *)(pDevice))->pci_data.memory_base);
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
}*/ }
*/
LM_STATUS b44_MM_IndicateRxPackets(PLM_DEVICE_BLOCK pDevice) {
LM_STATUS
b44_MM_IndicateRxPackets(PLM_DEVICE_BLOCK pDevice)
{
struct be_b44_dev *dev = (struct be_b44_dev *)pDevice; struct be_b44_dev *dev = (struct be_b44_dev *)pDevice;
PLM_PACKET pPacket; PLM_PACKET pPacket;
@@ -374,7 +457,7 @@ LM_STATUS b44_MM_IndicateRxPackets(PLM_DEVICE_BLOCK pDevice) {
break; break;
acquire_spinlock(&dev->lock); acquire_spinlock(&dev->lock);
release_sem_etc(dev->packet_release_sem,1,B_DO_NOT_RESCHEDULE); release_sem_etc(dev->packet_release_sem, 1, B_DO_NOT_RESCHEDULE);
release_spinlock(&dev->lock); release_spinlock(&dev->lock);
QQ_PushTail(&dev->RxPacketReadQ.Container, pPacket); QQ_PushTail(&dev->RxPacketReadQ.Container, pPacket);
} }
@@ -382,11 +465,17 @@ LM_STATUS b44_MM_IndicateRxPackets(PLM_DEVICE_BLOCK pDevice) {
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_IndicateTxPackets(PLM_DEVICE_BLOCK pDevice) {
LM_STATUS
b44_MM_IndicateTxPackets(PLM_DEVICE_BLOCK pDevice)
{
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
int32 tx_cleanup_thread(void *us) {
int32
tx_cleanup_thread(void *us)
{
PLM_PACKET pPacket; PLM_PACKET pPacket;
PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK)(us); PLM_DEVICE_BLOCK pDevice = (PLM_DEVICE_BLOCK)(us);
struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(us); struct be_b44_dev *pUmDevice = (struct be_b44_dev *)(us);
@@ -404,6 +493,7 @@ int32 tx_cleanup_thread(void *us) {
restore_interrupts(cpu); restore_interrupts(cpu);
if (pPacket == 0) if (pPacket == 0)
break; break;
pUmPacket = (struct B_UM_PACKET *)(pPacket); pUmPacket = (struct B_UM_PACKET *)(pPacket);
chunk_pool_put(pUmPacket->data); chunk_pool_put(pUmPacket->data);
pUmPacket->data = NULL; pUmPacket->data = NULL;
@@ -420,8 +510,11 @@ int32 tx_cleanup_thread(void *us) {
/*LM_STATUS b44_MM_StartTxDma(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket); /*LM_STATUS b44_MM_StartTxDma(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket);
LM_STATUS b44_MM_CompleteTxDma(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket);*/ LM_STATUS b44_MM_CompleteTxDma(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket);*/
LM_STATUS b44_MM_AllocateMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
PLM_VOID *pMemoryBlockVirt) { LM_STATUS
b44_MM_AllocateMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
PLM_VOID *pMemoryBlockVirt)
{
struct be_b44_dev *dev = (struct be_b44_dev *)(pDevice); struct be_b44_dev *dev = (struct be_b44_dev *)(pDevice);
if (dev->mem_list_num == 16) if (dev->mem_list_num == 16)
@@ -429,19 +522,23 @@ LM_STATUS b44_MM_AllocateMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
*pMemoryBlockVirt = dev->mem_list[(dev->mem_list_num)++] = (void *)malloc(BlockSize); *pMemoryBlockVirt = dev->mem_list[(dev->mem_list_num)++] = (void *)malloc(BlockSize);
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
PLM_VOID *pMemoryBlockVirt, PLM_PHYSICAL_ADDRESS pMemoryBlockPhy) { LM_STATUS
b44_MM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
PLM_VOID *pMemoryBlockVirt, PLM_PHYSICAL_ADDRESS pMemoryBlockPhy)
{
struct be_b44_dev *dev; struct be_b44_dev *dev;
void *pvirt = NULL; void *pvirt = NULL;
area_id area_desc; area_id area_desc;
physical_entry entry; physical_entry entry;
dev = (struct be_b44_dev *)(pDevice); dev = (struct be_b44_dev *)(pDevice);
area_desc = dev->lockmem_list[dev->lockmem_list_num++] = create_area("broadcom_shared_mem",&pvirt,B_ANY_KERNEL_ADDRESS,ROUND_UP_TO_PAGE(BlockSize),/*B_CONTIGUOUS | B_FULL_LOCK*/ B_LOMEM,B_READ_AREA | B_WRITE_AREA); area_desc = dev->lockmem_list[dev->lockmem_list_num++] = create_area("broadcom_shared_mem",
&pvirt, B_ANY_KERNEL_ADDRESS, ROUND_UP_TO_PAGE(BlockSize),
if (pvirt == NULL) /*B_CONTIGUOUS*/ B_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
if (area_desc < B_OK)
return LM_STATUS_FAILURE; return LM_STATUS_FAILURE;
memset(pvirt, 0, BlockSize); memset(pvirt, 0, BlockSize);
@@ -453,7 +550,10 @@ LM_STATUS b44_MM_AllocateSharedMemory(PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockS
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_GetConfig(PLM_DEVICE_BLOCK pDevice){
LM_STATUS
b44_MM_GetConfig(PLM_DEVICE_BLOCK pDevice)
{
pDevice->DisableAutoNeg = FALSE; pDevice->DisableAutoNeg = FALSE;
pDevice->RequestedLineSpeed = LM_LINE_SPEED_AUTO; pDevice->RequestedLineSpeed = LM_LINE_SPEED_AUTO;
pDevice->RequestedDuplexMode = LM_DUPLEX_MODE_FULL; pDevice->RequestedDuplexMode = LM_DUPLEX_MODE_FULL;
@@ -464,10 +564,14 @@ LM_STATUS b44_MM_GetConfig(PLM_DEVICE_BLOCK pDevice){
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_IndicateStatus(PLM_DEVICE_BLOCK pDevice, LM_STATUS Status) {
LM_STATUS
b44_MM_IndicateStatus(PLM_DEVICE_BLOCK pDevice, LM_STATUS Status)
{
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS LM_STATUS
b44_MM_InitializeUmPackets(PLM_DEVICE_BLOCK pDevice) b44_MM_InitializeUmPackets(PLM_DEVICE_BLOCK pDevice)
{ {
@@ -490,9 +594,12 @@ b44_MM_InitializeUmPackets(PLM_DEVICE_BLOCK pDevice)
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;
} }
LM_STATUS b44_MM_FreeRxBuffer(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket) {
LM_STATUS
b44_MM_FreeRxBuffer(PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket)
{
struct B_UM_PACKET *pUmPacket; struct B_UM_PACKET *pUmPacket;
pUmPacket = (struct B_UM_PACKET *) pPacket; pUmPacket = (struct B_UM_PACKET *)pPacket;
chunk_pool_put(pUmPacket->data); chunk_pool_put(pUmPacket->data);
pUmPacket->data = NULL; pUmPacket->data = NULL;
return LM_STATUS_SUCCESS; return LM_STATUS_SUCCESS;