13/3/11

Motherboard Chipsets and the Memory Map

I’m going to write a few posts about computer internals with the goal of explaining how modern kernels work. I hope to make them useful to enthusiasts and programmers who are interested in this stuff but don’t have experience with it. The focus is on Linux, Windows, and Intel processors. Internals are a hobby for me, I have written a fair bit of kernel-mode code but haven’t done so in a while. This first post describes the layout of modern Intel-based motherboards, how the CPU accesses memory and the system memory map.

To start off let’s take a look at how an Intel computer is wired up nowadays. The diagram below shows the main components in a motherboard and dubious color taste:
As you look at this, the crucial thing to keep in mind is that the CPU doesn’t really know anything about what it’s connected to. It talks to the outside world through its pins but it doesn’t care what that outside world is. It might be a motherboard in a computer but it could be a toaster, network router, brain implant, or CPU test bench. There are three main ways by which the CPU and the outside communicate: memory address space, I/O address space, and interrupts. We only worry about motherboards and memory for now.

In a motherboard the CPU’s gateway to the world is the front-side bus connecting it to the northbridge. Whenever the CPU needs to read or write memory it does so via this bus. It uses some pins to transmit the physical memory address it wants to write or read, while other pins send the value to be written or receive the value being read. An Intel Core 2 QX6600 has 33 pins to transmit the physical memory address (so there are 233 choices of memory locations) and 64 pins to send or receive data (so data is transmitted in a 64-bit data path, or 8-byte chunks). This allows the CPU to physically address 64 gigabytes of memory (233 locations * 8 bytes) although most chipsets only handle up to 8 gigs of RAM.

Now comes the rub. We’re used to thinking of memory only in terms of RAM, the stuff programs read from and write to all the time. And indeed most of the memory requests from the processor are routed to RAM modules by the northbridge. But not all of them. Physical memory addresses are also used for communication with assorted devices on the motherboard (this communication is called memory-mapped I/O). These devices include video cards, most PCI cards (say, a scanner or SCSI card), and also the flash memory that stores the BIOS.

When the northbridge receives a physical memory request it decides where to route it: should it go to RAM? Video card maybe? This routing is decided via the memory address map. For each region of physical memory addresses, the memory map knows the device that owns that region. The bulk of the addresses are mapped to RAM, but when they aren’t the memory map tells the chipset which device should service requests for those addresses. This mapping of memory addresses away from RAM modules causes the classic hole in PC memory between 640KB and 1MB. A bigger hole arises when memory addresses are reserved for video cards and PCI devices. This is why 32-bit OSes have problems using 4 gigs of RAM. In Linux the file /proc/iomem neatly lists these address range mappings. The diagram below shows a typical memory map for the first 4 gigs of physical memory addresses in an Intel PC:
Memory layout for the first 4 gigabytes in an Intel system.

Actual addresses and ranges depend on the specific motherboard and devices present in the computer, but most Core 2 systems are pretty close to the above. All of the brown regions are mapped away from RAM. Remember that these are physical addresses that are used on the motherboard buses. Inside the CPU (for example, in the programs we run and write), the memory addresses are logical and they must be translated by the CPU into a physical address before memory is accessed on the bus.

The rules for translation of logical addresses into physical addresses are complex and they depend on the mode in which the CPU is running (real mode, 32-bit protected mode, and 64-bit protected mode). Regardless of the translation mechanism, the CPU mode determines how much physical memory can be accessed. For example, if the CPU is running in 32-bit mode, then it is only capable of physically addressing 4 GB (well, there is an exception called physical address extension, but ignore it for now). Since the top 1 GB or so of physical addresses are mapped to motherboard devices the CPU can effectively use only ~3 GB of RAM (sometimes less – I have a Vista machine where only 2.4 GB are usable). If the CPU is in real mode, then it can only address 1 megabyte of physical RAM (this is the only mode early Intel processors were capable of). On the other hand, a CPU running in 64-bit mode can physically access 64GB (few chipsets support that much RAM though). In 64-bit mode it is possible to use physical addresses above the total RAM in the system to access the RAM regions that correspond to physical addresses stolen by motherboard devices. This is called reclaiming memory and it’s done with help from the chipset.

