-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Driver dispatch Codegen 1.1 #5396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gilles-peskine-arm
merged 30 commits into
Mbed-TLS:development
from
SiliconLabs:codegen_1.1
Nov 7, 2022
Merged
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e829cd6
Driver Wrapper CodeGen Rev 1.1
silabs-ArchanaM 05efa17
JSON upgrade to give function names
silabs-ArchanaM 04cfe34
JSON Validation added
silabs-ArchanaM 3143805
PyLint errors fixed
silabs-ArchanaM 25876b8
Adding JSONSchema to CI scripts
silabs-ArchanaM 634e0d2
Update check_names.py to exclude autogen file
silabs-ArchanaM e17071a
Update Dockerfile with missing packages
silabs-ArchanaM fdbbcba
JSONschema and python improvements
silabs-ArchanaM a78dc70
Fix JsonObject type for MyPy
silabs-ArchanaM 4688624
Driver Wrappers code gen migration guide updated.
silabs-ArchanaM 01aa39e
Arg parse improvements
silabs-ArchanaM 22c7827
Schema and script improvements
silabs-ArchanaM 1776dd9
Doc improvements -Cosmetic
silabs-ArchanaM a2cac32
Update and document mbedtls extensions
silabs-ArchanaM 08f397a
refactored generate_driver_wrappers.py
asfand-silabs 39452a8
fixed formating of driver generator script
asfand-silabs b549776
Merge branch 'Mbed-TLS:development' into codegen_1.1
asfand-silabs de08803
refactored and addressed reviewer observations in generate_driver_wra…
asfand-silabs 4c93bb5
removed changed made to the test/bionic/Dockerfile
asfand-silabs 5c9569a
fixed formating
asfand-silabs 9e6170d
added some doc strings and fixed formating
asfand-silabs 4ca4a93
fixed opaque schemas paths
asfand-silabs ac6f650
fixed formating
asfand-silabs c155415
Merge branch 'Mbed-TLS:development' into codegen_1.1
asfand-silabs 6eaa75a
fixed docstring sentence
asfand-silabs 9bd28dc
Update changed log
asfand-silabs ee2b637
Fixed change log issue
asfand-silabs 4f63ac4
fixed changelog formating
asfand-silabs 65cd8a4
fixed formating issues in psa_crypto_code_gen_1_1.txt
asfand-silabs 9b656d3
removed stray whitespaces from change logs
asfand-silabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "type": "object", | ||
| "properties": { | ||
gilles-peskine-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "_comment": { | ||
| "type": "string" | ||
gilles-peskine-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| "prefix": { | ||
| "type": "string", | ||
| "pattern": "^[A-Z_a-z][0-9A-Z_a-z]*$" | ||
| }, | ||
| "type": { | ||
| "type": "string", | ||
| "const": ["opaque"] | ||
| }, | ||
| "location": { | ||
| "type": ["integer","string"], | ||
| "pattern": "^(0x|0X)?[a-fA-F0-9]+$" | ||
| }, | ||
| "mbedtls/h_condition": { | ||
| "type": "string" | ||
| }, | ||
gilles-peskine-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "headers": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| }, | ||
| "default": [] | ||
| }, | ||
| "capabilities": { | ||
| "type": "array", | ||
| "items": [ | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "_comment": { | ||
| "type": "string" | ||
| }, | ||
| "mbedtls/c_condition": { | ||
| "type": "string" | ||
| }, | ||
| "entry_points": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "names": { | ||
| "type": "object", | ||
| "patternProperties": { | ||
| "^[A-Z_a-z][0-9A-Z_a-z]*$": { | ||
| "type": "string", | ||
| "pattern": "^[A-Z_a-z][0-9A-Z_a-z]*$" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "required": [ | ||
| "entry_points" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "required": [ | ||
| "prefix", | ||
| "type", | ||
| "location", | ||
| "capabilities" | ||
| ] | ||
| } | ||
70 changes: 70 additions & 0 deletions
70
scripts/data_files/driver_jsons/driver_transparent_schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "type": "object", | ||
| "properties": { | ||
| "_comment": { | ||
| "type": "string" | ||
| }, | ||
| "prefix": { | ||
| "type": "string", | ||
| "pattern": "^[A-Z_a-z][0-9A-Z_a-z]*$" | ||
| }, | ||
| "type": { | ||
| "type": "string", | ||
| "const": ["transparent"] | ||
| }, | ||
| "mbedtls/h_condition": { | ||
| "type": "string" | ||
| }, | ||
| "headers": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| }, | ||
| "default": [] | ||
| }, | ||
| "capabilities": { | ||
| "type": "array", | ||
| "items": [ | ||
| { | ||
| "type": "object", | ||
| "properties": { | ||
| "_comment": { | ||
| "type": "string" | ||
| }, | ||
| "mbedtls/c_condition": { | ||
| "type": "string" | ||
| }, | ||
| "entry_points": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "names": { | ||
| "type": "object", | ||
| "patternProperties": { | ||
| "^[A-Z_a-z][0-9A-Z_a-z]*$": { | ||
| "type": "string", | ||
| "pattern": "^[A-Z_a-z][0-9A-Z_a-z]*$" | ||
| } | ||
| } | ||
| }, | ||
| "fallback": { | ||
| "type": "boolean", | ||
| "default": "false" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "entry_points" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "required": [ | ||
| "prefix", | ||
| "type", | ||
| "capabilities" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ["mbedtls_test_opaque_driver.json","mbedtls_test_transparent_driver.json"] | ||
gilles-peskine-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
20 changes: 20 additions & 0 deletions
20
scripts/data_files/driver_jsons/mbedtls_test_opaque_driver.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
gilles-peskine-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "prefix": "mbedtls_test", | ||
| "type": "opaque", | ||
| "location": "0x7fffff", | ||
| "mbedtls/h_condition": "defined(PSA_CRYPTO_DRIVER_TEST)", | ||
| "headers": ["test/drivers/test_driver.h"], | ||
| "capabilities": [ | ||
| { | ||
| "_comment": "The Mbed TLS opaque driver supports import key/export key/export_public key", | ||
| "mbedtls/c_condition": "defined(PSA_CRYPTO_DRIVER_TEST)", | ||
| "entry_points": ["import_key", "export_key", "export_public_key"] | ||
| }, | ||
| { | ||
| "_comment": "The Mbed TLS opaque driver supports copy key/ get builtin key", | ||
| "mbedtls/c_condition": "defined(PSA_CRYPTO_DRIVER_TEST)", | ||
| "entry_points": ["copy_key", "get_builtin_key"], | ||
| "names": {"copy_key":"mbedtls_test_opaque_copy_key", "get_builtin_key":"mbedtls_test_opaque_get_builtin_key"} | ||
| } | ||
| ] | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
scripts/data_files/driver_jsons/mbedtls_test_transparent_driver.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "prefix": "mbedtls_test", | ||
| "type": "transparent", | ||
| "mbedtls/h_condition": "defined(PSA_CRYPTO_DRIVER_TEST)", | ||
| "headers": ["test/drivers/test_driver.h"], | ||
| "capabilities": [ | ||
| { | ||
| "_comment": "The Mbed TLS transparent driver supports import key/export key", | ||
| "mbedtls/c_condition": "defined(PSA_CRYPTO_DRIVER_TEST)", | ||
| "entry_points": ["import_key", "export_key"], | ||
| "fallback": true | ||
| }, | ||
| { | ||
| "_comment": "The Mbed TLS transparent driver supports export_public key", | ||
| "mbedtls/c_condition": "defined(PSA_CRYPTO_DRIVER_TEST)", | ||
| "entry_points": ["export_public_key"], | ||
| "fallback": true, | ||
| "names": {"export_public_key":"mbedtls_test_transparent_export_public_key"} | ||
| } | ||
|
|
||
| ] | ||
| } |
17 changes: 17 additions & 0 deletions
17
scripts/data_files/driver_templates/OS-template-opaque.jinja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| {# One Shot function's dispatch code for opaque drivers. | ||
| Expected inputs: | ||
| * drivers: the list of driver descriptions. | ||
| * entry_point: the name of the entry point that this function dispatches to. | ||
| * entry_point_param(driver): the parameters to pass to the entry point. | ||
| * nest_indent: number of extra spaces to indent the code to. | ||
| -#} | ||
| {% for driver in drivers if driver.type == "opaque" -%} | ||
gilles-peskine-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {% for capability in driver.capabilities if entry_point in capability.entry_points -%} | ||
| #if ({% if capability['mbedtls/c_condition'] is defined -%}{{ capability['mbedtls/c_condition'] }} {% else -%} {{ 1 }} {% endif %}) | ||
| {%- filter indent(width = nest_indent) %} | ||
| case {{ driver.location }}: | ||
| return( {{ entry_point_name(capability, entry_point, driver) }}({{entry_point_param(driver) | indent(20)}})); | ||
| {% endfilter -%} | ||
| #endif | ||
| {% endfor %} | ||
| {% endfor %} | ||
19 changes: 19 additions & 0 deletions
19
scripts/data_files/driver_templates/OS-template-transparent.jinja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| {# One Shot function's dispatch code for transparent drivers. | ||
| Expected inputs: | ||
| * drivers: the list of driver descriptions. | ||
| * entry_point: the name of the entry point that this function dispatches to. | ||
| * entry_point_param(driver): the parameters to pass to the entry point. | ||
| * nest_indent: number of extra spaces to indent the code to. | ||
| -#} | ||
| {% for driver in drivers if driver.type == "transparent" -%} | ||
| {% for capability in driver.capabilities if entry_point in capability.entry_points -%} | ||
| #if ({% if capability['mbedtls/c_condition'] is defined -%}{{ capability['mbedtls/c_condition'] }} {% else -%} {{ 1 }} {% endif %}) | ||
| {%- filter indent(width = nest_indent) %} | ||
| status = {{ entry_point_name(capability, entry_point, driver) }}({{entry_point_param(driver) | indent(20)}}); | ||
|
|
||
| if( status != PSA_ERROR_NOT_SUPPORTED ) | ||
| return( status ); | ||
| {% endfilter -%} | ||
| #endif | ||
| {% endfor %} | ||
| {% endfor %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz no txtspk in chglog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you need to add a file to
Changelog.d, don't editChangeLogdirectly (if we editChangeLogdirectly we get conflicts between all the pull requests that do it).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gilles-peskine-arm
Changelogissue is addressed, if there is anything please let me.