Ignore:
Timestamp:
Jul 12, 2017, 8:12:41 PM (7 years ago)
Author:
alain
Message:

Redefine the PIC device API.

File:
1 edited

Legend:

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

    r68 r188  
    394394    }
    395395
     396    ///////////////////////////////////////////////////
    396397    // loop on arch-info peripherals in io_cluster,
    397398    // to initialize the boot_info array of external peripherals
     
    399400#if DEBUG_BOOT_INFO
    400401boot_printf("\n[BOOT INFO] %s : external peripherals at cycle %d\n",
    401             __FUNCTION__ , cxy , boot_get_proctime() );
     402            __FUNCTION__ , boot_get_proctime() );
    402403#endif
    403404
     
    407408         device++ )
    408409    {
    409         // initialise one entry for each external peripheral
     410        if( device_id >= CONFIG_MAX_EXT_DEV )
     411        {
     412            boot_printf("\n[ERROR] in %s : too much external devices in arch_info\n",
     413                        __FUNCTION__ );
     414            boot_exit();
     415        }
     416       
     417        // keep only external devices
    410418        if( (device->type != DEV_TYPE_RAM_SCL) &&
    411419            (device->type != DEV_TYPE_ICU_XCU) &&
     
    433441        }
    434442   
    435         // Initialize array of irq descriptors for PIC
     443        // handle IRQs for PIC
    436444        if (device->type == DEV_TYPE_PIC_TSR)
    437445        {
    438             for (irq_id = 0; irq_id < CONFIG_MAX_IRQS_PER_PIC; irq_id++)
     446            for (irq_id = 0; irq_id < CONFIG_MAX_EXTERNAL_IRQS ; irq_id++)
    439447            {
    440448                boot_dev->irq[irq_id].valid  = 0;
     
    465473
    466474#if DEBUG_BOOT_INFO
    467 boot_printf("\n[BOOT INFO] %s : cores in cluster %x\n", __FUNCTION__ );
    468 #endif
    469 
     475boot_printf("\n[BOOT INFO] %s : cores in cluster %x\n", __FUNCTION__ , cxy );
     476#endif
     477
     478    ////////////////////////////////////////
    470479    // Initialize array of core descriptors
    471480    core_id = 0;
     
    488497    boot_info->cores_nr = core_id;
    489498
    490     // initialise internal devices (RAM, XCU, MMC, DMA)
    491     // set default values, then scan all local devices
     499    //////////////////////////////////////////////////////////////////////
     500    // initialise boot_info array of internal devices (RAM, ICU, MMC, DMA)
    492501
    493502#if DEBUG_BOOT_INFO
    494 boot_printf("\n[BOOT INFO] %s : internal peripherals in cluster %x\n", __FUNCTION__ );
    495 #endif
    496 
    497     boot_info->pages_nr         = 0;
    498     boot_info->dev_icu.channels = 0;
    499     boot_info->dev_mmc.channels = 0;
    500     boot_info->dev_dma.channels = 0;
    501 
     503boot_printf("\n[BOOT INFO] %s : internal peripherals in cluster %x\n", __FUNCTION__ , cxy );
     504#endif
     505
     506    device_id = 0;
    502507    for (device = &device_base[my_cluster->device_offset];
    503508         device < &device_base[my_cluster->device_offset + my_cluster->devices];
    504509         device++ )
    505510    {
    506         if (device->type == DEV_TYPE_RAM_SCL)
     511        // keep only internal devices
     512        if( (device->type == DEV_TYPE_RAM_SCL) ||
     513            (device->type == DEV_TYPE_ICU_XCU) ||
     514            (device->type == DEV_TYPE_MMC_TSR) ||
     515            (device->type == DEV_TYPE_DMA_SCL) )
    507516        {
    508             // set number of physical memory pages
    509             boot_info->pages_nr   = device->size >> CONFIG_PPM_PAGE_SHIFT;
     517            if (device->type == DEV_TYPE_RAM_SCL)   // RAM
     518            {
     519                // set number of physical memory pages
     520                boot_info->pages_nr   = device->size >> CONFIG_PPM_PAGE_SHIFT;
    510521
    511522#if DEBUG_BOOT_INFO
    512523boot_printf("  - RAM : %x pages\n", boot_info->pages_nr );
    513524#endif
    514         }
    515         else if (device->type == DEV_TYPE_ICU_XCU)
    516         {
    517             boot_dev = &boot_info->dev_icu;
    518 
    519             boot_dev->type     = device->type;
    520             boot_dev->base     = device->base;
    521             boot_dev->channels = device->channels;
    522             boot_dev->param0   = device->arg0;   
    523             boot_dev->param1   = device->arg1;   
    524             boot_dev->param2   = device->arg2;   
    525             boot_dev->param3   = device->arg3;   
    526             boot_dev->irqs     = device->irqs;
     525            }
     526            else                                    // ICU / MMC / DMA
     527            {
     528                if( device_id >= CONFIG_MAX_INT_DEV )
     529                {
     530                    boot_printf("\n[ERROR] in %s : too much internal devices in cluster %x\n",
     531                                __FUNCTION__ , cxy );
     532                    boot_exit();
     533                }
     534       
     535                boot_dev = &boot_info->int_dev[device_id];
     536
     537                boot_dev->type     = device->type;
     538                boot_dev->base     = device->base;
     539                boot_dev->channels = device->channels;
     540                boot_dev->param0   = device->arg0;   
     541                boot_dev->param1   = device->arg1;   
     542                boot_dev->param2   = device->arg2;   
     543                boot_dev->param3   = device->arg3;   
     544                boot_dev->irqs     = device->irqs;
     545
     546                device_id++;
    527547
    528548#if DEBUG_BOOT_INFO
    529 boot_printf("  - XCU : base = %l / size = %l / channels = %d / irqs = %d\n",
    530             device->base , device->size , device->channels , device->irqs );   
    531 #endif
    532 
    533             for (irq_id = 0; irq_id < CONFIG_MAX_HWIS_PER_ICU; irq_id++)
    534             {
    535                 boot_dev->irq[irq_id].valid  = 0;
    536             }
    537 
    538             for (irq = &irq_base[device->irq_offset];
    539                  irq < &irq_base[device->irq_offset + device->irqs];
    540                  irq++)
    541             {
    542                 boot_dev->irq[irq->port].valid    = 1;
    543                 boot_dev->irq[irq->port].dev_type = irq->dev_type;
    544                 boot_dev->irq[irq->port].channel  = irq->channel;
    545                 boot_dev->irq[irq->port].is_rx    = irq->is_rx;
     549boot_printf("  - %s : base = %l / size = %l / channels = %d / irqs = %d\n",
     550            device_type_str( device->type ) , device->base , device->size ,
     551            device->channels , device->irqs );   
     552#endif
     553
     554                // handle IRQs for ICU
     555                if (device->type == DEV_TYPE_ICU_XCU)
     556                {
     557                    for (irq_id = 0; irq_id < CONFIG_MAX_INTERNAL_IRQS ; irq_id++)
     558                    {
     559                        boot_dev->irq[irq_id].valid  = 0;
     560                    }
     561
     562                    for (irq = &irq_base[device->irq_offset];
     563                         irq < &irq_base[device->irq_offset + device->irqs] ; irq++)
     564                    {
     565                        boot_dev->irq[irq->port].valid    = 1;
     566                        boot_dev->irq[irq->port].dev_type = irq->dev_type;
     567                        boot_dev->irq[irq->port].channel  = irq->channel;
     568                        boot_dev->irq[irq->port].is_rx    = irq->is_rx;
    546569
    547570#if DEBUG_BOOT_INFO
     
    550573#endif
    551574
     575                    }
     576                }
    552577            }
    553578        }
    554         else if( device->type == DEV_TYPE_MMC_TSR )
    555         {
    556             boot_dev = &boot_info->dev_mmc;
    557 
    558             boot_dev->type     = device->type;
    559             boot_dev->base     = device->base;
    560             boot_dev->channels = device->channels;
    561             boot_dev->irqs     = 0;
    562 
    563 #if DEBUG_BOOT_INFO
    564 boot_printf("  - MMC : base = %l / size = %l / channels = %d / irqs = %d\n",
    565             device->base , device->size , device->channels , device->irqs );   
    566 #endif
    567         }
    568         else if( device->type == DEV_TYPE_DMA_SCL )
    569         {           
    570             boot_dev = &boot_info->dev_dma;
    571 
    572             boot_dev->type     = device->type;
    573             boot_dev->base     = device->base;
    574             boot_dev->channels = device->channels;
    575             boot_dev->irqs     = 0;
    576 
    577 #if DEBUG_BOOT_INFO
    578 boot_printf("  - DMA : base = %l / size = %l / channels = %d / irqs = %d\n",
    579             device->base , device->size , device->channels , device->irqs );   
    580 #endif
    581         }
    582579    }  // end loop on local peripherals
    583580
    584     // Get the top address of the kernel segments
     581    // initialize number of external peripherals
     582    boot_info->int_dev_nr = device_id;
     583
     584   // Get the top address of the kernel segments
    585585    end = (boot_info->kernel_code_end > boot_info->kernel_data_end ) ?
    586586          boot_info->kernel_code_end : boot_info->kernel_data_end;
     
    592592    // No "reserved zones" for the TSAR architecture
    593593    boot_info->rsvd_nr = 0;
    594 
    595 #if DEBUG_BOOT_INFO
    596 boot_printf("\n[BOOT INFO] %s : Kernel Reserved Zone / base = 0 / npages = %d at cycle %d\n",
    597             __FUNCTION__ , rsvd_pages ,boot_get_proctime() );
    598 #endif
    599594
    600595    // set boot_info signature
     
    690685
    691686/*********************************************************************************
    692  * This function is called by all CP0 to activate all local CPi cores.
    693  * @ boot_info  : pointer to local 'boot_info_t' structure, used to find
    694  *                the XICU device associated with local CPi base addresses.
     687 * This function is called by all CP0 to activate the other CPi cores.
     688 * @ boot_info  : pointer to local 'boot_info_t' structure.
    695689 *********************************************************************************/
    696690static void boot_wake_local_cores(boot_info_t * boot_info)
    697691{
    698     boot_device_t *  device;         // Iterator on devices
    699     unsigned int     core_id;        // Iterator on cores
    700 
    701     device = &boot_info->dev_icu;
     692    unsigned int     core_id;       
     693
     694    // get pointer on XCU device descriptor in boot_info
     695    boot_device_t *  xcu = &boot_info->int_dev[0];
    702696 
    703697    // loop on cores
     
    709703             boot_info->cxy , core_id , boot_get_proctime() );
    710704#endif
    711         boot_remote_sw( (xptr_t)(device->base + (core_id << 2)) , (uint32_t)boot_entry );
     705        // send an IPI
     706        boot_remote_sw( (xptr_t)(xcu->base + (core_id << 2)) , (uint32_t)boot_entry );
    712707    }
    713708} // boot_wake_local_cores()
Note: See TracChangeset for help on using the changeset viewer.