Jump to content

Intel - How pre-allocated memory and legacy VGA works?

Hello,


 


Reading a few datasheets for Intel processors and I keep reading this regarding the Main Memory Address Range (1 MB – TOLUD) -


 


"This address range extends from 1 MB to the top of Low Usable physical memory that is permitted to be accessible by the processor (as programmed in the TOLUD register). The processor will route all addresses within this range to the DRAM unless it falls into the optional TSEG, optional ISA Hole, or optional IGD stolen VGA memory."

 

It's that last bit that I don't understand regarding the pre-allocated memory for legacy VGA. Why would anything written to this address not be forwarded into DRAM?


 


It is important to note this is only regarding integrated graphics.


 


I have little understanding of how the process works regarding the CPU, Integrated GPU and DRAM for displaying graphics.


 


If your PC was running in legacy VGA/SVGA mode, how does this work regarding the above components. At some point something has to be written to the pre-allocated address as it's the frame buffer so why does it say any addresses in the stolen memory range aren't forwarded in DRAM?


 


If anyone could answer the above question and give a brief overview of the VGA graphics process it would be greatly appreciated


 


Thanks.


Link to comment
Share on other sites

Link to post
Share on other sites

What you're looking for is the Graphics Programming Black Book

 

https://github.com/jagregory/abrash-black-book/releases

 

VGA starts at chapter 23

 

Thanks, using the book and further research I understand it a little more but I'm still unsure on a few things

 

For example if a system is running in legacy VGA mode and the CPU rights to 0xA0000,it will be forwarded to the VGA adapter that will then write it to graphics memory. What address in graphics memory does it write to, does the VGA adapter have it's own address space?

 

Would this mean that the legacy VGA memory range  0xA0000 - 0xbffff is not accessible in DRAM as the VGA adapter is using the address range for MMIO?

 

Sorry for the badly worded questions and lack of understanding, I'm just trying to piece it all together,

 

Any help would be appreciated,

Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

Right, that RAM segment is mapped to the VGA adapter, so it can only be used for video.

 

The mapped segment is A000:0000 to A000:FFFF which is only 64KB, but VGA has 256KB of memory interally. It does this by planar mapping. Each address in the A000 segment maps to 4 VGA planes. It handles that internally depending what mode you are in. In the popular mode 13h it maps byte for byte to the first 64KB ( 320 * 200 ). This straight forward mapping is why it was so popular. In chapter 31 he shows how to hack mode 13h to allow access to all 256KB of VGA memory and a resolution of 320x400.

 

In other modes that use the 4 planes, the VGA has ALUs and latches that assist the CPU in writing to it. Essentially 1 CPU write will get fanned out to all 4 planes. In Chapter 47 he covers Mode X which is a hacked 256 color mode that abuses the planar mapping to speed up pixel writes.

 

Basically, VGA is a complex beast full of hacks and tricks. The Black Book covers a lot of them.

main(i){for(;i<101;i++)printf("Fizz\n\0Fizzz\bBuzz\n\0%d\n"+(!(i%5)^!!(i%3)*3)*6,i);}

Link to comment
Share on other sites

Link to post
Share on other sites

Thanks Avratz, I appreciate you taking the time to try and explain this to me.

 

TBH I'm not really wanting to know the in's and out's of VGA but rather the basic principle of how it works (and with integrated graphics), The Intel website says -

 

text.png

So this stolen memory is used as the frame buffer for the VGA adapter and any reads/writes by the VGA graphics controller will be going and coming from there?

 

Example system with 1MB stolen VGA memory-

 

table.png

So if the above system was running in VGA mode and something was written to the legacy VGA address range, what would the process be?

 

Currently my understanding is that the memory controller would forward it to the VGA adapter and then using the GTT it would translate this into a physical address at the top of DRAM?

 

Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

I'm not entirely sure of the route it takes, but considering how it's mapped I would think writes to those addresses would get sent straight to the VGA controller. Via the memory controller of course.

 

I don't think anything is actually ever stored in system memory. I could be wrong though.

main(i){for(;i<101;i++)printf("Fizz\n\0Fizzz\bBuzz\n\0%d\n"+(!(i%5)^!!(i%3)*3)*6,i);}

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×