[coreboot] Regarding patch review of 707

Stefan Reinauer stefan.reinauer at coreboot.org
Fri Apr 20 01:47:01 CEST 2012


* manasa gv <manasa671989 at gmail.com> [120419 12:54]:
> Hi,
> 
> 
> I have done patch review of 707  that is to Fix  address in Real mode IDT ..
> To find this i have gone through Intel IA-32  Vol-3A  manual..Here am
> using LIDT instruction to fix address in IDT register..I thought
> below given code may work to load an address..
> 
> 
> # include<system.h>
> 
> /*Defines an IDT entry*/
> struct idt_entry
> {
>    unsigned short base_lo;
>    unsigned short sel;
>    unsigned char always0;
>    unsigned char flags;
>    unsigned short base_hi;
> };
> 
> struct idt_ptr
> {
>    unsigned short limit;
>    unsigned int base;
> };

You should add __attribute__((packed)) to both of these structures
or gcc will attempt to align struct members.

> /*Declares an IDT of 256 entries*/
> struct idt_entry idt[256];
> struct idt_ptr idtp;
> 
> /*This is used to load IDT*/
> extern void idt_load();
> 
> extern void idt_set_gate();
> void idt_install();
> main()
> {
>   idt_install();
> }
> 
> void idt_install()
> {
> /*Sets the IDT pointer up*/
> idtp.limit = (sizeof ( struct idt_entry)*256)-1;
> idtp.base = &idt;
> 
> /*clears out the entire IDT, initializing it to zeros*/
> memset( &idt , 0 , sizeof ( struct idt_entry )*256);
> 
> /*points the processor's internal register to new IDT*/
> idt_load();
> }
> 
> 
> ;Loads the IDT defined in '_idtp' into the processor
> global _idt_load
> extern _idtp
> _idt load:
> lidt [ _idtp ]
> ret
 
how do you compile this?

> /*use this function to set an entry in the IDT*/
> void idt_set_gate ( unsigned char num , unsigned long base , unsigned
> short sel , unsigned char flags)
> {
>  idt[num].base_lo = base&0xFFFF;
>  idt[num].sel = sel;
>  idt[num].flags = ( flags >> 8) & 0xFF00;
>  idt[num].base_hi = ( base >> 16) & 0xFFFF;
> }
> 
> 
> If i test this code in terminal of Fedora16, leads to system hang..So
> Is there any other way to test??
> please let me know feedback regarding this work ..Is this the solution
> or not ?? Am new to this coreboot,
> so please help me out..

You might run into issues because lidt is a priviledged opcode iirc.






More information about the coreboot mailing list