[U-Boot-Users] Adding new commands

Tolunay Orkun
2006-10-16T20:45:56Z

Wolfgang Denk wrote:
> In message <453368A1.5050407@dave-tech.it> you wrote:
>> I have to add two new commands so I have to add something like this to
>> cmd_confdefs.h:
>>
>> #define CFG_CMD_NEW1 0x8000000000000000ULL
>> #define CFG_CMD_NEW2 ???
>>
>> IIUC we have 64 bits available for the commands and 63 commands are
>> already defined. So how to define more than 64 commands?
>
> We have to rework this whole configuration setup. At the moment I
> don't have a good and quick solution available.
>

One possibility is to get rid of existing bitmap scheme. A
cmd_defaults.h would define all default CFG_COMMAND_XXX. And board
configs would add remove commands by defining more or remove from
defaults by undefining the corresponding macros after the inclusion of
cmd_defaults.h.

Another quick solution would be to use Most Significant Bit as an
expansion flag and use up to 63 more commands via CONFIG_COMMANDS2 macro.

The test logic will need to be modified but it could be wrapped to a
macro like:

Instead of this:

#if (CONFIG_COMMANDS & CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
#include <rtc.h>
#endif

Use this:

#if IS_CONFIG_COMMAND(CFG_CMD_DATE) || defined(CONFIG_TIMESTAMP)
#include <rtc.h>
#endif

And IS_CONFIG_COMMAND macro defined something like:

#define IS_CONFIG_COMMAND(x) ((x) & 0x8000000000000000ULL) ? \
((x) & CONFIG_COMMANDS2) | \
((x) & CONFIG_COMMANDS))

And if we get to 63+62=126 commands we can use next to MSB in
CONFIG_COMMANDS2 as another expansion bit along with CONFIG_COMMANDS3
(if we ever get that far).

Actually we do not even need to modify the existing (CONFIG_COMMAND &
....) but any new configuration options needs to test for enabling via
the new macro.

Best regards,
Tolunay