From 2d7f2350559dde046e95bcc28c1f89f41f5a6d75 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 7 Jun 2025 15:23:29 -0600 Subject: lib9p_srv: Adopt a pread_to-like interface --- cmd/sbc_harness/fs_harness_flash_bin.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'cmd/sbc_harness/fs_harness_flash_bin.c') 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) -- cgit v1.2.3-2-g168b