I have a question about capability.

1. I know that CNode can consist of hierarchy of CNodes like 1-level, 2-level, 3-level.

Can I create new CNode object like them?


2. If I can create hierarchy of CNode, I want to create hierarchy of CNode in order to retype new object to new CNode object.

I tried it like below source code but it doesn't work with message "Untyped Retype: Invalid destination address".

Would you give some advices?
--------------------- source code


   // ** create CNode & mapping

   seL4_CPtr new_CNode_cap = info->empty.start + 5;


   error = untyped_retype_root(untyped, seL4_CapTableObject, seL4_SlotBits, cspace_cap, new_CNode_cap);


   ZF_LOGF_IFERR(error, "Failed to retype our chosen untyped into an CNode object.\n");


   printf("================== seL4_DebugCapIdentify ======================\n");

   printf("seL4_DebugCapIdentify seL4_CPtr CNode_cap : %u \n", seL4_DebugCapIdentify(new_CNode_cap));


   // ** create new Endpoint object and mapping to new CNode

   seL4_CPtr new_CNode_cap_Endpoint;

   

   new_CNode_cap_Endpoint =  info->empty.start + 6;


   error = seL4_Untyped_Retype(untyped /* untyped cap */,

                       seL4_EndpointObject /* type */,

                       seL4_SlotBits /* size */,

                       new_CNode_cap /* root cnode cap */,

                       new_CNode_cap_Endpoint /* destination cspace */,

                       32 /* depth */,

                       new_CNode_cap_Endpoint /* offset */,

                       1 /* num objects */);


   if(error == 0)

       printf("error : %d \n", error);



3. Can I check CNode level? It means like CNode level number.