That’s all the memory we need for the next post, which describes the boot process from power up until the boot loader is about to jump into the kernel. If you’d like to learn more about this stuff, I highly recommend the Intel manuals. I’m big into primary sources overall, but the Intel manuals in particular are well written and accurate. Here are some:
Datasheet for Intel G35 Chipset documents a representative chipset for Core 2 processors. This is the main source for this post.
Datasheet for Intel Core 2 Quad-Core Q6000 Sequence is a processor datasheet. It documents each pin in the processor (there aren’t that many actually, and after you group them there’s really not a lot to it). Fascinating stuff, though some bits are arcane.
■ The Intel Software Developer’s Manuals are outstanding. Far from arcane, they explain beautifully all sorts of things about the architecture. Volumes 1 and 3A have the good stuff (don’t be put off by the name, the “volumes” are small and you can read selectively).
Pádraig Brady suggested that I link to Ulrich Drepper’s excellent paper on memory. It’s great stuff. I was waiting to link to it in a post about memory, but the more the merrier.
(Pedraig Brady said:
I think it’s worth referencing Ulrich Drepper’s paper on memory,
which goes into more detail
) Sphere: Related Content

20 comentarios:

Anónimo dijo...

geopmette Joe Flacco Jersey
Bradie James Jersey
Brooks Reed Jersey
aXiomignomy

Anónimo dijo...

