#3838 closed enhancement (fixed)

Rework work area initialization

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 5.1
Component: bsps Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking: #3835, #3843, #3861, #3925

Description (last modified by Sebastian Huber)

The work area initialization is done by the BSP through bsp_work_area_initialize(). This approach predates the system initialization through the system initialization linker set. The workspace and C program heap are unconditionally initialized. With the availability of statically initialized threads a system without workspace and C program heap is feasible. Change the work area initialization so that components are initialized on demand. To achieve this:

  1. Add a Memory Handler which provides support for low level handling of memory areas which are handed over to the higher level Heap Handler.
  1. Add an implementation of _Memory_Get() to each BSP (basically a restructuring of the bsp_work_area_initialize() implementations).

See optimization opportunity in #3925.

Change History (21)

comment:1 Changed on Dec 11, 2019 at 4:01:24 PM by Chris Johns

This needs to be explained in more detail.

What happens to BSPs that are not in the tree?

comment:2 Changed on Dec 11, 2019 at 4:31:41 PM by Sebastian Huber

I am not sure what needs to be explained in more detail. This is mostly a mechanical change which just rearranges existing things a bit differently.

As usual, maintainers of BSPs which are not in the mainline RTEMS source have to pay a price and have to update their BSPs by themself. With an updated documentation, this shouldn't be an issue.

comment:3 in reply to:  2 ; Changed on Dec 12, 2019 at 6:08:47 PM by Chris Johns

Replying to Sebastian Huber:

I am not sure what needs to be explained in more detail. This is mostly a mechanical change which just rearranges existing things a bit differently.

I think there are somethings, for example take "components are initialized on demand", what is a "component" and what does "initialized on demand" mean?

I am OK with working through the detail but this will have to wait until I find the time. If you do not mind waiting let me know.

As usual, maintainers of BSPs which are not in the mainline RTEMS source have to pay a price and have to update their BSPs by themself. With an updated documentation, this shouldn't be an issue.

A number of users cannot submit their BSPs and we have attempted to maintain a BSP API. Maybe we should define a formal BSP interface that cannot be touched without careful consideration?

Last edited on Dec 12, 2019 at 6:10:04 PM by Chris Johns (previous) (diff)

comment:4 in reply to:  3 Changed on Dec 12, 2019 at 6:48:09 PM by Sebastian Huber

Replying to Chris Johns:

Replying to Sebastian Huber:

I am not sure what needs to be explained in more detail. This is mostly a mechanical change which just rearranges existing things a bit differently.

I think there are somethings, for example take "components are initialized on demand", what is a "component" and what does "initialized on demand" mean?

The two components are the workspace and the C program heap. On demand means that they are only initialized if functions of these components are used by the application.

I am OK with working through the detail but this will have to wait until I find the time. If you do not mind waiting let me know.

As usual, maintainers of BSPs which are not in the mainline RTEMS source have to pay a price and have to update their BSPs by themself. With an updated documentation, this shouldn't be an issue.

A number of users cannot submit their BSPs and we have attempted to maintain a BSP API. Maybe we should define a formal BSP interface that cannot be touched without careful consideration?

I do this with careful consideration. This change request is the result of a multi year work consisting of lots of small steps to make it possible to fully statically initialize RTEMS. Yes, it breaks the API, but adopting an existing BSP can be done easily in less than one hour. Also if you use a standard linker command file, then you can use the default implementation in your external BSP.

comment:5 Changed on Dec 16, 2019 at 7:51:32 AM by Sebastian Huber

Blocking: 3843 added

comment:6 Changed on Feb 4, 2020 at 5:23:46 AM by Sebastian Huber

Blocking: 3861 added

comment:7 Changed on Feb 4, 2020 at 6:03:26 AM by Sebastian Huber <sebastian.huber@…>

In 1cb9257/rtems:

score: Add Memory Handler

Update #3838.

comment:8 Changed on Feb 4, 2020 at 6:03:30 AM by Sebastian Huber <sebastian.huber@…>

In c477d927/rtems:

score: Add _Memory_Fill()

Update #3838.

