-
Notifications
You must be signed in to change notification settings - Fork 109
/
view_internal.h
120 lines (91 loc) · 3.37 KB
/
view_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*******************************************************************************
* (c) 2019 Zondax GmbH
* (c) 2016 Ledger
*
* 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.
********************************************************************************/
#pragma once
#include <stdint.h>
#include "coin.h"
#define CUR_FLOW G_ux.flow_stack[G_ux.stack_count-1]
#if defined(TARGET_NANOX)
#define MAX_CHARS_PER_KEY_LINE 64
#define MAX_CHARS_PER_VALUE1_LINE 4096
#define MAX_CHARS_HEXMESSAGE 160
#else
#define MAX_CHARS_PER_KEY_LINE (32+1)
#define MAX_CHARS_PER_VALUE_LINE (18)
#define MAX_CHARS_PER_VALUE1_LINE (2*MAX_CHARS_PER_VALUE_LINE+1)
#define MAX_CHARS_PER_VALUE2_LINE (MAX_CHARS_PER_VALUE_LINE+1)
#define MAX_CHARS_HEXMESSAGE 40
#endif
#define MAX_CHARS_ADDR (MAX_CHARS_PER_KEY_LINE + MAX_CHARS_PER_VALUE1_LINE)
// This takes data from G_io_apdu_buffer that is prefilled with the address
typedef struct {
union {
struct {
char key[MAX_CHARS_PER_KEY_LINE];
char value[MAX_CHARS_PER_VALUE1_LINE];
#if defined(TARGET_NANOS)
char value2[MAX_CHARS_PER_VALUE2_LINE];
#endif
};
struct {
char addr[MAX_CHARS_ADDR];
};
};
address_kind_e addrKind;
uint8_t itemIdx;
uint8_t itemCount;
uint8_t pageIdx;
uint8_t pageCount;
} view_t;
extern view_t viewdata;
typedef enum {
view_no_error = 0,
view_no_data = 1,
view_error_detected = 2
} view_error_t;
#define print_title(...) snprintf(viewdata.title, sizeof(viewdata.title), __VA_ARGS__)
#define print_key(...) snprintf(viewdata.key, sizeof(viewdata.key), __VA_ARGS__);
#define print_value(...) snprintf(viewdata.value, sizeof(viewdata.value), __VA_ARGS__);
#if defined(TARGET_NANOS)
#define print_value2(...) snprintf(viewdata.value2, sizeof(viewdata.value2), __VA_ARGS__);
#endif
void splitValueField();
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
///////////////////////////////////////////////
void view_idle_show_impl(uint8_t item_idx);
void view_address_show_impl();
void view_error_show_impl();
void view_sign_show_impl();
void h_address_accept(unsigned int _);
void h_error_accept(unsigned int _);
void h_sign_accept(unsigned int _);
void h_sign_reject(unsigned int _);
void h_paging_init();
uint8_t h_paging_can_increase();
void h_paging_increase();
uint8_t h_paging_can_decrease();
void h_paging_decrease();
void h_paging_set_page_count(uint8_t pageCount);
view_error_t h_review_update_data();
view_error_t h_addr_update_item(uint8_t idx);
view_error_t view_printAddr();
view_error_t view_printPath();