pcidp.asm

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

ASM
2,261
字号
	pop	esi

; 240  : }

	ret	8
_PCIDPDispatchPower@8 ENDP
_TEXT	ENDS
EXTRN	_StartDevice@8:NEAR
EXTRN	_StopDevice@4:NEAR
EXTRN	_CancelStopDevice@8:NEAR
EXTRN	_RemoveDevice@4:NEAR
EXTRN	__imp_@IofCallDriver@8:NEAR
EXTRN	__imp_@IofCompleteRequest@8:NEAR
;	COMDAT _PCIDPDispatchPnp@8
; File c:\kernel2000\pcidp.c
_TEXT	SEGMENT
$SG8478	DB	'[PCIDP]->Entering DispatchPnp...', 0aH, 00H
	ORG $+2
$SG8498	DB	'[PCIDP]->Leaving DispatchPnp, status=%ld...', 0aH, 00H
_DeviceObject$ = 8
_Irp$ = 12
_PCIDPDispatchPnp@8 PROC NEAR				; COMDAT

; 251  : ){

	push	ebx
	push	esi
	push	edi

; 252  : 
; 253  : 	PIO_STACK_LOCATION IrpStack;
; 254  : 	NTSTATUS NTStatus;
; 255  : 	PPCIDP_EXTENSION ObjExt;
; 256  : 
; 257  : 	// Debug entry point
; 258  : 	DbgPrint("[PCIDP]->Entering DispatchPnp...\n");	//debug

	push	OFFSET FLAT:$SG8478
	call	_DbgPrint
	pop	ecx

; 259  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 260  : 
; 261  : 	ObjExt = (PPCIDP_EXTENSION)DeviceObject->DeviceExtension;
; 262  : 
; 263  : 	// Get a pointer to the current location in the Irp. This is where
; 264  : 	// the function codes and parameters are located.
; 265  : 	IrpStack = IoGetCurrentIrpStackLocation(IN Irp);

	mov	esi, DWORD PTR _Irp$[esp+8]
	mov	edx, DWORD PTR _DeviceObject$[esp+8]
	mov	eax, DWORD PTR [esi+96]
	mov	edi, DWORD PTR [edx+40]

; 337  : 
; 338  : 	return NTStatus;

	movzx	ecx, BYTE PTR [eax+1]
	cmp	ecx, 5
	jg	SHORT $L8724

; 266  : 
; 267  : 	// Determine the PnP I/O request packet.
; 268  : 	switch (IrpStack->MinorFunction){

	je	SHORT $L8492
	sub	ecx, 0
	je	SHORT $L8484
	dec	ecx
	je	SHORT $L8494
	dec	ecx
	je	SHORT $L8491
	dec	ecx
	dec	ecx
	jne	SHORT $L8496

; 286  : 
; 287  : 	case IRP_MN_STOP_DEVICE:
; 288  : 		NTStatus = StopDevice(DeviceObject);

	push	edx
	call	_StopDevice@4
	mov	ebx, eax
$L8728:

; 289  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack

	inc	BYTE PTR [esi+35]
	add	DWORD PTR [esi+96], 36			; 00000024H

; 290  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);
; 291  : 		break;

	jmp	SHORT $L8727
$L8491:

; 305  : 
; 306  : 	case IRP_MN_REMOVE_DEVICE:
; 307  : 		NTStatus = RemoveDevice(DeviceObject);

	push	edx
	call	_RemoveDevice@4
	mov	ebx, eax

; 308  : 		Irp->IoStatus.Status = NTStatus;

	mov	DWORD PTR [esi+24], ebx

; 309  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack
; 310  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);
; 311  : 		break;

	jmp	SHORT $L8728
$L8494:

; 297  : 		break;
; 298  : 
; 299  : 	case IRP_MN_QUERY_REMOVE_DEVICE:
; 300  : 		NTStatus = STATUS_UNSUCCESSFUL;

	mov	ebx, -1073741823			; c0000001H

; 301  : 		Irp->IoStatus.Status = NTStatus;

	mov	DWORD PTR [esi+24], ebx

; 302  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack
; 303  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);
; 304  : 		break;

	jmp	SHORT $L8726
$L8484:

; 269  : 
; 270  : 	case IRP_MN_START_DEVICE:
; 271  : 		NTStatus = StartDevice(DeviceObject, Irp);

	push	esi
	push	edx
	call	_StartDevice@8

