Ignore:
Timestamp:
Jul 16, 2012, 10:26:27 AM (12 years ago)
Author:
alain
Message:

Fix several bugs to use the vci_block_device with MMU activated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/sys/kernel_init.c

    r166 r167  
    3131 
    3232///////////////////////////////////////////////////////////////////////////////////
     33// array of pointers on the page tables
     34// (both physical and virtual addresses)
     35///////////////////////////////////////////////////////////////////////////////////
     36
     37__attribute__((section (".kdata"))) unsigned int _kernel_ptabs_paddr[GIET_NB_VSPACE_MAX];
     38__attribute__((section (".kdata"))) unsigned int _kernel_ptabs_vaddr[GIET_NB_VSPACE_MAX];
     39
     40///////////////////////////////////////////////////////////////////////////////////
    3341// declarations required to avoid forward references
    3442///////////////////////////////////////////////////////////////////////////////////
    3543
    36 void    _kernel_vobjs_init(unsigned int*);
    37 void    _kernel_tasks_init(unsigned int*);
     44void    _kernel_vobjs_init(void);
     45void    _kernel_tasks_init(void);
    3846void    _kernel_peripherals_init(void);
    3947void    _kernel_interrupt_vector_init(void);
     
    4553in_kinit void _kernel_init()
    4654{
    47     // array of pointers on the page tables (used for task context initialisation)
    48     unsigned int        kernel_ptabs[GIET_NB_VSPACE_MAX];
    49 
    5055    // values to be written in registers
    5156    unsigned int        sp_value;
     
    5964    if ( pid == 0 )
    6065    {
    61         _kernel_vobjs_init(kernel_ptabs);
    62         _kernel_tasks_init(kernel_ptabs);
     66        _kernel_vobjs_init();
     67        _kernel_tasks_init();
    6368        _kernel_interrupt_vector_init();
    6469        _kernel_peripherals_init();
     
    163168// - ptpr   page table base address / 8K
    164169// - mode   mmu_mode = 0xF (TLBs and caches activated)
     170// - ptab   page table virtual address
    165171////////////////////////////////////////////////////////////////////////////////
    166172in_kinit void _task_map( unsigned int   task_id,    // global index
    167173                                         unsigned int   vspace_id,  // global index
    168174                         unsigned int   tty_id,         // TTY index
    169                          unsigned int   fb_id,          // FB index
    170                          unsigned int   pt_base )   // page table base adddress
     175                         unsigned int   fbdma_id )  // FBDMA index
    171176{
    172177    mapping_header_t*   header = (mapping_header_t*)&seg_mapping_base; 
     
    176181    mapping_vobj_t*     vobj   = _get_vobj_base( header );
    177182
     183   
    178184    // values to be initialised in task context
    179     unsigned int                ra = (unsigned int)&_eret;
     185    unsigned int                ra   = (unsigned int)&_eret;
    180186    unsigned int                sr   = 0x0000FF13;
    181187    unsigned int                tty  = tty_id;
    182     unsigned int                fb   = fb_id;   
    183     unsigned int                ptpr = pt_base >> 13;
     188    unsigned int                fb   = fbdma_id;         
     189    unsigned int                ptpr = _kernel_ptabs_paddr[vspace_id] >> 13;
     190    unsigned int                ptab = _kernel_ptabs_vaddr[vspace_id];
    184191    unsigned int                mode = 0xF;
    185192    unsigned int                sp;
    186193    unsigned int                epc;     
    187194
    188     // compute epc value
    189     // Get the (virtual) base address of the start_vector that
    190     // contains the start addresses for all tasks defined in a vspace.
     195    // EPC : Get the (virtual) base address of the start_vector containing
     196    // the start addresses for all tasks defined in a vspace.
    191197    mapping_vobj_t* vobj_data = &vobj[vspace[vspace_id].vobj_offset +
    192198                                      vspace[vspace_id].start_offset];
     
    194200    epc  = start_vector[task[task_id].startid];
    195201
    196     // compute sp value
    197     // Get the vobj containing the stack
     202    // SP :  Get the vobj containing the stack
    198203    unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset;
    199204    sp = vobj[vobj_id].vaddr + vobj[vobj_id].length;
     
    220225    _scheduler[proc_id].context[ltid][CTX_RA_ID]    = ra;
    221226    _scheduler[proc_id].context[ltid][CTX_EPC_ID]   = epc;
     227    _scheduler[proc_id].context[ltid][CTX_PTPR_ID]  = ptpr;
     228    _scheduler[proc_id].context[ltid][CTX_MODE_ID]  = mode;
    222229    _scheduler[proc_id].context[ltid][CTX_TTY_ID]   = tty;
    223230        _scheduler[proc_id].context[ltid][CTX_FBDMA_ID] = fb;
    224     _scheduler[proc_id].context[ltid][CTX_PTPR_ID]  = ptpr;
    225     _scheduler[proc_id].context[ltid][CTX_MODE_ID]  = mode;
     231    _scheduler[proc_id].context[ltid][CTX_PTAB_ID]  = ptab;
    226232    _scheduler[proc_id].context[ltid][CTX_TASK_ID]  = task_id;
    227233   
    228 #if INIT_DEBUG
     234#if INIT_DEBUG_CTX
    229235_puts("Task ");
    230236_puts( task[task_id].name );
     
    259265_puts("\n");
    260266
     267_puts("  - PTPR        = ");
     268_putw( ptpr<<13 );
     269_puts("  saved at ");
     270_putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTPR_ID] );
     271_puts("\n");
     272
    261273_puts("  - TTY         = ");
    262274_putw( tty );
     
    271283_puts("\n");
    272284
    273 _puts("  - PTPR        = ");
    274 _putw( ptpr<<13 );
    275 _puts("  saved at ");
    276 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTPR_ID] );
     285_puts("  - PTAB        = ");
     286_putw( ptab );
     287_puts("  saved at ");
     288_putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTAB_ID] );
    277289_puts("\n");
    278290#endif
     
    284296// such as mwmr channels, barriers and locks, depending on the vobj type.
    285297// (Most of the vobjs are not known, and not initialised by the compiler).
    286 // This function initialises the kernel_ptabs[] array indexed by the vspace_id,
    287 // and containint the base addresses of all page tables.
    288 // This kernel_ptabs[] array is used to initialise the task contexts.
     298// This function initialises the _kernel_ptabs_paddr[] array indexed by the vspace_id,
     299// and containing the base addresses of all page tables.
     300// This _kernel_ptabs_paddr[] array is used to initialise the task contexts.
    289301///////////////////////////////////////////////////////////////////////////////
    290 in_kinit void _kernel_vobjs_init( unsigned int* kernel_ptabs )
     302in_kinit void _kernel_vobjs_init()
    291303{
    292304    mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
     
    302314        char ptab_found = 0;
    303315
    304 #if INIT_DEBUG
     316#if INIT_DEBUG_CTX
    305317_puts("[INIT] --- vobjs initialisation in vspace ");
    306318_puts(vspace[vspace_id].name);
     
    317329                {
    318330                    ptab_found = 1;
    319                     kernel_ptabs[vspace_id] = vobj[vobj_id].paddr;
    320 
    321 #if INIT_DEBUG
     331                    _kernel_ptabs_paddr[vspace_id] = vobj[vobj_id].paddr;
     332                    _kernel_ptabs_vaddr[vspace_id] = vobj[vobj_id].vaddr;
     333
     334#if INIT_DEBUG_CTX
    322335_puts("[INIT]   PTAB address = ");
    323 _putw(kernel_ptabs[vspace_id]);
     336_putw(_kernel_ptabs_paddr[vspace_id]);
    324337_puts("\n");
    325338#endif
     
    334347                    mwmr->depth = (vobj[vobj_id].length>>2) - 5;
    335348                    mwmr->lock  = 0;
    336 #if INIT_DEBUG
     349#if INIT_DEBUG_CTX
    337350_puts("[INIT]   MWMR channel ");
    338351_puts( vobj->name);
     
    346359                {
    347360
    348 #if INIT_DEBUG
     361#if INIT_DEBUG_CTX
    349362_puts("[INIT]   ELF section ");
    350363_puts( vobj->name);
     
    360373                    barrier->count = 0;
    361374                    barrier->init  = vobj[vobj_id].init;
    362 #if INIT_DEBUG
     375#if INIT_DEBUG_CTX
    363376_puts("   BARRIER ");
    364377_puts( vobj->name);
     
    373386                    unsigned int* lock = (unsigned int*)(vobj[vobj_id].vaddr);
    374387                    *lock = 0;
    375 #if INIT_DEBUG
     388#if INIT_DEBUG_CTX
    376389_puts("   LOCK ");
    377390_puts( vobj->name);
     
    383396                {
    384397
    385 #if INIT_DEBUG
     398#if INIT_DEBUG_CTX
    386399_puts("   BUFFER ");
    387400_puts( vobj->name);
     
    425438// TTY[0] is reserved for the kernel.
    426439///////////////////////////////////////////////////////////////////////////////
    427 in_kinit void _kernel_tasks_init(unsigned int* ptabs)
     440in_kinit void _kernel_tasks_init()
    428441{
    429442    mapping_header_t*   header  = (mapping_header_t*)&seg_mapping_base; 
     
    461474    {
    462475
    463 #if INIT_DEBUG
     476#if INIT_DEBUG_CTX
    464477_puts("\n[INIT] mapping tasks in vspace ");
    465478_puts(vspace[vspace_id].name);
     
    486499                       vspace_id,                       // vspace index
    487500                       tty_id,                          // global tty index
    488                        fb_id,                           // global fbdma index
    489                        ptabs[vspace_id] );      // page table pointer
     501                       fb_id );                         // global fbdma index
    490502        } // end loop on tasks
    491503    } // end oop on vspaces
     
    495507    _puts("\n");
    496508
    497 #if INIT_DEBUG
     509#if INIT_DEBUG_CTX
    498510for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    499511{
     
    540552    {
    541553        unsigned int*   iob_address = (unsigned int*)&seg_iob_base;
    542         unsigned int    icu_address = (unsigned int)&seg_icu_base;
    543554
    544555        // define IPI address mapping the IOC interrupt ...TODO...
Note: See TracChangeset for help on using the changeset viewer.