Skip to content
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

Cherry pick for API_LEVEL_5 #441

Merged
merged 16 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@

# Formatting commit
59a948f2838ec0ced714c81c8e268d6016b84057

# Temporary formatting commit revert
e6391739c0b6e24df9465eccfb17d86fa9a42a68

# Reapply formatting
8c5ba3b82a6523759f3f7a59cb5ea2d2f3a5e12a
1 change: 0 additions & 1 deletion .github/workflows/build_all_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ env:
\"app-edgeware\" : \"./app\" ,
\"app-filecoin\" : \"app\" ,
\"app-firmachain\" : \"./app\" ,
\"app-flow\" : \"app\" ,
\"app-genshiro\" : \"./app\" ,
\"app-iov\" : \"app\" ,
\"app-internetcomputer\" : \"./app\" ,
Expand Down
2 changes: 2 additions & 0 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ DEFINES += HAVE_BAGL_FONT_INTER_REGULAR_24PX
DEFINES += HAVE_BAGL_FONT_INTER_SEMIBOLD_24PX
DEFINES += HAVE_BAGL_FONT_INTER_REGULAR_32PX
DEFINES += HAVE_BAGL_FONT_HMALPHAMONO_MEDIUM_32PX
DEFINES += HAVE_INAPP_BLE_PAIRING
DEFINES += HAVE_NBGL
DEFINES += HAVE_PIEZO_SOUND
DEFINES += HAVE_SE_TOUCH
Expand Down Expand Up @@ -211,6 +212,7 @@ DEFINES += HAVE_MCU_SERIAL_STORAGE
DEFINES += HAVE_FONTS
# already defined within apps
# DEFINES += HAVE_BLE
DEFINES += HAVE_INAPP_BLE_PAIRING
DEFINES += HAVE_BATTERY
endif

Expand Down
9 changes: 6 additions & 3 deletions include/ledger_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ enum {

/* Exported types, structures, unions ----------------------------------------*/
typedef struct ledger_protocol_s {
uint8_t *tx_apdu_buffer;
const uint8_t *tx_apdu_buffer;

uint16_t tx_apdu_length;
uint16_t tx_apdu_sequence_number;
uint16_t tx_apdu_offset;
Expand All @@ -45,6 +46,8 @@ typedef struct ledger_protocol_s {
uint16_t rx_apdu_length;
uint16_t rx_apdu_offset;

uint8_t *rx_dst_buffer;

uint16_t mtu;
uint8_t mtu_negotiated;
} ledger_protocol_t;
Expand All @@ -57,5 +60,5 @@ typedef struct ledger_protocol_s {

/* Exported functions prototypes--------------------------------------------- */
void LEDGER_PROTOCOL_init(ledger_protocol_t *data);
void LEDGER_PROTOCOL_rx(uint8_t *buffer, uint16_t length);
void LEDGER_PROTOCOL_tx(uint8_t *buffer, uint16_t length);
void LEDGER_PROTOCOL_rx(const uint8_t *buffer, uint16_t length);
void LEDGER_PROTOCOL_tx(const uint8_t *buffer, uint16_t length);
8 changes: 8 additions & 0 deletions include/os_apilevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
#ifndef OS_APILEVEL_H
#define OS_APILEVEL_H

#ifndef HAVE_BOLOS
// Obsolete defines - shall not be used
// Replaced by API_LEVEL mechanism enforced directly at app sideloading.
// Hence the app can consider it runs on a OS which match the SDK the app has been built for.
#define CX_APILEVEL _Pragma("GCC warning \"Deprecated constant!\"") 12
#define CX_COMPAT_APILEVEL _Pragma("GCC warning \"Deprecated constant!\"") 12
#else
#define CX_APILEVEL 12
#define CX_COMPAT_APILEVEL 12
#endif

#endif // OS_APILEVEL_H
5 changes: 4 additions & 1 deletion include/os_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ unsigned int os_get_sn(unsigned char *buffer);
SYSCALL unsigned int get_api_level(void);

#ifndef HAVE_BOLOS
static inline void check_api_level(unsigned int apiLevel)
// Obsolete function - shall not be used
// Replaced by API_LEVEL mechanism enforced directly at app sideloading.
// Hence the app can consider it runs on a OS which match the SDK the app has been built for.
DEPRECATED static inline void check_api_level(unsigned int apiLevel)
{
if (apiLevel < get_api_level()) {
os_sched_exit(-1);
Expand Down
6 changes: 6 additions & 0 deletions include/os_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
#else
#define IO_APDU_BUFFER_SIZE IMPL_IO_APDU_BUFFER_SIZE
#endif

typedef struct apdu_buffer_s {
uint8_t *buf;
uint16_t len;
} apdu_buffer_t;

extern unsigned char G_io_apdu_buffer[IO_APDU_BUFFER_SIZE];

// send tx_len bytes (atr or rapdu) and retrieve the length of the next command apdu (over the
Expand Down
6 changes: 4 additions & 2 deletions include/os_io_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define OS_IO_USB_H

#include "os_io_seproxyhal.h"
#include "os_io.h"

#ifdef HAVE_USB_APDU

Expand All @@ -46,7 +47,8 @@ void io_usb_hid_init(void);
*/
io_usb_hid_receive_status_t io_usb_hid_receive(io_send_t sndfct,
unsigned char *buffer,
unsigned short l);
unsigned short l,
apdu_buffer_t *apdu_buffer);

/**
* Mark the last chunk transmitted as sent.
Expand All @@ -57,7 +59,7 @@ void io_usb_hid_sent(io_send_t sndfct);
/**
* Request transmission of an APDU from the G_io_apdu_buffer using the HID transport protocol
*/
void io_usb_hid_send(io_send_t sndfct, unsigned short sndlength);
void io_usb_hid_send(io_send_t sndfct, unsigned short sndlength, unsigned char *apdu_buffer);

#endif // HAVE_USB_APDU

Expand Down
5 changes: 3 additions & 2 deletions lib_blewbxx_impl/include/ledger_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@

/* Exported functions prototypes--------------------------------------------- */
void LEDGER_BLE_init(void);
void LEDGER_BLE_send(uint8_t *packet, uint16_t packet_length);
void LEDGER_BLE_receive(void);
void LEDGER_BLE_send(const uint8_t *packet, uint16_t packet_length);
void LEDGER_BLE_receive(const uint8_t *spi_buffer);
void LEDGER_BLE_set_recv_buffer(uint8_t *buffer, uint16_t buffer_length);
void LEDGER_BLE_enable_advertising(uint8_t enable);
void LEDGER_BLE_reset_pairings(void);

Expand Down
Loading
Loading