1/* 2 * Copyright (c) 2014, University of Washington. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef STORAGE_VSIC_H 11#define STORAGE_VSIC_H 12 13// Roundup s to the next multiple of m 14#define STORAGE_ROUNDUP(s, m) \ 15 ((s) % (m) != 0 ? (s) + ((m) - ((s) % (m))) : (s)) 16 17// Round to VSIC block size 18#define STORAGE_VSIC_ROUND(vsic, s) \ 19 STORAGE_ROUNDUP(s, (vsic)->blocksize) 20 21struct storage_vsic; 22struct storage_vsa; 23 24struct storage_vsic_ops { 25 errval_t (*write)(struct storage_vsic *vsic, struct storage_vsa *vsa, 26 off_t offset, size_t size, void *buffer); 27 errval_t (*read)(struct storage_vsic *vsic, struct storage_vsa *vsa, 28 off_t offset, size_t size, void *buffer); 29 errval_t (*flush)(struct storage_vsic *vsic, struct storage_vsa *vsa); 30 errval_t (*flush2)(struct storage_vsic *vsic, struct storage_vsa *vsa, void *handle); 31 errval_t (*wait)(struct storage_vsic *vsic); 32 errval_t (*poll)(struct storage_vsic *vsic, void **handle); 33}; 34 35struct storage_vsic { 36 struct storage_vsic_ops ops; 37 void *data; 38 size_t blocksize; 39}; 40 41// XXX: Remove once we support multiple backend drivers 42errval_t storage_vsic_driver_init(int argc, const char **argv, 43 struct storage_vsic *vsic); 44 45#endif 46