Changeset 359


Ignore:
Timestamp:
Jul 23, 2014, 10:09:42 AM (10 years ago)
Author:
alain
Message:

1/ Introduce the boot.S file that is the entry point
in the GIET-VM bootloader: The GIET-VM does not use
the preloader stack anymore, but uses its own stack
2/ Remove the seg_boot_buffer segment for the boot-loader.
The buffer used to load a complete .elf segment is defined
as a global variable in the seg_boot_data segment.
The GIET_ELF_BUFFER_SIZE is defined in the giet_config.h file.

Location:
soft/giet_vm/giet_boot
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_boot/boot.c

    r356 r359  
    88//
    99// This nano-kernel has been written for the MIPS32 processor.
    10 // The virtual adresses are on 32 bits and use the (unsigned int) type, but the
     10// The virtual adresses are on 32 bits and use the (unsigned int) type. The
    1111// physicals addresses can have up to 40 bits, and use the  (unsigned long long) type.
    1212// It natively supports clusterised shared mmemory multi-processors architectures,
     
    1414// and where there is one physical memory bank per cluster.
    1515//
    16 // This code, executed in the boot phase by proc[0,0,0] performs the following tasks:
    17 // - load into memory the binary files, from a FAT32 file system,
     16// This code, executed in the boot phase by proc[0,0,0], performs the following tasks:
     17// - load into memory various binary files, from a FAT32 file system,
    1818// - build the various page tables (one page table per vspace)
    1919// - initialize the shedulers (one scheduler per processor)
     
    9595
    9696#if !defined(X_SIZE)
    97 # error The X_SIZE value must be defined in the 'hard_config.h' file !
     97# error: The X_SIZE value must be defined in the 'hard_config.h' file !
    9898#endif
    9999
    100100#if !defined(Y_SIZE)
    101 # error The Y_SIZE value must be defined in the 'hard_config.h' file !
     101# error: The Y_SIZE value must be defined in the 'hard_config.h' file !
    102102#endif
    103103
    104104#if !defined(X_WIDTH)
    105 # error The X_WIDTH value must be defined in the 'hard_config.h' file !
     105# error: The X_WIDTH value must be defined in the 'hard_config.h' file !
    106106#endif
    107107
    108108#if !defined(Y_WIDTH)
    109 # error The Y_WIDTH value must be defined in the 'hard_config.h' file !
     109# error: The Y_WIDTH value must be defined in the 'hard_config.h' file !
    110110#endif
    111111
    112112#if !defined(SEG_BOOT_MAPPING_BASE)
    113 # error: You must define SEG_BOOT_MAPPING_BASE in the hard_config.h file
    114 #endif
    115 
    116 #if !defined(SEG_BOOT_BUFFER_BASE)
    117 # error: You must define SEG_BOOT_BUFFER_BASE in the hard_config.h file
    118 #endif
    119 
    120 #if !defined(SEG_BOOT_BUFFER_SIZE)
    121 # error: You must define SEG_BOOT_BUFFER_SIZE in the hard_config.h file
     113# error: The SEG_BOOT_MAPPING_BASE value must be defined in the hard_config.h file !
    122114#endif
    123115
    124116#if !defined(NB_PROCS_MAX)
    125 # error The NB_PROCS_MAX value must be defined in the 'hard_config.h' file !
     117# error: The NB_PROCS_MAX value must be defined in the 'hard_config.h' file !
    126118#endif
    127119
    128120#if !defined(GIET_NB_VSPACE_MAX)
    129 # error The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file !
     121# error: The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file !
     122#endif
     123
     124#if !defined(GIET_ELF_BUFFER_SIZE)
     125# error: The GIET_ELF_BUFFER_SIZE value must be defined in the giet_config.h file !
    130126#endif
    131127
     
    134130// Both the page tables for the various virtual spaces, and the schedulers
    135131// for the processors are physically distributed on the clusters.
    136 // These global variables are just arrays of pointers.
    137132////////////////////////////////////////////////////////////////////////////
    138133
     
    140135extern fat32_fs_t fat;
    141136
    142 // Page tables base addresses, sizes, and PT2 allocators:
    143 // For each vspace, it can exist one page table per cluster,
    144 // but only one virtual base address per vspace
    145 
     137// Page tables virtual base addresses (one per vspace)
    146138__attribute__((section (".bootdata")))
    147139unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX];
    148140
     141// Page tables physical base addresses (one per vspace / one per cluster)
    149142__attribute__((section (".bootdata")))
    150143paddr_t _ptabs_paddr[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE];
    151144
     145// Page table max_pt2 (one per vspace / one per cluster )
    152146__attribute__((section (".bootdata")))
    153147unsigned int _ptabs_max_pt2[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE];
    154148
     149// Page tables pt2 allocators (one per vspace / one per cluster)
    155150__attribute__((section (".bootdata")))
    156151unsigned int _ptabs_next_pt2[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE];
     
    161156static_scheduler_t* _schedulers[1<<X_WIDTH][1<<Y_WIDTH][NB_PROCS_MAX];
    162157
     158// Temporaty buffer used to load one complete .elf file 
     159__attribute__((section (".bootdata")))
     160char boot_elf_buffer[GIET_ELF_BUFFER_SIZE] __attribute__((aligned(512)));
    163161
    164162/////////////////////////////////////////////////////////////////////
     
    19161914// clusters: same virtual address but different physical addresses. 
    19171915// - It open the file.
    1918 // - It loads the complete file in a dedicated buffer (seg_boot_buffer).
    1919 // - It copies each loadable segments  at the virtual address defined in the .elf
    1920 //   file, making several copies if the target vseg is not local.
     1916// - It loads the complete file in the dedicated boot_elf_buffer.
     1917// - It copies each loadable segments  at the virtual address defined in
     1918//   the .elf file, making several copies if the target vseg is not local.
    19211919// - It closes the file.
     1920// This function is supposed to be executed by processor[0,0,0].
    19221921// Note:
    1923 // - This function is supposed to be executed by processor[0,0,0].
    19241922//   We must use physical addresses to reach the destination buffers that
    19251923//   can be located in remote clusters. We use either a _physical_memcpy(),
    19261924//   or a _dma_physical_copy() if DMA is available.
    1927 //   The source seg_boot_buffer must be identity mapping.
    19281925//////////////////////////////////////////////////////////////////////////////////////
    19291926void load_one_elf_file( unsigned int is_kernel,     // kernel file if non zero
     
    19381935    unsigned int seg_id;
    19391936
    1940     // get boot buffer address and size
    1941     char*             boot_buffer      = (char*)SEG_BOOT_BUFFER_BASE;
    1942     unsigned int      boot_buffer_size = SEG_BOOT_BUFFER_SIZE;
    1943 
    19441937#if BOOT_DEBUG_ELF
    19451938_puts("\n[BOOT DEBUG] Start searching file ");
     
    19621955    }
    19631956
    1964     // check boot_buffer size versus file size
    1965     if ( fat.fd[fd_id].file_size > boot_buffer_size )
     1957    // check buffer size versus file size
     1958    if ( fat.fd[fd_id].file_size > GIET_ELF_BUFFER_SIZE )
    19661959    {
    19671960        _puts("\n[BOOT ERROR] load_one_elf_file() : ");
    19681961        _puts( pathname );
    1969         _puts(" exceeds the seg_boot_buffer size\n");
     1962        _puts(" exceeds the GIET_ELF_BUFFERSIZE defined in giet_config.h\n");
    19701963        _exit();
    19711964    }
     
    19761969    if( nbytes & 0x1FF) nsectors++;
    19771970
    1978     // load file in boot_buffer
     1971    // load file in elf buffer
    19791972    if( _fat_read( IOC_BOOT_MODE,
    19801973                   fd_id,
    1981                    boot_buffer,
     1974                   boot_elf_buffer,
    19821975                   nsectors,
    19831976                   0 ) != nsectors )
     
    19901983
    19911984    // Check ELF Magic Number in ELF header
    1992     Elf32_Ehdr* elf_header_ptr = (Elf32_Ehdr*)boot_buffer;
     1985    Elf32_Ehdr* elf_header_ptr = (Elf32_Ehdr*)boot_elf_buffer;
    19931986
    19941987    if ( (elf_header_ptr->e_ident[EI_MAG0] != ELFMAG0) ||
     
    20122005        _exit();
    20132006    }
    2014     Elf32_Phdr* elf_pht_ptr = (Elf32_Phdr*)(boot_buffer + pht_index);
     2007    Elf32_Phdr* elf_pht_ptr = (Elf32_Phdr*)(boot_elf_buffer + pht_index);
    20152008
    20162009    // get number of segments
     
    20502043                _puts(" in file ");
    20512044                _puts( pathname );
    2052                 _puts(" has a memsz < filesz \n");   
     2045                _puts(" has memsz < filesz \n");   
    20532046                _exit();
    20542047            }
     
    20582051            {
    20592052                unsigned int i;
    2060                 for( i = seg_filesz ; i < seg_memsz ; i++ ) boot_buffer[i+seg_offset] = 0;
     2053                for( i = seg_filesz ; i < seg_memsz ; i++ ) boot_elf_buffer[i+seg_offset] = 0;
    20612054            }
    20622055
    2063             unsigned int src_vaddr = (unsigned int)boot_buffer + seg_offset;
     2056            unsigned int src_vaddr = (unsigned int)boot_elf_buffer + seg_offset;
    20642057
    20652058            // search all vsegs matching the virtual address
Note: See TracChangeset for help on using the changeset viewer.