problem with rom
Steve Gehlbach
steve at nexpath.com
Mon May 5 14:01:01 CEST 2003
Gregg C Levine wrote:
> Hello from Gregg C Levine
> Steve, now I am completely confused. Can you elaborate on the term
> "gdt"? I am familiar with its use, on the PC, during the time period
> that covers the pre-Linux era. Namely working in assembler for the
> IBM-PC, itself, during the 1980s to the 1990s.
The gdt is one of a number of registers in the IA-32 model used for
protected mode memory management (ie, for 32-bit mode). Typically, it
is loaded to point to a data structure that defines a flat (ie, 4 GB)
data segment, and an identical code segment, although you can in reality
have many segments defined. These segments are referenced by their
offset into the gdt data structure, for example in linux startup, 0x18
defines the data segment, and you would put this into the %ds register.
This means the segment is defined 24 bytes into the gdt table. This
is very different, of course, from how you use the %ds in real or 16-bit
mode.
Originally in linuxbios, the gdt was defined in flash, and not changed
until jumping to linux. However, linux will hang if the gdt is located
above 1M (not sure why, but I have tested this many times). So if you
setup biosbase=0xffff0000, this would put the gdt high, and it has to be
loaded low so linux will work. However, recently, Eric setup a gdt
reload in c_start.S, which is relocated into ram below 1M, and so this
will work fine for linux. This makes some gdt reload code I put into
the sis630 area unnecessary.
But the bottom line is you have to setup the gdt to point to a
compatible (read that identical) gdt table to linux, before jumping to
linux. Linux expects to be in 32-bit mode with the gdt data structure a
certain way. You can see it at the bottom of
linux/arch/i386/boot/setup.S in the kernel source tree.
Anytime you go into protected mode, you have to setup the gdt, and
usually also the idt, which handles interrupts.
You can find more that you would ever want to know about it in the Intel
reference manuals, but most folks just copy the table data from someone
else. It is very painful code to debug, many bytes of the entries in
the table requiring bit by bit settings.
-Steve
More information about the coreboot
mailing list