Accessing Linear Framebuffer Memory
Once you have initialized the graphics hardware into a mode that supports a hardware linear framebuffer, you need to create a pointer that your application can use to write to the linear framebuffer memory. The first thing you should realize is that the linear framebuffer location reported in the ModeInfoBlock for the mode you are using is a physical memory address, and cannot be used directly from protected mode applications. Before you can use the memory you must use the services your operating system provides to map the physical memory to a linear memory address, and then map this linear address into your applications memory space. Under DPMI mapping the linear memory is done with DPMI function 0x800, and equivalent functions exist under other operating systems.
The steps involved in mapping in a linear framebuffer region are as follows (32-bit protected mode only) :
- Map the physical memory address to a linear memory address (using DPMI function
0x800 for example). - Find the base address of the default DS selector for your operating environment.
- 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.