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 )
//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]);
}
}
}
}
}
}
static int open_Arm7(struct inode * inode, struct file * files)
{
MOD_INC_USE_COUNT;
printk("(----K----)open_Test Excuted!\n");
///////////////////////////////////////////////
InitBoard();
//////////////////////////////////////////////
Setup5465();
printk("(----K----)Init Hdlc Chip Bus Mode Ok!");
//////////////////////////////////////////////
return 0;
}
/*
* close access to the HDLCController
*/
static int release_Arm7(struct inode * inode, struct file * files)
{
int i;
for(i=0;i<32;i+=4)
printk("(----K----)ARM 0x3ff400%x = %x\n",i,(*(volatile unsigned int *)(0x3ff4000+i)));
MOD_DEC_USE_COUNT;
printk("\n(----K----)close_Test Excuted!\n");
return 0;
}
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);
}
多余的代码省略