software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Provides interface to perform read/write memory location
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Provides interface to perform read/write memory location
@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         UAP_SUCCESS/UAP_FAILURE
@brief Provides interface to perform read / write memory location @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
int
apcmd_memaccess(int argc, char *argv[])
{
	int opt;
	apcmdbuf_mem_access *cmd_buf = NULL;
	t_u8 *buf = NULL;
	t_u16 cmd_len = 0;
	t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
	int ret = UAP_SUCCESS;
	char *address = NULL;
	char *value = NULL;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_memaccess_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	if ((argc < 1) || (argc > 2)) {
		printf("ERR:wrong arguments.\n");
		print_memaccess_usage();
		return UAP_FAILURE;
	}
	address = argv[0];
	if (argc == 2)
		value = argv[1];
	buf = (t_u8 *)malloc(buf_len);
	if (!buf) {
		printf("ERR:Cannot allocate buffer from command!\n");
		return UAP_FAILURE;
	}
	memset(buf, 0, buf_len);
	cmd_len = sizeof(apcmdbuf_mem_access);
	cmd_buf = (apcmdbuf_mem_access *)buf;
	cmd_buf->size = cmd_len - BUF_HEADER_SIZE;
	cmd_buf->seq_num = 0;
	cmd_buf->result = 0;
	cmd_buf->cmd_code = HostCmd_CMD_MEM_ACCESS;
	if (value)
		cmd_buf->action = 1;	
	else
		cmd_buf->action = 0;	
	cmd_buf->action = uap_cpu_to_le16(cmd_buf->action);
	cmd_buf->address = A2HEXDECIMAL(address);
	cmd_buf->address = uap_cpu_to_le32(cmd_buf->address);
	if (value) {
		cmd_buf->value = A2HEXDECIMAL(value);
		cmd_buf->value = uap_cpu_to_le32(cmd_buf->value);
	}
	ret = uap_ioctl((t_u8 *)cmd_buf, &cmd_len, buf_len);
	if (ret == UAP_SUCCESS) {
		if (cmd_buf->result == CMD_SUCCESS) {
			printf("Successfully executed the command\n");
			printf("[0x%04x] = 0x%08x\n",
			       uap_le32_to_cpu(cmd_buf->address),
			       uap_le32_to_cpu(cmd_buf->value));
		} else {
			printf("ERR:Command sending failed!\n");
			free(buf);
			return UAP_FAILURE;
		}
	} else {
		printf("ERR:Command sending failed!\n");
		free(buf);
		return UAP_FAILURE;
	}
	free(buf);
	return UAP_SUCCESS;
}
int apcmd_memaccess ( int argc , char * argv [ ] ) { int opt ; apcmdbuf_mem_access * cmd_buf = NULL ; t_u8 * buf = NULL ; t_u16 cmd_len = 0 ; t_u16 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER ; int ret = UAP_SUCCESS ; char * address = NULL ; char * value = NULL ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_memaccess_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; if ( ( argc < 1 ) || ( argc > 2 ) ) { printf ( " \n " ) ; print_memaccess_usage ( ) ; return UAP_FAILURE ; } address = argv [ 0 ] ; if ( argc == 2 ) value = argv [ 1 ] ; buf = ( t_u8 * ) malloc ( buf_len ) ; if ( ! buf ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( buf , 0 , buf_len ) ; cmd_len = sizeof ( apcmdbuf_mem_access ) ; cmd_buf = ( apcmdbuf_mem_access * ) buf ; cmd_buf -> size = cmd_len - BUF_HEADER_SIZE ; cmd_buf -> seq_num = 0 ; cmd_buf -> result = 0 ; cmd_buf -> cmd_code = HostCmd_CMD_MEM_ACCESS ; if ( value ) cmd_buf -> action = 1 ; else cmd_buf -> action = 0 ; cmd_buf -> action = uap_cpu_to_le16 ( cmd_buf -> action ) ; cmd_buf -> address = A2HEXDECIMAL ( address ) ; cmd_buf -> address = uap_cpu_to_le32 ( cmd_buf -> address ) ; if ( value ) { cmd_buf -> value = A2HEXDECIMAL ( value ) ; cmd_buf -> value = uap_cpu_to_le32 ( cmd_buf -> value ) ; } ret = uap_ioctl ( ( t_u8 * ) cmd_buf , & cmd_len , buf_len ) ; if ( ret == UAP_SUCCESS ) { if ( cmd_buf -> result == CMD_SUCCESS ) { printf ( " \n " ) ; printf ( " \n " , uap_le32_to_cpu ( cmd_buf -> address ) , uap_le32_to_cpu ( cmd_buf -> value ) ) ; } else { printf ( " \n " ) ; free ( buf ) ; return UAP_FAILURE ; } } else { printf ( " \n " ) ; free ( buf ) ; return UAP_FAILURE ; } free ( buf ) ; return UAP_SUCCESS ; }
@brief Provides interface to perform read/write memory location
  @param argc     Number of arguments
  @param argv     Pointer to the arguments
  @return         UAP_SUCCESS/UAP_FAILURE
@brief Provides interface to perform read / write memory location @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
/* Check arguments */ /* Alloc buf for command */ /* Locate headers */ /* Fill the command buffer */ // WRITE // READ /* Send the command */ /* Process response */