Changeset a73ebf0 in mainline


Ignore:
Timestamp:
2013-10-15T16:34:04Z (11 years ago)
Author:
Jakub Klama <jakub.klama@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4d2dba7
Parents:
1f12fab
Message:

Pass AMBA P&P devices and memory size info from loader to kernel
using bootinfo_t structure.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc32/include/ambapp.h

    r1f12fab ra73ebf0  
    127127} __attribute__((packed)) ambapp_entry_t;
    128128
     129typedef struct {
     130        unsigned int ram_read_ws: 1;
     131        unsigned int ram_write_ws: 1;
     132        unsigned int ram_width: 2;
     133        unsigned int rmw: 1;
     134        unsigned int rbrdy: 1;
     135        unsigned int : 1;
     136        unsigned int bank_size: 4;
     137        unsigned int si: 1;
     138        unsigned int se: 1;
     139        unsigned int : 1;
     140        unsigned int ms: 1;
     141        unsigned int : 1;
     142        unsigned int d64: 1;
     143        unsigned int sdram_cmd: 2;
     144        unsigned int sdram_colsz: 2;
     145        unsigned int sdram_banksz: 3;
     146        unsigned int tcas: 1;
     147        unsigned int trfc: 3;
     148        unsigned int trp: 1;
     149        unsigned int sdrf: 1;
     150} __attribute__((packed)) mctrl_mcfg2_t;
     151
    129152amba_device_t amba_devices[AMBAPP_MAX_DEVICES];
    130153int amba_devices_found;
     154bool amba_fake;
    131155uintptr_t amba_uart_base;
    132156
    133157void ambapp_scan(void);
     158bool ambapp_fake(void);
    134159void ambapp_qemu_fake_scan(void);
    135160void ambapp_print_devices(void);
  • boot/arch/sparc32/src/ambapp.c

    r1f12fab ra73ebf0  
    5454void ambapp_scan()
    5555{
     56        amba_fake = false;
     57
    5658        /* Scan for AHB masters & slaves */
    5759        ambapp_scan_area(AMBAPP_AHBMASTER_AREA, 64);
     
    6466
    6567        /* If we found nothing, fake device entries */
    66         ambapp_qemu_fake_scan();
     68        if (amba_devices_found == 0)
     69                ambapp_qemu_fake_scan();
    6770}
    6871
     
    8083                amba_device_t *device = &amba_devices[amba_devices_found];
    8184                device->vendor_id = (amba_vendor_id_t)entry->vendor_id;
    82                 device->device_id = (amba_device_id_t)entry->device_id;
     85        device->device_id = (amba_device_id_t)entry->device_id;
    8386                device->version = entry->version;
    8487                device->irq = entry->irq;
     
    121124        amba_devices[2].bars[0].size = 0x100;
    122125
     126        amba_fake = true;
    123127        amba_devices_found = 3;
     128}
     129
     130bool ambapp_fake()
     131{
     132        return amba_fake;
    124133}
    125134
     
    130139        for (int i = 0; i < amba_devices_found; i++) {
    131140                amba_device_t *dev = &amba_devices[i];
    132                 printf("<%1x:%03x> at 0x%08x, irq %d\n", dev->vendor_id, dev->device_id, dev->bars[0].start, dev->irq);
     141                printf("<%1x:%03x> at 0x%08x ", dev->vendor_id, dev->device_id, dev->bars[0].start);
     142                if (dev->irq == -1)
     143                        printf("\n");
     144                else
     145                        printf("irq %d\n", dev->irq);
    133146        }
    134147}
  • boot/arch/sparc32/src/main.c

    r1f12fab ra73ebf0  
    6262        amba_device_t *uart = ambapp_lookup_first(GAISLER, GAISLER_APBUART);
    6363        amba_uart_base = uart->bars[0].start;
     64        bootinfo.uart_base = amba_uart_base;
     65        bootinfo.uart_irq = uart->irq;
    6466
     67        /* Look up for IRQMP */
     68        amba_device_t *irqmp = ambapp_lookup_first(GAISLER, GAISLER_IRQMP);
     69        bootinfo.intc_base = irqmp->bars[0].start;
     70
     71        /* Look up for timer */
     72        amba_device_t *timer = ambapp_lookup_first(GAISLER, GAISLER_GPTIMER);
     73        bootinfo.timer_base = timer->bars[0].start;
     74        bootinfo.timer_irq = timer->irq;
     75       
     76        /* Lookp up for memory controller and obtain memory size */
     77        if (ambapp_fake()) {
     78                bootinfo.memsize = 64 * 1024 * 1024; // 64MB
     79        } else {
     80                amba_device_t *mctrl = ambapp_lookup_first(ESA, ESA_MCTRL);
     81                volatile mctrl_mcfg2_t *mcfg2 = (volatile mctrl_mcfg2_t *)(mctrl->bars[0].start + 0x4);
     82                bootinfo.memsize = (1 << (13 + mcfg2->bank_size));
     83        }
     84       
    6585        /* Standard output is now initialized */
    6686        version_print();
     
    7393
    7494        ambapp_print_devices();
     95
     96        printf("Memory size: %dMB\n", bootinfo.memsize >> 20);
    7597
    7698        mmu_init();
  • kernel/arch/sparc32/include/arch/arch.h

    r1f12fab ra73ebf0  
    6363        size_t cnt;
    6464        utask_t tasks[TASKMAP_MAX_RECORDS];
     65        /* Fields below are LEON-specific */
     66        uintptr_t uart_base;
     67        uintptr_t intc_base;
     68        uintptr_t timer_base;
     69        int uart_irq;
     70        int timer_irq;
     71        uint32_t memsize;
    6572} bootinfo_t;
    6673
Note: See TracChangeset for help on using the changeset viewer.