[527] | 1 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 2 | // File : boot.c |
---|
| 3 | // Date : 01/11/2013 |
---|
| 4 | // Author : alain greiner |
---|
| 5 | // Copyright (c) UPMC-LIP6 |
---|
[527] | 6 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 7 | // The boot.c file contains the bootloader for the GIET-VM static OS. |
---|
[258] | 8 | // |
---|
[493] | 9 | // This code has been written for the MIPS32 processor. |
---|
[359] | 10 | // The virtual adresses are on 32 bits and use the (unsigned int) type. The |
---|
[527] | 11 | // physicals addresses can have up to 40 bits, and use type (unsigned long long). |
---|
[412] | 12 | // It natively supports clusterised shared memory multi-processors architectures, |
---|
[493] | 13 | // where each processor is identified by a composite index [x,y,p], |
---|
[258] | 14 | // and where there is one physical memory bank per cluster. |
---|
| 15 | // |
---|
[493] | 16 | // The boot.elf file is stored on disk and is loaded into memory by proc[0,0,0], |
---|
| 17 | // executing the generic preloader (stored in ROM). The boot-loader code itself |
---|
| 18 | // is executed in parallel by all proc[x,y,0], and performs the following tasks: |
---|
| 19 | // - load into memory various binary files, from a FAT32 file system. |
---|
| 20 | // - build the various page tables (one page table per vspace). |
---|
| 21 | // - initialize the shedulers (one scheduler per processor). |
---|
[258] | 22 | // |
---|
| 23 | // 1) The binary files to be loaded are: |
---|
[631] | 24 | // - the "map.bin" file contains the hardware architecture description, |
---|
| 25 | // the set of user applications that will be mapped on the architecture, |
---|
| 26 | // and the mapping directives. The mapping includes the placement of tasks |
---|
| 27 | // on processors, and the placement of virtual segments on the physical |
---|
| 28 | // segments. It must be stored in the the seg_boot_mapping segment |
---|
[321] | 29 | // (at address SEG_BOOT_MAPPING_BASE defined in hard_config.h file). |
---|
[493] | 30 | // - the "kernel.elf" file contains the kernel binary code and data. |
---|
[258] | 31 | // - the various "application.elf" files. |
---|
| 32 | // |
---|
[631] | 33 | // 2) The GIET-VM uses the paged virtual memory to provides two services: |
---|
[258] | 34 | // - classical memory protection, when several independant applications compiled |
---|
| 35 | // in different virtual spaces are executing on the same hardware platform. |
---|
[412] | 36 | // - data placement in NUMA architectures, to control the placement |
---|
| 37 | // of the software objects (vsegs) on the physical memory banks (psegs). |
---|
[527] | 38 | // The max number of vspaces (GIET_NB_VSPACE_MAX) is a configuration parameter. |
---|
[258] | 39 | // The page table are statically build in the boot phase, and they do not |
---|
[631] | 40 | // change during execution. For each application, the page tables are replicated |
---|
| 41 | // in all clusters. |
---|
[412] | 42 | // The GIET_VM uses both small pages (4 Kbytes), and big pages (2 Mbytes). |
---|
[527] | 43 | // Each page table (one page table per virtual space) is monolithic, and |
---|
| 44 | // contains one PT1 (8 Kbytes) and a variable number of PT2s (4 Kbytes each). |
---|
[631] | 45 | // For each vspace, the max number of PT2s is defined by the size of the PTAB |
---|
| 46 | // vseg in the mapping. |
---|
[527] | 47 | // The PT1 is indexed by the ix1 field (11 bits) of the VPN. An entry is 32 bits. |
---|
| 48 | // A PT2 is indexed the ix2 field (9 bits) of the VPN. An entry is 64 bits. |
---|
[412] | 49 | // The first word contains the flags, the second word contains the PPN. |
---|
[631] | 50 | // |
---|
| 51 | // 3) The Giet-VM implement one private scheduler per processor. |
---|
| 52 | // For each application, the tasks are statically allocated to processors |
---|
| 53 | // and there is no task migration during execution. |
---|
| 54 | // Each sheduler occupies 8K bytes, and contains up to 14 task contexts |
---|
| 55 | // The task context [13] is reserved for the "idle" task that does nothing, and |
---|
| 56 | // is launched by the scheduler when there is no other runable task. |
---|
[527] | 57 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[263] | 58 | // Implementation Notes: |
---|
| 59 | // |
---|
[527] | 60 | // 1) The cluster_id variable is a linear index in the mapping_info array. |
---|
[493] | 61 | // The cluster_xy variable is the tological index = x << Y_WIDTH + y |
---|
[412] | 62 | // |
---|
[493] | 63 | // 2) We set the _tty0_boot_mode variable to force the _printf() function to use |
---|
| 64 | // the tty0_spin_lock for exclusive access to TTY0. |
---|
[527] | 65 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 66 | |
---|
[263] | 67 | #include <giet_config.h> |
---|
[464] | 68 | #include <hard_config.h> |
---|
[436] | 69 | #include <mapping_info.h> |
---|
[464] | 70 | #include <kernel_malloc.h> |
---|
[258] | 71 | #include <memspace.h> |
---|
| 72 | #include <tty_driver.h> |
---|
| 73 | #include <xcu_driver.h> |
---|
[347] | 74 | #include <bdv_driver.h> |
---|
[460] | 75 | #include <hba_driver.h> |
---|
[527] | 76 | #include <sdc_driver.h> |
---|
[258] | 77 | #include <cma_driver.h> |
---|
| 78 | #include <nic_driver.h> |
---|
[299] | 79 | #include <iob_driver.h> |
---|
[295] | 80 | #include <pic_driver.h> |
---|
[258] | 81 | #include <mwr_driver.h> |
---|
[527] | 82 | #include <dma_driver.h> |
---|
[631] | 83 | #include <mmc_driver.h> |
---|
[258] | 84 | #include <ctx_handler.h> |
---|
| 85 | #include <irq_handler.h> |
---|
| 86 | #include <vmem.h> |
---|
[412] | 87 | #include <pmem.h> |
---|
[258] | 88 | #include <utils.h> |
---|
[460] | 89 | #include <tty0.h> |
---|
[493] | 90 | #include <kernel_locks.h> |
---|
| 91 | #include <kernel_barriers.h> |
---|
[258] | 92 | #include <elf-types.h> |
---|
| 93 | #include <fat32.h> |
---|
| 94 | #include <mips32_registers.h> |
---|
| 95 | #include <stdarg.h> |
---|
| 96 | |
---|
[263] | 97 | #if !defined(X_SIZE) |
---|
[359] | 98 | # error: The X_SIZE value must be defined in the 'hard_config.h' file ! |
---|
[258] | 99 | #endif |
---|
| 100 | |
---|
[263] | 101 | #if !defined(Y_SIZE) |
---|
[359] | 102 | # error: The Y_SIZE value must be defined in the 'hard_config.h' file ! |
---|
[263] | 103 | #endif |
---|
| 104 | |
---|
| 105 | #if !defined(X_WIDTH) |
---|
[359] | 106 | # error: The X_WIDTH value must be defined in the 'hard_config.h' file ! |
---|
[263] | 107 | #endif |
---|
| 108 | |
---|
| 109 | #if !defined(Y_WIDTH) |
---|
[359] | 110 | # error: The Y_WIDTH value must be defined in the 'hard_config.h' file ! |
---|
[263] | 111 | #endif |
---|
| 112 | |
---|
[321] | 113 | #if !defined(SEG_BOOT_MAPPING_BASE) |
---|
[359] | 114 | # error: The SEG_BOOT_MAPPING_BASE value must be defined in the hard_config.h file ! |
---|
[321] | 115 | #endif |
---|
| 116 | |
---|
[359] | 117 | #if !defined(NB_PROCS_MAX) |
---|
| 118 | # error: The NB_PROCS_MAX value must be defined in the 'hard_config.h' file ! |
---|
[321] | 119 | #endif |
---|
| 120 | |
---|
[359] | 121 | #if !defined(GIET_NB_VSPACE_MAX) |
---|
| 122 | # error: The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file ! |
---|
[321] | 123 | #endif |
---|
| 124 | |
---|
[359] | 125 | #if !defined(GIET_ELF_BUFFER_SIZE) |
---|
| 126 | # error: The GIET_ELF_BUFFER_SIZE value must be defined in the giet_config.h file ! |
---|
[258] | 127 | #endif |
---|
| 128 | |
---|
| 129 | //////////////////////////////////////////////////////////////////////////// |
---|
| 130 | // Global variables for boot code |
---|
| 131 | //////////////////////////////////////////////////////////////////////////// |
---|
| 132 | |
---|
[412] | 133 | // Temporaty buffer used to load one complete .elf file |
---|
[493] | 134 | __attribute__((section(".kdata"))) |
---|
[590] | 135 | unsigned char _boot_elf_buffer[GIET_ELF_BUFFER_SIZE] __attribute__((aligned(64))); |
---|
[258] | 136 | |
---|
[412] | 137 | // Physical memory allocators array (one per cluster) |
---|
[493] | 138 | __attribute__((section(".kdata"))) |
---|
[527] | 139 | pmem_alloc_t boot_pmem_alloc[X_SIZE][Y_SIZE]; |
---|
[258] | 140 | |
---|
[412] | 141 | // Schedulers virtual base addresses array (one per processor) |
---|
[493] | 142 | __attribute__((section(".kdata"))) |
---|
| 143 | static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
[258] | 144 | |
---|
[527] | 145 | // Page tables virtual base addresses (one per vspace and per cluster) |
---|
[493] | 146 | __attribute__((section(".kdata"))) |
---|
| 147 | unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; |
---|
[258] | 148 | |
---|
[412] | 149 | // Page tables physical base addresses (one per vspace and per cluster) |
---|
[493] | 150 | __attribute__((section(".kdata"))) |
---|
| 151 | paddr_t _ptabs_paddr[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; |
---|
[258] | 152 | |
---|
[412] | 153 | // Page tables pt2 allocators (one per vspace and per cluster) |
---|
[493] | 154 | __attribute__((section(".kdata"))) |
---|
| 155 | unsigned int _ptabs_next_pt2[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; |
---|
[263] | 156 | |
---|
[412] | 157 | // Page tables max_pt2 (same value for all page tables) |
---|
[493] | 158 | __attribute__((section(".kdata"))) |
---|
| 159 | unsigned int _ptabs_max_pt2; |
---|
[412] | 160 | |
---|
[493] | 161 | // boot code uses a spin lock to protect TTY0 |
---|
| 162 | __attribute__((section(".kdata"))) |
---|
| 163 | unsigned int _tty0_boot_mode = 1; |
---|
[490] | 164 | |
---|
[578] | 165 | // boot code does not uses a lock to protect HBA command allocator |
---|
[493] | 166 | __attribute__((section(".kdata"))) |
---|
[578] | 167 | unsigned int _hba_boot_mode = 1; |
---|
| 168 | |
---|
| 169 | __attribute__((section(".kdata"))) |
---|
[493] | 170 | spin_lock_t _ptabs_spin_lock[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; |
---|
[490] | 171 | |
---|
[493] | 172 | // barrier used by boot code for parallel execution |
---|
| 173 | __attribute__((section(".kdata"))) |
---|
| 174 | simple_barrier_t _barrier_all_clusters; |
---|
[490] | 175 | |
---|
[527] | 176 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 177 | // Extern variables |
---|
| 178 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 179 | |
---|
[631] | 180 | // this variable is allocated in the tty0.c file |
---|
[493] | 181 | extern spin_lock_t _tty0_spin_lock; |
---|
[464] | 182 | |
---|
[631] | 183 | // this variable is allocated in the mmc_driver.c |
---|
| 184 | extern unsigned int _mmc_boot_mode; |
---|
| 185 | |
---|
[527] | 186 | extern void boot_entry(); |
---|
| 187 | |
---|
[258] | 188 | ////////////////////////////////////////////////////////////////////////////// |
---|
[412] | 189 | // This function registers a new PTE1 in the page table defined |
---|
| 190 | // by the vspace_id argument, and the (x,y) coordinates. |
---|
| 191 | // It updates only the first level PT1. |
---|
[493] | 192 | // As each vseg is mapped by a different processor, the PT1 entry cannot |
---|
| 193 | // be concurrently accessed, and we don't need to take any lock. |
---|
[258] | 194 | ////////////////////////////////////////////////////////////////////////////// |
---|
[412] | 195 | void boot_add_pte1( unsigned int vspace_id, |
---|
| 196 | unsigned int x, |
---|
| 197 | unsigned int y, |
---|
| 198 | unsigned int vpn, // 20 bits right-justified |
---|
| 199 | unsigned int flags, // 10 bits left-justified |
---|
| 200 | unsigned int ppn ) // 28 bits right-justified |
---|
[258] | 201 | { |
---|
[412] | 202 | // compute index in PT1 |
---|
| 203 | unsigned int ix1 = vpn >> 9; // 11 bits for ix1 |
---|
[258] | 204 | |
---|
[412] | 205 | // get page table physical base address |
---|
[493] | 206 | paddr_t pt1_pbase = _ptabs_paddr[vspace_id][x][y]; |
---|
[412] | 207 | |
---|
| 208 | if ( pt1_pbase == 0 ) |
---|
[258] | 209 | { |
---|
[493] | 210 | _printf("\n[BOOT ERROR] in boot_add_pte1() : no PTAB in cluster[%d,%d]" |
---|
| 211 | " containing processors\n", x , y ); |
---|
[258] | 212 | _exit(); |
---|
| 213 | } |
---|
| 214 | |
---|
[412] | 215 | // compute pte1 : 2 bits V T / 8 bits flags / 3 bits RSVD / 19 bits bppi |
---|
| 216 | unsigned int pte1 = PTE_V | |
---|
| 217 | (flags & 0x3FC00000) | |
---|
| 218 | ((ppn>>9) & 0x0007FFFF); |
---|
[258] | 219 | |
---|
[412] | 220 | // write pte1 in PT1 |
---|
| 221 | _physical_write( pt1_pbase + 4*ix1, pte1 ); |
---|
| 222 | |
---|
[493] | 223 | asm volatile ("sync"); |
---|
[412] | 224 | |
---|
| 225 | } // end boot_add_pte1() |
---|
| 226 | |
---|
[258] | 227 | ////////////////////////////////////////////////////////////////////////////// |
---|
[412] | 228 | // This function registers a new PTE2 in the page table defined |
---|
[347] | 229 | // by the vspace_id argument, and the (x,y) coordinates. |
---|
[412] | 230 | // It updates both the first level PT1 and the second level PT2. |
---|
[258] | 231 | // As the set of PT2s is implemented as a fixed size array (no dynamic |
---|
| 232 | // allocation), this function checks a possible overflow of the PT2 array. |
---|
[493] | 233 | // As a given entry in PT1 can be shared by several vsegs, mapped by |
---|
| 234 | // different processors, we need to take the lock protecting PTAB[v][x]y]. |
---|
[258] | 235 | ////////////////////////////////////////////////////////////////////////////// |
---|
[412] | 236 | void boot_add_pte2( unsigned int vspace_id, |
---|
| 237 | unsigned int x, |
---|
| 238 | unsigned int y, |
---|
| 239 | unsigned int vpn, // 20 bits right-justified |
---|
| 240 | unsigned int flags, // 10 bits left-justified |
---|
| 241 | unsigned int ppn ) // 28 bits right-justified |
---|
[258] | 242 | { |
---|
| 243 | unsigned int ix1; |
---|
| 244 | unsigned int ix2; |
---|
[347] | 245 | paddr_t pt2_pbase; // PT2 physical base address |
---|
[412] | 246 | paddr_t pte2_paddr; // PTE2 physical address |
---|
[258] | 247 | unsigned int pt2_id; // PT2 index |
---|
| 248 | unsigned int ptd; // PTD : entry in PT1 |
---|
| 249 | |
---|
[412] | 250 | ix1 = vpn >> 9; // 11 bits for ix1 |
---|
| 251 | ix2 = vpn & 0x1FF; // 9 bits for ix2 |
---|
[258] | 252 | |
---|
[493] | 253 | // get page table physical base address |
---|
[347] | 254 | paddr_t pt1_pbase = _ptabs_paddr[vspace_id][x][y]; |
---|
[258] | 255 | |
---|
[412] | 256 | if ( pt1_pbase == 0 ) |
---|
[258] | 257 | { |
---|
[493] | 258 | _printf("\n[BOOT ERROR] in boot_add_pte2() : no PTAB for vspace %d " |
---|
| 259 | "in cluster[%d,%d]\n", vspace_id , x , y ); |
---|
[258] | 260 | _exit(); |
---|
| 261 | } |
---|
| 262 | |
---|
[493] | 263 | // get lock protecting PTAB[vspace_id][x][y] |
---|
| 264 | _spin_lock_acquire( &_ptabs_spin_lock[vspace_id][x][y] ); |
---|
| 265 | |
---|
[258] | 266 | // get ptd in PT1 |
---|
[493] | 267 | ptd = _physical_read( pt1_pbase + 4 * ix1 ); |
---|
[258] | 268 | |
---|
[347] | 269 | if ((ptd & PTE_V) == 0) // undefined PTD: compute PT2 base address, |
---|
[258] | 270 | // and set a new PTD in PT1 |
---|
| 271 | { |
---|
[493] | 272 | // get a new pt2_id |
---|
[347] | 273 | pt2_id = _ptabs_next_pt2[vspace_id][x][y]; |
---|
[493] | 274 | _ptabs_next_pt2[vspace_id][x][y] = pt2_id + 1; |
---|
| 275 | |
---|
| 276 | // check overflow |
---|
[412] | 277 | if (pt2_id == _ptabs_max_pt2) |
---|
[258] | 278 | { |
---|
[493] | 279 | _printf("\n[BOOT ERROR] in boot_add_pte2() : PTAB[%d,%d,%d]" |
---|
| 280 | " contains not enough PT2s\n", vspace_id, x, y ); |
---|
[258] | 281 | _exit(); |
---|
| 282 | } |
---|
[347] | 283 | |
---|
| 284 | pt2_pbase = pt1_pbase + PT1_SIZE + PT2_SIZE * pt2_id; |
---|
| 285 | ptd = PTE_V | PTE_T | (unsigned int) (pt2_pbase >> 12); |
---|
[493] | 286 | |
---|
| 287 | // set PTD into PT1 |
---|
[412] | 288 | _physical_write( pt1_pbase + 4*ix1, ptd); |
---|
[258] | 289 | } |
---|
| 290 | else // valid PTD: compute PT2 base address |
---|
| 291 | { |
---|
| 292 | pt2_pbase = ((paddr_t)(ptd & 0x0FFFFFFF)) << 12; |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | // set PTE in PT2 : flags & PPN in two 32 bits words |
---|
[412] | 296 | pte2_paddr = pt2_pbase + 8 * ix2; |
---|
[493] | 297 | _physical_write(pte2_paddr , (PTE_V | flags) ); |
---|
| 298 | _physical_write(pte2_paddr + 4 , ppn ); |
---|
[258] | 299 | |
---|
[493] | 300 | // release lock protecting PTAB[vspace_id][x][y] |
---|
| 301 | _spin_lock_release( &_ptabs_spin_lock[vspace_id][x][y] ); |
---|
| 302 | |
---|
| 303 | asm volatile ("sync"); |
---|
| 304 | |
---|
[412] | 305 | } // end boot_add_pte2() |
---|
[258] | 306 | |
---|
[412] | 307 | //////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 308 | // Align the value of paddr or vaddr to the required alignement, |
---|
| 309 | // defined by alignPow2 == L2(alignement). |
---|
[412] | 310 | //////////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 311 | paddr_t paddr_align_to( paddr_t paddr, unsigned int alignPow2 ) |
---|
[258] | 312 | { |
---|
| 313 | paddr_t mask = (1 << alignPow2) - 1; |
---|
| 314 | return ((paddr + mask) & ~mask); |
---|
| 315 | } |
---|
| 316 | |
---|
[493] | 317 | unsigned int vaddr_align_to( unsigned int vaddr, unsigned int alignPow2 ) |
---|
[258] | 318 | { |
---|
| 319 | unsigned int mask = (1 << alignPow2) - 1; |
---|
| 320 | return ((vaddr + mask) & ~mask); |
---|
| 321 | } |
---|
| 322 | |
---|
[412] | 323 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
| 324 | // This function map a vseg identified by the vseg pointer. |
---|
| 325 | // |
---|
[493] | 326 | // A given vseg can be mapped in a Big Physical Pages (BPP: 2 Mbytes) or in a |
---|
[412] | 327 | // Small Physical Pages (SPP: 4 Kbytes), depending on the "big" attribute of vseg, |
---|
| 328 | // with the following rules: |
---|
| 329 | // - SPP : There is only one vseg in a small physical page, but a single vseg |
---|
| 330 | // can cover several contiguous small physical pages. |
---|
| 331 | // - BPP : It can exist several vsegs in a single big physical page, and a single |
---|
| 332 | // vseg can cover several contiguous big physical pages. |
---|
| 333 | // |
---|
[513] | 334 | // 1) First step: it computes various vseg attributes and checks |
---|
| 335 | // alignment constraints. |
---|
[412] | 336 | // |
---|
[493] | 337 | // 2) Second step: it allocates the required number of contiguous physical pages, |
---|
[412] | 338 | // computes the physical base address (if the vseg is not identity mapping), |
---|
| 339 | // and register it in the vseg pbase field. |
---|
[493] | 340 | // Only the vsegs used by the boot code and the peripheral vsegs |
---|
| 341 | // can be identity mapping. The first big physical page in cluster[0,0] |
---|
| 342 | // is reserved for the boot vsegs. |
---|
[412] | 343 | // |
---|
[513] | 344 | // 3) Third step (only for vseg that have the VSEG_TYPE_PTAB): the M page tables |
---|
[493] | 345 | // associated to the M vspaces must be packed in the same vseg. |
---|
| 346 | // We divide this vseg in M sub-segments, and compute the vbase and pbase |
---|
| 347 | // addresses for M page tables, and register these addresses in the _ptabs_paddr |
---|
[412] | 348 | // and _ptabs_vaddr arrays. |
---|
| 349 | // |
---|
| 350 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
[427] | 351 | void boot_vseg_map( mapping_vseg_t* vseg, |
---|
| 352 | unsigned int vspace_id ) |
---|
[258] | 353 | { |
---|
[412] | 354 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 355 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 356 | mapping_pseg_t* pseg = _get_pseg_base(header); |
---|
[258] | 357 | |
---|
[513] | 358 | //////////// First step : compute vseg attributes |
---|
| 359 | |
---|
[412] | 360 | // compute destination cluster pointer & coordinates |
---|
| 361 | pseg = pseg + vseg->psegid; |
---|
| 362 | cluster = cluster + pseg->clusterid; |
---|
| 363 | unsigned int x_dest = cluster->x; |
---|
| 364 | unsigned int y_dest = cluster->y; |
---|
[258] | 365 | |
---|
[412] | 366 | // compute the "big" vseg attribute |
---|
| 367 | unsigned int big = vseg->big; |
---|
[258] | 368 | |
---|
[513] | 369 | // all vsegs must be aligned on 4Kbytes |
---|
| 370 | if ( vseg->vbase & 0x00000FFF ) |
---|
| 371 | { |
---|
| 372 | _printf("\n[BOOT ERROR] vseg %s not aligned : vbase = %x\n", |
---|
| 373 | vseg->name, vseg->vbase ); |
---|
| 374 | _exit(); |
---|
| 375 | } |
---|
| 376 | |
---|
[412] | 377 | // compute the "is_ram" vseg attribute |
---|
| 378 | unsigned int is_ram; |
---|
| 379 | if ( pseg->type == PSEG_TYPE_RAM ) is_ram = 1; |
---|
| 380 | else is_ram = 0; |
---|
[258] | 381 | |
---|
[412] | 382 | // compute the "is_ptab" attribute |
---|
| 383 | unsigned int is_ptab; |
---|
[513] | 384 | if ( vseg->type == VSEG_TYPE_PTAB ) is_ptab = 1; |
---|
| 385 | else is_ptab = 0; |
---|
[258] | 386 | |
---|
[427] | 387 | // compute actual vspace index |
---|
| 388 | unsigned int vsid; |
---|
| 389 | if ( vspace_id == 0xFFFFFFFF ) vsid = 0; |
---|
| 390 | else vsid = vspace_id; |
---|
| 391 | |
---|
[412] | 392 | //////////// Second step : compute ppn and npages |
---|
| 393 | //////////// - if identity mapping : ppn <= vpn |
---|
| 394 | //////////// - if vseg is periph : ppn <= pseg.base >> 12 |
---|
| 395 | //////////// - if vseg is ram : ppn <= physical memory allocator |
---|
[258] | 396 | |
---|
[493] | 397 | unsigned int ppn; // first physical page index (28 bits = |x|y|bppi|sppi|) |
---|
| 398 | unsigned int vpn; // first virtual page index (20 bits = |ix1|ix2|) |
---|
| 399 | unsigned int vpn_max; // last virtual page index (20 bits = |ix1|ix2|) |
---|
[258] | 400 | |
---|
[412] | 401 | vpn = vseg->vbase >> 12; |
---|
| 402 | vpn_max = (vseg->vbase + vseg->length - 1) >> 12; |
---|
[258] | 403 | |
---|
[412] | 404 | // compute npages |
---|
| 405 | unsigned int npages; // number of required (big or small) pages |
---|
| 406 | if ( big == 0 ) npages = vpn_max - vpn + 1; // number of small pages |
---|
| 407 | else npages = (vpn_max>>9) - (vpn>>9) + 1; // number of big pages |
---|
| 408 | |
---|
| 409 | // compute ppn |
---|
| 410 | if ( vseg->ident ) // identity mapping |
---|
[258] | 411 | { |
---|
[412] | 412 | ppn = vpn; |
---|
[258] | 413 | } |
---|
[412] | 414 | else // not identity mapping |
---|
[258] | 415 | { |
---|
[412] | 416 | if ( is_ram ) // RAM : physical memory allocation required |
---|
[258] | 417 | { |
---|
[412] | 418 | // compute pointer on physical memory allocator in dest cluster |
---|
| 419 | pmem_alloc_t* palloc = &boot_pmem_alloc[x_dest][y_dest]; |
---|
[258] | 420 | |
---|
[412] | 421 | if ( big == 0 ) // SPP : small physical pages |
---|
| 422 | { |
---|
| 423 | // allocate contiguous small physical pages |
---|
| 424 | ppn = _get_small_ppn( palloc, npages ); |
---|
| 425 | } |
---|
| 426 | else // BPP : big physical pages |
---|
| 427 | { |
---|
| 428 | |
---|
| 429 | // one big page can be shared by several vsegs |
---|
| 430 | // we must chek if BPP already allocated |
---|
| 431 | if ( is_ptab ) // It cannot be mapped |
---|
| 432 | { |
---|
| 433 | ppn = _get_big_ppn( palloc, npages ); |
---|
| 434 | } |
---|
| 435 | else // It can be mapped |
---|
| 436 | { |
---|
| 437 | unsigned int ix1 = vpn >> 9; // 11 bits |
---|
[427] | 438 | paddr_t paddr = _ptabs_paddr[vsid][x_dest][y_dest] + (ix1<<2); |
---|
[412] | 439 | unsigned int pte1 = _physical_read( paddr ); |
---|
[493] | 440 | |
---|
[412] | 441 | if ( (pte1 & PTE_V) == 0 ) // BPP not allocated yet |
---|
| 442 | { |
---|
| 443 | // allocate contiguous big physical pages |
---|
[433] | 444 | ppn = _get_big_ppn( palloc, npages ); |
---|
[412] | 445 | } |
---|
| 446 | else // BPP already allocated |
---|
| 447 | { |
---|
[433] | 448 | // test if new vseg has the same mode bits than |
---|
| 449 | // the other vsegs in the same big page |
---|
| 450 | unsigned int pte1_mode = 0; |
---|
| 451 | if (pte1 & PTE_C) pte1_mode |= C_MODE_MASK; |
---|
| 452 | if (pte1 & PTE_X) pte1_mode |= X_MODE_MASK; |
---|
| 453 | if (pte1 & PTE_W) pte1_mode |= W_MODE_MASK; |
---|
| 454 | if (pte1 & PTE_U) pte1_mode |= U_MODE_MASK; |
---|
[493] | 455 | if (vseg->mode != pte1_mode) |
---|
| 456 | { |
---|
| 457 | _printf("\n[BOOT ERROR] in boot_vseg_map() : " |
---|
| 458 | "vseg %s has different flags than another vseg " |
---|
| 459 | "in the same BPP\n", vseg->name ); |
---|
[433] | 460 | _exit(); |
---|
| 461 | } |
---|
[412] | 462 | ppn = ((pte1 << 9) & 0x0FFFFE00); |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | ppn = ppn | (vpn & 0x1FF); |
---|
| 466 | } |
---|
[258] | 467 | } |
---|
[412] | 468 | else // PERI : no memory allocation required |
---|
[258] | 469 | { |
---|
[412] | 470 | ppn = pseg->base >> 12; |
---|
[258] | 471 | } |
---|
| 472 | } |
---|
| 473 | |
---|
[412] | 474 | // update vseg.pbase field and update vsegs chaining |
---|
| 475 | vseg->pbase = ((paddr_t)ppn) << 12; |
---|
[493] | 476 | vseg->mapped = 1; |
---|
[258] | 477 | |
---|
[412] | 478 | |
---|
| 479 | //////////// Third step : (only if the vseg is a page table) |
---|
| 480 | //////////// - compute the physical & virtual base address for each vspace |
---|
| 481 | //////////// by dividing the vseg in several sub-segments. |
---|
| 482 | //////////// - register it in _ptabs_vaddr & _ptabs_paddr arrays, |
---|
[427] | 483 | //////////// and initialize next_pt2 allocators. |
---|
| 484 | //////////// - reset all entries in first level page tables |
---|
[412] | 485 | |
---|
| 486 | if ( is_ptab ) |
---|
[258] | 487 | { |
---|
[412] | 488 | unsigned int vs; // vspace index |
---|
| 489 | unsigned int nspaces; // number of vspaces |
---|
| 490 | unsigned int nsp; // number of small pages for one PTAB |
---|
| 491 | unsigned int offset; // address offset for current PTAB |
---|
[258] | 492 | |
---|
[412] | 493 | nspaces = header->vspaces; |
---|
| 494 | offset = 0; |
---|
[258] | 495 | |
---|
[412] | 496 | // each PTAB must be aligned on a 8 Kbytes boundary |
---|
[427] | 497 | nsp = ( vseg->length >> 12 ) / nspaces; |
---|
[412] | 498 | if ( (nsp & 0x1) == 0x1 ) nsp = nsp - 1; |
---|
[258] | 499 | |
---|
[412] | 500 | // compute max_pt2 |
---|
| 501 | _ptabs_max_pt2 = ((nsp<<12) - PT1_SIZE) / PT2_SIZE; |
---|
[433] | 502 | |
---|
[412] | 503 | for ( vs = 0 ; vs < nspaces ; vs++ ) |
---|
[258] | 504 | { |
---|
[433] | 505 | _ptabs_vaddr [vs][x_dest][y_dest] = (vpn + offset) << 12; |
---|
[412] | 506 | _ptabs_paddr [vs][x_dest][y_dest] = ((paddr_t)(ppn + offset)) << 12; |
---|
| 507 | _ptabs_next_pt2[vs][x_dest][y_dest] = 0; |
---|
[427] | 508 | offset += nsp; |
---|
[433] | 509 | |
---|
[427] | 510 | // reset all entries in PT1 (8 Kbytes) |
---|
| 511 | _physical_memset( _ptabs_paddr[vs][x_dest][y_dest], PT1_SIZE, 0 ); |
---|
[258] | 512 | } |
---|
| 513 | } |
---|
| 514 | |
---|
[493] | 515 | asm volatile ("sync"); |
---|
| 516 | |
---|
[412] | 517 | #if BOOT_DEBUG_PT |
---|
[493] | 518 | if ( big ) |
---|
| 519 | _printf("\n[BOOT] vseg %s : cluster[%d,%d] / " |
---|
| 520 | "vbase = %x / length = %x / BIG / npages = %d / pbase = %l\n", |
---|
| 521 | vseg->name, x_dest, y_dest, vseg->vbase, vseg->length, npages, vseg-> pbase ); |
---|
| 522 | else |
---|
| 523 | _printf("\n[BOOT] vseg %s : cluster[%d,%d] / " |
---|
| 524 | "vbase = %x / length = %x / SMALL / npages = %d / pbase = %l\n", |
---|
| 525 | vseg->name, x_dest, y_dest, vseg->vbase, vseg->length, npages, vseg-> pbase ); |
---|
[412] | 526 | #endif |
---|
| 527 | |
---|
| 528 | } // end boot_vseg_map() |
---|
| 529 | |
---|
| 530 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 531 | // For the vseg defined by the vseg pointer, this function register PTEs |
---|
[412] | 532 | // in one or several page tables. |
---|
[436] | 533 | // It is a global vseg (kernel vseg) if (vspace_id == 0xFFFFFFFF). |
---|
[412] | 534 | // The number of involved PTABs depends on the "local" and "global" attributes: |
---|
| 535 | // - PTEs are replicated in all vspaces for a global vseg. |
---|
[493] | 536 | // - PTEs are replicated in all clusters containing procs for a non local vseg. |
---|
[412] | 537 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
[427] | 538 | void boot_vseg_pte( mapping_vseg_t* vseg, |
---|
| 539 | unsigned int vspace_id ) |
---|
[412] | 540 | { |
---|
| 541 | // compute the "global" vseg attribute and actual vspace index |
---|
| 542 | unsigned int global; |
---|
| 543 | unsigned int vsid; |
---|
| 544 | if ( vspace_id == 0xFFFFFFFF ) |
---|
[258] | 545 | { |
---|
[412] | 546 | global = 1; |
---|
| 547 | vsid = 0; |
---|
[258] | 548 | } |
---|
[412] | 549 | else |
---|
[258] | 550 | { |
---|
[412] | 551 | global = 0; |
---|
| 552 | vsid = vspace_id; |
---|
[258] | 553 | } |
---|
| 554 | |
---|
[412] | 555 | // compute the "local" and "big" attributes |
---|
| 556 | unsigned int local = vseg->local; |
---|
| 557 | unsigned int big = vseg->big; |
---|
[258] | 558 | |
---|
[412] | 559 | // compute vseg flags |
---|
[493] | 560 | // The three flags (Local, Remote and Dirty) are set to 1 |
---|
| 561 | // to avoid hardware update for these flags, because GIET_VM |
---|
| 562 | // does use these flags. |
---|
[412] | 563 | unsigned int flags = 0; |
---|
| 564 | if (vseg->mode & C_MODE_MASK) flags |= PTE_C; |
---|
| 565 | if (vseg->mode & X_MODE_MASK) flags |= PTE_X; |
---|
| 566 | if (vseg->mode & W_MODE_MASK) flags |= PTE_W; |
---|
| 567 | if (vseg->mode & U_MODE_MASK) flags |= PTE_U; |
---|
| 568 | if ( global ) flags |= PTE_G; |
---|
| 569 | flags |= PTE_L; |
---|
| 570 | flags |= PTE_R; |
---|
| 571 | flags |= PTE_D; |
---|
[258] | 572 | |
---|
[412] | 573 | // compute VPN, PPN and number of pages (big or small) |
---|
| 574 | unsigned int vpn = vseg->vbase >> 12; |
---|
| 575 | unsigned int vpn_max = (vseg->vbase + vseg->length - 1) >> 12; |
---|
| 576 | unsigned int ppn = (unsigned int)(vseg->pbase >> 12); |
---|
| 577 | unsigned int npages; |
---|
| 578 | if ( big == 0 ) npages = vpn_max - vpn + 1; |
---|
| 579 | else npages = (vpn_max>>9) - (vpn>>9) + 1; |
---|
| 580 | |
---|
[493] | 581 | // compute destination cluster coordinates, for local vsegs |
---|
| 582 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 583 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 584 | mapping_pseg_t* pseg = _get_pseg_base(header); |
---|
| 585 | mapping_pseg_t* pseg_dest = &pseg[vseg->psegid]; |
---|
| 586 | mapping_cluster_t* cluster_dest = &cluster[pseg_dest->clusterid]; |
---|
| 587 | unsigned int x_dest = cluster_dest->x; |
---|
| 588 | unsigned int y_dest = cluster_dest->y; |
---|
[412] | 589 | |
---|
[493] | 590 | unsigned int p; // iterator for physical page index |
---|
| 591 | unsigned int x; // iterator for cluster x coordinate |
---|
| 592 | unsigned int y; // iterator for cluster y coordinate |
---|
| 593 | unsigned int v; // iterator for vspace index |
---|
[412] | 594 | |
---|
| 595 | // loop on PTEs |
---|
| 596 | for ( p = 0 ; p < npages ; p++ ) |
---|
| 597 | { |
---|
| 598 | if ( (local != 0) && (global == 0) ) // one cluster / one vspace |
---|
[258] | 599 | { |
---|
[412] | 600 | if ( big ) // big pages => PTE1s |
---|
| 601 | { |
---|
| 602 | boot_add_pte1( vsid, |
---|
| 603 | x_dest, |
---|
| 604 | y_dest, |
---|
| 605 | vpn + (p<<9), |
---|
| 606 | flags, |
---|
| 607 | ppn + (p<<9) ); |
---|
| 608 | } |
---|
| 609 | else // small pages => PTE2s |
---|
| 610 | { |
---|
| 611 | boot_add_pte2( vsid, |
---|
| 612 | x_dest, |
---|
| 613 | y_dest, |
---|
| 614 | vpn + p, |
---|
| 615 | flags, |
---|
| 616 | ppn + p ); |
---|
| 617 | } |
---|
[258] | 618 | } |
---|
[412] | 619 | else if ( (local == 0) && (global == 0) ) // all clusters / one vspace |
---|
[258] | 620 | { |
---|
[412] | 621 | for ( x = 0 ; x < X_SIZE ; x++ ) |
---|
[258] | 622 | { |
---|
[412] | 623 | for ( y = 0 ; y < Y_SIZE ; y++ ) |
---|
| 624 | { |
---|
[493] | 625 | if ( cluster[(x * Y_SIZE) + y].procs ) |
---|
[412] | 626 | { |
---|
[493] | 627 | if ( big ) // big pages => PTE1s |
---|
| 628 | { |
---|
| 629 | boot_add_pte1( vsid, |
---|
| 630 | x, |
---|
| 631 | y, |
---|
| 632 | vpn + (p<<9), |
---|
| 633 | flags, |
---|
| 634 | ppn + (p<<9) ); |
---|
| 635 | } |
---|
| 636 | else // small pages => PTE2s |
---|
| 637 | { |
---|
| 638 | boot_add_pte2( vsid, |
---|
| 639 | x, |
---|
| 640 | y, |
---|
| 641 | vpn + p, |
---|
| 642 | flags, |
---|
| 643 | ppn + p ); |
---|
| 644 | } |
---|
[412] | 645 | } |
---|
| 646 | } |
---|
[258] | 647 | } |
---|
[412] | 648 | } |
---|
| 649 | else if ( (local != 0) && (global != 0) ) // one cluster / all vspaces |
---|
| 650 | { |
---|
| 651 | for ( v = 0 ; v < header->vspaces ; v++ ) |
---|
[258] | 652 | { |
---|
[412] | 653 | if ( big ) // big pages => PTE1s |
---|
| 654 | { |
---|
| 655 | boot_add_pte1( v, |
---|
| 656 | x_dest, |
---|
| 657 | y_dest, |
---|
| 658 | vpn + (p<<9), |
---|
| 659 | flags, |
---|
| 660 | ppn + (p<<9) ); |
---|
| 661 | } |
---|
| 662 | else // small pages = PTE2s |
---|
| 663 | { |
---|
| 664 | boot_add_pte2( v, |
---|
| 665 | x_dest, |
---|
| 666 | y_dest, |
---|
| 667 | vpn + p, |
---|
| 668 | flags, |
---|
| 669 | ppn + p ); |
---|
| 670 | } |
---|
[258] | 671 | } |
---|
[412] | 672 | } |
---|
| 673 | else if ( (local == 0) && (global != 0) ) // all clusters / all vspaces |
---|
| 674 | { |
---|
| 675 | for ( x = 0 ; x < X_SIZE ; x++ ) |
---|
[258] | 676 | { |
---|
[412] | 677 | for ( y = 0 ; y < Y_SIZE ; y++ ) |
---|
| 678 | { |
---|
[493] | 679 | if ( cluster[(x * Y_SIZE) + y].procs ) |
---|
[412] | 680 | { |
---|
[493] | 681 | for ( v = 0 ; v < header->vspaces ; v++ ) |
---|
[412] | 682 | { |
---|
[493] | 683 | if ( big ) // big pages => PTE1s |
---|
| 684 | { |
---|
| 685 | boot_add_pte1( v, |
---|
| 686 | x, |
---|
| 687 | y, |
---|
| 688 | vpn + (p<<9), |
---|
| 689 | flags, |
---|
| 690 | ppn + (p<<9) ); |
---|
| 691 | } |
---|
| 692 | else // small pages -> PTE2s |
---|
| 693 | { |
---|
| 694 | boot_add_pte2( v, |
---|
| 695 | x, |
---|
| 696 | y, |
---|
| 697 | vpn + p, |
---|
| 698 | flags, |
---|
| 699 | ppn + p ); |
---|
| 700 | } |
---|
[412] | 701 | } |
---|
| 702 | } |
---|
| 703 | } |
---|
[258] | 704 | } |
---|
| 705 | } |
---|
[412] | 706 | } // end for pages |
---|
[493] | 707 | |
---|
| 708 | asm volatile ("sync"); |
---|
| 709 | |
---|
[427] | 710 | } // end boot_vseg_pte() |
---|
[258] | 711 | |
---|
[493] | 712 | |
---|
[412] | 713 | /////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 714 | // This function is executed by processor[x][y][0] in each cluster |
---|
| 715 | // containing at least one processor. |
---|
| 716 | // It initialises all page table for all global or private vsegs |
---|
| 717 | // mapped in cluster[x][y], as specified in the mapping. |
---|
[412] | 718 | // In each cluster all page tables for the different vspaces must be |
---|
| 719 | // packed in one vseg occupying one single BPP (Big Physical Page). |
---|
[490] | 720 | // |
---|
[412] | 721 | // For each vseg, the mapping is done in two steps: |
---|
[436] | 722 | // 1) mapping : the boot_vseg_map() function allocates contiguous BPPs |
---|
[412] | 723 | // or SPPs (if the vseg is not associated to a peripheral), and register |
---|
| 724 | // the physical base address in the vseg pbase field. It initialises the |
---|
[493] | 725 | // _ptabs_vaddr[] and _ptabs_paddr[] arrays if the vseg is a PTAB. |
---|
[412] | 726 | // |
---|
[436] | 727 | // 2) page table initialisation : the boot_vseg_pte() function initialise |
---|
[412] | 728 | // the PTEs (both PTE1 and PTE2) in one or several page tables: |
---|
| 729 | // - PTEs are replicated in all vspaces for a global vseg. |
---|
| 730 | // - PTEs are replicated in all clusters for a non local vseg. |
---|
| 731 | // |
---|
| 732 | // We must handle vsegs in the following order |
---|
[493] | 733 | // 1) global vseg containing PTAB mapped in cluster[x][y], |
---|
| 734 | // 2) global vsegs occupying more than one BPP mapped in cluster[x][y], |
---|
| 735 | // 3) others global vsegs mapped in cluster[x][y], |
---|
| 736 | // 4) all private vsegs in all user spaces mapped in cluster[x][y]. |
---|
[412] | 737 | /////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 738 | void boot_ptab_init( unsigned int cx, |
---|
| 739 | unsigned int cy ) |
---|
[258] | 740 | { |
---|
[412] | 741 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 742 | mapping_vspace_t* vspace = _get_vspace_base(header); |
---|
| 743 | mapping_vseg_t* vseg = _get_vseg_base(header); |
---|
[490] | 744 | mapping_cluster_t* cluster ; |
---|
| 745 | mapping_pseg_t* pseg ; |
---|
[258] | 746 | |
---|
| 747 | unsigned int vspace_id; |
---|
| 748 | unsigned int vseg_id; |
---|
| 749 | |
---|
[490] | 750 | unsigned int procid = _get_procid(); |
---|
| 751 | unsigned int lpid = procid & ((1<<P_WIDTH)-1); |
---|
| 752 | |
---|
[493] | 753 | if( lpid ) |
---|
[490] | 754 | { |
---|
[493] | 755 | _printf("\n[BOOT ERROR] in boot_ptab_init() : " |
---|
| 756 | "P[%d][%d][%d] should not execute it\n", cx, cy, lpid ); |
---|
[490] | 757 | _exit(); |
---|
| 758 | } |
---|
| 759 | |
---|
[493] | 760 | if ( header->vspaces == 0 ) |
---|
[258] | 761 | { |
---|
[493] | 762 | _printf("\n[BOOT ERROR] in boot_ptab_init() : " |
---|
| 763 | "mapping %s contains no vspace\n", header->name ); |
---|
[258] | 764 | _exit(); |
---|
| 765 | } |
---|
| 766 | |
---|
[493] | 767 | ///////// Phase 1 : global vseg containing the PTAB (two barriers required) |
---|
[412] | 768 | |
---|
[513] | 769 | // get PTAB global vseg in cluster(cx,cy) |
---|
[493] | 770 | unsigned int found = 0; |
---|
[412] | 771 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 772 | { |
---|
[490] | 773 | pseg = _get_pseg_base(header) + vseg[vseg_id].psegid; |
---|
| 774 | cluster = _get_cluster_base(header) + pseg->clusterid; |
---|
[513] | 775 | if ( (vseg[vseg_id].type == VSEG_TYPE_PTAB) && |
---|
[493] | 776 | (cluster->x == cx) && (cluster->y == cy) ) |
---|
[412] | 777 | { |
---|
[493] | 778 | found = 1; |
---|
| 779 | break; |
---|
[412] | 780 | } |
---|
| 781 | } |
---|
[493] | 782 | if ( found == 0 ) |
---|
[258] | 783 | { |
---|
[493] | 784 | _printf("\n[BOOT ERROR] in boot_ptab_init() : " |
---|
| 785 | "cluster[%d][%d] contains no PTAB vseg\n", cx , cy ); |
---|
| 786 | _exit(); |
---|
[258] | 787 | } |
---|
| 788 | |
---|
[493] | 789 | boot_vseg_map( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
[490] | 790 | |
---|
[493] | 791 | ////////////////////////////////////////////// |
---|
| 792 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 793 | ////////////////////////////////////////////// |
---|
[412] | 794 | |
---|
[493] | 795 | boot_vseg_pte( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
[412] | 796 | |
---|
[493] | 797 | ////////////////////////////////////////////// |
---|
| 798 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 799 | ////////////////////////////////////////////// |
---|
| 800 | |
---|
| 801 | ///////// Phase 2 : global vsegs occupying more than one BPP |
---|
| 802 | |
---|
[258] | 803 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 804 | { |
---|
[490] | 805 | pseg = _get_pseg_base(header) + vseg[vseg_id].psegid; |
---|
| 806 | cluster = _get_cluster_base(header) + pseg->clusterid; |
---|
[513] | 807 | if ( (vseg[vseg_id].length > 0x200000) && |
---|
[490] | 808 | (vseg[vseg_id].mapped == 0) && |
---|
[493] | 809 | (cluster->x == cx) && (cluster->y == cy) ) |
---|
[412] | 810 | { |
---|
[427] | 811 | boot_vseg_map( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
| 812 | boot_vseg_pte( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
[412] | 813 | } |
---|
[258] | 814 | } |
---|
| 815 | |
---|
[493] | 816 | ///////// Phase 3 : all others global vsegs |
---|
[347] | 817 | |
---|
[412] | 818 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
[493] | 819 | { |
---|
[490] | 820 | pseg = _get_pseg_base(header) + vseg[vseg_id].psegid; |
---|
| 821 | cluster = _get_cluster_base(header) + pseg->clusterid; |
---|
[493] | 822 | if ( (vseg[vseg_id].mapped == 0) && |
---|
| 823 | (cluster->x == cx) && (cluster->y == cy) ) |
---|
[412] | 824 | { |
---|
[427] | 825 | boot_vseg_map( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
| 826 | boot_vseg_pte( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
[412] | 827 | } |
---|
| 828 | } |
---|
| 829 | |
---|
[493] | 830 | ///////// Phase 4 : all private vsegs |
---|
[412] | 831 | |
---|
[258] | 832 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 833 | { |
---|
| 834 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 835 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 836 | vseg_id++) |
---|
| 837 | { |
---|
[490] | 838 | pseg = _get_pseg_base(header) + vseg[vseg_id].psegid; |
---|
| 839 | cluster = _get_cluster_base(header) + pseg->clusterid; |
---|
[493] | 840 | if ( (cluster->x == cx) && (cluster->y == cy) ) |
---|
[490] | 841 | { |
---|
| 842 | boot_vseg_map( &vseg[vseg_id], vspace_id ); |
---|
| 843 | boot_vseg_pte( &vseg[vseg_id], vspace_id ); |
---|
| 844 | } |
---|
[258] | 845 | } |
---|
| 846 | } |
---|
| 847 | |
---|
[493] | 848 | ////////////////////////////////////////////// |
---|
| 849 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 850 | ////////////////////////////////////////////// |
---|
[258] | 851 | |
---|
[493] | 852 | } // end boot_ptab_init() |
---|
[258] | 853 | |
---|
[493] | 854 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 855 | // This function should be executed by P[0][0][0] only. It complete the |
---|
| 856 | // page table initialisation, taking care of all global vsegs that are |
---|
| 857 | // not mapped in a cluster containing a processor, and have not been |
---|
| 858 | // handled by the boot_ptab_init(x,y) function. |
---|
| 859 | // An example of such vsegs are the external peripherals in TSAR_LETI platform. |
---|
| 860 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 861 | void boot_ptab_extend() |
---|
[258] | 862 | { |
---|
| 863 | |
---|
[493] | 864 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 865 | mapping_vseg_t* vseg = _get_vseg_base(header); |
---|
[258] | 866 | |
---|
[493] | 867 | unsigned int vseg_id; |
---|
| 868 | |
---|
| 869 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
[258] | 870 | { |
---|
[493] | 871 | if ( vseg[vseg_id].mapped == 0 ) |
---|
[258] | 872 | { |
---|
[493] | 873 | boot_vseg_map( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
| 874 | boot_vseg_pte( &vseg[vseg_id], 0xFFFFFFFF ); |
---|
[452] | 875 | } |
---|
| 876 | } |
---|
[493] | 877 | } // end boot_ptab_extend() |
---|
[258] | 878 | |
---|
| 879 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 880 | // This function returns in the vbase and length buffers the virtual base |
---|
| 881 | // address and the length of the segment allocated to the schedulers array |
---|
| 882 | // in the cluster defined by the clusterid argument. |
---|
| 883 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 884 | void boot_get_sched_vaddr( unsigned int cluster_id, |
---|
| 885 | unsigned int* vbase, |
---|
| 886 | unsigned int* length ) |
---|
| 887 | { |
---|
[321] | 888 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
[258] | 889 | mapping_vseg_t* vseg = _get_vseg_base(header); |
---|
| 890 | mapping_pseg_t* pseg = _get_pseg_base(header); |
---|
| 891 | |
---|
| 892 | unsigned int vseg_id; |
---|
| 893 | unsigned int found = 0; |
---|
| 894 | |
---|
| 895 | for ( vseg_id = 0 ; (vseg_id < header->vsegs) && (found == 0) ; vseg_id++ ) |
---|
| 896 | { |
---|
[513] | 897 | if ( (vseg[vseg_id].type == VSEG_TYPE_SCHED) && |
---|
[263] | 898 | (pseg[vseg[vseg_id].psegid].clusterid == cluster_id ) ) |
---|
[258] | 899 | { |
---|
| 900 | *vbase = vseg[vseg_id].vbase; |
---|
[513] | 901 | *length = vseg[vseg_id].length; |
---|
[258] | 902 | found = 1; |
---|
| 903 | } |
---|
| 904 | } |
---|
| 905 | if ( found == 0 ) |
---|
| 906 | { |
---|
[263] | 907 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
[513] | 908 | _printf("\n[BOOT ERROR] No vseg of type SCHED in cluster [%d,%d]\n", |
---|
[493] | 909 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
[258] | 910 | _exit(); |
---|
| 911 | } |
---|
| 912 | } // end boot_get_sched_vaddr() |
---|
| 913 | |
---|
[527] | 914 | #if BOOT_DEBUG_SCHED |
---|
| 915 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 916 | // This debug function should be executed by only one procesor. |
---|
| 917 | // It loops on all processors in all clusters to display |
---|
| 918 | // the HWI / PTI / WTI interrupt vectors for each processor. |
---|
| 919 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 920 | void boot_sched_irq_display() |
---|
| 921 | { |
---|
| 922 | unsigned int cx; |
---|
| 923 | unsigned int cy; |
---|
| 924 | unsigned int lpid; |
---|
| 925 | unsigned int slot; |
---|
| 926 | unsigned int entry; |
---|
[564] | 927 | unsigned int type; |
---|
| 928 | unsigned int channel; |
---|
[527] | 929 | |
---|
| 930 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 931 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 932 | |
---|
| 933 | static_scheduler_t* psched; |
---|
| 934 | |
---|
| 935 | for ( cx = 0 ; cx < X_SIZE ; cx++ ) |
---|
| 936 | { |
---|
| 937 | for ( cy = 0 ; cy < Y_SIZE ; cy++ ) |
---|
| 938 | { |
---|
| 939 | unsigned int cluster_id = (cx * Y_SIZE) + cy; |
---|
| 940 | unsigned int nprocs = cluster[cluster_id].procs; |
---|
| 941 | |
---|
| 942 | for ( lpid = 0 ; lpid < nprocs ; lpid++ ) |
---|
| 943 | { |
---|
| 944 | psched = _schedulers[cx][cy][lpid]; |
---|
| 945 | |
---|
[564] | 946 | _printf("\n[BOOT] interrupt vectors for proc[%d,%d,%d]\n", |
---|
[527] | 947 | cx , cy , lpid ); |
---|
| 948 | |
---|
| 949 | for ( slot = 0 ; slot < 32 ; slot++ ) |
---|
| 950 | { |
---|
[564] | 951 | entry = psched->hwi_vector[slot]; |
---|
| 952 | type = entry & 0xFFFF; |
---|
| 953 | channel = entry >> 16; |
---|
| 954 | if ( type != ISR_DEFAULT ) |
---|
| 955 | _printf(" - HWI : index = %d / type = %s / channel = %d\n", |
---|
| 956 | slot , _isr_type_str[type] , channel ); |
---|
[527] | 957 | } |
---|
| 958 | for ( slot = 0 ; slot < 32 ; slot++ ) |
---|
| 959 | { |
---|
[564] | 960 | entry = psched->wti_vector[slot]; |
---|
| 961 | type = entry & 0xFFFF; |
---|
| 962 | channel = entry >> 16; |
---|
| 963 | if ( type != ISR_DEFAULT ) |
---|
| 964 | _printf(" - WTI : index = %d / type = %s / channel = %d\n", |
---|
| 965 | slot , _isr_type_str[type] , channel ); |
---|
[527] | 966 | } |
---|
| 967 | for ( slot = 0 ; slot < 32 ; slot++ ) |
---|
| 968 | { |
---|
[564] | 969 | entry = psched->pti_vector[slot]; |
---|
| 970 | type = entry & 0xFFFF; |
---|
| 971 | channel = entry >> 16; |
---|
| 972 | if ( type != ISR_DEFAULT ) |
---|
| 973 | _printf(" - PTI : index = %d / type = %s / channel = %d\n", |
---|
| 974 | slot , _isr_type_str[type] , channel ); |
---|
[527] | 975 | } |
---|
| 976 | } |
---|
| 977 | } |
---|
| 978 | } |
---|
| 979 | } // end boot_sched_irq_display() |
---|
| 980 | #endif |
---|
| 981 | |
---|
| 982 | |
---|
[258] | 983 | //////////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 984 | // This function is executed in parallel by all processors P[x][y][0]. |
---|
| 985 | // It initialises all schedulers in cluster [x][y]. The MMU must be activated. |
---|
| 986 | // It is split in two phases separated by a synchronisation barrier. |
---|
[527] | 987 | // - In Step 1, it initialises the _schedulers[x][y][l] pointers array, the |
---|
| 988 | // idle_task context, the HWI / PTI / WTI interrupt vectors, |
---|
| 989 | // and the CU HWI / PTI / WTI masks. |
---|
[321] | 990 | // - In Step 2, it scan all tasks in all vspaces to complete the tasks contexts, |
---|
[493] | 991 | // initialisation as specified in the mapping_info data structure, |
---|
| 992 | // and set the CP0_SCHED register. |
---|
[258] | 993 | //////////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 994 | void boot_scheduler_init( unsigned int x, |
---|
| 995 | unsigned int y ) |
---|
[258] | 996 | { |
---|
[493] | 997 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 998 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 999 | mapping_vspace_t* vspace = _get_vspace_base(header); |
---|
[513] | 1000 | mapping_vseg_t* vseg = _get_vseg_base(header); |
---|
[493] | 1001 | mapping_task_t* task = _get_task_base(header); |
---|
| 1002 | mapping_periph_t* periph = _get_periph_base(header); |
---|
| 1003 | mapping_irq_t* irq = _get_irq_base(header); |
---|
[258] | 1004 | |
---|
[493] | 1005 | unsigned int periph_id; |
---|
| 1006 | unsigned int irq_id; |
---|
| 1007 | unsigned int vspace_id; |
---|
[513] | 1008 | unsigned int vseg_id; |
---|
[493] | 1009 | unsigned int task_id; |
---|
[258] | 1010 | |
---|
[493] | 1011 | unsigned int sched_vbase; // schedulers array vbase address |
---|
| 1012 | unsigned int sched_length; // schedulers array length |
---|
| 1013 | static_scheduler_t* psched; // pointer on processor scheduler |
---|
[321] | 1014 | |
---|
[527] | 1015 | unsigned int cluster_id = (x * Y_SIZE) + y; |
---|
| 1016 | unsigned int cluster_xy = (x << Y_WIDTH) + y; |
---|
[493] | 1017 | unsigned int nprocs = cluster[cluster_id].procs; |
---|
| 1018 | unsigned int lpid; |
---|
| 1019 | |
---|
[527] | 1020 | if ( nprocs > 8 ) |
---|
| 1021 | { |
---|
| 1022 | _printf("\n[BOOT ERROR] cluster[%d,%d] contains more than 8 procs\n", x, y ); |
---|
| 1023 | _exit(); |
---|
| 1024 | } |
---|
[258] | 1025 | |
---|
[527] | 1026 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 1027 | // Step 1 : - initialize the schedulers[] array of pointers, |
---|
| 1028 | // - initialize the "tasks" and "current variables. |
---|
| 1029 | // - initialise the idle task context. |
---|
| 1030 | // - initialize the HWI, PTI and WTI interrupt vectors. |
---|
| 1031 | // - initialize the XCU masks for HWI / WTI / PTI interrupts. |
---|
| 1032 | // |
---|
| 1033 | // The general policy for interrupts routing is the following: |
---|
| 1034 | // - the local HWI are statically allocatedted to local processors. |
---|
| 1035 | // - the nprocs first PTI are allocated for TICK (one per processor). |
---|
| 1036 | // - we allocate 4 WTI per processor: the first one is for WAKUP, |
---|
| 1037 | // the 3 others WTI are used for external interrupts (from PIC), |
---|
| 1038 | // and are dynamically allocated by kernel on demand. |
---|
| 1039 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 1040 | |
---|
[493] | 1041 | // get scheduler array virtual base address in cluster[x,y] |
---|
| 1042 | boot_get_sched_vaddr( cluster_id, &sched_vbase, &sched_length ); |
---|
[321] | 1043 | |
---|
[493] | 1044 | if ( sched_length < (nprocs<<13) ) // 8 Kbytes per scheduler |
---|
| 1045 | { |
---|
[527] | 1046 | _printf("\n[BOOT ERROR] Sched segment too small in cluster[%d,%d]\n", |
---|
| 1047 | x, y ); |
---|
[493] | 1048 | _exit(); |
---|
| 1049 | } |
---|
[321] | 1050 | |
---|
[493] | 1051 | // loop on local processors |
---|
| 1052 | for ( lpid = 0 ; lpid < nprocs ; lpid++ ) |
---|
[258] | 1053 | { |
---|
[493] | 1054 | // get scheduler pointer and initialise the schedulers pointers array |
---|
| 1055 | psched = (static_scheduler_t*)(sched_vbase + (lpid<<13)); |
---|
| 1056 | _schedulers[x][y][lpid] = psched; |
---|
[258] | 1057 | |
---|
[493] | 1058 | // initialise the "tasks" and "current" variables default values |
---|
| 1059 | psched->tasks = 0; |
---|
| 1060 | psched->current = IDLE_TASK_INDEX; |
---|
[258] | 1061 | |
---|
[527] | 1062 | // set default values for HWI / PTI / SWI vectors (valid bit = 0) |
---|
[493] | 1063 | unsigned int slot; |
---|
| 1064 | for (slot = 0; slot < 32; slot++) |
---|
[258] | 1065 | { |
---|
[493] | 1066 | psched->hwi_vector[slot] = 0; |
---|
| 1067 | psched->pti_vector[slot] = 0; |
---|
| 1068 | psched->wti_vector[slot] = 0; |
---|
[258] | 1069 | } |
---|
[493] | 1070 | |
---|
| 1071 | // initializes the idle_task context: |
---|
| 1072 | // - the SR slot is 0xFF03 because this task run in kernel mode. |
---|
| 1073 | // - it uses the page table of vspace[0] |
---|
| 1074 | // - it uses the kernel TTY terminal |
---|
| 1075 | // - slots containing addresses (SP,RA,EPC) are initialised by kernel_init() |
---|
| 1076 | |
---|
[631] | 1077 | psched->context[IDLE_TASK_INDEX][CTX_CR_ID] = 0; |
---|
| 1078 | psched->context[IDLE_TASK_INDEX][CTX_SR_ID] = 0xFF03; |
---|
| 1079 | psched->context[IDLE_TASK_INDEX][CTX_PTPR_ID] = _ptabs_paddr[0][x][y]>>13; |
---|
| 1080 | psched->context[IDLE_TASK_INDEX][CTX_PTAB_ID] = _ptabs_vaddr[0][x][y]; |
---|
| 1081 | psched->context[IDLE_TASK_INDEX][CTX_TTY_ID] = 0; |
---|
| 1082 | psched->context[IDLE_TASK_INDEX][CTX_LTID_ID] = IDLE_TASK_INDEX; |
---|
| 1083 | psched->context[IDLE_TASK_INDEX][CTX_VSID_ID] = 0; |
---|
| 1084 | psched->context[IDLE_TASK_INDEX][CTX_NORUN_ID] = 0; |
---|
[493] | 1085 | } |
---|
| 1086 | |
---|
[527] | 1087 | // HWI / PTI / WTI masks (up to 8 local processors) |
---|
| 1088 | unsigned int hwi_mask[8] = {0,0,0,0,0,0,0,0}; |
---|
| 1089 | unsigned int pti_mask[8] = {0,0,0,0,0,0,0,0}; |
---|
| 1090 | unsigned int wti_mask[8] = {0,0,0,0,0,0,0,0}; |
---|
| 1091 | |
---|
| 1092 | // scan local peripherals to get and check local XCU |
---|
[493] | 1093 | mapping_periph_t* xcu = NULL; |
---|
[527] | 1094 | unsigned int min = cluster[cluster_id].periph_offset ; |
---|
| 1095 | unsigned int max = min + cluster[cluster_id].periphs ; |
---|
[493] | 1096 | |
---|
[527] | 1097 | for ( periph_id = min ; periph_id < max ; periph_id++ ) |
---|
[493] | 1098 | { |
---|
| 1099 | if( periph[periph_id].type == PERIPH_TYPE_XCU ) |
---|
[258] | 1100 | { |
---|
[493] | 1101 | xcu = &periph[periph_id]; |
---|
[258] | 1102 | |
---|
[527] | 1103 | // check nb_hwi_in |
---|
| 1104 | if ( xcu->arg0 < xcu->irqs ) |
---|
[295] | 1105 | { |
---|
[538] | 1106 | _printf("\n[BOOT ERROR] Not enough HWI inputs for XCU[%d,%d]" |
---|
| 1107 | " : nb_hwi = %d / nb_irqs = %d\n", |
---|
| 1108 | x , y , xcu->arg0 , xcu->irqs ); |
---|
[295] | 1109 | _exit(); |
---|
| 1110 | } |
---|
[527] | 1111 | // check nb_pti_in |
---|
| 1112 | if ( xcu->arg2 < nprocs ) |
---|
| 1113 | { |
---|
| 1114 | _printf("\n[BOOT ERROR] Not enough PTI inputs for XCU[%d,%d]\n", |
---|
| 1115 | x, y ); |
---|
| 1116 | _exit(); |
---|
| 1117 | } |
---|
| 1118 | // check nb_wti_in |
---|
| 1119 | if ( xcu->arg1 < (4 * nprocs) ) |
---|
| 1120 | { |
---|
| 1121 | _printf("\n[BOOT ERROR] Not enough WTI inputs for XCU[%d,%d]\n", |
---|
| 1122 | x, y ); |
---|
| 1123 | _exit(); |
---|
| 1124 | } |
---|
| 1125 | // check nb_irq_out |
---|
[538] | 1126 | if ( xcu->channels < (nprocs * header->irq_per_proc) ) |
---|
[527] | 1127 | { |
---|
| 1128 | _printf("\n[BOOT ERROR] Not enough outputs for XCU[%d,%d]\n", |
---|
| 1129 | x, y ); |
---|
| 1130 | _exit(); |
---|
| 1131 | } |
---|
[493] | 1132 | } |
---|
| 1133 | } |
---|
[263] | 1134 | |
---|
[493] | 1135 | if ( xcu == NULL ) |
---|
| 1136 | { |
---|
| 1137 | _printf("\n[BOOT ERROR] missing XCU in cluster[%d,%d]\n", x , y ); |
---|
| 1138 | _exit(); |
---|
| 1139 | } |
---|
[321] | 1140 | |
---|
[527] | 1141 | // HWI interrupt vector definition |
---|
| 1142 | // scan HWI connected to local XCU |
---|
[493] | 1143 | // for round-robin allocation to local processors |
---|
| 1144 | lpid = 0; |
---|
| 1145 | for ( irq_id = xcu->irq_offset ; |
---|
| 1146 | irq_id < xcu->irq_offset + xcu->irqs ; |
---|
| 1147 | irq_id++ ) |
---|
| 1148 | { |
---|
| 1149 | unsigned int type = irq[irq_id].srctype; |
---|
| 1150 | unsigned int srcid = irq[irq_id].srcid; |
---|
| 1151 | unsigned int isr = irq[irq_id].isr & 0xFFFF; |
---|
| 1152 | unsigned int channel = irq[irq_id].channel << 16; |
---|
[321] | 1153 | |
---|
[493] | 1154 | if ( (type != IRQ_TYPE_HWI) || (srcid > 31) ) |
---|
| 1155 | { |
---|
| 1156 | _printf("\n[BOOT ERROR] Bad IRQ in cluster[%d,%d]\n", x, y ); |
---|
| 1157 | _exit(); |
---|
| 1158 | } |
---|
[295] | 1159 | |
---|
[527] | 1160 | // register entry in HWI interrupt vector |
---|
| 1161 | _schedulers[x][y][lpid]->hwi_vector[srcid] = isr | channel; |
---|
[295] | 1162 | |
---|
[527] | 1163 | // update XCU HWI mask for P[x,y,lpid] |
---|
| 1164 | hwi_mask[lpid] = hwi_mask[lpid] | (1<<srcid); |
---|
| 1165 | |
---|
[493] | 1166 | lpid = (lpid + 1) % nprocs; |
---|
| 1167 | } // end for irqs |
---|
[412] | 1168 | |
---|
[527] | 1169 | // PTI interrupt vector definition |
---|
| 1170 | // one PTI for TICK per processor |
---|
| 1171 | for ( lpid = 0 ; lpid < nprocs ; lpid++ ) |
---|
| 1172 | { |
---|
| 1173 | // register entry in PTI interrupt vector |
---|
| 1174 | _schedulers[x][y][lpid]->pti_vector[lpid] = ISR_TICK; |
---|
| 1175 | |
---|
| 1176 | // update XCU PTI mask for P[x,y,lpid] |
---|
| 1177 | pti_mask[lpid] = pti_mask[lpid] | (1<<lpid); |
---|
| 1178 | } |
---|
| 1179 | |
---|
| 1180 | // WTI interrupt vector definition |
---|
| 1181 | // 4 WTI per processor, first for WAKUP |
---|
| 1182 | for ( lpid = 0 ; lpid < nprocs ; lpid++ ) |
---|
| 1183 | { |
---|
| 1184 | // register WAKUP ISR in WTI interrupt vector |
---|
[552] | 1185 | _schedulers[x][y][lpid]->wti_vector[lpid] = ISR_WAKUP; |
---|
[527] | 1186 | |
---|
| 1187 | // update XCU WTI mask for P[x,y,lpid] (4 entries per proc) |
---|
| 1188 | wti_mask[lpid] = wti_mask[lpid] | (0x1<<(lpid )); |
---|
| 1189 | wti_mask[lpid] = wti_mask[lpid] | (0x1<<(lpid + NB_PROCS_MAX )); |
---|
| 1190 | wti_mask[lpid] = wti_mask[lpid] | (0x1<<(lpid + 2*NB_PROCS_MAX)); |
---|
| 1191 | wti_mask[lpid] = wti_mask[lpid] | (0x1<<(lpid + 3*NB_PROCS_MAX)); |
---|
| 1192 | } |
---|
| 1193 | |
---|
| 1194 | // set the XCU masks for HWI / WTI / PTI interrupts |
---|
| 1195 | for ( lpid = 0 ; lpid < nprocs ; lpid++ ) |
---|
| 1196 | { |
---|
| 1197 | unsigned int channel = lpid * IRQ_PER_PROCESSOR; |
---|
| 1198 | |
---|
| 1199 | _xcu_set_mask( cluster_xy, channel, hwi_mask[lpid], IRQ_TYPE_HWI ); |
---|
| 1200 | _xcu_set_mask( cluster_xy, channel, wti_mask[lpid], IRQ_TYPE_WTI ); |
---|
| 1201 | _xcu_set_mask( cluster_xy, channel, pti_mask[lpid], IRQ_TYPE_PTI ); |
---|
| 1202 | } |
---|
| 1203 | |
---|
[493] | 1204 | ////////////////////////////////////////////// |
---|
| 1205 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1206 | ////////////////////////////////////////////// |
---|
[412] | 1207 | |
---|
[527] | 1208 | #if BOOT_DEBUG_SCHED |
---|
| 1209 | if ( cluster_xy == 0 ) boot_sched_irq_display(); |
---|
| 1210 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1211 | #endif |
---|
| 1212 | |
---|
| 1213 | /////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 1214 | // Step 2 : Initialise the tasks context. The context of task placed |
---|
| 1215 | // on processor P must be stored in the scheduler of P. |
---|
| 1216 | // This require two nested loops: loop on the tasks, and loop |
---|
| 1217 | // on the local processors. We complete the scheduler when the |
---|
| 1218 | // required placement fit one local processor. |
---|
[527] | 1219 | /////////////////////////////////////////////////////////////////////////////// |
---|
[412] | 1220 | |
---|
[493] | 1221 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 1222 | { |
---|
| 1223 | // We must set the PTPR depending on the vspace, because the start_vector |
---|
| 1224 | // and the stack address are defined in virtual space. |
---|
| 1225 | _set_mmu_ptpr( (unsigned int)(_ptabs_paddr[vspace_id][x][y] >> 13) ); |
---|
[258] | 1226 | |
---|
[493] | 1227 | // loop on the tasks in vspace (task_id is the global index in mapping) |
---|
| 1228 | for (task_id = vspace[vspace_id].task_offset; |
---|
| 1229 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
| 1230 | task_id++) |
---|
| 1231 | { |
---|
| 1232 | // get the required task placement coordinates [x,y,p] |
---|
| 1233 | unsigned int req_x = cluster[task[task_id].clusterid].x; |
---|
| 1234 | unsigned int req_y = cluster[task[task_id].clusterid].y; |
---|
| 1235 | unsigned int req_p = task[task_id].proclocid; |
---|
[258] | 1236 | |
---|
[493] | 1237 | // ctx_ptpr : page table physical base address (shifted by 13 bit) |
---|
| 1238 | unsigned int ctx_ptpr = (_ptabs_paddr[vspace_id][req_x][req_y] >> 13); |
---|
[258] | 1239 | |
---|
[493] | 1240 | // ctx_ptab : page_table virtual base address |
---|
| 1241 | unsigned int ctx_ptab = _ptabs_vaddr[vspace_id][req_x][req_y]; |
---|
[412] | 1242 | |
---|
[493] | 1243 | // ctx_epc : Get the virtual address of the memory location containing |
---|
[527] | 1244 | // the task entry point : the start_vector is stored by GCC in the |
---|
| 1245 | // seg_data segment, and we must wait the .elf loading to get |
---|
| 1246 | // the entry point value... |
---|
[513] | 1247 | vseg_id = vspace[vspace_id].start_vseg_id; |
---|
| 1248 | unsigned int ctx_epc = vseg[vseg_id].vbase + (task[task_id].startid)*4; |
---|
[258] | 1249 | |
---|
[513] | 1250 | // ctx_sp : Get the vseg containing the stack |
---|
| 1251 | vseg_id = task[task_id].stack_vseg_id; |
---|
| 1252 | unsigned int ctx_sp = vseg[vseg_id].vbase + vseg[vseg_id].length; |
---|
[493] | 1253 | |
---|
| 1254 | // get vspace thread index |
---|
| 1255 | unsigned int thread_id = task[task_id].trdid; |
---|
| 1256 | |
---|
| 1257 | // loop on the local processors |
---|
| 1258 | for ( lpid = 0 ; lpid < nprocs ; lpid++ ) |
---|
[258] | 1259 | { |
---|
[493] | 1260 | if ( (x == req_x) && (y == req_y) && (req_p == lpid) ) // fit |
---|
[295] | 1261 | { |
---|
[493] | 1262 | // pointer on selected scheduler |
---|
| 1263 | psched = _schedulers[x][y][lpid]; |
---|
[258] | 1264 | |
---|
[493] | 1265 | // get local task index in scheduler |
---|
| 1266 | unsigned int ltid = psched->tasks; |
---|
[258] | 1267 | |
---|
[493] | 1268 | // update the "tasks" and "current" fields in scheduler: |
---|
| 1269 | psched->tasks = ltid + 1; |
---|
| 1270 | psched->current = 0; |
---|
[258] | 1271 | |
---|
[493] | 1272 | // initializes the task context |
---|
| 1273 | psched->context[ltid][CTX_CR_ID] = 0; |
---|
[631] | 1274 | psched->context[ltid][CTX_SR_ID] = GIET_SR_INIT_VALUE; |
---|
[493] | 1275 | psched->context[ltid][CTX_SP_ID] = ctx_sp; |
---|
| 1276 | psched->context[ltid][CTX_EPC_ID] = ctx_epc; |
---|
| 1277 | psched->context[ltid][CTX_PTPR_ID] = ctx_ptpr; |
---|
| 1278 | psched->context[ltid][CTX_PTAB_ID] = ctx_ptab; |
---|
| 1279 | psched->context[ltid][CTX_LTID_ID] = ltid; |
---|
| 1280 | psched->context[ltid][CTX_GTID_ID] = task_id; |
---|
| 1281 | psched->context[ltid][CTX_TRDID_ID] = thread_id; |
---|
| 1282 | psched->context[ltid][CTX_VSID_ID] = vspace_id; |
---|
[631] | 1283 | psched->context[ltid][CTX_NORUN_ID] = 0; |
---|
[321] | 1284 | |
---|
[493] | 1285 | psched->context[ltid][CTX_TTY_ID] = 0xFFFFFFFF; |
---|
| 1286 | psched->context[ltid][CTX_CMA_FB_ID] = 0xFFFFFFFF; |
---|
| 1287 | psched->context[ltid][CTX_CMA_RX_ID] = 0xFFFFFFFF; |
---|
| 1288 | psched->context[ltid][CTX_CMA_TX_ID] = 0xFFFFFFFF; |
---|
| 1289 | psched->context[ltid][CTX_NIC_RX_ID] = 0xFFFFFFFF; |
---|
| 1290 | psched->context[ltid][CTX_NIC_TX_ID] = 0xFFFFFFFF; |
---|
| 1291 | psched->context[ltid][CTX_TIM_ID] = 0xFFFFFFFF; |
---|
| 1292 | psched->context[ltid][CTX_HBA_ID] = 0xFFFFFFFF; |
---|
| 1293 | |
---|
[631] | 1294 | // update task ltid field in the mapping |
---|
| 1295 | task[task_id].ltid = ltid; |
---|
| 1296 | |
---|
[493] | 1297 | #if BOOT_DEBUG_SCHED |
---|
| 1298 | _printf("\nTask %s in vspace %s allocated to P[%d,%d,%d]\n" |
---|
| 1299 | " - ctx[LTID] = %d\n" |
---|
| 1300 | " - ctx[SR] = %x\n" |
---|
| 1301 | " - ctx[SP] = %x\n" |
---|
| 1302 | " - ctx[EPC] = %x\n" |
---|
| 1303 | " - ctx[PTPR] = %x\n" |
---|
| 1304 | " - ctx[PTAB] = %x\n" |
---|
| 1305 | " - ctx[VSID] = %d\n" |
---|
| 1306 | " - ctx[TRDID] = %d\n", |
---|
| 1307 | task[task_id].name, |
---|
| 1308 | vspace[vspace_id].name, |
---|
| 1309 | x, y, lpid, |
---|
| 1310 | psched->context[ltid][CTX_LTID_ID], |
---|
| 1311 | psched->context[ltid][CTX_SR_ID], |
---|
| 1312 | psched->context[ltid][CTX_SP_ID], |
---|
| 1313 | psched->context[ltid][CTX_EPC_ID], |
---|
| 1314 | psched->context[ltid][CTX_PTPR_ID], |
---|
| 1315 | psched->context[ltid][CTX_PTAB_ID], |
---|
| 1316 | psched->context[ltid][CTX_VSID_ID], |
---|
| 1317 | psched->context[ltid][CTX_TRDID_ID] ); |
---|
| 1318 | #endif |
---|
| 1319 | } // end if FIT |
---|
| 1320 | } // end for loop on local procs |
---|
| 1321 | } // end loop on tasks |
---|
| 1322 | } // end loop on vspaces |
---|
| 1323 | } // end boot_scheduler_init() |
---|
| 1324 | |
---|
| 1325 | |
---|
| 1326 | |
---|
[258] | 1327 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 1328 | // This function loads the map.bin file from block device. |
---|
| 1329 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 1330 | void boot_mapping_init() |
---|
| 1331 | { |
---|
[590] | 1332 | // load map.bin file into buffer |
---|
| 1333 | if ( _fat_load_no_cache( "map.bin", |
---|
| 1334 | SEG_BOOT_MAPPING_BASE, |
---|
| 1335 | SEG_BOOT_MAPPING_SIZE ) ) |
---|
[258] | 1336 | { |
---|
[493] | 1337 | _printf("\n[BOOT ERROR] : map.bin file not found \n"); |
---|
[258] | 1338 | _exit(); |
---|
| 1339 | } |
---|
| 1340 | |
---|
[477] | 1341 | // check mapping signature, number of clusters, number of vspaces |
---|
| 1342 | mapping_header_t * header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 1343 | if ( (header->signature != IN_MAPPING_SIGNATURE) || |
---|
| 1344 | (header->x_size != X_SIZE) || |
---|
| 1345 | (header->y_size != Y_SIZE) || |
---|
| 1346 | (header->vspaces > GIET_NB_VSPACE_MAX) ) |
---|
| 1347 | { |
---|
[590] | 1348 | _printf("\n[BOOT ERROR] Illegal mapping : signature = %x\n", header->signature ); |
---|
[524] | 1349 | _exit(); |
---|
| 1350 | } |
---|
[477] | 1351 | |
---|
| 1352 | #if BOOT_DEBUG_MAPPING |
---|
| 1353 | unsigned int line; |
---|
| 1354 | unsigned int* pointer = (unsigned int*)SEG_BOOT_MAPPING_BASE; |
---|
[493] | 1355 | _printf("\n[BOOT] First block of mapping\n"); |
---|
[477] | 1356 | for ( line = 0 ; line < 8 ; line++ ) |
---|
| 1357 | { |
---|
[590] | 1358 | _printf(" | %X | %X | %X | %X | %X | %X | %X | %X |\n", |
---|
[493] | 1359 | *(pointer + 0), |
---|
| 1360 | *(pointer + 1), |
---|
| 1361 | *(pointer + 2), |
---|
| 1362 | *(pointer + 3), |
---|
| 1363 | *(pointer + 4), |
---|
| 1364 | *(pointer + 5), |
---|
| 1365 | *(pointer + 6), |
---|
| 1366 | *(pointer + 7) ); |
---|
| 1367 | |
---|
[477] | 1368 | pointer = pointer + 8; |
---|
| 1369 | } |
---|
| 1370 | #endif |
---|
| 1371 | |
---|
[258] | 1372 | } // end boot_mapping_init() |
---|
| 1373 | |
---|
| 1374 | |
---|
[557] | 1375 | /////////////////////////////////////////////////// |
---|
| 1376 | void boot_dma_copy( unsigned int cluster_xy, |
---|
| 1377 | unsigned long long dst_paddr, |
---|
| 1378 | unsigned long long src_paddr, |
---|
| 1379 | unsigned int size ) |
---|
| 1380 | { |
---|
| 1381 | // size must be multiple of 64 bytes |
---|
| 1382 | if ( size & 0x3F ) size = (size & (~0x3F)) + 0x40; |
---|
| 1383 | |
---|
| 1384 | unsigned int mode = MODE_DMA_NO_IRQ; |
---|
| 1385 | |
---|
| 1386 | unsigned int src = 0; |
---|
| 1387 | unsigned int src_lsb = (unsigned int)src_paddr; |
---|
| 1388 | unsigned int src_msb = (unsigned int)(src_paddr>>32); |
---|
| 1389 | |
---|
| 1390 | unsigned int dst = 1; |
---|
| 1391 | unsigned int dst_lsb = (unsigned int)dst_paddr; |
---|
| 1392 | unsigned int dst_msb = (unsigned int)(dst_paddr>>32); |
---|
| 1393 | |
---|
| 1394 | // initializes src channel |
---|
| 1395 | _mwr_set_channel_register( cluster_xy , src , MWR_CHANNEL_MODE , mode ); |
---|
| 1396 | _mwr_set_channel_register( cluster_xy , src , MWR_CHANNEL_SIZE , size ); |
---|
| 1397 | _mwr_set_channel_register( cluster_xy , src , MWR_CHANNEL_BUFFER_LSB , src_lsb ); |
---|
| 1398 | _mwr_set_channel_register( cluster_xy , src , MWR_CHANNEL_BUFFER_MSB , src_msb ); |
---|
| 1399 | _mwr_set_channel_register( cluster_xy , src , MWR_CHANNEL_RUNNING , 1 ); |
---|
| 1400 | |
---|
| 1401 | // initializes dst channel |
---|
| 1402 | _mwr_set_channel_register( cluster_xy , dst , MWR_CHANNEL_MODE , mode ); |
---|
| 1403 | _mwr_set_channel_register( cluster_xy , dst , MWR_CHANNEL_SIZE , size ); |
---|
| 1404 | _mwr_set_channel_register( cluster_xy , dst , MWR_CHANNEL_BUFFER_LSB , dst_lsb ); |
---|
| 1405 | _mwr_set_channel_register( cluster_xy , dst , MWR_CHANNEL_BUFFER_MSB , dst_msb ); |
---|
| 1406 | _mwr_set_channel_register( cluster_xy , dst , MWR_CHANNEL_RUNNING , 1 ); |
---|
| 1407 | |
---|
| 1408 | // start CPY coprocessor (write non-zero value into config register) |
---|
| 1409 | _mwr_set_coproc_register( cluster_xy, 0 , 1 ); |
---|
| 1410 | |
---|
| 1411 | // poll dst channel status register to detect completion |
---|
| 1412 | unsigned int status; |
---|
| 1413 | do |
---|
| 1414 | { |
---|
| 1415 | status = _mwr_get_channel_register( cluster_xy , dst , MWR_CHANNEL_STATUS ); |
---|
| 1416 | } while ( status == MWR_CHANNEL_BUSY ); |
---|
| 1417 | |
---|
| 1418 | if ( status ) |
---|
| 1419 | { |
---|
| 1420 | _printf("\n[BOOT ERROR] in boot_dma_copy()\n"); |
---|
| 1421 | _exit(); |
---|
| 1422 | } |
---|
| 1423 | |
---|
| 1424 | // stop CPY coprocessor and DMA channels |
---|
| 1425 | _mwr_set_channel_register( cluster_xy , src , MWR_CHANNEL_RUNNING , 0 ); |
---|
| 1426 | _mwr_set_channel_register( cluster_xy , dst , MWR_CHANNEL_RUNNING , 0 ); |
---|
| 1427 | _mwr_set_coproc_register ( cluster_xy , 0 , 0 ); |
---|
| 1428 | |
---|
| 1429 | } // end boot_dma_copy() |
---|
| 1430 | |
---|
[527] | 1431 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 1432 | // This function load all loadable segments contained in the .elf file identified |
---|
[347] | 1433 | // by the "pathname" argument. Some loadable segments can be copied in several |
---|
| 1434 | // clusters: same virtual address but different physical addresses. |
---|
| 1435 | // - It open the file. |
---|
[527] | 1436 | // - It loads the complete file in the dedicated _boot_elf_buffer. |
---|
[359] | 1437 | // - It copies each loadable segments at the virtual address defined in |
---|
| 1438 | // the .elf file, making several copies if the target vseg is not local. |
---|
[347] | 1439 | // - It closes the file. |
---|
[527] | 1440 | // This function is supposed to be executed by all processors[x,y,0]. |
---|
| 1441 | // |
---|
| 1442 | // Note: We must use physical addresses to reach the destination buffers that |
---|
| 1443 | // can be located in remote clusters. We use either a _physical_memcpy(), |
---|
| 1444 | // or a _dma_physical_copy() if DMA is available. |
---|
| 1445 | ////////////////////////////////////////////////////////////////////////////////// |
---|
[347] | 1446 | void load_one_elf_file( unsigned int is_kernel, // kernel file if non zero |
---|
[258] | 1447 | char* pathname, |
---|
[347] | 1448 | unsigned int vspace_id ) // to scan the proper vspace |
---|
[258] | 1449 | { |
---|
[347] | 1450 | mapping_header_t * header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 1451 | mapping_vspace_t * vspace = _get_vspace_base(header); |
---|
| 1452 | mapping_vseg_t * vseg = _get_vseg_base(header); |
---|
| 1453 | |
---|
[527] | 1454 | unsigned int procid = _get_procid(); |
---|
| 1455 | unsigned int cxy = procid >> P_WIDTH; |
---|
| 1456 | unsigned int x = cxy >> Y_WIDTH; |
---|
| 1457 | unsigned int y = cxy & ((1<<Y_WIDTH)-1); |
---|
| 1458 | unsigned int p = procid & ((1<<P_WIDTH)-1); |
---|
[258] | 1459 | |
---|
| 1460 | #if BOOT_DEBUG_ELF |
---|
[557] | 1461 | _printf("\n[DEBUG BOOT_ELF] load_one_elf_file() : P[%d,%d,%d] enters for %s\n", |
---|
[527] | 1462 | x , y , p , pathname ); |
---|
[258] | 1463 | #endif |
---|
| 1464 | |
---|
[527] | 1465 | Elf32_Ehdr* elf_header_ptr = NULL; // avoid a warning |
---|
[258] | 1466 | |
---|
[590] | 1467 | // only P[0,0,0] load file |
---|
[527] | 1468 | if ( (cxy == 0) && (p == 0) ) |
---|
[258] | 1469 | { |
---|
[590] | 1470 | if ( _fat_load_no_cache( pathname, |
---|
| 1471 | (unsigned int)_boot_elf_buffer, |
---|
| 1472 | GIET_ELF_BUFFER_SIZE ) ) |
---|
[527] | 1473 | { |
---|
[590] | 1474 | _printf("\n[BOOT ERROR] in load_one_elf_file() : %s\n", pathname ); |
---|
[527] | 1475 | _exit(); |
---|
| 1476 | } |
---|
[258] | 1477 | |
---|
[527] | 1478 | // Check ELF Magic Number in ELF header |
---|
| 1479 | Elf32_Ehdr* ptr = (Elf32_Ehdr*)_boot_elf_buffer; |
---|
| 1480 | |
---|
| 1481 | if ( (ptr->e_ident[EI_MAG0] != ELFMAG0) || |
---|
| 1482 | (ptr->e_ident[EI_MAG1] != ELFMAG1) || |
---|
| 1483 | (ptr->e_ident[EI_MAG2] != ELFMAG2) || |
---|
| 1484 | (ptr->e_ident[EI_MAG3] != ELFMAG3) ) |
---|
| 1485 | { |
---|
[557] | 1486 | _printf("\n[BOOT ERROR] load_one_elf_file() : %s not ELF format\n", |
---|
[527] | 1487 | pathname ); |
---|
| 1488 | _exit(); |
---|
| 1489 | } |
---|
| 1490 | |
---|
| 1491 | #if BOOT_DEBUG_ELF |
---|
[557] | 1492 | _printf("\n[DEBUG BOOT_ELF] load_one_elf_file() : P[%d,%d,%d] load %s at cycle %d\n", |
---|
| 1493 | x , y , p , pathname , _get_proctime() ); |
---|
[527] | 1494 | #endif |
---|
| 1495 | |
---|
| 1496 | } // end if P[0,0,0] |
---|
| 1497 | |
---|
| 1498 | ////////////////////////////////////////////// |
---|
| 1499 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1500 | ////////////////////////////////////////////// |
---|
| 1501 | |
---|
| 1502 | // Each processor P[x,y,0] copy replicated segments in cluster[x,y] |
---|
| 1503 | elf_header_ptr = (Elf32_Ehdr*)_boot_elf_buffer; |
---|
| 1504 | |
---|
[258] | 1505 | // get program header table pointer |
---|
[527] | 1506 | unsigned int offset = elf_header_ptr->e_phoff; |
---|
| 1507 | if( offset == 0 ) |
---|
[258] | 1508 | { |
---|
[493] | 1509 | _printf("\n[BOOT ERROR] load_one_elf_file() : file %s " |
---|
| 1510 | "does not contain loadable segment\n", pathname ); |
---|
[258] | 1511 | _exit(); |
---|
| 1512 | } |
---|
| 1513 | |
---|
[527] | 1514 | Elf32_Phdr* elf_pht_ptr = (Elf32_Phdr*)(_boot_elf_buffer + offset); |
---|
| 1515 | |
---|
[258] | 1516 | // get number of segments |
---|
| 1517 | unsigned int nsegments = elf_header_ptr->e_phnum; |
---|
| 1518 | |
---|
[527] | 1519 | // First loop on loadable segments in the .elf file |
---|
| 1520 | unsigned int seg_id; |
---|
[258] | 1521 | for (seg_id = 0 ; seg_id < nsegments ; seg_id++) |
---|
| 1522 | { |
---|
| 1523 | if(elf_pht_ptr[seg_id].p_type == PT_LOAD) |
---|
| 1524 | { |
---|
| 1525 | // Get segment attributes |
---|
| 1526 | unsigned int seg_vaddr = elf_pht_ptr[seg_id].p_vaddr; |
---|
| 1527 | unsigned int seg_offset = elf_pht_ptr[seg_id].p_offset; |
---|
| 1528 | unsigned int seg_filesz = elf_pht_ptr[seg_id].p_filesz; |
---|
| 1529 | unsigned int seg_memsz = elf_pht_ptr[seg_id].p_memsz; |
---|
| 1530 | |
---|
[527] | 1531 | if( seg_memsz != seg_filesz ) |
---|
[258] | 1532 | { |
---|
[527] | 1533 | _printf("\n[BOOT ERROR] load_one_elf_file() : segment at vaddr = %x\n" |
---|
| 1534 | " in file %s has memsize = %x / filesize = %x \n" |
---|
| 1535 | " check that all global variables are in data segment\n", |
---|
| 1536 | seg_vaddr, pathname , seg_memsz , seg_filesz ); |
---|
[258] | 1537 | _exit(); |
---|
| 1538 | } |
---|
| 1539 | |
---|
[527] | 1540 | unsigned int src_vaddr = (unsigned int)_boot_elf_buffer + seg_offset; |
---|
[258] | 1541 | |
---|
[347] | 1542 | // search all vsegs matching the virtual address |
---|
| 1543 | unsigned int vseg_first; |
---|
| 1544 | unsigned int vseg_last; |
---|
| 1545 | unsigned int vseg_id; |
---|
| 1546 | unsigned int found = 0; |
---|
| 1547 | if ( is_kernel ) |
---|
| 1548 | { |
---|
| 1549 | vseg_first = 0; |
---|
| 1550 | vseg_last = header->globals; |
---|
| 1551 | } |
---|
| 1552 | else |
---|
| 1553 | { |
---|
| 1554 | vseg_first = vspace[vspace_id].vseg_offset; |
---|
| 1555 | vseg_last = vseg_first + vspace[vspace_id].vsegs; |
---|
| 1556 | } |
---|
| 1557 | |
---|
[527] | 1558 | // Second loop on vsegs in the mapping |
---|
[347] | 1559 | for ( vseg_id = vseg_first ; vseg_id < vseg_last ; vseg_id++ ) |
---|
| 1560 | { |
---|
| 1561 | if ( seg_vaddr == vseg[vseg_id].vbase ) // matching |
---|
| 1562 | { |
---|
| 1563 | found = 1; |
---|
| 1564 | |
---|
[527] | 1565 | // get destination buffer physical address, size, coordinates |
---|
[347] | 1566 | paddr_t seg_paddr = vseg[vseg_id].pbase; |
---|
[513] | 1567 | unsigned int seg_size = vseg[vseg_id].length; |
---|
[557] | 1568 | unsigned int cluster_xy = (unsigned int)(seg_paddr>>32); |
---|
| 1569 | unsigned int cx = cluster_xy >> Y_WIDTH; |
---|
| 1570 | unsigned int cy = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
[527] | 1571 | |
---|
[347] | 1572 | // check vseg size |
---|
| 1573 | if ( seg_size < seg_filesz ) |
---|
| 1574 | { |
---|
[493] | 1575 | _printf("\n[BOOT ERROR] in load_one_elf_file() : vseg %s " |
---|
[590] | 1576 | "is too small for segment %x\n" |
---|
| 1577 | " file = %s / vseg_size = %x / seg_file_size = %x\n", |
---|
| 1578 | vseg[vseg_id].name , seg_vaddr , pathname, |
---|
| 1579 | seg_size , seg_filesz ); |
---|
[347] | 1580 | _exit(); |
---|
| 1581 | } |
---|
[258] | 1582 | |
---|
[527] | 1583 | // P[x,y,0] copy the segment from boot buffer in cluster[0,0] |
---|
[557] | 1584 | // to destination buffer in cluster[x,y], using DMA if available |
---|
[527] | 1585 | if ( (cx == x) && (cy == y) ) |
---|
[347] | 1586 | { |
---|
[557] | 1587 | if( USE_MWR_CPY ) |
---|
[527] | 1588 | { |
---|
[557] | 1589 | boot_dma_copy( cluster_xy, // DMA in cluster[x,y] |
---|
| 1590 | seg_paddr, |
---|
| 1591 | (paddr_t)src_vaddr, |
---|
| 1592 | seg_filesz ); |
---|
| 1593 | #if BOOT_DEBUG_ELF |
---|
| 1594 | _printf("\n[DEBUG BOOT_ELF] load_one_elf_file() : DMA[%d,%d] copy segment %d :\n" |
---|
| 1595 | " vaddr = %x / size = %x / paddr = %l\n", |
---|
| 1596 | x , y , seg_id , seg_vaddr , seg_memsz , seg_paddr ); |
---|
| 1597 | #endif |
---|
[527] | 1598 | } |
---|
| 1599 | else |
---|
| 1600 | { |
---|
| 1601 | _physical_memcpy( seg_paddr, // dest paddr |
---|
| 1602 | (paddr_t)src_vaddr, // source paddr |
---|
| 1603 | seg_filesz ); // size |
---|
| 1604 | #if BOOT_DEBUG_ELF |
---|
[557] | 1605 | _printf("\n[DEBUG BOOT_ELF] load_one_elf_file() : P[%d,%d,%d] copy segment %d :\n" |
---|
[527] | 1606 | " vaddr = %x / size = %x / paddr = %l\n", |
---|
| 1607 | x , y , p , seg_id , seg_vaddr , seg_memsz , seg_paddr ); |
---|
| 1608 | #endif |
---|
[557] | 1609 | } |
---|
[347] | 1610 | } |
---|
| 1611 | } |
---|
[527] | 1612 | } // end for vsegs |
---|
[347] | 1613 | |
---|
| 1614 | // check at least one matching vseg |
---|
| 1615 | if ( found == 0 ) |
---|
[258] | 1616 | { |
---|
[493] | 1617 | _printf("\n[BOOT ERROR] in load_one_elf_file() : vseg for loadable " |
---|
| 1618 | "segment %x in file %s not found " |
---|
| 1619 | "check consistency between the .py and .ld files\n", |
---|
| 1620 | seg_vaddr, pathname ); |
---|
[347] | 1621 | _exit(); |
---|
[258] | 1622 | } |
---|
| 1623 | } |
---|
[347] | 1624 | } // end for loadable segments |
---|
[258] | 1625 | |
---|
[527] | 1626 | ////////////////////////////////////////////// |
---|
| 1627 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1628 | ////////////////////////////////////////////// |
---|
[258] | 1629 | |
---|
[590] | 1630 | // only P[0,0,0] signals completion |
---|
[527] | 1631 | if ( (cxy == 0) && (p == 0) ) |
---|
| 1632 | { |
---|
| 1633 | _printf("\n[BOOT] File %s loaded at cycle %d\n", |
---|
| 1634 | pathname , _get_proctime() ); |
---|
| 1635 | } |
---|
| 1636 | |
---|
[258] | 1637 | } // end load_one_elf_file() |
---|
| 1638 | |
---|
| 1639 | |
---|
[347] | 1640 | /////i//////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 1641 | // This function uses the map.bin data structure to load the "kernel.elf" file |
---|
[347] | 1642 | // as well as the various "application.elf" files into memory. |
---|
| 1643 | // - The "preloader.elf" file is not loaded, because it has been burned in the ROM. |
---|
| 1644 | // - The "boot.elf" file is not loaded, because it has been loaded by the preloader. |
---|
[513] | 1645 | // This function scans all vsegs defined in the map.bin data structure to collect |
---|
[347] | 1646 | // all .elf files pathnames, and calls the load_one_elf_file() for each .elf file. |
---|
| 1647 | // As the code can be replicated in several vsegs, the same code can be copied |
---|
| 1648 | // in one or several clusters by the load_one_elf_file() function. |
---|
| 1649 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 1650 | void boot_elf_load() |
---|
| 1651 | { |
---|
[321] | 1652 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
[258] | 1653 | mapping_vspace_t* vspace = _get_vspace_base( header ); |
---|
[513] | 1654 | mapping_vseg_t* vseg = _get_vseg_base( header ); |
---|
| 1655 | |
---|
[258] | 1656 | unsigned int vspace_id; |
---|
[513] | 1657 | unsigned int vseg_id; |
---|
[258] | 1658 | unsigned int found; |
---|
| 1659 | |
---|
[513] | 1660 | // Scan all global vsegs to find the pathname to the kernel.elf file |
---|
[258] | 1661 | found = 0; |
---|
[513] | 1662 | for( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ ) |
---|
[258] | 1663 | { |
---|
[513] | 1664 | if(vseg[vseg_id].type == VSEG_TYPE_ELF) |
---|
[258] | 1665 | { |
---|
| 1666 | found = 1; |
---|
| 1667 | break; |
---|
| 1668 | } |
---|
| 1669 | } |
---|
| 1670 | |
---|
| 1671 | // We need one kernel.elf file |
---|
| 1672 | if (found == 0) |
---|
| 1673 | { |
---|
[493] | 1674 | _printf("\n[BOOT ERROR] boot_elf_load() : kernel.elf file not found\n"); |
---|
[258] | 1675 | _exit(); |
---|
| 1676 | } |
---|
| 1677 | |
---|
[347] | 1678 | // Load the kernel |
---|
| 1679 | load_one_elf_file( 1, // kernel file |
---|
[513] | 1680 | vseg[vseg_id].binpath, // file pathname |
---|
[258] | 1681 | 0 ); // vspace 0 |
---|
| 1682 | |
---|
[513] | 1683 | // loop on the vspaces, scanning all vsegs in the vspace, |
---|
[258] | 1684 | // to find the pathname of the .elf file associated to the vspace. |
---|
| 1685 | for( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) |
---|
| 1686 | { |
---|
[513] | 1687 | // loop on the private vsegs |
---|
[258] | 1688 | unsigned int found = 0; |
---|
[513] | 1689 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 1690 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 1691 | vseg_id++) |
---|
[258] | 1692 | { |
---|
[513] | 1693 | if(vseg[vseg_id].type == VSEG_TYPE_ELF) |
---|
[258] | 1694 | { |
---|
| 1695 | found = 1; |
---|
| 1696 | break; |
---|
| 1697 | } |
---|
| 1698 | } |
---|
| 1699 | |
---|
| 1700 | // We want one .elf file per vspace |
---|
| 1701 | if (found == 0) |
---|
| 1702 | { |
---|
[493] | 1703 | _printf("\n[BOOT ERROR] boot_elf_load() : " |
---|
| 1704 | ".elf file not found for vspace %s\n", vspace[vspace_id].name ); |
---|
[258] | 1705 | _exit(); |
---|
| 1706 | } |
---|
| 1707 | |
---|
[347] | 1708 | load_one_elf_file( 0, // not a kernel file |
---|
[513] | 1709 | vseg[vseg_id].binpath, // file pathname |
---|
[347] | 1710 | vspace_id ); // vspace index |
---|
[258] | 1711 | |
---|
| 1712 | } // end for vspaces |
---|
| 1713 | |
---|
| 1714 | } // end boot_elf_load() |
---|
| 1715 | |
---|
| 1716 | |
---|
[527] | 1717 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 1718 | // This function is executed in parallel by all processors[x][y][0]. |
---|
[527] | 1719 | // It initialises the physical memory allocator in each cluster containing |
---|
| 1720 | // a RAM pseg. |
---|
| 1721 | ///////////////////////////////////////////////////////////////////////////////// |
---|
[493] | 1722 | void boot_pmem_init( unsigned int cx, |
---|
| 1723 | unsigned int cy ) |
---|
[412] | 1724 | { |
---|
| 1725 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 1726 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 1727 | mapping_pseg_t* pseg = _get_pseg_base(header); |
---|
| 1728 | |
---|
| 1729 | unsigned int pseg_id; |
---|
[490] | 1730 | unsigned int procid = _get_procid(); |
---|
| 1731 | unsigned int lpid = procid & ((1<<P_WIDTH)-1); |
---|
[493] | 1732 | |
---|
| 1733 | if( lpid ) |
---|
[490] | 1734 | { |
---|
[493] | 1735 | _printf("\n[BOOT ERROR] boot_pmem_init() : " |
---|
| 1736 | "P[%d][%d][%d] should not execute it\n", cx, cy, lpid ); |
---|
[490] | 1737 | _exit(); |
---|
[493] | 1738 | } |
---|
[412] | 1739 | |
---|
[493] | 1740 | // scan the psegs in local cluster to find pseg of type RAM |
---|
| 1741 | unsigned int found = 0; |
---|
| 1742 | unsigned int cluster_id = cx * Y_SIZE + cy; |
---|
| 1743 | unsigned int pseg_min = cluster[cluster_id].pseg_offset; |
---|
| 1744 | unsigned int pseg_max = pseg_min + cluster[cluster_id].psegs; |
---|
[490] | 1745 | for ( pseg_id = pseg_min ; pseg_id < pseg_max ; pseg_id++ ) |
---|
[412] | 1746 | { |
---|
[490] | 1747 | if ( pseg[pseg_id].type == PSEG_TYPE_RAM ) |
---|
[412] | 1748 | { |
---|
[490] | 1749 | unsigned int base = (unsigned int)pseg[pseg_id].base; |
---|
| 1750 | unsigned int size = (unsigned int)pseg[pseg_id].length; |
---|
[493] | 1751 | _pmem_alloc_init( cx, cy, base, size ); |
---|
| 1752 | found = 1; |
---|
[412] | 1753 | |
---|
| 1754 | #if BOOT_DEBUG_PT |
---|
[493] | 1755 | _printf("\n[BOOT] pmem allocator initialised in cluster[%d][%d]" |
---|
| 1756 | " : base = %x / size = %x\n", cx , cy , base , size ); |
---|
[412] | 1757 | #endif |
---|
[490] | 1758 | break; |
---|
[412] | 1759 | } |
---|
| 1760 | } |
---|
[493] | 1761 | |
---|
| 1762 | if ( found == 0 ) |
---|
| 1763 | { |
---|
| 1764 | _printf("\n[BOOT ERROR] boot_pmem_init() : no RAM in cluster[%d][%d]\n", |
---|
[527] | 1765 | cx , cy ); |
---|
[493] | 1766 | _exit(); |
---|
| 1767 | } |
---|
[412] | 1768 | } // end boot_pmem_init() |
---|
| 1769 | |
---|
| 1770 | ///////////////////////////////////////////////////////////////////////// |
---|
[258] | 1771 | // This function is the entry point of the boot code for all processors. |
---|
| 1772 | ///////////////////////////////////////////////////////////////////////// |
---|
[347] | 1773 | void boot_init() |
---|
[258] | 1774 | { |
---|
[493] | 1775 | |
---|
[295] | 1776 | unsigned int gpid = _get_procid(); |
---|
[493] | 1777 | unsigned int cx = gpid >> (Y_WIDTH + P_WIDTH); |
---|
| 1778 | unsigned int cy = (gpid >> P_WIDTH) & ((1<<Y_WIDTH)-1); |
---|
| 1779 | unsigned int lpid = gpid & ((1 << P_WIDTH) -1); |
---|
[490] | 1780 | |
---|
[527] | 1781 | ////////////////////////////////////////////////////////// |
---|
[493] | 1782 | // Phase ONE : only P[0][0][0] execute it |
---|
[527] | 1783 | ////////////////////////////////////////////////////////// |
---|
[493] | 1784 | if ( gpid == 0 ) |
---|
[258] | 1785 | { |
---|
[552] | 1786 | unsigned int cid; // index for loop on clusters |
---|
[258] | 1787 | |
---|
[493] | 1788 | // initialises the TTY0 spin lock |
---|
| 1789 | _spin_lock_init( &_tty0_spin_lock ); |
---|
| 1790 | |
---|
| 1791 | _printf("\n[BOOT] P[0,0,0] starts at cycle %d\n", _get_proctime() ); |
---|
| 1792 | |
---|
[631] | 1793 | // initialise the MMC locks array |
---|
| 1794 | _mmc_boot_mode = 1; |
---|
| 1795 | _mmc_init_locks(); |
---|
| 1796 | |
---|
[552] | 1797 | // initialises the IOC peripheral |
---|
| 1798 | if ( USE_IOC_BDV != 0 ) _bdv_init(); |
---|
| 1799 | else if ( USE_IOC_HBA != 0 ) _hba_init(); |
---|
| 1800 | else if ( USE_IOC_SDC != 0 ) _sdc_init(); |
---|
| 1801 | else if ( USE_IOC_RDK == 0 ) |
---|
| 1802 | { |
---|
| 1803 | _printf("\n[BOOT ERROR] boot_init() : no IOC peripheral\n"); |
---|
| 1804 | _exit(); |
---|
| 1805 | } |
---|
| 1806 | |
---|
[460] | 1807 | // initialises the FAT |
---|
[590] | 1808 | _fat_init( 0 ); // don't use Inode-Tree, Fat-Cache, etc. |
---|
[460] | 1809 | |
---|
[493] | 1810 | _printf("\n[BOOT] FAT initialised at cycle %d\n", _get_proctime() ); |
---|
| 1811 | |
---|
| 1812 | // Load the map.bin file into memory |
---|
[258] | 1813 | boot_mapping_init(); |
---|
| 1814 | |
---|
[524] | 1815 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 1816 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 1817 | |
---|
[493] | 1818 | _printf("\n[BOOT] Mapping %s loaded at cycle %d\n", |
---|
| 1819 | header->name , _get_proctime() ); |
---|
[258] | 1820 | |
---|
[493] | 1821 | // initialises the barrier for all clusters containing processors |
---|
| 1822 | unsigned int nclusters = 0; |
---|
| 1823 | for ( cid = 0 ; cid < X_SIZE*Y_SIZE ; cid++ ) |
---|
| 1824 | { |
---|
| 1825 | if ( cluster[cid].procs ) nclusters++ ; |
---|
| 1826 | } |
---|
[490] | 1827 | |
---|
[493] | 1828 | _simple_barrier_init( &_barrier_all_clusters , nclusters ); |
---|
| 1829 | |
---|
| 1830 | // wake up all processors P[x][y][0] |
---|
| 1831 | for ( cid = 1 ; cid < X_SIZE*Y_SIZE ; cid++ ) |
---|
[490] | 1832 | { |
---|
[493] | 1833 | unsigned int x = cluster[cid].x; |
---|
| 1834 | unsigned int y = cluster[cid].y; |
---|
| 1835 | unsigned int cluster_xy = (x << Y_WIDTH) + y; |
---|
[490] | 1836 | |
---|
[493] | 1837 | if ( cluster[cid].procs ) |
---|
| 1838 | { |
---|
| 1839 | unsigned long long paddr = (((unsigned long long)cluster_xy)<<32) + |
---|
[527] | 1840 | SEG_XCU_BASE+XCU_REG( XCU_WTI_REG , 0 ); |
---|
[493] | 1841 | |
---|
| 1842 | _physical_write( paddr , (unsigned int)boot_entry ); |
---|
| 1843 | } |
---|
[490] | 1844 | } |
---|
[412] | 1845 | |
---|
[527] | 1846 | _printf("\n[BOOT] Processors P[x,y,0] start at cycle %d\n", |
---|
| 1847 | _get_proctime() ); |
---|
[490] | 1848 | } |
---|
[412] | 1849 | |
---|
[527] | 1850 | ///////////////////////////////////////////////////////////////// |
---|
[493] | 1851 | // Phase TWO : All processors P[x][y][0] execute it in parallel |
---|
[527] | 1852 | ///////////////////////////////////////////////////////////////// |
---|
[493] | 1853 | if( lpid == 0 ) |
---|
[490] | 1854 | { |
---|
[493] | 1855 | // Initializes physical memory allocator in cluster[cx][cy] |
---|
| 1856 | boot_pmem_init( cx , cy ); |
---|
[412] | 1857 | |
---|
[493] | 1858 | // Build page table in cluster[cx][cy] |
---|
| 1859 | boot_ptab_init( cx , cy ); |
---|
[258] | 1860 | |
---|
[493] | 1861 | ////////////////////////////////////////////// |
---|
| 1862 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1863 | ////////////////////////////////////////////// |
---|
[258] | 1864 | |
---|
[493] | 1865 | // P[0][0][0] complete page tables with vsegs |
---|
| 1866 | // mapped in clusters without processors |
---|
| 1867 | if ( gpid == 0 ) |
---|
| 1868 | { |
---|
| 1869 | // complete page tables initialisation |
---|
| 1870 | boot_ptab_extend(); |
---|
[258] | 1871 | |
---|
[493] | 1872 | _printf("\n[BOOT] Physical memory allocators and page tables" |
---|
| 1873 | " initialized at cycle %d\n", _get_proctime() ); |
---|
| 1874 | } |
---|
[258] | 1875 | |
---|
[493] | 1876 | ////////////////////////////////////////////// |
---|
| 1877 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1878 | ////////////////////////////////////////////// |
---|
| 1879 | |
---|
| 1880 | // All processors P[x,y,0] activate MMU (using local PTAB) |
---|
| 1881 | _set_mmu_ptpr( (unsigned int)(_ptabs_paddr[0][cx][cy]>>13) ); |
---|
| 1882 | _set_mmu_mode( 0xF ); |
---|
[258] | 1883 | |
---|
[493] | 1884 | // Each processor P[x,y,0] initialises all schedulers in cluster[x,y] |
---|
| 1885 | boot_scheduler_init( cx , cy ); |
---|
[258] | 1886 | |
---|
[493] | 1887 | // Each processor P[x][y][0] initialises its CP0_SCHED register |
---|
| 1888 | _set_sched( (unsigned int)_schedulers[cx][cy][0] ); |
---|
[258] | 1889 | |
---|
[493] | 1890 | ////////////////////////////////////////////// |
---|
| 1891 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1892 | ////////////////////////////////////////////// |
---|
[527] | 1893 | |
---|
[493] | 1894 | if ( gpid == 0 ) |
---|
| 1895 | { |
---|
[527] | 1896 | _printf("\n[BOOT] Schedulers initialised at cycle %d\n", |
---|
| 1897 | _get_proctime() ); |
---|
| 1898 | } |
---|
[258] | 1899 | |
---|
[552] | 1900 | // All processor P[x,y,0] contributes to load .elf files into clusters. |
---|
[527] | 1901 | boot_elf_load(); |
---|
[258] | 1902 | |
---|
[527] | 1903 | ////////////////////////////////////////////// |
---|
| 1904 | _simple_barrier_wait( &_barrier_all_clusters ); |
---|
| 1905 | ////////////////////////////////////////////// |
---|
| 1906 | |
---|
[552] | 1907 | // Each processor P[x][y][0] wake up other processors in same cluster |
---|
[524] | 1908 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 1909 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 1910 | unsigned int cluster_xy = (cx << Y_WIDTH) + cy; |
---|
| 1911 | unsigned int cluster_id = (cx * Y_SIZE) + cy; |
---|
[493] | 1912 | unsigned int p; |
---|
| 1913 | for ( p = 1 ; p < cluster[cluster_id].procs ; p++ ) |
---|
| 1914 | { |
---|
| 1915 | _xcu_send_wti( cluster_xy , p , (unsigned int)boot_entry ); |
---|
| 1916 | } |
---|
[258] | 1917 | |
---|
[527] | 1918 | // only P[0][0][0] makes display |
---|
| 1919 | if ( gpid == 0 ) |
---|
| 1920 | { |
---|
| 1921 | _printf("\n[BOOT] All processors start at cycle %d\n", |
---|
| 1922 | _get_proctime() ); |
---|
| 1923 | } |
---|
[493] | 1924 | } |
---|
[552] | 1925 | // All other processors activate MMU (using local PTAB) |
---|
[493] | 1926 | if ( lpid != 0 ) |
---|
[258] | 1927 | { |
---|
[493] | 1928 | _set_mmu_ptpr( (unsigned int)(_ptabs_paddr[0][cx][cy]>>13) ); |
---|
[258] | 1929 | _set_mmu_mode( 0xF ); |
---|
| 1930 | } |
---|
| 1931 | |
---|
[493] | 1932 | // All processors set CP0_SCHED register |
---|
| 1933 | _set_sched( (unsigned int)_schedulers[cx][cy][lpid] ); |
---|
| 1934 | |
---|
| 1935 | // All processors reset BEV bit in SR to use GIET_VM exception handler |
---|
[427] | 1936 | _set_sr( 0 ); |
---|
| 1937 | |
---|
[527] | 1938 | // Each proocessor get kernel entry virtual address |
---|
| 1939 | unsigned int kernel_entry = (unsigned int)&kernel_init_vbase; |
---|
| 1940 | |
---|
| 1941 | #if BOOT_DEBUG_ELF |
---|
[552] | 1942 | _printf("\n[DEBUG BOOT_ELF] P[%d,%d,%d] exit boot & jump to %x at cycle %d\n", |
---|
[527] | 1943 | cx, cy, lpid, kernel_entry , _get_proctime() ); |
---|
| 1944 | #endif |
---|
| 1945 | |
---|
[493] | 1946 | // All processors jump to kernel_init |
---|
[258] | 1947 | asm volatile( "jr %0" ::"r"(kernel_entry) ); |
---|
| 1948 | |
---|
| 1949 | } // end boot_init() |
---|
| 1950 | |
---|
| 1951 | |
---|
| 1952 | // Local Variables: |
---|
| 1953 | // tab-width: 4 |
---|
| 1954 | // c-basic-offset: 4 |
---|
| 1955 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 1956 | // indent-tabs-mode: nil |
---|
| 1957 | // End: |
---|
| 1958 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 1959 | |
---|