OK, so in RTAI this code from src/shm.c:53

static inline void *_rt_shm_alloc(unsigned long name, int size, int suprt)
{
void *adr;

//suprt = USE_GFP_ATOMIC; // to force some testing
    if (!(adr = rt_get_adr_cnt(name)) && size > 0 && suprt >= 0 &&
RT_SHM_OP_PERM()) {
size = ((size - 1) & PAGE_MASK) + PAGE_SIZE;
if (adr = (suprt ? rkmalloc(&size, SUPRT[suprt]) : rvmalloc(size))) {
if (!rt_register(name, adr, suprt ? -size : size, 0)) {
if (suprt) {
                                        rkfree(adr, size);
                                } else {
                                        rvfree(adr, size);
                                }
return 0;
}
memset(ALIGN2PAGE(adr), 0, size);
}
}
    rt_printk("adr = %lx , ALIGN2PAGE(adr) = %lx\n", adr, ALIGN2PAGE(adr));
return ALIGN2PAGE(adr);
}

Prints:

[58253.421443] *adr = ffffc90000409000 , ALIGN2PAGE(adr) = ffffc90000409000*

And this, from LinuxCNC src/rtapi/rtapi_ulapi.c:101

int rtapi_init(const char *modname)
{
    int n, module_id;
    module_data *module;

    /* say hello */
    rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: initing module %s\n", modname);
    /* get shared memory block from OS and save its address */
    errno = 0;
    if(!rtapi_data){
        rtapi_print("!rtapi_data, initing\n");
        //rtapi_data = rtai_malloc(RTAPI_KEY, sizeof(rtapi_data_t));
        rtapi_data = (rtapi_data_t*)rt_shm_alloc(RTAPI_KEY,
sizeof(rtapi_data_t), USE_GFP_ATOMIC);
        rtapi_print("rtapi_data = %p\n", rtapi_data);
    }
    if (rtapi_data == NULL || rtapi_data == MAP_FAILED) {
        rtapi_print_msg(RTAPI_MSG_ERR,
            "RTAPI: ERROR: could not open shared memory (%s)\n",
            (rtapi_data == MAP_FAILED ? "map failed" : strerror(errno)));
        check_memlock_limit("could not open shared memory");
        rtapi_data = 0;
        return -ENOMEM;
    }
    nummods++;

prints:

!rtapi_data, initing
rtapi_data = 0xffffffffffffffff
RTAPI: ERROR: could not open shared memory (map failed)
HAL: ERROR: could not initialize RTAPI


So, somehow and somewhere the adr ( ffffc90000409000 ) is being returned to
rtapi_data as 0xffffffffffffffff

(the commented-out rtai_malloc is original LinuxCNC, I was trying to
takeout a layer of macros. Reverting that makes no difference, nor does
changing USE_GFP_ATOMIC to USE_VMALLOC which is the default)
https://www.rtai.org/userfiles/documentation/magma/html/api/group__shm.html#ga24


-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is designed
for the especial use of mechanical geniuses, daredevils and lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912

_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to