/*++
Copyright (c) 1995 Microsoft Corporation
Module Name:
D12.c
Abstract:
USB device driver for Philips D12 USB test board
Environment:
kernel mode only
Notes:
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
PURPOSE.
Copyright (c) 1996 Microsoft Corporation. All Rights Reserved.
Revision History:
5-4-96 : created
--*/
#define DRIVER
#include "wdm.h"
#include "stdarg.h"
#include "stdio.h"
#include "usbdi.h"
#include "usbdlib.h"
#include "D12.h"
#include "d12irp.h"
#include "guid829.h"
//
// Global pointer to Driver Object
//
PDRIVER_OBJECT D12_DriverObject;
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
/*++
Routine Description:
Installable driver initialization entry point.
This entry point is called directly by the I/O system.
Arguments:
DriverObject - pointer to the driver object
RegistryPath - pointer to a unicode string representing the path
to driver-specific key in the registry
Return Value:
STATUS_SUCCESS if successful,
STATUS_UNSUCCESSFUL otherwise
--*/
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
D12_KdPrint (("D12TEST.SYS: entering (D12) DriverEntry\n"));
D12_DriverObject = DriverObject;
//
// Create dispatch points for device control, create, close.
//
DriverObject->MajorFunction[IRP_MJ_CREATE] = D12_Create;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = D12_Close;
DriverObject->DriverUnload = D12_Unload;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = D12_ProcessIOCTL;
DriverObject->MajorFunction[IRP_MJ_WRITE] = D12_Write;
DriverObject->MajorFunction[IRP_MJ_READ] = D12_Read;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] =
DriverObject->MajorFunction[IRP_MJ_PNP] = D12_Dispatch;
DriverObject->MajorFunction[IRP_MJ_POWER] = D12_ProcessPowerIrp;
DriverObject->DriverExtension->AddDevice = D12_PnPAddDevice;
D12_KdPrint (("D12TEST.SYS: exiting (D12) DriverEntry (%x)\n", ntStatus));
return ntStatus;
}
NTSTATUS
D12_PoRequestCompletion(
IN PDEVICE_OBJECT DeviceObject,
IN UCHAR MinorFunction,
IN POWER_STATE PowerState,
IN PVOID Context,
IN PIO_STATUS_BLOCK IoStatus
)
/*++
Routine Description:
This routine is called when the port driver completes an IRP.
Arguments:
DeviceObject - Pointer to the device object for the class device.
Context - Driver defined context.
Return Value:
The function value is the final status from the operation.
--*/
{
PIRP irp;
PDEVICE_EXTENSION deviceExtension;
PDEVICE_OBJECT deviceObject = Context;
NTSTATUS ntStatus;
deviceExtension = deviceObject->DeviceExtension;
irp = deviceExtension->PowerIrp;
ntStatus = IoStatus->Status;
D12_KdPrint(("'D12_PoRequestCompletion\n"));
IoCopyCurrentIrpStackLocationToNext(irp);
PoStartNextPowerIrp(irp);
PoCallDriver(deviceExtension->TopOfStackDeviceObject,
irp);
D12_DecrementIoCount(deviceObject);
return ntStatus;
}
NTSTATUS
D12_PowerIrp_Complete(
IN PDEVICE_OBJECT NullDeviceObject,
IN PIRP Irp,
IN PVOID Context
)
/*++
Routine Description:
This routine is called when the port driver completes an IRP.
Arguments:
DeviceObject - Pointer to the device object for the class device.
Irp - Irp completed.
Context - Driver defined context.
Return Value:
The function value is the final status from the operation.
--*/
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject;
PIO_STACK_LOCATION irpStack;
PDEVICE_EXTENSION deviceExtension;
D12_KdPrint(("D12TEST.SYS: enter D12_PowerIrp_Complete\n"));
deviceObject = (PDEVICE_OBJECT) Context;
deviceExtension = (PDEVICE_EXTENSION) deviceObject->DeviceExtension;
// BUGBUG
// kenray sez we should be calling IoMarkIrpPending
// from our completion routine.
//
if (Irp->PendingReturned) {
IoMarkIrpPending(Irp);
}
irpStack = IoGetCurrentIrpStackLocation (Irp);
ASSERT(irpStack->MajorFunction == IRP_MJ_POWER);
ASSERT(irpStack->MinorFunction == IRP_MN_SET_POWER);
ASSERT(irpStack->Parameters.Power.Type==DevicePowerState);
ASSERT(irpStack->Parameters.Power.State.DeviceState==PowerDeviceD0);
deviceExtension->CurrentDevicePowerState = PowerDeviceD0;
KdPrint(("D12TEST.SYS: enter D0 complete\n"));
Irp->IoStatus.Status = ntStatus;
D12_DecrementIoCount(deviceObject);
return ntStatus;
}
NTSTATUS
D12_SetDevicePowerState(
IN PDEVICE_OBJECT DeviceObject,
IN DEVICE_POWER_STATE DeviceState,
IN PBOOLEAN HookIt
)
/*++
Routine Description:
Arguments:
DeviceObject - Pointer to the device object for the class device.
Irp - Irp completed.
DeviceState - Device specific power state to set the device in to.
Return Value:
--*/
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_EXTENSION deviceExtension;
deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
switch (DeviceState) {
case PowerDeviceD3:
//
// device will be going OFF, save any state now.
//
D12_KdPrint(("D12TEST.SYS: PowerDeviceD3 (OFF)\n"));
KdPrint(("D12: PM power off\n"));
deviceExtension->CurrentDevicePowerState = DeviceState;
break;
case PowerDeviceD1:
case PowerDeviceD2:
//
// power states D1,D2 translate to USB suspend
D12_KdPrint(("D12TEST.SYS: PowerDeviceD1/D2 (SUSPEND)\n"));
KdPrint(("D12: device entered D%d\n", DeviceState-1));
deviceExtension->CurrentDevicePowerState = DeviceState;
break;
case PowerDeviceD0:
D12_KdPrint(("D12TEST.SYS: PowerDeviceD0 (ON)\n"));
//
// finish the rest in the completion routine
//
*HookIt = TRUE;
// pass on to PDO
break;
default:
D12_KdPrint(("D12TEST.SYS: Bogus DeviceState = %x\n", DeviceState));
}
return ntStatus;
}
NTSTATUS
D12_DeferIrpCompletion(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PVOID Context
)
/*++
Routine Description:
This routine is called when the port driver completes an IRP.
Arguments:
DeviceObject - Pointer to the device object for the class device.
Irp - Irp completed.
Context - Driver defined context.
Return Value:
The function value is the final status from the operation.
--*/
{
PKEVENT event = Context;
KeSetEvent(event,
1,
FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
NTSTATUS
D12_QueryCapabilities(
IN PDEVICE_OBJECT PdoDeviceObject,
IN PDEVICE_CAPABILITIES DeviceCapabilities
)
/*++
Routine Description:
This routine reads or write config space.
Arguments:
DeviceObject - Physical DeviceObject for this USB controller.
Return Value:
None.
--*/
{
PIO_STACK_LOCATION nextStack;
PIRP irp;
NTSTATUS ntStatus;
KEVENT event;
PAGED_CODE();
irp = IoAllocateIrp(PdoDeviceObject->StackSize, FALSE);
if (!irp) {
return STATUS_INSUFFICIENT_RESOURCES;
}
nextStack = IoGetNextIrpStackLocation(irp);
ASSERT(nextStack != NULL);
nextS
没有合适的资源?快使用搜索试试~ 我知道了~
USB-TEST-S3C44B0X.rar_USBtest-prayaya_usb s3c44b0x_usb te
共57个文件
h:19个
c:10个
o:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 25 浏览量
2022-09-23
06:58:42
上传
评论
收藏 353KB RAR 举报
温馨提示
简单测试S3C44B0X开发板USB设备的功能。PC通过USB口向芯片下发指令。调试之前要装USB驱动,调试过程要打开代理软件(已在包内),在ADS1.2下调试,
资源推荐
资源详情
资源评论
收起资源包目录
USB-TEST-S3C44B0X.rar (57个子文件)
www.pudn.com.txt 218B
USB测试
winxpsource
source
NTIOLOGC.H 12KB
buildfre.log 2KB
D12.c 55KB
USBDI.H 26KB
obj
_objects.mac 836B
MAKEFILE 670B
EXCPT.H 3KB
NTSTATUS.H 179KB
D12.h 5KB
Sources 361B
NTDEF.H 41KB
USBDLIB.H 15KB
BUGCODES.H 27KB
D12irp.c 2KB
Ioctl.c 20KB
D12.APS 3KB
WDM.H 270KB
D12.rc 3KB
RESOURCE.H 453B
Ioctl.h 3KB
objfre
i386
D12IRP.H 343B
GUID829.H 899B
Ocrw.c 25KB
usb
SRC
SysUtils.c 3KB
D12OP.C 1KB
vector.s 4KB
console.c 4KB
ctrl_set.c 7KB
D12Int.c 9KB
SysInit.s 9KB
usbdemo.c 3KB
INC
D12Def.H 2KB
44B0X.H 15KB
Option.s 551B
MemCfg.s 3KB
SysUtils.h 493B
uTypes.h 908B
usbdesc.h 313B
console.h 275B
usb_Data
Release
CWSettingsWindows.stg 3KB
Debug
DebugRel
usb.bin 18KB
ObjectCode
D12OP.o 10KB
SysUtils.o 21KB
D12Int.o 32KB
vector.o 3KB
usbdemo.o 23KB
console.o 25KB
SysInit.o 5KB
usb.axf 62KB
TargetDataWindows.tdt 74KB
usb.mcp 192KB
LEDDEMO.EXE 188KB
PDIUSBD12驱动程序
win2k_xp
D12test.inf 2KB
D12TEST.sys 16KB
win98
D12TEST.SYS 14KB
D12test.inf 2KB
共 57 条
- 1
资源评论
小贝德罗
- 粉丝: 71
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功