pcidppublic.cod

来自「一个amccs5933芯片的驱动程序开发源程序和部分文档」· COD 代码 · 共 2,006 行 · 第 1/4 页

COD
2,006
字号
_CurrentLink$ = 20
_FirstLink$ = -8
_PCIDPUnMapDMA@16 PROC NEAR				; COMDAT

; 392  : ){

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	83 ec 0c	 sub	 esp, 12			; 0000000cH

; 393  : 
; 394  : 	// Define variables.
; 395  : 	ULONG i;
; 396  : 	NTSTATUS NTStatus;
; 397  : 	pPCIDP00_UNMAP_DMA_SEND IoInput;
; 398  : 	pPCIDP_EXTENSION ObjExt;
; 399  : 	PMDL Mdl;
; 400  : 	pREGISTERED_INTERRUPT RegisteredInt;
; 401  : 	KIRQL CancelSpin;
; 402  : 	pLINKED_LIST CurrentLink;
; 403  : 	pLINKED_LIST FirstLink;
; 404  : 
; 405  : 	// Initialize variables.
; 406  : 	NTStatus = STATUS_SUCCESS;
; 407  : 	IoInput = (pPCIDP00_UNMAP_DMA_SEND)IoBuffer;
; 408  : 	ObjExt = (pPCIDP_EXTENSION)DeviceObject->DeviceExtension;

  00006	8b 45 08	 mov	 eax, DWORD PTR _DeviceObject$[ebp]

; 409  : 
; 410  : 	if(InputBufferLength >= sizeof(PCIDP00_UNMAP_DMA_SEND)){

  00009	83 7d 14 04	 cmp	 DWORD PTR _InputBufferLength$[ebp], 4
  0000d	53		 push	 ebx
  0000e	57		 push	 edi
  0000f	8b 78 28	 mov	 edi, DWORD PTR [eax+40]
  00012	0f 82 d7 00 00
	00		 jb	 $L6092

; 411  : 		if(ObjExt->MDL){

  00018	8b 87 8c 00 00
	00		 mov	 eax, DWORD PTR [edi+140]
  0001e	33 db		 xor	 ebx, ebx
  00020	3b c3		 cmp	 eax, ebx
  00022	0f 84 be 00 00
	00		 je	 $L6093

; 412  : 			MmUnmapLockedPages((PVOID)IoInput->LinearAddress, ObjExt->MDL);

  00028	50		 push	 eax
  00029	8b 45 10	 mov	 eax, DWORD PTR _IoBuffer$[ebp]
  0002c	ff 30		 push	 DWORD PTR [eax]
  0002e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__MmUnmapLockedPages@8

; 413  : 			NTStatus = STATUS_SUCCESS;
; 414  : 
; 415  : 			//ObjExt->MemoryBase[0x1C61]++;	//debug
; 416  : 
; 417  : 			// Cancel the CancelMapDMA pending irp.
; 418  : 			CurrentLink = NULL;
; 419  : 			FirstLink = NULL;
; 420  : 			while(GetNextEntry(ObjExt, &FirstLink, &CurrentLink, &RegisteredInt) == TRUE){

  00034	8d 45 08	 lea	 eax, DWORD PTR _RegisteredInt$[ebp]
  00037	89 5d fc	 mov	 DWORD PTR _NTStatus$[ebp], ebx
  0003a	50		 push	 eax
  0003b	8d 45 14	 lea	 eax, DWORD PTR _CurrentLink$[ebp]
  0003e	50		 push	 eax
  0003f	8d 45 f8	 lea	 eax, DWORD PTR _FirstLink$[ebp]
  00042	50		 push	 eax
  00043	57		 push	 edi
  00044	89 5d 14	 mov	 DWORD PTR _CurrentLink$[ebp], ebx
  00047	89 5d f8	 mov	 DWORD PTR _FirstLink$[ebp], ebx
  0004a	e8 00 00 00 00	 call	 _GetNextEntry@16
  0004f	3c 01		 cmp	 al, 1
  00051	0f 85 9f 00 00
	00		 jne	 $L6110
  00057	56		 push	 esi
  00058	8b 35 00 00 00
	00		 mov	 esi, DWORD PTR __imp__IoReleaseCancelSpinLock@4
$L6099:

; 421  : 
; 422  : 				//ObjExt->MemoryBase[0x1C62]++;	//debug
; 423  : 
; 424  : 				if(IoInput->LinearAddress == RegisteredInt->Type){

  0005e	8b 45 10	 mov	 eax, DWORD PTR _IoBuffer$[ebp]
  00061	8b 4d 08	 mov	 ecx, DWORD PTR _RegisteredInt$[ebp]
  00064	8b 00		 mov	 eax, DWORD PTR [eax]
  00066	3b 01		 cmp	 eax, DWORD PTR [ecx]
  00068	75 56		 jne	 SHORT $L6101

; 425  : 
; 426  : 					// Found an entry.  Disable the cancel routine, complete the I/O for
; 427  : 					// this IRP, then delete the linked	list entry.
; 428  : 					IoAcquireCancelSpinLock (&CancelSpin);

  0006a	8d 45 f4	 lea	 eax, DWORD PTR _CancelSpin$[ebp]
  0006d	50		 push	 eax
  0006e	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__IoAcquireCancelSpinLock@4

; 429  : 					IoSetCancelRoutine(RegisteredInt->Irp, NULL);

  00074	8b 45 08	 mov	 eax, DWORD PTR _RegisteredInt$[ebp]
  00077	33 d2		 xor	 edx, edx
  00079	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  0007c	83 c1 38	 add	 ecx, 56			; 00000038H
  0007f	e8 00 00 00 00	 call	 @InterlockedExchange@8

; 430  : 					IoReleaseCancelSpinLock (CancelSpin);

  00084	ff 75 f4	 push	 DWORD PTR _CancelSpin$[ebp]
  00087	ff d6		 call	 esi

; 431  : 					IoReleaseCancelSpinLock (RegisteredInt->Irp->CancelIrql);

  00089	8b 45 08	 mov	 eax, DWORD PTR _RegisteredInt$[ebp]
  0008c	8b 40 04	 mov	 eax, DWORD PTR [eax+4]
  0008f	8a 40 25	 mov	 al, BYTE PTR [eax+37]
  00092	50		 push	 eax
  00093	ff d6		 call	 esi

; 432  : 					RegisteredInt->Irp->IoStatus.Status = STATUS_SUCCESS ;

  00095	8b 45 08	 mov	 eax, DWORD PTR _RegisteredInt$[ebp]

; 433  : 					RegisteredInt->Irp->IoStatus.Information = 0 ;
; 434  : 					IoCompleteRequest(RegisteredInt->Irp, IO_NO_INCREMENT);

  00098	32 d2		 xor	 dl, dl
  0009a	8b 40 04	 mov	 eax, DWORD PTR [eax+4]
  0009d	89 58 18	 mov	 DWORD PTR [eax+24], ebx
  000a0	8b 45 08	 mov	 eax, DWORD PTR _RegisteredInt$[ebp]
  000a3	8b 40 04	 mov	 eax, DWORD PTR [eax+4]
  000a6	89 58 1c	 mov	 DWORD PTR [eax+28], ebx
  000a9	8b 45 08	 mov	 eax, DWORD PTR _RegisteredInt$[ebp]
  000ac	8b 48 04	 mov	 ecx, DWORD PTR [eax+4]
  000af	ff 15 00 00 00
	00		 call	 DWORD PTR __imp_@IofCompleteRequest@8

; 435  : 
; 436  : 					//ObjExt->MemoryBase[0x1C63]++;	//debug
; 437  : 
; 438  : 					FreeEntry(ObjExt, CurrentLink);

  000b5	ff 75 14	 push	 DWORD PTR _CurrentLink$[ebp]
  000b8	57		 push	 edi
  000b9	e8 00 00 00 00	 call	 _FreeEntry@8

; 439  : 				}
; 440  : 				else

  000be	eb 09		 jmp	 SHORT $L6107
$L6101:

; 441  : 					PutBackEntry(ObjExt, CurrentLink);

  000c0	ff 75 14	 push	 DWORD PTR _CurrentLink$[ebp]
  000c3	57		 push	 edi
  000c4	e8 00 00 00 00	 call	 _PutBackEntry@8
$L6107:
  000c9	8d 45 08	 lea	 eax, DWORD PTR _RegisteredInt$[ebp]
  000cc	50		 push	 eax
  000cd	8d 45 14	 lea	 eax, DWORD PTR _CurrentLink$[ebp]
  000d0	50		 push	 eax
  000d1	8d 45 f8	 lea	 eax, DWORD PTR _FirstLink$[ebp]
  000d4	50		 push	 eax
  000d5	57		 push	 edi
  000d6	e8 00 00 00 00	 call	 _GetNextEntry@16
  000db	3c 01		 cmp	 al, 1
  000dd	0f 84 7b ff ff
	ff		 je	 $L6099
  000e3	5e		 pop	 esi

; 442  : 			}
; 443  : 		}
; 444  : 		else

  000e4	eb 10		 jmp	 SHORT $L6110
$L6093:

; 445  : 			NTStatus = STATUS_NO_MEMORY;

  000e6	c7 45 fc 17 00
	00 c0		 mov	 DWORD PTR _NTStatus$[ebp], -1073741801 ; c0000017H

; 446  : 
; 447  : 	}
; 448  : 	else

  000ed	eb 07		 jmp	 SHORT $L6110
$L6092:

; 449  : 		NTStatus = STATUS_INVALID_BUFFER_SIZE;

  000ef	c7 45 fc 06 02
	00 c0		 mov	 DWORD PTR _NTStatus$[ebp], -1073741306 ; c0000206H
$L6110:

; 450  : 
; 451  : 	Irp->IoStatus.Status = NTStatus;

  000f6	8b 45 0c	 mov	 eax, DWORD PTR _Irp$[ebp]
  000f9	8b 4d fc	 mov	 ecx, DWORD PTR _NTStatus$[ebp]
  000fc	5f		 pop	 edi
  000fd	5b		 pop	 ebx
  000fe	89 48 18	 mov	 DWORD PTR [eax+24], ecx

; 452  : }

  00101	c9		 leave
  00102	c2 10 00	 ret	 16			; 00000010H
