[U-Boot-Users] Re: The i386 patch
Robert Kaiser
rob at sysgo.de
Wed Nov 20 17:51:54 CET 2002
Am Mittwoch, 20. November 2002 15:18 schrieb Daniel Engström:
>
> The i386 can do indirect calls on the ebp register. So we could let the
> application know the location of the syscall table by providing it in a
> register on entry. The applications initialization code can then store
> it in a suitable location (called syscall_table below).
>
> The syscall would than be done like this:
>
> movl $SYSCALL_NR, %eax
> movl syscall_table, %ebp
> shll $2, %eax
> addl %eax, %ebp
> call *%ebp
> ret
>
Exactly, except that I would do it in C:
---------------------------- cut here ----------------------------
/*
** The U-Boot's anchor :-)
** This is an absolute address that is otherwise unused.
** U-boot sets it to contain the address of the syscall
** jumptable, so clients can make calls into U-boot.
*/
#define UBOOT_ANCHOR 0x.....
struct syscall_jmptbl {
int (*j_mon_getc)(void);
int (*j_mon_tstc)(void);
void (*j_mon_putc)(const char);
void (*j_mon_puts)(const char*);
void (*j_mon_printf)(const char* fmt, ...);
void (*j_mon_install_hdlr)(int, interrupt_handler_t*, void*);
void (*j_mon_free_hdlr)(int);
void *(*j_mon_malloc)(size_t);
void (*j_mon_free)(void*);
void (*j_mon_udelay)(unsigned long);
unsigned long (*j_mon_get_timer)(unsigned long);
};
... in U-BOOT startup:
static struct syscall_jmptbl jmptable;
...
jmptable.j_mon_getc = mon_getc;
jmptable.j_mon_tstc = mon_tstc;
jmptable.j_mon_putc = mon_putc;
jmptable.j_mon_puts = mon_puts;
jmptable.j_mon_printf = mon_printf;
jmptable.j_mon_install_hdlr = mon_install_hdlr;
jmptable.j_mon_free_hdlr = mon_free_hdlr;
jmptable.j_mon_malloc = mon_malloc;
jmptable.j_mon_free = mon_free;
jmptable.j_mon_udelay = mon_udelay;
jmptable.j_mon_get_timer= mon_get_timer;
/* publish location of jump table */
*((struct syscall_jmptbl**)UBOOT_ANCHOR) = &jmptable;
....
in client:
struct syscall_jmptbl *tbl;
tbl = *((struct syscall_jmptbl**)UBOOT_ANCHOR);
tbl->j_mon_printf("Hello\n");
...
---------------------------- cut here ----------------------------
This would essentially do the same thing, but it should work on all platforms.
Rob
----------------------------------------------------------------
Robert Kaiser email: rkaiser at sysgo.de
SYSGO AG
Am Pfaffenstein 14 phone: (49) 6136 9948-762
D-55270 Klein-Winternheim / Germany fax: (49) 6136 9948-10
More information about the U-Boot
mailing list