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_INTERNAL_STATE_H_ 14#define _REFOS_IO_INTERNAL_STATE_H_ 15 16#include <stdint.h> 17#include <stdbool.h> 18#include <sel4/sel4.h> 19#include "stdio.h" 20#include "morecore.h" 21#include "mmap_segment.h" 22#include "filetable.h" 23 24#include <refos-util/walloc.h> 25#include <refos-rpc/serv_client.h> 26#include <refos-rpc/serv_client_helper.h> 27 28struct sl_procinfo_s; 29 30typedef struct refos_io_internal_state { 31 /* STDIO read / write override functions. One example where this comps in handy is the OS 32 server, which obviously cannot IPC itself to print. */ 33 stdio_read_fn_t stdioReadOverride; 34 stdio_read_fn_t stdioWriteOverride; 35 36 /*! \brief Statically allocated morecore area. 37 38 This is a rather terrible workaround for servers which would like to use malloc before 39 The RefOS userland infrastructure is properly set up. 40 41 */ 42 char* staticMoreCoreOverride; 43 uintptr_t staticMoreCoreOverrideBase; 44 uintptr_t staticMoreCoreOverrideTop; 45 46 /*! The STDIO dataspace, owned by Console server. */ 47 serv_connection_t stdioSession; 48 seL4_CPtr stdioDataspace; 49 50 /*! File descriptor table. */ 51 fd_table_t fdTable; 52 53 /*! Dynamic morecore heap state. */ 54 bool dynamicHeap; 55 struct sl_procinfo_s *procInfo; 56 57 /*! Dynamic morecore mmap state. */ 58 bool dynamicMMap; 59 refos_io_mmap_segment_state_t mmapState; 60 61 /*! Timer state. */ 62 FILE * timerFD; 63} refos_io_internal_state_t; 64 65extern refos_io_internal_state_t refosIOState; 66 67#endif /* _REFOS_IO_INTERNAL_STATE_H_ */