cmd_mem.c: add a memory wait (mwait) command
PATCH 1/4 cmd_mem.c: add a memory wait (mwait) command
From: Aurelien Jacquiot <[email protected]>
This new memory command allows to wait a given value in memory. It can be useful when U-Boot is used in a slave mode (another device is pushing images to the local memory) such as RapidIO or any RDMA kind of transport. We can then be notified that images have been loaded to our memory before booting.
Usage is: mwait[.b, .w, .l, .q] address value
--- common/cmd_mem.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-)
common/cmd_mem.c +69 -0
@@ -1238,6 +1238,65 @@ static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#endif +static int +do_mem_mwait (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +ulong addr; +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA +u64 val, readval; +#else +ulong val, readval; +#endif +int size; + +if (argc !=3 ) +return CMD_RET_USAGE ; + +/* check for size specification */ + size =cmd_get_data_size (argv[0 ],4 ); +if (size <1 ) +return 1 ; + +/* first arg: address */ + addr =simple_strtoul (argv[1 ],NULL ,16 ); + +/* second arg: expected value */ +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + val =simple_strtoull (argv[2 ],NULL ,16 ); +printf ("waiting 0x%llx at 0x%lx...\n" , val, addr); +#else + val =simple_strtoul (argv[2 ],NULL ,16 ); +printf ("waiting 0x%lx@0x%lx...\n" , val, addr); +#endif + +for (;;) { +if (size ==4 ) + readval = *((u32 *)addr); +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + else if (size == 8) + readval = *((u64 *)addr); +#endif + else if (size == 2) + readval = *((u16 *)addr); + else + readval = *((u8 *)addr); + +if (readval == val) +return 0 ; + +/* check for ctrl-c to abort... */ +if (ctrlc ()) { +puts ("Abort\n" ); +return 0 ; + } + +WATCHDOG_RESET (); +udelay (1000 ); + } + +return 0 ; +} +/**************************************************/ U_BOOT_CMD( md, 3, 1, do_mem_md,
@@ -1399,6 +1458,16 @@ U_BOOT_CMD( );#endif /* CONFIG_MX_CYCLIC */ +U_BOOT_CMD ( + mwait,3 ,1 , do_mem_mwait, +"memory wait for value" , +#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA + "[.b, .w, .l, .q] address value\n" +#else +"[.b, .w, .l] address value\n" +#endif +); +#ifdef CONFIG_CMD_MEMINFO U_BOOT_CMD( meminfo, 3, 1, do_mem_info,
Signature · 1 line
1.6.2.1
PATCH 1/4 cmd_mem.c: add a memory wait (mwait) command
Quoted 9 lines · jacquiot.aurelien at gmail.com
From: Aurelien Jacquiot <[email protected]>
This new memory command allows to wait a given value in memory. It can be useful when U-Boot is used in a slave mode (another device is pushing images to the local memory) such as RapidIO or any RDMA kind of transport. We can then be notified that images have been loaded to our memory before booting.
Usage is: mwait[.b, .w, .l, .q] address value
First, we need to add a new CONFIG_CMD_MWAIT (and Kconfig entry) for this. Second:
common/cmd_mem.c static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 1294
Quoted 2 lines
common/cmd_mem.c +2
-0+WATCHDOG_RESET (); +udelay (1000 );
Lets use 100 here not 1000, after looking at how long we wait during 'sleep' which is this an equivalent of. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160104/3d2a9cd3/attachment.sig>