Re: [PATCH 06/10] ratp: implement generic command support
On Tue, Feb 06, 2018 at 05:49:10PM +0100, Aleksander Morgado wrote: > >> + > >> +#define BAREBOX_RATP_CMD_START(_name) > >>\ > >> +extern const struct ratp_command __barebox_cmd_##_name; > >>\ > > > > You shouldn't use the same name as the existing barebox commands, > > otherwise there might be name clashes. Add some _ratp_ to it. > > > > Ah, sure. > > >> +const struct ratp_command __barebox_cmd_##_name > >>\ > >> + __attribute__ ((unused,section (".barebox_ratp_cmd_" > >> __stringify(_name = { \ > >> + .id = BB_RATP_TYPE_##_name, > > > > I am not sure if I like the magic construction of the id field. Being > > able to grep for BB_RATP_TYPE_PING and finding the user has advantages. > > How about manually setting the field in the body of the command instead > > of constructing it? > > > > You mean doing this instead? > > BAREBOX_RATP_CMD_START(PING) > .cmd = ratp_cmd_ping, > .id = BB_RATP_TYPE_PING > BAREBOX_RATP_CMD_END Yes, that's what I meant. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 06/10] ratp: implement generic command support
>> + >> +#define BAREBOX_RATP_CMD_START(_name) >> \ >> +extern const struct ratp_command __barebox_cmd_##_name; >> \ > > You shouldn't use the same name as the existing barebox commands, > otherwise there might be name clashes. Add some _ratp_ to it. > Ah, sure. >> +const struct ratp_command __barebox_cmd_##_name >> \ >> + __attribute__ ((unused,section (".barebox_ratp_cmd_" >> __stringify(_name = { \ >> + .id = BB_RATP_TYPE_##_name, > > I am not sure if I like the magic construction of the id field. Being > able to grep for BB_RATP_TYPE_PING and finding the user has advantages. > How about manually setting the field in the body of the command instead > of constructing it? > You mean doing this instead? BAREBOX_RATP_CMD_START(PING) .cmd = ratp_cmd_ping, .id = BB_RATP_TYPE_PING BAREBOX_RATP_CMD_END -- Aleksander https://aleksander.es ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 06/10] ratp: implement generic command support
On Fri, Feb 02, 2018 at 12:14:38PM +0100, Aleksander Morgado wrote: > The RATP implementation now allows executing generic commands with a > binary interface: binary requests are received and binary responses > are returned. > > Each command can define its own RATP request contents (e.g. to specify > command-specific options) as well as its own RATP response contents > (if any data is to be returned). > > Each command is associated with a numeric unique command ID, and for > easy reference these IDs are maintained in the common ratp_bb header. > Modules may override generic implemented commands or include their own > new ones (as long as the numeric IDs introduced are unique). > > Signed-off-by: Aleksander Morgado > --- > @@ -11,4 +29,33 @@ void barebox_ratp_command_run(void); > int barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx); > int barebox_ratp_fs_mount(const char *path); > > +/* > + * RATP commands definition > + */ > + > +struct ratp_command { > + struct list_head list; > + uint16_t id; > + int (*cmd)(const struct ratp_bb *req, > +int req_len, > +struct ratp_bb **rsp, > +int *rsp_len); > +} > +#ifdef __x86_64__ > +/* This is required because the linker will put symbols on a 64 bit > alignment */ > +__attribute__((aligned(64))) > +#endif > +; > + > +#define BAREBOX_RATP_CMD_START(_name) > \ > +extern const struct ratp_command __barebox_cmd_##_name; > \ You shouldn't use the same name as the existing barebox commands, otherwise there might be name clashes. Add some _ratp_ to it. > +const struct ratp_command __barebox_cmd_##_name > \ > + __attribute__ ((unused,section (".barebox_ratp_cmd_" > __stringify(_name = { \ > + .id = BB_RATP_TYPE_##_name, I am not sure if I like the magic construction of the id field. Being able to grep for BB_RATP_TYPE_PING and finding the user has advantages. How about manually setting the field in the body of the command instead of constructing it? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0| Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 06/10] ratp: implement generic command support
The RATP implementation now allows executing generic commands with a binary interface: binary requests are received and binary responses are returned. Each command can define its own RATP request contents (e.g. to specify command-specific options) as well as its own RATP response contents (if any data is to be returned). Each command is associated with a numeric unique command ID, and for easy reference these IDs are maintained in the common ratp_bb header. Modules may override generic implemented commands or include their own new ones (as long as the numeric IDs introduced are unique). Signed-off-by: Aleksander Morgado --- arch/arm/lib32/barebox.lds.S | 4 + arch/arm/lib64/barebox.lds.S | 4 + arch/blackfin/boards/ipe337/barebox.lds.S | 5 +- arch/mips/lib/barebox.lds.S | 4 + arch/nios2/cpu/barebox.lds.S | 5 +- arch/openrisc/cpu/barebox.lds.S | 4 + arch/ppc/boards/pcm030/barebox.lds.S | 4 + arch/ppc/mach-mpc85xx/barebox.lds.S | 4 + arch/sandbox/board/barebox.lds.S | 5 + arch/x86/lib/barebox.lds.S| 7 + arch/x86/mach-efi/elf_ia32_efi.lds.S | 5 + arch/x86/mach-efi/elf_x86_64_efi.lds.S| 5 + common/module.lds.S | 2 + common/ratp.c | 255 ++ include/asm-generic/barebox.lds.h | 2 + include/ratp_bb.h | 47 ++ 16 files changed, 258 insertions(+), 104 deletions(-) diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S index e7b87b7cd..6fadc2a35 100644 --- a/arch/arm/lib32/barebox.lds.S +++ b/arch/arm/lib32/barebox.lds.S @@ -85,6 +85,10 @@ SECTIONS .barebox_cmd : { BAREBOX_CMDS } __barebox_cmd_end = .; + __barebox_ratp_cmd_start = .; + .barebox_ratp_cmd : { BAREBOX_RATP_CMDS } + __barebox_ratp_cmd_end = .; + __barebox_magicvar_start = .; .barebox_magicvar : { BAREBOX_MAGICVARS } __barebox_magicvar_end = .; diff --git a/arch/arm/lib64/barebox.lds.S b/arch/arm/lib64/barebox.lds.S index 240699f1a..a53b933bb 100644 --- a/arch/arm/lib64/barebox.lds.S +++ b/arch/arm/lib64/barebox.lds.S @@ -82,6 +82,10 @@ SECTIONS .barebox_cmd : { BAREBOX_CMDS } __barebox_cmd_end = .; + __barebox_ratp_cmd_start = .; + .barebox_ratp_cmd : { BAREBOX_RATP_CMDS } + __barebox_ratp_cmd_end = .; + __barebox_magicvar_start = .; .barebox_magicvar : { BAREBOX_MAGICVARS } __barebox_magicvar_end = .; diff --git a/arch/blackfin/boards/ipe337/barebox.lds.S b/arch/blackfin/boards/ipe337/barebox.lds.S index 51a586af2..7e82a1bd7 100644 --- a/arch/blackfin/boards/ipe337/barebox.lds.S +++ b/arch/blackfin/boards/ipe337/barebox.lds.S @@ -68,6 +68,10 @@ SECTIONS .barebox_cmd : { BAREBOX_CMDS } ___barebox_cmd_end = .; + ___barebox_ratp_cmd_start = .; + .barebox_ratp_cmd : { BAREBOX_RATP_CMDS } + ___barebox_ratp_cmd_end = .; + ___barebox_magicvar_start = .; .barebox_magicvar : { BAREBOX_MAGICVARS } ___barebox_magicvar_end = .; @@ -91,4 +95,3 @@ SECTIONS ___bss_stop = .; _end = .; } - diff --git a/arch/mips/lib/barebox.lds.S b/arch/mips/lib/barebox.lds.S index 899f62b96..660d4be85 100644 --- a/arch/mips/lib/barebox.lds.S +++ b/arch/mips/lib/barebox.lds.S @@ -55,6 +55,10 @@ SECTIONS .barebox_cmd : { BAREBOX_CMDS } __barebox_cmd_end = .; + __barebox_ratp_cmd_start = .; + .barebox_ratp_cmd : { BAREBOX_RATP_CMDS } + __barebox_ratp_cmd_end = .; + __barebox_magicvar_start = .; .barebox_magicvar : { BAREBOX_MAGICVARS } __barebox_magicvar_end = .; diff --git a/arch/nios2/cpu/barebox.lds.S b/arch/nios2/cpu/barebox.lds.S index a2d7fa8cd..fbcd1cd3f 100644 --- a/arch/nios2/cpu/barebox.lds.S +++ b/arch/nios2/cpu/barebox.lds.S @@ -55,6 +55,10 @@ SECTIONS .barebox_cmd : { BAREBOX_CMDS } __barebox_cmd_end = .; + __barebox_ratp_cmd_start = .; + .barebox_ratp_cmd : { BAREBOX_RATP_CMDS } + __barebox_ratp_cmd_end = .; + __barebox_magicvar_start = .; .barebox_magicvar : { BAREBOX_MAGICVARS } __barebox_magicvar_end = .; @@ -129,4 +133,3 @@ SECTIONS _end = .; PROVIDE (end = .); } - diff --git a/arch/openrisc/cpu/barebox.lds.S b/arch/openrisc/cpu/barebox.lds.S index b819ca099..c6807aec3 100644 --- a/arch/openrisc/cpu/barebox.lds.S +++ b/arch/openrisc/cpu/barebox.lds.S @@ -57,6 +57,10 @@ SECTIONS .barebox_cmd : { BAREBOX_CMDS } > ram __barebox_cmd_end = .; + __barebox_ratp_cmd_start = .; + .barebox_ratp_cmd : { BAREBOX_RATP_CMDS } > ram + __barebox_ratp_cmd_end = .; + __barebox_magicvar_start = .; .barebox_magicvar : { BAREBOX_MAGICVARS } > ram __barebox_magicvar_end = .; diff --git a/arch/ppc/boards/pcm030/barebox.lds.S