Skip to content

Commit

Permalink
vcsm: Add ioctl for custom cache flushing
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed May 25, 2015
1 parent 9cc14b2 commit d4aa617
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
15 changes: 15 additions & 0 deletions host_applications/linux/kernel_headers/vmcs_sm_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ enum vmcs_sm_cmd_e {
VMCS_SM_CMD_HOST_WALK_PID_ALLOC,
VMCS_SM_CMD_HOST_WALK_PID_MAP,

VMCS_SM_CMD_CLEAN_INVALID,

VMCS_SM_CMD_LAST /* Do no delete */
};

Expand Down Expand Up @@ -175,6 +177,16 @@ struct vmcs_sm_ioctl_cache {
unsigned int size;
};

struct vmcs_sm_ioctl_clean_invalid {
/* user -> kernel */
struct {
unsigned int cmd;
unsigned int handle;
unsigned int addr;
unsigned int size;
} s[8];
};

/* IOCTL numbers */
#define VMCS_SM_IOCTL_MEM_ALLOC\
_IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_ALLOC,\
Expand Down Expand Up @@ -203,6 +215,9 @@ struct vmcs_sm_ioctl_cache {
#define VMCS_SM_IOCTL_MEM_INVALID\
_IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_INVALID,\
struct vmcs_sm_ioctl_cache)
#define VMCS_SM_IOCTL_MEM_CLEAN_INVALID\
_IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_CLEAN_INVALID,\
struct vmcs_sm_ioctl_clean_invalid)

#define VMCS_SM_IOCTL_SIZE_USR_HDL\
_IOR(VMCS_SM_MAGIC_TYPE, VMCS_SM_CMD_SIZE_USR_HANDLE,\
Expand Down
37 changes: 37 additions & 0 deletions host_applications/linux/libs/sm/user-vcsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1559,3 +1559,40 @@ int vcsm_resize( unsigned int handle, unsigned int new_size )
out:
return rc;
}


/* Flush or invalidate the memory associated with this user opaque handle
**
** Returns: non-zero on error
**
** structure contains a list of flush/invalidate commands
** See header file
*/
int vcsm_clean_invalid( struct vcsm_user_clean_invalid_s *s )
{
int rc = 0;
struct vmcs_sm_ioctl_clean_invalid cache;

if ( vcsm_handle == VCSM_INVALID_HANDLE )
{
vcos_log_error( "[%s]: [%d]: invalid device or invalid handle!",
__func__,
getpid() );

rc = -1;
goto out;
}

memcpy( &cache, s, sizeof cache );

rc = ioctl( vcsm_handle,
VMCS_SM_IOCTL_MEM_CLEAN_INVALID,
&cache );

/* Done.
*/
goto out;

out:
return rc;
}
21 changes: 21 additions & 0 deletions host_applications/linux/libs/sm/user-vcsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,27 @@ int vcsm_unlock_hdl( unsigned int handle );
*/
int vcsm_unlock_hdl_sp( unsigned int handle, int cache_no_flush );

/* Clean and/or invalidate the memory associated with this user opaque handle
**
** Returns: non-zero on error
**
** structure contains a list of flush/invalidate commands. Commands are:
** 0: nop
** 1: invalidate given virtual range in L1/L2
** 2: clean given virtual range in L1/L2
** 3: clean+invalidate given virtual range in L1/L2
*/
struct vcsm_user_clean_invalid_s {
struct {
unsigned int cmd;
unsigned int handle;
unsigned int addr;
unsigned int size;
} s[8];
};

int vcsm_clean_invalid( struct vcsm_user_clean_invalid_s *s );

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit d4aa617

Please sign in to comment.