Skip to content

Conversation

sauleThsQuin
Copy link

Title

fix[RL78 Port] incorrect register image for pvParameters in FAR mode (#1316)

Description

In the RL78 FAR data model, pxPortInitialiseStack() did not correctly
initialize the register image in the task stack for the parameter (pvParameters).

The saved A:DE registers were filled with dummy values instead of the actual pointer value.

As a result, when the first context restore occurred, the compiler's function prologue read a corrupted parameter from the register image.

This only affected FAR builds; NEAR model was not impacted.

This patch updates the RL78 FAR path so that the register image matches the RL78 calling convention:
DE = low 16 bits of pvParameters
A = high 8 bits of pvParameters (via AX register image, X = 0)

With this change, tasks in FAR model receive the correct parameter at entry, while NEAR model remains unchanged.

Test Steps

  • Build FreeRTOS for RL78 with FAR data model.
  • Create a task with xTaskCreate(task, "name", stack, pvParameters, prio, NULL).
  • Inspect pvParameters inside the task:

Before fix: value corrupted (dummy registers A:DE = 0x1111/0xDEDE).

After fix: value matches the pointer passed to xTaskCreate.

Confirm no regression with NEAR model build.

Checklist

  • I have tested my changes. No regression in existing tests.

  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

#1316

…FreeRTOS#1316)

In the RL78 FAR data model, pxPortInitialiseStack() did not correctly
initialize the register image for the task parameter (pvParameters).
The saved A:DE registers were filled with dummy values instead of the
actual pointer value.

As a result, when the first context restore occurred, the compiler's
function prologue read a corrupted parameter from the register image.
This only affected FAR builds; NEAR model was not impacted.

This patch updates the RL78 FAR path so that the register image matches
the calling convention:
 - DE = low 16 bits of pvParameters
 - A  = high 8 bits of pvParameters (via AX register image, X = 0)

With this change, tasks in FAR model receive the correct parameter
at entry, while NEAR model remains unchanged.
@sauleThsQuin sauleThsQuin requested a review from a team as a code owner September 8, 2025 09:36
@aggarg
Copy link
Member

aggarg commented Sep 9, 2025

@KeitaKashima What do you think about this change?

@KeitaKashima
Copy link
Contributor

@aggarg san

@KeitaKashima What do you think about this change?

My team will check the code. Could you please have some time to check it in about one or two weeks?

@aggarg
Copy link
Member

aggarg commented Sep 9, 2025

@KeitaKashima Of course. Take your time. Thank you for your help with the review!

@KeitaKashima
Copy link
Contributor

@aggarg
I am sorry that my team needs more time than I expected.

@TakeoTakahashi2020 and @ShunichiroNakamura of my team members, will check and answer the result.

@aggarg
Copy link
Member

aggarg commented Sep 17, 2025

@KeitaKashima No worries at all! Please take your time.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants