diff --git a/src/fpga/common/driver.cpp b/src/fpga/common/driver.cpp index 508f95f0bf175e270cc8ec49f1a7d8fb7ddfb977..71e3bf9746e600703fa43f2c8616f73806f6fd60 100644 --- a/src/fpga/common/driver.cpp +++ b/src/fpga/common/driver.cpp @@ -51,6 +51,10 @@ int open_memdevice() { return g_fpgainfo.fd_mem; } +int close_drvdevice() { return close(g_fpgainfo.fd_drv); } + +int close_memdevice() { return close(g_fpgainfo.fd_mem); } + void pl_reset() { usleep(100 * 1000); } void setup_pe(struct pe_data_s *pe_data, struct fpga_pe *pe, @@ -144,17 +148,6 @@ int fpga_regpoll(uint64_t reg, uint64_t val, int time) { } } -void memory_release(struct fpga_memory *memory) { - void *ptr = nullptr; - - /*unmap memory*/ - std::map map = g_fpgainfo.fpga_addr2size_map; - std::map::iterator iter; - for (iter = map.begin(); iter != map.end(); iter++) { - fpga_free_driver(ptr); - } -} - uint64_t vaddr_to_paddr_driver(void *address) { uint64_t paddr = 0; auto iter = g_fpgainfo.fpga_vaddr2paddr_map.find(address); @@ -291,8 +284,10 @@ int open_device_driver() { int close_device_driver() { pl_destroy(); fpga_reg_free(g_fpgainfo.FpgaRegVirAddr); - memory_release(g_fpgainfo.memory_info); - return 0; + int ret = 0; + ret = close_drvdevice(); + ret |= close_memdevice(); + return ret; } } // namespace driver