dp83815 network driver: replace sprintf by snprintf, code style
This commit is contained in:
@@ -132,7 +132,8 @@ static status_t close_hook( void * );
|
|||||||
#define read16( offset ) (m_pcimodule->read_io_16((data->reg_base + offset)))
|
#define read16( offset ) (m_pcimodule->read_io_16((data->reg_base + offset)))
|
||||||
#define read32( offset ) (m_pcimodule->read_io_32((data->reg_base + offset)))
|
#define read32( offset ) (m_pcimodule->read_io_32((data->reg_base + offset)))
|
||||||
|
|
||||||
static void dp83815_init_registers( dp83815_properties_t *data )
|
static void
|
||||||
|
dp83815_init_registers(dp83815_properties_t *data)
|
||||||
{
|
{
|
||||||
data->reg_base = data->pcii->u.h0.base_registers[0];
|
data->reg_base = data->pcii->u.h0.base_registers[0];
|
||||||
}
|
}
|
||||||
@@ -146,7 +147,8 @@ static status_t close_hook( void * );
|
|||||||
#define read16( offset ) B_LENDIAN_TO_HOST_INT16(*((volatile uint16*)(data->reg_base + (offset))))
|
#define read16( offset ) B_LENDIAN_TO_HOST_INT16(*((volatile uint16*)(data->reg_base + (offset))))
|
||||||
#define read32( offset ) B_LENDIAN_TO_HOST_INT32(*((volatile uint32*)(data->reg_base + (offset))))
|
#define read32( offset ) B_LENDIAN_TO_HOST_INT32(*((volatile uint32*)(data->reg_base + (offset))))
|
||||||
|
|
||||||
static void dp83815_init_registers( rtl8139_properties_t *data )
|
static void
|
||||||
|
dp83815_init_registers(rtl8139_properties_t *data)
|
||||||
{
|
{
|
||||||
int32 base, size, offset;
|
int32 base, size, offset;
|
||||||
base = data->pcii->u.h0.base_registers[0];
|
base = data->pcii->u.h0.base_registers[0];
|
||||||
@@ -160,7 +162,8 @@ static status_t close_hook( void * );
|
|||||||
size += offset;
|
size += offset;
|
||||||
size = (size + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1);
|
size = (size + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1);
|
||||||
|
|
||||||
TRACE(( kDevName " _open_hook(): PCI base=%lx size=%lx offset=%lx\n", base, size, offset));
|
TRACE(( kDevName " _open_hook(): PCI base=%lx size=%lx offset=%lx\n",
|
||||||
|
base, size, offset));
|
||||||
|
|
||||||
data->ioarea = map_physical_memory(kDevName " Regs", base, size,
|
data->ioarea = map_physical_memory(kDevName " Regs", base, size,
|
||||||
B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA,
|
B_ANY_KERNEL_ADDRESS, B_READ_AREA | B_WRITE_AREA,
|
||||||
@@ -170,13 +173,17 @@ static status_t close_hook( void * );
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32 pages_needed(uint32 mem_size)
|
|
||||||
|
uint32
|
||||||
|
pages_needed(uint32 mem_size)
|
||||||
{
|
{
|
||||||
uint32 pages = mem_size / B_PAGE_SIZE;
|
uint32 pages = mem_size / B_PAGE_SIZE;
|
||||||
if( pages%B_PAGE_SIZE != 0 ) pages += 1;
|
if (pages % B_PAGE_SIZE != 0)
|
||||||
|
pages += 1;
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
init_hardware(void)
|
init_hardware(void)
|
||||||
{
|
{
|
||||||
@@ -185,6 +192,7 @@ init_hardware (void)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
init_driver(void)
|
init_driver(void)
|
||||||
{
|
{
|
||||||
@@ -194,34 +202,36 @@ init_driver (void)
|
|||||||
|
|
||||||
TRACE(( kDevName ": init_driver()\n" ));
|
TRACE(( kDevName ": init_driver()\n" ));
|
||||||
|
|
||||||
// Try if the PCI module is loaded (it would be weird if it wouldn't, but alas)
|
// Try if the PCI module is loaded (it would be weird if it wouldn't,
|
||||||
if( ( status = get_module( B_PCI_MODULE_NAME, (module_info **)&m_pcimodule )) != B_OK)
|
// but alas)
|
||||||
{
|
if ((status = get_module(B_PCI_MODULE_NAME, (module_info **)&m_pcimodule))
|
||||||
TRACE(( kDevName " init_driver(): Get PCI module failed! %lu \n", status));
|
!= B_OK) {
|
||||||
|
TRACE((kDevName " init_driver(): Get PCI module failed! %lu \n",
|
||||||
|
status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
i = 0;
|
i = 0;
|
||||||
item = (pci_info *)malloc(sizeof(pci_info));
|
item = (pci_info *)malloc(sizeof(pci_info));
|
||||||
for ( i = found = 0 ; m_pcimodule->get_nth_pci_info(i, item) == B_OK ; i++ )
|
for (i = found = 0; m_pcimodule->get_nth_pci_info(i, item) == B_OK; i++) {
|
||||||
{
|
|
||||||
supported_device_t *supported;
|
supported_device_t *supported;
|
||||||
|
|
||||||
for (supported = m_supported_devices; supported->name; supported++) {
|
for (supported = m_supported_devices; supported->name; supported++) {
|
||||||
if ( (item->vendor_id == supported->vendor_id) &&
|
if ((item->vendor_id == supported->vendor_id)
|
||||||
(item->device_id == supported->device_id) )
|
&& (item->device_id == supported->device_id)) {
|
||||||
{
|
|
||||||
//Also done in etherpci sample code
|
//Also done in etherpci sample code
|
||||||
if ((item->u.h0.interrupt_line == 0) || (item->u.h0.interrupt_line == 0xFF))
|
if ((item->u.h0.interrupt_line == 0)
|
||||||
{
|
|| (item->u.h0.interrupt_line == 0xFF)) {
|
||||||
TRACE(( kDevName " init_driver(): found %s with invalid IRQ - check IRQ assignement\n", supported->name));
|
TRACE(( kDevName " init_driver(): found %s with invalid IRQ"
|
||||||
|
" - check IRQ assignement\n", supported->name));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(( kDevName " init_driver(): found %s at IRQ %u \n", supported->name, item->u.h0.interrupt_line));
|
TRACE(( kDevName " init_driver(): found %s at IRQ %u \n",
|
||||||
|
supported->name, item->u.h0.interrupt_line));
|
||||||
m_devices[found] = item;
|
m_devices[found] = item;
|
||||||
item = (pci_info *)malloc(sizeof(pci_info));
|
item = (pci_info *)malloc(sizeof(pci_info));
|
||||||
|
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,8 +240,7 @@ init_driver (void)
|
|||||||
free(item);
|
free(item);
|
||||||
|
|
||||||
//Check if we have found any devices:
|
//Check if we have found any devices:
|
||||||
if ( found == 0 )
|
if (found == 0) {
|
||||||
{
|
|
||||||
TRACE(( kDevName " init_driver(): no device found\n" ));
|
TRACE(( kDevName " init_driver(): no device found\n" ));
|
||||||
put_module(B_PCI_MODULE_NAME); //dereference module
|
put_module(B_PCI_MODULE_NAME); //dereference module
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
@@ -241,9 +250,8 @@ init_driver (void)
|
|||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
|
|
||||||
for (i = 0; i < found; i++)
|
for (i = 0; i < found; i++) {
|
||||||
{
|
snprintf(name, 32, "%s%ld", kDevDir, i);
|
||||||
sprintf(name, "%s%ld", kDevDir, i);
|
|
||||||
dp83815_names[i] = strdup(name);
|
dp83815_names[i] = strdup(name);
|
||||||
}
|
}
|
||||||
dp83815_names[i] = NULL;
|
dp83815_names[i] = NULL;
|
||||||
@@ -272,6 +280,7 @@ uninit_driver (void)
|
|||||||
put_module(B_PCI_MODULE_NAME);
|
put_module(B_PCI_MODULE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
open_hook(const char *name, uint32 flags, void** cookie)
|
open_hook(const char *name, uint32 flags, void** cookie)
|
||||||
{
|
{
|
||||||
@@ -304,8 +313,8 @@ open_hook(const char *name, uint32 flags, void** cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Create a structure that contains the internals
|
//Create a structure that contains the internals
|
||||||
if (!(*cookie = data = (dp83815_properties_t *)malloc(sizeof(dp83815_properties_t))))
|
if (!(*cookie = data =
|
||||||
{
|
(dp83815_properties_t *)malloc(sizeof(dp83815_properties_t)))) {
|
||||||
TRACE(( kDevName " open_hook(): Out of memory\n" ));
|
TRACE(( kDevName " open_hook(): Out of memory\n" ));
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -334,16 +343,18 @@ open_hook(const char *name, uint32 flags, void** cookie)
|
|||||||
dp83815_init_registers(data);
|
dp83815_init_registers(data);
|
||||||
|
|
||||||
/* enable pci address access */
|
/* enable pci address access */
|
||||||
cmd = m_pcimodule->read_pci_config(data->pcii->bus, data->pcii->device, data->pcii->function, PCI_command, 2);
|
cmd = m_pcimodule->read_pci_config(data->pcii->bus, data->pcii->device,
|
||||||
|
data->pcii->function, PCI_command, 2);
|
||||||
cmd = cmd | PCI_command_io | PCI_command_master | PCI_command_memory;
|
cmd = cmd | PCI_command_io | PCI_command_master | PCI_command_memory;
|
||||||
m_pcimodule->write_pci_config(data->pcii->bus, data->pcii->device, data->pcii->function, PCI_command, 2, cmd );
|
m_pcimodule->write_pci_config(data->pcii->bus, data->pcii->device,
|
||||||
|
data->pcii->function, PCI_command, 2, cmd);
|
||||||
|
|
||||||
if (allocate_resources(data) != B_OK)
|
if (allocate_resources(data) != B_OK)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
/* We want interrupts! */
|
/* We want interrupts! */
|
||||||
if ( install_io_interrupt_handler( data->pcii->u.h0.interrupt_line , dp83815_interrupt_hook , data , 0 ) != B_OK )
|
if (install_io_interrupt_handler(data->pcii->u.h0.interrupt_line,
|
||||||
{
|
dp83815_interrupt_hook, data, 0) != B_OK) {
|
||||||
TRACE((kDevName " open_hook(): Error installing interrupt handler\n"));
|
TRACE((kDevName " open_hook(): Error installing interrupt handler\n"));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -382,6 +393,7 @@ open_hook(const char *name, uint32 flags, void** cookie)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
|
read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
|
||||||
{
|
{
|
||||||
@@ -393,7 +405,8 @@ read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
|
|||||||
TRACE(( kDevName ": read_hook()\n" ));
|
TRACE(( kDevName ": read_hook()\n" ));
|
||||||
|
|
||||||
//if( !data->nonblocking )
|
//if( !data->nonblocking )
|
||||||
acquire_sem_etc( data->Rx.Sem, 1, B_CAN_INTERRUPT|data->blockFlag, NONBLOCK_WAIT );
|
acquire_sem_etc(data->Rx.Sem, 1, B_CAN_INTERRUPT | data->blockFlag,
|
||||||
|
NONBLOCK_WAIT);
|
||||||
|
|
||||||
{
|
{
|
||||||
former = disable_interrupts();
|
former = disable_interrupts();
|
||||||
@@ -406,7 +419,8 @@ read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
|
|||||||
|
|
||||||
length = DESC_LENGTH&desc->cmd;
|
length = DESC_LENGTH&desc->cmd;
|
||||||
|
|
||||||
if( desc->cmd & (DESC_RXA|DESC_RXO|DESC_LONG|DESC_RUNT|DESC_ISE|DESC_CRCE|DESC_FAE|DESC_LBP|DESC_COL) )
|
if (desc->cmd & (DESC_RXA | DESC_RXO | DESC_LONG | DESC_RUNT | DESC_ISE
|
||||||
|
| DESC_CRCE | DESC_FAE | DESC_LBP | DESC_COL))
|
||||||
TRACE(( "desc cmd: %x\n", desc->cmd ));
|
TRACE(( "desc cmd: %x\n", desc->cmd ));
|
||||||
|
|
||||||
if (length < 64) {
|
if (length < 64) {
|
||||||
@@ -429,6 +443,7 @@ read_hook (void* cookie, off_t position, void *buf, size_t* num_bytes)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
write_hook(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
write_hook(void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
||||||
{
|
{
|
||||||
@@ -439,7 +454,8 @@ write_hook (void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
|||||||
TRACE(( kDevName " write_hook()\n" ));
|
TRACE(( kDevName " write_hook()\n" ));
|
||||||
|
|
||||||
acquire_sem(data->lock);
|
acquire_sem(data->lock);
|
||||||
acquire_sem_etc( data->Tx.Sem, 1, B_CAN_INTERRUPT|data->blockFlag, NONBLOCK_WAIT );
|
acquire_sem_etc(data->Tx.Sem, 1, B_CAN_INTERRUPT | data->blockFlag,
|
||||||
|
NONBLOCK_WAIT);
|
||||||
|
|
||||||
{
|
{
|
||||||
former = disable_interrupts();
|
former = disable_interrupts();
|
||||||
@@ -451,7 +467,8 @@ write_hook (void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*num_bytes > MAX_PACKET_SIZE) { /* if needed */
|
if (*num_bytes > MAX_PACKET_SIZE) { /* if needed */
|
||||||
TRACE(( "Had to truncate the packet from %d to %d\n", *num_bytes, MAX_PACKET_SIZE));
|
TRACE(( "Had to truncate the packet from %d to %d\n", *num_bytes,
|
||||||
|
MAX_PACKET_SIZE));
|
||||||
*num_bytes = MAX_PACKET_SIZE; /* truncate the packet */
|
*num_bytes = MAX_PACKET_SIZE; /* truncate the packet */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,14 +489,14 @@ write_hook (void* cookie, off_t position, const void* buffer, size_t* num_bytes)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
control_hook (void* cookie, uint32 op, void* arg, size_t len)
|
control_hook (void* cookie, uint32 op, void* arg, size_t len)
|
||||||
{
|
{
|
||||||
dp83815_properties_t *data = (dp83815_properties_t *)cookie;
|
dp83815_properties_t *data = (dp83815_properties_t *)cookie;
|
||||||
TRACE(( kDevName " control_hook()\n" ));
|
TRACE(( kDevName " control_hook()\n" ));
|
||||||
|
|
||||||
switch ( op )
|
switch (op) {
|
||||||
{
|
|
||||||
case ETHER_INIT:
|
case ETHER_INIT:
|
||||||
TRACE((kDevName " control_hook(): Wants us to init... ;-)\n"));
|
TRACE((kDevName " control_hook(): Wants us to init... ;-)\n"));
|
||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
@@ -525,6 +542,7 @@ control_hook (void* cookie, uint32 op, void* arg, size_t len)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int32
|
static int32
|
||||||
dp83815_interrupt_hook(void *cookie)
|
dp83815_interrupt_hook(void *cookie)
|
||||||
{
|
{
|
||||||
@@ -532,7 +550,8 @@ dp83815_interrupt_hook(void *cookie)
|
|||||||
uint32 isr;
|
uint32 isr;
|
||||||
isr = read32(REG_ISR);
|
isr = read32(REG_ISR);
|
||||||
|
|
||||||
if ( isr == 0 ) return B_UNHANDLED_INTERRUPT;
|
if (isr == 0)
|
||||||
|
return B_UNHANDLED_INTERRUPT;
|
||||||
|
|
||||||
if (isr & ISR_RXOK) {
|
if (isr & ISR_RXOK) {
|
||||||
int num_packets = 0;
|
int num_packets = 0;
|
||||||
@@ -565,6 +584,7 @@ dp83815_interrupt_hook(void *cookie)
|
|||||||
return B_INVOKE_SCHEDULER;
|
return B_INVOKE_SCHEDULER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
close_hook(void* cookie)
|
close_hook(void* cookie)
|
||||||
{
|
{
|
||||||
@@ -576,6 +596,7 @@ close_hook (void* cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
free_hook(void* cookie)
|
free_hook(void* cookie)
|
||||||
{
|
{
|
||||||
@@ -603,6 +624,7 @@ free_hook (void* cookie)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
device_hooks dp83815_hooks = {
|
device_hooks dp83815_hooks = {
|
||||||
open_hook, /* -> open entry point */
|
open_hook, /* -> open entry point */
|
||||||
close_hook, /* -> close entry point */
|
close_hook, /* -> close entry point */
|
||||||
@@ -612,19 +634,23 @@ device_hooks dp83815_hooks = {
|
|||||||
write_hook /* -> write entry point */
|
write_hook /* -> write entry point */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const char**
|
const char**
|
||||||
publish_devices()
|
publish_devices()
|
||||||
{
|
{
|
||||||
return (const char **)dp83815_names;
|
return (const char **)dp83815_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
device_hooks*
|
device_hooks*
|
||||||
find_device(const char* name)
|
find_device(const char* name)
|
||||||
{
|
{
|
||||||
return &dp83815_hooks;
|
return &dp83815_hooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
static status_t init_ring_buffers(dp83815_properties_t *data)
|
|
||||||
|
static status_t
|
||||||
|
init_ring_buffers(dp83815_properties_t *data)
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i;
|
||||||
area_info info;
|
area_info info;
|
||||||
@@ -645,13 +671,14 @@ static status_t init_ring_buffers(dp83815_properties_t *data)
|
|||||||
|
|
||||||
#define NUM_BUFFS 2*MAX_DESC
|
#define NUM_BUFFS 2*MAX_DESC
|
||||||
|
|
||||||
pages = pages_needed(2*MAX_DESC*sizeof(descriptor_t) + NUM_BUFFS*BUFFER_SIZE);
|
pages = pages_needed(2 * MAX_DESC * sizeof(descriptor_t)
|
||||||
|
+ NUM_BUFFS * BUFFER_SIZE);
|
||||||
|
|
||||||
data->mem_area = create_area(kDevName " desc buffer", (void**)&RxDescRing,
|
data->mem_area = create_area(kDevName " desc buffer", (void**)&RxDescRing,
|
||||||
B_ANY_KERNEL_ADDRESS, pages * B_PAGE_SIZE, B_32_BIT_CONTIGUOUS,
|
B_ANY_KERNEL_ADDRESS, pages * B_PAGE_SIZE, B_32_BIT_CONTIGUOUS,
|
||||||
B_READ_AREA | B_WRITE_AREA);
|
B_READ_AREA | B_WRITE_AREA);
|
||||||
if (data->mem_area < 0)
|
if (data->mem_area < 0)
|
||||||
return -1;
|
return B_ERROR;
|
||||||
|
|
||||||
get_area_info(data->mem_area, &info);
|
get_area_info(data->mem_area, &info);
|
||||||
get_memory_map(info.address, info.size, map, 4);
|
get_memory_map(info.address, info.size, map, 4);
|
||||||
@@ -664,7 +691,8 @@ static status_t init_ring_buffers(dp83815_properties_t *data)
|
|||||||
|
|
||||||
RxDescRing = desc_base_virt_addr;
|
RxDescRing = desc_base_virt_addr;
|
||||||
for (i = 0; i < MAX_DESC; i++) {
|
for (i = 0; i < MAX_DESC; i++) {
|
||||||
RxDescRing[i].link = desc_base_phys_addr + ((i+1)%MAX_DESC)*sizeof(descriptor_t);
|
RxDescRing[i].link = desc_base_phys_addr
|
||||||
|
+ ((i + 1) % MAX_DESC) * sizeof(descriptor_t);
|
||||||
RxDescRing[i].cmd = MAX_PACKET_SIZE;
|
RxDescRing[i].cmd = MAX_PACKET_SIZE;
|
||||||
RxDescRing[i].ptr = buff_base_phys_addr + i * BUFFER_SIZE;
|
RxDescRing[i].ptr = buff_base_phys_addr + i * BUFFER_SIZE;
|
||||||
RxDescRing[i].virt_next = &RxDescRing[(i + 1) % MAX_DESC];
|
RxDescRing[i].virt_next = &RxDescRing[(i + 1) % MAX_DESC];
|
||||||
@@ -673,11 +701,15 @@ static status_t init_ring_buffers(dp83815_properties_t *data)
|
|||||||
|
|
||||||
TxDescRing = desc_base_virt_addr + MAX_DESC;
|
TxDescRing = desc_base_virt_addr + MAX_DESC;
|
||||||
for (i = 0; i < MAX_DESC; i++) {
|
for (i = 0; i < MAX_DESC; i++) {
|
||||||
TxDescRing[i].link = desc_base_phys_addr + MAX_DESC*sizeof(descriptor_t)+ ((i+1)%MAX_DESC)*sizeof(descriptor_t);
|
TxDescRing[i].link = desc_base_phys_addr
|
||||||
|
+ MAX_DESC * sizeof(descriptor_t)
|
||||||
|
+ ((i + 1) % MAX_DESC) * sizeof(descriptor_t);
|
||||||
TxDescRing[i].cmd = MAX_PACKET_SIZE;
|
TxDescRing[i].cmd = MAX_PACKET_SIZE;
|
||||||
TxDescRing[i].ptr = buff_base_phys_addr + ((i+MAX_DESC)*BUFFER_SIZE);
|
TxDescRing[i].ptr = buff_base_phys_addr
|
||||||
|
+ ((i + MAX_DESC) * BUFFER_SIZE);
|
||||||
TxDescRing[i].virt_next = &TxDescRing[(i + 1) % MAX_DESC];
|
TxDescRing[i].virt_next = &TxDescRing[(i + 1) % MAX_DESC];
|
||||||
TxDescRing[i].virt_buff = buff_base_virt_addr + ((i+MAX_DESC)*BUFFER_SIZE);
|
TxDescRing[i].virt_buff = buff_base_virt_addr
|
||||||
|
+ ((i + MAX_DESC) * BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->Rx.Curr = RxDescRing;
|
data->Rx.Curr = RxDescRing;
|
||||||
@@ -695,7 +727,9 @@ static status_t init_ring_buffers(dp83815_properties_t *data)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static status_t allocate_resources(dp83815_properties_t *data)
|
|
||||||
|
static status_t
|
||||||
|
allocate_resources(dp83815_properties_t *data)
|
||||||
{
|
{
|
||||||
/* intialize rx semaphore with zero received packets */
|
/* intialize rx semaphore with zero received packets */
|
||||||
if ((data->Rx.Sem = create_sem(0, kDevName " rx")) < 0) {
|
if ((data->Rx.Sem = create_sem(0, kDevName " rx")) < 0) {
|
||||||
@@ -719,12 +753,14 @@ static status_t allocate_resources(dp83815_properties_t *data)
|
|||||||
return (B_OK);
|
return (B_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void free_resources(dp83815_properties_t *data)
|
static void free_resources(dp83815_properties_t *data)
|
||||||
{
|
{
|
||||||
delete_sem(data->Rx.Sem);
|
delete_sem(data->Rx.Sem);
|
||||||
delete_sem(data->Tx.Sem);
|
delete_sem(data->Tx.Sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t domulti(dp83815_properties_t *data, uint8 *addr)
|
static status_t domulti(dp83815_properties_t *data, uint8 *addr)
|
||||||
{
|
{
|
||||||
TRACE(( "Set up multicast filter here\n"));
|
TRACE(( "Set up multicast filter here\n"));
|
||||||
|
|||||||
Reference in New Issue
Block a user