Style fixes, notably the pointer style and struct keyword used

iconsintently.
Respect the 80 columns limit, update copyright, used calloc instead of
malloc.
No functional changes (hopefully)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40597 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2011-02-21 13:11:24 +00:00
parent f191a57149
commit 7920b5579c
6 changed files with 156 additions and 128 deletions
@@ -1,7 +1,7 @@
#ifndef __MYDEBUG_H
#define __MYDEBUG_H
#define ARGS (const char *, ...)
#define ARGS (const char*, ...)
#ifdef DEBUG
#define LOG(ARGS) dprintf ARGS
@@ -1,5 +1,5 @@
/* Copyright (c) 2003-2005
* Stefano Ceccherini <[email protected]>. All rights reserved.
/* Copyright (c) 2003-2011
* Stefano Ceccherini <[email protected]>. All rights reserved.
* This file is released under the MIT license
*/
#include <KernelExport.h>
@@ -17,21 +17,20 @@
#include "wb840.h"
#define MAX_CARDS 4
extern char * gDevNameList[];
extern pci_info *gDevList[];
extern char* gDevNameList[];
extern pci_info* gDevList[];
static int32 sOpenMask = 0;
static status_t
wb840_open(const char *name, uint32 flags, void** cookie)
wb840_open(const char* name, uint32 flags, void** cookie)
{
char *deviceName = NULL;
char* deviceName = NULL;
int32 i;
int32 mask;
struct wb_device *data;
struct wb_device* data;
status_t status;
LOG((DEVICE_NAME ": open()\n"));
@@ -52,13 +51,11 @@ wb840_open(const char *name, uint32 flags, void** cookie)
return B_BUSY;
// Allocate a wb_device structure
if (!(data = (wb_device *)malloc(sizeof(wb_device)))) {
if (!(data = (wb_device*)calloc(1, sizeof(wb_device)))) {
sOpenMask &= ~(1L << i);
return B_NO_MEMORY;
}
memset(data, 0, sizeof(wb_device));
*cookie = data;
#ifdef DEBUG
@@ -70,26 +67,27 @@ wb840_open(const char *name, uint32 flags, void** cookie)
data->deviceName = gDevNameList[i];
data->blockFlag = 0;
data->reg_base = data->pciInfo->u.h0.base_registers[0];
data->wb_cachesize = gPci->read_pci_config(data->pciInfo->bus, data->pciInfo->device,
data->pciInfo->function, PCI_line_size, sizeof (PCI_line_size)) & 0xff;
data->wb_cachesize = gPci->read_pci_config(data->pciInfo->bus,
data->pciInfo->device, data->pciInfo->function, PCI_line_size,
sizeof(PCI_line_size)) & 0xff;
wb_read_eeprom(data, &data->MAC_Address, 0, 3, false);
status = wb_create_semaphores(data);
if (status < B_OK) {
LOG((DEVICE_NAME ": Couldn't create semaphores\n"));
LOG((DEVICE_NAME": couldn't create semaphores\n"));
goto err;
}
status = wb_stop(data);
if (status < B_OK) {
LOG((DEVICE_NAME": Can't stop device\n"));
LOG((DEVICE_NAME": can't stop device\n"));
goto err1;
}
status = wb_initPHYs(data);
if (status < B_OK) {
LOG((DEVICE_NAME": Can't init PHYs\n"));
LOG((DEVICE_NAME": can't init PHYs\n"));
goto err1;
}
@@ -100,11 +98,11 @@ wb840_open(const char *name, uint32 flags, void** cookie)
status = install_io_interrupt_handler(data->irq, wb_interrupt, data, 0);
if (status < B_OK) {
LOG((DEVICE_NAME
" can't install interrupt handler: %s\n", strerror(status)));
": can't install interrupt handler: %s\n", strerror(status)));
goto err1;
}
LOG(("Interrupts installed at irq line %x\n", data->irq));
LOG((DEVICE_NAME ": interrupts installed at irq line %x\n", data->irq));
status = wb_create_rings(data);
if (status < B_OK) {
@@ -139,9 +137,9 @@ err:
static status_t
wb840_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
wb840_read(void* cookie, off_t position, void* buf, size_t* num_bytes)
{
wb_device *device = (wb_device*)cookie;
wb_device* device = (wb_device*)cookie;
int16 current;
status_t status;
size_t size;
@@ -167,7 +165,8 @@ wb840_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
current = device->rxCurrent;
check = device->rxDescriptor[current].wb_status;
if (check & WB_RXSTAT_OWN) {
LOG(("ERROR: read: buffer %d still in use: %x\n", (int)current, (int)status));
LOG((DEVICE_NAME ":ERROR: read: buffer %d still in use: %x\n",
(int)current, (int)status));
atomic_and(&device->rxLock, 0);
*num_bytes = 0;
return B_BUSY;
@@ -185,7 +184,7 @@ wb840_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
size = *num_bytes;
}
*num_bytes = size;
memcpy(buf, (void *)device->rxBuffer[current], size);
memcpy(buf, (void*)device->rxBuffer[current], size);
}
device->rxCurrent = (current + 1) & WB_RX_CNT_MASK;
@@ -211,7 +210,7 @@ wb840_read(void* cookie, off_t position, void *buf, size_t* num_bytes)
static status_t
wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
{
wb_device *device = (wb_device*)cookie;
wb_device* device = (wb_device*)cookie;
status_t status = B_OK;
uint16 frameSize;
int16 current;
@@ -231,7 +230,8 @@ wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
status = acquire_sem_etc(device->txSem, 1, B_TIMEOUT, ETHER_TRANSMIT_TIMEOUT);
if (status < B_OK) {
write32(device->reg_base + WB_TXSTART, 0xFFFFFFFF);
LOG(("write: acquiring sem failed: %ld, %s\n", status, strerror(status)));
LOG((DEVICE_NAME": write: acquiring sem failed: %ld, %s\n",
status, strerror(status)));
atomic_add(&device->txLock, -1);
*num_bytes = 0;
return status;
@@ -247,7 +247,7 @@ wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
}
/* Copy data to tx buffer */
memcpy((void *)device->txBuffer[current], buffer, frameSize);
memcpy((void*)device->txBuffer[current], buffer, frameSize);
device->txCurrent = (current + 1) & WB_TX_CNT_MASK;
LOG((DEVICE_NAME ": %d bytes written\n", frameSize));
@@ -256,7 +256,8 @@ wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
acquire_spinlock(&device->txSpinlock);
device->txDescriptor[current].wb_ctl = WB_TXCTL_TLINK | frameSize;
device->txDescriptor[current].wb_ctl |= WB_TXCTL_FIRSTFRAG | WB_TXCTL_LASTFRAG;
device->txDescriptor[current].wb_ctl |= WB_TXCTL_FIRSTFRAG
| WB_TXCTL_LASTFRAG;
device->txDescriptor[current].wb_status = WB_TXSTAT_OWN;
device->txSent++;
@@ -274,9 +275,9 @@ wb840_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
static status_t
wb840_control (void *cookie, uint32 op, void *arg, size_t len)
wb840_control (void* cookie, uint32 op, void* arg, size_t len)
{
wb_device *data = (wb_device *)cookie;
wb_device* data = (wb_device*)cookie;
LOG((DEVICE_NAME ": control()\n"));
switch (op) {
@@ -292,7 +293,7 @@ wb840_control (void *cookie, uint32 op, void *arg, size_t len)
case ETHER_NONBLOCK:
LOG(("ETHER_NON_BLOCK\n"));
data->blockFlag = *(int32 *)arg ? B_TIMEOUT : 0;
data->blockFlag = *(int32*)arg ? B_TIMEOUT : 0;
return B_OK;
case ETHER_GETFRAMESIZE:
@@ -338,7 +339,7 @@ wb840_control (void *cookie, uint32 op, void *arg, size_t len)
static status_t
wb840_close(void* cookie)
{
wb_device *device = (wb_device *)cookie;
wb_device* device = (wb_device*)cookie;
LOG((DEVICE_NAME ": close()\n"));
@@ -362,7 +363,7 @@ wb840_close(void* cookie)
static status_t
wb840_free(void* cookie)
{
wb_device *device = (wb_device *)cookie;
wb_device* device = (wb_device*)cookie;
LOG((DEVICE_NAME ": free()\n"));
@@ -28,6 +28,6 @@
# define write32(address,data) (*((volatile uint32 *)(address)) = (data))
#endif
extern pci_module_info *gPci;
extern pci_module_info* gPci;
#endif
@@ -1,5 +1,5 @@
/* Copyright (c) 2003-2004
* Stefano Ceccherini <[email protected]>. All rights reserved.
/* Copyright (c) 2003-2011
* Stefano Ceccherini <[email protected]>. All rights reserved.
*/
#include "debug.h"
#include <Debug.h>
@@ -18,13 +18,13 @@
int32 api_version = B_CUR_DRIVER_API_VERSION;
pci_module_info *gPci;
pci_module_info* gPci;
char* gDevNameList[MAX_CARDS + 1];
pci_info *gDevList[MAX_CARDS];
pci_info* gDevList[MAX_CARDS];
static bool
probe(pci_info *item)
probe(pci_info* item)
{
if ((item->vendor_id == WB_VENDORID && item->device_id == WB_DEVICEID_840F)
|| (item->vendor_id == CP_VENDORID && item->device_id == CP_DEVICEID_RL100))
@@ -34,7 +34,7 @@ probe(pci_info *item)
status_t
init_hardware (void)
init_hardware(void)
{
LOG((DEVICE_NAME ": init_hardware\n"));
return B_OK;
@@ -42,9 +42,9 @@ init_hardware (void)
status_t
init_driver (void)
init_driver(void)
{
struct pci_info *item = NULL;
struct pci_info* item = NULL;
int index = 0;
int card_found = 0;
char devName[64];
@@ -56,11 +56,11 @@ init_driver (void)
set_dprintf_enabled(true);
#endif
status = get_module(B_PCI_MODULE_NAME, (module_info **)&gPci);
status = get_module(B_PCI_MODULE_NAME, (module_info**)&gPci);
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;
@@ -128,7 +128,7 @@ device_hooks*
find_device(const char* name)
{
int32 i;
char *item;
char* item;
LOG((DEVICE_NAME ": find_device()\n"));
// Find device name
@@ -1,5 +1,5 @@
/* Copyright (c) 2003-2005
* Stefano Ceccherini <[email protected]>. All rights reserved.
/* Copyright (c) 2003-2011
* Stefano Ceccherini <[email protected]>. All rights reserved.
* This file is released under the MIT license
*/
#include "device.h"
@@ -26,8 +26,9 @@
struct mii_chip_info
{
const char *name;
uint16 id0, id1;
const char* name;
uint16 id0;
uint16 id1;
uint8 types;
};
@@ -35,12 +36,12 @@ struct mii_chip_info
const static struct mii_chip_info
gMIIChips[] = {
{"DAVICOM_DM9101", PHY_ID0_DAVICOM_DM9101, PHY_ID1_DAVICOM_DM9101, MII_LAN},
{NULL,0,0,0}
{NULL, 0, 0, 0}
};
static int
mii_readstatus(wb_device *device)
mii_readstatus(wb_device* device)
{
int i = 0;
int status;
@@ -54,7 +55,7 @@ mii_readstatus(wb_device *device)
static phys_addr_t
physicalAddress(volatile void *addr, uint32 length)
physicalAddress(volatile void* addr, uint32 length)
{
physical_entry table;
@@ -66,7 +67,7 @@ physicalAddress(volatile void *addr, uint32 length)
// Prepares a RX descriptor to be used by the chip
void
wb_put_rx_descriptor(volatile wb_desc *descriptor)
wb_put_rx_descriptor(volatile wb_desc* descriptor)
{
descriptor->wb_status = WB_RXSTAT_OWN;
descriptor->wb_ctl |= WB_MAX_FRAMELEN | WB_RXCTL_RLINK;
@@ -74,7 +75,7 @@ wb_put_rx_descriptor(volatile wb_desc *descriptor)
void
wb_enable_interrupts(struct wb_device *device)
wb_enable_interrupts(wb_device* device)
{
write32(device->reg_base + WB_IMR, WB_INTRS);
write32(device->reg_base + WB_ISR, 0xFFFFFFFF);
@@ -82,7 +83,7 @@ wb_enable_interrupts(struct wb_device *device)
void
wb_disable_interrupts(struct wb_device *device)
wb_disable_interrupts(wb_device* device)
{
write32(device->reg_base + WB_IMR, 0L);
write32(device->reg_base + WB_ISR, 0L);
@@ -90,7 +91,7 @@ wb_disable_interrupts(struct wb_device *device)
static void
wb_selectPHY(wb_device *device)
wb_selectPHY(wb_device* device)
{
uint16 status;
@@ -107,12 +108,12 @@ wb_selectPHY(wb_device *device)
status_t
wb_initPHYs(wb_device *device)
wb_initPHYs(wb_device* device)
{
uint16 phy;
// search for total of 32 possible MII PHY addresses
for (phy = 0; phy < 32; phy++) {
struct mii_phy *mii;
struct mii_phy* mii;
uint16 status;
int i = 0;
@@ -123,7 +124,7 @@ wb_initPHYs(wb_device *device)
// this MII is not accessable
continue;
mii = (struct mii_phy *)malloc(sizeof(struct mii_phy));
mii = (struct mii_phy*)calloc(1, sizeof(struct mii_phy));
if (mii == NULL)
return B_NO_MEMORY;
@@ -135,15 +136,18 @@ wb_initPHYs(wb_device *device)
device->firstPHY = mii;
while (gMIIChips[i].name != NULL) {
if (gMIIChips[i].id0 == mii->id0 && gMIIChips[i].id1 == (mii->id1 & 0xfff0)) {
if (gMIIChips[i].id0 == mii->id0
&& gMIIChips[i].id1 == (mii->id1 & 0xfff0)) {
dprintf("Found MII PHY: %s\n", gMIIChips[i].name);
mii->types = gMIIChips[i].types;
break;
}
i++;
}
if (gMIIChips[i].name == NULL)
dprintf("Unknown MII PHY transceiver: id = (%x, %x).\n",mii->id0, mii->id1);
if (gMIIChips[i].name == NULL) {
dprintf("Unknown MII PHY transceiver: id = (%x, %x).\n",
mii->id0, mii->id1);
}
}
if (device->firstPHY == NULL) {
@@ -159,7 +163,7 @@ wb_initPHYs(wb_device *device)
void
wb_init(wb_device *device)
wb_init(wb_device* device)
{
LOG((DEVICE_NAME": init()\n"));
@@ -183,14 +187,16 @@ wb_init(wb_device *device)
break;
}
write32(device->reg_base + WB_BUSCTL, WB_BUSCTL_MUSTBEONE|WB_BUSCTL_ARBITRATION);
write32(device->reg_base + WB_BUSCTL,
WB_BUSCTL_MUSTBEONE | WB_BUSCTL_ARBITRATION);
WB_SETBIT(device->reg_base + WB_BUSCTL, WB_BURSTLEN_16LONG);
write32(device->reg_base + WB_BUSCTL_SKIPLEN, WB_SKIPLEN_4LONG);
// Disable early TX/RX interrupt, as we can't take advantage
// 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);
}
@@ -225,13 +231,13 @@ wb_reset(wb_device *device)
status_t
wb_stop(wb_device *device)
wb_stop(wb_device* device)
{
uint32 cfgAddress = (uint32)device->reg_base + WB_NETCFG;
int32 i = 0;
if (read32(cfgAddress) & (WB_NETCFG_TX_ON|WB_NETCFG_RX_ON)) {
WB_CLRBIT(cfgAddress, (WB_NETCFG_TX_ON|WB_NETCFG_RX_ON));
if (read32(cfgAddress) & (WB_NETCFG_TX_ON | WB_NETCFG_RX_ON)) {
WB_CLRBIT(cfgAddress, (WB_NETCFG_TX_ON | WB_NETCFG_RX_ON));
for (i = 0; i < WB_TIMEOUT; i++) {
if ((read32(device->reg_base + WB_ISR) & WB_ISR_TX_IDLE) &&
@@ -248,7 +254,7 @@ wb_stop(wb_device *device)
static void
wb_updateLink(struct wb_device *device)
wb_updateLink(wb_device* device)
{
if (!device->autoNegotiationComplete) {
int32 mode = wb_read_mode(device);
@@ -277,9 +283,9 @@ wb_updateLink(struct wb_device *device)
int32
wb_tick(timer *arg)
wb_tick(timer* arg)
{
struct wb_device *device = (wb_device*)arg;
wb_device* device = (wb_device*)arg;
wb_updateLink(device);
@@ -291,7 +297,7 @@ wb_tick(timer *arg)
* Program the rx filter.
*/
void
wb_set_rx_filter(wb_device *device)
wb_set_rx_filter(wb_device* device)
{
// TODO: Basically we just config the filter to accept broadcasts
// packets. We'll need also to configure it to multicast.
@@ -301,7 +307,7 @@ wb_set_rx_filter(wb_device *device)
/***************** Interrupt handling ******************************/
static status_t
wb_rxok(struct wb_device *device)
wb_rxok(wb_device* device)
{
uint32 releaseRxSem = 0;
int16 limit;
@@ -309,12 +315,14 @@ wb_rxok(struct wb_device *device)
acquire_spinlock(&device->rxSpinlock);
for (limit = device->rxFree; limit > 0; limit--) {
if (device->rxDescriptor[device->rxInterruptIndex].wb_status & WB_RXSTAT_OWN) {
if (device->rxDescriptor[device->rxInterruptIndex].wb_status
& WB_RXSTAT_OWN) {
break;
}
releaseRxSem++;
device->rxInterruptIndex = (device->rxInterruptIndex + 1) & WB_RX_CNT_MASK;
device->rxInterruptIndex = (device->rxInterruptIndex + 1)
& WB_RX_CNT_MASK;
device->rxFree--;
}
@@ -333,7 +341,7 @@ wb_rxok(struct wb_device *device)
static status_t
wb_tx_nobuf(struct wb_device *info)
wb_tx_nobuf(wb_device* info)
{
int16 releaseTxSem = 0;
int16 limit;
@@ -377,9 +385,9 @@ wb_tx_nobuf(struct wb_device *info)
int32
wb_interrupt(void *arg)
wb_interrupt(void* arg)
{
struct wb_device *device = (wb_device*)arg;
wb_device* device = (wb_device*)arg;
int32 retval = B_UNHANDLED_INTERRUPT;
uint32 status;
@@ -469,21 +477,21 @@ wb_interrupt(void *arg)
* Print an ethernet address
*/
void
print_address(ether_address_t *addr)
print_address(ether_address_t* addr)
{
int i;
char buf[3 * 6 + 1];
for (i = 0; i < 5; i++) {
sprintf(&buf[3*i], "%02x:", addr->ebyte[i]);
sprintf(&buf[3 * i], "%02x:", addr->ebyte[i]);
}
sprintf(&buf[3*5], "%02x", addr->ebyte[5]);
sprintf(&buf[3 * 5], "%02x", addr->ebyte[5]);
dprintf("%s\n", buf);
}
status_t
wb_create_semaphores(struct wb_device *device)
wb_create_semaphores(wb_device* device)
{
device->rxSem = create_sem(0, "wb840 receive");
if (device->rxSem < B_OK) {
@@ -509,7 +517,7 @@ wb_create_semaphores(struct wb_device *device)
void
wb_delete_semaphores(wb_device *device)
wb_delete_semaphores(wb_device* device)
{
if (device->rxSem >= 0)
delete_sem(device->rxSem);
@@ -519,46 +527,57 @@ wb_delete_semaphores(wb_device *device)
status_t
wb_create_rings(struct wb_device *device)
wb_create_rings(wb_device* device)
{
int i;
device->rxArea = create_area("wb840 rx buffer", (void **)&device->rxBuffer[0],
B_ANY_KERNEL_ADDRESS, ROUND_TO_PAGE_SIZE(WB_BUFBYTES * WB_RX_LIST_CNT),
B_32_BIT_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
device->rxArea = create_area("wb840 rx buffer",
(void**)&device->rxBuffer[0], B_ANY_KERNEL_ADDRESS,
ROUND_TO_PAGE_SIZE(WB_BUFBYTES * WB_RX_LIST_CNT),
B_32_BIT_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
if (device->rxArea < B_OK)
return device->rxArea;
for (i = 1; i < WB_RX_LIST_CNT; i++)
device->rxBuffer[i] = (void *)(((uint32)device->rxBuffer[0]) + (i * WB_BUFBYTES));
for (i = 1; i < WB_RX_LIST_CNT; i++) {
device->rxBuffer[i] = (void*)(((uint32)device->rxBuffer[0])
+ (i * WB_BUFBYTES));
}
for (i = 0; i < WB_RX_LIST_CNT; i++) {
device->rxDescriptor[i].wb_status = 0;
device->rxDescriptor[i].wb_ctl = WB_RXCTL_RLINK;
wb_put_rx_descriptor(&device->rxDescriptor[i]);
device->rxDescriptor[i].wb_data = physicalAddress(device->rxBuffer[i], WB_BUFBYTES);
device->rxDescriptor[i].wb_next = physicalAddress(&device->rxDescriptor[(i + 1) & WB_RX_CNT_MASK],
device->rxDescriptor[i].wb_data = physicalAddress(
device->rxBuffer[i], WB_BUFBYTES);
device->rxDescriptor[i].wb_next = physicalAddress(
&device->rxDescriptor[(i + 1) & WB_RX_CNT_MASK],
sizeof(struct wb_desc));
}
device->rxFree = WB_RX_LIST_CNT;
device->txArea = create_area("wb840 tx buffer", (void **)&device->txBuffer[0],
B_ANY_KERNEL_ADDRESS, ROUND_TO_PAGE_SIZE(WB_BUFBYTES * WB_TX_LIST_CNT),
B_32_BIT_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
device->txArea = create_area("wb840 tx buffer",
(void**)&device->txBuffer[0], B_ANY_KERNEL_ADDRESS,
ROUND_TO_PAGE_SIZE(WB_BUFBYTES * WB_TX_LIST_CNT),
B_32_BIT_FULL_LOCK, B_READ_AREA | B_WRITE_AREA);
if (device->txArea < B_OK) {
delete_area(device->rxArea);
return device->txArea;
}
for (i = 1; i < WB_TX_LIST_CNT; i++)
device->txBuffer[i] = (void *)(((uint32)device->txBuffer[0]) + (i * WB_BUFBYTES));
for (i = 1; i < WB_TX_LIST_CNT; i++) {
device->txBuffer[i] = (void*)(((uint32)device->txBuffer[0])
+ (i * WB_BUFBYTES));
}
for (i = 0; i < WB_TX_LIST_CNT; i++) {
device->txDescriptor[i].wb_status = 0;
device->txDescriptor[i].wb_ctl = WB_TXCTL_TLINK;
device->txDescriptor[i].wb_data = physicalAddress(device->txBuffer[i], WB_BUFBYTES);
device->txDescriptor[i].wb_next = physicalAddress(&device->txDescriptor[(i + 1) & WB_TX_CNT_MASK],
device->txDescriptor[i].wb_data = physicalAddress(
device->txBuffer[i], WB_BUFBYTES);
device->txDescriptor[i].wb_next = physicalAddress(
&device->txDescriptor[(i + 1) & WB_TX_CNT_MASK],
sizeof(struct wb_desc));
}
@@ -574,7 +593,7 @@ wb_create_rings(struct wb_device *device)
void
wb_delete_rings(struct wb_device *device)
wb_delete_rings(wb_device* device)
{
delete_area(device->rxArea);
delete_area(device->txArea);
@@ -582,10 +601,12 @@ wb_delete_rings(struct wb_device *device)
int32
wb_read_mode(wb_device *info)
wb_read_mode(wb_device* info)
{
uint16 autoAdv, autoLinkPartner;
int32 speed, duplex;
uint16 autoAdv;
uint16 autoLinkPartner;
int32 speed;
int32 duplex;
uint16 status = mii_readstatus(info);
if (!(status & MII_STATUS_LINK)) {
@@ -595,11 +616,14 @@ wb_read_mode(wb_device *info)
// auto negotiation completed
autoAdv = wb_miibus_readreg(info, info->phy, MII_AUTONEG_ADV);
autoLinkPartner = wb_miibus_readreg(info, info->phy, MII_AUTONEG_LINK_PARTNER);
autoLinkPartner = wb_miibus_readreg(info, info->phy,
MII_AUTONEG_LINK_PARTNER);
status = autoAdv & autoLinkPartner;
speed = status & (MII_NWAY_TX | MII_NWAY_TX_FDX) ? LINK_SPEED_100_MBIT : LINK_SPEED_10_MBIT;
duplex = status & (MII_NWAY_TX_FDX | MII_NWAY_T_FDX) ? LINK_FULL_DUPLEX : LINK_HALF_DUPLEX;
speed = status & (MII_NWAY_TX | MII_NWAY_TX_FDX)
? LINK_SPEED_100_MBIT : LINK_SPEED_10_MBIT;
duplex = status & (MII_NWAY_TX_FDX | MII_NWAY_T_FDX)
? LINK_FULL_DUPLEX : LINK_HALF_DUPLEX;
info->autoNegotiationComplete = true;
@@ -612,7 +636,7 @@ wb_read_mode(wb_device *info)
void
wb_set_mode(wb_device *info, int mode)
wb_set_mode(wb_device* info, int mode)
{
uint32 cfgAddress = (uint32)info->reg_base + WB_NETCFG;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2004 Stefano Ceccherini ([email protected])
* Copyright (c) 2003-2004 Stefano Ceccherini ([email protected])
* Copyright (c) 1997, 1998
* Bill Paul <[email protected]>. All rights reserved.
*
@@ -342,7 +342,7 @@ struct wb_device {
// rx data
volatile wb_desc rxDescriptor[WB_RX_LIST_CNT];
volatile void *rxBuffer[WB_RX_LIST_CNT];
volatile void* rxBuffer[WB_RX_LIST_CNT];
int32 rxLock;
sem_id rxSem;
spinlock rxSpinlock;
@@ -353,7 +353,7 @@ struct wb_device {
//tx data
volatile wb_desc txDescriptor[WB_TX_LIST_CNT];
volatile char *txBuffer[WB_TX_LIST_CNT];
volatile char* txBuffer[WB_TX_LIST_CNT];
int32 txLock;
sem_id txSem;
spinlock txSpinlock;
@@ -362,8 +362,8 @@ struct wb_device {
int16 txInterruptIndex;
int16 txSent;
struct mii_phy *firstPHY;
struct mii_phy *currentPHY;
struct mii_phy* firstPHY;
struct mii_phy* currentPHY;
uint16 phy;
bool autoNegotiationComplete;
bool link;
@@ -480,35 +480,38 @@ enum link_modes {
#define CP_VENDORID 0x11F6
#define CP_DEVICEID_RL100 0x2011
/*
* Utility Macros
*/
#define WB_SETBIT(reg, x) write32(reg, read32(reg) | x)
#define WB_CLRBIT(reg, x) write32(reg, read32(reg) & ~x)
// Prototypes
extern int32 wb_interrupt(void *arg);
extern int32 wb_interrupt(void* arg);
extern status_t wb_create_semaphores(wb_device *device);
extern void wb_delete_semaphores(wb_device *device);
extern status_t wb_create_semaphores(wb_device* device);
extern void wb_delete_semaphores(wb_device* device);
extern status_t wb_create_rings(wb_device *device);
extern void wb_delete_rings(wb_device *device);
extern status_t wb_create_rings(wb_device* device);
extern void wb_delete_rings(wb_device* device);
extern void wb_init(wb_device *device);
extern void wb_reset(wb_device *device);
extern status_t wb_stop(wb_device *device);
extern void wb_init(wb_device* device);
extern void wb_reset(wb_device* device);
extern status_t wb_stop(wb_device* device);
extern status_t wb_initPHYs(wb_device *device);
extern status_t wb_initPHYs(wb_device* device);
extern void wb_disable_interrupts(wb_device *device);
extern void wb_enable_interrupts(wb_device *device);
extern void wb_disable_interrupts(wb_device* device);
extern void wb_enable_interrupts(wb_device* device);
extern void wb_set_mode(wb_device *device, int mode);
extern int32 wb_read_mode(wb_device *device);
extern void wb_set_mode(wb_device* device, int mode);
extern int32 wb_read_mode(wb_device* device);
extern void wb_set_rx_filter(wb_device *device);
extern void wb_set_rx_filter(wb_device* device);
extern int32 wb_tick(timer *arg);
extern void wb_put_rx_descriptor(volatile wb_desc *desc);
extern int32 wb_tick(timer* arg);
extern void wb_put_rx_descriptor(volatile wb_desc* desc);
extern void print_address(ether_address_t *addr);
extern void print_address(ether_address_t* addr);
#endif //__WB840_H