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

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

?? iomgr.cpp

?? 小型的操作系統開發的原代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//***********************************************************************/
//    Author                    : Garry
//    Original Date             : May,02 2005
//    Module Name               : iomgr.cpp
//    Module Funciton           : 
//                                This module countains the implementation code of
//                                I/O Manager.
//    Last modified Author      :
//    Last modified Date        :
//    Last modified Content     :
//                                1.
//                                2.
//    Lines number              :
//***********************************************************************/

#ifndef __STDAFX_H__
#include "StdAfx.h"
#endif

//
//In front of this file,we implement three call back routines first,these three
//call back routines are called by device driver(s) to report some events to IOManager.
//These three routines are members of DRCB object,i.e,their base addresses are countained 
//in DRCB object.
//The first routine is WaitForCompletion,this routine is called when device driver(s) 
//submit a device operation transaction,such as READ or WRITE,and to wait the operation
//over,in this situation,device driver(s) calls this this routine,put the current kernel
//thread to BLOCKED queue.
//The second routine is OnCompletion,this routine is called when device request operation
//over,to indicate the IOManager this event,and wakeup the kernel thread which is blocked
//in WaitForCompletion routine.
//The third routine is OnCancel,which is called when an IO operation is canceled.
//

//
//The implementation of WaitForCompletion.
//This routine does the following:
// 1. Check the validation of parameter(s);
// 2. Block the current kernel thread.
//

static DWORD WaitForCompletion(__COMMON_OBJECT* lpThis)
{
	__DRCB*                    lpDrcb           = NULL;
	__EVENT*                   lpEvent          = NULL;

	if(NULL == lpThis) //Invalid parameter.
		return 0L;

	lpDrcb   = (__DRCB*)lpThis;
	lpEvent  = lpDrcb->lpSynObject;
	
	lpEvent->WaitForThisObject((__COMMON_OBJECT*)lpEvent);  //Block the current kernel thread.
	return 1L;
}

//
//The implementation of OnCompletion.
//This routine does the following:
// 1. Check the parameter's validation;
// 2. Wakeup the kernel thread who waiting for the current device operation.
//

static DWORD OnCompletion(__COMMON_OBJECT* lpThis)
{
	__EVENT*              lpEvent          = NULL;

	if(NULL == lpThis)
		return 0L;

	lpEvent = ((__DRCB*)lpThis)->lpSynObject;
	lpEvent->SetEvent((__COMMON_OBJECT*)lpEvent);  //Wakeup kernel thread.
	return 1L;
}

//
//The implementation of OnCancel.
//This routine does the following:
// 1. 
//

static DWORD OnCancel(__COMMON_OBJECT* lpThis)
{
	if(NULL == lpThis)    //Parameter check.
		return 0L;

	return 1L;
}

//
//The Initialize routine and UnInitialize routine of DRCB.
//

BOOL DrcbInitialize(__COMMON_OBJECT*  lpThis)
{
	__EVENT*          lpSynObject     = NULL;
	__DRCB*           lpDrcb          = NULL;
	DWORD             dwFlags         = 0L;

	if(NULL == lpThis)
		return FALSE;

	lpDrcb = (__DRCB*)lpThis;

	lpSynObject = (__EVENT*)ObjectManager.CreateObject(
		&ObjectManager,
		NULL,
		OBJECT_TYPE_EVENT);
	if(NULL == lpSynObject)    //Failed to create event object.
		return FALSE;

	if(!lpSynObject->Initialize((__COMMON_OBJECT*)lpSynObject)) //Failed to initialize.
	{
		ObjectManager.DestroyObject(&ObjectManager,
			(__COMMON_OBJECT*)lpSynObject);
		return FALSE;
	}

	lpDrcb->lpSynObject        = lpSynObject;

	//ENTER_CRITICAL_SECTION();
	__ENTER_CRITICAL_SECTION(NULL,dwFlags);
	lpDrcb->lpKernelThread     = KernelThreadManager.lpCurrentKernelThread;
	//LEAVE_CRITICAL_SECTION();
	__LEAVE_CRITICAL_SECTION(NULL,dwFlags);

	lpDrcb->dwDrcbFlag         = 0L;
	lpDrcb->dwStatus           = DRCB_STATUS_INITIALIZED;
	lpDrcb->dwRequestMode      = 0L;
	lpDrcb->dwCtrlCommand      = 0L;

	lpDrcb->dwOutputLen        = 0L;
	lpDrcb->lpOutputBuffer     = NULL;
	lpDrcb->dwInputLen         = 0L;
	lpDrcb->lpInputBuffer      = NULL;

	lpDrcb->lpNext             = NULL;
	lpDrcb->lpPrev             = NULL;

	lpDrcb->WaitForCompletion  = NULL;
	lpDrcb->OnCompletion       = NULL;
	lpDrcb->OnCancel           = NULL;

	lpDrcb->lpDrcbExtension    = NULL;
	return TRUE;
}

