[coreboot] How can I call the interrupt of SeaBIOS in coreboot?

Zhang Rui zrfail at gmail.com
Thu Aug 7 17:40:40 CEST 2008


Hello,



2008/8/6, Kevin O'Connor <kevin at koconnor.net>:
> On Tue, Aug 05, 2008 at 12:50:54PM +0800, Zhang Rui wrote:
> No.  The call_int16(0x19, ...) function will call irq_trampoline_0x19
> in real mode (see src/util.h).  The irq_trampoline_0x19 code is
> defined in src/romlayout.S (see macro "IRQ_TRAMPOLINE 19") which runs
> "int 0x19".
>
yes. My mistake. I see.

> >       3. write asm code to jump to real mode and call int 19.
> >       but in coreboot there is compiling errors when I write asm codes with
> > lables in it in vm86.c.
> >       for a simple example:
> >       __asm__ __volatile__ (
> >                       /* paranoia -- does ecx get saved? not sure. This is
> >                        * the easiest safe thing to do. */
> >                       "       pushal                  \n"
> >                       "       ljmp    $0x28, $cbint16bit\n"
> >                       "cbint16bit:            \n"
> >                       "       .code16                 \n"
> >                       "       popal\n"
> >                       );
> >
> >       will cause errors:
> >       {standard input}: Assembler messages:
> >       {standard input}:746: Error: symbol `cbint16bit' is already defined
> >
I changed all labels to numbers and use "ljmp    $0x28, $1f\n".
Then It can successfully call interrupt of seabios in coreboot now.



> >       in seabios there is compiling errors because of ".code16":
> >       out/../src/post.c:349: relocation truncated to fit: R_386_16 against `.text'
> >
> >       what is wrong here?
>
> I'm guessing you didn't issue a ".code32" after the ".code16".  Not
> putting the assembler back into 32bit mode will totally confuse it.
>
> Also, you may be running into trouble with the segmented memory model
> - the 32bit code runs at 0xfxxxx and uses 32bit offsets, while the
> 16bit code runs at 0xf000:xxxx and uses 16bit offsets.
>
I added ".code32" and the code is now:
void tmpboot()
{
	asm(
		"	lgdt 	%cs:__mygdtaddr	\n"

		"	ljmp 	$0x20, $boot_16bit\n"
		"boot_16bit:		\n"
		".code16		\n"
		
		"	mov	$0x28, %ax     	\n"
		"	mov	%ax, %ds       	\n"
		"	mov	%ax, %es       	\n"
		"	mov	%ax, %fs       	\n"
		"	mov	%ax, %gs       	\n"
		"	mov	%ax, %ss       	\n"

		"	movl	%cr0, %eax     	\n"
		"	andl	$0xFFFFFFFE, %eax\n"
		"	movl	%eax, %cr0     	\n"

		"	ljmp	$0xf000, $boot_real \n"
		"boot_real:                  \n"

		"	int	$0x19		\n"
		"	.code32\n"
	);
}

The compiling error also exist. But when I removed "ljmp $0xf000,
$boot_real \n", It can go through compilation. Why?


> I'm not sure why you'd want to do this in seabios though - option 2
> above would be the preferred way to call int19.
>
I am testing if the interrupt can be called.
Now I can call int19 in coreboot with asm codes and in seabios using
call_int16() function.


Zhang Rui




More information about the coreboot mailing list