如果文本模式视频缓冲区不在 0xB8000,那么它在哪里?
大约 15 年前,我曾经通过编写直接修改显示器上文本的糟糕代码来自娱自乐并惹恼我的计算机老师。 通过访问配备 VGA 的 PC 兼容机上 0xB8000 处的视频内存,可以轻松完成此操作。
快进到今天,我决定通过调试端口尝试我的老技巧,该端口使我能够读取物理内存。 令我满意的是,它在我尝试的第一个平台上仍然有效。 然后,令人沮丧的是,我发现它在许多其他系统上不起作用。 似乎它不支持的系统都有 UMA(共享内存)显卡。
因此,对于所有 BIOS 编写者、低级操作系统人员和视频驱动程序专家来说,有一个问题 - 如果我在具有共享图形内存的 PC 兼容系统上处于常规 80x25 彩色文本模式,处于实模式,并且内容0xb8000 - 0xB8FFF 都是 0xFF 而不是给我屏幕上的内容,屏幕缓冲区去了哪里?
About 15 years ago, I used to amuse myself and annoy my CS teacher by writing bad code that would directly modify the text on the monitor. This was/is easily done by accessing video memory at 0xB8000 on VGA-equipped PC-compatibles.
Fast forward to today, I decided to try out my old trick through a debug port that gives me access to read physical memory. To my gratification, it still worked on the first platform I tried it on. Then, dishearteningly, I discovered that it doesn't work on many other systems. It seems that the systems it doesn't work on all have UMA (shared-memory) graphics.
So, a question for all of you BIOS writers, low-level OS guys, and video driver gurus - if I'm in regular 80x25 color textmode on a PC-compatible system with shared graphics memory, in real mode, and the contents of 0xb8000 - 0xB8FFF are all 0xFF instead of giving me what's on the screen, where did the screen buffer go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
啊,如果是 BIOS 屏幕,那么一切就都完了。 事实上,它是带有集成显卡的主板上的 BIOS,这使得它更加有利于视频的陌生感。
很可能“经典”VGA 功能是为了所有目的而模拟的。 对于外部显卡,BIOS 将看不到这一点 - 它仍然会看到 VGA 显卡。 但是硬连线到显卡的 BIOS 不需要设置假 VGA 层和老式 20 位地址空间内存映射,只是为了在屏幕上粘贴一些文本。
相反,BIOS 可以直接与卡连接(通过某种专有模式),直到操作系统实际启动,此时它会自行进行内存映射。 这样做的一个主要优点是,对于共享主内存的显卡,如果 RAM 安装不正确,启动时不会出现空白屏幕(相反,显卡专有 BIOS 模式可以使用通常为其他目的保留的缓冲区,让您进入 BIOS 并看到已安装 0MB 的 RAM)
Ah, if it's a BIOS screen then all bets are off. The fact that it's a BIOS on a motherboard with integrated graphics leans things even more in favor of video strangeness.
In all likelyhood "classic" VGA functionality is for all intents emulated. With an external video card this would be invisible to the BIOS - it still sees a VGA video card. But a BIOS hardwired to the video card wouldn't need to setup the fake VGA layer and old school 20 bit address space memory mapping just to stick some text on the screen.
Instead the BIOS may interface directly with the card (via some proprietary mode) until the operating system is actually going to be started up, at which point it does memory mapping itself. This has a major advantage in that for a card that shares main memory, you don't get a blank screen on startup if your RAM is incorrectly installed (instead the video cards propritary BIOS mode could use a buffer normally reserved for some other purpose, allowing you to get into the BIOS and see 0MB of RAM installed)
CGA(彩色图形适配器)和MDA(单色显示适配器)卡使用不同的区域。 一种(颜色)位于0xB8000; 但单色从 0xB0000 开始。 请记住,您可以同时在计算机上激活两个显示屏。
请参阅 DOS 内存映射(尽管它在 CGA - 应该是 8000h 而不是 0800h)。
就 VGA(视频图形阵列)而言,其内存开始较低,在 640K 边界位于 0xA0000 并继续 64K - 但它可以超出,因为该卡最多可以有 256K。 一些用于 VGA 编程的示例代码位于此处。 但它并不那么简单,因为它有多种视频模式。 您可以尝试此处寻求帮助。
您确定您有 VGA,而不是 EGA、XGA 或 Super-VGA? 所有这些都有稍微不同的语义...但是,我仍然很确定其中任何一个都应该将文本放在 0xB0000 或 0xB8000 处。 当您键入
或
MODE CO80
时会发生什么- 这会影响显示吗? 这些会在 DOS 下从一种适配器文本模式切换到另一种。
The CGA (Color Graphics Adapter) and MDA (Monochrome Display Adapter) cards used different regions. One (color) is at 0xB8000; but monochrome starts at 0xB0000. Remember, you could have both displays active on the machine at once.
See DOS Memory Map (although it has a typo in the offset for CGA - should be 8000h not 0800h).
As far as VGA (Video Graphics Array) goes, its memory starts lower, at the 640K boundary at 0xA0000 and continues for 64K - but it can go beyond, as the card could have up to 256K. Some sample code for programming VGA is here. But it isn't quite so simple as it has multiple video modes. You might try here for some help.
Are you sure you have VGA, and not EGA or XGA or Super-VGA? All of those have slightly different semantics... But still, I'm pretty sure any of those should put text either at 0xB0000 or 0xB8000. What happens when you type either
or
MODE CO80
-- does that affect the display? Those would switch from one adapter text mode to the other, under DOS.
此时可能会启用虚拟内存。
例如,
我试图写入 iPXE 代码库中的视频缓冲区,但它没有反映在屏幕上。 经过调查,我意识到我需要调用该函数:
才能直接写入视频缓冲区。
It might be the case that virtual memory is enabled at that point.
For eg.,
I was trying to write to the video buffer in the iPXE codebase and it didn't reflect on the screen. After investigating, I realized that I needed to call the function:
to be able to write to the video buffer directly.