static int allocate_memory(void ** virt_addr, unsigned long virt_base, unsigned long size_in_bytes, unsigned long flags) { int r; l4re_ds_t ds; /* Allocate a free capability index for our data space */ ds = l4re_util_cap_alloc(); if (l4_is_invalid_cap(ds)) return -L4_ENOMEM; /* Allocate memory via a dataspace */ if ((r = l4re_ma_alloc(size_in_bytes, ds, flags))) { printf("Memory allocation failed.\n"); return r; } /* Make the dataspace visible in our address space */ *virt_addr = (void *)virt_base; if ((r = l4re_rm_attach(virt_addr, size_in_bytes, L4RE_RM_SEARCH_ADDR, ds, 0, L4_PAGESHIFT))) { printf("Memory mapping failed.\n"); return r; } /* Done, virtual address is in virt_addr */ return 0; }
static void setup_memory(void) { int ret; l4_size_t phys_size; if (fb_vaddr) return; ret = l4io_request_iomem(0x48050000, 0x1000, 0, &omap_dss_virt_base); if (ret) { printf("[LCD] Error: Could not map device memory\n"); return; } // get some frame buffer l4re_ds_t mem = l4re_util_cap_alloc(); if (l4_is_invalid_cap(mem)) return; if (l4re_ma_alloc(fbmem_size(), mem, L4RE_MA_CONTINUOUS | L4RE_MA_PINNED)) { printf("[LCD] Error: Could not allocate memory\n"); return; } fb_vaddr = 0; if (l4re_rm_attach(&fb_vaddr, fbmem_size(), L4RE_RM_SEARCH_ADDR | L4RE_RM_EAGER_MAP, mem, 0, L4_PAGESHIFT)) { printf("[LCD] Error: Could not attach memory\n"); return; } printf("[LCD] Info: Video memory is at virtual %p (size: 0x%x Bytes)\n", fb_vaddr, fbmem_size()); // get physical address if (l4re_ds_phys(mem, 0, &fb_paddr, &phys_size) || phys_size != fbmem_size()) { printf("[LCD] Error: Could not get physical address\n"); return; } printf("[LCD] Info: Physical video memory is at %p\n", (void *)fb_paddr); }
static void setup_memory(void) { l4_size_t phys_size; l4io_device_handle_t dh; l4io_resource_handle_t hdl; if (fb_vaddr) return; if (l4io_lookup_device("System Control", &dh, 0, &hdl)) { printf("Could not get system controller space\n"); return; } /* System controller -- XXX Wrong Place XXX */ amba_pl110_sys_base_virt = l4io_request_resource_iomem(dh, &hdl); if (amba_pl110_sys_base_virt == 0) { printf("Could not map system controller space\n"); return; } if (l4io_lookup_device("AMBA PL110", &dh, 0, &hdl)) { printf("Could not get PL110 LCD device\n"); return; } amba_pl110_lcd_control_virt_base = l4io_request_resource_iomem(dh, &hdl); if (amba_pl110_lcd_control_virt_base == 0) { printf("Could not map controller space for '%s'\n", arm_lcd_get_info()); return; } setup_type(); if ((read_sys_reg(Reg_sys_clcd) & Sys_clcd_idmask) == 0x1000) { is_qemu = 1; // remember if we run on qemu because of the different // handling of the bpp16 mode with PL110: my hardware has // 5551 mode, qemu does 565 type = PL111; // also set the type to PL111 because qemu only // announces a PL110 but can do the 1024 resolution too printf("Running on QEmu (assuming PL111).\n"); } if (config_request_xga && type == PL111) use_xga = 1; // get some frame buffer l4re_ds_t mem = l4re_util_cap_alloc(); if (l4_is_invalid_cap(mem)) return; if (l4re_ma_alloc(fbmem_size(), mem, L4RE_MA_CONTINUOUS | L4RE_MA_PINNED)) { printf("Error allocating memory\n"); return; } fb_vaddr = 0; if (l4re_rm_attach(&fb_vaddr, fbmem_size(), L4RE_RM_SEARCH_ADDR | L4RE_RM_EAGER_MAP, mem, 0, L4_PAGESHIFT)) { printf("Error getting memory\n"); return; } printf("Video memory is at virtual %p (size: 0x%x Bytes)\n", fb_vaddr, fbmem_size()); // get physical address if (l4re_ds_phys(mem, 0, &fb_paddr, &phys_size) || phys_size != fbmem_size()) { printf("Getting the physical address failed or not contiguous\n"); return; } printf("Physical video memory is at %p\n", (void *)fb_paddr); }