亚洲欧美第一页_禁久久精品乱码_粉嫩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 "..\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);
	}

__SUCCESSFUL:

	ObjectManager.DestroyObject(&ObjectManager,
		(__COMMON_OBJECT*)lpDrcb);    //Destroy the DRCB object.

__TERMINAL:
	if(!bResult)    //This routine failed.
	{
		if(lpDrcb != NULL)    //Destroy the DRCB object.
		{
			ObjectManager.DestroyObject(&ObjectManager,
				(__COMMON_OBJECT*)lpDrcb);
		}
	}
	return bResult;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
eeuss鲁片一区二区三区在线看| 国产成人精品亚洲日本在线桃色| 精品国产免费久久| 99视频热这里只有精品免费| 五月激情六月综合| 亚洲天堂a在线| www久久精品| 911国产精品| 在线视频国内自拍亚洲视频| 国产激情偷乱视频一区二区三区| 亚洲亚洲精品在线观看| 国产农村妇女精品| 精品三级av在线| 欧美日韩精品一区二区天天拍小说| 从欧美一区二区三区| 久久草av在线| 日韩av高清在线观看| 一二三区精品福利视频| 国产精品久久久久精k8| 亚洲精品一区二区三区精华液 | 久久99国产乱子伦精品免费| 亚洲美女免费在线| 中文字幕永久在线不卡| 久久九九影视网| 日韩精品一区二区在线| 91精品国产91久久久久久一区二区| 91日韩在线专区| 不卡的av在线| 成人一区二区三区在线观看| 国产毛片精品国产一区二区三区| 久久精品国产一区二区三| 日韩电影在线观看一区| 亚洲.国产.中文慕字在线| 悠悠色在线精品| 亚洲精品国产第一综合99久久| 中文字幕国产一区| 亚洲国产精品二十页| 国产精品色在线观看| 国产欧美一区二区三区鸳鸯浴 | 欧美色图一区二区三区| 色综合天天综合给合国产| 9l国产精品久久久久麻豆| 国产电影一区在线| 成人av小说网| 色综合久久久久久久久久久| 一本久久a久久精品亚洲| 日本韩国欧美在线| 欧美特级限制片免费在线观看| 欧美系列亚洲系列| 欧美日韩国产高清一区二区| 欧美一区国产二区| 日韩色在线观看| www久久精品| 国产精品久久久久7777按摩| 亚洲天堂精品视频| 亚洲成av人片在www色猫咪| 日本午夜精品一区二区三区电影| 久久精品72免费观看| 国产一区二区三区免费播放| 国产成人啪免费观看软件| 波多野结衣中文字幕一区二区三区 | 中文字幕免费观看一区| 日韩久久一区二区| 午夜久久久影院| 国产在线视视频有精品| 国产suv一区二区三区88区| 91视视频在线观看入口直接观看www | 99视频精品全部免费在线| 色综合天天狠狠| 欧美一区二区三区系列电影| 亚洲精品在线观看视频| 中文字幕一区二区三区在线播放| 一区二区三区中文免费| 蜜臀久久久99精品久久久久久| 国产乱码精品1区2区3区| 成人免费视频视频| 欧美三级日韩在线| 久久久国产精品麻豆| 亚洲精品视频一区| 久久激情综合网| 91蜜桃传媒精品久久久一区二区| 538在线一区二区精品国产| 久久九九99视频| 亚洲.国产.中文慕字在线| 国产成人亚洲精品狼色在线| 在线视频中文字幕一区二区| 久久一区二区三区国产精品| 尤物av一区二区| 国产精品综合av一区二区国产馆| 欧美性大战久久久久久久蜜臀| 国产亚洲一区二区在线观看| 亚洲一区在线观看视频| 风流少妇一区二区| 91精品国产麻豆| 国产精品婷婷午夜在线观看| 石原莉奈在线亚洲二区| 99久久精品免费观看| 精品久久人人做人人爰| 亚洲国产综合色| hitomi一区二区三区精品| 日韩欧美一级二级| 亚洲一区二区三区不卡国产欧美| 国产精品亚洲成人| 日韩无一区二区| 亚洲综合自拍偷拍| 成人一区二区在线观看| 日韩欧美久久一区| 亚洲国产精品一区二区久久| 成人av小说网| 国产亚洲污的网站| 九九九精品视频| 欧美性极品少妇| 一区二区三区在线观看视频 | 欧美精品v国产精品v日韩精品| 国产精品女主播av| 精品亚洲成av人在线观看| 欧美精品久久天天躁| 亚洲一区二区在线视频| 97精品超碰一区二区三区| 国产午夜一区二区三区| 久久99国产精品尤物| 欧美大胆一级视频| 奇米四色…亚洲| 日韩一级片在线观看| 日韩精品久久久久久| 欧美日韩国产高清一区二区三区| 亚洲精品免费一二三区| 北岛玲一区二区三区四区| 国产欧美精品一区二区色综合 | 国产精品1024| 久久久久国产精品免费免费搜索| 蜜桃一区二区三区四区| 宅男噜噜噜66一区二区66| 亚洲成人免费视频| 91福利小视频| 香蕉加勒比综合久久| 欧美日韩国产美女| 日日噜噜夜夜狠狠视频欧美人| 欧洲精品中文字幕| 亚洲mv在线观看| 91精品国产免费| 精品中文字幕一区二区小辣椒| 欧美一区二区三区播放老司机| 天天亚洲美女在线视频| 欧美一级日韩免费不卡| 久久精品久久99精品久久| 久久综合色播五月| 国产99久久久久| 亚洲欧洲精品一区二区精品久久久| a亚洲天堂av| 亚洲精品伦理在线| 欧美日韩一区二区三区免费看| 天天综合网天天综合色| 欧美一区二区性放荡片| 国产自产v一区二区三区c| 中文久久乱码一区二区| 97aⅴ精品视频一二三区| 亚洲一区免费在线观看| 欧美一区二区三区人| 国产一区二区在线看| 1000部国产精品成人观看| 欧美日韩中文另类| 美女爽到高潮91| 欧美激情一区二区三区全黄 | 91成人网在线| 蜜桃一区二区三区在线| 亚洲国产高清在线观看视频| 一本久久综合亚洲鲁鲁五月天| 日韩福利电影在线| 国产精品每日更新在线播放网址 | 风间由美一区二区三区在线观看| 亚洲免费观看高清完整版在线观看| 欧美色中文字幕| 国产精品自拍在线| 亚洲最大色网站| 久久久三级国产网站| 在线视频一区二区三| 久久精品国产77777蜜臀| |精品福利一区二区三区| 91精品欧美福利在线观看| 懂色av噜噜一区二区三区av| 一区二区欧美在线观看| 日韩欧美在线网站| 成人av中文字幕| 日本欧美肥老太交大片| 中文字幕一区二区不卡| 91精品国产综合久久久久久久久久| 国产伦精一区二区三区| 亚洲国产婷婷综合在线精品| 国产喂奶挤奶一区二区三区| 欧美高清激情brazzers| av在线综合网| 久久综合综合久久综合| 亚洲影院理伦片| 国产精品区一区二区三| 精品国产电影一区二区| 欧美亚日韩国产aⅴ精品中极品| 国产精品白丝jk白祙喷水网站| 亚洲成在人线免费| 日韩毛片视频在线看|