Subversion Repositories HelenOS

Rev

Rev 3004 | Rev 3101 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3004 Rev 3010
Line 284... Line 284...
284
int load_segment(elf_ld_t *elf, elf_segment_header_t *entry)
284
int load_segment(elf_ld_t *elf, elf_segment_header_t *entry)
285
{
285
{
286
    void *a;
286
    void *a;
287
    int flags = 0;
287
    int flags = 0;
288
    uintptr_t bias;
288
    uintptr_t bias;
-
 
289
    uintptr_t base;
-
 
290
    size_t mem_sz;
289
    int rc;
291
    int rc;
290
 
292
 
291
    printf("load segment at addr 0x%x, size 0x%x\n", entry->p_vaddr,
293
    printf("load segment at addr 0x%x, size 0x%x\n", entry->p_vaddr,
292
        entry->p_memsz);
294
        entry->p_memsz);
293
   
295
   
Line 311... Line 313...
311
    if (entry->p_flags & PF_W)
313
    if (entry->p_flags & PF_W)
312
        flags |= AS_AREA_WRITE;
314
        flags |= AS_AREA_WRITE;
313
    if (entry->p_flags & PF_R)
315
    if (entry->p_flags & PF_R)
314
        flags |= AS_AREA_READ;
316
        flags |= AS_AREA_READ;
315
    flags |= AS_AREA_CACHEABLE;
317
    flags |= AS_AREA_CACHEABLE;
316
 
-
 
317
    /*
-
 
318
     * Check if the virtual address starts on page boundary.
-
 
319
     */
-
 
320
    if (ALIGN_UP(entry->p_vaddr, PAGE_SIZE) != entry->p_vaddr) {
-
 
321
        printf("align check 2 failed - not page-aligned\n");
-
 
322
        printf("vaddr = 0x%x, should be 0x%x\n",
-
 
323
            entry->p_vaddr, ALIGN_UP(entry->p_vaddr, PAGE_SIZE));
-
 
324
        return EE_UNSUPPORTED;
-
 
325
    }
-
 
326
   
318
   
-
 
319
    base = ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE);
-
 
320
    mem_sz = entry->p_memsz + (entry->p_vaddr - base);
-
 
321
 
327
    printf("map to p_vaddr=0x%x-0x%x...\n", entry->p_vaddr + bias,
322
    printf("map to p_vaddr=0x%x-0x%x...\n", entry->p_vaddr + bias,
328
    entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
323
    entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
329
 
324
 
330
    /*
325
    /*
331
     * For the course of loading, the area needs to be readable
326
     * For the course of loading, the area needs to be readable
332
     * and writeable.
327
     * and writeable.
333
     */
328
     */
334
    a = as_area_create((uint8_t *)entry->p_vaddr + bias,
329
    a = as_area_create((uint8_t *)base + bias,
335
        entry->p_memsz, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
330
        mem_sz, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
336
    if (a == (void *)(-1)) {
331
    if (a == (void *)(-1)) {
337
        printf("memory mapping failed\n");
332
        printf("memory mapping failed\n");
338
        return EE_MEMORY;
333
        return EE_MEMORY;
339
    }
334
    }
340
 
335