ETH plugin SDK : Move some parts from plugin boilerplate to Eth plugin SDK to ease the plugins development, remove throw and fix the CI issues
This commit is contained in:
committed by
Alexandre Paillier
parent
03c43f73da
commit
eeb52344df
68
src_plugins_sdk/plugin_main.c
Normal file
68
src_plugins_sdk/plugin_main.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/*****************************************************************************
|
||||
* Ledger Plugins SDK.
|
||||
* (c) 2023 Ledger SAS.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*****************************************************************************/
|
||||
|
||||
// Calls the ethereum app.
|
||||
void call_app_ethereum() {
|
||||
unsigned int libcall_params[5];
|
||||
libcall_params[0] = (unsigned int) "Ethereum";
|
||||
libcall_params[1] = 0x100;
|
||||
libcall_params[2] = RUN_APPLICATION;
|
||||
libcall_params[3] = (unsigned int) NULL;
|
||||
#ifdef HAVE_NBGL
|
||||
caller_app_t capp;
|
||||
const char name[] = APPNAME;
|
||||
nbgl_icon_details_t icon_details;
|
||||
uint8_t bitmap[sizeof(ICONBITMAP)];
|
||||
|
||||
memcpy(&icon_details, &ICONGLYPH, sizeof(ICONGLYPH));
|
||||
memcpy(&bitmap, &ICONBITMAP, sizeof(bitmap));
|
||||
icon_details.bitmap = (const uint8_t *) bitmap;
|
||||
capp.name = (const char *) name;
|
||||
capp.icon = &icon_details;
|
||||
libcall_params[4] = (unsigned int) &capp;
|
||||
#else
|
||||
libcall_params[4] = (unsigned int) NULL;
|
||||
#endif
|
||||
os_lib_call((unsigned int *) &libcall_params);
|
||||
}
|
||||
|
||||
// Low-level main for plugins.
|
||||
__attribute__((section(".boot"))) int main(int arg0) {
|
||||
// Exit critical section
|
||||
__asm volatile("cpsie i");
|
||||
|
||||
os_boot();
|
||||
|
||||
check_api_level(CX_COMPAT_APILEVEL);
|
||||
|
||||
// Check if plugin is called from the dashboard.
|
||||
if (!arg0) {
|
||||
// Called from dashboard, launch Ethereum app
|
||||
call_app_ethereum();
|
||||
return 0;
|
||||
} else {
|
||||
// Not called from dashboard: called from the ethereum app!
|
||||
// launch plugin main
|
||||
plugin_main(arg0);
|
||||
}
|
||||
|
||||
// Call `os_lib_end`, go back to the ethereum app.
|
||||
os_lib_end();
|
||||
|
||||
// Will not get reached.
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user