OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:29 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: What register needs to be set for booting linux kernel .
PostPosted: Tue Apr 16, 2013 1:32 am 
Offline

Joined: Sat Mar 30, 2013 12:11 pm
Posts: 4
I am new to bootloader stuff and going through u-boot code and looking into file zimage.c file with boot_zimage function and following are comments from boot_zimage function

Set %ebx, %ebp, and %edi to 0, %esi to point to the boot_params * structure, and then jump to the kernel. We assume that %cs is * 0x10, 4GB flat, and read/execute, and the data segments are 0x18, * 4GB flat, and read/write. U-boot is setting them up that way for * itself in arch/i386/cpu/cpu.c.

Now these comment says set ebp,ebx and edi resgister to value 0 and now my question is everytime i need to set these register to 0 before giving control to linux in case of x86 architecture., or its very much uboot specific.


Top
 Profile  
 
 Post subject: Re: What register needs to be set for booting linux kernel .
PostPosted: Tue Apr 16, 2013 3:56 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
Very end of https://www.kernel.org/doc/Documentation/x86/boot.txt

Quote:
At entry, the CPU must be in 32-bit protected mode with paging
disabled; a GDT must be loaded with the descriptors for selectors
__BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat
segment; __BOOS_CS must have execute/read permission, and __BOOT_DS
must have read/write permission; CS must be __BOOT_CS and DS, ES, SS
must be __BOOT_DS; interrupt must be disabled; %esi must hold the base
address of the struct boot_params; %ebp, %edi and %ebx must be zero.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: What register needs to be set for booting linux kernel .
PostPosted: Tue Apr 16, 2013 4:25 am 
Offline

Joined: Sat Mar 30, 2013 12:11 pm
Posts: 4
So are you saying every bootloader(Grub,uboot,LILO etc) has to follow this protocol to boot linux/x86 ??


Top
 Profile  
 
 Post subject: Re: What register needs to be set for booting linux kernel .
PostPosted: Tue Apr 16, 2013 4:50 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
Apparently you need to follow Multiboot protocol to be able to boot multiboot-compliant kernel. Linux is no different.

There are probably some shortcuts if you want quick-n-dirty boot, but it will be not fully functional.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: What register needs to be set for booting linux kernel .
PostPosted: Tue Apr 16, 2013 5:37 am 
Offline

Joined: Sat Mar 30, 2013 12:11 pm
Posts: 4
Thanks dozniak for your kind response,is it safe to say for any bootloader minimum required to boot linux/x86 is what you said

At entry, the CPU must be in 32-bit protected mode with paging
disabled; a GDT must be loaded with the descriptors for selectors
__BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat
segment; __BOOS_CS must have execute/read permission, and __BOOT_DS
must have read/write permission; CS must be __BOOT_CS and DS, ES, SS
must be __BOOT_DS; interrupt must be disabled; %esi must hold the base
address of the struct boot_params; %ebp, %edi and %ebx must be zero.


Top
 Profile  
 
 Post subject: Re: What register needs to be set for booting linux kernel .
PostPosted: Tue Apr 16, 2013 2:22 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
Just read the link I posted, it describes the full linux kernel boot protocol and what is needed to perform a successful kernel boot.

_________________
Learn to read.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 125 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group