//
//The Uninitialize of DRCB.
//

VOID DrcbUninitialize(__COMMON_OBJECT*  lpThis)
{
	__DRCB*           lpDrcb            = NULL;

	if(NULL == lpThis)
		return;

	lpDrcb = (__DRCB*)lpThis;

	if(lpDrcb->lpSynObject != NULL)
		ObjectManager.DestroyObject(&ObjectManager,
		(__COMMON_OBJECT*)(lpDrcb->lpSynObject));

	return;
}

//
//The implementation of driver object's initialize routine.
//

BOOL DrvObjInitialize(__COMMON_OBJECT*  lpThis)
{
	__DRIVER_OBJECT*       lpDrvObj     = NULL;

	if(NULL == lpThis)
		return FALSE;

	lpDrvObj = (__DRIVER_OBJECT*)lpThis;

	lpDrvObj->lpPrev            = NULL;
	lpDrvObj->lpNext            = NULL;

	return TRUE;
}

//
//The implementation of driver object's Uninitialize routine.
//

VOID DrvObjUninitialize(__COMMON_OBJECT* lpThis)
{
	return;
}

//
//The implementation of device object's initialize routine.
//

BOOL DevObjInitialize(__COMMON_OBJECT* lpThis)
{
	__DEVICE_OBJECT*          lpDevObject = NULL;

	if(NULL == lpThis)
		return FALSE;

	lpDevObject = (__DEVICE_OBJECT*)lpThis;

	lpDevObject->lpPrev           = NULL;
	lpDevObject->lpNext           = NULL;

	lpDevObject->DevName[0]       = 0;
	lpDevObject->dwDevType        = DEVICE_TYPE_NORMAL;
	lpDevObject->lpDriverObject   = NULL;

	lpDevObject->dwStartPort      = 0L;
	lpDevObject->dwEndPort        = 0L;

	lpDevObject->dwDmaChannel     = 0L;
	lpDevObject->dwInterrupt      = 0L;

	lpDevObject->lpMemoryStartAddr = NULL;
	lpDevObject->dwMemLen          = NULL;
	lpDevObject->lpDevExtension    = NULL;

	return TRUE;
}

//
//Device object's Uninitialize routine.
//

VOID DevObjUninitialize(__COMMON_OBJECT* lpThis)
{
	return;
}


//
//The implementation of IOManager.
//

//
//The initialize routine of IOManager.
//This routine does the following:
// 1. 
//

static BOOL IOManagerInitialize(__COMMON_OBJECT* lpThis)
{
	BOOL                       bResult         = FALSE;
	__IO_MANAGER*              lpIoManager     = NULL;

	if(NULL == lpThis)    //Parameter check.
		return bResult;

	bResult = TRUE;

	return bResult;
}

