Ignore:
Timestamp:
Jul 27, 2017, 12:23:29 AM (7 years ago)
Author:
alain
Message:

1) Introduce independant command fields for the various devices in the thread descriptor.
2) Introduce a new dev_pic_enable_ipi() function in the generic PIC device
3) Fix two bugs identified by Maxime in the scheduler initialisation, and in the sched_select().
4) fix several bugs in the TSAR hal_kentry.S.
5) Introduce a third kgiet segment (besides kdata and kcode) in the TSAR bootloader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bootloader_tsar/boot.c

    r204 r279  
    109109uint32_t                        seg_kdata_base;  // kdata segment base address
    110110uint32_t                        seg_kdata_size;  // kdata segment size (bytes)
     111uint32_t                        seg_kgiet_base;  // kcode segment base address
     112uint32_t                        seg_kgiet_size;  // kcode segment size (bytes)
     113
    111114uint32_t                        kernel_entry;    // kernel entry point
    112115
     
    172175/**************************************************************************************
    173176 * This function loads the 'kernel.elf' file into the boot cluster memory buffer,
    174  * analyzes it, and places the the two seg_kcode & seg_kdata segments at their final
    175  * 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).       
    176179 * It set the global variables defining the kernel layout.
    177180 *************************************************************************************/
     
    189192    bool_t       kcode_found;     // kcode segment found.
    190193    bool_t       kdata_found;     // kdata segment found.
     194    bool_t       kgiet_found;     // kgiet segment found.
    191195    uint32_t     seg_id;          // iterator for segments loop.
    192196
     
    229233    kcode_found = false;
    230234    kdata_found = false;
     235    kgiet_found = false;
    231236    for (seg_id = 0; seg_id < segments_nb; seg_id++)
    232237    {
     
    259264            }
    260265
    261             // Note: we suppose that the 'kernel.elf' file contains only 2
    262             // loadable segments ktext & kdata and that the main
    263             // difference between these two is the WRITE permission: ktext
    264             // 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 segment
     266            // 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
    268273            {
    269274                if( kcode_found )
    270275                {
    271276                    boot_printf("\n[BOOT_ERROR] in %s for file %s :\n"
    272                                 "   two loadable kcode segments found\n",
     277                                "   two kcode segments found\n",
    273278                                __FUNCTION__ , KERNEL_PATHNAME );
    274279                    boot_exit();
     
    279284                seg_kcode_size = seg_memsz;
    280285            }
    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
    282301            {
    283302                if( kdata_found )
     
    299318    if( kcode_found == false )
    300319    {
    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",
    303321                    __FUNCTION__ , KERNEL_PATHNAME );
    304322        boot_exit();
    305323    }
    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",
    310327                    __FUNCTION__ , KERNEL_PATHNAME );
    311328        boot_exit();
    312329    }
     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    }
    313336
    314337    // set entry point
     
    316339
    317340#if DEBUG_BOOT_ELF
    318 boot_printf("\n[BOOT INFO] %s successfully completed for file %s at cycle %d\n",
     341boot_printf("\n[BOOT INFO] %s completed for file %s at cycle %d\n",
    319342            __FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() );
    320343#endif
     
    584607          boot_info->kernel_code_end : boot_info->kernel_data_end;
    585608
    586     // Set number of pages occupied by the kernel code
     609    // compute number of physical pages occupied by the kernel code
    587610    boot_info->pages_offset = ( (end & CONFIG_PPM_PAGE_MASK) == 0 ) ?
    588611                 (end >> CONFIG_PPM_PAGE_SHIFT) : (end >> CONFIG_PPM_PAGE_SHIFT) + 1;
    589612
    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;
    592620
    593621    // set boot_info signature
Note: See TracChangeset for help on using the changeset viewer.