<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><span><h2 dir="ltr" style="font-weight:bold"><span style="font-size:19px;white-space:pre-wrap;font-family:Arial">This is introduction to my project high-level design , I would appreciate any feedback.</span></h2>
<h2 dir="ltr"><span><h2 dir="ltr" style="font-family:'Times New Roman';font-size:medium">
<span style="font-size:19px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap">Introduction to Arena :</span></h2><span style="font-size:15px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">The main problem we want to solve is how to make it easier for users to apply memory protection attributes in a flexible way. Developer who want to control this area of memory and apply/modify or even delete memory protection attributes should make use of libmmu [1] (the result of previous GSoC2009/2011 projects that provide memory protection through mmu). But developer has to know how to work with this API and some low-level knowledge about how the core implements memory protection. To satisfy the need for usable memory protection, I am introducing arenas, which control memory protection attributes of an area of memory. Arena only has the start address and size of an area of memory and needed memory protection attributes to be applied on this area. No libmmu or low-level knowledge is required by a developer who uses Arena to apply memory protection, only the memory area description and memory protection attributes.</span><br>
<span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">Arena could be created by a developer by passing the chunk of memory that needs to have memory protection attributes. Arena can support sharing if there is an area of memory that a developer wants to share between many tasks with the same access attributes (i.e code segment ). Arena could be defined as a construct which specifies memory attributes that could be shared among tasks. </span><br>
<span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">Arenas and tasks have a many-to-many symmetric relationship. All tasks having access to an Arena are "attached" to that Arena. Also a set of Arenas that a specific task has access to are said to be its "Attached Arenas". Context switch code deactivates all Arenas the current task is attached to, and activates the next task’s attached Arenas therefore the CS code needs a way to access all of the arenas attached to a given task. Representing attached Arenas for a task in a linked list/array to keep track of relationship between a task and its attached Arenas is useful so that a context switch code can know which Arenas to deactivate by just have a pointer to current task’s attached Arenas list in its TCB and walk through it to deactivate all the list. When Arena is deleted, all attached tasks TCBs must be updated by deleting this Arena from their lists. The process of updating TCBs could be done by representing attached tasks in a linked list of pointers to TCBs in the ACB, So when an Arena is deleted it traverses the list and updates each attached task’s TCB.</span><br>
<span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:16px;font-family:Arial;background-color:rgb(239,239,239);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">Further (optional) goal is to embed an allocator to an Arena which could be. Then an Arena could be used to allocate </span><span style="font-size:16px;font-family:Arial;background-color:rgb(243,243,243);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">memory from its pool, providing tasks a way to share and divide protected memory regions efficiently. Another further goal is to provide Posix mmap support and implementing it using arenas. Also i consider adding naming capability to an Arena.</span><br>
<span style="font-size:16px;font-family:Arial;background-color:rgb(243,243,243);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-weight:bold;font-size:15px;font-family:Arial;color:rgb(51,51,51);background-color:rgb(242,237,225);vertical-align:baseline;white-space:pre-wrap">[1] : </span><a href="http://code.google.com/p/gsoc2011-rtems-mmu-support-project/" style="font-family:'Times New Roman';font-size:medium;font-weight:bold" target="_blank"><span style="font-size:15px;font-family:Arial;color:rgb(17,85,204);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">http://code.google.com/p/gsoc2011-rtems-mmu-support-project/</span></a><span style="font-size:15px;font-family:Arial;color:rgb(51,51,51);background-color:rgb(242,237,225);vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:15px;font-family:Arial;color:rgb(51,51,51);background-color:rgb(242,237,225);vertical-align:baseline;white-space:pre-wrap"></span><br><h2 dir="ltr" style="font-family:'Times New Roman';font-size:medium;font-weight:bold">
<span style="font-size:19px;font-family:Arial;vertical-align:baseline;white-space:pre-wrap">Proposed Interfaces :</span></h2><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">struct Arena_Control {</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Objects_Control Object;</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* starting address of the arena’s memory pool */</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> void *start_address ;</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* size of the arena’s memory pool */</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> size_t size ;</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* memory attributes like w/r/x, cacheable */</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> uint32_t attributes;</span><font face="Arial"><span style="font-size:15px;font-weight:normal;white-space:pre-wrap">
</span></font><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* linked list of tasks that are attached to this arena. Points to</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> * an Arena_Per_task structure embedded in a Thread_Control. */</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Chain_Control attached_tasks;</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">}</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-weight:bold;font-size:15px;font-family:Arial;background-color:rgb(242,237,225);vertical-align:baseline;white-space:pre-wrap">// The TCB would have a pointer to an array of the following struct.</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">struct Arena_Per_task {</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* node of the task in attached_arena->attached_tasks list */</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Chain_Node node; </span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* pointer to a specific Arena which this task is attached to. */</span><br>
<span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Control *attached_arena;</span><br><span style="font-size:15px;font-family:Arial;background-color:rgb(242,237,225);font-weight:normal;vertical-align:baseline;white-space:pre-wrap">}</span><br>
<span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">struct Thread_Control {</span><br>
<span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> …</span><br><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> /* array of Arena_Per_task of fixed maximum size. NULL if arenas are not used. */</span><br>
<span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Per_task *attached_tasks;</span><br><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> …</span><br>
<span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">}</span><br><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Status _Arena_Initialize( ) ;</span><br>
<span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function will apply setup fields in Arena_Control and apply memory protection</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">attributes using libmmu API. Also initializing an empty list of attached_tasks. */</span><span style="font-size:15px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">Arena_Control* _Arena_Create(void* start_address , size_t size , uint32 attributes ) ;</span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> </span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function returns attributes of a given Arena */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> uint32_t _Arena_Get_attributes (Arena_Control*);</span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function returns the starting address of that Arena in memory</span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> void* _Arena_Get_start_address (Arena_Control* Arena) ;</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function returns the size of the Arena</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> size_t _Arena_Get_size (Arena_Control* Arena);</span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function update the current attributes for an Arena with new_attributes , could be used for deleting protection */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Status _Arena_Update_attributes(Arena_Control* , uint32_t new_attributes) ;</span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function create a link between an Arena and a task by adding a pointer to ACB in TCB’s attached arenas list and By adding a pointer to TCB in ACB by adding a pointer to attached task list */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Status _Arena_Attach(Arena_Control* , Thread_Control*</span><span style="font-size:13px;font-family:Arial;color:rgb(102,102,102);font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> </span><span style="vertical-align:baseline;font-size:15px;white-space:pre-wrap;font-family:Arial;font-weight:normal"> task</span><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">);</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function cut the link between a given Arena one of its attached tasks */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Status _Arena_Detach(Arena_Control* , Thread_Control* </span><span style="vertical-align:baseline;font-size:15px;white-space:pre-wrap;font-family:Arial;font-weight:normal">task);</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function mark an Arena as Deactivated when the current task use it and a context switch happens, so that the next task can not access this deactivated Arena. */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Status _Arena_Deactivate(Arena_Control*) ; </span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function mark an Arena as Activated when a context switch happens, and the next task is attached to that Arena */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"> Arena_Status _Arena_Activate(Arena_Control*); </span><br><span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap"></span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">/* This function delete the Arena and update the Arena list in every attached task TCB by deleting the ACB entry of the deleted Arena */</span><br>
<span style="font-size:13px;font-family:Arial;font-weight:normal;vertical-align:baseline;white-space:pre-wrap">Arena_Status _Arena_Delete(Arena_Control* );</span></span></h2></span></div>
</div><br></div>