亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ezloader.c

?? EZ_LOADER驅動程序源代碼(VC工程文件)
?? C
?? 第 1 頁 / 共 2 頁
字號:
   Ezusb_KdPrint (("enter Ezusb_StartDevice\n"));

   //
   // First download loader firmware.  The loader firmware implements a vendor
   // specific command that will allow us to anchor load to external ram
   //
   Ezusb_8051Reset(fdo,1);
   Ezusb_DownloadIntelHex(fdo,loader);
   Ezusb_8051Reset(fdo,0);

   //
   // Now download the device firmware
   //
   Ezusb_DownloadIntelHex(fdo,firmware);
   Ezusb_8051Reset(fdo,1);
   Ezusb_8051Reset(fdo,0);

   Ezusb_KdPrint (("exit Ezusb_StartDevice\n"));

   return STATUS_SUCCESS;
}


NTSTATUS
Ezusb_RemoveDevice(
    IN  PDEVICE_OBJECT fdo
    )
/*++

Routine Description:
    Removes a given instance of a Ezusb Device device on the USB.

Arguments:
    fdo - pointer to the device object for this instance of a Ezusb Device

Return Value:
    NT status code

--*/
{
   PDEVICE_EXTENSION pdx;
   NTSTATUS ntStatus = STATUS_SUCCESS;

   Ezusb_KdPrint (("enter Ezusb_RemoveDevice\n"));

   pdx = fdo->DeviceExtension;

   IoDetachDevice(pdx->StackDeviceObject);

   IoDeleteDevice (fdo);

   Ezusb_KdPrint (("exit Ezusb_RemoveDevice (%x)\n", ntStatus));

   return ntStatus;
}

NTSTATUS
Ezusb_PnPAddDevice(
    IN PDRIVER_OBJECT DriverObject,
    IN PDEVICE_OBJECT PhysicalDeviceObject
    )
/*++
Routine Description:
    This routine is called to create a new instance of the device

Arguments:
    DriverObject - pointer to the driver object for this instance of Ezusb
    PhysicalDeviceObject - pointer to a device object created by the bus

Return Value:
    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

--*/
{
   NTSTATUS                ntStatus = STATUS_SUCCESS;
   PDEVICE_OBJECT          fdo = NULL;
   PDEVICE_EXTENSION       pdx;

   Ezusb_KdPrint(("enter Ezusb_PnPAddDevice\n"));

   ntStatus = IoCreateDevice (DriverObject,
                              sizeof (DEVICE_EXTENSION),
                              NULL,
                              FILE_DEVICE_UNKNOWN,
                              0,
                              FALSE,
                              &fdo);

   if (NT_SUCCESS(ntStatus))
   {
      pdx = fdo->DeviceExtension;

      //
      // Non plug and play drivers usually create the device object in
      // driver entry, and the I/O manager autimatically clears this flag.
      // Since we are creating the device object ourselves in response to 
      // a PnP START_DEVICE IRP, we need to clear this flag ourselves.
      //
      fdo->Flags &= ~DO_DEVICE_INITIALIZING;

      //
      // This driver uses direct I/O for read/write requests
      //
      fdo->Flags |= DO_DIRECT_IO;
      //
      //
      // store away the Physical device Object
      //
      pdx->PhysicalDeviceObject=PhysicalDeviceObject;

      //
      // Attach to the StackDeviceObject.  This is the device object that what we 
      // use to send Irps and Urbs down the USB software stack
      //
      pdx->StackDeviceObject =
         IoAttachDeviceToDeviceStack(fdo, PhysicalDeviceObject);

      ASSERT (pdx->StackDeviceObject != NULL);

	   pdx->usage = 1;				// locked until RemoveDevice
	   KeInitializeEvent(&pdx->evRemove,
                        NotificationEvent,
                        FALSE);              // set when use count drops to zero
   }

   Ezusb_KdPrint(("exit Ezusb_PnPAddDevice (%x)\n", ntStatus));

   return ntStatus;
}

NTSTATUS
Ezusb_CallUSBD(
    IN PDEVICE_OBJECT fdo,
    IN PURB Urb
    )
