-
Notifications
You must be signed in to change notification settings - Fork 8.4k
shell: modules: devmem: streamline the codebase #98437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shell: modules: devmem: streamline the codebase #98437
Conversation
To improve code clarity, use `shell_print` in place of `shell_fprintf` with `SHELL_NORMAL` where appropriate. Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
| hex_data[data_offset] = (uint8_t)value; | ||
| value >>= 8; | ||
| hex_data[data_offset + 1] = (uint8_t)value; | ||
| sys_put_be16(value, &hex_data[data_offset]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static inline void sys_put_be16(uint16_t val, uint8_t dst[2])
{
dst[0] = val >> 8;
dst[1] = val;
}You probably should use sys_put_le16() to maintain the same endianness?
static inline void sys_put_le16(uint16_t val, uint8_t dst[2])
{
dst[0] = val;
dst[1] = val >> 8;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for my misinterpretation. It seems that devmem dump will always output memory in Little-Endian byte order, regardless of the underlying architecture. The correct one is as follows:
case 16:
value = sys_read16(addr + data_offset);
sys_put_le16(value, &hex_data[data_offset]);
break;
case 32:
value = sys_read32(addr + data_offset);
sys_put_le32(value, &hex_data[data_offset]);
break;
#ifdef CONFIG_64BIT
case 64:
value = sys_read64(addr + data_offset);
sys_put_le64(value, &hex_data[data_offset]);
break;
#endif /* CONFIG_64BIT */| break; | ||
| case 16: | ||
| value = sys_le16_to_cpu(sys_read16(addr + data_offset)); | ||
| value = sys_read16(addr + data_offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should add big endian support for this shell command instead of converting it to big endian?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should add big endian support for this shell command instead of converting it to big endian?
Thanks for the suggestion! For now, I'm focusing on streamlining the existing codebase, so I'll hold off on adding big-endian support in this PR.
Replaces direct byte shifting and assignment with `sys_put_le16`, `sys_put_le32`, and `sys_put_le64` to simplify the `memory_dump` function. Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
bf9176d to
44a2a2b
Compare
|
|
Ping @ycsin. |
ycsin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks



This PR is dedicated to improving
devmem_service.cthrough the following commits:shell_printwhere applicablesys_put_le(16|32|64)inmemory_dump