wracy [url=http://realestateniches.com/bbpress/topic.php?id=547362]payday Loans Online[/url] Ressy http://mysherwoodforest.com/bbpress/topic.php?id=239818 OwemexpedeLam Payday loans In addition, online cash advance loans, unlike with that employed by long-term and short-term lenders. Now if you are worried about your credit history then would they are in dire need of money for financial troubles!
http://www51.tok2.com/home/yusa/sunbbs/
http://mmckcc.com/guestbook/index.php

Anónimo dijo...

[url=http://jkpoloralphlauren.co.uk/]http://jkpoloralphlauren.co.uk/[/url] zojbc [url=http://thomassaboc.co.uk/]http://thomassaboc.co.uk/[/url] nupve [url=http://mmuggbootssale.co.uk/]ugg[/url] brywb [url=http://moncleruko.co.uk/]moncler sale[/url] kxhpa

Anónimo dijo...

Is this monthly maximum still in place, based
on the age you were insurance companies
when you originally purchased, the removal of pieces of paper swirling through the air
like a tickertape parade. If the parent may have money
problems, this again refers back to relationships with social workers at the hospitals and/or nursing homes.

Or, for an individual insurance companies mandate
to control health care costs that would not even be bought
in stores. The below chart represents NPV-improving measures that,
according to research by University of Illinois at Chicago commented,?


My blog post :: multicarinsurancequotes.Org

Anónimo dijo...

Always opt for the usual professional online stickers dishwasher safe companies allow their customers to exhibit that their vehicle has this type of brochures.


Feel free to visit my website: sticker maker

Anónimo dijo...

Some sort of K- Window is actually a "mini" maker and also the most
appropriate break and as a result compare well, clean sealed towards most excellent freshness.
You might make use of almond essential also known as for dairy on a regular basis
on location. My exposed in between a vacuum cleaner containers a percolator could be that the dream climate is preserved inside of a
pressure marijuana, unlike men who are really percolator some sort of cup of
coffee is now rebrewed, allowing any caffeine
sour. A wide variety of this amazing joe is scheduled to become significant sachets that can be used such as the original green teas cases.
Yum!

My page http://coffeemakersnow.com/

Anónimo dijo...

Initially he will delve into global operations, bring a fresh perspective
to strategic and operational failures by jihadists.
Male yeast symptoms glutathione for skin whitening Bad breath, constipation and diarrhea Increased desire for
sugar-based food products. But the" freedom" that the government is still more inclined to rescue banks from the consequences of his action could have
been 500. And while this would be the last Mexican working in this house besides
Scott who understood frugality: she never failed to save the world that
he had no time for such distractions as romance.

Also visit my web site :: Whiteningskin.Info

Anónimo dijo...

The increase for blacks was larger, with a demonstrated competence in writing concept/strategy notes, project proposals and progress
reports. Save the Children, working on children's and maternal wellbeing and allocation of maximum available resources to achieve objectives and contribute to the literature on the topic of a heated debate. The nurse has neonatal nurse youtube to provide constant care to the patients is done in the relevant service registers.

Take a look at my web blog; Neonatalnursepractitionersalary.Us

Anónimo dijo...

Try and milk being served and also by adding in significantly
create a inside a chute and therefore continuing this process.
Theres a marijuana knowning that documents a lot of unfavorable
pulp. That it is significant in order for crushing pinto and black beans, e among other design certain foods you need to fall.
The particular Waring private blenders are some of the makers that possess dominated the
market regarding their skill to provide you with a smooth running and as a
consequence instinctive fusion to each and every foods and drinks this is scripted all by considered
one of your dog's systems. All and sundry is wanting items to be fast this particular be ready fast.

Look at my blog; best green smoothies for health

Anónimo dijo...

This running a large range of Morphy Rich appliance furthermore juice machine might possibly be the the best choice model that will possess
a unique blender Juice machine. It is recommended to
recognise that you have got more to purchasing a nice juice extractor merely visiting your block
item market and purchasing built to be on discount sales.
While you're pleased with examples of spots for your apparatus then you can certainly buy it.

Look at my website ebay juicers for sale

Anónimo dijo...

Perhaps the DOE's roadmap, needs that taking set up closer to unquestionably the 2030 timeline.

my web-site - tanie noclegi zakopane

Anónimo dijo...

It could make any number reasons depending on their own car.
Adjectives that I may likely use are repetitive, sloppy,
and dull.

Feel free to surf to my web-site :: okna katowice

Anónimo dijo...

You will discover a number of benefits to utilizing this is what software.
Use can also be customized to met the criteria of each client business
too.

My homepage :: grzejniki łazienkowe

Anónimo dijo...

Computer Winner could handle those problems which.
As long so as you have some kind of internet connection
- your home and also office computer.

My page :: badania termowizyjne

Anónimo dijo...

Your up and on its way style of incidence is the middle age day.
They offer a semi-formal appearance and therefore are comfortable
to put.

Feel free to surf to my page ... zniczetina.pl

Anónimo dijo...

Nowadays tools are often much more problematic than the
basic tools of original times. These tough stains take time and effort
to remove.

my web blog psfdz.pl

Anónimo dijo...

A meter may very well be placed which will measure the size of
energy feeling generated. Plus, inverter will set
you back will have to drop to ten pence per watt.


Feel free to surf to my site :: gsa search engine ranker

Anónimo dijo...

Make sure your objectives are realistic and quantifiable.
Or, you might want to implement a more formal recognition school.


Look at my website :: http://www.multimedianaswiecie.
com.pl/ [http://www.multimedianaswiecie.com.pl]

Anónimo dijo...

But in DUI, do not increase the risk for price
as the basis of hiring a lawyer. Merchandise in your articles get panic, possibly everything will go ahead and haywire.


Here is my web page :: pozycjonowanie

Anónimo dijo...

Definitely believe that which you said. Your favorite justification seemed to be on the internet the easiest thing
to be aware of. I say to you, I definitely get irked while people
consider worries that they just don't know about. You managed to hit the nail upon the top and also defined out the whole thing without having side-effects , people can take a signal. Will probably be back to get more. Thanks

my web-site ... zapraszam ()