📄 ecom8xx.c
字号:
/* @(#) pSOSystem/PPC V221 */
/***********************************************************************/
/* */
/* MODULE: mpc8xx/ecom/src/ecom8xx.c */
/* DATE: 99/10/22 */
/* AUTHOR: Dong Aiping */
/* PURPOSE: */
/* */
/*---------------------------------------------------------------------*/
/* */
/* Copyright 1999 - 2000, ZHONGXING TELECOM CO.,LTD. */
/* ALL RIGHTS RESERVED */
/* */
/*---------------------------------------------------------------------*/
/* */
/* This file include functions about this board special */
/* */
/***********************************************************************/
#include "src/board.h"
#include "ecom8xx.h"
#include <bspfuncs.h>
#define IRQ2_MASK 0x08000000 /* IRQ2 interrupt mask */
#define IRQ2_PENDING 0x08000000 /* IRQ2 pending bit */
#define IRQ3_MASK 0x02000000 /* IRQ3 interrupt mask */
#define IRQ3_PENDING 0x02000000 /* IRQ3 pendng bit */
/* used in Dpram interrupt and exception */
DpramSetActionStruct pEcomDpramIntSet;
/***********************************************************************/
/* Ecom_ExceptionStore: 奇偶校验错处理服务程序 */
/* */
/* RETURNS: None */
/***********************************************************************/
void Ecom_ExceptionStore(void)
{
DpramSetActionStruct *pData;
pData = &pEcomDpramIntSet;
pData->ParityErrorNum++;
if( (pData->DpramPrtEv!=NULL) && (pData->DpramTid!=NULL) )
ev_send(pData->DpramTid,pData->DpramPrtEv);
return;
}
/***********************************************************************/
/* UP_Irq2Isr: IRQ2中断服务程序 */
/* */
/* RETURNS: None */
/***********************************************************************/
void UP_Irq2Isr(void)
{
ULONG s;
DpramSetActionStruct* pData;
pData = &pEcomDpramIntSet;
/* mask off all CPU interrupt */
s = splx(MAX_ILEV);
if( (pData->DpramUpEv!=NULL) && (pData->DpramTid!=NULL) )
ev_send(pData->DpramTid,pData->DpramUpEv);
/* clear interrupt 2 pending bit */
S_SiPendRegister |= IRQ2_PENDING; /* SPLX done */
/* restore CPU interrupt mask */
(void)splx(s);
}
/***********************************************************************/
/* DN_Irq3Isr: IRQ3中断服务程序 */
/* */
/* RETURNS: None */
/***********************************************************************/
void DN_Irq3Isr(void)
{
ULONG s;
DpramSetActionStruct* pData;
pData = &pEcomDpramIntSet;
/* mask off all CPU interrupt */
s = splx(MAX_ILEV);
if( (pData->DpramDnEv!=NULL) && (pData->DpramTid!=NULL) )
ev_send(pData->DpramTid,pData->DpramDnEv);
/* clear interrupt 3 pending bit */
S_SiPendRegister |= IRQ3_PENDING; /* SPLX done */
/* restore CPU interrupt mask */
(void)splx(s);
}
/***********************************************************************/
/* InitInt: IRQ中断初始化程序 */
/* */
/* RETURNS: None */
/***********************************************************************/
void InitInt(void)
{
ULONG s;
/* mask off all CPU interrupt */
s = splx(MAX_ILEV);
/* init UP_IRQ2() */
IsrAddHandler(V_SIU_IRQ2,(void *)UP_Irq2Isr, (void *)0);
S_IntEdgeLvlMaskReg |= IRQ2_MASK; /* SPLX done */
S_SiPendRegister |= IRQ2_PENDING; /* SPLX done */
S_SiMaskRegister |= IRQ2_MASK; /* SPLX done */
/* init DN_IRQ3() */
IsrAddHandler(V_SIU_IRQ3,(void *)DN_Irq3Isr, (void *)0);
S_IntEdgeLvlMaskReg |= IRQ3_MASK; /* SPLX done */
S_SiPendRegister |= IRQ3_PENDING; /* SPLX done */
S_SiMaskRegister |= IRQ3_MASK; /* SPLX done */
/* Set Event */
pEcomDpramIntSet.DpramUpEv=DPRAM_UP_EV;
pEcomDpramIntSet.DpramDnEv=DPRAM_DN_EV;
pEcomDpramIntSet.DpramPrtEv=DPRAM_PRT_EV;
pEcomDpramIntSet.ParityErrorNum=0;
pEcomDpramIntSet.DpramTid=0;
/* restore CPU interrupt mask */
(void)splx(s);
}
/*******************************************************************/
/* ReadMailbox: This function is used to Clear the Interrupt sign */
/* */
/* INPUTS : Name. : ECOM_DPRAM_UP, ECOM_DPRAM_DN;
*/
/* OUTPUTS : Write operation successful (TRUE) or not (FALSE) */
/* */
/*******************************************************************/
int ReadMailbox(int Name)
{
UCHAR *mailbox;
volatile Temp;
if(Name == ECOM_DPRAM_UP)
mailbox=(UCHAR *)(CS4_BASE+0x0ffc);
else if(Name == ECOM_DPRAM_DN)
mailbox = (UCHAR *)(CS5_BASE+0x0ffc);
else
return FALSE;
Temp = *mailbox;
return TRUE;
}
/*******************************************************************/
/* WriteMailbox: This function is used to Set the Interrupt sign */
/* */
/* INPUTS : Name. : ECOM_DPRAM_UP, ECOM_DPRAM_DN;
*/
/* OUTPUTS : Write operation successful (TRUE) or not (FALSE) */
/* */
/*******************************************************************/
int WriteMailbox(int Name)
{
USHORT *mailbox;
if(Name == ECOM_DPRAM_UP)
mailbox=(USHORT *)(CS4_BASE+0x0ffe);
else if(Name == ECOM_DPRAM_DN)
mailbox = (USHORT *)(CS5_BASE+0x0ffe);
else
return FALSE;
*mailbox = 0x0001;
return TRUE;
}
/*******************************************************************/
/* DpramRead: This function is used to read data in the DPRAM. */
/* */
/* INPUTS : Name. : ECOM_DPRAM_UP, ECOM_DPRAM_DN;
Offset : 字节偏移地址。
DataLen : 要读取数据的字节长度。
BufAddr : 缓冲区的指针
*/
/* OUTPUTS : Write operation successful (TRUE) or not (FALSE) */
/* */
/*******************************************************************/
int DpramRead(int Name, ULONG Offset, ULONG DataLen, UCHAR *BufAddr)
{
UCHAR *addr;
int i;
if(Name == ECOM_DPRAM_UP)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -