Skip to content

Commit

Permalink
fs/ioctl:add FIOC_XIPBASE to get file xip address
Browse files Browse the repository at this point in the history
in tmpfs/romfs, we can get file real xip address to execute program

Signed-off-by: anjiahao <[email protected]>
  • Loading branch information
anjiahao1 committed Sep 30, 2024
1 parent 02c292a commit 7d55679
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions fs/romfs/fs_romfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,21 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
strlcat(ptr, rf->rf_path, PATH_MAX);
return OK;
}
else if (cmd == FIOC_XIPBASE)
{
FAR struct romfs_mountpt_s *rm = filep->f_inode->i_private;
FAR uintptr_t *ptr = (FAR uintptr_t *)arg;

if (rm->rm_xipbase != 0)
{
*ptr = (uintptr_t)rm->rm_xipbase + rf->rf_startoffset;
return OK;
}
else
{
return -ENXIO;
}
}

return -ENOTTY;
}
Expand Down
7 changes: 7 additions & 0 deletions fs/tmpfs/fs_tmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,13 @@ static int tmpfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
return ret;
}
}
else if (cmd == FIOC_XIPBASE)
{
FAR uintptr_t *ptr = (FAR uintptr_t *)arg;

*ptr = (uintptr_t)tfo->tfo_data;
return OK;
}

return ret;
}
Expand Down
3 changes: 3 additions & 0 deletions include/nuttx/fs/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
#define FIOC_SETLKW _FIOC(0x0014) /* IN: Pointer to flock
* OUT: None
*/
#define FIOC_XIPBASE _FIOC(0x0015) /* IN: uinptr_t *
* OUT: Current file xip base address
*/

/* NuttX file system ioctl definitions **************************************/

Expand Down

0 comments on commit 7d55679

Please sign in to comment.