void HDLC_read_service(int irq,void *dev_id,struct pt_regs *regs)//中断处理函数
{
printk("\n(----K----)INTERRUPT EXECUTED!(----K----)\n");
int i,k;
BYTE rLen;
BYTE rBuf[512];
BYTE Channel;
UWORD16 HdlcQueueData;
UWORD16 * HdlcQueue;
if( HdlcReg[HDLC_IR] & 0x01 )
{
for(i=0;i<HdlcQueueSize;i++)
{
SetRamPage(InitBlockPage);
HdlcQueue=(UWORD16 *)(St5465_Mem_BaseAddr+HdlcQueue_BaseAddr);
HdlcQueueData=HdlcQueue[i];
HdlcQueue[i]=0x00;
if( HdlcQueueData & 0x8000 )
file://HDLC INT NOT APPLIED YET
{
if( HdlcQueueData & 0x2000 ) // Tx
{
}
else // Rx
{
Channel = ( (HdlcQueueData & 0x1F00) >> 8 );
rLen = GetHdlcFrame(Channel,rBuf);
if(rLen > 0 && rLen < 63)
{
printk("\n(----K----)Receive From Hdlc Port %2d : ",Channel);
for(k=0;k<rLen;k++)
printk("%02x ",rBuf[k]);
}
}
}
}
}
}
struct file_operations arm7_fops = {
read: read_Arm7,
write: write_Arm7,
open: open_Arm7,
release: release_Arm7,
};
int hdlc_init(void)
{
int result;
result = register_chrdev(254, "hdlc", &arm7_fops);
if (result < 0)
{
printk("(----K----)Test: can't register the test driver\n");
return(-1);
}
if (Arm7_major == 0)
Arm7_major = result;
printk("(----K----)Major Number=%d\n",result);
result=request_irq(HDLC_READ_IRQ,&HDLC_read_service,SA_INTERRUPT,"HDLC_read",NULL);
INT_ENABLE(HDLC_READ_IRQ);
//注册使能中断
if (result == -1)
{
printk("(----K----)Can't get assigned irq %d\n",HDLC_READ_IRQ);
return -1;
}
return(0);
}