On Fri, Mar 17, 2017 at 1:02 PM, Liviu Ionescu <[email protected]> wrote:

>
>
> my plan is to use rom, not ram, which usually is not as limited, so a few
> tens of bytes used for the metadata would be perfectly acceptable.
>
> the current metadata looks like this:
>
> const __attribute__ ((section(".drtm")))
> struct os::rtos::port::drtm_s os_rtos_drtm =
>   {
>       { 'D', 'R', 'T', 'M'},
>       { 'v', OS_RTOS_DRTM_VERSION_MAJOR, OS_RTOS_DRTM_VERSION_MINOR,
>         OS_RTOS_DRTM_VERSION_PATCH}, /**/
>
>     &os::rtos::scheduler::is_started_, /**/
>     &os::rtos::scheduler::top_threads_list_, /**/
>     &os::rtos::scheduler::current_thread_, /**/
>
>     offsetof(os::rtos::thread, name_),
>     offsetof(os::rtos::thread, parent_), /**/
>     offsetof(os::rtos::thread, child_links_), /**/
>     offsetof(os::rtos::thread, children_), /**/
>     offsetof(os::rtos::thread, state_), /**/
>     offsetof(os::rtos::thread, context_.port_.stack_ptr),  /**/
>     offsetof(os::rtos::thread, prio_assigned_),  /**/
>     offsetof(os::rtos::thread, prio_inherited_)
>   };
>
> that's not such a big deal.
>

Just a tip, another even better option is to not use any target memory at
all. This is mostly not required because OpenOCD has access, via GDB, to
all the symbols in the debugged binary. So you can declare symbols with the
necessary values instead of placing them into a structure in RAM or Flash.
This method is also more efficient because we don't have to access the
target to find out the static offsets into the OS data structures.

I've implemented RTOS support for another kernel exactly this way, by
simply adding the following chunk to any suitable c-file which is linked
with the kernel. In OpenOCD RTOS layer the value of the symbol
(e.g. __off_task2stack) is the actual offset value, not the target address
of a location where the offset value can be read.

#define DECLARE_SYMBOL(name, value) __asm__ (".global "#name"\n.set
"#name",%c0\n" :: "i"((unsigned long)(value)))

void __debug_info(void)
{
   DECLARE_SYMBOL(__off_os_state2chain, offsetof(os_state_t, chain));
   DECLARE_SYMBOL(__off_os_state2current, offsetof(os_state_t,
current_task));
   DECLARE_SYMBOL(__off_task2chain, offsetof(task_t, chain));
   DECLARE_SYMBOL(__off_task2magic, offsetof(task_t, magic));
   DECLARE_SYMBOL(__off_task2stack, offsetof(task_t, stack_ptr));
   DECLARE_SYMBOL(__off_task2state, offsetof(task_t, state));
   DECLARE_SYMBOL(__off_task2name, offsetof(task_t, name));
   DECLARE_SYMBOL(__val_task_magic, MAGIC_TASK);
}

/Andreas
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to