[driver] Fix bug in addr range check for upload/download
Device address should not be compared against LOCAL_MEM_SIZE but against an absolute max address. Introduce new DEVICE_MAX_ADDR for this.
This commit is contained in:
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
int upload(const void* src, uint64_t dest_addr, uint64_t size, uint64_t src_offset) {
|
||||
uint64_t asize = aligned_size(size, CACHE_BLOCK_SIZE);
|
||||
if (dest_addr + asize > LOCAL_MEM_SIZE)
|
||||
if (dest_addr + asize > DEVICE_MAX_ADDR)
|
||||
return -1;
|
||||
|
||||
ram_.write((const uint8_t*)src + src_offset, dest_addr, asize);
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
|
||||
int download(void* dest, uint64_t src_addr, uint64_t size, uint64_t dest_offset) {
|
||||
uint64_t asize = aligned_size(size, CACHE_BLOCK_SIZE);
|
||||
if (src_addr + asize > LOCAL_MEM_SIZE)
|
||||
if (src_addr + asize > DEVICE_MAX_ADDR)
|
||||
return -1;
|
||||
|
||||
ram_.read((uint8_t*)dest + dest_offset, src_addr, asize);
|
||||
@@ -354,4 +354,4 @@ extern int vx_ready_wait(vx_device_h hdevice, uint64_t timeout) {
|
||||
vx_device *device = ((vx_device*)hdevice);
|
||||
|
||||
return device->wait(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user