flat model是映射了一个基地址为0的4GB地址空间,并且关闭了分页机制,所以线性地址等于物理地址。
但flat model并不是“标准”的保护模式,大致可以理解为32-bit的实模式。
所以为了程序能在多段的、分页的保护模式下也可以使用,最好还是先进行物理地址映射,这是标准做法。
你说的“设置什么模式位”,是在设置VESA mode时用的。
对于VESA 2.0+
int 10 ax=4f02 set video mode
bx=new video mode
bit
15 preserve display memory on mode change
14 (VBE v2.0+) use linear (flat) frame buffer
13 (VBE/AF 1.0P) VBE/AF initializes accelerator hardware
12 reserved for VBE/AF
11 (VBE v3.0) user user-specified CRTC refresh rate values
10-9 reserved for future expansion
8-0 video mode number (0xxh are non-VESA modes, 1xxh are VESA-defined)
要设置bit14为1才行。
我以前也发现过:某些卡在Banking模式时,linear framebuffer仍然可使用;但有些则不行,必须明确设置为linear framebuffer模式才行。
但是,在看vbe文档时还有些问题
The steps involved in mapping in a linear framebuffer region are as follows(32-bit protected mode only):
1, Map the physical memory address to a linear memory
2, Find the base address of the default DS selector for your operating enviroment.
3, Subtract the base address from the linear address computed in step 1 to give you a near pointer(relative to DS) that you can use from within your code.
其实第2,3步我并没有做,但是结果出来了,是否the base address of the default DS selector可能是零呢?或许是个bug。
呵,暂时不管了,先往后赶事情吧,帖子放两天有兴趣继续,过两天来给分。