Howto map a page using okl4 library?

1 message Options
Embed this post
Permalink
Gabi Voiculescu

Howto map a page using okl4 library?

Reply Threaded More More options
Print post
Permalink
Hi.

I want to map a certain 4k SFR into virtual memory of a v2 driver in order to have access to the arm Interrupt Controller SFRs.

I (think I) found the instructions to create a memory section, associate it with the SFR, and to map it but I get:
  • OKL4_INVALID_ARGUMENT from the _okl4_kspace_mapbyid(), and
  • EINVALID_PARAM from L4_ErrorCode().

Can anybody help me with the clist instructions I am missing to get the necessary privilege for the space the v2 driver is in and for performing the mapping within the space? I have trouble figuring it out from the okl4 library documentation.

Thank you,
Gabi Voiculescu

PS: Using l4/l4e to emulate the old iguana hardware_back_memsection I raeched the same L4_ErrorCode = EINVALID_PARAM.


The new okl4 3. code that fails to map:
---------------------------
    struct okl4_memsec *ms;
    struct okl4_kspace *kspace;
    word_t error;
    okl4_physmem_item_t phys;
...
    okl4_init_thread();
...
    kspace = okl4_env_get("MAIN_KSPACE");
    assert(kspace !=NULL);
...
    /* Perform the mapping in main KSPACE. FIXME: is this the same as current KSPACE for v2 serial driver? Okl4 Doc says Main kspace is the default space in each cell, and v2 driver ??? */
    okl4_kspace_map_attr_t kattr;
        okl4_range_item_setrange(&phys.range, 0x10000000, phys.range.size);
        okl4_kspace_map_attr_init(&kattr);
        okl4_kspace_map_attr_setperms(&kattr, /*perms*/ L4_Readable | L4_Writable);
        okl4_kspace_map_attr_setattributes(&kattr, /*attributes*/ L4_UncachedMemory);
        okl4_kspace_map_attr_setpagesize(&kattr, /*ms->page_size*/ 0x1000);
        okl4_kspace_map_attr_settarget(&kattr, &phys);
        okl4_kspace_map_attr_setrange(&kattr, &phys.range);
//        error = okl4_kspace_map(kspace, &kattr);
        printf("kattr->range->size=%lx, kattr->page_size=%lx\n", kattr.range->size, kattr.page_size);
        error = _okl4_kspace_mapbyid(okl4_kspace_getid(okl4_env_get("MAIN_KSPACE")), &kattr);
 printf("mapping resulted in %d %ld",error, L4_ErrorCode());



Old okl4 2.1 code that used iguana (which is unusable without much effort in changing ktest build scripts to build the iguana library):
---------------------------
    memsection_ref_t ms;
    int r;

    /*
     * Map in the SYS_REGS
     */
    ms = memsection_create_user(0x1000, &USER_SYSREGS_VADDR);
 
    dprintf("%s %s: memsection for SYSREGS vbase=%p size=0x%lx\n",
                  string, __func__, memsection_base(ms), memsection_size(ms) );

    if (ms == 0){
        printf("%s %s: Error creating memsection for SYS_REGS\n",string, __func__);
        return 0;
    }
   
    r = hardware_back_memsection(ms, 0x10000000, /*L4_IOMemory*/ L4_UncachedMemory);




_______________________________________________
Developer mailing list
[hidden email]
https://lists.okl4.org/mailman/listinfo/developer