reactos操作系统实现(142)

前端之家收集整理的这篇文章主要介绍了reactos操作系统实现(142)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

VidInitialize函数主要进行VGA简单视频显示模式初始化。具体实现代码如下:

#001 BOOLEAN

#002 NTAPI

#003 VidInitialize(IN BOOLEAN SetMode)

#004 {

#005 ULONG Context = 0;

#006 PHYSICAL_ADDRESS TranslatedAddress;

#007 PHYSICAL_ADDRESS NullAddress = {{0,0}};

#008 ULONG AddressSpace = 1;

#009 BOOLEAN Result;

#010 ULONG_PTR Base;

#011

#012 /* Make sure that we have a bus translation function */

确保已经初始化地址总线转换回调函数

#013 if (!HalFindBusAddressTranslation) return FALSE;

#014

#015 /* Get the VGA Register address */

获取VGA的寄存器地址。

#016 Result = HalFindBusAddressTranslation(NullAddress,

#017 &AddressSpace,

#018 &TranslatedAddress,

#019 &Context,

#020 TRUE);

#021 if (!Result) return FALSE;

#022

检查是否需要映射I/O地址空间。

#023 /* See if this is I/O Space,which we need to map */

#024 TryAgain:

#025 if (!AddressSpace)

#026 {

#027 /* Map it */

#028 Base = (ULONG_PTR)MmMapIoSpace(TranslatedAddress,0x400,MmNonCached);

#029 }

#030 else

#031 {

#032 /* The base is the translated address,no need to map I/O space */

#033 Base = TranslatedAddress.LowPart;

#034 }

#035

#036 /* Set the VGA Register base and now check if we have a VGA device */

保存VGA的寄存器地址。

#037 VgaRegisterBase = Base;

调用函数VgaIsPresent来判断VGA显示卡是否安装。

#038 if (VgaIsPresent())

#039 {

转换VGA显示内存地址。

#040 /* Translate the VGA Memory Address */

#041 NullAddress.LowPart = 0xA0000;

#042 AddressSpace = 0;

#043 Result = HalFindBusAddressTranslation(NullAddress,

#044 &AddressSpace,

#045 &TranslatedAddress,

#046 &Context,

#047 FALSE);

#048 if (Result)

#049 {

#050 /* Success! See if this is I/O Space,which we need to map */

如果是I/O地址空间,就进行映射转换。

#051 if (!AddressSpace)

#052 {

#053 /* Map it */

#054 Base = (ULONG_PTR)MmMapIoSpace(TranslatedAddress,

#055 0x20000,

#056 MmNonCached);

#057 }

#058 else

#059 {

#060 /* The base is the translated address,no need to map I/O space */

#061 Base = TranslatedAddress.LowPart;

#062 }

#063

设置VGA的内存基地址。

#064 /* Set the VGA Memory Base */

#065 VgaBase = Base;

#066

是否需要显示图片模式。

#067 /* Now check if we have to set the mode */

#068 if (SetMode)

#069 {

复位显示

#070 /* Reset the display */

#071 HalResetDisplay();

#072 curr_x = 0;

#073 curr_y = 0;

#074

#075 /* Initialize it */

初始化VGA显示

#076 VgaInterpretCmdStream(AT_Initialization);

#077 return TRUE;

#078 }

#079 }

#080 }

#081 else

#082 {

#083 /* It's not,so unmap the I/O space if we mapped it */

#084 if (!AddressSpace) MmUnmapIoSpace((PVOID)VgaRegisterBase,0x400);

#085 }

#086

如果初始化失败,重新开始初始化。

#087 /* If we got here,then we Failed...let's try again */

#088 Result = HalFindBusAddressTranslation(NullAddress,

#089 &AddressSpace,

#090 &TranslatedAddress,

#091 &Context,

#092 TRUE);

#093 if (Result) goto TryAgain;

#094

运行到这里就表示初始化VGA显示卡失败。

#095 /* If we got here,then we Failed even past our re-try... */

#096 return FALSE;

#097}

原文链接:https://www.f2er.com/react/308382.html

猜你在找的React相关文章