_PCIDPUnMapDMA@16 ENDP
_TEXT	ENDS
PUBLIC	_PCIDPGetPCIRegs@16
EXTRN	__imp__HalGetBusData@20:NEAR
;	COMDAT _PCIDPGetPCIRegs@16
_TEXT	SEGMENT
_DeviceObject$ = 8
_Irp$ = 12
_IoBuffer$ = 16
_OutputBufferLength$ = 20
_PCIDPGetPCIRegs@16 PROC NEAR				; COMDAT

; 464  : ){

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp

; 465  : 
; 466  : 	// Define variables.
; 467  : 	NTSTATUS NTStatus;
; 468  : 	ULONG InfoSize;
; 469  : 	pPCIDP00_GET_PCI_CONFIG_REGS_RECV IoOutput;
; 470  : 	pPCIDP_EXTENSION ObjExt;
; 471  : 
; 472  : 	// Initialize variables.
; 473  : 	IoOutput = (pPCIDP00_GET_PCI_CONFIG_REGS_RECV)IoBuffer;
; 474  : 	ObjExt = (pPCIDP_EXTENSION)DeviceObject->DeviceExtension;

  00003	8b 45 08	 mov	 eax, DWORD PTR _DeviceObject$[ebp]

; 475  : 
; 476  : 	// Check for adequate output buffer space.
; 477  : 	if(OutputBufferLength >= sizeof(PCIDP00_GET_PCI_CONFIG_REGS_RECV)){

  00006	83 7d 14 40	 cmp	 DWORD PTR _OutputBufferLength$[ebp], 64 ; 00000040H
  0000a	56		 push	 esi
  0000b	8b 75 0c	 mov	 esi, DWORD PTR _Irp$[ebp]
  0000e	8b 40 28	 mov	 eax, DWORD PTR [eax+40]
  00011	72 2e		 jb	 SHORT $L6128

; 478  : 
; 479  : 		// Now get the PCI register space.
; 480  : 		InfoSize = HalGetBusData(
; 481  : 			IN PCIConfiguration,
; 482  : 			IN ObjExt->BusNumber,
; 483  : 			IN ObjExt->SlotNumber.u.AsULONG,
; 484  : 			OUT (PVOID)IoOutput,
; 485  : 			IN (ULONG)OutputBufferLength 
; 486  : 		);

  00013	ff 75 14	 push	 DWORD PTR _OutputBufferLength$[ebp]
  00016	ff 75 10	 push	 DWORD PTR _IoBuffer$[ebp]
  00019	ff 70 04	 push	 DWORD PTR [eax+4]
  0001c	ff 30		 push	 DWORD PTR [eax]
  0001e	6a 04		 push	 4
  00020	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__HalGetBusData@20

; 487  : 
; 488  : 		// Did we get any data?
; 489  : 		if(InfoSize > 2){

  00026	83 f8 02	 cmp	 eax, 2
  00029	76 0b		 jbe	 SHORT $L6131

; 490  : 			NTStatus = STATUS_SUCCESS;

  0002b	33 c0		 xor	 eax, eax

; 491  : 			Irp->IoStatus.Information = sizeof(PCIDP00_GET_PCI_CONFIG_REGS_RECV);

  0002d	c7 46 1c 40 00
	00 00		 mov	 DWORD PTR [esi+28], 64	; 00000040H

; 492  : 		}
; 493  : 
; 494  : 		else{

  00034	eb 10		 jmp	 SHORT $L6136
$L6131:

; 495  : 			NTStatus = STATUS_ACCESS_DENIED;
; 496  : 			Irp->IoStatus.Information = 0;

  00036	83 66 1c 00	 and	 DWORD PTR [esi+28], 0
  0003a	b8 22 00 00 c0	 mov	 eax, -1073741790	; c0000022H

; 497  : 		}
; 498  : 	}
; 499  : 
; 500  : 	else

  0003f	eb 05		 jmp	 SHORT $L6136
$L6128:

; 501  : 		NTStatus = STATUS_INVALID_BUFFER_SIZE;

  00041	b8 06 02 00 c0	 mov	 eax, -1073741306	; c0000206H
$L6136:

; 502  : 
; 503  : 	Irp->IoStatus.Status = NTStatus;

  00046	89 46 18	 mov	 DWORD PTR [esi+24], eax
  00049	5e		 pop	 esi

; 504  : }

  0004a	5d		 pop	 ebp
  0004b	c2 10 00	 ret	 16			; 00000010H