//
//The CreateFile routine's implementation of IOManager.
//Several tips about this routine:
// 1. In current version implementation of Hello China,all devices are treated as files,
//    so,if users want to access device,he or she can open the target device by calling
//    this routine;
// 2. One file or device can be opend as READ ONLY,WRITE ONLY,or READ WRITE,the dwAccessMode
//    parameter of this routine indicates the opening mode;
// 3. In current version,one file or device can be opend more than one time,so,the
//    dwShareMode indicates the re-open mode of the currently opend file,for example,if one
//    kernel thread opens a file as READ WRITE mode,and also indicates the OS that this
//    file can only be re-opend as READ mode(by seting the appropriate value of the
//    dwShareMode parameter),so,if there is another kernel thread want to open the file
//    as READ WRITE mode or WRITE mode,it will fail,by contraries,if the second kernel
//    thread want to open the file only in READ ONLY mode,it will success.
// 4. The last parameter,lpReserved,is a reserved parameter that may be used in the future.
//Once success,this routine returns the base address of the device object that opend,
//otherwise,it will return a NULL value to indicate the failure,user can determine the
//failing reason by calling GetLastError routine.
//
//The routine does the following:
// 1. 
//

static __COMMON_OBJECT* CreateFile(__COMMON_OBJECT*  lpThis,
								   LPSTR             lpszFileName,
								   DWORD             dwAccessMode,
								   DWORD             dwShareMode,
								   LPVOID            lpReserved)
{
	__COMMON_OBJECT*               lpFileObj         = NULL;

	if((NULL == lpThis)
	   || (NULL == lpszFileName)) //Parameters check.
	   return lpFileObj;

	return lpFileObj;
}

//
//The ReadFile's implementation.
//The routine does the following:
// 1. Create a DRCB object,and initializes it;
// 2. Get the read block size of this device;
// 3. According to the block size,submit the read quest;
// 4. According to the result,set appropriate return value(s).
//

