Ok, here's my latest patch that makes initram callbacks to stage0 work in v3. It's not all that pretty, but it is the least ugly thing I could find.
Stefan
On 07/10/07 04:52 +0200, Stefan Reinauer wrote:
Ok, here's my latest patch that makes initram callbacks to stage0 work in v3. It's not all that pretty, but it is the least ugly thing I could find.
Stefan
-- coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br. Tel.: +49 761 7668825 • Fax: +49 761 7664613 Email: info@coresystems.de • http://www.coresystems.de/ Registergericht: Amtsgericht Freiburg • HRB 7656 Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
This patch against LinuxBIOSv3 enables calls from initram (freely located XIP code) to stage0 (fixed location code) by forcing gcc to create an absolute call instruction to stage0.
Signed-off-by: Stefan Reinauer stepan@coresystems.de
Index: include/console.h
--- include/console.h (revision 503) +++ include/console.h (working copy) @@ -46,7 +46,13 @@ };
// +#ifndef XIP
I really don't like the idea of singling out XIP segements. I vote we changed this to SHARED, and do this for all segments, regardless of where they live. The code impact should be minimal.
int printk(int msg_level, const char *fmt, ...) __attribute__((format (printf, 2, 3))); +#else +int stage0printk(int msg_level, const char *fmt, ...)
- __attribute__((format (printf, 2, 3)));
+int (*printk)(int msg_level, const char *fmt, ...) = stage0printk; +#endif
There has got to be a way that we can turn this into a general purpose macro to make it easy for developers to mark new functions as shared without understanding whats happening above
Index: arch/x86/ldscript.ld
--- arch/x86/ldscript.ld (revision 503) +++ arch/x86/ldscript.ld (working copy) @@ -33,10 +33,13 @@ .stage0_1 . : { _stage0_1 = .; *(.text);
*(.text.*)
*(.rodata)
*(.rodata.*)
*(.got)
*(.got.*)
How much size does the GOT add?
Jordan
On 07/10/07 07:39 -0600, Jordan Crouse wrote:
There has got to be a way that we can turn this into a general purpose macro to make it easy for developers to mark new functions as shared without understanding whats happening above
Like maybe this (avert your eyes, children!):
#if SHARED #define FUNC(func, ret, args...) \ ret stage0##func(args) #define EXTERN(func,ret,args...) \ ret (*func)(args) = stage0##func #else #define FUNC(func, ret, args...) \ ret func(args) #define EXTERN(func,ret,args...) #endif
/* Syntax: * func - function name * ret - return value * args - function arguments */
#define _SHARED(func,ret,args...) \ FUNC(func,ret,##args); \ EXTERN(func,ret,##args)
/* Example */
_SHARED(printk, int, char *, ...);
/* Resolves to: int printk(char *, ...); ; (when !SHARED)
int stage0printk(char *, ...); int (*printk)(char *, ...) = stage0printk; (when SHARED) */
Jordan
Jordan Crouse wrote:
On 07/10/07 07:39 -0600, Jordan Crouse wrote:
There has got to be a way that we can turn this into a general purpose macro to make it easy for developers to mark new functions as shared without understanding whats happening above
Like maybe this (avert your eyes, children!):
#if SHARED #define FUNC(func, ret, args...) \ ret stage0##func(args) #define EXTERN(func,ret,args...) \ ret (*func)(args) = stage0##func #else #define FUNC(func, ret, args...) \ ret func(args) #define EXTERN(func,ret,args...) #endif
/* Syntax:
- func - function name
- ret - return value
- args - function arguments
*/
#define _SHARED(func,ret,args...) \ FUNC(func,ret,##args); \ EXTERN(func,ret,##args)
/* Example */
_SHARED(printk, int, char *, ...);
/* Resolves to: int printk(char *, ...); ; (when !SHARED)
int stage0printk(char *, ...); int (*printk)(char *, ...) = stage0printk; (when SHARED) */
Jordan
It roughly seems we can't easily put our printk parameter checking in there without complexing the interface by another parameter. I'd say that is an acceptable price.
I like it. I think we should make the flag _SHARED and the macro SHARED though ?
Any opinions? Ron?
Stefan
no opinions. You guys work it out, I've screwed this up enough times already :-)
ron
On 09/10/07 18:26 +0100, Stefan Reinauer wrote:
It roughly seems we can't easily put our printk parameter checking in there without complexing the interface by another parameter. I'd say that is an acceptable price.
Thats fine - in fact, if we want to make printk a special case, we can. My only worry was somebody trying to figure out how to share a symbol that they created for their platform (for whatever reason).
I like it. I think we should make the flag _SHARED and the macro SHARED though ?
Thats fine with me.
Jordan