How does a computer boot (technical response please :))

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
What happens once you press power? My understand of CPUs is at the 1st/2nd year comp-sci courses with little independant reading. I am assuming once the power is on, the program counter reads address block 0? This starts the bootstrap process... but what is that process? What is stored in the first memory block... heck it probably looks at the BIOS first...

ok... I am going to stop sounding like an idiot and wait for the smart people to post ;)
 

jhu

Lifer
Oct 10, 1999
11,918
9
81
what architecture? the general sequence for most architecture (i think) is post, execute rom, load instructions from boot device to memory, and execute it (die, die, die!!!)
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
Does anyone have more details on this? For example on a PC, isn't the BIOS in upper memory? So, does the PC start at 0, or somewhere else?

I assume that you are not after how a motherboard powers up, as there is a whole lot more to that.
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
Guess it's up to me to say something :)

In general, when coming out of the hardware reset sequence, a processor starts fetching code from a certain fixed location. Chipset and board design must make sure that the bootstrap ROM is found there.

Talking IA32, we have processors that start execution at (top of address space)-10h, with current 32-bit machines the needle goes onto the record at FFFF_FFF0h. The chipset south bridge maps the BIOS ROM to occupy that spot, so off we go. First thing that BIOS does (after JUMPing to the location in the BIOS ROM where the bootblock code is, typically in the uppermost 16 KBytes) is fire up the keyboard controller to lift the dreaded A20 gate, and then detect and initialize the DRAM array. After that, life is much easier - next step is checksumming and unpacking the main BIOS POST code into DRAM, to then pass control to it. POST then initializes PCI, AGP and ISA busses, scans for devices there, allocates resources, fires up the boot input and output devices (this is when we see the VGA card fire up), and scans for supported peripherals (mouse, IDE, USB). Finally other mass storage support ROMs are invoked (IDE RAID, SCSI, network boot), and out we go into the boot sequence - loading the master boot record from the 1st of the listed boot devices, and passing control to it. After that, it's up to the installed operating system.

Questions?

regards, Peter
 

highwire

Senior member
Nov 5, 2000
363
0
76
edit:Shoulda rechecked the thread. already answered. Peter has it right.


The X8086 is hard wired to begin by fetching instructions from a high address. That is where the BIOS ROM is located. I bet Andy Hui or others would be able to give a very detailed answer, but here is a sketch of the BIOS operation.

The CPU begins running the instruction code in the BIOS rom. Memory checks and other housekeeping functions are done here first, power on systems test (POST), etc.

Then the bios reads in a particular drive sector. There is specific hard coding in the BIOS to perform this read operation to a particular sector of either the floppy or drive C. ( lately some BIOSs are able to read a CD drive.)
The instructions from this sector are specific to the operating system.

This instruction code from the disk sector is then executed by the CPU. It is the first stage in loading an operating system, DOS, Windows, Linux,etc.
At this point on, the details will vary for the various OS's.

 

jhu

Lifer
Oct 10, 1999
11,918
9
81
it's all pretty much the same sequence on most computers: initialize the hardware, check for memory, build the device tree (non-x86?), load a file from the boot device (usually disk, sometimes ethernet) and run it
 

Moohooya

Senior member
Oct 10, 1999
677
0
0
There are various memory timings in the BIOS. How does the bios access the memory prior to having set the memory timings? Or is all memory access to the bios ROM, and none to the ram?

Also, what happens when the bios sets the memory timings? Are these just registers in the chipset? If so, then could someone write a divice driver to read/write these registers so they could be messed with?
 

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
Cool, thanks for the responses. It seems like everything is a premilinary checkup on the hardware then things get forwarded to the boot sector that the BIOS defines to be loaded first?

I never even though that different architectures would do it any differently :). I guess the BIOS is holding machine level instructions and that would be connected to the
ISA of the CPU that it is supposed to boot.

It would be interesting to see some of the assembly language that goes along with this.
 

panglq

Junior Member
Dec 16, 2001
17
0
66
A20 is the 20th bit of the address line which can be caculated to 1 Mega Bytes. So after enabling the A20 line, we can access memory above 1 Mega Bytes. I don't know if this is whole explanation.
 

jhu

Lifer
Oct 10, 1999
11,918
9
81
here's a good history of the a20 line

here's my question: why didn't intel implement 4gb addressing using segment:eek:ffset instead of limiting it to 1mb?
 

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
Wow great link! I totally forgot about that website... I could spend days there :)
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
The chipset takes care that the BIOS ROM appears in address space at the very location where the CPU starts
execution after reset. It must be that way in all architectures, CPUs are nothing without software.

How do you initialize RAM? Well simple (NOT) ... you write some code that can do without stack or storage,
and either probes memory sizes (old style, weird) or uses the chipset's SMbus engine to identify the RAM
array through the SPD data it brings in tiny little EEPROMs on the DIMMs (new style, from PC100 SDRAM on).

So now you know the size and timing of the DIMMs, mingle that with what your board can do, and with these
data fire up the chipset's RAM controller unit. If you got ECC RAM, you need to scrub it, and after that you
can start using RAM. Life is much easier from that point on. Next thing BIOS does is unpack the main POST
program from ROM into RAM, and start it.

BIOS doesn't do "initial hardware check", it does all the initializing, PnP mapping of PCI, ISA and onboard
stuff. Actually, there is little to no functional check in there.

Finally, BIOS doesn't load a file from disk. It has no knowledge about file systems. It loads the master boot
record and starts the program that resides in there - which has been put there by the operating system's
installation procedure. It is this program that then knows where to load the OS kernel from (it does call
BIOS HDD services to read the appropriate sectors from the HDD for that).

regards, Peter
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
It's all in a day's work for Bicycle Repair Man ... ummm ... I mean ... BIOS Engineer Man :)
 

PandaBear

Golden Member
Aug 23, 2000
1,375
1
81
as a sidenote to different architecture:

Some system doesn't have the backward compatibility problems of x86 and they put all the assumption and required stuff in the boot ROM, things like part of the OS or the harddrive access routine could be inserted there instead of off the 1st sector of the disk.

I think this is how Xbox is made, removing many unused old stuff and put in part of the Xbox OS in the ROM, so you cannot directly run it off as a PC.

 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
Oh, the HDD access services are in the BIOS already. That's how the bootloader program (from the MBR) reads stuff from the boot media -
by calling BIOS HDD services. That way the actual HDD interface is abstracted, so that the same bootloader can boot (i.e. load the OS
kernel) off IDE, SCSI, USB or even network.

regards, Peter
 

clockhar

Senior member
Dec 29, 2000
271
0
0


<< here's a good history of the a20 line

here's my question: why didn't intel implement 4gb addressing using segment:eek:ffset instead of limiting it to 1mb?
>>



Wow, some seriously useful info here ... but you should NOT have shown me pcguide site. I have a feeling I'm gonna spend a whole lot of my Chrismtas break there ;)