static BOOL  ReadFile(__COMMON_OBJECT*    lpThis,
					  __COMMON_OBJECT*    lpFileObj,
					  DWORD               dwByteSize,
					  LPVOID              lpBuffer,
					  DWORD*              lpdwReadSize)
{
	BOOL              bResult             = FALSE;
	__DRCB*           lpDrcb              = NULL;
	__IO_MANAGER*     lpIoManager         = NULL;
	__DEVICE_OBJECT*  lpDevObject         = NULL;
	__DRIVER_OBJECT*  lpDrvObject         = NULL;
	DWORD             dwReadBlockSize     = 0L;
	DWORD             dwTotalSize         = 0L;

	if((NULL == lpThis)
	   || (NULL == lpFileObj)
	   || (0 == dwByteSize)
	   || (NULL == lpBuffer))    //Parameters check.
	   goto __TERMINAL;

	lpIoManager = (__IO_MANAGER*)lpThis;
	lpDevObject = (__DEVICE_OBJECT*)lpFileObj;
	lpDrvObject = lpDevObject->lpDriverObject;

	lpDrcb = (__DRCB*)ObjectManager.CreateObject(&ObjectManager,
		NULL,
		OBJECT_TYPE_DRCB);
	if(NULL == lpDrcb)        //Failed to create DRCB object.
		goto __TERMINAL;

	if(!lpDrcb->Initialize((__COMMON_OBJECT*)lpDrcb))  //Failed to initialize.
		goto __TERMINAL;

	//
	//The following code gets the read block size by calling DeviceCtrl.
	//
	lpDrcb->dwRequestMode    = DRCB_REQUEST_MODE_IOCTRL;
	lpDrcb->dwCtrlCommand    = IOCONTROL_GET_READ_BLOCK_SIZE;
	lpDrcb->dwStatus         = DRCB_STATUS_INITIALIZED;
	lpDrcb->dwOutputLen      = sizeof(DWORD);
	lpDrcb->lpOutputBuffer   = (LPVOID)&dwReadBlockSize;    //When returned,the read block
	                                                        //size will be countained in
	                                                        //dwReadBlockSize variable.

	lpDrcb->WaitForCompletion = WaitForCompletion;          //Initializes the control routine.
	lpDrcb->OnCompletion      = OnCompletion;
	lpDrcb->OnCancel          = OnCancel;

	lpDrvObject->DeviceCtrl((__COMMON_OBJECT*)lpDrvObject,
		(__COMMON_OBJECT*)lpDevObject,
		lpDrcb);
	if(DRCB_STATUS_SUCCESS != lpDrcb->dwStatus)    //Can not get read block size successfully.
		goto __TERMINAL;

	//
	//The following code commits the read operations by calling DeviceRead routine.
	//
	dwTotalSize = dwByteSize;
	lpDrcb->dwRequestMode = DRCB_REQUEST_MODE_READ;
	lpDrcb->dwStatus      = DRCB_STATUS_INITIALIZED;
	while(TRUE)
	{
		lpDrcb->dwOutputLen    = 
			dwTotalSize > dwReadBlockSize ? dwReadBlockSize : dwTotalSize;
		lpDrcb->lpOutputBuffer = 
			lpBuffer;
		lpDrvObject->DeviceRead((__COMMON_OBJECT*)lpDrvObject,
			(__COMMON_OBJECT*)lpDevObject,
			lpDrcb);
		if(DRCB_STATUS_SUCCESS != lpDrcb->dwStatus)  //Can not read successfully.
			goto __TERMINAL;    //Exit the read process.
		if(lpDrcb->dwOutputLen < dwReadBlockSize)  //This suituation indicates the following
			                                       //case:
												   //1. At the end of the target file,but
												   //   the original request data size is
												   //   not satisfied;
												   //2. The read transaction is over.
												   //
		{
			*lpdwReadSize  = dwByteSize - dwTotalSize;
			*lpdwReadSize += lpDrcb->dwOutputLen;  //Set the actually read byte size.
			bResult = TRUE;
			goto __SUCCESSFUL;
		}

		dwTotalSize -= dwReadBlockSize;
		if(0 == dwTotalSize)
		{
			*lpdwReadSize = dwByteSize;
			bResult = TRUE;
			goto __SUCCESSFUL;
		}
		lpBuffer     = (LPVOID)((DWORD)lpBuffer + dwReadBlockSize);
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲视频你懂的| 亚洲欧洲日产国码二区| 久久久精品欧美丰满| 一区二区三区四区视频精品免费 | 日韩三级视频在线观看| 久久老女人爱爱| 视频一区中文字幕国产| 99久久久无码国产精品| www国产精品av| 午夜激情综合网| 色伊人久久综合中文字幕| 国产日韩精品一区二区浪潮av| 日韩高清不卡在线| 欧美网站大全在线观看| 日韩毛片在线免费观看| 国产成人精品aa毛片| 欧美成人乱码一区二区三区| 日韩成人av影视| 欧美日韩在线播放一区| 亚洲一二三专区| 91国产精品成人| 在线观看亚洲a| 2020国产精品| 无码av免费一区二区三区试看| 成人免费看的视频| 久久久久久久久免费| 蜜桃久久精品一区二区| 欧美一区二区三区影视| 亚洲成av人片www| 欧美日韩国产影片| 亚洲一区二区精品视频| 欧美色图天堂网| 亚洲一区二区三区三| 欧美日韩一区小说| 男女性色大片免费观看一区二区| 欧美丝袜第三区| 午夜影院在线观看欧美| 欧美二区乱c少妇| 日本不卡视频在线| 欧美大片在线观看一区| 激情五月激情综合网| 亚洲欧洲av在线| 亚洲美女免费在线| 97久久精品人人澡人人爽| 日本一区二区高清| av在线播放一区二区三区| 亚洲免费视频中文字幕| 欧美性高清videossexo| 日韩精品国产欧美| 精品国产91洋老外米糕| 成人性生交大片免费看中文| 中文字幕亚洲欧美在线不卡| 欧美在线不卡一区| 日日骚欧美日韩| 亚洲精品一线二线三线无人区| 国产精品资源在线观看| 亚洲视频一二区| 在线成人午夜影院| 国产精品白丝jk黑袜喷水| 最新国产精品久久精品| 91香蕉视频mp4| 久久福利资源站| 久久久午夜电影| 成人av中文字幕| 亚洲一区av在线| 久久久久久久久久久久久久久99 | 国产午夜精品久久久久久免费视| 精品在线你懂的| 91精品国产黑色紧身裤美女| 日本成人在线电影网| 国产午夜精品在线观看| 91极品视觉盛宴| 久久99精品国产麻豆婷婷| 亚洲激情在线激情| 欧美日韩免费观看一区二区三区| 国产精品亚洲第一区在线暖暖韩国| 日韩高清不卡一区二区| 午夜视频在线观看一区| 亚洲午夜av在线| 亚洲成人在线观看视频| 亚洲成人自拍偷拍| 午夜精品福利视频网站| 美女国产一区二区三区| 麻豆91在线播放免费| 久久99精品国产.久久久久| 国产美女一区二区三区| 成人久久视频在线观看| 91网站视频在线观看| 99精品久久只有精品| 色婷婷狠狠综合| 欧美人伦禁忌dvd放荡欲情| 777欧美精品| 精品国产百合女同互慰| 国产精品毛片大码女人| 亚洲精品一区二区三区香蕉| 国产色综合一区| 日韩欧美高清在线| 欧美成人a视频| 国产日产欧美精品一区二区三区| 国产欧美精品日韩区二区麻豆天美| 日本一区二区动态图| 亚洲精品午夜久久久| 欧美aaaaa成人免费观看视频| 国产一区高清在线| 91小视频在线| 欧美一卡二卡在线观看| 日本一区二区三区四区在线视频| 一区二区在线观看视频| 日日噜噜夜夜狠狠视频欧美人| 国产综合久久久久久久久久久久| 不卡高清视频专区| 91精品国产全国免费观看| 久久久久久免费| 一区二区三区成人| 极品少妇xxxx偷拍精品少妇| 91色|porny| 精品久久人人做人人爽| 亚洲欧美偷拍三级| 美女网站色91| 91蝌蚪porny九色| 国内久久婷婷综合| 韩国成人在线视频| 一本色道久久综合亚洲精品按摩| 337p亚洲精品色噜噜狠狠| 日本一区二区三区免费乱视频| 午夜精品久久久久| 99久久99久久久精品齐齐| 日韩午夜三级在线| 亚洲男帅同性gay1069| 国产一区二区三区久久久| 欧美午夜精品免费| 国产欧美精品国产国产专区| 婷婷综合久久一区二区三区| www.成人在线| 久久综合色鬼综合色| 亚洲午夜影视影院在线观看| www.欧美亚洲| 国产丝袜在线精品| 免费成人av资源网| 欧美性猛片aaaaaaa做受| 国产精品国产自产拍高清av | 日韩欧美不卡在线观看视频| 亚洲欧美另类在线| 亚洲乱码中文字幕| 日韩欧美国产综合| 亚洲精品免费在线| 国产一区二区久久| 欧美男男青年gay1069videost| 国产精品女人毛片| 国产毛片精品视频| 日韩一区二区免费视频| 亚洲不卡一区二区三区| 欧美三级电影精品| 亚洲欧美精品午睡沙发| 波多野结衣中文字幕一区| 久久网这里都是精品| 久久99热狠狠色一区二区| 91精品国产综合久久精品图片| 亚洲一区二区综合| 欧洲亚洲国产日韩| 亚洲乱码国产乱码精品精可以看| 波多野结衣一区二区三区| 久久久久9999亚洲精品| 国产精品亚洲第一| 国产亚洲欧美在线| 国产成人在线视频网站| 国产欧美一区视频| 国产成人综合视频| 国产精品久久久久aaaa樱花| av亚洲精华国产精华精| 亚洲日本护士毛茸茸| 在线精品视频免费观看| 亚洲成人免费影院| 成人精品视频一区二区三区| 国产成人小视频| 国产亚洲精品久| 成人一道本在线| 中文字幕字幕中文在线中不卡视频| 成人a区在线观看| 亚洲欧美在线视频观看| 91偷拍与自偷拍精品| 亚洲日本在线a| 欧美日韩高清一区二区三区| 蜜臀av性久久久久蜜臀aⅴ| 亚洲精品一区二区三区香蕉 | 亚州成人在线电影| 日韩午夜在线影院| 国产综合成人久久大片91| 国产精品国产馆在线真实露脸 | 欧美v日韩v国产v| 国内精品国产成人国产三级粉色 | 亚洲色图都市小说| 欧美性三三影院| 美国三级日本三级久久99| 欧美经典一区二区三区| 在线欧美日韩精品| 久久国产婷婷国产香蕉| 中文子幕无线码一区tr| 国内精品伊人久久久久av一坑| 99久久er热在这里只有精品15|