|
|
|
@ -15,7 +15,11 @@ |
|
|
|
|
int ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
uint32_t page; |
|
|
|
|
uint32_t mask, offset, page; |
|
|
|
|
|
|
|
|
|
mask = ((1 << map->log2_page_size) - 1); |
|
|
|
|
offset = va & mask; |
|
|
|
|
va = va & ~mask; |
|
|
|
|
|
|
|
|
|
if ((ret = trace_path(map, NULL, &page, va)) < 0) { |
|
|
|
|
memset(data, 0, len); |
|
|
|
@ -25,8 +29,8 @@ int ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va) |
|
|
|
|
if (!data) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
return flash_read(map->dev, page << map->log2_page_size, data, |
|
|
|
|
min(map->log2_page_size, len)); |
|
|
|
|
return flash_read(map->dev, (page << map->log2_page_size) + offset, data, |
|
|
|
|
min(map->log2_page_size - offset, len)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int ftl_write(struct ftl_map *map, uint32_t va, const uint8_t *data) |
|
|
|
|