📄 pcmcia_ide.c
字号:
#ifdef DEBUG_OUT printk("mbx8xx_pcmciaide_write_reg(0x%x,0x%x)\r\n",reg,value & 0xff);#endif if (reg == IDE_REGISTER_DATA_WORD) {#ifdef DATAREG_16BIT *(volatile unsigned16 *)(port+reg) = value; #else *(volatile unsigned8 *)(port+reg) = value >> 8; *(volatile unsigned8 *)(port+reg+1) = value; #endif } else { *(volatile unsigned8 *)(port+reg)= value; }}/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/void mbx8xx_pcmciaide_read_block(/*-------------------------------------------------------------------------*\| Purpose: || read a PCMCIA IDE controller register |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor, unsigned16 block_size, blkdev_sg_buffer *bufs, rtems_unsigned32 *cbuf, rtems_unsigned32 *pos )/*-------------------------------------------------------------------------*\| Return Value: || <none> |\*=========================================================================*/{ unsigned32 port = IDE_Controller_Table[minor].port1; unsigned16 cnt = 0;#ifdef DEBUG_OUT printk("mbx8xx_pcmciaide_read_block()\r\n");#endif#ifdef DATAREG_16BIT unsigned16 *lbuf = (unsigned16 *) ((unsigned8 *)(bufs[(*cbuf)].buffer) + (*pos));#else unsigned8 *lbuf = (unsigned8 *) ((unsigned8 *)(bufs[(*cbuf)].buffer) + (*pos));#endif unsigned32 llength = bufs[(*cbuf)].length; while (((*(volatile unsigned8 *)(port+IDE_REGISTER_STATUS)) & IDE_REGISTER_STATUS_DRQ) && (cnt < block_size)) {#ifdef DATAREG_16BIT *lbuf++ = *(volatile unsigned16 *)(port+8); /* 16 bit data port */ cnt += 2; (*pos) += 2;#else *lbuf++ = *(volatile unsigned8 *)(port+IDE_REGISTER_DATA); cnt += 1; (*pos) += 1;#endif if ((*pos) == llength) { (*pos) = 0; (*cbuf)++; lbuf = bufs[(*cbuf)].buffer; llength = bufs[(*cbuf)].length; } } }/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/void mbx8xx_pcmciaide_write_block(/*-------------------------------------------------------------------------*\| Purpose: || write a PCMCIA IDE controller register |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor, unsigned16 block_size, blkdev_sg_buffer *bufs, rtems_unsigned32 *cbuf, rtems_unsigned32 *pos )/*-------------------------------------------------------------------------*\| Return Value: || <none> |\*=========================================================================*/{ unsigned32 port = IDE_Controller_Table[minor].port1; unsigned16 cnt = 0;#ifdef DEBUG_OUT printk("mbx8xx_pcmciaide_write_block()\r\n");#endif#ifdef DATA_REG_16BIT unsigned16 *lbuf = (unsigned16 *) ((unsigned8 *)(bufs[(*cbuf)].buffer) + (*pos));#else unsigned8 *lbuf = (unsigned8 *) ((unsigned8 *)(bufs[(*cbuf)].buffer) + (*pos));#endif unsigned32 llength = bufs[(*cbuf)].length; while (((*(volatile unsigned8 *)(port+IDE_REGISTER_STATUS)) & IDE_REGISTER_STATUS_DRQ) && (cnt < block_size)) {#ifdef DATAREG_16BIT *(volatile unsigned16 *)(port+8) = *lbuf++; /* 16 bit data port */ cnt += 2; (*pos) += 2;#else *(volatile unsigned8 *)(port+IDE_REGISTER_DATA) = *lbuf++; cnt += 1; (*pos) += 1;#endif if ((*pos) == llength) { (*pos) = 0; (*cbuf)++; lbuf = bufs[(*cbuf)].buffer; llength = bufs[(*cbuf)].length; } } }/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/int mbx8xx_pcmciaide_control(/*-------------------------------------------------------------------------*\| Purpose: || control interface for controller |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor, /* controller minor number */ unsigned32 cmd, /* command to send */ void * arg /* optional argument */ )/*-------------------------------------------------------------------------*\| Return Value: || <none> |\*=========================================================================*/{ return 0;}/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/rtems_status_code mbx8xx_pcmciaide_config_io_speed(/*-------------------------------------------------------------------------*\| Purpose: || set up transfer speed, if possible |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor, /* controller minor number */ unsigned8 modes_avail /* optional argument */ )/*-------------------------------------------------------------------------*\| Return Value: || rtems_status_code |\*=========================================================================*/{ return RTEMS_SUCCESSFUL;}/* * The following table configures the functions used for IDE drivers * in this BSP. */ide_ctrl_fns_t mbx8xx_pcmciaide_ctrl_fns = { mbx8xx_pcmciaide_probe, mbx8xx_pcmciaide_initialize, mbx8xx_pcmciaide_control, mbx8xx_pcmciaide_read_reg, mbx8xx_pcmciaide_write_reg, mbx8xx_pcmciaide_read_block, mbx8xx_pcmciaide_write_block, mbx8xx_pcmciaide_config_io_speed};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -