Skip to content

Commit

Permalink
sdk: added fpga_pci_get_address to allow direct access mmap'ed regions
Browse files Browse the repository at this point in the history
  • Loading branch information
AWSjswinney authored and AWSsunandaj committed Apr 19, 2017
1 parent a6f62c0 commit c359f03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sdk/userspace/fpga_libs/fpga_pci/fpga_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,16 @@ int fpga_pci_write_burst(pci_bar_handle_t handle, uint64_t offset, uint32_t* dat
err:
return FPGA_ERR_FAIL;
}

int
fpga_pci_get_address(pci_bar_handle_t handle, uint64_t offset, size_t len,
void **ptr)
{
fail_on(!ptr, err, "ptr is NULL");

*ptr = fpga_pci_bar_get_mem_at_offset(handle, offset, len);
fail_on(!*ptr, err, "fpga_plat_get_mem_at_offset failed");
return 0;
err:
return FPGA_ERR_FAIL;
}
14 changes: 14 additions & 0 deletions sdk/userspace/include/fpga_pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,17 @@ int fpga_pci_get_resource_map(int slot_id, int pf_id,
* @returns 0 on success, non-zero on error
*/
int fpga_pci_rescan_slot_app_pfs(int slot_id);

/**
* Get a bounds checked pointer to memory in the mapped region for this handle.
*
* @param[in] handle handle provided by fpga_pci_attach
* @param[in] offset offset into the mmap'ed region
* @param[in] dword_len the length of data to write in burst, in 4-byte DWORDs
* (used for bounds checking)
* @param[out] ptr pointer to memory
*
* @return 0 on success, non-zero on error (bounds errors in particular)
*/
int fpga_pci_get_address(pci_bar_handle_t handle, uint64_t offset,
uint64_t dword_len, void **ptr);

0 comments on commit c359f03

Please sign in to comment.