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

📄 writeq.cpp

📁 串口驱动程序
💻 CPP
字号:
// writeq.cpp - implementation of class SerialWriteQueue
//=============================================================================
//
// Compuware Corporation
// NuMega Lab
// 9 Townsend West
// Nashua, NH 03060  USA
//
// Copyright (c) 1998 Compuware Corporation. All Rights Reserved.
// Unpublished - rights reserved under the Copyright laws of the
// United States.
//
//=============================================================================

#include <vdw.h>
#include "serdev.h"
#include "glbtrace.h"

// The serial driver uses three driver managed queues: one for reads,
// one for write and flush, and one for waits. This class implements
// the write queue. The StartIo routine passes the request to the
// StartWrite member function of SerialDevice (or its subclass).

/////////////////////////////////////////////////////////////////////////////
// StartIo
//
VOID SerialWriteQueue::StartIo(KIrp I)
{
	GTRACE((TLEVEL,"WriteQueue::StartIo\n"));

	CancelSpinLock::Acquire();
	if (I.WasCanceled())
	{
		GTRACE((TLEVEL, "WriteQueue: Irp was canceled\n"));
		CancelSpinLock::Release();
		return;
	}
	else
		CancelSpinLock::Release();

	if (I.MajorFunction() == IRP_MJ_FLUSH_BUFFERS)
	{
		I.Information() = 0;
		I.Status() = STATUS_SUCCESS;
	}
	else
		m_Device->StartWrite(
			(PUCHAR)I.BufferedWriteSource(),
			I.WriteSize()
			);
}

/////////////////////////////////////////////////////////////////////////////
// Cancel
//
VOID SerialWriteQueue::Cancel(KIrp I)
{
	GTRACE((TLEVEL,"WriteQueue: Cancel IRP\n"));

	if ( (PIRP)I == (PIRP)m_CurrentIrp)
		m_Device->CancelCurrentWrite();

	KDriverManagedQueue::Cancel(I);
}	

/////////////////////////////////////////////////////////////////////////////
// CompleteCurrent
//
VOID SerialWriteQueue::CompleteCurrent(NTSTATUS status, ULONG nLeft)
{
	ASSERT ( (PIRP)m_CurrentIrp != NULL);

	m_CurrentIrp.Information() = m_CurrentIrp.WriteSize() - nLeft;
	m_CurrentIrp.Status() = status;

	NextIrp(m_CurrentIrp, IO_SERIAL_INCREMENT);
}

⌨️ 快捷键说明

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