⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcidpprotect.cod

📁 一个amccs5933芯片的驱动程序开发源程序和部分文档
💻 COD
📖 第 1 页 / 共 2 页
字号:
	TITLE	I:\PCI-DP\KERNEL\KERNELNT\pcidpprotect.c
	.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS	ENDS
_TLS	SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS	ENDS
;	COMDAT _RtlConvertLongToLargeInteger@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _ReportResources@8
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
;	COMDAT _UnReportResources@4
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC	_ReportResources@8
EXTRN	__imp__IoReportResourceUsage@36:NEAR
EXTRN	__imp__ExAllocatePoolWithTag@12:NEAR
EXTRN	__imp__ExFreePool@4:NEAR
;	COMDAT _ReportResources@8
_TEXT	SEGMENT
_DeviceObject$ = 8
_CardInfo$ = 12
_ConflictDetected$ = -1
_PhysicalAddress$ = -12
_ObjExt$ = -8
_ReportResources@8 PROC NEAR				; COMDAT

; 28   : ){

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

; 29   : 
; 30   : 	BOOLEAN ConflictDetected;
; 31   : 	NTSTATUS NTStatus;
; 32   : 	PHYSICAL_ADDRESS PhysicalAddress = {0,0};
; 33   : 	ULONG SizeOfResourceList;
; 34   : 	//ULONG* DataPointer;
; 35   : 	PCM_RESOURCE_LIST ResourceList;
; 36   : 	PCM_FULL_RESOURCE_DESCRIPTOR FullResource;
; 37   : 	PCM_PARTIAL_RESOURCE_LIST PartialList;
; 38   : 	PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResource;
; 39   : 	pPCIDP_EXTENSION ObjExt = (pPCIDP_EXTENSION)DeviceObject->DeviceExtension;

  00006	8b 45 08	 mov	 eax, DWORD PTR _DeviceObject$[ebp]
  00009	53		 push	 ebx
  0000a	56		 push	 esi
  0000b	57		 push	 edi
  0000c	8b 40 28	 mov	 eax, DWORD PTR [eax+40]

; 40   : 
; 41   : 	// The size of the resource list is going to be one full resource
; 42   : 	// list which already has one full resource descriptor included
; 43   : 	// which already has one partial list included which already has
; 44   : 	// one partial descriptor included; plus four more partial descriptors.
; 45   : 	// One partial descriptor will be for the interrupt, one for the port,
; 46   : 	// and the remaining three for memory. The full resource descriptor
; 47   : 	// describes the PCI bus.  Each partial resource descriptor describes
; 48   : 	// each type of resource (e.g. interrupts, memory, ports).
; 49   : 	SizeOfResourceList = sizeof(CM_RESOURCE_LIST);
; 50   : 	SizeOfResourceList += sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR)*8;
; 51   : 	SizeOfResourceList += sizeof(ULONG)*5;        //device specific data
; 52   : 
; 53   : 	// Now allocate memory pool for the structure.
; 54   : 	ResourceList = ExAllocatePool(
; 55   : 		PagedPool,
; 56   : 		SizeOfResourceList
; 57   : 	);

  0000f	68 44 64 6b 20	 push	 543908932		; 206b6444H
  00014	33 db		 xor	 ebx, ebx
  00016	68 b8 00 00 00	 push	 184			; 000000b8H
  0001b	6a 01		 push	 1
  0001d	89 5d f4	 mov	 DWORD PTR _PhysicalAddress$[ebp], ebx
  00020	89 45 f8	 mov	 DWORD PTR _ObjExt$[ebp], eax
  00023	ff 15 00 00 00
	00		 call	 DWORD PTR __imp__ExAllocatePoolWithTag@12
  00029	8b f0		 mov	 esi, eax