; 272  : 		Irp->IoStatus.Status = NTStatus;
; 273  : 		//PoSetPowerState(DeviceObject, DevicePowerState, PowerDeviceD0);
; 274  : 		IoCompleteRequest(Irp, IO_NO_INCREMENT);	//back up the stack so complete it.
; 275  : 		break;

	jmp	SHORT $L8725
$L8492:

; 276  : 
; 277  : 	case IRP_MN_QUERY_STOP_DEVICE:
; 278  : 		//NTStatus = STATUS_UNSUCCESSFUL;
; 279  : 		//Irp->IoStatus.Status = NTStatus;
; 280  : 		//IoCompleteRequest(Irp, IO_NO_INCREMENT);
; 281  : 		NTStatus = STATUS_SUCCESS;

	xor	ebx, ebx

; 282  : 		Irp->IoStatus.Status = NTStatus;

	and	DWORD PTR [esi+24], ebx

; 283  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack
; 284  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);
; 285  : 		break;

	jmp	SHORT $L8726
$L8724:

; 266  : 
; 267  : 	// Determine the PnP I/O request packet.
; 268  : 	switch (IrpStack->MinorFunction){

	sub	ecx, 6
	je	SHORT $L8488
	sub	ecx, 16					; 00000010H
	je	SHORT $L8494
	dec	ecx
	je	SHORT $L8492
$L8496:

; 312  : 
; 313  : 	case IRP_MN_SURPRISE_REMOVAL:
; 314  : 		NTStatus = STATUS_SUCCESS;
; 315  : 		Irp->IoStatus.Status = NTStatus;
; 316  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack
; 317  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);
; 318  : 		break;
; 319  : 
; 320  : 	case IRP_MN_DEVICE_USAGE_NOTIFICATION:
; 321  : 		NTStatus = STATUS_UNSUCCESSFUL;
; 322  : 		Irp->IoStatus.Status = NTStatus;
; 323  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack
; 324  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);
; 325  : 		break;
; 326  : 
; 327  : 	default:
; 328  : 		NTStatus = STATUS_SUCCESS;

	xor	ebx, ebx
$L8726:

; 329  : 	  IoSkipCurrentIrpStackLocation(Irp);	//send it on down the stack

	inc	BYTE PTR [esi+35]
	add	eax, 36					; 00000024H
	mov	DWORD PTR [esi+96], eax
$L8727:

; 330  : 		IoCallDriver(ObjExt->NextLowerDeviceObject, Irp);

	mov	ecx, DWORD PTR [edi+140]
	mov	edx, esi
	call	DWORD PTR __imp_@IofCallDriver@8

; 331  : 		break;

	jmp	SHORT $L8481
$L8488:

; 292  : 
; 293  : 	case IRP_MN_CANCEL_STOP_DEVICE:
; 294  : 		NTStatus = CancelStopDevice(DeviceObject, Irp);

	push	esi
	push	edx
	call	_CancelStopDevice@8
$L8725:
	mov	ebx, eax

; 295  : 		Irp->IoStatus.Status = NTStatus;
; 296  : 		IoCompleteRequest(Irp, IO_NO_INCREMENT);	//back up the stack so complete it.

	xor	dl, dl
	mov	ecx, esi
	mov	DWORD PTR [esi+24], ebx
	call	DWORD PTR __imp_@IofCompleteRequest@8
$L8481:

; 332  : 	}
; 333  : 
; 334  : 	// Debug exit point
; 335  : 	DbgPrint("[PCIDP]->Leaving DispatchPnp, status=%ld...\n", NTStatus);	//debug

	push	ebx
	push	OFFSET FLAT:$SG8498
	call	_DbgPrint
	pop	ecx
	pop	ecx

; 336  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0
	pop	edi

; 337  : 
; 338  : 	return NTStatus;

	mov	eax, ebx
	pop	esi
	pop	ebx

; 339  : }

	ret	8
_PCIDPDispatchPnp@8 ENDP
_TEXT	ENDS
EXTRN	_PCIDPGetDriverVersion@12:NEAR
EXTRN	_PCIDPMapBaseRegs@20:NEAR
EXTRN	_PCIDPUnMap@16:NEAR
EXTRN	_PCIDPMapDMAMem@16:NEAR
EXTRN	_PCIDPCancelMapDMA@16:NEAR
EXTRN	_PCIDPUnMapDMA@16:NEAR
EXTRN	_PCIDPGetPCIRegs@20:NEAR
EXTRN	_PCIDPSetPCIRegs@20:NEAR
EXTRN	_PCIDPRegisterInterrupt@20:NEAR
EXTRN	_PCIDPUnregisterInterrupt@16:NEAR
;	COMDAT _PCIDPDeviceControl@8
; File c:\kernel2000\pcidp.c
_TEXT	SEGMENT
$SG8509	DB	'[PCIDP]->Entering DeviceControl...', 0aH, 00H
$SG8530	DB	'[PCIDP]->Leaving DeviceControl, status=%ld...', 0aH, 00H
_DeviceObject$ = 8
_Irp$ = 12
_OutputBufferLength$ = 12
_PCIDPDeviceControl@8 PROC NEAR				; COMDAT