/*++

Routine Description:
   Passes a Usb Request Block (URB) to the USB class driver (USBD)

Arguments:
   fdo - pointer to the device object for this instance of an Ezusb Device
   Urb          - pointer to Urb request block

Return Value:
   STATUS_SUCCESS if successful,
   STATUS_UNSUCCESSFUL otherwise

--*/
{
   NTSTATUS ntStatus, status = STATUS_SUCCESS;
   PDEVICE_EXTENSION pdx;
   PIRP irp;
   KEVENT event;
   IO_STATUS_BLOCK ioStatus;
   PIO_STACK_LOCATION nextStack;

   Ezusb_KdPrint (("enter Ezusb_CallUSBD\n"));

   pdx = fdo->DeviceExtension;

   // issue a synchronous request (see notes above)
   KeInitializeEvent(&event, NotificationEvent, FALSE);

   irp = IoBuildDeviceIoControlRequest(
             IOCTL_INTERNAL_USB_SUBMIT_URB,
             pdx->StackDeviceObject,
             NULL,
             0,
             NULL,
             0,
             TRUE, /* INTERNAL */
             &event,
             &ioStatus);

   // Prepare for calling the USB driver stack
   nextStack = IoGetNextIrpStackLocation(irp);
   ASSERT(nextStack != NULL);

   // Set up the URB ptr to pass to the USB driver stack
   nextStack->Parameters.Others.Argument1 = Urb;

   Ezusb_KdPrint (("Calling USB Driver Stack\n"));

   //
   // Call the USB class driver to perform the operation.  If the returned status
   // is PENDING, wait for the request to complete.
   //
   ntStatus = IoCallDriver(pdx->StackDeviceObject,
                         irp);

   Ezusb_KdPrint (("return from IoCallDriver USBD %x\n", ntStatus));

   if (ntStatus == STATUS_PENDING)
   {
      Ezusb_KdPrint (("Wait for single object\n"));

      status = KeWaitForSingleObject(
                    &event,
                    Suspended,
                    KernelMode,
                    FALSE,
                    NULL);

      Ezusb_KdPrint (("Wait for single object, returned %x\n", status));
   }
   else
   {
      ioStatus.Status = ntStatus;
   }

   Ezusb_KdPrint (("URB status = %x status = %x irp status %x\n",
     Urb->UrbHeader.Status, status, ioStatus.Status));

   ntStatus = ioStatus.Status;


   Ezusb_KdPrint(("exit Ezusb_CallUSBD (%x)\n", ntStatus));

   return ntStatus;
}

///////////////////////////////////////////////////////////////////////////////
// @func Lock a SIMPLE device object
// @parm Address of our device extension
// @rdesc TRUE if it was possible to lock the device, FALSE otherwise.
// @comm A FALSE return value indicates that we're in the process of deleting
// the device object, so all new requests should be failed

BOOLEAN LockDevice(
   IN PDEVICE_OBJECT fdo
   )
{
   PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

   // Increment use count on our device object
   LONG usage = InterlockedIncrement(&pdx->usage);

   // AddDevice initialized the use count to 1, so it ought to be bigger than
   // one now. HandleRemoveDevice sets the "removing" flag and decrements the
   // use count, possibly to zero. So if we find a use count of "1" now, we
   // should also find the "removing" flag set.

   ASSERT(usage > 1 || pdx->removing);

   // If device is about to be removed, restore the use count and return FALSE.
   // If we're in a race with HandleRemoveDevice (maybe running on another CPU),
   // the sequence we've followed is guaranteed to avoid a mistaken deletion of
   // the device object. If we test "removing" after HandleRemoveDevice sets it,
   // we'll restore the use count and return FALSE. In the meantime, if
   // HandleRemoveDevice decremented the count to 0 before we did our increment,
   // its thread will have set the remove event. Otherwise, we'll decrement to 0
   // and set the event. Either way, HandleRemoveDevice will wake up to finish
   // removing the device, and we'll return FALSE to our caller.
   // 
   // If, on the other hand, we test "removing" before HandleRemoveDevice sets it,
   // we'll have already incremented the use count past 1 and will return TRUE.
   // Our caller will eventually call UnlockDevice, which will decrement the use
   // count and might set the event HandleRemoveDevice is waiting on at that point.

   if (pdx->removing)
	{
	   if (InterlockedDecrement(&pdx->usage) == 0)
		   KeSetEvent(&pdx->evRemove, 0, FALSE);
	   return FALSE;
	}

   return TRUE;
}

///////////////////////////////////////////////////////////////////////////////
// @func Unlock a SIMPLE device object
// @parm Address of our device extension
// @comm If the use count drops to zero, set the evRemove event because we're
// about to remove this device object.

