Various small changes (mostly style related)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13823 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2003-2004
|
/* Copyright (c) 2003-2005
|
||||||
* Stefano Ceccherini <[email protected]>. All rights reserved.
|
* Stefano Ceccherini <[email protected]>. All rights reserved.
|
||||||
* This file is released under the MIT license
|
* This file is released under the MIT license
|
||||||
*/
|
*/
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
extern char * gDevNameList[];
|
extern char * gDevNameList[];
|
||||||
extern pci_info *gDevList[];
|
extern pci_info *gDevList[];
|
||||||
|
|
||||||
static int32 gOpenMask = 0;
|
static int32 sOpenMask = 0;
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
wb840_open(const char *name, uint32 flags, void** cookie)
|
wb840_open(const char *name, uint32 flags, void** cookie)
|
||||||
@@ -42,14 +42,14 @@ wb840_open(const char *name, uint32 flags, void** cookie)
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There can be only one access at time */
|
// There can be only one access at time
|
||||||
mask = 1L << i;
|
mask = 1L << i;
|
||||||
if (atomic_or(&gOpenMask, mask) & mask)
|
if (atomic_or(&sOpenMask, mask) & mask)
|
||||||
return B_BUSY;
|
return B_BUSY;
|
||||||
|
|
||||||
/* Allocate a wb_device structure */
|
// Allocate a wb_device structure
|
||||||
if (!(data = (wb_device *)malloc(sizeof(wb_device)))) {
|
if (!(data = (wb_device *)malloc(sizeof(wb_device)))) {
|
||||||
gOpenMask &= ~(1L << i);
|
sOpenMask &= ~(1L << i);
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,6 @@ wb840_open(const char *name, uint32 flags, void** cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wb_enable_interrupts(data);
|
wb_enable_interrupts(data);
|
||||||
wb_set_rx_filter(data);
|
|
||||||
|
|
||||||
WB_SETBIT(data->reg_base + WB_NETCFG, WB_NETCFG_RX_ON);
|
WB_SETBIT(data->reg_base + WB_NETCFG, WB_NETCFG_RX_ON);
|
||||||
write32(data->reg_base + WB_RXSTART, 0xFFFFFFFF);
|
write32(data->reg_base + WB_RXSTART, 0xFFFFFFFF);
|
||||||
@@ -126,7 +125,7 @@ err1:
|
|||||||
wb_delete_semaphores(data);
|
wb_delete_semaphores(data);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
gOpenMask &= ~(1L << i);
|
sOpenMask &= ~(1L << i);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
LOG(("wb840: Open Failed\n"));
|
LOG(("wb840: Open Failed\n"));
|
||||||
@@ -154,7 +153,8 @@ wb840_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((status = acquire_sem_etc(device->rxSem, 1, B_CAN_INTERRUPT | blockFlag, 0)) < B_OK) {
|
status = acquire_sem_etc(device->rxSem, 1, B_CAN_INTERRUPT | blockFlag, 0);
|
||||||
|
if (status < B_OK) {
|
||||||
atomic_and(&device->rxLock, 0);
|
atomic_and(&device->rxLock, 0);
|
||||||
*num_bytes = 0;
|
*num_bytes = 0;
|
||||||
return status;
|
return status;
|
||||||
@@ -224,7 +224,8 @@ wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
|||||||
current = device->txCurrent;
|
current = device->txCurrent;
|
||||||
|
|
||||||
// block until a free tx descriptor is available
|
// block until a free tx descriptor is available
|
||||||
if ((status = acquire_sem_etc(device->txSem, 1, B_TIMEOUT, ETHER_TRANSMIT_TIMEOUT)) < B_OK) {
|
status = acquire_sem_etc(device->txSem, 1, B_TIMEOUT, ETHER_TRANSMIT_TIMEOUT);
|
||||||
|
if (status < B_OK) {
|
||||||
write32(device->reg_base + WB_TXSTART, 0xFFFFFFFF);
|
write32(device->reg_base + WB_TXSTART, 0xFFFFFFFF);
|
||||||
LOG(("write: acquiring sem failed: %ld, %s\n", status, strerror(status)));
|
LOG(("write: acquiring sem failed: %ld, %s\n", status, strerror(status)));
|
||||||
atomic_add(&device->txLock, -1);
|
atomic_add(&device->txLock, -1);
|
||||||
@@ -245,9 +246,9 @@ wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
|||||||
memcpy((void *)device->txBuffer[current], buffer, frameSize);
|
memcpy((void *)device->txBuffer[current], buffer, frameSize);
|
||||||
device->txCurrent = (current + 1) & WB_TX_CNT_MASK;
|
device->txCurrent = (current + 1) & WB_TX_CNT_MASK;
|
||||||
LOG((DEVICE_NAME ": %d bytes written\n", frameSize));
|
LOG((DEVICE_NAME ": %d bytes written\n", frameSize));
|
||||||
|
|
||||||
{
|
{
|
||||||
cpu_status former;
|
cpu_status former = disable_interrupts();
|
||||||
former = disable_interrupts();
|
|
||||||
acquire_spinlock(&device->txSpinlock);
|
acquire_spinlock(&device->txSpinlock);
|
||||||
|
|
||||||
device->txDescriptor[current].wb_ctl = WB_TXCTL_TLINK | frameSize;
|
device->txDescriptor[current].wb_ctl = WB_TXCTL_TLINK | frameSize;
|
||||||
@@ -290,22 +291,22 @@ wb840_control (void *cookie, uint32 op, void *arg, size_t len)
|
|||||||
data->blockFlag = *(int32 *)arg ? B_TIMEOUT : 0;
|
data->blockFlag = *(int32 *)arg ? B_TIMEOUT : 0;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
|
case ETHER_GETFRAMESIZE:
|
||||||
|
LOG(("ETHER_GETFRAMESIZE\n"));
|
||||||
|
*(uint32 *)arg = WB_MAX_FRAMELEN;
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
case ETHER_ADDMULTI:
|
case ETHER_ADDMULTI:
|
||||||
LOG(("ETHER_ADDMULTI\n"));
|
LOG(("ETHER_ADDMULTI\n"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ETHER_REMMULTI:
|
case ETHER_REMMULTI:
|
||||||
LOG(("ETHER_REMMULTI\n"));
|
LOG(("ETHER_REMMULTI\n"));
|
||||||
return B_OK;
|
break;
|
||||||
|
|
||||||
case ETHER_SETPROMISC:
|
case ETHER_SETPROMISC:
|
||||||
LOG(("ETHER_SETPROMISC\n"));
|
LOG(("ETHER_SETPROMISC\n"));
|
||||||
return B_OK;
|
break;
|
||||||
|
|
||||||
case ETHER_GETFRAMESIZE:
|
|
||||||
LOG(("ETHER_GETFRAMESIZE\n"));
|
|
||||||
*(uint32*)arg = WB_MAX_FRAMELEN;
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG(("Invalid command\n"));
|
LOG(("Invalid command\n"));
|
||||||
@@ -343,11 +344,11 @@ wb840_close(void* cookie)
|
|||||||
static status_t
|
static status_t
|
||||||
wb840_free(void* cookie)
|
wb840_free(void* cookie)
|
||||||
{
|
{
|
||||||
wb_device *device = (wb_device*)cookie;
|
wb_device *device = (wb_device *)cookie;
|
||||||
|
|
||||||
LOG((DEVICE_NAME ": free()\n"));
|
LOG((DEVICE_NAME ": free()\n"));
|
||||||
|
|
||||||
gOpenMask &= ~(1L << device->devId);
|
sOpenMask &= ~(1L << device->devId);
|
||||||
|
|
||||||
wb_delete_rings(device);
|
wb_delete_rings(device);
|
||||||
free(device->firstPHY);
|
free(device->firstPHY);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ init_driver (void)
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
int card_found = 0;
|
int card_found = 0;
|
||||||
char devName[64];
|
char devName[64];
|
||||||
|
status_t status;
|
||||||
|
|
||||||
LOG((DEVICE_NAME ": init_driver\n"));
|
LOG((DEVICE_NAME ": init_driver\n"));
|
||||||
|
|
||||||
@@ -55,10 +56,15 @@ init_driver (void)
|
|||||||
set_dprintf_enabled(true);
|
set_dprintf_enabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK)
|
status = get_module(B_PCI_MODULE_NAME, (module_info **)&gPci);
|
||||||
return B_ERROR;
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
item = (pci_info *)malloc(sizeof(pci_info));
|
item = (pci_info *)malloc(sizeof(pci_info));
|
||||||
|
if (item == NULL) {
|
||||||
|
put_module(B_PCI_MODULE_NAME);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
while (gPci->get_nth_pci_info(index, item) == B_OK) {
|
while (gPci->get_nth_pci_info(index, item) == B_OK) {
|
||||||
if (probe(item)) {
|
if (probe(item)) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#define ROUND_TO_PAGE_SIZE(x) (((x) + (B_PAGE_SIZE) - 1) & ~((B_PAGE_SIZE) - 1))
|
#define ROUND_TO_PAGE_SIZE(x) (((x) + (B_PAGE_SIZE) - 1) & ~((B_PAGE_SIZE) - 1))
|
||||||
|
|
||||||
// MII chip info table
|
// MII chip info table
|
||||||
#define PHY_ID0_DAVICOM_DM9101 0x0181
|
#define PHY_ID0_DAVICOM_DM9101 0x0181
|
||||||
#define PHY_ID1_DAVICOM_DM9101 0xb800
|
#define PHY_ID1_DAVICOM_DM9101 0xb800
|
||||||
#define MII_HOME 0x0001
|
#define MII_HOME 0x0001
|
||||||
#define MII_LAN 0x0002
|
#define MII_LAN 0x0002
|
||||||
@@ -191,6 +191,8 @@ wb_init(wb_device *device)
|
|||||||
// Disable early TX/RX interrupt, as we can't take advantage
|
// Disable early TX/RX interrupt, as we can't take advantage
|
||||||
// from them, at least for now.
|
// from them, at least for now.
|
||||||
WB_CLRBIT(device->reg_base + WB_NETCFG, (WB_NETCFG_TX_EARLY_ON|WB_NETCFG_RX_EARLY_ON));
|
WB_CLRBIT(device->reg_base + WB_NETCFG, (WB_NETCFG_TX_EARLY_ON|WB_NETCFG_RX_EARLY_ON));
|
||||||
|
|
||||||
|
wb_set_rx_filter(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -381,7 +383,7 @@ wb_interrupt(void *arg)
|
|||||||
int32 retval = B_UNHANDLED_INTERRUPT;
|
int32 retval = B_UNHANDLED_INTERRUPT;
|
||||||
uint32 status;
|
uint32 status;
|
||||||
|
|
||||||
//TODO: Handle others interrupts
|
// TODO: Handle other interrupts
|
||||||
|
|
||||||
acquire_spinlock(&device->intLock);
|
acquire_spinlock(&device->intLock);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user