-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgrade zxlib * adjust ValidatorPrefs type * updating makefile * updating icons * updating zemu screenshots
- Loading branch information
Showing
25 changed files
with
2,097 additions
and
1,831 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
APPVERSION_M=0 | ||
APPVERSION_N=11 | ||
APPVERSION_P=1 | ||
APPVERSION_P=3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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 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 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 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,80 @@ | ||
/******************************************************************************* | ||
* (c) 2020 Zondax GmbH | ||
* | ||
* 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. | ||
********************************************************************************/ | ||
|
||
#include "zbuffer.h" | ||
#include "zxmacros.h" | ||
|
||
typedef struct { | ||
uint8_t *ptr; | ||
uint16_t size; | ||
} zbuffer_t; | ||
|
||
zbuffer_t _internal; | ||
|
||
#define CANARY_EXPECTED 0x987def82u | ||
|
||
zbuffer_error_e zb_get(uint8_t **buffer) { | ||
*buffer = NULL; | ||
if (_internal.size == 0 || _internal.ptr == NULL) { | ||
return zb_not_allocated; | ||
} | ||
*buffer = _internal.ptr; | ||
return zb_no_error; | ||
} | ||
|
||
zbuffer_error_e zb_init() { | ||
_internal.size = 0; | ||
_internal.ptr = NULL; | ||
return zb_no_error; | ||
} | ||
|
||
zbuffer_error_e zb_allocate(uint16_t size) { | ||
if (size % 4 != 0) { | ||
return zb_misaligned_buffer; | ||
} | ||
_internal.size = size; | ||
_internal.ptr = (uint8_t *) (&app_stack_canary + 4); | ||
|
||
uint32_t *zb_canary = (uint32_t *) (_internal.ptr + _internal.size + 4); | ||
*zb_canary = CANARY_EXPECTED; | ||
|
||
return zb_no_error; | ||
} | ||
|
||
zbuffer_error_e zb_deallocate() { | ||
if (_internal.size == 0) { | ||
return zb_not_allocated; | ||
} | ||
|
||
// Flush any information | ||
MEMZERO(_internal.ptr, _internal.size); | ||
|
||
zb_init(); | ||
return zb_no_error; | ||
} | ||
|
||
zbuffer_error_e zb_check_canary() { | ||
CHECK_APP_CANARY(); | ||
if (_internal.size != 0) { | ||
// allocated | ||
uint32_t *zb_canary = (uint32_t *) (_internal.ptr + _internal.size + 4); | ||
if (*zb_canary != CANARY_EXPECTED) { | ||
handle_stack_overflow(); | ||
} | ||
} | ||
|
||
return zb_no_error; | ||
} |
Oops, something went wrong.