1/* 2 * Copyright 2016, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(D61_BSD) 11 */ 12 13#ifndef _REFOS_IO_FILETABLE_H_ 14#define _REFOS_IO_FILETABLE_H_ 15 16#include <stdint.h> 17#include <refos/refos.h> 18#include <refos/error.h> 19#include <data_struct/coat.h> 20 21#define FD_TABLE_MAGIC 0xA6B1063F 22#define FD_TABLE_BASE 3 /* 0, 1 and 2 are stdin, stdout and stderr. */ 23 24typedef struct fd_table_s { 25 coat_t table; /* fd_table_entry_*_t, Inherited, must be first. */ 26 uint32_t tableSize; 27 uint32_t magic; 28} fd_table_t; 29 30void filetable_init(fd_table_t *fdt, uint32_t tableSize); 31 32void filetable_release(fd_table_t *fdt); 33 34int filetable_dspace_open(fd_table_t *fdt, char* filePath, int flags, int mode, int size); 35 36int filetable_close(fd_table_t *fdt, int fd); 37 38refos_err_t filetable_lseek(fd_table_t *fdt, int fd, int *offset, int whence); 39 40int filetable_read(fd_table_t *fdt, int fd, char *bufferDest, int bufferLen); 41 42int filetable_write(fd_table_t *fdt, int fd, char *bufferSrc, int bufferLen); 43 44seL4_CPtr filetable_dspace_get(fd_table_t *fdt, int fd); 45 46void filetable_init_default(void); 47 48void filetable_deinit_default(void); 49 50#endif /* _REFOS_IO_FILETABLE_H_ */ 51