Changeset 296 for trunk/tools/bootloader_tsar
- Timestamp:
- Jul 31, 2017, 1:59:52 PM (7 years ago)
- Location:
- trunk/tools/bootloader_tsar
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/bootloader_tsar/boot.c
r279 r296 105 105 // kernel segments layout variables 106 106 107 uint32_t seg_kcode_base; // kcode segment base address108 uint32_t seg_kcode_size; // kcode segment size (bytes)109 uint32_t seg_kdata_base; // kdata segment base address110 uint32_t seg_kdata_size; // kdata segment size (bytes)111 uint32_t seg_k giet_base; // kcode segment base address112 uint32_t seg_k giet_size; // kcode segment size (bytes)107 uint32_t seg_kcode_base; // kcode segment base address 108 uint32_t seg_kcode_size; // kcode segment size (bytes) 109 uint32_t seg_kdata_base; // kdata segment base address 110 uint32_t seg_kdata_size; // kdata segment size (bytes) 111 uint32_t seg_kentry_base; // kcode segment base address 112 uint32_t seg_kentry_size; // kcode segment size (bytes) 113 113 114 114 uint32_t kernel_entry; // kernel entry point … … 175 175 /************************************************************************************** 176 176 * This function loads the 'kernel.elf' file into the boot cluster memory buffer, 177 * analyzes it, and places the three kcode, k giet, kdata segments at their final177 * analyzes it, and places the three kcode, kentry, kdata segments at their final 178 178 * physical adresses (defined the .elf file). 179 179 * It set the global variables defining the kernel layout. … … 192 192 bool_t kcode_found; // kcode segment found. 193 193 bool_t kdata_found; // kdata segment found. 194 bool_t k giet_found; // kgietsegment found.194 bool_t kentry_found; // kentry segment found. 195 195 uint32_t seg_id; // iterator for segments loop. 196 196 … … 231 231 232 232 // loop on segments 233 kcode_found = false;234 kdata_found = false;235 k giet_found = false;233 kcode_found = false; 234 kdata_found = false; 235 kentry_found = false; 236 236 for (seg_id = 0; seg_id < segments_nb; seg_id++) 237 237 { … … 265 265 266 266 // Note: we suppose that the 'kernel.elf' file contains exactly 267 // three loadable segments ktext, k giet, & kdata:268 // - the kcode segment is read-only and base < 0x80000000269 // - the k giet segment is read-only and base >= 0x8000000267 // three loadable segments ktext, kentry, & kdata: 268 // - the kcode segment is read-only and base == KCODE_BASE 269 // - the kentry segment is read-only and base == KENTRY_BASE 270 270 271 271 if( ((program_header[seg_id].p_flags & PF_W) == 0) && 272 (program_header[seg_id].p_paddr < 0x80000000) ) // kcode segment272 (program_header[seg_id].p_paddr == KCODE_BASE) ) // kcode segment 273 273 { 274 274 if( kcode_found ) … … 284 284 seg_kcode_size = seg_memsz; 285 285 } 286 else if( program_header[seg_id].p_paddr >= 0x80000000 ) // kgietsegment287 { 288 if( k giet_found )286 else if( program_header[seg_id].p_paddr == KENTRY_BASE ) // kentry segment 287 { 288 if( kentry_found ) 289 289 { 290 290 boot_printf("\n[BOOT_ERROR] in %s for file %s :\n" 291 " two k gietsegments found\n",291 " two kentry segments found\n", 292 292 __FUNCTION__ , KERNEL_PATHNAME ); 293 293 boot_exit(); 294 294 } 295 295 296 k giet_found = true;297 seg_k giet_base = seg_paddr;298 seg_k giet_size = seg_memsz;296 kentry_found = true; 297 seg_kentry_base = seg_paddr; 298 seg_kentry_size = seg_memsz; 299 299 } 300 300 else // kdata segment … … 322 322 boot_exit(); 323 323 } 324 if( k giet_found == false )325 { 326 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_k gietnot found\n",324 if( kentry_found == false ) 325 { 326 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry not found\n", 327 327 __FUNCTION__ , KERNEL_PATHNAME ); 328 328 boot_exit(); … … 333 333 __FUNCTION__ , KERNEL_PATHNAME ); 334 334 boot_exit(); 335 } 336 337 // check segments sizes 338 if( seg_kentry_size > KENTRY_MAX_SIZE ) 339 { 340 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry too large\n", 341 __FUNCTION__ , KERNEL_PATHNAME ); 342 boot_exit(); 343 } 344 345 if( (seg_kcode_size + seg_kdata_size) > KCODE_MAX_SIZE ) 346 { 347 boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode + seg_kdata too large\n", 348 __FUNCTION__ , KERNEL_PATHNAME ); 335 349 } 336 350 … … 388 402 389 403 // Initialize kernel segments from global variables 390 boot_info->kernel_code_start = seg_kcode_base; 391 boot_info->kernel_code_end = seg_kcode_base + seg_kcode_size; 392 boot_info->kernel_data_start = seg_kdata_base; 393 boot_info->kernel_data_end = seg_kdata_base + seg_kdata_size; 404 boot_info->kcode_base = seg_kcode_base; 405 boot_info->kcode_size = seg_kcode_size; 406 boot_info->kdata_base = seg_kdata_base; 407 boot_info->kdata_size = seg_kdata_size; 408 boot_info->kentry_base = seg_kentry_base; 409 boot_info->kentry_size = seg_kentry_size; 394 410 395 411 // loop on arch_info clusters to get relevant pointers … … 604 620 605 621 // Get the top address of the kernel segments 606 end = (boot_info->kernel_code_end > boot_info->kernel_data_end ) ? 607 boot_info->kernel_code_end : boot_info->kernel_data_end; 622 end = boot_info->kdata_base + boot_info->kdata_size; 608 623 609 624 // compute number of physical pages occupied by the kernel code … … 611 626 (end >> CONFIG_PPM_PAGE_SHIFT) : (end >> CONFIG_PPM_PAGE_SHIFT) + 1; 612 627 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; 628 // no reserved sones for TSAR architecture 629 boot_info->rsvd_nr = 0; 620 630 621 631 // set boot_info signature … … 697 707 698 708 #if DEBUG_BOOT_WAKUP 699 boot_printf("\n[BOOT] core[%x ][0] activated at cycle %d\n",709 boot_printf("\n[BOOT] core[%x,0] activated at cycle %d\n", 700 710 cluster->cxy , boot_get_proctime ); 701 711 #endif … … 726 736 727 737 #if DEBUG_BOOT_WAKUP 728 boot_printf("\n[BOOT] core[%x ][%d] activated at cycle %d\n",738 boot_printf("\n[BOOT] core[%x,%d] activated at cycle %d\n", 729 739 boot_info->cxy , core_id , boot_get_proctime() ); 730 740 #endif … … 754 764 if (cxy == BOOT_CORE_CXY) 755 765 { 756 boot_printf("\n[BOOT] core[%x ][%d] enters at cycle %d\n",766 boot_printf("\n[BOOT] core[%x,%d] enters at cycle %d\n", 757 767 cxy , lid , boot_get_proctime() ); 758 768 … … 775 785 boot_kernel_load(); 776 786 777 boot_printf("\n[BOOT] core[%x ][%d] loaded kernel at cycle %d\n",787 boot_printf("\n[BOOT] core[%x,%d] loaded kernel at cycle %d\n", 778 788 cxy , lid , boot_get_proctime() ); 779 789 … … 791 801 if (boot_info->signature != BOOT_INFO_SIGNATURE) 792 802 { 793 boot_printf("\n[BOOT ERROR] in %s reported by core[%x ][%d]\n"803 boot_printf("\n[BOOT ERROR] in %s reported by core[%x,%d]\n" 794 804 " illegal boot_info signature / should be %x\n", 795 805 __FUNCTION__ , cxy , lid , BOOT_INFO_SIGNATURE ); … … 797 807 } 798 808 799 boot_printf("\n[BOOT] core[%x ][%d] loaded boot_info at cycle %d\n",809 boot_printf("\n[BOOT] core[%x,%d] loaded boot_info at cycle %d\n", 800 810 cxy , lid , boot_get_proctime() ); 801 811 … … 812 822 // activate other local cores 813 823 boot_wake_local_cores( boot_info ); 824 825 // display address extensions 826 uint32_t cp2_data_ext; 827 uint32_t cp2_ins_ext; 828 asm volatile( "mfc2 %0, $24" : "=&r" (cp2_data_ext) ); 829 asm volatile( "mfc2 %0, $25" : "=&r" (cp2_ins_ext) ); 830 boot_printf("\n[BOOT] core[%x,%d] CP2_DATA_EXT = %x / CP2_INS_EXT = %x\n", 831 cxy , lid , cp2_data_ext , cp2_ins_ext ); 814 832 815 833 // Wait until all local cores in cluster ready … … 832 850 833 851 // from now, it is safe to refer to the boot code global variables 834 boot_printf("\n[BOOT] core[%x ][%d] replicated boot code at cycle %d\n",852 boot_printf("\n[BOOT] core[%x,%d] replicated boot code at cycle %d\n", 835 853 cxy , lid , boot_get_proctime() ); 836 854 837 855 // switch to the INSTRUCTION local memory space, to avoid contention. 838 856 asm volatile("mtc2 %0, $25" :: "r"(cxy)); 839 857 … … 843 861 ARCHINFO_MAX_SIZE ); 844 862 845 boot_printf("\n[BOOT] core[%x ][%d] replicated arch_info at cycle %d\n",863 boot_printf("\n[BOOT] core[%x,%d] replicated arch_info at cycle %d\n", 846 864 cxy , lid , boot_get_proctime() ); 847 865 … … 856 874 seg_kdata_size ); 857 875 858 boot_printf("\n[BOOT] core[%x ][%d] replicated kernel code at cycle %d\n",876 boot_printf("\n[BOOT] core[%x,%d] replicated kernel code at cycle %d\n", 859 877 cxy , lid , boot_get_proctime() ); 860 878 … … 876 894 // activate other local cores 877 895 boot_wake_local_cores( boot_info ); 896 897 // display address extensions 898 uint32_t cp2_data_ext; 899 uint32_t cp2_ins_ext; 900 asm volatile( "mfc2 %0, $24" : "=&r" (cp2_data_ext) ); 901 asm volatile( "mfc2 %0, $25" : "=&r" (cp2_ins_ext) ); 902 boot_printf("\n[BOOT] core[%x,%d] CP2_DATA_EXT = %x / CP2_INS_EXT = %x\n", 903 cxy , lid , cp2_data_ext , cp2_ins_ext ); 878 904 879 905 // Wait until all local cores in cluster ready … … 897 923 // Check core information 898 924 boot_check_core(boot_info, lid); 925 926 // display address extensions 927 uint32_t cp2_data_ext; 928 uint32_t cp2_ins_ext; 929 asm volatile( "mfc2 %0, $24" : "=&r" (cp2_data_ext) ); 930 asm volatile( "mfc2 %0, $25" : "=&r" (cp2_ins_ext) ); 931 boot_printf("\n[BOOT] core[%x,%d] CP2_DATA_EXT = %x / CP2_INS_EXT = %x\n", 932 cxy , lid , cp2_data_ext , cp2_ins_ext ); 899 933 900 934 // Wait until all local cores in cluster ready … … 911 945 uint32_t pmask = CONFIG_PPM_PAGE_MASK; 912 946 uint32_t psize = CONFIG_PPM_PAGE_SIZE; 947 913 948 914 949 // compute base address of idle thread descriptors array … … 927 962 "ori $26, $26, 0xFFFF \n" 928 963 "and $27, $27, $26 \n" 929 "mtc0 $27, $12 \n" 964 "mtc0 $27, $12 \n" 930 965 "move $4, %0 \n" 931 966 "move $29, %1 \n" -
trunk/tools/bootloader_tsar/boot_config.h
r68 r296 20 20 21 21 // Preloader temporary segment 22 #define PRELOADER_BASE 0x0 /* Preloader base address. */23 #define PRELOADER_MAX_SIZE 0x 4000 /* Preloader max size. */22 #define PRELOADER_BASE 0x00000000 // 'preloader' physical base address 23 #define PRELOADER_MAX_SIZE 0x00004000 // 'preloader' max size 24 24 25 // boot code temporary segment26 #define BOOT_BASE 0x100000 /* 'boot.elf' base address. */27 #define BOOT_MAX_SIZE 0x010000 /* 'boot.elf' max size. */25 // kentry segment 26 #define KENTRY_BASE 0x00004000 // 'kentry' segment physical base address 27 #define KENTRY_MAX_SIZE 0X00004000 // 'kentry' segment max size 28 28 29 // arch_info temporarysegment30 #define ARCHINFO_BASE 0x200000 /* 'arch_info.bin' file base address */31 #define ARCHINFO_MAX_SIZE 0x010000 /* 'arch_info.bin' file max size. */29 // kcode segment 30 #define KCODE_BASE 0x00008000 // 'kcode' segment physical base address 31 #define KCODE_MAX_SIZE 0x000F8000 // 'kcode' + 'kdata' segments max size 32 32 33 // kernel code temporary segment 34 #define KERN_BASE 0x300000 /* 'kernel.elf' file base address */ 35 #define KERN_MAX_SIZE 0x200000 /* 'kernel.elf' file max size. */ 33 // boot.elf file temporary buffer 34 #define BOOT_BASE 0x00100000 // 'boot.elf' file physical base address 35 #define BOOT_MAX_SIZE 0x00010000 // 'boot.elf' file max size 36 37 // arch_info file temporary buffer 38 #define ARCHINFO_BASE 0x00200000 // 'arch_info.bin' file physical base address 39 #define ARCHINFO_MAX_SIZE 0x00010000 // 'arch_info.bin' file max size 40 41 // kernel.elf file temporary buffer 42 #define KERN_BASE 0x00300000 // 'kernel.elf' file base address 43 #define KERN_MAX_SIZE 0x00200000 // 'kernel.elf' file max size 36 44 37 45 // Temporary stacks segments 38 #define BOOT_STACK_BASE 0x504000 /* Boot stack base address. */ 39 #define BOOT_STACK_SIZE 0x4000 /* Boot stack size (16Kb) */ 46 #define BOOT_STACK_BASE 0x00504000 // Boot stack base address 47 #define BOOT_STACK_SIZE 0x00004000 // Boot stack size (16Kb) 48 49 40 50 41 51 #endif // _BOOT_CONFIG_H -
trunk/tools/bootloader_tsar/boot_entry.S
r6 r296 22 22 */ 23 23 24 /********************************************************************************************** ***25 * This file contains the entry point of the ALMOS-MK boot-loader for TSAR architecture. 26 * It supports a generic multi-clusters / multi-processors architecture 27 * 28 * - The number of clusters is defined by the (X_SIZE, Y_SIZE) parameters in the 29 * hard_config.h file (up to 256 clusters). 30 * - The number of processors per cluster is defined by the NB_PROCS_MAX parameter in the 31 * hard_config.h file (up to 4 processors per cluster). 32 * 33 * This assembly code is executed by all cores. It has 2 versions (in order to see if the 34 * contention created by the ARCHINFO core descriptor table scanning loops is acceptable): 35 * with or without the assumption that the core hardware identifier gid has a fixed format: 36 * 37 * - Version with fixed format: gid == (((x << Y_WIDTH) + y) << PADDR_WIDTH) + lid 38 * It does 3 things: 39 * + It initializes the stack pointer depending on the lid extracted from the gid, 40 * using the BOOT_STACK_BASE and BOOT_STACK_SIZE parameters defined in the 41 * 'boot_config.h' file, 42 * + It changes the value of the address extension registers using the cxy extracted 43 * from the gid, 44 * + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2 45 * arguments which are the cxy and lid of each core to this function. 46 * 47 * - Version without fixed format 48 * It has to perform an additional step in order to extract the (cxy,lid) values from the 49 * arch_info.bin structure that has been loaded in the cluster (0,0) memory by the bscpu. 50 * + Each core other than the bscpu scans the core descriptor table in the arch_info.bin 51 * structure to make an associative search on the (gid), and get the (cxy,lid). 52 * + It initializes the stack pointer depending on the lid, using the BOOT_STACK_BASE 53 * and BOOT_STACK_SIZE parameters defined in the 'boot_config.h' file, 54 * + It changes the value of the address extension registers using cxy obtained 55 * previously, 56 * + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2 57 * arguments which are the cxy and lid of each core to this function. 58 ********************************************************************************************* ****/24 /********************************************************************************************** 25 * This file contains the entry point of the ALMOS-MK boot-loader for TSAR architecture. * 26 * It supports a generic multi-clusters / multi-processors architecture * 27 * * 28 * - The number of clusters is defined by the (X_SIZE, Y_SIZE) parameters in the * 29 * hard_config.h file (up to 256 clusters). * 30 * - The number of processors per cluster is defined by the NB_PROCS_MAX parameter in the * 31 * hard_config.h file (up to 4 processors per cluster). * 32 * * 33 * This assembly code is executed by all cores. It has 2 versions (in order to see if the * 34 * contention created by the ARCHINFO core descriptor table scanning loops is acceptable): * 35 * with or without the assumption that the core hardware identifier gid has a fixed format: * 36 * * 37 * - Version with fixed format: gid == (((x << Y_WIDTH) + y) << PADDR_WIDTH) + lid * 38 * It does 3 things: * 39 * + It initializes the stack pointer depending on the lid extracted from the gid, * 40 * using the BOOT_STACK_BASE and BOOT_STACK_SIZE parameters defined in the * 41 * 'boot_config.h' file, * 42 * + It changes the value of the address extension registers using the cxy extracted * 43 * from the gid, * 44 * + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2 * 45 * arguments which are the cxy and lid of each core to this function. * 46 * * 47 * - Version without fixed format * 48 * It has to perform an additional step in order to extract the (cxy,lid) values from the * 49 * arch_info.bin structure that has been loaded in the cluster (0,0) memory by the bscpu. * 50 * + Each core other than the bscpu scans the core descriptor table in the arch_info.bin * 51 * structure to make an associative search on the (gid), and get the (cxy,lid). * 52 * + It initializes the stack pointer depending on the lid, using the BOOT_STACK_BASE * 53 * and BOOT_STACK_SIZE parameters defined in the 'boot_config.h' file, * 54 * + It changes the value of the address extension registers using cxy obtained * 55 * previously, * 56 * + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2 * 57 * arguments which are the cxy and lid of each core to this function. * 58 *********************************************************************************************/ 59 59 60 60 #include "mips32_registers.h"
Note: See TracChangeset
for help on using the changeset viewer.