comment:9 Changed on Feb 4, 2020 at 6:03:34 AM by Sebastian Huber <sebastian.huber@…>

In ffa1153/rtems:

bsps: Add RamEnd? to linker command files

Update #3838.

comment:10 Changed on Feb 4, 2020 at 6:03:37 AM by Sebastian Huber <sebastian.huber@…>

In 34a7a12f/rtems:

bsps: Add RTEMS_SYSINIT_BSP_EARLY

Add new BSP system initialization step for work to be performed before
the work areas are initialized.

Update #3838.

comment:11 Changed on Feb 4, 2020 at 6:03:41 AM by Sebastian Huber <sebastian.huber@…>

In c184b0c/rtems:

stackchk: Add RTEMS_SYSINIT_ISR_STACK

Use a dedicated system initialization step for the stack checker
interrupt stack support.

Update #3838.

comment:12 Changed on Feb 4, 2020 at 6:03:45 AM by Sebastian Huber <sebastian.huber@…>

In 07e2eac/rtems:

bsps: Remove uses of BSP_GET_WORK_AREA_DEBUG

The code covered by BSP_GET_WORK_AREA_DEBUG was basically dead code
since there was no normal way to activate it (e.g. via a BSP
configuration option). A follow up patch will bring back this feature
through a CONFIGURE_VERBOSE_SYSTEM_INITIALIZATION configuration option.

Update #3838.

comment:13 Changed on Feb 4, 2020 at 6:03:48 AM by Sebastian Huber <sebastian.huber@…>

In eea21eac/rtems:

bsps: Rework work area initialization

The work area initialization was done by the BSP through
bsp_work_area_initialize(). This approach predated the system
initialization through the system initialization linker set. The
workspace and C program heap were unconditionally initialized. The aim
is to support RTEMS application configurations which do not need the
workspace and C program heap. In these configurations, the workspace
and C prgram heap should not get initialized.

Change all bsp_work_area_initialize() to implement _Memory_Get()
instead. Move the dirty memory, sbrk(), per-CPU data, workspace, and
malloc() heap initialization into separate system initialization steps.
This makes it also easier to test the individual initialization steps.

This change adds a dependency to _Heap_Extend() to all BSPs. This
dependency will be removed in a follow up change.

Update #3838.

comment:14 Changed on Feb 4, 2020 at 6:03:52 AM by Sebastian Huber <sebastian.huber@…>

In f7c5f94/rtems:

sysinit: Add RTEMS_SYSINIT_ORDER_LAST_BUT_[1-9]

Update #3838.

comment:15 Changed on Feb 4, 2020 at 6:03:56 AM by Sebastian Huber <sebastian.huber@…>

In c344e58/rtems:

Use RTEMS_SYSINIT_ORDER_LAST_BUT_5

Use RTEMS_SYSINIT_ORDER_LAST_BUT_5 instead of RTEMS_SYSINIT_ORDER_LAST
to allow applications and support functions to place system
initialization handlers behind the standard handlers.

Update #3838.

comment:16 Changed on Feb 4, 2020 at 6:22:23 AM by Sebastian Huber <sebastian.huber@…>

In 813ada5/rtems-docs:

c-user: Update system initialization chapter

Update #2408.
Update #3838.

comment:17 Changed on Feb 4, 2020 at 8:58:48 AM by Sebastian Huber <sebastian.huber@…>

In 4205250/rtems-docs:

bsp-howto: Rework system initialization chapter

Update #2852.
Update #3838.

comment:18 Changed on Feb 4, 2020 at 10:26:04 AM by Sebastian Huber <sebastian.huber@…>

In ccaec966/rtems:

libtests/malloc04: Fix typo

Update #3838.

comment:19 Changed on Feb 14, 2020 at 9:06:57 AM by Sebastian Huber <sebastian.huber@…>

In 33d89af/rtems:

smpfatal09: Fix test case

Update #3838.

comment:20 Changed on Apr 2, 2020 at 8:48:23 AM by Sebastian Huber

Blocking: 3925 added

comment:21 Changed on Apr 2, 2020 at 8:49:21 AM by Sebastian Huber

Description: modified (diff)
Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.