Changeset 572 for trunk/boot/tsar_mips32/boot.c
- Timestamp:
- Oct 5, 2018, 12:20:34 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/boot/tsar_mips32/boot.c
r562 r572 2 2 * boot.c - TSAR bootloader implementation. 3 3 * 4 * Authors : Alain Greiner / Vu Son (2016) 4 * Authors : Vu Son (2016) 5 * Alain Greiner (2016, 2017,2018) 5 6 * 6 7 * Copyright (c) UPMC Sorbonne Universites … … 55 56 * - activate all other cores in the same cluster (CPi). * 56 57 * - wait local CPi completion reports on a local barrier. * 57 * - report completion to bscpu on the global barrier.*58 * - report completion on the global barrier. * 58 59 * * 59 60 * 3) The boot-loader third phase is executed in parallel by all cores. * 60 * After passing the global barrier the bscpu:*61 * - activates the CPi of cluster(0),*61 * In each cluster (i) the CP0 * 62 * - activates the other cores of cluster(i), * 62 63 * - blocks on the local barrier waiting for all local CPi to report * 63 64 * completion on the local barrier, * … … 65 66 * address 0x0, (erasing the preloader code). * 66 67 * * 67 * 4) All cores have finished the boot phase, they jump to the kern_init() * 68 * function (maybe not at the same time). * 68 * 4) All cores jump to kern_init() (maybe not at the same time). * 69 69 ****************************************************************************/ 70 70 … … 77 77 #include <arch_info.h> 78 78 #include <boot_info.h> 79 80 #include <cluster_info.h>81 79 82 80 #include <boot_utils.h> … … 84 82 #include <boot_bdv_driver.h> 85 83 #include <boot_hba_driver.h> 86 #include <boot_spi_driver.h>87 84 #include <boot_tty_driver.h> 88 85 … … 117 114 uint32_t kernel_entry; // kernel entry point 118 115 119 // address used by the WTI to activate remote CP0s 120 121 // Functions called by boot_entry.S must be externs. 116 // Functions called by boot_entry.S 117 122 118 extern void boot_entry( void ); // boot_loader entry point 123 119 extern void boot_loader( lid_t lid, cxy_t cxy ); 124 120 121 122 #if DEBUG_BOOT_INFO 125 123 /********************************************************************************* 126 * This function returns the printable string for each device type124 * This debug function returns the printable string for each device type. 127 125 ********************************************************************************/ 128 static const char * device_type_str( boot_device_types_t dev_type ) { 129 switch (dev_type) { 126 static char * device_type_str( enum device_types_e dev_type ) 127 { 128 switch ( dev_type ) 129 { 130 130 case DEV_TYPE_RAM_SCL: return "RAM_SCL"; 131 131 case DEV_TYPE_ROM_SCL: return "ROM_SCL"; … … 148 148 } 149 149 } 150 #endif 150 151 151 152 /************************************************************************************ … … 160 161 { 161 162 boot_printf("\n[BOOT ERROR]: boot_archinfo_load(): " 162 163 163 "<%s> file not found\n", 164 ARCHINFO_PATHNAME); 164 165 boot_exit(); 165 166 } … … 168 169 { 169 170 boot_printf("\n[BOOT_ERROR]: boot_archinfo_load(): " 170 171 171 "<%s> file signature should be %x\n", 172 ARCHINFO_PATHNAME, ARCHINFO_SIGNATURE); 172 173 boot_exit(); 173 174 } … … 175 176 #if DEBUG_BOOT_INFO 176 177 boot_printf("\n[BOOT INFO] in %s : file %s loaded at address = %x\n", 177 178 __FUNCTION__ , ARCHINFO_PATHNAME , ARCHINFO_BASE ); 178 179 #endif 179 180 … … 204 205 #if DEBUG_BOOT_ELF 205 206 boot_printf("\n[BOOT INFO] %s enters for file %s at cycle %d\n", 206 207 __FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() ); 207 208 #endif 208 209 … … 261 262 #if DEBUG_BOOT_ELF 262 263 boot_printf("\n[BOOT INFO] in %s for file %s : found loadable segment\n" 263 264 264 " base = %x / size = %x\n", 265 __FUNCTION__ , KERNEL_PATHNAME , seg_paddr , seg_memsz ); 265 266 #endif 266 267 … … 282 283 { 283 284 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 284 285 285 " two kcode segments found\n", 286 __FUNCTION__ , KERNEL_PATHNAME ); 286 287 boot_exit(); 287 288 } … … 296 297 { 297 298 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 298 299 299 " two kentry segments found\n", 300 __FUNCTION__ , KERNEL_PATHNAME ); 300 301 boot_exit(); 301 302 } … … 310 311 { 311 312 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 312 " two loadablekdata segments found\n",313 313 " two kdata segments found\n", 314 __FUNCTION__ , KERNEL_PATHNAME ); 314 315 boot_exit(); 315 316 } … … 326 327 { 327 328 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode not found\n", 328 329 __FUNCTION__ , KERNEL_PATHNAME ); 329 330 boot_exit(); 330 331 } … … 332 333 { 333 334 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry not found\n", 334 335 __FUNCTION__ , KERNEL_PATHNAME ); 335 336 boot_exit(); 336 337 } … … 338 339 { 339 340 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kdata not found\n", 340 341 __FUNCTION__ , KERNEL_PATHNAME ); 341 342 boot_exit(); 342 343 } … … 346 347 { 347 348 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry too large\n", 348 349 __FUNCTION__ , KERNEL_PATHNAME ); 349 350 boot_exit(); 350 351 } … … 353 354 { 354 355 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode + seg_kdata too large\n", 355 356 __FUNCTION__ , KERNEL_PATHNAME ); 356 357 } 357 358 … … 361 362 #if DEBUG_BOOT_ELF 362 363 boot_printf("\n[BOOT INFO] %s completed for file %s at cycle %d\n", 363 364 __FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() ); 364 365 #endif 365 366 … … 382 383 archinfo_cluster_t * cluster; 383 384 archinfo_cluster_t * my_cluster = NULL; // target cluster 384 archinfo_cluster_t * io_cluster = NULL; // cluster containing ext. peripherals385 archinfo_cluster_t * io_cluster = NULL; // external peripherals cluster 385 386 386 387 archinfo_core_t * core; … … 416 417 boot_info->kentry_size = seg_kentry_size; 417 418 418 /* Initialize all clusters as empty for now */ 419 int x, y; 420 for ( x = 0; x < CONFIG_MAX_CLUSTERS_X; x++) 421 { 422 for ( x = 0; x < CONFIG_MAX_CLUSTERS_X; x++) 423 { 424 boot_info->cluster_info[x][y] = 0x0; 425 } 426 } 427 428 // loop on arch_info clusters to get relevant pointers 419 // loop on arch_info clusters to build cluster_info[][] array 420 // and get io_cluster and my_cluster pointers 429 421 for (cluster = cluster_base; 430 422 cluster < &cluster_base[header->x_size * header->y_size]; … … 433 425 int x = cluster->cxy >> Y_WIDTH; 434 426 int y = cluster->cxy & ((1 << Y_WIDTH) - 1); 435 436 if( cluster->cxy == cxy ) my_cluster = cluster; 437 if( cluster->cxy == header->io_cxy ) { 438 io_cluster = cluster; 439 boot_info->cluster_info[x][y] |= CINFO_IS_IO; 440 } 441 if ( cluster->cores > 0 ) { 442 boot_info->cluster_info[x][y] |= CINFO_ACTIVE; 443 } 427 boot_info->cluster_info[x][y] = (uint8_t)cluster->cores; 428 429 if( cluster->cxy == cxy ) my_cluster = cluster; 430 if( cluster->cxy == header->io_cxy ) io_cluster = cluster; 444 431 } 445 432 … … 447 434 { 448 435 boot_printf("\n[ERROR] in %s : cannot found cluster %x in arch_info\n", 449 436 __FUNCTION__ , cxy ); 450 437 boot_exit(); 451 438 } … … 454 441 { 455 442 boot_printf("\n[ERROR] in %s : cannot found io_cluster %x in arch_info\n", 456 __FUNCTION__ , header->io_cxy );443 __FUNCTION__ , cxy ); 457 444 boot_exit(); 458 445 } … … 463 450 #if DEBUG_BOOT_INFO 464 451 boot_printf("\n[BOOT INFO] %s : external peripherals at cycle %d\n", 465 452 __FUNCTION__ , boot_get_proctime() ); 466 453 #endif 467 454 … … 474 461 { 475 462 boot_printf("\n[ERROR] in %s : too much external devices in arch_info\n", 476 463 __FUNCTION__ ); 477 464 boot_exit(); 478 465 } … … 501 488 #if DEBUG_BOOT_INFO 502 489 boot_printf(" - %s : base = %l / size = %l / channels = %d / irqs = %d\n", 503 device_type_str( device->type ) , device->base , device->size , 504 device->channels , device->irqs ); 490 device_type_str(device->type), device->base, device->size, device->channels, device->irqs ); 505 491 #endif 506 492 } … … 525 511 #if DEBUG_BOOT_INFO 526 512 boot_printf(" . irq_port = %d / source = %s / channel = %d / is_rx = %d\n", 527 513 irq->port , device_type_str( irq->dev_type ) , irq->channel , irq->is_rx ); 528 514 #endif 529 515 } … … 554 540 #if DEBUG_BOOT_INFO 555 541 boot_printf(" - core_gid = %x : cxy = %x / lid = %d\n", 556 542 core->gid , core->cxy , core->lid ); 557 543 #endif 558 544 core_id++; … … 566 552 567 553 #if DEBUG_BOOT_INFO 568 boot_printf("\n[BOOT INFO] %s : internal peripherals in cluster %x\n", __FUNCTION__ , cxy ); 554 boot_printf("\n[BOOT INFO] %s : internal peripherals in cluster %x\n", 555 __FUNCTION__ , cxy ); 569 556 #endif 570 557 … … 615 602 #if DEBUG_BOOT_INFO 616 603 boot_printf(" - %s : base = %l / size = %l / channels = %d / irqs = %d\n", 617 618 604 device_type_str( device->type ) , device->base , device->size , 605 device->channels , device->irqs ); 619 606 #endif 620 607 … … 637 624 #if DEBUG_BOOT_INFO 638 625 boot_printf(" . irq_port = %d / source = %s / channel = %d / is_rx = %d\n", 639 626 irq->port , device_type_str( irq->dev_type ) , irq->channel , irq->is_rx ); 640 627 #endif 641 628 … … 656 643 (end >> CONFIG_PPM_PAGE_SHIFT) : (end >> CONFIG_PPM_PAGE_SHIFT) + 1; 657 644 658 // no reserved sones for TSAR architecture645 // no reserved zones for TSAR architecture 659 646 boot_info->rsvd_nr = 0; 660 647 … … 738 725 #if DEBUG_BOOT_WAKUP 739 726 boot_printf("\n[BOOT] core[%x,0] activated at cycle %d\n", 740 727 cluster->cxy , boot_get_proctime ); 741 728 #endif 742 729 … … 767 754 #if DEBUG_BOOT_WAKUP 768 755 boot_printf("\n[BOOT] core[%x,%d] activated at cycle %d\n", 769 756 boot_info->cxy , core_id , boot_get_proctime() ); 770 757 #endif 771 758 // send an IPI … … 801 788 else if (USE_IOC_HBA) boot_hba_init(); 802 789 // else if (USE_IOC_SDC) boot_sdc_init(); 803 else if (USE_IOC_SPI) boot_spi_init();790 // else if (USE_IOC_SPI) boot_spi_init(); 804 791 else if (!USE_IOC_RDK) 805 792 { … … 816 803 817 804 boot_printf("\n[BOOT] core[%x,%d] loaded kernel at cycle %d\n", 818 805 cxy , lid , boot_get_proctime() ); 819 806 820 807 // Load the arch_info.bin file into memory. 821 808 boot_archinfo_load(); 809 810 boot_printf("\n[BOOT] core[%x,%d] loaded arch_info at cycle %d\n", 811 cxy , lid , boot_get_proctime() ); 822 812 823 813 // Get local boot_info_t structure base address. … … 827 817 // Initialize local boot_info_t structure. 828 818 boot_info_init( boot_info , cxy ); 819 820 boot_printf("\n[BOOT] core[%x,%d] initialised boot_info at cycle %d\n", 821 cxy , lid , boot_get_proctime() ); 829 822 830 823 // check boot_info signature … … 832 825 { 833 826 boot_printf("\n[BOOT ERROR] in %s reported by core[%x,%d]\n" 834 835 827 " illegal boot_info signature / should be %x\n", 828 __FUNCTION__ , cxy , lid , BOOT_INFO_SIGNATURE ); 836 829 boot_exit(); 837 830 } 838 839 boot_printf("\n[BOOT] core[%x,%d] loaded arch_info at cycle %d\n",840 cxy , lid , boot_get_proctime() );841 831 842 832 // Check core information. … … 881 871 // from now, it is safe to refer to the boot code global variables 882 872 boot_printf("\n[BOOT] core[%x,%d] replicated boot code at cycle %d\n", 883 873 cxy , lid , boot_get_proctime() ); 884 874 885 875 // switch to the INSTRUCTION local memory space, to avoid contention. … … 892 882 893 883 boot_printf("\n[BOOT] core[%x,%d] replicated arch_info at cycle %d\n", 894 884 cxy , lid , boot_get_proctime() ); 895 885 896 886 // Copy the kcode segment into local memory … … 910 900 911 901 boot_printf("\n[BOOT] core[%x,%d] replicated kernel code at cycle %d\n", 912 902 cxy , lid , boot_get_proctime() ); 913 903 914 904 // Get local boot_info_t structure base address. … … 917 907 // Initialize local boot_info_t structure. 918 908 boot_info_init( boot_info , cxy ); 909 910 boot_printf("\n[BOOT] core[%x,%d] initialised boot_info at cycle %d\n", 911 cxy , lid , boot_get_proctime() ); 919 912 920 913 // Check core information.
Note: See TracChangeset
for help on using the changeset viewer.