void UnlockDevice(
   PDEVICE_OBJECT fdo
   )
{
   PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;
   LONG usage = InterlockedDecrement(&pdx->usage);

   ASSERT(usage >= 0);

   if (usage == 0)
   {						// removing device
      ASSERT(pdx->removing);	// HandleRemoveDevice should already have set this
      KeSetEvent(&pdx->evRemove, 0, FALSE);
   }						// removing device
}

NTSTATUS Ezusb_8051Reset(
   PDEVICE_OBJECT fdo,
   UCHAR resetBit
   )
/*++

Routine Description:
   Uses the ANCHOR LOAD vendor specific command to either set or release the
   8051 reset bit in the EZ-USB chip.

Arguments:
   fdo - pointer to the device object for this instance of an Ezusb Device
   resetBit - 1 sets the 8051 reset bit (holds the 8051 in reset)
              0 clears the 8051 reset bit (8051 starts running)
              
Return Value:
   STATUS_SUCCESS if successful,
   STATUS_UNSUCCESSFUL otherwise

--*/
{
   NTSTATUS ntStatus;
   PURB urb = NULL;

   urb = ExAllocatePool(NonPagedPool, 
                       sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

   if (urb)
   {

      // toggle the EZ-USB reset bit (harmless on FX2)
      RtlZeroMemory(urb,sizeof(struct  _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

      urb->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
      urb->UrbHeader.Function = URB_FUNCTION_VENDOR_DEVICE;

      urb->UrbControlVendorClassRequest.TransferBufferLength = 1;
      urb->UrbControlVendorClassRequest.TransferBuffer = &resetBit;
      urb->UrbControlVendorClassRequest.TransferBufferMDL = NULL;
      urb->UrbControlVendorClassRequest.Request = ANCHOR_LOAD_INTERNAL;
      urb->UrbControlVendorClassRequest.Value = CPUCS_REG_EZUSB;
      urb->UrbControlVendorClassRequest.Index = 0;

      ntStatus = Ezusb_CallUSBD(fdo, urb);

      // toggle the FX2 reset bit (harmless on EZ-USB)
      RtlZeroMemory(urb,sizeof(struct  _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

      urb->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
      urb->UrbHeader.Function = URB_FUNCTION_VENDOR_DEVICE;

      urb->UrbControlVendorClassRequest.TransferBufferLength = 1;
      urb->UrbControlVendorClassRequest.TransferBuffer = &resetBit;
      urb->UrbControlVendorClassRequest.TransferBufferMDL = NULL;
      urb->UrbControlVendorClassRequest.Request = ANCHOR_LOAD_INTERNAL;
      urb->UrbControlVendorClassRequest.Value = CPUCS_REG_FX2;
      urb->UrbControlVendorClassRequest.Index = 0;

      ntStatus = Ezusb_CallUSBD(fdo, urb);
   }
   else
   {
      ntStatus = STATUS_NO_MEMORY;
   }

   if (urb)
      ExFreePool(urb);

   return ntStatus;
}


NTSTATUS Ezusb_DownloadIntelHex(
   PDEVICE_OBJECT fdo,
   PINTEL_HEX_RECORD hexRecord
   )
/*++

Routine Description:
   This function downloads Intel Hex Records to the EZ-USB device.  If any of the hex records
   are destined for external RAM, then the caller must have previously downloaded firmware
   to the device that knows how to download to external RAM (ie. firmware that implements
   the ANCHOR_LOAD_EXTERNAL vendor specific command).

Arguments:
   fdo - pointer to the device object for this instance of an Ezusb Device
   hexRecord - pointer to an array of INTEL_HEX_RECORD structures.  This array
               is terminated by an Intel Hex End record (Type = 1).

Return Value:
   STATUS_SUCCESS if successful,
   STATUS_UNSUCCESSFUL otherwise

--*/
{
   NTSTATUS ntStatus;
   PURB urb = NULL;
   PINTEL_HEX_RECORD ptr = hexRecord;

   urb = ExAllocatePool(NonPagedPool, 
                       sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

   if (urb)
   {
      //
      // The download must be performed in two passes.  The first pass loads all of the
      // external addresses, and the 2nd pass loads to all of the internal addresses.
      // why?  because downloading to the internal addresses will probably wipe out the firmware
      // running on the device that knows how to receive external ram downloads.
      //
      //
      // First download all the records that go in external ram
      //
      while (ptr->Type == 0)
      {
         if (!INTERNAL_RAM(ptr->Address))
         {
            RtlZeroMemory(urb,sizeof(struct  _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

            urb->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
            urb->UrbHeader.Function = URB_FUNCTION_VENDOR_DEVICE;
            urb->UrbControlVendorClassRequest.TransferBufferLength = ptr->Length;
            urb->UrbControlVendorClassRequest.TransferBuffer = ptr->Data;
            urb->UrbControlVendorClassRequest.Request = ANCHOR_LOAD_EXTERNAL;
            urb->UrbControlVendorClassRequest.Value = ptr->Address;
            urb->UrbControlVendorClassRequest.Index = 0;

            Ezusb_KdPrint (("Downloading %d bytes to 0x%x\n",ptr->Length,ptr->Address));

            ntStatus = Ezusb_CallUSBD(fdo, urb);

            if (!NT_SUCCESS(ntStatus))
               break;
         }
         ptr++;
      }

      //
      // Now download all of the records that are in internal RAM.  Before starting
      // the download, stop the 8051.
      //
      Ezusb_8051Reset(fdo,1);
      ptr = hexRecord;
      while (ptr->Type == 0)
      {
         if (INTERNAL_RAM(ptr->Address))
         {
            RtlZeroMemory(urb,sizeof(struct  _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));

            urb->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
            urb->UrbHeader.Function = URB_FUNCTION_VENDOR_DEVICE;
            urb->UrbControlVendorClassRequest.TransferBufferLength = ptr->Length;
            urb->UrbControlVendorClassRequest.TransferBuffer = ptr->Data;
            urb->UrbControlVendorClassRequest.Request = ANCHOR_LOAD_INTERNAL;
            urb->UrbControlVendorClassRequest.Value = ptr->Address;
            urb->UrbControlVendorClassRequest.Index = 0;

            Ezusb_KdPrint (("Downloading %d bytes to 0x%x\n",ptr->Length,ptr->Address));

            ntStatus = Ezusb_CallUSBD(fdo, urb);

            if (!NT_SUCCESS(ntStatus))
               break;
         }
         ptr++;
      }

   }
   else
   {
      ntStatus = STATUS_NO_MEMORY;
   }

   if (urb)
      ExFreePool(urb);

   return ntStatus;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费成人av资源网| 精品国产人成亚洲区| **欧美大码日韩| 成人网页在线观看| 国产精品欧美综合在线| 成人免费高清在线| 国产精品青草综合久久久久99| 成人中文字幕在线| 成人免费一区二区三区视频 | 午夜视频在线观看一区二区三区 | 91.com视频| 毛片av中文字幕一区二区| 精品久久一二三区| 国产福利精品导航| 亚洲欧美日韩一区| 欧美日韩久久一区| 久久国产夜色精品鲁鲁99| 久久久久久久精| 色婷婷综合五月| 亚洲va中文字幕| 26uuu亚洲婷婷狠狠天堂| 国产成人精品午夜视频免费 | 亚洲高清中文字幕| 精品伦理精品一区| a亚洲天堂av| 日韩影院在线观看| 国产欧美日韩激情| 欧美午夜一区二区三区免费大片| 日本不卡一二三区黄网| 欧美激情在线一区二区三区| 色国产综合视频| 麻豆免费看一区二区三区| 国产欧美日韩一区二区三区在线观看| 91在线观看免费视频| 青青草成人在线观看| 国产片一区二区三区| 欧美综合亚洲图片综合区| 老司机精品视频导航| 亚洲三级小视频| 日韩亚洲欧美一区| av一二三不卡影片| 麻豆国产精品视频| 亚洲美女电影在线| 2023国产精品自拍| 欧美色中文字幕| 国产69精品一区二区亚洲孕妇| 亚洲成人免费影院| 国产精品久99| 欧美成人福利视频| 欧美午夜在线一二页| jlzzjlzz国产精品久久| 激情综合一区二区三区| 夜夜夜精品看看| 欧美国产一区二区在线观看| 777欧美精品| 欧美亚洲一区二区在线观看| 丰满亚洲少妇av| 奇米精品一区二区三区在线观看| 国产精品成人一区二区艾草| 日韩精品一区国产麻豆| 欧美午夜精品久久久久久孕妇 | 亚洲另类春色国产| 国产欧美一区二区精品仙草咪| 91精品国产高清一区二区三区| 9i在线看片成人免费| 懂色av一区二区三区免费观看| 麻豆成人久久精品二区三区小说| 亚洲午夜久久久久久久久久久 | 欧美美女黄视频| 91麻豆福利精品推荐| 成人涩涩免费视频| 国产精品一区二区免费不卡 | 欧美精选一区二区| 久久66热偷产精品| 婷婷国产v国产偷v亚洲高清| 亚洲私人黄色宅男| 久久免费偷拍视频| 欧美日韩午夜精品| 97成人超碰视| 成人黄色电影在线 | 日本道免费精品一区二区三区| 国产精品资源网站| 日韩av网站在线观看| 亚洲一区二区三区四区在线观看 | 免费看欧美女人艹b| 亚洲免费观看高清完整版在线 | 欧美韩日一区二区三区四区| 日韩免费观看高清完整版| 在线欧美小视频| 99视频超级精品| 99久久伊人久久99| 成人丝袜18视频在线观看| 国产又黄又大久久| 久久www免费人成看片高清| 日日摸夜夜添夜夜添精品视频 | 亚洲电影在线播放| 有坂深雪av一区二区精品| 国产精品久久国产精麻豆99网站 | 韩国毛片一区二区三区| 蜜桃久久精品一区二区| 三级精品在线观看| 天天爽夜夜爽夜夜爽精品视频 | 久久嫩草精品久久久久| 亚洲精品在线观| 在线播放欧美女士性生活| 91精品国产综合久久久久久久久久 | 日本v片在线高清不卡在线观看| 亚洲国产成人av| 亚洲午夜一区二区三区| 亚洲一区二区四区蜜桃| 亚洲h精品动漫在线观看| 亚洲va欧美va国产va天堂影院| 亚洲精品大片www| 亚洲精品国产一区二区三区四区在线| 中文字幕成人在线观看| 国产精品传媒视频| 亚洲欧美乱综合| 最新中文字幕一区二区三区| 亚洲色图色小说| 亚洲欧美另类久久久精品| 日韩精品成人一区二区在线| 美国一区二区三区在线播放| 精品影视av免费| 国产成人高清视频| 91香蕉视频黄| 欧美日韩成人在线| 精品少妇一区二区三区日产乱码 | 日韩精品一区二区三区视频在线观看| 国产日韩欧美一区二区三区乱码 | 在线视频观看一区| 日韩午夜精品视频| 国产精品美女久久久久久久久| 最新国产成人在线观看| 一区二区三区美女视频| 欧美aaaaa成人免费观看视频| 国产美女娇喘av呻吟久久| 91在线视频播放地址| 一本久久a久久精品亚洲| 在线观看欧美精品| 精品嫩草影院久久| 综合久久久久综合| 日本不卡视频在线观看| 成人一二三区视频| 欧美日韩国产另类不卡| 久久久久久久久久久久久夜| 亚洲激情校园春色| 久久99国产乱子伦精品免费| 91麻豆国产在线观看| 欧美白人最猛性xxxxx69交| 最好看的中文字幕久久| 男女男精品视频网| av在线不卡网| 日韩美女视频在线| 久久久久久久久久久久电影| 有码一区二区三区| 国产馆精品极品| 制服丝袜国产精品| 亚洲三级电影全部在线观看高清| 久久精品国产99久久6| 日本韩国欧美三级| 国产亚洲午夜高清国产拍精品 | 亚洲一线二线三线视频| 岛国一区二区三区| 欧美一区二区黄色| 亚洲在线视频网站| jizz一区二区| 国产日韩成人精品| 全国精品久久少妇| 91精品国产乱| 午夜视频在线观看一区| 色综合久久久久综合| 久久伊人蜜桃av一区二区| 欧美a一区二区| 欧美日韩不卡一区二区| 亚洲欧洲成人自拍| a4yy欧美一区二区三区| 日本一区二区不卡视频| 国产精品香蕉一区二区三区| 欧美一级片在线| 视频一区视频二区中文字幕| 欧美日韩一级视频| 夜夜操天天操亚洲| 日本高清不卡视频| 亚洲免费看黄网站| 色婷婷av一区二区三区大白胸 | 国产日韩精品一区二区三区在线| 狠狠狠色丁香婷婷综合久久五月| 3d动漫精品啪啪| 性做久久久久久| 欧美肥妇free| 亚洲妇女屁股眼交7| 日韩欧美视频一区| 蜜臀a∨国产成人精品| 欧美成人性福生活免费看| 久久97超碰色| 精品福利一区二区三区| 久久精品国产99| 中文字幕欧美国产| eeuss影院一区二区三区| 亚洲同性gay激情无套|