亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
麻豆91精品91久久久的内涵| 在线成人小视频| 国产日韩在线不卡| 成人综合婷婷国产精品久久免费| 337p粉嫩大胆噜噜噜噜噜91av| 捆绑变态av一区二区三区| 欧美成人免费网站| 懂色中文一区二区在线播放| 国产精品福利电影一区二区三区四区| 成人爱爱电影网址| 亚洲一线二线三线久久久| 欧美一区二区三区在线电影| 国产伦精品一区二区三区免费迷| 中文成人av在线| 欧美日韩卡一卡二| 国内不卡的二区三区中文字幕 | 豆国产96在线|亚洲| 亚洲色图在线播放| 欧美一区二区三区免费在线看| 狠狠色综合日日| 一级特黄大欧美久久久| 欧美一区二区三区在线观看| 成人开心网精品视频| 日韩一区精品视频| 欧美韩日一区二区三区四区| 精品视频一区二区不卡| 国产精品乡下勾搭老头1| 亚洲狠狠丁香婷婷综合久久久| 欧美精品一二三| www.66久久| 激情综合色播五月| 一区二区三区在线观看视频| 337p日本欧洲亚洲大胆精品| 在线观看av一区| 国产麻豆午夜三级精品| 亚洲国产精品综合小说图片区| 久久精品一区四区| 制服丝袜av成人在线看| 成人国产精品免费| 毛片基地黄久久久久久天堂| 有码一区二区三区| 欧美极品xxx| 欧美精品一区二区在线观看| 欧美日韩一本到| 92国产精品观看| 国产一区不卡视频| 日韩国产精品大片| 亚洲综合视频在线| 国产精品超碰97尤物18| 欧美久久久一区| 91欧美一区二区| 国产成+人+日韩+欧美+亚洲| 日韩**一区毛片| 亚洲香蕉伊在人在线观| 亚洲欧美另类在线| 国产精品久久看| 久久日一线二线三线suv| 69精品人人人人| 色94色欧美sute亚洲线路一ni | 国产福利一区二区| 久色婷婷小香蕉久久| 亚洲国产va精品久久久不卡综合| 国产精品成人免费在线| 国产精品拍天天在线| 久久综合色综合88| 亚洲精品在线一区二区| 精品日韩一区二区| 欧美成人精品高清在线播放 | 国产露脸91国语对白| 久久成人羞羞网站| 激情小说欧美图片| 国产精品91xxx| 国产一区免费电影| 国产精品综合一区二区三区| 国产传媒日韩欧美成人| 国产盗摄一区二区三区| 国产999精品久久久久久绿帽| 成人午夜碰碰视频| 99国产精品视频免费观看| 91麻豆精品在线观看| 91一区在线观看| 色94色欧美sute亚洲13| 欧美探花视频资源| 欧美嫩在线观看| 日韩欧美在线网站| 久久网这里都是精品| 国产日韩欧美高清在线| 亚洲欧美在线另类| 亚洲第一综合色| 日韩avvvv在线播放| 国产在线一区观看| 91原创在线视频| 欧美另类videos死尸| 精品国产欧美一区二区| 国产日产精品1区| 亚洲精品国产精品乱码不99| 石原莉奈一区二区三区在线观看| 美国三级日本三级久久99| 国产91对白在线观看九色| 色婷婷av一区二区三区gif| 欧美高清视频在线高清观看mv色露露十八| 欧美丰满一区二区免费视频| 亚洲精品一区二区三区四区高清| 欧美极品少妇xxxxⅹ高跟鞋| 亚洲最新在线观看| 狠狠色丁香久久婷婷综| 97精品久久久久中文字幕| 欧美福利视频导航| 国产午夜亚洲精品午夜鲁丝片 | 国产精品久久毛片a| 亚洲国产欧美另类丝袜| 精品一区二区三区的国产在线播放| 国产成人鲁色资源国产91色综| 1024成人网| 亚洲视频一区在线| 六月丁香综合在线视频| 色综合久久久久久久久久久| 在线播放中文一区| 国产精品久久久久久久久果冻传媒| 亚洲福中文字幕伊人影院| 国产高清亚洲一区| 777色狠狠一区二区三区| 中文无字幕一区二区三区| 日韩电影免费在线看| 97久久久精品综合88久久| 日韩欧美国产电影| 亚洲精品国产a| 大白屁股一区二区视频| 日韩精品一区在线观看| 一区二区三区欧美激情| 国产综合久久久久久久久久久久| 欧美主播一区二区三区| 国产三级精品在线| 日韩avvvv在线播放| 一本一道综合狠狠老| 久久久久国色av免费看影院| 日韩和欧美的一区| 91行情网站电视在线观看高清版| 国产欧美一区二区精品婷婷| 蜜桃视频一区二区三区在线观看| 91麻豆福利精品推荐| 日本一区二区三级电影在线观看| 石原莉奈在线亚洲二区| 91高清视频在线| 国产精品日韩精品欧美在线| 韩国一区二区在线观看| 日韩欧美亚洲一区二区| 日日欢夜夜爽一区| 欧美日韩免费一区二区三区| 亚洲欧洲成人精品av97| 成人高清伦理免费影院在线观看| 日韩一区二区三区免费看| 日本aⅴ免费视频一区二区三区| 在线观看日韩一区| 亚洲男人的天堂av| 色综合久久中文字幕| 亚洲欧美日韩中文字幕一区二区三区 | 亚洲高清一区二区三区| 欧洲一区在线电影| 一区二区久久久| 在线中文字幕一区二区| 一区二区三区欧美| 91精品1区2区| 亚洲成av人在线观看| 欧美伊人久久久久久久久影院| 亚洲黄色在线视频| 欧美在线免费播放| 亚洲bt欧美bt精品777| 91超碰这里只有精品国产| 香蕉加勒比综合久久| 欧美精品乱码久久久久久| 蜜臀va亚洲va欧美va天堂| 精品少妇一区二区三区| 国内精品久久久久影院薰衣草| 久久久久国产精品人| 成人国产精品免费观看动漫| 亚洲精品大片www| 欧美日韩一区小说| 久久国产乱子精品免费女| 久久久久久久久久看片| jlzzjlzz亚洲日本少妇| 亚洲一二三级电影| 日韩一区二区电影在线| 国产精品自在在线| 国产精品伦理一区二区| 欧美性一二三区| 蜜桃在线一区二区三区| 国产精品国产三级国产aⅴ入口| 欧美一区午夜视频在线观看| 久久91精品久久久久久秒播| 久久久国产精华| 色94色欧美sute亚洲线路一久| 丝袜美腿一区二区三区| 久久久无码精品亚洲日韩按摩| 99久久国产免费看| 首页国产欧美久久| 国产日韩欧美在线一区| 欧美天堂一区二区三区| 国产揄拍国内精品对白| 伊人婷婷欧美激情|