_PCIDPGetPCIRegs@16 ENDP
_TEXT	ENDS
PUBLIC	_PCIDPSetPCIRegs@16
EXTRN	__imp__HalSetBusData@20:NEAR
;	COMDAT _PCIDPSetPCIRegs@16
_TEXT	SEGMENT
_InputBufferLength$ = 20
_DeviceObject$ = 8
_Irp$ = 12
_IoBuffer$ = 16
_PCIDPSetPCIRegs@16 PROC NEAR				; COMDAT

; 516  : ){

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp

; 517  : 
; 518  : 	// Define variables.
; 519  : 	NTSTATUS NTStatus;
; 520  : 	ULONG InfoSize;
; 521  : 	pPCIDP00_SET_PCI_CONFIG_REGS_SEND IoInput;
; 522  : 	pPCIDP_EXTENSION ObjExt;
; 523  : 
; 524  : 	// Initialize variables.
; 525  : 	IoInput = (pPCIDP00_SET_PCI_CONFIG_REGS_SEND)IoBuffer;
; 526  : 	ObjExt = (pPCIDP_EXTENSION)DeviceObject->DeviceExtension;

  00003	8b 45 08	 mov	 eax, DWORD PTR _DeviceObject$[ebp]

; 527  : 
; 528  : 	// Check for adequate input buffer space.
; 529  : 	if(InputBufferLength >= sizeof(PCIDP00_SET_PCI_CONFIG_REGS_SEND)){

  00006	83 7d 14 40	 cmp	 DWORD PTR _InputBufferLength$[ebp], 64 ; 00000040H
  0000a	8b 40 28	 mov	 eax, DWORD PTR [eax+40]
  0000d	72 17		 jb	 SHORT $L6154

; 530  : 
; 531  : 		// Now set the PCI register space.
; 532  : 		InfoSize = HalSetBusData(
; 533  : 			IN PCIConfiguration,
; 534  : 			IN ObjExt->BusNumber,
; 535  : 			IN ObjExt->SlotNumber.u.AsULONG,
; 536  : 			IN (PVOID)IoInput,
; 537  : 			IN (ULONG)InputBufferLength 
; 538  : 		);

  0000f	ff 75 14	 push	 DWORD PTR _InputBufferLength$[ebp]
  00012	ff 75 10	 push	 DWORD PTR _IoBuffer$[ebp]
  00015	ff 70 04	 push	 DWORD PTR [eax+4]
  00018	ff 30		 push	 DWORD PTR [eax]
  0001a	6a 04		 push	 4
  0001c	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__HalSetBusData@20

; 539  : 
; 540  : 		NTStatus = STATUS_SUCCESS;

  00022	33 c0		 xor	 eax, eax

; 541  : 	}
; 542  : 
; 543  : 	else

  00024	eb 05		 jmp	 SHORT $L6158
$L6154:

; 544  : 		NTStatus = STATUS_INVALID_BUFFER_SIZE;

  00026	b8 06 02 00 c0	 mov	 eax, -1073741306	; c0000206H
$L6158:

; 545  : 
; 546  : 	Irp->IoStatus.Status = NTStatus;

  0002b	8b 4d 0c	 mov	 ecx, DWORD PTR _Irp$[ebp]
  0002e	89 41 18	 mov	 DWORD PTR [ecx+24], eax

; 547  : }

  00031	5d		 pop	 ebp
  00032	c2 10 00	 ret	 16			; 00000010H
