Changeset 279 for trunk/tools/bootloader_tsar
- Timestamp:
- Jul 27, 2017, 12:23:29 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/bootloader_tsar/boot.c
r204 r279 109 109 uint32_t seg_kdata_base; // kdata segment base address 110 110 uint32_t seg_kdata_size; // kdata segment size (bytes) 111 uint32_t seg_kgiet_base; // kcode segment base address 112 uint32_t seg_kgiet_size; // kcode segment size (bytes) 113 111 114 uint32_t kernel_entry; // kernel entry point 112 115 … … 172 175 /************************************************************************************** 173 176 * This function loads the 'kernel.elf' file into the boot cluster memory buffer, 174 * analyzes it, and places the th e two seg_kcode & seg_kdata segments at their final175 * physical adresses ( just after the preloader zone).177 * analyzes it, and places the three kcode, kgiet, kdata segments at their final 178 * physical adresses (defined the .elf file). 176 179 * It set the global variables defining the kernel layout. 177 180 *************************************************************************************/ … … 189 192 bool_t kcode_found; // kcode segment found. 190 193 bool_t kdata_found; // kdata segment found. 194 bool_t kgiet_found; // kgiet segment found. 191 195 uint32_t seg_id; // iterator for segments loop. 192 196 … … 229 233 kcode_found = false; 230 234 kdata_found = false; 235 kgiet_found = false; 231 236 for (seg_id = 0; seg_id < segments_nb; seg_id++) 232 237 { … … 259 264 } 260 265 261 // Note: we suppose that the 'kernel.elf' file contains only 2262 // loadable segments ktext & kdata and that the main263 // difference between these two is the WRITE permission: ktext264 // contains read-only instructions and read_only data,265 // while kdata contains writable data. 266 267 if ((program_header[seg_id].p_flags & PF_W) == 0)// kcode segment266 // Note: we suppose that the 'kernel.elf' file contains exactly 267 // three loadable segments ktext, kgiet, & kdata: 268 // - the kcode segment is read-only and base < 0x80000000 269 // - the kgiet segment is read-only and base >= 0x8000000 270 271 if( ((program_header[seg_id].p_flags & PF_W) == 0) && 272 (program_header[seg_id].p_paddr < 0x80000000) ) // kcode segment 268 273 { 269 274 if( kcode_found ) 270 275 { 271 276 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 272 " two loadablekcode segments found\n",277 " two kcode segments found\n", 273 278 __FUNCTION__ , KERNEL_PATHNAME ); 274 279 boot_exit(); … … 279 284 seg_kcode_size = seg_memsz; 280 285 } 281 else // kdata segment 286 else if( program_header[seg_id].p_paddr >= 0x80000000 ) // kgiet segment 287 { 288 if( kgiet_found ) 289 { 290 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 291 " two kgiet segments found\n", 292 __FUNCTION__ , KERNEL_PATHNAME ); 293 boot_exit(); 294 } 295 296 kgiet_found = true; 297 seg_kgiet_base = seg_paddr; 298 seg_kgiet_size = seg_memsz; 299 } 300 else // kdata segment 282 301 { 283 302 if( kdata_found ) … … 299 318 if( kcode_found == false ) 300 319 { 301 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 302 " kcode segment not found\n", 320 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode not found\n", 303 321 __FUNCTION__ , KERNEL_PATHNAME ); 304 322 boot_exit(); 305 323 } 306 if( kdata_found == false ) 307 { 308 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 309 " kdata segment not found\n", 324 if( kgiet_found == false ) 325 { 326 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kgiet not found\n", 310 327 __FUNCTION__ , KERNEL_PATHNAME ); 311 328 boot_exit(); 312 329 } 330 if( kdata_found == false ) 331 { 332 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kdata not found\n", 333 __FUNCTION__ , KERNEL_PATHNAME ); 334 boot_exit(); 335 } 313 336 314 337 // set entry point … … 316 339 317 340 #if DEBUG_BOOT_ELF 318 boot_printf("\n[BOOT INFO] %s successfullycompleted for file %s at cycle %d\n",341 boot_printf("\n[BOOT INFO] %s completed for file %s at cycle %d\n", 319 342 __FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() ); 320 343 #endif … … 584 607 boot_info->kernel_code_end : boot_info->kernel_data_end; 585 608 586 // Set number ofpages occupied by the kernel code609 // compute number of physical pages occupied by the kernel code 587 610 boot_info->pages_offset = ( (end & CONFIG_PPM_PAGE_MASK) == 0 ) ? 588 611 (end >> CONFIG_PPM_PAGE_SHIFT) : (end >> CONFIG_PPM_PAGE_SHIFT) + 1; 589 612 590 // No "reserved zones" for the TSAR architecture 591 boot_info->rsvd_nr = 0; 613 // set one reserved zone for giet code 614 uint32_t first_page = seg_kgiet_base >> CONFIG_PPM_PAGE_SHIFT; 615 uint32_t last_page = (seg_kgiet_base + seg_kgiet_size - 1) >> CONFIG_PPM_PAGE_SHIFT; 616 617 boot_info->rsvd_nr = 1; 618 boot_info->rsvd[0].first_page = first_page; 619 boot_info->rsvd[0].npages = last_page - first_page + 1; 592 620 593 621 // set boot_info signature
Note: See TracChangeset
for help on using the changeset viewer.