sysdp8~1.c
来自「网卡83815的vxworks下基于PCI总线的驱动」· C语言 代码 · 共 132 行
C
132 行
/* sysDp83815End.c - BSP interface to dp83815 END network interface driver */
/* Copyright 1999 TeamF1, Inc. */
/*
modification history
--------------------
01a,19Jul99,mpy Created.
*/
#include "vxWorks.h"
#include "stdio.h"
#include "config.h"
#include "drv/pci/pciIntLib.h"
#include "drv/pci/pciConfigLib.h"
#include "string.h"
#include "memLib.h"
#include "end.h"
#include "muxLib.h"
#include "m2Lib.h"
#include "vmLib.h" /* hanzhf*/
#include "drv/end/dp83815End.h"
#ifndef INIT_STATE_MASK
#define INIT_STATE_MASK (VM_STATE_MASK_VALID | VM_STATE_MASK_WRITABLE | VM_STATE_MASK_CACHEABLE)
#define INIT_STATE (VM_STATE_VALID | VM_STATE_WRITABLE | VM_STATE_CACHEABLE_NOT)
#endif
extern int tickGet();
extern STATUS sysMmuMapAdd(void *addr, UINT len, UINT mask, UINT state);/* hanzhf */
/*******************************************************************************
* sysDp83815EnetAddrGet - Get the ethernet address of a device
*
* Computes an ethernet address for a given dp83815 device.
*
* RETURNS: N/A
*/
void sysDp83815EnetAddrGet
(
int unit,
char * pEnetAddr
)
{
UINT16 random = (UINT16) ((tickGet() << 8) | unit);
pEnetAddr[0] = 0x08;
pEnetAddr[1] = 0x00;
pEnetAddr[2] = 0x17;
pEnetAddr[3] = 11;/*(random >> 16) & 0xFF;*/
pEnetAddr[4] = 22;/*(random >> 8) & 0xFF;*/
pEnetAddr[5] = 33;/*random & 0xFF;*/
return;
}
/*******************************************************************************
* sysDp83815ParamGet - Get the device parameters of a device
*
* This routine initializes the parameter <dpParam> with the base address,
* interrupt vector, interrupt level, and PCI memory base address for the
* device instance specified by <unit>.
*
* RETURNS: OK on success and ERROR otherwise.
*/
STATUS sysDp83815ParamGet
(
int unit,
DP83815_PARAM * dpParam
)
{
UINT32 busNo;
UINT32 funcNo;
UINT32 deviceNo;
UINT8 irq;
UINT32 iobase;
UINT32 membase;
/* find the device */
if (pciFindDevice (PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, unit,
&busNo, &deviceNo, &funcNo) == ERROR)
return ERROR;
/* read in values of iobase and irq */
pciConfigInLong (busNo, deviceNo, funcNo, PCI_CFG_BASE_ADDRESS_0, &iobase);
iobase &= PCI_IOBASE_MASK;
pciConfigInByte (busNo, deviceNo, funcNo, PCI_CFG_DEV_INT_LINE, &irq);
pciConfigInLong (busNo, deviceNo, funcNo, PCI_CFG_BASE_ADDRESS_1, &membase);
membase &=PCI_MEMBASE_MASK;
if (sysMmuMapAdd(sysPciToPhys((void *)membase), (1024*4),INIT_STATE_MASK, INIT_STATE) == ERROR)
{
printf("mmu error\n");
}
/***********************************************************************/
/* hanzhf */
pciConfigInLong (busNo, deviceNo, funcNo, 0x04, &membase);
pciConfigOutLong (busNo, deviceNo, funcNo, 0x04, 0x02900005);
printf("config space 0x04 is %x .\n",membase);
/***********************************************************************/
/*
if (sysMmuMapAdd((void *)(membase), (1024*4),INIT_STATE_MASK, INIT_STATE) == ERROR)
{
printf("mmu error\n");
}
if (sysMmuMapAdd((void *)(0xC0000000), (1024*1024),INIT_STATE_MASK, INIT_STATE) == ERROR)
{
printf("mmu error\n");
}*/
/* initialise dpParam
printf("membase is %x .\n",membase);
printf("iobase is %x.\n",iobase);
printf("irq is %d.\n",irq);*/
dpParam->iobase = iobase;
dpParam->ivec = (int) IVEC_TO_INUM (irq);
dpParam->ilevel = (int) irq;
dpParam->pciMemBase =-0xc0000000;
return OK;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?