Changeset 359 for soft/giet_vm/giet_boot/boot.c
- Timestamp:
- Jul 23, 2014, 10:09:42 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_boot/boot.c
r356 r359 8 8 // 9 9 // This nano-kernel has been written for the MIPS32 processor. 10 // The virtual adresses are on 32 bits and use the (unsigned int) type , but the10 // The virtual adresses are on 32 bits and use the (unsigned int) type. The 11 11 // physicals addresses can have up to 40 bits, and use the (unsigned long long) type. 12 12 // It natively supports clusterised shared mmemory multi-processors architectures, … … 14 14 // and where there is one physical memory bank per cluster. 15 15 // 16 // This code, executed in the boot phase by proc[0,0,0] performs the following tasks:17 // - load into memory thebinary files, from a FAT32 file system,16 // This code, executed in the boot phase by proc[0,0,0], performs the following tasks: 17 // - load into memory various binary files, from a FAT32 file system, 18 18 // - build the various page tables (one page table per vspace) 19 19 // - initialize the shedulers (one scheduler per processor) … … 95 95 96 96 #if !defined(X_SIZE) 97 # error The X_SIZE value must be defined in the 'hard_config.h' file !97 # error: The X_SIZE value must be defined in the 'hard_config.h' file ! 98 98 #endif 99 99 100 100 #if !defined(Y_SIZE) 101 # error The Y_SIZE value must be defined in the 'hard_config.h' file !101 # error: The Y_SIZE value must be defined in the 'hard_config.h' file ! 102 102 #endif 103 103 104 104 #if !defined(X_WIDTH) 105 # error The X_WIDTH value must be defined in the 'hard_config.h' file !105 # error: The X_WIDTH value must be defined in the 'hard_config.h' file ! 106 106 #endif 107 107 108 108 #if !defined(Y_WIDTH) 109 # error The Y_WIDTH value must be defined in the 'hard_config.h' file !109 # error: The Y_WIDTH value must be defined in the 'hard_config.h' file ! 110 110 #endif 111 111 112 112 #if !defined(SEG_BOOT_MAPPING_BASE) 113 # error: You must define SEG_BOOT_MAPPING_BASE in the hard_config.h file 114 #endif 115 116 #if !defined(SEG_BOOT_BUFFER_BASE) 117 # error: You must define SEG_BOOT_BUFFER_BASE in the hard_config.h file 118 #endif 119 120 #if !defined(SEG_BOOT_BUFFER_SIZE) 121 # error: You must define SEG_BOOT_BUFFER_SIZE in the hard_config.h file 113 # error: The SEG_BOOT_MAPPING_BASE value must be defined in the hard_config.h file ! 122 114 #endif 123 115 124 116 #if !defined(NB_PROCS_MAX) 125 # error The NB_PROCS_MAX value must be defined in the 'hard_config.h' file !117 # error: The NB_PROCS_MAX value must be defined in the 'hard_config.h' file ! 126 118 #endif 127 119 128 120 #if !defined(GIET_NB_VSPACE_MAX) 129 # error The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file ! 121 # error: The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file ! 122 #endif 123 124 #if !defined(GIET_ELF_BUFFER_SIZE) 125 # error: The GIET_ELF_BUFFER_SIZE value must be defined in the giet_config.h file ! 130 126 #endif 131 127 … … 134 130 // Both the page tables for the various virtual spaces, and the schedulers 135 131 // for the processors are physically distributed on the clusters. 136 // These global variables are just arrays of pointers.137 132 //////////////////////////////////////////////////////////////////////////// 138 133 … … 140 135 extern fat32_fs_t fat; 141 136 142 // Page tables base addresses, sizes, and PT2 allocators: 143 // For each vspace, it can exist one page table per cluster, 144 // but only one virtual base address per vspace 145 137 // Page tables virtual base addresses (one per vspace) 146 138 __attribute__((section (".bootdata"))) 147 139 unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX]; 148 140 141 // Page tables physical base addresses (one per vspace / one per cluster) 149 142 __attribute__((section (".bootdata"))) 150 143 paddr_t _ptabs_paddr[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; 151 144 145 // Page table max_pt2 (one per vspace / one per cluster ) 152 146 __attribute__((section (".bootdata"))) 153 147 unsigned int _ptabs_max_pt2[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; 154 148 149 // Page tables pt2 allocators (one per vspace / one per cluster) 155 150 __attribute__((section (".bootdata"))) 156 151 unsigned int _ptabs_next_pt2[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; … … 161 156 static_scheduler_t* _schedulers[1<<X_WIDTH][1<<Y_WIDTH][NB_PROCS_MAX]; 162 157 158 // Temporaty buffer used to load one complete .elf file 159 __attribute__((section (".bootdata"))) 160 char boot_elf_buffer[GIET_ELF_BUFFER_SIZE] __attribute__((aligned(512))); 163 161 164 162 ///////////////////////////////////////////////////////////////////// … … 1916 1914 // clusters: same virtual address but different physical addresses. 1917 1915 // - It open the file. 1918 // - It loads the complete file in a dedicated buffer (seg_boot_buffer).1919 // - It copies each loadable segments at the virtual address defined in the .elf1920 // file, making several copies if the target vseg is not local.1916 // - It loads the complete file in the dedicated boot_elf_buffer. 1917 // - It copies each loadable segments at the virtual address defined in 1918 // the .elf file, making several copies if the target vseg is not local. 1921 1919 // - It closes the file. 1920 // This function is supposed to be executed by processor[0,0,0]. 1922 1921 // Note: 1923 // - This function is supposed to be executed by processor[0,0,0].1924 1922 // We must use physical addresses to reach the destination buffers that 1925 1923 // can be located in remote clusters. We use either a _physical_memcpy(), 1926 1924 // or a _dma_physical_copy() if DMA is available. 1927 // The source seg_boot_buffer must be identity mapping.1928 1925 ////////////////////////////////////////////////////////////////////////////////////// 1929 1926 void load_one_elf_file( unsigned int is_kernel, // kernel file if non zero … … 1938 1935 unsigned int seg_id; 1939 1936 1940 // get boot buffer address and size1941 char* boot_buffer = (char*)SEG_BOOT_BUFFER_BASE;1942 unsigned int boot_buffer_size = SEG_BOOT_BUFFER_SIZE;1943 1944 1937 #if BOOT_DEBUG_ELF 1945 1938 _puts("\n[BOOT DEBUG] Start searching file "); … … 1962 1955 } 1963 1956 1964 // check b oot_buffer size versus file size1965 if ( fat.fd[fd_id].file_size > boot_buffer_size)1957 // check buffer size versus file size 1958 if ( fat.fd[fd_id].file_size > GIET_ELF_BUFFER_SIZE ) 1966 1959 { 1967 1960 _puts("\n[BOOT ERROR] load_one_elf_file() : "); 1968 1961 _puts( pathname ); 1969 _puts(" exceeds the seg_boot_buffer size\n");1962 _puts(" exceeds the GIET_ELF_BUFFERSIZE defined in giet_config.h\n"); 1970 1963 _exit(); 1971 1964 } … … 1976 1969 if( nbytes & 0x1FF) nsectors++; 1977 1970 1978 // load file in boot_buffer1971 // load file in elf buffer 1979 1972 if( _fat_read( IOC_BOOT_MODE, 1980 1973 fd_id, 1981 boot_ buffer,1974 boot_elf_buffer, 1982 1975 nsectors, 1983 1976 0 ) != nsectors ) … … 1990 1983 1991 1984 // Check ELF Magic Number in ELF header 1992 Elf32_Ehdr* elf_header_ptr = (Elf32_Ehdr*)boot_ buffer;1985 Elf32_Ehdr* elf_header_ptr = (Elf32_Ehdr*)boot_elf_buffer; 1993 1986 1994 1987 if ( (elf_header_ptr->e_ident[EI_MAG0] != ELFMAG0) || … … 2012 2005 _exit(); 2013 2006 } 2014 Elf32_Phdr* elf_pht_ptr = (Elf32_Phdr*)(boot_ buffer + pht_index);2007 Elf32_Phdr* elf_pht_ptr = (Elf32_Phdr*)(boot_elf_buffer + pht_index); 2015 2008 2016 2009 // get number of segments … … 2050 2043 _puts(" in file "); 2051 2044 _puts( pathname ); 2052 _puts(" has amemsz < filesz \n");2045 _puts(" has memsz < filesz \n"); 2053 2046 _exit(); 2054 2047 } … … 2058 2051 { 2059 2052 unsigned int i; 2060 for( i = seg_filesz ; i < seg_memsz ; i++ ) boot_ buffer[i+seg_offset] = 0;2053 for( i = seg_filesz ; i < seg_memsz ; i++ ) boot_elf_buffer[i+seg_offset] = 0; 2061 2054 } 2062 2055 2063 unsigned int src_vaddr = (unsigned int)boot_ buffer + seg_offset;2056 unsigned int src_vaddr = (unsigned int)boot_elf_buffer + seg_offset; 2064 2057 2065 2058 // search all vsegs matching the virtual address
Note: See TracChangeset
for help on using the changeset viewer.