; 350  : ){

	push	ebp
	mov	ebp, esp
	push	ebx
	push	esi
	push	edi

; 351  : 
; 352  : 	PIO_STACK_LOCATION IrpStack;
; 353  : 	PVOID IoBuffer;
; 354  : 	ULONG InputBufferLength;
; 355  : 	ULONG OutputBufferLength;
; 356  : 	NTSTATUS NTStatus;
; 357  : 
; 358  : 	// Debug entry point
; 359  : 	DbgPrint("[PCIDP]->Entering DeviceControl...\n");	//debug

	push	OFFSET FLAT:$SG8509
	call	_DbgPrint
	pop	ecx

; 360  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 361  : 
; 362  : 	// Initialize the return values with some defaults.
; 363  : 	Irp->IoStatus.Status = STATUS_SUCCESS;

	mov	esi, DWORD PTR _Irp$[ebp]

; 364  : 	Irp->IoStatus.Information = 0;
; 365  : 
; 366  : 	// Get a pointer to the current location in the Irp. This is where
; 367  : 	// the function codes and parameters are located.
; 368  : 	IrpStack = IoGetCurrentIrpStackLocation(IN Irp);
; 369  : 
; 370  : 	// Get the pointer to the input/output buffer and it's length(s).
; 371  : 	IoBuffer           = Irp->AssociatedIrp.SystemBuffer;
; 372  : 	InputBufferLength  = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
; 373  : 	OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
; 374  : 
; 375  : 
; 376  : 	// Determine which I/O control code was specified.
; 377  : 	switch (IrpStack->Parameters.DeviceIoControl.IoControlCode){

	mov	edi, -1023401836			; c3002094H
	mov	eax, DWORD PTR [esi+96]
	and	DWORD PTR [esi+24], 0
	and	DWORD PTR [esi+28], 0
	mov	ecx, DWORD PTR [esi+12]
	mov	edx, DWORD PTR [eax+4]
	mov	ebx, DWORD PTR [eax+8]
	mov	DWORD PTR _OutputBufferLength$[ebp], edx
	mov	edx, DWORD PTR [eax+12]
	cmp	edx, edi
	ja	$L8732
	je	$L8521
	cmp	edx, -1023401856			; c3002080H
	je	SHORT $L8515
	cmp	edx, -1023401852			; c3002084H
	je	SHORT $L8516
	cmp	edx, -1023401848			; c3002088H
	je	SHORT $L8517
	cmp	edx, -1023401844			; c300208cH
	je	SHORT $L8519
	cmp	edx, -1023401840			; c3002090H
	jne	$L8526

; 424  : 
; 425  : 	case IOCTL_PCIDP00_GET_PCI_CONFIG_REGS:
; 426  : 		PCIDPGetPCIRegs(
; 427  : 			IN DeviceObject,
; 428  : 			IN IrpStack->FileObject,
; 429  : 			IN OUT Irp,
; 430  : 			OUT IoBuffer,
; 431  : 			IN OutputBufferLength
; 432  : 		);

	push	DWORD PTR _OutputBufferLength$[ebp]
	push	ecx
	push	esi
	push	DWORD PTR [eax+24]
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPGetPCIRegs@20

; 433  : 		break;

	jmp	$L8512
$L8519:

; 415  : 
; 416  : 	case IOCTL_PCIDP00_UNMAP_DMA:
; 417  : 		PCIDPUnMapDMA(
; 418  : 			IN DeviceObject,
; 419  : 			IN OUT Irp,
; 420  : 			IN IoBuffer,
; 421  : 			IN InputBufferLength
; 422  : 		);

	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPUnMapDMA@16

; 423  : 		break;

	jmp	$L8512
$L8517:

; 397  : 
; 398  : 	case IOCTL_PCIDP00_MAP_DMA_MEM:
; 399  : 		PCIDPMapDMAMem(
; 400  : 			IN DeviceObject,
; 401  : 			IN OUT Irp,
; 402  : 			OUT IoBuffer,
; 403  : 			IN OutputBufferLength
; 404  : 		);

	push	DWORD PTR _OutputBufferLength$[ebp]
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPMapDMAMem@16

; 405  : 		break;

	jmp	$L8512
$L8516:

; 388  : 
; 389  : 	case IOCTL_PCIDP00_UNMAP:
; 390  : 		PCIDPUnMap(
; 391  : 			IN DeviceObject,
; 392  : 			IN OUT Irp,
; 393  : 			IN IoBuffer,
; 394  : 			IN InputBufferLength
; 395  : 		);

	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPUnMap@16

; 396  : 		break;

	jmp	$L8512
$L8515:

; 378  : 
; 379  : 	case IOCTL_PCIDP00_MAP_BASE_REGS:
; 380  : 		PCIDPMapBaseRegs(
; 381  : 			IN DeviceObject,
; 382  : 			IN OUT Irp,
; 383  : 			IN OUT IoBuffer,
; 384  : 			IN InputBufferLength,
; 385  : 			IN OutputBufferLength
; 386  : 		);

	push	DWORD PTR _OutputBufferLength$[ebp]
	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPMapBaseRegs@20

; 387  : 		break;

	jmp	SHORT $L8512
$L8521:

; 434  : 
; 435  : 	case IOCTL_PCIDP00_SET_PCI_CONFIG_REGS:
; 436  : 		PCIDPSetPCIRegs(
; 437  : 			IN DeviceObject,
; 438  : 			IN IrpStack->FileObject,
; 439  : 			IN OUT Irp,
; 440  : 			IN IoBuffer,
; 441  : 			IN InputBufferLength
; 442  : 		);

	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR [eax+24]
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPSetPCIRegs@20

; 443  : 		break;

	jmp	SHORT $L8512
$L8732:

; 364  : 	Irp->IoStatus.Information = 0;
; 365  : 
; 366  : 	// Get a pointer to the current location in the Irp. This is where
; 367  : 	// the function codes and parameters are located.
; 368  : 	IrpStack = IoGetCurrentIrpStackLocation(IN Irp);
; 369  : 
; 370  : 	// Get the pointer to the input/output buffer and it's length(s).
; 371  : 	IoBuffer           = Irp->AssociatedIrp.SystemBuffer;
; 372  : 	InputBufferLength  = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
; 373  : 	OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
; 374  : 
; 375  : 
; 376  : 	// Determine which I/O control code was specified.
; 377  : 	switch (IrpStack->Parameters.DeviceIoControl.IoControlCode){

	cmp	edx, -1023401832			; c3002098H
	je	SHORT $L8522
	cmp	edx, -1023401828			; c300209cH
	je	SHORT $L8523
	cmp	edx, -1023401824			; c30020a0H
	je	SHORT $L8512
	cmp	edx, -1023401820			; c30020a4H
	je	SHORT $L8525
	cmp	edx, -1023401816			; c30020a8H
	je	SHORT $L8518
$L8526:

; 474  : 
; 475  : 	default:
; 476  : 		Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;

	mov	DWORD PTR [esi+24], -1073741808		; c0000010H

; 477  : 		break;

	jmp	SHORT $L8512
$L8518:

; 406  : 
; 407  : 	case IOCTL_PCIDP00_CANCEL_MAP_DMA:
; 408  : 		PCIDPCancelMapDMA(
; 409  : 			IN DeviceObject,
; 410  : 			IN OUT Irp,
; 411  : 			IN IoBuffer,
; 412  : 			IN InputBufferLength
; 413  : 		);

	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPCancelMapDMA@16

; 414  : 		break;

	jmp	SHORT $L8512
$L8525:

; 463  : 
; 464  : 	case IOCTL_PCIDP00_HELLO:
; 465  : 		break;
; 466  : 
; 467  : 	case IOCTL_PCIDP00_GET_VERSION:
; 468  : 		PCIDPGetDriverVersion(
; 469  : 			IN OUT Irp,
; 470  : 			OUT IoBuffer,
; 471  : 			IN OutputBufferLength
; 472  : 		);

	push	DWORD PTR _OutputBufferLength$[ebp]
	push	ecx
	push	esi
	call	_PCIDPGetDriverVersion@12

; 473  : 		break;

	jmp	SHORT $L8512
$L8523:

; 453  : 		break;

⌨️ 快捷键说明

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