_PCIDPSetPCIRegs@16 ENDP
_TEXT	ENDS
PUBLIC	_PCIDPRegisterInterrupt@20
EXTRN	_PCIDPCancelInterrupt@8:NEAR
;	COMDAT _PCIDPRegisterInterrupt@20
_TEXT	SEGMENT
_DeviceObject$ = 8
_Irp$ = 12
_IoBuffer$ = 16
_InputBufferLength$ = 20
_CancelSpin$ = 16
_MemoryBase$ = -4
_Type$ = 8
_PCIDPRegisterInterrupt@20 PROC NEAR			; COMDAT

; 560  : ){

  00000	55		 push	 ebp
  00001	8b ec		 mov	 ebp, esp
  00003	51		 push	 ecx

; 561  : 
; 562  : 	// Define variables.
; 563  : 	NTSTATUS NTStatus;
; 564  : 	pPCIDP00_REGISTER_INTERRUPT_SEND IoInput;
; 565  : 	pPCIDP_EXTENSION ObjExt;
; 566  : 	KIRQL CancelSpin;
; 567  : 	PULONG MemoryBase;
; 568  :   pLINKED_LIST LLEntry;
; 569  : 	ULONG Type;
; 570  : 	ULONG HINTPattern;
; 571  : 
; 572  : 	// Initialize variables.
; 573  : 	IoInput = (pPCIDP00_REGISTER_INTERRUPT_SEND)IoBuffer;
; 574  : 	ObjExt = (pPCIDP_EXTENSION)DeviceObject->DeviceExtension;

  00004	8b 45 08	 mov	 eax, DWORD PTR _DeviceObject$[ebp]
  00007	53		 push	 ebx

; 575  : 	MemoryBase = ObjExt->MemoryBase;
; 576  : 
; 577  : 	// Check that call was made via the PCIDP API.
; 578  : 	if((IoInput->InterruptType & 0xF0C00000) != 0xF0C00000){

  00008	b9 00 00 c0 f0	 mov	 ecx, -255852544		; f0c00000H
  0000d	56		 push	 esi
  0000e	8b 58 28	 mov	 ebx, DWORD PTR [eax+40]
  00011	57		 push	 edi
  00012	8b 7d 0c	 mov	 edi, DWORD PTR _Irp$[ebp]
  00015	8b 43 24	 mov	 eax, DWORD PTR [ebx+36]
  00018	89 45 fc	 mov	 DWORD PTR _MemoryBase$[ebp], eax
  0001b	8b 45 10	 mov	 eax, DWORD PTR _IoBuffer$[ebp]
  0001e	8b 00		 mov	 eax, DWORD PTR [eax]
  00020	8b d0		 mov	 edx, eax
  00022	23 d1		 and	 edx, ecx
  00024	3b d1		 cmp	 edx, ecx
  00026	74 0a		 je	 SHORT $L6181

; 579  : 		NTStatus = STATUS_ACCESS_DENIED;

  00028	b8 22 00 00 c0	 mov	 eax, -1073741790	; c0000022H

; 580  : 		goto ExitA;

  0002d	e9 bf 00 00 00	 jmp	 $ExitA$6183
$L6181:

; 581  : 	}
; 582  : 	Type = IoInput->InterruptType & 0x000003FF;

  00032	25 ff 03 00 00	 and	 eax, 1023		; 000003ffH

; 583  : 
; 584  : 	// Check to make sure the board has the interrupt pin enabled.
; 585  : 	if(ObjExt->InterruptObject == 0){

  00037	83 7b 2c 00	 cmp	 DWORD PTR [ebx+44], 0
  0003b	89 45 08	 mov	 DWORD PTR _Type$[ebp], eax
  0003e	75 0a		 jne	 SHORT $L6184

; 586  : 		NTStatus = STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT;

  00040	b8 6e 01 00 c0	 mov	 eax, -1073741458	; c000016eH

; 587  : 		goto ExitA;

  00045	e9 a7 00 00 00	 jmp	 $ExitA$6183
$L6184:

; 588  : 	}
; 589  : 
; 590  : 	// Make sure the buffer lengths are of sufficient size to handle
; 591  : 	// the transactions.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?