不使用中断的VGA编程(仅寄存器)
我想开发一个 VGA 图形驱动程序(适用于 Linux(Ubuntu)),支持 putpixel、drawline、fillrect 和 bitblt 等基本原语。我想在保护模式下进行。 我已经用谷歌搜索了一个星期,以下四个链接是我找到的最好的链接:
http: //www.brackeen....vga/basics.html http://www.osdever.n...VGA/vga/vga.htm http://bos.asmhacker...sing%20bios.htm
不幸的是,第一个一个使用 BIOS 调用,所以我无法使用它。第二个链接有很多有关 VGA 寄存器的信息,但没有示例说明如何使它们一起工作。第三个示例是在 13h 模式下切换的示例,但我已经尝试过,但没有任何反应。你们能给我一个提示吗?提前致谢!
——文森佐
I want to develop a VGA graphics driver (for Linux(Ubuntu)) with support for the basic primitives such as putpixel, drawline, fillrect and bitblt. I want to do it in protected mode.
I´ve been googling for a week and the following four links are the best I have found:
http://www.brackeen....vga/basics.html
http://www.osdever.n...VGA/vga/vga.htm
http://bos.asmhacker...sing%20bios.htm
Unfortunately, the first one uses a BIOS call so I cannot use it. The second link has lots of information on the VGA registers but no examples showing how to make them work together. The third example is a example to switch in 13h mode but i've tried it and nothing happened. Can you guys give me a hint? Thanks in advance!
--Vincenzo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的代码位于 http://bos.asmhackers.net/docs/vga_without_bios/snippet_5/ vga.php
如果您处于具有完整硬件访问权限的 32 位模式,则可以正常工作。不幸的是,我怀疑任何 Linux 变体都会让你直接访问 VGA 端口。我不确定你是如何开发这个驱动程序的,但如果你确保你可以完全访问 VGA 端口,它应该可以工作。在我的示例代码中,我仅在模式 0x03 和 0x13 之间切换,但在上面的文件夹中,您将能够找到大多数其他常见 VGA 模式的端口值,以及用于执行切换的 C 代码(如果您愿意)。
my code at http://bos.asmhackers.net/docs/vga_without_bios/snippet_5/vga.php
works fine if you are in 32bit mode with full hardware access. Unfortunately I doubt that any Linux variant will let you directly access the VGA ports. I'm not sure how you develop this driver, but if you made sure that you have full access to the VGA ports it should work. In my example code I only switch between mode 0x03 and 0x13, but in the folders above you'll be able to find port values for most other common VGA modes, as well as C code to do the switch if you prefer that.
Christoffer 代码包含文件可在 BOS 操作系统源代码中找到,例如 text.inc 和 font8x16.inc
http://bos .asmhackers.net/downloads.php
Christoffer code include files are found BOS operating system source code like text.inc and font8x16.inc
http://bos.asmhackers.net/downloads.php
这是许多年后的事,但我认为它仍然非常相关,如果有人正在挣扎,我希望他们能发现它有用。
首先,仅使用寄存器而不中断地配置 VGA 是完全可能的,尽管这可能很困难。关于寄存器以及如何配置它们的有用资源可以在此处找到,但除非您有大量如果您有时间学习如何正确完成所有这些工作,请转到下一部分。
如果您想真正了解如何做到这一点,我建议您仔细阅读前面提供的文档。然而,其中一些已经完成了!
Chris Giese 出色地演示了如何在 MS-DOS 系统上执行此操作,虽然您可能认为这对您没有帮助,但它确实有帮助。
Chris 的代码可以在此处找到。如果您需要其他有用的代码,请查看此处。
现在,虽然它仅适用于 MS-DOS,但实际上很容易转换到其他系统。该代码已包含在许多不同模式下配置寄存器所需的所有数据。这就是为您节省大量浏览文档时间的部分。
该代码使用 MS-DOS 函数
outportb
、inportb
向端口写入单个字节或从端口读取单个字节。因此,你必须重新定义这些函数来为你自己的系统读/写。重新定义的复杂性取决于您所运行的系统。此外,您还需要提供写入
0xA0000-0xBFFFF
之间的物理内存区域的方法,该区域对应于标准 VGA 内存区域。分配完毕后,您还需要重新定义函数pokeb
pokew
peekb
这将帮助您在上输出内容(文本或像素数据)屏幕。最后一点:代码已经定义为可以使用许多不同的模式,包括文本和显示模式。
This is coming many many years later but I think it's still very relevant and if somebody is struggling I hope they can find it useful.
First of all, it is completely possible to configure VGA only using registers without interrupts, as hard as it may be. A useful resource about registers and how to configure them can be found here, but unless you have a ton of time to spare to learn how to properly do all of it, move to the following section.
If you wish to really learn how to do it, I suggest going through with the documentation provided earlier. However, some of it is already done!
Chris Giese did a great job demonstrating exactly how to do this for MS-DOS system, and while you may think that doesn't help you, it really does.
Chris's code can be found here. If you want another useful codes check here as well.
Now, while it only works for MS-DOS it's actually easy to convert to other systems. The code already contains all data needed to configure the registers in many different modes. And that's the part that saves you a ton of time going through documentation.
The code uses functions
outportb
,inportb
, which are MS-DOS functions, to write/read single byte to/from a port. Therefore, you have to redefine these functions to read/write for your own system. Redefinition complexity depends on the system you operate on.In addition, you will also need to provide means to write to physical memory region between
0xA0000-0xBFFFF
which corresponds to standard VGA memory area. Once you have that allocated, you need to also redefine the functionspokeb
pokew
peekb
which will help you output things (text or pixel data) on the screen.One last note: the code is already defined to work with many different modes including both text and display modes.