viadriver.c
来自「source code of armboot for s3c4510」· C语言 代码 · 共 281 行
C
281 行
#include "armboot.h"#include "command.h"#include "net.h"//#include "s3c2510.h"#include "s5n8947.h"#include "viadriver.h"#include "log.h"#include "swsys.h"#include "swpkt.h"#include "swreg.h"#include "platform.h"//#ifdef CONFIG_S3C2500 //used for selecting "s3c2500" when ./armbootcfg//#ifdef CONFIG_S3C2510 //used for selecting "s3c2510" when ./armbootcfg#ifdef CONFIG_S5N8947 //used for selecting "s5n8947" when ./armbootcfg#if (CONFIG_COMMANDS & CFG_CMD_NET)API_DEVICE api_Mac_dev;void InitEtherApi(bd_t *bd){ api_init(bd, &api_Mac_dev);}void eth_halt( void ){ api_MacIntDisable(&api_Mac_dev); api_MacHWStop(&api_Mac_dev); api_MacHWReset(&api_Mac_dev); api_MacBuffFree(&api_Mac_dev);}int eth_init( bd_t *bd ){ api_MacBuffInit(&api_Mac_dev); api_MacHWInit(&api_Mac_dev); api_MacHWStart(&api_Mac_dev); return 0;}/* Get a data block via Ethernet */extern int eth_rx(void){ api_MacRcv(&api_Mac_dev); return 0;}/* Send a data block via Ethernet. */extern int eth_send(volatile void *packet, int length){ api_MacSend(&api_Mac_dev, (ulong)packet, length); return 0;}/***************************//* Sub Function for driver *//***************************//********************************************************************************* api_MacHWReset - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacHWReset(API_DEVICE *api_Mac_dev){ // Trigger MAC & PHY reset signal SWSYS_vSwitchResetSignal(); return OK;}/********************************************************************************* api_MacBuffInit - Initialize TX and RX FD lists* Make a circular list of Rx and TX frame descriptors and buffers.* Two global variables gpReceiveFrameDescStart and gpTransmitFrameDescStart * stores the pointer to the start of the list. BDMA TX/RX PTR registers are * also initialized with the start of the appropriate list.*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacBuffInit(API_DEVICE *api_Mac_dev){ STATUS status = OK; return status;}/********************************************************************************* api_MacBuffFree - Free the allocated TX and RX FD lists and buffers* This function frees all the allocated TX and RX FDs and the associated* buffers** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacBuffFree(API_DEVICE *api_Mac_dev){ STATUS status = OK; return status;}/********************************************************************************** RETURNS: OK or ERROR return status why..** SEE ALSO:*/int api_MacHWInit(API_DEVICE *api_Mac_dev){ STATUS status = OK; PLAT_vInit(); //cancel by hill 20070920 SWSYS_vBoardInit(); SWPKT_vSetMacAddress(api_Mac_dev->enetAddr); return status;}/********************************************************************************* api_MacHWStart - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacHWStart(API_DEVICE *api_Mac_dev){ STATUS status = OK; SWPKT_vDrvOpen(); return status;}/********************************************************************************* api_MacHWStop - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacHWStop (API_DEVICE *api_Mac_dev){ STATUS status = OK; SWSYS_vBoardShutdown(); PLAT_vInit(); return status;}/********************************************************************************* api_MacRcv - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */void api_MacRcv(API_DEVICE *api_Mac_dev){ int frameLength; SRBuf pPktBuf; //modified by hill 20070919 //SYS_vIsrIntaAss(); //add by hill 20070919 ISR_vSwitch (); if(SWPKT_bRecvPkt(&pPktBuf)) { frameLength = pPktBuf.pkb_u16BufLen; NetReceive(pPktBuf.pkb_au8Buffer, frameLength); }}/********************************************************************************* api_MacSend - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacSend(API_DEVICE *api_Mac_dev, ulong pData, int len){ SRBuf pPktBuf; int i; pPktBuf.pu8AppData = 0; pPktBuf.u16AppDataOffset = 0; pPktBuf.pkb_u8SrcPortId = 26; pPktBuf.pkb_bTagged = 0; pPktBuf.pkb_u16VID = 0; pPktBuf.pkb_u8Priority = 0; pPktBuf.pkb_u32TxMbrPrtMsk = 0; pPktBuf.pkb_u32TxTagPrtMsk = 0; pPktBuf.pkb_u16BufLen = len; for(i=0;i<len;i++) { pPktBuf.pkb_au8Buffer[i]= *((UINT8 *)pData +i); } SWPKT_bSendPkt(&pPktBuf); return OK;}/********************************************************************************* api_MacIntEnable - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacIntEnable(API_DEVICE *api_Mac_dev){ STATUS status = OK; SWPKT_vDrvOpen(); return status;}/********************************************************************************* api_MacIntDisable - .*** RETURNS: OK or ERROR return status why..** SEE ALSO: */int api_MacIntDisable(API_DEVICE *api_Mac_dev){ STATUS status = OK; // disable switch interrupt mask SWREG_vWriteU8(CPUIF_IRQ_MASK, 0); // disable CPU IO SWREG_vBitsOffU8(CPUPORT_CFG, CPU_CFG_RX_ENABLE | CPU_CFG_TX_ENABLE); // stop forwarding ARP to CPU SWREG_vWriteU8(FWDCTL_ARP_CFG, 0); return status;}void api_init(bd_t *bd, API_DEVICE *api_Mac_dev){ SYS_ENET_ADDR_GET(api_Mac_dev, bd->bi_enetaddr);}#endif /* COMMANDS & CFG_NET */#endif /* CONFIG_S3C2510 */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?