Initialisation Sequence Framework
cover Initialisation Sequence Framework
Well here it is (finally) - My Initialisation Sequence Framework
This series is limited to x86 and is controlled by CONFIG_INIT_FUNC so no other arch should be effected. I don't have any cross compilers, so I would appreciate if others could confirm the zero impact assertion
Asbestos suit on
Fire away ;)
Regards,
Graeme
Graeme Russ (3):
init_func: Add fundamental framework
init_func: Add x86 support
init_func: Use for eNET board
Makefile | 34 +- arch/x86/cpu/cpu.c | 3 + arch/x86/cpu/sc520/sc520_sdram.c | 3 + arch/x86/cpu/sc520/sc520_timer.c | 2 + arch/x86/cpu/u-boot.lds | 23 + arch/x86/lib/board.c | 10 +- arch/x86/lib/init_helpers.c | 14 + arch/x86/lib/init_wrappers.c | 11 +- arch/x86/lib/pcat_interrupts.c | 2 + arch/x86/lib/relocate.c | 4 + board/eNET/eNET.c | 5 + common/Makefile | 2 + common/console.c | 3 + common/env_dataflash.c | 1 + common/env_eeprom.c | 1 + common/env_fat.c | 1 + common/env_flash.c | 2 + common/env_mgdisk.c | 1 + common/env_mmc.c | 1 + common/env_nand.c | 1 + common/env_nowhere.c | 1 + common/env_nvram.c | 1 + common/env_onenand.c | 1 + common/env_sf.c | 1 + common/serial.c | 2 + common/stdio.c | 2 + config.mk | 2 + doc/README.INIT_FUNC | 65 ++ include/configs/eNET.h | 1 + include/init_func.h | 37 + tools/Makefile | 6 + tools/mkinitseq.c | 1512 ++++++++++++++++++++++++++++++++++++++ 32 files changed, 1746 insertions(+), 9 deletions(-) create mode 100644 doc/README.INIT_FUNC create mode 100644 include/init_func.h create mode 100644 tools/mkinitseq.c
Signature · 1 line
1.7.7.6
PATCH 1/3 init_func: Add fundamental framework
--- Makefile | 34 ++- common/Makefile | 2 + config.mk | 2 + doc/README.INIT_FUNC | 65 +++ include/init_func.h | 37 ++ tools/Makefile | 6 + tools/mkinitseq.c | 1512 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1657 insertions(+), 1 deletions(-) create mode 100644 doc/README.INIT_FUNC create mode 100644 include/init_func.h create mode 100644 tools/mkinitseq.c
Makefile +33 -1
@@ -467,8 +467,40 @@ GEN_UBOOT = \ -Map u-boot.map -o u-boot endif +ifeq ($(CONFIG_INIT_FUNC),y) +INIT_SEQ = $(obj)init_seq.o + +GEN_UBOOT_INIT = \ + UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ + sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ + cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \ + --start-group $(__LIBS) --end-group \ + -Map u-boot-init.map -o u-boot-init + +$(obj)u-boot-init.lds: $(LDSCRIPT) + $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -DMAKE_INIT_LDS -P - <$^ >$@ + +$(obj)u-boot-init: depend \ + $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(obj)u-boot-init.lds + $(GEN_UBOOT_INIT) + +$(obj)u-boot-init.bin: $(obj)u-boot-init + $(OBJCOPY) -j .initfuncs -O binary $< $@ + +$(obj)init_seq.c: depend \ + $(obj)u-boot-init.bin + $(obj)tools/mkinitseq $(obj)u-boot-init.bin $(obj)common/init_seq.c + +$(obj)init_seq.o: depend \ + $(obj)init_seq.c + $(MAKE) BUILD_INIT_SEQ=y -C common all +else +INIT_SEQ = +endif + $(obj)u-boot: depend \ - $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds + $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) \ + $(INIT_SEQ) $(obj)u-boot.lds $(GEN_UBOOT) ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \
common/Makefile +2 -0
@@ -195,6 +195,8 @@ COBJS-y += dlmalloc.o COBJS-y += memsize.o COBJS-y += stdio.o +# initialisation sequence (second build stage) +COBJS-$(BUILD_INIT_SEQ) += init_seq.o COBJS := $(sort $(COBJS-y)) XCOBJS := $(sort $(XCOBJS-y))
config.mk +2 -0
@@ -257,6 +257,8 @@ ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) endif +LDFLAGS_u-boot-init += -T $(obj)u-boot-init.lds $(LDFLAGS_FINAL) + LDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL) ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
doc/README.INIT_FUNC new file +65 -0
65 lines not on this page · raw message
include/init_func.h new file +37 -0
@@ -0,0 +1,37 @@ +#ifndef __INIT_FUNC_H__ +#define __INIT_FUNC_H__ + +/* +* The requirements for any new initalization function is simple: it is +* a function with no parameters which returns an integer return code, +* where 0 means "continue" and != 0 means "fatal error, hang the system" +*/ +typedef int (init_fnc_t ) (void ); + +extern init_fnc_t *init_sequence_f[]; +extern init_fnc_t *init_sequence_f_r[]; +extern init_fnc_t *init_sequence_r[]; + +#ifdef CONFIG_INIT_FUNC +#include <linux/compiler.h> + +#define INIT_FUNC (fn, grp, man_reqs, pre_reqs, pst_reqs) \ + static const char __init_func_ ## fn[] __used \ + __attribute__((__section__(".initfuncs"))) = \ + "(f:" #fn ":" #grp ":" #man_reqs " | " #pre_reqs " | " #pst_reqs ")\n"; + +#define SKIP_INIT (fn_or_group) \ + static const char __skip_init_ ## fn_or_group[] __used \ + __attribute__((__section__(".initfuncs"))) = \ + "(s:" #fn_or_group ")\n"; + +#define REPLACE_INIT (old_fn_or_group, new_fn_or_group) \ + static const char __replace_init_ ## old_fn_or_group[] __used \ + __attribute__((__section__(".initfuncs"))) = \ + "(r:" #old_fn_or_group ":" #new_fn_or_group ")\n"; +#else +#define INIT_FUNC (fn, group, man_reqs, pre_reqs, post_reqs) +#define SKIP_INIT (fn_or_group) +#define REPLACE_INIT (old_fn_or_group, new_fn_or_group) +#endif +#endif /* !__INIT_FUNC_H__ */
tools/Makefile +6 -0
@@ -68,6 +68,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX) BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX) BIN_FILES-y += mkenvimage$(SFX) BIN_FILES-y += mkimage$(SFX) +BIN_FILES-$(CONFIG_INIT_FUNC) += mkinitseq$(SFX) BIN_FILES-$(CONFIG_SMDK5250) += mksmdk5250spl$(SFX) BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX) BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)
@@ -95,6 +96,7 @@ NOPED_OBJ_FILES-y += imximage.o NOPED_OBJ_FILES-y += omapimage.o NOPED_OBJ_FILES-y += mkenvimage.o NOPED_OBJ_FILES-y += mkimage.o +NOPED_OBJ_FILES-$(CONFIG_INIT_FUNC) += mkinitseq.o OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o OBJ_FILES-$(CONFIG_MX28) += mxsboot.o OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
@@ -215,6 +217,10 @@ $(obj)mkimage$(SFX): $(obj)aisimage.o \ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@ +$(obj)mkinitseq$(SFX): $(obj)mkinitseq.o + $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ + $(HOSTSTRIP) $@ + $(obj)mk$(BOARD)spl$(SFX): $(obj)mkexynosspl.o $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@
tools/mkinitseq.c new file +1512 -0
1,512 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH 1/3 init_func: Add fundamental framework
Dear Graeme Russ,
Quoted 15 lines
Signed-off-by Graeme Russ <[email protected]>--- Makefile | 34 ++- common/Makefile | 2 + config.mk | 2 + doc/README.INIT_FUNC | 65 +++ include/init_func.h | 37 ++ tools/Makefile | 6 + tools/mkinitseq.c | 1512 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1657 insertions(+), 1 deletions(-) create mode 100644 doc/README.INIT_FUNC create mode 100644 include/init_func.h create mode 100644 tools/mkinitseq.c
[...]
Quoted 7 lines
doc/README.INIT_FUNC new file +1
-0@@ -0,0 +1,65 @@ +The INIT_FUNC macro allows initialisation functions (i.e. functions whichare +executed before the main loop) to be easily added to the init sequence +
doc/README.INIT_FUNC new file +1
-0+
doc/README.INIT_FUNC line 14
Quoted 10 lines
doc/README.INIT_FUNC new file +10
-0+Specifying an Initialisation Function and is Dependencies +--------------------------------------------------------- +The format of the INIT_FUNC macro is: + +INIT_FUNC(fn, grp, man_reqs, pre_reqs, pst_reqs) + +fn is the name of the init function to call. This function must have the +following prototype: + +int foo(void);
What if I want to pass some data to such a func ? Clearly, I can think of this being doable, but extra hard.
Quoted 19 lines
doc/README.INIT_FUNC new file +2
-0+ +Each init function must return 0 to indicate success - any other returnvalue +indicates failure and the init sequence will stop
doc/README.INIT_FUNC new file +3
-0+ +grp is the name of the group that the init function belongs to. grp may be +the same as fn for any individual init function, but between initfunctions, +fn and grp must be unique.
doc/README.INIT_FUNC new file +2
-0+ +The purpose of groups is to allow functions to be grouped together soother +functions can specify the group as a whole as a dependency rather than having +to list every function in the group in the dependency list
doc/README.INIT_FUNC new file +2
-0+ +man_reqs is a space seperated list of functions or groups that MUST existand +MUST run BEFORE fn
doc/README.INIT_FUNC new file +2
-0+ +pre_reqs is a space seperated list of functions or groups that MAY existand +(if they do) MUST run BEFORE fn
doc/README.INIT_FUNC new file +2
-0+ +pst_reqs is a space seperated list of functions or groups that MAY exist
Quoted 1 line
and +(if they do) MUST run AFTER fn
What's the point? Can't you create a kind of proxy object that the pst_reqs will have as a pre_req ?
Maybe you should create this:
INIT_FUNC(fn, grp, prereqs, postreqs) and for each function from prereqs and postreqs, specify per-function attributes via the GCC __attribute__(()) directive, like if the function must run before something or may run before something etc?
Quoted 13 lines
doc/README.INIT_FUNC new file +4
-0+ +Skipping or Replacing a Function or Group +----------------------------------------- +Occassionally, a board may provide a completely seperate implementationfor +an initialisation function that is provided in the common arch, SoC or +common code.
doc/README.INIT_FUNC new file +4
-0+ +SKIP_INIT(fn_or_group) + +After the initialisation function dependencies are calculated, allfunctions +and groups listed in any
SKIP_INITsare removed - This may result in +dependent functions being removed - It is up to the board code developer +to ensure suitable replacements are in place
doc/README.INIT_FUNC line 54
Quoted 7 lines
doc/README.INIT_FUNC new file +7
-0+ +REPLACE_INIT(old_fn_or_group, new_fn_or_group) + +Like SKIP_INIT but replaces on function with another (or one group with +another) + +Example: In the SoC code yoy may have
Yoy :)
tools/mkinitseq.c
Quoted 91 lines
doc/README.INIT_FUNC new file +11
-0+ +INIT_FUNC(init_cpu_f, RESET, , , ); + +In the board code, you may want a slightly tweaked version, so you might +have: + +int my_new_init_cpu_f(void) +{ + ... +} +REPLACE_INIT(init_cpu_f, my_new_init_cpu_f);include/init_func.h new file +37
-0@@ -0,0 +1,37 @@ +#ifndef __INIT_FUNC_H__ +#define __INIT_FUNC_H__ + +/* +* The requirements for any new initalization function is simple: it is +* a function with no parameters which returns an integer return code, +* where 0 means "continue" and != 0 means "fatal error, hang the system" +*/ +typedef int (init_fnc_t ) (void ); + +extern init_fnc_t *init_sequence_f[]; +extern init_fnc_t *init_sequence_f_r[]; +extern init_fnc_t *init_sequence_r[]; + +#ifdef CONFIG_INIT_FUNC +#include <linux/compiler.h> + +#define INIT_FUNC (fn, grp, man_reqs, pre_reqs, pst_reqs) \ + static const char __init_func_ ## fn[] __used \ + __attribute__((__section__(".initfuncs"))) = \ + "(f:" #fn ":" #grp ":" #man_reqs " | " #pre_reqs " | " #pst_reqs ")\n"; + +#define SKIP_INIT (fn_or_group) \ + static const char __skip_init_ ## fn_or_group[] __used \ + __attribute__((__section__(".initfuncs"))) = \ + "(s:" #fn_or_group ")\n"; + +#define REPLACE_INIT (old_fn_or_group, new_fn_or_group) \ + static const char __replace_init_ ## old_fn_or_group[] __used \ + __attribute__((__section__(".initfuncs"))) = \ + "(r:" #old_fn_or_group ":" #new_fn_or_group ")\n"; +#else +#define INIT_FUNC (fn, group, man_reqs, pre_reqs, post_reqs) +#define SKIP_INIT (fn_or_group) +#define REPLACE_INIT (old_fn_or_group, new_fn_or_group) +#endif +#endif /* !__INIT_FUNC_H__ */ tools/Makefile +6
-0@@ -68,6 +68,7 @@ BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX) BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX) BIN_FILES-y += mkenvimage$(SFX) BIN_FILES-y += mkimage$(SFX) +BIN_FILES-$(CONFIG_INIT_FUNC) += mkinitseq$(SFX) BIN_FILES-$(CONFIG_SMDK5250) += mksmdk5250spl$(SFX) BIN_FILES-$(CONFIG_MX28) += mxsboot$(SFX) BIN_FILES-$(CONFIG_NETCONSOLE) += ncb$(SFX)@@ -95,6 +96,7 @@ NOPED_OBJ_FILES-y += imximage.o NOPED_OBJ_FILES-y += omapimage.o NOPED_OBJ_FILES-y += mkenvimage.o NOPED_OBJ_FILES-y += mkimage.o +NOPED_OBJ_FILES-$(CONFIG_INIT_FUNC) += mkinitseq.o OBJ_FILES-$(CONFIG_SMDK5250) += mkexynosspl.o OBJ_FILES-$(CONFIG_MX28) += mxsboot.o OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o@@ -215,6 +217,10 @@ $(obj)mkimage$(SFX): $(obj)aisimage.o \ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@ +$(obj)mkinitseq$(SFX): $(obj)mkinitseq.o + $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ + $(HOSTSTRIP) $@ + $(obj)mk$(BOARD)spl$(SFX): $(obj)mkexynosspl.o $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTSTRIP) $@tools/mkinitseq.c new file +0
-0@@ -0,0 +1,1512 @@
Ok, this is the worst part. I think this could be reimplemented in shell ;-)
Quoted 27 lines
tools/mkinitseq.c new file +22
-0+/* +* (C) Copyright 2012 +* Graeme Russ <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/** +* container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
tools/mkinitseq.c line 30
Quoted 3 lines
tools/mkinitseq.c new file +3
-0+#define container_of (ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );})
Don't we already have this defined in uboot ?
[...]
PATCH 1/3 init_func: Add fundamental framework
Hi Marek,
Thanks for taking a look
Quoted 9 lines
Quoted 9 lines
+The
INIT_FUNCmacro allows initialisation functions (i.e. functions which are +executed before the main loop) to be easily added to the init sequence +doc/README.INIT_FUNC new file +6
-0+ +Specifying an Initialisation Function and is Dependencies +--------------------------------------------------------- +The format of the INIT_FUNC macro is: + +INIT_FUNC(fn, grp, man_reqs, pre_reqs, pst_reqs)
Quoted 8 lines
doc/README.INIT_FUNC line 14
Quoted 5 lines
doc/README.INIT_FUNC new file +5
-0+ +fn is the name of the init function to call. This function must have the +following prototype: + +int foo(void);What if I want to pass some data to such a func ? Clearly, I can think of this being doable, but extra hard.
The idea is that no changes are being made to the existing init methodology.
Quoted 24 lines
Quoted 19 lines
(quoted diff) +2
-0+ +Each init function must return 0 to indicate success - any other returnvalue +indicates failure and the init sequence will stop
doc/README.INIT_FUNC new file +3
-0+ +grp is the name of the group that the init function belongs to. grp may be +the same as fn for any individual init function, but between initfunctions, +fn and grp must be unique.
(quoted diff) +2
-0+ +The purpose of groups is to allow functions to be grouped together soother +functions can specify the group as a whole as a dependency rather than having +to list every function in the group in the dependency list
(quoted diff) +2
-0+ +man_reqs is a space seperated list of functions or groups that MUST existand +MUST run BEFORE fn
(quoted diff) +2
-0+ +pre_reqs is a space seperated list of functions or groups that MAY existand +(if they do) MUST run BEFORE fn
(quoted diff) +2
-0+ +pst_reqs is a space seperated list of functions or groups that MAY existQuoted 1 line
and +(if they do) MUST run AFTER fn
What's the point? Can't you create a kind of proxy object that the
pst_reqswill have as apre_req?
Quoted 6 lines
Maybe you should create this:
INIT_FUNC(fn, grp, prereqs, postreqs)and for each function from prereqs and postreqs, specify per-function attributes via the GCC __attribute__(()) directive, like if the function must run before something or may run before something etc?
Eep, I would like to see that implemented - I'm sure it would be 'interesting'
The way INIT_FUNC and friends work is to simply build a list of static strings (which we just happen to shove in a seperate section so they can be filtered in/out based on the link stage)
Quoted 14 lines
Quoted 14 lines
doc/README.INIT_FUNC new file +4
-0+ +Skipping or Replacing a Function or Group +----------------------------------------- +Occassionally, a board may provide a completely seperate implementationfor +an initialisation function that is provided in the common arch, SoC or +common code.
doc/README.INIT_FUNC new file +4
-0+ +SKIP_INIT(fn_or_group) + +After the initialisation function dependencies are calculated, allfunctions +and groups listed in any
SKIP_INITsare removed - This may result in +dependent functions being removed - It is up to the board code developer +to ensure suitable replacements are in place
+
Quoted 8 lines
doc/README.INIT_FUNC line 54
Quoted 6 lines
doc/README.INIT_FUNC new file +6
-0+REPLACE_INIT(old_fn_or_group, new_fn_or_group) + +Like SKIP_INIT but replaces on function with another (or one group with +another) + +Example: In the SoC code yoy may haveYoy :)
Yes. The ultimate goal is to remove a heap of '#ifdef mess' and delegate the selection of initialiasation functions to where is is most appropriate. CPU init in ARCH code with board specific init in board code with the ARCH code 100% unaware of what the board is doing. This will also make it a lot easier for vendors to implement multi-arch solutions :)
Quoted 11 lines
Quoted 11 lines
doc/README.INIT_FUNC new file +11
-0+ +INIT_FUNC(init_cpu_f, RESET, , , ); + +In the board code, you may want a slightly tweaked version, so you might +have: + +int my_new_init_cpu_f(void) +{ + ? ? ... +} +REPLACE_INIT(init_cpu_f, my_new_init_cpu_f);
[snip]
Quoted 8 lines
tools/mkinitseq.c
Quoted 6 lines
tools/mkinitseq.c new file +0
-0@@ -0,0 +1,1512 @@Ok, this is the worst part. I think this could be reimplemented in shell ;-)
Be my guest :) - Have a really good look at what is happening behind the scenes - Lots of list processing and checking. In particular, the processing of the REPLACE and SKIP macros would be particularly nasty.
I have no problem with this being done in shell code. BUT if I have to do so in order for it to be accepted, then I'll bin this patch series right now. I'm more than happy to integrate somebody elses shell-based tool into the series. Sorry to be so blunt, but I do not have the time or energy to re-implement this myself.
My argument is that this is a black-box tool like gcc/ld. Once we prove it to do what it does correctly, we can 'leave it alone'(tm) and test cases are fairly trivial. You can even mock-up the input file in vi :)
And is a shell based implementation going to be any easier to understand, modify, debug, etc?
Quoted 24 lines
Quoted 24 lines
tools/mkinitseq.c new file +22
-0+/* +* (C) Copyright 2012 +* Graeme Russ <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/** +* container_of - cast a member of a structure out to the containing structure + * @ptr: ? the pointer to the member.
+ * @type: ? ?the type of the container struct this is embedded in.
Quoted 8 lines
Quoted 6 lines
+ * @member: ?the name of the member within the struct.
+ *
+ */
+#definecontainer_of(ptr, type, member)({ ? ? ? ? ? ? ? ? ? \
+ ? ? consttypeof( ((type *)0)->member )*__mptr= (ptr); ? ?\
+ ? ? (type *)( (char *)__mptr -offsetof(type,member));})Don't we already have this defined in uboot ?
mkinitseq is host-code so it only brings in host headers (not U-Boot headers) - If you don't have Linux kernel headers installed, you can't get this macro. Actually, even though I do have them, I had a hard time getting this macro in, so I gave up - Any hints?
As an aside, I wonder if the kernel headers are required for the list macros?
Regards,
Graeme
PATCH 1/3 init_func: Add fundamental framework
Dear Graeme Russ,
Quoted 22 lines
Hi Marek,
Thanks for taking a look
Quoted 9 lines
Quoted 9 lines
+The
INIT_FUNCmacro allows initialisation functions (i.e. functions which are +executed before the main loop) to be easily added to the init sequence +doc/README.INIT_FUNC new file +6
-0+ +Specifying an Initialisation Function and is Dependencies +--------------------------------------------------------- +The format of the INIT_FUNC macro is: + +INIT_FUNC(fn, grp, man_reqs, pre_reqs, pst_reqs)Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +2
-0+ +fn is the name of the init function to call. This function must havethe +following prototype:
(quoted diff) +2
-0+ +int foo(void);What if I want to pass some data to such a func ? Clearly, I can think of this being doable, but extra hard.
Quoted 2 lines
The idea is that no changes are being made to the existing init methodology.
Well ... what if I want to pass eg. pdata?
Quoted 27 lines
Quoted 27 lines
Quoted 20 lines
(quoted diff) +2
-0+ +Each init function must return 0 to indicate success - any other returnvalue +indicates failure and the init sequence will stop
(quoted diff) +2
-0+ +grp is the name of the group that the init function belongs to. grp maybe +the same as fn for any individual init function, but between init functions, +fn and grp must be unique.
(quoted diff) +2
-0+ +The purpose of groups is to allow functions to be grouped together soother +functions can specify the group as a whole as a dependency rather than having +to list every function in the group in the dependency list
(quoted diff) +2
-0+ +man_reqs is a space seperated list of functions or groups that MUSTexist and +MUST run BEFORE fn
(quoted diff) +2
-0+ +pre_reqs is a space seperated list of functions or groups that MAYexist and +(if they do) MUST run BEFORE fn
(quoted diff) +2
-0+ +pst_reqs is a space seperated list of functions or groups that MAYQuoted 1 line
exist and +(if they do) MUST run AFTER fn
What's the point? Can't you create a kind of proxy object that the
pst_reqswill have as apre_req?Maybe you should create this:
Quoted 7 lines
Quoted 4 lines
INIT_FUNC(fn, grp, prereqs, postreqs)and for each function from prereqs and postreqs, specify per-function attributes via the GCC __attribute__(()) directive, like if the function must run before something or may run before something etc?Eep, I would like to see that implemented - I'm sure it would be 'interesting'
Pervy and sadistic at least :-)
Quoted 3 lines
The way
INIT_FUNCand friends work is to simply build a list of static strings (which we just happen to shove in a seperate section so they can be filtered in/out based on the link stage)
Yes, I got the understanding of it. I was more bothered by the man_reqs and pre_reqs, what if we soon need functions that are executed under another weird condition? And if you look at it the other way -- if you need function that's executed conditionally, why not wrap the condition into the pre_req (or some proxy object, whatever).
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
doc/README.INIT_FUNC new file +4
-0+ +Skipping or Replacing a Function or Group +----------------------------------------- +Occassionally, a board may provide a completely seperate implementationfor +an initialisation function that is provided in the common arch, SoC or +common code.
doc/README.INIT_FUNC new file +4
-0+ +SKIP_INIT(fn_or_group) + +After the initialisation function dependencies are calculated, allfunctions +and groups listed in any
SKIP_INITsare removed - This may result in +dependent functions being removed - It is up to the board code developer +to ensure suitable replacements are in place +Quoted 8 lines
doc/README.INIT_FUNC line 54
Quoted 6 lines
doc/README.INIT_FUNC new file +6
-0+REPLACE_INIT(old_fn_or_group, new_fn_or_group) + +Like SKIP_INIT but replaces on function with another (or one group with +another) + +Example: In the SoC code yoy may haveYoy :)
Quoted 5 lines
Yes. The ultimate goal is to remove a heap of '#ifdef mess' and delegate the selection of initialiasation functions to where is is most appropriate. CPU init in ARCH code with board specific init in board code with the ARCH code 100% unaware of what the board is doing. This will also make it a lot easier for vendors to implement multi-arch solutions :)
Correct, alongside kbuild and driver model, we'll make an awesome bootloader. But fix that s/yoy/you/ please ;-)
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
doc/README.INIT_FUNC new file +4
-0+ +INIT_FUNC(init_cpu_f, RESET, , , ); + +In the board code, you may want a slightly tweaked version, so youmight +have:
doc/README.INIT_FUNC new file +6
-0+ +int my_new_init_cpu_f(void) +{ + ... +} +REPLACE_INIT(init_cpu_f, my_new_init_cpu_f);[snip]
Quoted 9 lines
tools/mkinitseq.c
Quoted 6 lines
tools/mkinitseq.c new file +0
-0@@ -0,0 +1,1512 @@Ok, this is the worst part. I think this could be reimplemented in shell ;-)
Quoted 3 lines
Be my guest :) - Have a really good look at what is happening behind the scenes - Lots of list processing and checking. In particular, the processing of the REPLACE and SKIP macros would be particularly nasty.
That's what sed can do for you, can't it ?
Quoted 5 lines
I have no problem with this being done in shell code. BUT if I have to do so in order for it to be accepted, then I'll bin this patch series right now. I'm more than happy to integrate somebody elses shell-based tool into the series. Sorry to be so blunt, but I do not have the time or energy to re-implement this myself.
Ooh, I smell flame-fuel :-) I'd certainly prefer to see this in shell, since I believe the substitutions and reordering of text might be easier there.
Quoted 3 lines
My argument is that this is a black-box tool like gcc/ld. Once we prove it to do what it does correctly, we can 'leave it alone'(tm) and test cases are fairly trivial. You can even mock-up the input file in vi :)
Ewwwwww ... like gcc/ld ... or maybe like Windows (TM)(C)(R)(?) :-D
Quoted 2 lines
And is a shell based implementation going to be any easier to understand, modify, debug, etc?
I wonder :-)
Quoted 33 lines
Quoted 24 lines
Quoted 24 lines
tools/mkinitseq.c new file +22
-0+/* +* (C) Copyright 2012 +* Graeme Russ <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/** +* container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.Quoted 8 lines
tools/mkinitseq.c line 30
Quoted 6 lines
+ * @member: the name of the member within the struct.
+ *
+ */tools/mkinitseq.c new file +3
-0+#define container_of (ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );})Don't we already have this defined in uboot ?
Quoted 4 lines
mkinitseq is host-code so it only brings in host headers (not U-Boot headers) - If you don't have Linux kernel headers installed, you can't get this macro. Actually, even though I do have them, I had a hard time getting this macro in, so I gave up - Any hints?
Reimplement this thing in shell :-)
Quoted 3 lines
As an aside, I wonder if the kernel headers are required for the list macros?
Nope.
Quoted 4 lines
Regards,
Graeme
PATCH 1/3 init_func: Add fundamental framework
Hi Marek,
Quoted 24 lines · Marek Vasut
Dear Graeme Russ,
Quoted 22 lines
Hi Marek,
Thanks for taking a look
Quoted 17 lines
Quoted 12 lines
+The
INIT_FUNCmacro allows initialisation functions (i.e. functions which are +executed before the main loop) to be easily added to the init sequence +doc/README.INIT_FUNC new file +8
-0+ +Specifying an Initialisation Function and is Dependencies +--------------------------------------------------------- +The format of the INIT_FUNC macro is: + +INIT_FUNC(fn, grp, man_reqs, pre_reqs, pst_reqs) + +fn is the name of the init function to call. This function must havethe +following prototype:
Review
Quoted 2 lines
(quoted diff) +2
-0+ +int foo(void);What if I want to pass some data to such a func ? Clearly, I can think of this being doable, but extra hard.
Quoted 4 lines
Quoted 2 lines
The idea is that no changes are being made to the existing init methodology.
Well ... what if I want to pass eg. pdata?
Do what we do now - Global Data is the only way to pass data between initialisation functions. Sure, this _might_ change in the future (but I doubt it) but we can deal with that later
Quoted 40 lines
Quoted 26 lines
Quoted 26 lines
Quoted 19 lines
(quoted diff) +2
-0+ +Each init function must return 0 to indicate success - any other returnvalue +indicates failure and the init sequence will stop
(quoted diff) +2
-0+ +grp is the name of the group that the init function belongs to. grp maybe +the same as fn for any individual init function, but between init functions, +fn and grp must be unique.
(quoted diff) +2
-0+ +The purpose of groups is to allow functions to be grouped together soother +functions can specify the group as a whole as a dependency rather than having +to list every function in the group in the dependency list
(quoted diff) +2
-0+ +man_reqs is a space seperated list of functions or groups that MUSTexist and +MUST run BEFORE fn
(quoted diff) +2
-0+ +pre_reqs is a space seperated list of functions or groups that MAYexist and +(if they do) MUST run BEFORE fn
(quoted diff) +2
-0+ +pst_reqs is a space seperated list of functions or groups that MAYQuoted 1 line
exist and +(if they do) MUST run AFTER fn
What's the point? Can't you create a kind of proxy object that the
pst_reqswill have as apre_req?Maybe you should create this:
Quoted 7 lines
Quoted 4 lines
INIT_FUNC(fn, grp, prereqs, postreqs)and for each function from prereqs and postreqs, specify per-function attributes via the GCC __attribute__(()) directive, like if the function must run before something or may run before something etc?Eep, I would like to see that implemented - I'm sure it would be 'interesting'
Pervy and sadistic at least :-)
Quoted 3 lines
The way
INIT_FUNCand friends work is to simply build a list of static strings (which we just happen to shove in a seperate section so they can be filtered in/out based on the link stage)
Quoted 5 lines
Yes, I got the understanding of it. I was more bothered by the
man_reqsandpre_reqs, what if we soon need functions that are executed under another weird condition? And if you look at it the other way -- if you need function that's executed conditionally, why not wrap the condition into thepre_req(or some proxy object, whatever).
It's not about being executed conditionally - It's about 'I need to be initialised after 'X', but if 'X' does not exist, I can still initialise'
Network is one example - If you have a PCI network adapter, it must be intialised after PCI. But if the adapter is not PCI, you still want to be able to initialise it
Timer is another - Hopefully the timer infrastructure will soon be an arch independent API. But each arch (and potentially down to the board level) may have a role to play in getting the timer infrastucture running (FPGA, PLL, PIT intialiastion). So potentially, the common driver code would be intialised with:
INIT_FUNC(timer_api, timer, arch_timer, board_timer, );
So the arch_timer function MUST exist and it MUST run before timer_api. The board specific timer initialisation is optional. If the board has timer related code, it MUST run before timer_api but timer_api can still run if board_timer does not exist (i.e. all the timer init done at the arch level)
Now depending on the arch and board, board_timer may be either:
INIT_FUNC(board_timer, timer, arch_timer, , timer_api);
i.e. arch -> board -> api
or
INIT_FUNC(board_timer, timer, , , arch_timer timer_api);
i.e. board -> arch -> api
NOTE: In both of the above example, including timer_api as a post-req is redundant. The timer_api INIT_FUNC definition already mandated the order. This is not a problem and including or excluding it makes no difference to the output. Of course, including timer_api in the above examples means we could have done:
INIT_FUNC(timer_api, timer, arch_timer, , );
But adding the redundant references makes it clearer when you are looking at that bit of code. The 'black-box' tool will warn you if you created a circular reference and will print out what the init sequence is that created the circular reference.
Now, here is where the fun begins :) - Lets say you need timer support early, but you can't get the low level infrastructure for hi-res timers running until later...
board/vendor_me/common/timer.cINIT_FUNC(me_timer_init, me_late_timer, me_pit_init, , ); INIT_FUNC(me_pit_init, me_late_timer, , fpga_init pll_init, me_timer_init);
(again, me_late_timer in the second INIT_FUNC is redundant)
board/vendor_me/board_a/timer.c INIT_FUNC(fpga_init, me_late_timer, , , me_pit_init);
board/vendor_me/board_b/timer.c INIT_FUNC(pll_init, me_late_timer, , , me_pit_init);
(again, me_pit_init in these INIT_FUNCs is redundant)
board/vendor_me/board_c/timer.c
/*
* This board has the PIT hard-wired to a crystal oscillator so there
* is now board_level init function - So we can actually initialise
* the PIT earlier :)
*/
int me_pit_early_init(void)
{
return me_pit_init();
}INIT_FUNC(me_pit_early_init, timer, arch_timer, , );
/*
* Don't need any late timer init - This will skip both me_timer_init and
* me_pit_init as they have been defined in the me_late_timer group */INIT_SKIP(me_late_timer);
The idea is that me_late_timer() will perform some tweak to the timer API to redirect it to the hi-res clock source. The hi-res clock source is driven by a PIT common to all the boards manufacture by this vendor. But the PIT has a different raw clock source depending on a particular board Board A has an FPGA, board B has a PLL and board C uses a hard-wired crystal oscillator
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 13 lines
doc/README.INIT_FUNC new file +4
-0+ +Skipping or Replacing a Function or Group +----------------------------------------- +Occassionally, a board may provide a completely seperate implementationfor +an initialisation function that is provided in the common arch, SoC or +common code.
doc/README.INIT_FUNC new file +4
-0+ +SKIP_INIT(fn_or_group) + +After the initialisation function dependencies are calculated, allfunctions +and groups listed in any
SKIP_INITsare removed - This may result in +dependent functions being removed - It is up to the board code developer +to ensure suitable replacements are in placedoc/README.INIT_FUNC line 54
Quoted 7 lines
doc/README.INIT_FUNC new file +7
-0+ +REPLACE_INIT(old_fn_or_group, new_fn_or_group) + +Like SKIP_INIT but replaces on function with another (or one group with +another) + +Example: In the SoC code yoy may haveYoy :)
Quoted 8 lines
Quoted 5 lines
Yes. The ultimate goal is to remove a heap of '#ifdef mess' and delegate the selection of initialiasation functions to where is is most appropriate. CPU init in ARCH code with board specific init in board code with the ARCH code 100% unaware of what the board is doing. This will also make it a lot easier for vendors to implement multi-arch solutions :)
Correct, alongside kbuild and driver model, we'll make an awesome bootloader. But fix that s/yoy/you/ please ;-)
Ah, I see now... Will do
Quoted 24 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
doc/README.INIT_FUNC new file +4
-0+ +INIT_FUNC(init_cpu_f, RESET, , , ); + +In the board code, you may want a slightly tweaked version, so youmight +have:
doc/README.INIT_FUNC new file +6
-0+ +int my_new_init_cpu_f(void) +{ + ? ? ... +} +REPLACE_INIT(init_cpu_f, my_new_init_cpu_f);[snip]
Quoted 9 lines
tools/mkinitseq.c
Quoted 6 lines
tools/mkinitseq.c new file +0
-0@@ -0,0 +1,1512 @@Ok, this is the worst part. I think this could be reimplemented in shell ;-)
Quoted 5 lines
Quoted 3 lines
Be my guest :) - Have a really good look at what is happening behind the scenes - Lots of list processing and checking. In particular, the processing of the REPLACE and SKIP macros would be particularly nasty.
That's what sed can do for you, can't it ?
So below - If you can show me (i.e. write the whole thing in shell) I might include it
Quoted 8 lines
Quoted 5 lines
I have no problem with this being done in shell code. BUT if I have to do so in order for it to be accepted, then I'll bin this patch series right now. I'm more than happy to integrate somebody elses shell-based tool into the series. Sorry to be so blunt, but I do not have the time or energy to re-implement this myself.
Ooh, I smell flame-fuel :-) I'd certainly prefer to see this in shell, since I believe the substitutions and reordering of text might be easier there.
See above - be my guest ;)
Quoted 5 lines
Quoted 3 lines
My argument is that this is a black-box tool like gcc/ld. Once we prove it to do what it does correctly, we can 'leave it alone'(tm) and test cases are fairly trivial. You can even mock-up the input file in vi :)
Ewwwwww ... like gcc/ld ... or maybe like Windows (TM)(C)(R)(?) :-D
No, like FLOSS gcc/ld :P
Quoted 4 lines
Quoted 2 lines
And is a shell based implementation going to be any easier to understand, modify, debug, etc?
I wonder :-)
Well, if someone manages to do it in shell, we will see - Take a look at main() - I have been very carefull to layout the way the tool operates in a very linear way but ther lists are global, so sharing data between the shell stages will be a pain (pipes?)
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 22 lines
tools/mkinitseq.c new file +22
-0+/* +* (C) Copyright 2012 +* Graeme Russ <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/** +* container_of - cast a member of a structure out to the containing Quoted 8 lines
structure + * @ptr: ? the pointer to the member.
+ * @type: ? ?the type of the container struct this is embedded in.
+ * @member: ?the name of the member within the struct.
+ *
+ */
+#definecontainer_of(ptr, type, member)({ ? ? ? ? ? ? ? ? ? \
+ ? ? consttypeof( ((type *)0)->member )*__mptr= (ptr); ? ?\
+ ? ? (type *)( (char *)__mptr -offsetof(type,member));})Don't we already have this defined in uboot ?
Quoted 6 lines
Quoted 4 lines
mkinitseq is host-code so it only brings in host headers (not U-Boot headers) - If you don't have Linux kernel headers installed, you can't get this macro. Actually, even though I do have them, I had a hard time getting this macro in, so I gave up - Any hints?
Reimplement this thing in shell :-)
You already know my answer to this ;)
Quoted 4 lines
Quoted 2 lines
As an aside, I wonder if the kernel headers are required for the list macros?
Nope.
Good :)
Regards,
Graeme
PATCH 1/3 init_func: Add fundamental framework
Dear Graeme Russ,
Quoted 27 lines
Hi Marek,
Quoted 24 lines · Marek Vasut
Dear Graeme Russ,
Quoted 22 lines
Hi Marek,
Thanks for taking a look
Quoted 17 lines
Quoted 12 lines
+The
INIT_FUNCmacro allows initialisation functions (i.e. functions which are +executed before the main loop) to be easily added to the init sequence +doc/README.INIT_FUNC new file +8
-0+ +Specifying an Initialisation Function and is Dependencies +--------------------------------------------------------- +The format of the INIT_FUNC macro is: + +INIT_FUNC(fn, grp, man_reqs, pre_reqs, pst_reqs) + +fn is the name of the init function to call. This function must havethe +following prototype:
Review
Quoted 2 lines
(quoted diff) +2
-0+ +int foo(void);What if I want to pass some data to such a func ? Clearly, I can think of this being doable, but extra hard.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
The idea is that no changes are being made to the existing init methodology.
Well ... what if I want to pass eg. pdata?
Do what we do now - Global Data is the only way to pass data between initialisation functions. Sure, this _might_ change in the future (but I doubt it) but we can deal with that later
Global data won't die, but they should shrink as much as possible ... so I don't like the idea of using global data that way.
Quoted 47 lines
Quoted 41 lines
Quoted 27 lines
Quoted 27 lines
Quoted 20 lines
(quoted diff) +2
-0+ +Each init function must return 0 to indicate success - any otherreturn value +indicates failure and the init sequence will stop
(quoted diff) +2
-0+ +grp is the name of the group that the init function belongs to. grpmay be +the same as fn for any individual init function, but between init functions, +fn and grp must be unique.
(quoted diff) +2
-0+ +The purpose of groups is to allow functions to be grouped togetherso other +functions can specify the group as a whole as a dependency rather than having +to list every function in the group in the dependency list +
+man_reqs is a space seperated list of functions or groups that MUST exist and +MUST run BEFORE fn(quoted diff) +2
-0+ +pre_reqs is a space seperated list of functions or groups that MAYexist and +(if they do) MUST run BEFORE fn
(quoted diff) +2
-0+ +pst_reqs is a space seperated list of functions or groups that MAYQuoted 1 line
exist and +(if they do) MUST run AFTER fn
What's the point? Can't you create a kind of proxy object that the
pst_reqswill have as apre_req?Maybe you should create this:
Quoted 7 lines
Quoted 4 lines
INIT_FUNC(fn, grp, prereqs, postreqs)and for each function from prereqs and postreqs, specify per-function attributes via the GCC __attribute__(()) directive, like if the function must run before something or may run before something etc?Eep, I would like to see that implemented - I'm sure it would be 'interesting'
Pervy and sadistic at least :-)
Quoted 3 lines
The way
INIT_FUNCand friends work is to simply build a list of static strings (which we just happen to shove in a seperate section so they can be filtered in/out based on the link stage)Quoted 5 lines
Yes, I got the understanding of it. I was more bothered by the
man_reqsandpre_reqs, what if we soon need functions that are executed under another weird condition? And if you look at it the other way -- if you need function that's executed conditionally, why not wrap the condition into thepre_req(or some proxy object, whatever).
Quoted 6 lines
It's not about being executed conditionally - It's about 'I need to be initialised after 'X', but if 'X' does not exist, I can still initialise'
Network is one example - If you have a PCI network adapter, it must be intialised after PCI. But if the adapter is not PCI, you still want to be able to initialise it
So why don't we make function, that can depend on "OR-group" and/or "AND-group" then? Won't that be more logical? I mean, group where you must execute as much as possible, to be OR-group and group where you must execute everything to be AND-group.
Quoted 6 lines
Timer is another - Hopefully the timer infrastructure will soon be an arch independent API. But each arch (and potentially down to the board level) may have a role to play in getting the timer infrastucture running (FPGA, PLL, PIT intialiastion). So potentially, the common driver code would be intialised with:
Well, I hope to create unified timer api with the DM biz.
Quoted 6 lines
INIT_FUNC(timer_api, timer, arch_timer, board_timer, );So the
arch_timerfunction MUST exist and it MUST run beforetimer_api. The board specific timer initialisation is optional. If the board has timer related code, it MUST run beforetimer_apibuttimer_apican still run ifboard_timerdoes not exist (i.e. all the timer init done at the arch level)
Ok, I see. OR-groups won't fit in here?
Quoted 18 lines
Now depending on the arch and board,
board_timermay be either:
INIT_FUNC(board_timer, timer, arch_timer, , timer_api);i.e. arch -> board -> api
or
INIT_FUNC(board_timer, timer, , , arch_timer timer_api);i.e. board -> arch -> api
NOTE: In both of the above example, including
timer_apias a post-req is redundant. Thetimer_apiINIT_FUNCdefinition already mandated the order. This is not a problem and including or excluding it makes no difference to the output. Of course, includingtimer_apiin the above examples means we could have done:
Quoted 6 lines
INIT_FUNC(timer_api, timer, arch_timer, , );But adding the redundant references makes it clearer when you are looking at that bit of code. The 'black-box' tool will warn you if you created a circular reference and will print out what the init sequence is that created the circular reference.
Neat.
Quoted 36 lines
Now, here is where the fun begins :) - Lets say you need timer support early, but you can't get the low level infrastructure for hi-res timers running until later...
board/vendor_me/common/timer.cINIT_FUNC(me_timer_init, me_late_timer, me_pit_init, , );INIT_FUNC(me_pit_init, me_late_timer, , fpga_init pll_init, me_timer_init);(again,
me_late_timerin the secondINIT_FUNCis redundant)
board/vendor_me/board_a/timer.cINIT_FUNC(fpga_init, me_late_timer, , , me_pit_init);
board/vendor_me/board_b/timer.cINIT_FUNC(pll_init, me_late_timer, , , me_pit_init);(again,
me_pit_initin theseINIT_FUNCsis redundant)
board/vendor_me/board_c/timer.c
/*
* This board has the PIT hard-wired to a crystal oscillator so there
* is nowboard_levelinit function - So we can actually initialise
* the PIT earlier :)
*/
intme_pit_early_init(void){ return me_pit_init(); }
INIT_FUNC(me_pit_early_init, timer, arch_timer, , );/*
* Don't need any late timer init - This will skip bothme_timer_initand
*me_pit_initas they have been defined in theme_late_timergroup */INIT_SKIP(me_late_timer);
Quoted 6 lines
The idea is that
me_late_timer()will perform some tweak to the timer API to redirect it to the hi-res clock source. The hi-res clock source is driven by a PIT common to all the boards manufacture by this vendor. But the PIT has a different raw clock source depending on a particular board Board A has an FPGA, board B has a PLL and board C uses a hard-wired crystal oscillator
I see.
Quoted 59 lines
Quoted 30 lines
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
doc/README.INIT_FUNC new file +4
-0+ +Skipping or Replacing a Function or Group +----------------------------------------- +Occassionally, a board may provide a completely seperateimplementation for +an initialisation function that is provided in the common arch, SoC or +common code.
doc/README.INIT_FUNC new file +4
-0+ +SKIP_INIT(fn_or_group) + +After the initialisation function dependencies are calculated, allfunctions +and groups listed in any
SKIP_INITsare removed - This may result in +dependent functions being removed - It is up to the board code developer +to ensure suitable replacements are in place +Quoted 8 lines
Review
Quoted 6 lines
doc/README.INIT_FUNC new file +3
-0+REPLACE_INIT(old_fn_or_group, new_fn_or_group) + +Like SKIP_INIT but replaces on function with another (or one groupwith +another)
(quoted diff) +2
-0+ +Example: In the SoC code yoy may haveYoy :)
Quoted 6 lines
Yes. The ultimate goal is to remove a heap of '#ifdef mess' and delegate the selection of initialiasation functions to where is is most appropriate. CPU init in ARCH code with board specific init in board code with the ARCH code 100% unaware of what the board is doing. This will also make it a lot easier for vendors to implement multi-arch solutions :)
Quoted 2 lines
Correct, alongside kbuild and driver model, we'll make an awesome bootloader. But fix that s/yoy/you/ please ;-)
Ah, I see now... Will do
Quoted 24 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
doc/README.INIT_FUNC new file +4
-0+ +INIT_FUNC(init_cpu_f, RESET, , , ); + +In the board code, you may want a slightly tweaked version, so youmight +have:
doc/README.INIT_FUNC new file +6
-0+ +int my_new_init_cpu_f(void) +{ + ... +} +REPLACE_INIT(init_cpu_f, my_new_init_cpu_f);[snip]
Quoted 9 lines
tools/mkinitseq.c
Quoted 6 lines
tools/mkinitseq.c new file +0
-0@@ -0,0 +1,1512 @@Ok, this is the worst part. I think this could be reimplemented in shell ;-)
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Be my guest :) - Have a really good look at what is happening behind the scenes - Lots of list processing and checking. In particular, the processing of the REPLACE and SKIP macros would be particularly nasty.
That's what sed can do for you, can't it ?
So below - If you can show me (i.e. write the whole thing in shell) I might include it
I'll think about it ;-)
Quoted 12 lines
Quoted 9 lines
Quoted 5 lines
I have no problem with this being done in shell code. BUT if I have to do so in order for it to be accepted, then I'll bin this patch series right now. I'm more than happy to integrate somebody elses shell-based tool into the series. Sorry to be so blunt, but I do not have the time or energy to re-implement this myself.
Ooh, I smell flame-fuel :-) I'd certainly prefer to see this in shell, since I believe the substitutions and reordering of text might be easier there.
See above - be my guest ;)
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
My argument is that this is a black-box tool like gcc/ld. Once we prove it to do what it does correctly, we can 'leave it alone'(tm) and test cases are fairly trivial. You can even mock-up the input file in vi :)
Ewwwwww ... like gcc/ld ... or maybe like Windows (TM)(C)(R)(?) :-D
No, like FLOSS gcc/ld :P
:-)
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
And is a shell based implementation going to be any easier to understand, modify, debug, etc?
I wonder :-)
Well, if someone manages to do it in shell, we will see - Take a look at
main()- I have been very carefull to layout the way the tool operates in a very linear way but ther lists are global, so sharing data between the shell stages will be a pain (pipes?)
Bash can do locals ;-)
Quoted 52 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 27 lines
tools/mkinitseq.c new file +22
-0+/* +* (C) Copyright 2012 +* Graeme Russ <[email protected]> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/** +* container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */tools/mkinitseq.c line 30
Quoted 3 lines
tools/mkinitseq.c new file +3
-0+#define container_of (ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );})Don't we already have this defined in uboot ?
Quoted 6 lines
Quoted 4 lines
mkinitseq is host-code so it only brings in host headers (not U-Boot headers) - If you don't have Linux kernel headers installed, you can't get this macro. Actually, even though I do have them, I had a hard time getting this macro in, so I gave up - Any hints?
Reimplement this thing in shell :-)
You already know my answer to this ;)
Quoted 4 lines
Quoted 2 lines
As an aside, I wonder if the kernel headers are required for the list macros?
Nope.
Good :)
Regards,
Graeme
PATCH 2/3 init_func: Add x86 support
In reply to Graeme Russ--- arch/x86/cpu/u-boot.lds | 23 +++++++++++++++++++++++ arch/x86/lib/board.c | 10 +++------- 2 files changed, 26 insertions(+), 7 deletions(-)
arch/x86/cpu/u-boot.lds +23 -0
@@ -28,6 +28,27 @@ ENTRY(_start) SECTIONS { +#ifdef MAKE_INIT_LDS + .initfuncs : { KEEP(*(.initfuncs*)) } + + /DISCARD/ : { *(.text*) } + /DISCARD/ : { *(.debug*) } + /DISCARD/ : { *(.u_boot_cmd*) } + /DISCARD/ : { *(.rodata*) } + /DISCARD/ : { *(.data*) } + /DISCARD/ : { *(.dynsym*) } + /DISCARD/ : { *(.hash*) } + /DISCARD/ : { *(.bss*) } + /DISCARD/ : { *(.bss) } + /DISCARD/ : { *(.rel.dyn*) } + /DISCARD/ : { *(.rel.dyn) } + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.comment*) } +#else . = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */ __text_start = .; .text : { *(.text*); }
@@ -72,6 +93,7 @@ SECTIONS /DISCARD/ : { *(.plt*) } /DISCARD/ : { *(.interp*) } /DISCARD/ : { *(.gnu*) } + /DISCARD/ : { *(.initfuncs*) } /* 16bit realmode trampoline code */ .realmode REALMODE_BASE : AT ( LOADADDR(.rel.dyn) + SIZEOF(.rel.dyn) ) { KEEP(*(.realmode)) }
@@ -94,4 +116,5 @@ SECTIONS . = RESET_VEC_LOC; .resetvec : AT (CONFIG_SYS_TEXT_BASE + (CONFIG_SYS_MONITOR_LEN - RESET_SEG_SIZE + RESET_VEC_LOC)) { KEEP(*(.resetvec)); } +#endif }
arch/x86/lib/board.c +3 -7
@@ -32,6 +32,7 @@*/ #include <common.h> +#include <init_func.h> #include <watchdog.h> #include <stdio_dev.h> #include <asm/u-boot-x86.h>
@@ -77,13 +78,7 @@* - All remaining initialisation */ -/* -* The requirements for any new initalization function is simple: it is -* a function with no parameters which returns an integer return code, -* where 0 means "continue" and != 0 means "fatal error, hang the system" -*/ -typedef int (init_fnc_t ) (void ); - +#ifndef CONFIG_INIT_FUNC /* * init_sequence_f is the list of init functions which are run when U-Boot * is executing from Flash with a limited 'C' environment. The following
@@ -206,6 +201,7 @@ init_fnc_t *init_sequence_r[] = {#endif NULL, }; +#endif static void do_init_loop (init_fnc_t **init_fnc_ptr) {
Signature · 1 line
1.7.7.6
PATCH 3/3 init_func: Use for eNET board
In reply to Graeme Russ--- arch/x86/cpu/cpu.c | 3 +++ arch/x86/cpu/sc520/sc520_sdram.c | 3 +++ arch/x86/cpu/sc520/sc520_timer.c | 2 ++ arch/x86/lib/init_helpers.c | 14 ++++++++++++++ arch/x86/lib/init_wrappers.c | 11 ++++++++++- arch/x86/lib/pcat_interrupts.c | 2 ++ arch/x86/lib/relocate.c | 4 ++++ board/eNET/eNET.c | 5 +++++ common/console.c | 3 +++ common/env_dataflash.c | 1 + common/env_eeprom.c | 1 + common/env_fat.c | 1 + common/env_flash.c | 2 ++ common/env_mgdisk.c | 1 + common/env_mmc.c | 1 + common/env_nand.c | 1 + common/env_nowhere.c | 1 + common/env_nvram.c | 1 + common/env_onenand.c | 1 + common/env_sf.c | 1 + common/serial.c | 2 ++ common/stdio.c | 2 ++ include/configs/eNET.h | 1 + 23 files changed, 63 insertions(+), 1 deletions(-)
arch/x86/cpu/cpu.c +3 -0
@@ -33,6 +33,7 @@*/ #include <common.h> +#include <init_func.h> #include <command.h> #include <asm/processor.h> #include <asm/processor-flags.h>
@@ -137,6 +138,7 @@ int x86_cpu_init_f(void)return 0 ; }int cpu_init_f (void ) __attribute__((weak,alias ("x86_cpu_init_f" ))); +INIT_FUNC(cpu_init_f, cpu_f, RESET, , SDRAM);int x86_cpu_init_r (void ) {
@@ -145,6 +147,7 @@ int x86_cpu_init_r(void)return 0 ; }int cpu_init_r (void ) __attribute__((weak,alias ("x86_cpu_init_r" ))); +INIT_FUNC(cpu_init_r, cpu_r, mem_malloc_init_r, , );void x86_enable_caches (void ) {
arch/x86/cpu/sc520/sc520_sdram.c +3 -0
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <init_func.h> #include <asm/io.h> #include <asm/processor-flags.h> #include <asm/arch/sc520.h>
@@ -51,6 +52,7 @@ int dram_init_f(void)return 0 ; } +INIT_FUNC(dram_init_f, dram_f, console_init_f, , SDRAM);static inline void sc520_dummy_write (void ) {
@@ -477,3 +479,4 @@ int dram_init(void)return 0 ; } +INIT_FUNC(dram_init, dram_r, , board_early_init_r, );
arch/x86/cpu/sc520/sc520_timer.c +2 -0
@@ -25,6 +25,7 @@*/ #include <common.h> +#include <init_func.h> #include <asm/io.h> #include <asm/interrupt.h> #include <asm/arch/sc520.h>
@@ -69,6 +70,7 @@ int timer_init(void)return 0 ; } +INIT_FUNC(timer_init, timer, interrupt_init, , );/* Allow boards to override udelay implementation */ void __udelay (unsigned long usec)
arch/x86/lib/init_helpers.c +14 -0
@@ -21,6 +21,7 @@* MA 02111-1307 USA */ #include <common.h> +#include <init_func.h> #include <command.h> #include <stdio_dev.h> #include <version.h>
@@ -50,6 +51,7 @@ int display_banner(void)return 0 ; } +INIT_FUNC(display_banner, banner, timer_init, , );int display_dram_config (void ) {
@@ -64,12 +66,14 @@ int display_dram_config(void)return 0 ; } +INIT_FUNC(display_dram_config, display_dram, display_banner, , );int init_baudrate_f (void ) { gd->baudrate =getenv_ulong ("baudrate" ,10 ,CONFIG_BAUDRATE );return 0 ; } +INIT_FUNC(init_baudrate_f, display_dram, env_init, , );int calculate_relocation_address (void ) {
@@ -106,6 +110,7 @@ int calculate_relocation_address(void)return 0 ; } +INIT_FUNC(calculate_relocation_address, calc_reloc, dram_init_f, , );int copy_gd_to_ram_f_r (void ) {
@@ -131,12 +136,14 @@ int copy_gd_to_ram_f_r(void)return 0 ; } +INIT_FUNC(copy_gd_to_ram_f_r, copy_gd, SDRAM, , RELOC);int init_cache_f_r (void ) {/* Initialise the CPU cache(s) */ return init_cache (); } +INIT_FUNC(init_cache_f_r, cache_f_r, copy_gd_to_ram_f_r, , RELOC);int set_reloc_flag_r (void ) {
@@ -144,6 +151,7 @@ int set_reloc_flag_r(void)return 0 ; } +INIT_FUNC(set_reloc_flag_r, reloc_flag, RELOC, , );int mem_malloc_init_r (void ) {
@@ -152,6 +160,7 @@ int mem_malloc_init_r(void)return 0 ; } +INIT_FUNC(mem_malloc_init_r, malloc, init_bd_struct_r, , );bd_t bd_data;
@@ -162,6 +171,7 @@ int init_bd_struct_r(void)return 0 ; } +INIT_FUNC(init_bd_struct_r, bd_struct, set_reloc_flag_r, , );#ifndef CONFIG_SYS_NO_FLASH int flash_init_r (void )
@@ -177,6 +187,7 @@ int flash_init_r(void)return 0 ; } +INIT_FUNC(flash_init_r, flash_r, RELOC, serial_initialize_r display_dram_config, );#endif int init_ip_address_r (void )
@@ -186,6 +197,7 @@ int init_ip_address_r(void)return 0 ; } +INIT_FUNC(init_ip_address_r, ip_address, env_relocate_r, , pci_init_r stdio_init);#ifdef CONFIG_STATUS_LED int status_led_set_r (void )
@@ -207,6 +219,7 @@ int set_bootfile_r(void)return 0 ; } +INIT_FUNC(set_bootfile_r, set_bootfile, set_load_addr_r, , );int set_load_addr_r (void ) {
@@ -215,3 +228,4 @@ int set_load_addr_r(void)return 0 ; } +INIT_FUNC(set_load_addr_r, set_load_addr, enable_interrupts_r, , );
arch/x86/lib/init_wrappers.c +10 -1
@@ -21,6 +21,7 @@* MA 02111-1307 USA */ #include <common.h> +#include <init_func.h> #include <serial.h> #include <kgdb.h> #include <scsi.h>
@@ -35,6 +36,7 @@ int serial_initialize_r(void)return 0 ; } +INIT_FUNC(serial_initialize_r, serial_multi, RELOC, display_dram_config, );int env_relocate_r (void ) {
@@ -43,7 +45,7 @@ int env_relocate_r(void)return 0 ; } - +INIT_FUNC(env_relocate_r, env_reloc, RELOC env_init, display_dram_config serial_initialize_r flash_init_r, );int pci_init_r (void ) {
@@ -52,6 +54,7 @@ int pci_init_r(void)return 0 ; } +INIT_FUNC(pci_init_r, pci, cpu_r, init_ip_address_r env_relocate_r, stdio_init);int jumptable_init_r (void ) {
@@ -59,6 +62,7 @@ int jumptable_init_r(void)return 0 ; } +INIT_FUNC(jumptable_init_r, jumptable, stdio_init, , );int pcmcia_init_r (void ) {
@@ -83,6 +87,7 @@ int enable_interrupts_r(void)return 0 ; } +INIT_FUNC(enable_interrupts_r, enable_interrupts, , kgdb_init_r pci_init_r misc_init_r console_init_r, );int eth_initialize_r (void ) {
@@ -91,7 +96,9 @@ int eth_initialize_r(void)return 0 ; } +INIT_FUNC(eth_initialize_r, eth, pci, bb_miiphy_init_r doc_init_r scsi_init_r ide_init_r set_bootfile_r set_load_addr_r, ); +#ifdef CONFIG_RESET_PHY_R int reset_phy_r (void ) {#ifdef DEBUG
@@ -101,6 +108,8 @@ int reset_phy_r(void)return 0 ; } +INIT_FUNC(reset_phy_r, phy_reset, eth, eth_initialize_r, ); +#endif int ide_init_r (void ) {
arch/x86/lib/pcat_interrupts.c +2 -0
@@ -31,6 +31,7 @@*/ #include <common.h> +#include <init_func.h> #include <asm/io.h> #include <asm/i8259.h> #include <asm/ibmpc.h>
@@ -82,6 +83,7 @@ int interrupt_init(void)return 0 ; } +INIT_FUNC(interrupt_init, pcat_interrupt, , dram_init, );void mask_irq (int irq) {
arch/x86/lib/relocate.c +4 -0
@@ -32,6 +32,7 @@*/ #include <common.h> +#include <init_func.h> #include <malloc.h> #include <asm/u-boot-x86.h> #include <asm/relocate.h>
@@ -45,6 +46,7 @@ int copy_uboot_to_ram(void)return 0 ; } +INIT_FUNC (copy_uboot_to_ram, copy_to_ram,SDRAM , init_cache_f_r,RELOC );int clear_bss (void ) {
@@ -55,6 +57,7 @@ int clear_bss(void)return 0 ; } +INIT_FUNC (clear_bss, clear_bss,SDRAM , copy_uboot_to_ram,RELOC );int do_elf_reloc_fixups (void ) {
@@ -89,3 +92,4 @@ int do_elf_reloc_fixups(void)return 0 ; } +INIT_FUNC(do_elf_reloc_fixups, elf_reloc, clear_bss, , RELOC);
board/eNET/eNET.c +5 -0
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <init_func.h> #include <asm/io.h> #include <asm/arch/sc520.h> #include <net.h>
@@ -106,6 +107,7 @@ int board_early_init_f(void)return 0 ; } +INIT_FUNC(board_early_init_f, board_early_f, cpu_init_f, , SDRAM);static void enet_setup_pars (void ) {
@@ -161,6 +163,7 @@ int board_early_init_r(void)return 0 ; } +INIT_FUNC(board_early_init_r, board_early_r, cpu_init_r, , pci);void show_boot_progress (int val) {
@@ -186,6 +189,8 @@ int last_stage_init(void)return 0 ; } +INIT_FUNC(last_stage_init, last_stage, , eth_initialize_r reset_phy_r, ); +ulong board_flash_get_legacy (ulong base,int banknum,flash_info_t *info) {
common/console.c +3 -0
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <init_func.h> #include <stdarg.h> #include <malloc.h> #include <stdio_dev.h>
@@ -588,6 +589,7 @@ int console_init_f(void)return 0 ; } +INIT_FUNC(console_init_f, console_f, serial_init, , SDRAM);void stdio_print_current_devices (void ) {
@@ -775,5 +777,6 @@ int console_init_r(void)return 0 ; } +INIT_FUNC(console_init_r, console_r, stdio_init, jumptable_init_r, );#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
common/env_dataflash.c +1 -0
@@ -114,3 +114,4 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/env_eeprom.c +1 -0
@@ -289,3 +289,4 @@ int env_init(void) return 0; }#endif +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/env_fat.c +1 -0
@@ -53,6 +53,7 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );#ifdef CONFIG_CMD_SAVEENV int saveenv (void )
common/env_flash.c +2 -0
@@ -27,6 +27,7 @@/* #define DEBUG */ #include <common.h> +#include <init_func.h> #include <command.h> #include <environment.h> #include <linux/stddef.h>
@@ -117,6 +118,7 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );#ifdef CMD_SAVEENV int saveenv (void )
common/env_mgdisk.c +1 -0
@@ -74,3 +74,4 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/env_mmc.c +1 -0
@@ -62,6 +62,7 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );static int init_mmc_for_env (struct mmc *mmc) {
common/env_nand.c +1 -0
@@ -134,6 +134,7 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );#ifdef CMD_SAVEENV /*
common/env_nowhere.c +1 -0
@@ -49,3 +49,4 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/env_nvram.c +1 -0
@@ -134,3 +134,4 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/env_onenand.c +1 -0
@@ -135,3 +135,4 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/env_sf.c +1 -0
@@ -349,3 +349,4 @@ int env_init(void)return 0 ; } +INIT_FUNC (env_init, env_init, cpu_init_f, board_early_init_f,SDRAM );
common/serial.c +2 -0
@@ -22,6 +22,7 @@*/ #include <common.h> +#include <init_func.h> #include <serial.h> #include <stdio_dev.h> #include <post.h>
@@ -190,6 +191,7 @@ int serial_init(void) {return get_current ()->init (); } +INIT_FUNC(serial_init, serial_f, init_baudrate_f, , SDRAM);void serial_setbrg (void ) {
common/stdio.c +2 -0
@@ -22,6 +22,7 @@*/ #include <config.h> +#include <init_func.h> #include <common.h> #include <stdarg.h> #include <malloc.h>
@@ -242,3 +243,4 @@ int stdio_init (void)return (0 ); } +INIT_FUNC(stdio_init, stdio, env_relocate_r, , );
include/configs/eNET.h +1 -0
@@ -29,6 +29,7 @@#ifndef __CONFIG_H#define __CONFIG_H +#define CONFIG_INIT_FUNC /* * High Level Configuration Options * (easy to change)
Signature · 1 line
1.7.7.6
cover Initialisation Sequence Framework
In reply to Graeme RussDear Graeme Russ,
Quoted 7 lines
Well here it is (finally) - My Initialisation Sequence Framework
This series is limited to x86 and is controlled by
CONFIG_INIT_FUNCso no other arch should be effected. I don't have any cross compilers, so I would appreciate if others could confirm the zero impact assertionAsbestos suit on
Oh this is gonna be the flamewar of the year now :-E~
Gasoline ready, asbestos pants - check, flamethrower on ... let's go!
) ( ( (
( ) () @@ ) (( (
( ( )( @@ ( )) ) (
( ( ( ()( /---\ (()( (
_______ ) ) )(@ !O O! )@@ ( ) ) )
< ____) ) ( ( )( ()@ \ o / (@@@@@ ( ()( )
/--| |( o| ( ) ) ((@@(@@ !o! @@@@(@@@@@)() (
| > \___| ) ( @)@@)@ /---\-/---\ )@@@@@()( )
| /---------+ (@@@@)@@@( // /-----\ \\ @@@)@@@@@( .
| | \ =========______/|@@@@@@@@@@@@@(@@@ // @ /---\ @ \\ @(@@@(@@@ . .
| \ \\=========------\|@@@@@@@@@@@@@@@@@ O @@@ /-\ @@@ O @@(@@)@@ @ .
| \ \----+--\-))) @@@@@@@@@@ !! @@@@ % @@@@ !! @@)@@@ .. .
| |\______|_)))/ . @@@@@@ !! @@ /---\ @@ !! @@(@@@ @ . .
\__========== * . @@ /MM /\O O/\ MM\ @@@@@@@. .
| |-\ \ ( . @ !!! !! \-/ !! !!! @@@@@ .
| | \ \ ) . . @@@@ !! !! .(. @. .. .
| | \ \ ( / .( . \)). ( |O )( O! @@@@ . ) .
| | / / ) ( )). (( .) !! ((( !! @@ (. ((. . .
| | / / () )) )) .( ( ( ) ). ( !! )( !! ) (( )) ..
| |_< / ( ) ( ( ) ) (( ) )).) ((/ | ( | \( )) ((. ).____<_____\\__\__(___)_))_((_(____))__(_(___.oooO_____Oooo.(_(_)_)((_
Artist: P.r.i.m.a.l
Borrowed from: http://www.ascii-art.de/ascii/def/flamethrower.txt
Copyright ? 1997-2004 Andreas Freise
Quoted 40 lines
Fire away ;)
Regards,
Graeme
Graeme Russ (3):
init_func: Add fundamental framework
init_func: Add x86 support
init_func: Use for eNET boardMakefile | 34 +- arch/x86/cpu/cpu.c | 3 + arch/x86/cpu/sc520/sc520_sdram.c | 3 + arch/x86/cpu/sc520/sc520_timer.c | 2 + arch/x86/cpu/u-boot.lds | 23 + arch/x86/lib/board.c | 10 +- arch/x86/lib/init_helpers.c | 14 + arch/x86/lib/init_wrappers.c | 11 +- arch/x86/lib/pcat_interrupts.c | 2 + arch/x86/lib/relocate.c | 4 + board/eNET/eNET.c | 5 + common/Makefile | 2 + common/console.c | 3 + common/env_dataflash.c | 1 + common/env_eeprom.c | 1 + common/env_fat.c | 1 + common/env_flash.c | 2 + common/env_mgdisk.c | 1 + common/env_mmc.c | 1 + common/env_nand.c | 1 + common/env_nowhere.c | 1 + common/env_nvram.c | 1 + common/env_onenand.c | 1 + common/env_sf.c | 1 + common/serial.c | 2 + common/stdio.c | 2 + config.mk | 2 + doc/README.INIT_FUNC | 65 ++ include/configs/eNET.h | 1 +
Quoted 8 lines
include/init_func.h | 37 + tools/Makefile | 6 + tools/mkinitseq.c | 1512 ++++++++++++++++++++++++++++++++++++++ 32 files changed, 1746 insertions(+), 9 deletions(-) create mode 100644 doc/README.INIT_FUNC create mode 100644 include/init_func.h create mode 100644 tools/mkinitseq.c
Best regards,
Marek Vasut