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

Introduce new global header files #4300

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Introduce new global header files #4300

merged 1 commit into from
Nov 5, 2024

Conversation

cepetr
Copy link
Contributor

@cepetr cepetr commented Nov 1, 2024

This large PR focuses on cleaning up code structure and organization.

It introduces well-defined global headers that simplify includes, make the code tidier, and establish a system to prevent unnecessary dependencies in API headers.

  • trezor_types.h: Defines commonly used types like uint8_t, uint32_t, bool, and secbool. This header is primarily intended for interface headers, consolidating all common types and replacing direct includes of stdint.h, stdbool.h, and secbool.h.

  • trezor_rtl.h: Provides declarations for commonly used functions (e.g., memset, memcpy, strcmp, strcpy). It should be included only in implementation files (.c files), replacing direct includes of assert.h, stdio.h, string.h, and error_handling.h. This header should not be included in API headers.

  • trezor_bsp.h: Contains board-specific definitions (e.g., pin mappings) and STM32 HAL headers, replacing the direct inclusion of STM32_HAL_H and TREZOR_BOARD_H. It should only be used in platform-specific code (typically within trezorhal) and avoided in platform-independent code.

  • trezor_model.h: Replaces model.h with no current changes.

These headers should be included using angle brackets (#include <...>) at the beginning of the include block in .c or .h files. While this is not technically required, it helps keep the code organized.

@cepetr cepetr added the core Trezor Core firmware. Runs on Trezor Model T and T2B1. label Nov 1, 2024
@cepetr cepetr self-assigned this Nov 1, 2024
core/embed/models/trezor_bsp.h Outdated Show resolved Hide resolved
core/embed/bootloader/main.c Outdated Show resolved Hide resolved
core/embed/prodtest/main.c Outdated Show resolved Hide resolved
core/embed/reflash/main.c Outdated Show resolved Hide resolved
core/embed/reflash/main.c Outdated Show resolved Hide resolved
core/embed/reflash/main.c Outdated Show resolved Hide resolved
core/embed/rust/trezorhal.h Outdated Show resolved Hide resolved
core/embed/trezorhal/stm32f4/sdram.h Show resolved Hide resolved
Base automatically changed from cepetr/model-board-cleanup to main November 4, 2024 13:05
@cepetr cepetr marked this pull request as ready for review November 4, 2024 15:40
@cepetr cepetr requested a review from prusnak as a code owner November 4, 2024 15:40
@cepetr cepetr merged commit 7b6f444 into main Nov 5, 2024
93 checks passed
@cepetr cepetr deleted the cepetr/global-headers branch November 5, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Trezor Core firmware. Runs on Trezor Model T and T2B1.
Projects
Status: Approved
Development

Successfully merging this pull request may close these issues.

2 participants