summaryrefslogtreecommitdiff
path: root/cmd/sbc_harness/fs_harness_flash_bin.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-06-07 15:23:29 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-06-12 02:28:40 -0600
commit2d7f2350559dde046e95bcc28c1f89f41f5a6d75 (patch)
tree374571661ef53086e6a9e025b9b344bf80451cb4 /cmd/sbc_harness/fs_harness_flash_bin.c
parent4109b15224b08fe49297097d9891e4c584712400 (diff)
lib9p_srv: Adopt a pread_to-like interface
Diffstat (limited to 'cmd/sbc_harness/fs_harness_flash_bin.c')
-rw-r--r--cmd/sbc_harness/fs_harness_flash_bin.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c
index 9a5bb2f..e5c3026 100644
--- a/cmd/sbc_harness/fs_harness_flash_bin.c
+++ b/cmd/sbc_harness/fs_harness_flash_bin.c
@@ -221,13 +221,13 @@ static void flash_file_iofree(struct flash_file *self) {
ab_flash_finalize(self->wbuf.dat);
}
-static iovec_or_error flash_file_pread(struct flash_file *self, struct lib9p_srv_ctx *ctx,
- uint32_t byte_count, uint64_t byte_offset) {
+static error flash_file_pread(struct flash_file *self, struct lib9p_srv_ctx *ctx,
+ lo_interface io_writer dst, uint64_t byte_offset, uint32_t byte_count) {
assert(self);
assert(ctx);
if (byte_offset > DATA_SIZE)
- return ERROR_NEW_ERR(iovec, error_new(E_POSIX_EINVAL, "offset is past the chip size"));
+ return error_new(E_POSIX_EINVAL, "offset is past the chip size");
/* Assume that somewhere down the line the iovec we return
* will be passed to DMA. We don't want the DMA engine to hit
@@ -237,9 +237,7 @@ static iovec_or_error flash_file_pread(struct flash_file *self, struct lib9p_srv
* DMA engine can only have a DREQ on one side of the channel.
*/
if (byte_offset == DATA_SIZE)
- return ERROR_NEW_VAL(iovec, ((struct iovec){
- .iov_len = 0,
- }));
+ return io_write(dst, NULL, 0).err;
size_t sector_base = LM_ROUND_DOWN(byte_offset, FLASH_SECTOR_SIZE);
if (byte_offset + byte_count > sector_base + FLASH_SECTOR_SIZE)
byte_count = (sector_base + FLASH_SECTOR_SIZE) - byte_offset;
@@ -251,10 +249,7 @@ static iovec_or_error flash_file_pread(struct flash_file *self, struct lib9p_srv
memcpy(self->rbuf.dat, DATA_START+sector_base, FLASH_SECTOR_SIZE);
}
- return ERROR_NEW_VAL(iovec, ((struct iovec){
- .iov_base = &self->rbuf.dat[byte_offset-sector_base],
- .iov_len = byte_count,
- }));
+ return io_write(dst, &self->rbuf.dat[byte_offset-sector_base], byte_count).err;
}
/* TODO: Short/corrupt writes are dangerous. This should either (1)