optee_test/host/xtest/sdp_basic.c
/*
 * Old ION API to allocate and export a buffer
 */
Old ION API to allocate and export a buffer
Old ION API to allocate and export a buffer
static int allocate_ion_buffer_old_api(size_t size, int heap_type_id, int ion)
{
	struct ion0_allocation_data alloc_data;
	struct ion0_handle_data hdl_data;
	struct ion0_fd_data fd_data;
	int fd = -1;
	alloc_data.len = size;
	alloc_data.align = 0;
	alloc_data.flags = 0;
	alloc_data.heap_id_mask = 1 << heap_type_id;
	if (ioctl(ion, ION0_IOC_ALLOC, &alloc_data) == -1) {
		fprintf(stderr, "Error: old ION allocate API failed\n");
		return fd;
	}
	fd_data.handle = alloc_data.handle;
	if (ioctl(ion, ION0_IOC_SHARE, &fd_data) != -1)
		fd = fd_data.fd;
	else
		fprintf(stderr, "Error: old ION share API failed\n");
	hdl_data.handle = alloc_data.handle;
	(void)ioctl(ion, ION0_IOC_FREE, &hdl_data);
	return fd;
}
static int allocate_ion_buffer_old_api ( size_t size , int heap_type_id , int ion ) { struct ion0_allocation_data alloc_data ; struct ion0_handle_data hdl_data ; struct ion0_fd_data fd_data ; int fd = -1 ; alloc_data . len = size ; alloc_data . align = 0 ; alloc_data . flags = 0 ; alloc_data . heap_id_mask = 1 << heap_type_id ; if ( ioctl ( ion , ION0_IOC_ALLOC , & alloc_data ) == -1 ) { fprintf ( stderr , " \n " ) ; return fd ; } fd_data . handle = alloc_data . handle ; if ( ioctl ( ion , ION0_IOC_SHARE , & fd_data ) != -1 ) fd = fd_data . fd ; else fprintf ( stderr , " \n " ) ; hdl_data . handle = alloc_data . handle ; ( void ) ioctl ( ion , ION0_IOC_FREE , & hdl_data ) ; return fd ; }
Old ION API to allocate and export a buffer
Old ION API to allocate and export a buffer