Ignore:
Timestamp:
Jul 25, 2012, 10:31:13 AM (12 years ago)
Author:
karaoui
Message:

removing the parametre variable PTE2_MAX from giet_config.
Now we compute dynamically the second table size from the length of the vobj.

File:
1 edited

Legend:

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

    r169 r180  
    3131// As most applications use only a limited number of segments, the number of PT2s
    3232// actually used by a given virtual space is generally smaller than 2048, and is
    33 // defined by the (GIET_NB_PT2_MAX) configuration parameter.
    34 // The max number of virtual spaces (GIET_NB_VSPACE_MAX) is a configuration parameter.
     33// computed using the length of the vobj and stored in the _max_pte2 global variable,
     34// which is table indexed by the vspace_id.
    3535//
    3636// Each page table (one page table per virtual space) is monolithic, and
    37 // contains one PT1 and (GIET_NB_PT2_MAX) PT2s. The PT1 is addressed using the ix1 field
    38 // (11 bits) of the VPN, and the selected PT2 is addressed using the ix2 field (9 bits).
     37// contains one PT1 and ((vobj.length - PT1_SIZE) / PT2_SIZE ) PT2s.
     38// The PT1 is addressed using the ix1 field (11 bits) of the VPN, and
     39// the selected PT2 is addressed using the ix2 field (9 bits).
    3940// - PT1[2048] : a first 8K aligned array of unsigned int, indexed by the (ix1) field of VPN.
    4041//   Each entry in the PT1 contains a 32 bits PTD. The MSB bit PTD[31] is
     
    4243//   address of the selected PT2.
    4344//   The PT1 contains 2048 PTD of 4 bytes => 8K bytes.
    44 // - PT2[1024][GIET_NB_PT2_MAX] : an array of array of unsigned int.
     45// - PT2[_max_pte2[vspace_id]][1024]: an array of array of unsigned int.
    4546//   Each PT2[1024] must be 4K aligned,  and each entry in a PT2 contains two unsigned int:
    4647//   the first word contains the protection flags, and the second word contains the PPN.
     
    6162#endif
    6263
    63 #if !defined(GIET_NB_PT2_MAX)
    64 # error The GIET_NB_PT2_MAX value must be defined in the 'giet_config.h' file !
    65 #endif
    66 
    6764////////////////////////////////////////////////////////////////////////////
    6865//  Page Tables global variables
     
    7168// Next free PT2 index array
    7269unsigned int  _next_free_pt2[GIET_NB_VSPACE_MAX] =
     70                         { [0 ... GIET_NB_VSPACE_MAX-1] = 0 };
     71
     72// Max PT2 index
     73unsigned int  _max_pte2[GIET_NB_VSPACE_MAX] =
    7374                         { [0 ... GIET_NB_VSPACE_MAX-1] = 0 };
    7475
     
    458459    ix2 = vpn  & 0x1FF;         //  9 bits
    459460
     461    // since the max_pte2 has to be > 1, we check that he have been set
     462    // otherwise it means tha the ptabs has not been set
     463    unsigned int max_pte2   = _max_pte2[vspace_id];
     464    if(max_pte2 == 0)
     465    {
     466        boot_puts("Unfound page table for vspace ");
     467        boot_putw(vspace_id);
     468        boot_puts("\n");
     469        boot_exit();
     470    }
     471
    460472    page_table_t* pt = (page_table_t *)_ptabs[vspace_id];
    461473    if ( (pt->pt1[ix1] & PTE_V) == 0 )   // set a new PTD in PT1
    462474    {
    463475        pt2_id = _next_free_pt2[vspace_id];
    464         if ( pt2_id == GIET_NB_PT2_MAX )
     476        if ( pt2_id == max_pte2 )
    465477        {
    466478            boot_puts("\n[BOOT ERROR] in boot_add_pte() function\n");
     
    665677        if ( vobj[vobj_id].type == VOBJ_TYPE_PTAB )
    666678        {
    667             if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE*GIET_NB_PT2_MAX) )
    668             {
    669                 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function: " );
    670                 boot_puts("PTAB vobj is too small in vspace ");
    671                 boot_putw(vspace_id);
    672                 boot_puts("\n");
    673                 boot_exit();
    674             }
     679
    675680            if(vspace_id == ((unsigned int) -1))    // global vseg
    676681            {
     
    679684                boot_exit();
    680685            }
    681             _ptabs[vspace_id] = (page_table_t*)vobj[vobj_id].paddr;
     686
     687            if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE) ) //at least one pte2 => ( max_pte2 >= 1)
     688            {
     689                boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function, " );
     690                boot_puts("PTAB too small, minumum size is: ");
     691                boot_putw( PT1_SIZE + PT2_SIZE);
     692                boot_exit();
     693            }
     694
     695            /* getting the physical address of the ptab */
     696            _ptabs[vspace_id]        = (page_table_t*) vobj[vobj_id].paddr;
     697            /* computing the number of second level page */
     698            _max_pte2[vspace_id]    = (vobj[vobj_id].length - PT1_SIZE) / PT2_SIZE;
    682699        }
    683700    } // end for vobjs
     
    849866boot_puts("\n>>> page table physical address = ");
    850867boot_putw((unsigned int)_ptabs[vspace_id]);
     868boot_puts(", page table max_pte2 = ");
     869boot_putw((unsigned int)_max_pte2[vspace_id]);
    851870boot_puts("\n");
    852871#endif
Note: See TracChangeset for help on using the changeset viewer.