阅读:1771回复:2
DM642+PCI驱动源码分析一下
#define SI_PASSTHROUGH_REGION_INDEX 0
#define SI_PASSTHROUGH_OFFSET_INDEX 1 #define SI_PASSTHROUGH_COUNT_INDEX 2 NTSTATUS SheldonPassthroughRead(PIRP Irp, PDEVICE_EXTENSION pdx) { PULONG params; CHAR *bytePointer; // get a ULONG pointer to the buffer params = (PULONG) Irp->AssociatedIrp.SystemBuffer; // KdPrint((" the region %d,the offset is %d,the count is %d\n",params[0],params[1],params[2])); // check that the passthrough region given really is a passthrough region if(params[SI_PASSTHROUGH_REGION_INDEX] > TI_MAX_REGION || params[SI_PASSTHROUGH_REGION_INDEX] < TI_MIN_REGION) return STATUS_INVALID_PARAMETER_1; // check that the offset is smaller than the size of the region if(params[SI_PASSTHROUGH_OFFSET_INDEX] > (pdx->base_len[params[SI_PASSTHROUGH_REGION_INDEX]]) ) return STATUS_INVALID_PARAMETER_2; // check for null base pointer if(pdx->base[params[SI_PASSTHROUGH_REGION_INDEX]] == NULL) return STATUS_INVALID_PARAMETER_1; bytePointer = (CHAR *) pdx->base[params[SI_PASSTHROUGH_REGION_INDEX]]; bytePointer += params[SI_PASSTHROUGH_OFFSET_INDEX]; // write number of bytes coming back, before this param is overwritten Irp->IoStatus.Information = params[SI_PASSTHROUGH_COUNT_INDEX] * sizeof(ULONG); // all looks OK, so do the read if(pdx->mem_mapped[params[SI_PASSTHROUGH_REGION_INDEX]]) { READ_REGISTER_BUFFER_ULONG((PULONG) bytePointer, (PULONG) Irp->AssociatedIrp.SystemBuffer, params[SI_PASSTHROUGH_COUNT_INDEX]); } else { READ_PORT_BUFFER_ULONG((PULONG) bytePointer, (PULONG) Irp->AssociatedIrp.SystemBuffer, params[SI_PASSTHROUGH_COUNT_INDEX]); } return STATUS_SUCCESS; } 这是DM642的PCI驱动程序的一个函数,以4字节为单位,读DSP上的IO端口或者内存,其中IO端口为区域0,片内RAM和片外SDRAM都为区域1。 有些地方看不懂: 在一开始params 指向了AssociatedIrp.SystemBuffer,在后面的操作中,为什么params[0],params[1],params[2]分别指向了“region ”,“offset ”,“count ”? 这个是规定好的吗,还是在别的地方赋值了的? 请高手们给点提示,谢谢! 有意讨论者请加QQ:28813358 |
|
沙发#
发布于:2009-10-15 16:54
|
|
板凳#
发布于:2009-10-15 16:58
高手指点下,什么回事啊
|
|