This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
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 * updating makefile * updating zemu screenshots
- Loading branch information
Showing
18 changed files
with
2,320 additions
and
2,053 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=1 | ||
APPVERSION_N=2011 | ||
APPVERSION_P=2 | ||
APPVERSION_P=3 |
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
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; | ||
} |
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,37 @@ | ||
/******************************************************************************* | ||
* (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 <inttypes.h> | ||
#include <stdint.h> | ||
|
||
typedef enum { | ||
zb_no_error, | ||
zb_misaligned_buffer, | ||
zb_not_allocated | ||
} zbuffer_error_e; | ||
|
||
// allocate a block at the end of the stack | ||
// maximum size will not be checked | ||
zbuffer_error_e zb_allocate(uint16_t size); | ||
|
||
// deallocate memory block as the end of the stack | ||
zbuffer_error_e zb_deallocate(); | ||
|
||
// obtain a pointer to the allocated block | ||
zbuffer_error_e zb_get(uint8_t **buffer); | ||
|
||
// check that the block boundary has not been corrupted | ||
zbuffer_error_e zb_check_canary(); |
Oops, something went wrong.