; 58   : 
; 59   : 	// Initialize the structure prior to calling IoReportResourceUsage.
; 60   : 	if(ResourceList){

  0002b	3b f3		 cmp	 esi, ebx
  0002d	0f 84 f7 00 00
	00		 je	 $L5912

; 61   : 		RtlZeroMemory(ResourceList, SizeOfResourceList);

  00033	6a 2e		 push	 46			; 0000002eH
  00035	33 c0		 xor	 eax, eax
  00037	59		 pop	 ecx
  00038	8b fe		 mov	 edi, esi

; 62   : 		ResourceList->Count = 1;      // number of resource descriptors
; 63   : 
; 64   : 		FullResource = &ResourceList->List[0];
; 65   : 		FullResource->InterfaceType = PCIBus;
; 66   : 		FullResource->BusNumber = ObjExt->BusNumber;
; 67   : 
; 68   : 		PartialList = &FullResource->PartialResourceList;
; 69   : 		PartialList->Version = 1;
; 70   : 		PartialList->Revision = 0;
; 71   : 
; 72   : 		// Calculate the number of partial resource descriptors.
; 73   : 		if((ULONG)CardInfo->u.type0.InterruptPin == 0)

  0003a	8b 55 0c	 mov	 edx, DWORD PTR _CardInfo$[ebp]
  0003d	6a 01		 push	 1
  0003f	f3 ab		 rep stosd
  00041	8b 4d f8	 mov	 ecx, DWORD PTR _ObjExt$[ebp]
  00044	58		 pop	 eax
  00045	89 06		 mov	 DWORD PTR [esi], eax
  00047	c7 46 04 05 00
	00 00		 mov	 DWORD PTR [esi+4], 5
  0004e	8b 09		 mov	 ecx, DWORD PTR [ecx]
  00050	89 4e 08	 mov	 DWORD PTR [esi+8], ecx
  00053	66 89 46 0c	 mov	 WORD PTR [esi+12], ax
  00057	66 89 5e 0e	 mov	 WORD PTR [esi+14], bx
  0005b	38 5a 3d	 cmp	 BYTE PTR [edx+61], bl
  0005e	75 09		 jne	 SHORT $L5914

; 74   : 			PartialList->Count = 3;

  00060	c7 46 10 03 00
	00 00		 mov	 DWORD PTR [esi+16], 3

; 75   : 		else

  00067	eb 07		 jmp	 SHORT $L5915
$L5914:

; 76   : 			PartialList->Count = 4;

  00069	c7 46 10 04 00
	00 00		 mov	 DWORD PTR [esi+16], 4
$L5915:

; 77   : 
; 78   : 		PartialResource = &PartialList->PartialDescriptors[0];
; 79   : 
; 80   : 		// Fill the partial resource for the interrupt.
; 81   : 		PartialResource++;
; 82   : 		if((ULONG)CardInfo->u.type0.InterruptPin != 0){

  00070	38 5a 3d	 cmp	 BYTE PTR [edx+61], bl
  00073	8d 46 24	 lea	 eax, DWORD PTR [esi+36]
  00076	74 1b		 je	 SHORT $L5917

; 83   : 			PartialResource->Type = CmResourceTypeInterrupt;

  00078	c6 00 02	 mov	 BYTE PTR [eax], 2

; 84   : 			PartialResource->ShareDisposition = CmResourceShareShared;

  0007b	c6 40 01 03	 mov	 BYTE PTR [eax+1], 3

; 85   : 			//PartialResource->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
; 86   : 			PartialResource->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;

  0007f	66 89 58 02	 mov	 WORD PTR [eax+2], bx

; 87   : 			PartialResource->u.Interrupt.Level = (ULONG)CardInfo->u.type0.InterruptLine;
; 88   : 			PartialResource->u.Interrupt.Vector = 0;
; 89   : 			PartialResource->u.Interrupt.Affinity = 0;
; 90   : 			PartialResource++;

  00083	83 c0 10	 add	 eax, 16			; 00000010H
  00086	0f b6 4a 3c	 movzx	 ecx, BYTE PTR [edx+60]
  0008a	89 48 f4	 mov	 DWORD PTR [eax-12], ecx
  0008d	89 58 f8	 mov	 DWORD PTR [eax-8], ebx
  00090	89 58 fc	 mov	 DWORD PTR [eax-4], ebx
$L5917:

; 91   : 		}
; 92   : 
; 93   : 		// Fill the partial resource for the port I/O board registers.
; 94   : 		PartialResource->Type = CmResourceTypePort;

  00093	c6 00 01	 mov	 BYTE PTR [eax], 1

; 95   : 		PartialResource->ShareDisposition = CmResourceShareDeviceExclusive;

  00096	c6 40 01 01	 mov	 BYTE PTR [eax+1], 1

; 96   : 		PartialResource->Flags = CM_RESOURCE_PORT_IO;

  0009a	66 c7 40 02 01
	00		 mov	 WORD PTR [eax+2], 1

; 97   : 		PhysicalAddress.LowPart = CardInfo->u.type0.BaseAddresses[1] & 0xFFFFFFFE;

  000a0	8b 4a 14	 mov	 ecx, DWORD PTR [edx+20]
  000a3	83 e1 fe	 and	 ecx, -2			; fffffffeH

; 98   : 		PartialResource->u.Port.Start = PhysicalAddress;
; 99   : 		PartialResource->u.Port.Length = 8;

  000a6	c7 40 0c 08 00
	00 00		 mov	 DWORD PTR [eax+12], 8
  000ad	89 48 04	 mov	 DWORD PTR [eax+4], ecx
  000b0	89 58 08	 mov	 DWORD PTR [eax+8], ebx

; 100  : 
; 101  : 		// Fill the partial resource for the memory mapped RAM.
; 102  : 		PartialResource++;

  000b3	83 c0 10	 add	 eax, 16			; 00000010H

; 103  : 		PartialResource->Type = CmResourceTypeMemory;
; 104  : 		PartialResource->ShareDisposition = CmResourceShareDeviceExclusive;
; 105  : 		PartialResource->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
; 106  : 		PhysicalAddress.LowPart = CardInfo->u.type0.BaseAddresses[0];
; 107  : 		PartialResource->u.Memory.Start = PhysicalAddress;
; 108  : 		PartialResource->u.Memory.Length = MemoryBaseSize;
; 109  : 
; 110  : 		// Fill the partial resource for the memory mapped DMA.
; 111  : 		PartialResource++;
; 112  : 		PartialResource->Type = CmResourceTypeMemory;
; 113  : 		PartialResource->ShareDisposition = CmResourceShareShared;
; 114  : 		PartialResource->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
; 115  : 		PhysicalAddress.LowPart = (ULONG)ObjExt->PhysicalDMAAddress;

  000b6	8b 4d f8	 mov	 ecx, DWORD PTR _ObjExt$[ebp]
  000b9	c6 00 03	 mov	 BYTE PTR [eax], 3
  000bc	c6 40 01 01	 mov	 BYTE PTR [eax+1], 1
  000c0	66 89 58 02	 mov	 WORD PTR [eax+2], bx
  000c4	8b 52 10	 mov	 edx, DWORD PTR [edx+16]
  000c7	89 50 04	 mov	 DWORD PTR [eax+4], edx
  000ca	89 58 08	 mov	 DWORD PTR [eax+8], ebx
  000cd	c7 40 0c 00 80
	00 00		 mov	 DWORD PTR [eax+12], 32768 ; 00008000H
  000d4	83 c0 10	 add	 eax, 16			; 00000010H

⌨️ 快捷键说明

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