Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Modify style checker for PKCS #11 types #117

Merged
merged 3 commits into from
Nov 29, 2018
Merged

Modify style checker for PKCS #11 types #117

merged 3 commits into from
Nov 29, 2018

Conversation

alexa-noxon
Copy link
Contributor

PKCS #11 types may follow the format CK_TYPE_PTR or CK_TYPE_PTR_PTR.
This change updates the style checker to recognize _PTR and _PTR_PTR
line endings as pointer types.

This change also allows variables to start with a number.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • My code is Linted.

PKCS #11 types may follow the format CK_TYPE_PTR or CK_TYPE_PTR_PTR.
This change updates the style checker to recognize _PTR and _PTR_PTR
line endings as pointer types.

This change also allows variables to start with a number.
@alexa-noxon alexa-noxon requested review from aggarg and tgsong November 28, 2018 22:10
@@ -224,7 +235,7 @@ def get_identifier_prefix(identifier):
indirection = "p" * (len(identifier) - len(direct_identifier))
for key in TYPE_PREFIXES:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this line didn't change, looks like we can just do for prefix in TYPE_PREFIXES.values():, key is only used to get values from this dictionary.

@@ -247,4 +258,4 @@ def main(): # pragma: no cover


if __name__ == "__main__": # pragma: no cover
main()
main()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor thing, missing newline here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. I got confused by the whitespace checker output.

@aggarg aggarg merged commit b682b54 into master Nov 29, 2018
@aggarg aggarg deleted the anoxon/pkcs11_style branch November 29, 2018 19:57
jcmvbkbc pushed a commit to foss-xtensa/amazon-freertos that referenced this pull request Jan 27, 2022
* Xtensa: fix the coproc_area incorrect issue

#2 mentioned a issue:
1.
In function pxPortInitialiseStack(StackType_t *pxTopOfStack....)
p = (uint32_t *)(((uint32_t) pxTopOfStack - XT_CP_SIZE) & ~0xf);

In function prvInitialiseNewTask (file: task.c)
pxTopOfStack = (pxStack + (ulStackDepth - 1)) & (~portBYTE_ALIGNMENT_MASK)

So the co-processor area is at
p = (uint32_t *)(((uint32_t)((pxStack + (ulStackDepth - 1)) & (~portBYTE_ALIGNMENT_MASK)) - XT_CP_SIZE) & ~0xf);

2.
In function vPortStoreTaskMPUSettings( .... , StackType_t pxBottomOfStack ...)
xMPUSettings->coproc_area = (StackType_t)((((uint32_t)(pxBottomOfStack + usStackDepth - 1)) - XT_CP_SIZE) & ~0xf);

pxBottomOfStack = pxStack

=> xMPUSettings->coproc_area = (StackType_t*)((((uint32_t)(pxStack+ ulStackDepth - 1)) - XT_CP_SIZE ) & ~0xf);

The p is coproc_area that should be equal to xMPUSettings->coproc_area.

For example, assume pxStack is 0xa0000000, ulStackDepth is 0x2000,
portBYTE_ALIGNMENT_MASK is 0x7f, XT_CP_SIZE is 0x100.

The p = (uint32_t)(((uint32_t)((pxStack + (ulStackDepth - 1)) & (~portBYTE_ALIGNMENT_MASK)) - XT_CP_SIZE) & ~0xf)
      = 0xa0001e80
The xMPUSettings->coproc_area = (StackType_t)((((uint32_t)(pxStack+ usStackDepth - 1)) - XT_CP_SIZE ) & ~0xf)
                              = 0xa0001ef0
Obviously, the p is not equal to the xMPUSettings->coproc_area, which will cause context switching error.

Signed-off-by: magicse7en <magicse7en@outlook.com>

* Update port.c

Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants