[Icc-avr] Bootloader
David Brown
david_brown at hotpop.com
Fri Sep 14 00:52:00 PDT 2007
Bengt Ragnemalm wrote:
> Is it possible for the normal program to access functions in the
> bootloader (to save space)? If that is so, how do I do it in C?
>
>
>
> Best regards
>
> Bengt
>
You would want to set up a table of functions in the boot program such as:
typedef void (*fvoid)(void);
extern int foo(void);
extern void bar(int a, int b);
const fvoid funcTable[] = {
(fvoid) foo,
(fvoid) bar
}
You need to either fix it at a specific address, or to find it's address
and compile that into the main program:
typedef void (*fvoid)(void);
#define funcTableAddress 0x1000 // Or whatever
#define funcTable(n) (((fvoid*) funcTableAddress)[n])
#define foo() ((int (*)(void)) funcTable(0))()
#define bar(a, b) ((void (*)(int, int)) funcTable(1))(a, b)
Then you can use foo() and bar(a, b) as though they were normal functions.
mvh.,
David
More information about the Icc-avr
mailing list