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/*! @file 14 @brief Process selfloader system application for RefOS. */ 15 16#ifndef _BOOTSTRAP_H_ 17#define _BOOTSTRAP_H_ 18 19#include <stdio.h> 20#include <refos/refos.h> 21#include <refos/vmlayout.h> 22#include <refos-rpc/name_client.h> 23#include <refos-rpc/name_client_helper.h> 24#include <refos-rpc/proc_client.h> 25#include <refos-rpc/proc_client_helper.h> 26#include <refos-rpc/serv_client.h> 27#include <refos-rpc/serv_client_helper.h> 28#include <refos-rpc/data_client.h> 29#include <refos-rpc/data_client_helper.h> 30#include <refos-util/init.h> 31#include <elf/elf.h> 32 33// Debug printing. 34#include <refos-util/dprintf.h> 35 36#ifndef CONFIG_REFOS_DEBUG 37 #define printf(x,...) 38#endif /* CONFIG_REFOS_DEBUG */ 39 40#if CONFIG_WORD_SIZE == 64 41#define Elf_auxv_t Elf64_auxv_t 42#elif CONFIG_WORD_SIZE == 32 43#define Elf_auxv_t Elf32_auxv_t 44#else 45#error "Word size unsupported" 46#endif /* CONFIG_WORD_SIZE */ 47 48#define ENV_STR_SIZE 128 49 50#define AT_SYSINFO 32 51 52/*! @brief Structure to store 32-bit aux */ 53typedef struct { 54 uint32_t a_type; 55 union { 56 uint32_t a_val; 57 } a_un; 58} Elf32_auxv_t; 59 60/*! @brief Structure to store 64-bit aux */ 61typedef struct { 62 uint64_t a_type; 63 union { 64 uint64_t a_val; 65 } a_un; 66} Elf64_auxv_t; 67 68/*! @brief Self-loader application elf file segment information 69 70 It stores segment and file information of each segment to initiate dataspace and window 71 of corresponding size. 72 */ 73struct sl_elf_segment_info { 74 seL4_Word source; /*!< Offset into ELF file containing segment data. */ 75 unsigned long segmentSize; /*!< Size of the entire segment. */ 76 unsigned long fileSize; /*!< Size of segment that has ELF content. Rest is zeroed. */ 77 unsigned long flags; /*!< Read / write flags. */ 78 seL4_Word vaddr; /*!< VAddr into client vspace at which segment resides. */ 79}; 80 81/*! @brief Self-loader application global state. */ 82struct sl_state { 83 serv_connection_t fileservConnection; 84 85 data_mapping_t elfFileHeader; 86 sl_dataspace_t elfSegment; 87 88 unsigned int endOfProgram; 89 unsigned int heapRegionStart; 90 sl_dataspace_t stackRegion; 91 sl_dataspace_t heapRegion; 92 sl_dataspace_t mmapRegion; 93}; 94 95#define SELFLOADER_MINI_MORECORE_REGION_SIZE 0x32000 96 97#endif /* _BOOTSTRAP_H_ */ 98 99 100