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

V1.0 review fixes #22

Merged
merged 25 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7c96dbf
rot: Change to a more appropriate error code
jonasblixt Apr 18, 2023
08fa63b
crypto: Change from uintptr_t to const void *
jonasblixt Apr 18, 2023
59c9546
bio: Move from drivers to src
jonasblixt Apr 18, 2023
1277a21
mbedtls: Stylefix
jonasblixt Apr 18, 2023
55ba565
crypto: Add comment about final and async
jonasblixt Apr 23, 2023
450080a
crypto: Add additional comment on init
jonasblixt Apr 23, 2023
75585f7
imx_caam: Merge common job completion code
jonasblixt Apr 23, 2023
b29ccd5
bio: Use void * instead of uintptr_t for read/write
jonasblixt Apr 23, 2023
dd225c0
cm/tops: Use void * instead of uintptr_t
jonasblixt Apr 23, 2023
5ec4449
bio: Add type lba_t for lba offsets
jonasblixt Apr 23, 2023
f078504
bio: Add API to report number of blocks
jonasblixt Apr 23, 2023
edbae20
pb: Use bio_get_no_of_blocks instead of bio_get_size
jonasblixt Apr 23, 2023
35ccfd7
bio: Change return type of bio_size to int64_t
jonasblixt Apr 23, 2023
2758bc7
bio: Clarify documentation on 'bio_set_flags'
jonasblixt Apr 23, 2023
373fd72
mmc_core: Put common part switching code in separate function
jonasblixt Apr 23, 2023
5788df6
mmc_core: remove unused 'mmc_part_size' function
jonasblixt Apr 23, 2023
baac970
mmc_core: Additional documentation
jonasblixt Apr 23, 2023
e1e5678
mmc_core: mmc_send_cmd: Avoid copying command and result
jonasblixt Apr 23, 2023
5b113a3
mmc_core: Add comment/todo regarding part switching
jonasblixt Apr 23, 2023
42dae41
part/gpt: Minor touch up's and additional comments
jonasblixt Apr 23, 2023
ec00360
drivers/mbedtls: Make mbedtls error strings optional
jonasblixt Apr 23, 2023
edab908
pb: Clean up usage of PB_ERR_MEM
jonasblixt Apr 23, 2023
c205c13
pb: Rename SZ_ -macros to reflect that it's a power of two
jonasblixt Apr 24, 2023
856b5e2
imx8x/fusebox: Added some additional fuse indices
jonasblixt Apr 24, 2023
46a3dcd
mmc_core: Add kconfig to override boot part size
jonasblixt Apr 24, 2023
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ src-y += keystore.c
src-y += src/delay.c
src-$(CONFIG_ENABLE_TIMESTAMPING) += src/timestamp.c
src-$(CONFIG_CRYPTO) += src/crypto.c
src-$(CONFIG_BIO_CORE) += src/bio.c
src-$(CONFIG_DEVICE_UUID) += src/device_uuid.c
src-$(CONFIG_SELF_TEST) += src/self_test.c
src-y += src/wire.c
Expand All @@ -95,7 +96,7 @@ include src/cm/makefile.mk

ldflags-y += -Map=$(BUILD_DIR)/pb.map
ldflags-y += --defsym=PB_ENTRY=$(PB_ENTRY)
ldflags-y += --defsym=PB_STACK_SIZE_KB=$(CONFIG_STACK_SIZE_KB)
ldflags-y += --defsym=PB_STACK_SIZE_KiB=$(CONFIG_STACK_SIZE_KiB)
ldflags-y += -Tsrc/link.lds --build-id=none

OBJS =
Expand Down
25 changes: 13 additions & 12 deletions configs/imx8qxmek_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ CONFIG_WATCHDOG_TIMEOUT=5
CONFIG_ENABLE_TIMESTAMPING=y
CONFIG_PRINT_TIMESTAMPS=y
CONFIG_NO_OF_TIMESTAMPS=64
# CONFIG_CALL_BOARD_SLC_SET_CONFIGURATION is not set
# CONFIG_CALL_BOARD_SLC_SET_CONFIGURATION_LOCK is not set
CONFIG_DEVICE_UUID=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_MAX_HASH_OPS=1
CONFIG_CRYPTO_MAX_DSA_OPS=1
CONFIG_BIO_CORE=y
CONFIG_BIO_MAX_DEVS=32
CONFIG_SELF_TEST=y
# end of Generic options

Expand All @@ -57,7 +57,7 @@ CONFIG_SELF_TEST=y
CONFIG_OPTIMIZE="2"
# CONFIG_DEBUG_SYMBOLS is not set
# CONFIG_STACK_USAGE is not set
CONFIG_STACK_SIZE_KB=16
CONFIG_STACK_SIZE_KiB=16
# end of Build configuration

#
Expand All @@ -67,20 +67,13 @@ CONFIG_BOOT_CORE=y
CONFIG_BOOT_BPAK_IMAGE_HELPERS=y
CONFIG_BOOT_AB_DRIVER=y
CONFIG_BOOT_LINUX=y
CONFIG_BOOT_LOAD_CHUNK_kB=4096
CONFIG_BOOT_LOAD_CHUNK_KiB=4096
# end of Boot

#
# Drivers
#

#
# Block drivers
#
CONFIG_DRIVERS_BIO_CORE=y
CONFIG_DRIVERS_BIO_MAX_DEVS=32
# end of Block drivers

#
# Crypto
#
Expand All @@ -92,6 +85,7 @@ CONFIG_DRIVERS_IMX_CAAM=y
# Fusebox
#
CONFIG_DRIVERS_FUSE_TEST=y
# CONFIG_DRIVERS_FUSE_IMX_OCOTP is not set
# end of Fusebox

#
Expand Down Expand Up @@ -127,6 +121,7 @@ CONFIG_DRIVERS_IMX_GPT=y
# Uart
#
CONFIG_DRIVERS_IMX_LPUART=y
# CONFIG_DRIVERS_IMX_UART is not set
# end of Uart

#
Expand All @@ -145,13 +140,19 @@ CONFIG_DRIVER_USB_PB_CLS=y
# CONFIG_DRIVER_VIRTIO_BLOCK is not set
# CONFIG_DRIVER_VIRTIO_SERIAL is not set
# end of Virtio

#
# Watchdog
#
# CONFIG_DRIVERS_IMX_WDOG is not set
# end of Watchdog
# end of Drivers

#
# Command mode
#
CONFIG_CM=y
CONFIG_CM_BUF_SIZE_KB=4096
CONFIG_CM_BUF_SIZE_KiB=4096
CONFIG_CM_TRANSPORT_READY_TIMEOUT=10
CONFIG_CM_AUTH=y
CONFIG_CM_AUTH_TOKEN=y
Expand Down
15 changes: 5 additions & 10 deletions configs/jiffy_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ CONFIG_DEVICE_UUID=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_MAX_HASH_OPS=1
CONFIG_CRYPTO_MAX_DSA_OPS=1
CONFIG_BIO_CORE=y
CONFIG_BIO_MAX_DEVS=32
CONFIG_SELF_TEST=y
# end of Generic options

Expand All @@ -45,7 +47,7 @@ CONFIG_SELF_TEST=y
CONFIG_OPTIMIZE="2"
# CONFIG_DEBUG_SYMBOLS is not set
# CONFIG_STACK_USAGE is not set
CONFIG_STACK_SIZE_KB=16
CONFIG_STACK_SIZE_KiB=16
# end of Build configuration

#
Expand All @@ -55,20 +57,13 @@ CONFIG_BOOT_CORE=y
CONFIG_BOOT_BPAK_IMAGE_HELPERS=y
CONFIG_BOOT_AB_DRIVER=y
CONFIG_BOOT_LINUX=y
CONFIG_BOOT_LOAD_CHUNK_kB=4096
CONFIG_BOOT_LOAD_CHUNK_KiB=4096
# end of Boot

#
# Drivers
#

#
# Block drivers
#
CONFIG_DRIVERS_BIO_CORE=y
CONFIG_DRIVERS_BIO_MAX_DEVS=32
# end of Block drivers

#
# Crypto
#
Expand Down Expand Up @@ -147,7 +142,7 @@ CONFIG_DRIVERS_IMX_WDOG=y
# Command mode
#
CONFIG_CM=y
CONFIG_CM_BUF_SIZE_KB=4096
CONFIG_CM_BUF_SIZE_KiB=4096
CONFIG_CM_TRANSPORT_READY_TIMEOUT=10
CONFIG_CM_AUTH=y
CONFIG_CM_AUTH_TOKEN=y
Expand Down
16 changes: 6 additions & 10 deletions configs/test_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ CONFIG_DEVICE_UUID=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_MAX_HASH_OPS=1
CONFIG_CRYPTO_MAX_DSA_OPS=1
CONFIG_BIO_CORE=y
CONFIG_BIO_MAX_DEVS=32
CONFIG_SELF_TEST=y
# end of Generic options

Expand All @@ -39,7 +41,7 @@ CONFIG_SELF_TEST=y
CONFIG_OPTIMIZE="2"
CONFIG_DEBUG_SYMBOLS=y
CONFIG_STACK_USAGE=y
CONFIG_STACK_SIZE_KB=16
CONFIG_STACK_SIZE_KiB=16
# end of Build configuration

#
Expand All @@ -49,20 +51,13 @@ CONFIG_BOOT_CORE=y
CONFIG_BOOT_BPAK_IMAGE_HELPERS=y
CONFIG_BOOT_AB_DRIVER=y
CONFIG_BOOT_LINUX=y
CONFIG_BOOT_LOAD_CHUNK_kB=4096
CONFIG_BOOT_LOAD_CHUNK_KiB=4096
# end of Boot

#
# Drivers
#

#
# Block drivers
#
CONFIG_DRIVERS_BIO_CORE=y
CONFIG_DRIVERS_BIO_MAX_DEVS=32
# end of Block drivers

#
# Crypto
#
Expand All @@ -72,6 +67,7 @@ CONFIG_MBEDTLS_MD_SHA384=y
CONFIG_MBEDTLS_MD_SHA512=y
CONFIG_MBEDTLS_MD_MD5=y
CONFIG_MBEDTLS_ECDSA=y
CONFIG_MBEDTLS_STRERROR=y
# end of Crypto

#
Expand Down Expand Up @@ -130,7 +126,7 @@ CONFIG_DRIVER_VIRTIO_SERIAL=y
# Command mode
#
CONFIG_CM=y
CONFIG_CM_BUF_SIZE_KB=4
CONFIG_CM_BUF_SIZE_KiB=4
CONFIG_CM_TRANSPORT_READY_TIMEOUT=10
CONFIG_CM_AUTH=y
CONFIG_CM_AUTH_TOKEN=y
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api-ref/bio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Block device layer

----------------------------------------------

Source code: :github-blob:`include/drivers/block/bio.h`, :github-blob:`src/drivers/block/bio.c`
Source code: :github-blob:`include/pb/bio.h`, :github-blob:`src/bio.c`

----------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion include/boot/ab_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

#include <uuid.h>
#include <drivers/block/bio.h>
#include <pb/bio.h>

enum ab_rollback_mode
{
Expand Down
4 changes: 2 additions & 2 deletions include/boot/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include <pb/utils_def.h>
#include <uuid.h>
#include <bpak/bpak.h>
#include <drivers/block/bio.h>
#include <pb/bio.h>

/* TODO: Write a note about the bpak block size of 512 bytes */
typedef int (*boot_read_cb_t)(int block_offset, size_t length, uintptr_t buf);
typedef int (*boot_read_cb_t)(int block_offset, size_t length, void *buf);
typedef int (*boot_result_cb_t)(int result);

/** Boot sources */
Expand Down
2 changes: 1 addition & 1 deletion include/drivers/fuse/test_fuse_bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef INCLUDE_DRIVERS_FUSE_TEST_BIO_H
#define INCLUDE_DRIVERS_FUSE_TEST_BIO_H

#include <drivers/block/bio.h>
#include <pb/bio.h>

int test_fuse_init(bio_dev_t dev);
int test_fuse_write(uint16_t addr, uint32_t value);
Expand Down
46 changes: 16 additions & 30 deletions include/drivers/mmc/mmc_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,6 @@ struct mmc_csd_emmc {
unsigned int csd_structure: 2;
};

struct mmc_cmd {
uint32_t arg; /*!< MMC command argument */
uint16_t resp_type; /*!< Type of response to expect */
uint16_t idx; /*!< Index of command to execute */
};

typedef uint32_t mmc_cmd_resp_t[4];

typedef int (*mmc_init_t)(void);
Expand All @@ -313,18 +307,18 @@ typedef int (*mmc_io_t)(unsigned int lba, size_t length, uintptr_t buf);
typedef int (*mmc_set_bus_clock_t)(unsigned int clk_hz);
typedef int (*mmc_set_bus_width_t)(enum mmc_bus_width width);

typedef int (*mmc_send_cmd_t)(const struct mmc_cmd *cmd,
typedef int (*mmc_send_cmd_t)(uint16_t idx, uint32_t arg, uint16_t resp_type,
mmc_cmd_resp_t result);
struct mmc_hal {
mmc_init_t init;
mmc_send_cmd_t send_cmd;
mmc_set_bus_clock_t set_bus_clock;
mmc_set_bus_width_t set_bus_width;
mmc_io_t prepare;
mmc_io_t read;
mmc_io_t write;
int (*set_delay_tap)(unsigned int tap);
size_t max_chunk_bytes;
mmc_init_t init; /*!< Initilize HAL */
mmc_send_cmd_t send_cmd; /*!< Send MMC command */
mmc_set_bus_clock_t set_bus_clock; /*!< Set bus clock rate */
mmc_set_bus_width_t set_bus_width; /*!< Set bus with */
mmc_io_t prepare; /*!< Prepare DMA and start xfer, this is optional */
mmc_io_t read; /*!< Perform read op */
mmc_io_t write; /*!< Perform write op */
int (*set_delay_tap)(unsigned int tap); /*!< Select bus delay tap */
size_t max_chunk_bytes; /*!< Maximum bytes per iop */
};

struct mmc_device_info {
Expand All @@ -337,12 +331,13 @@ struct mmc_device_info {
struct mmc_device_config {
enum mmc_bus_mode mode; /*!< Requested bus mode */
enum mmc_bus_width width; /*!< Requested bus width */
const unsigned char *boot0_uu;
const unsigned char *boot1_uu;
const unsigned char *rpmb_uu;
const unsigned char *user_uu;
const unsigned char *boot0_uu; /*!< UUID to assign to boot 0 partition */
const unsigned char *boot1_uu; /*!< UUID to assign to boot 1 partition */
const unsigned char *rpmb_uu; /*!< UUID to assign to RPMB partition */
const unsigned char *user_uu; /*!< UUID to assign to user partition */
uint32_t flags;
uint8_t boot_mode;
uint8_t boot_mode; /*!< Optional, used to update the boot
mode in extcsd, for example, for fast boot */
};

/**
Expand Down Expand Up @@ -398,13 +393,4 @@ int mmc_write(unsigned int lba, size_t length, const uintptr_t buf);
*/
int mmc_part_switch(enum mmc_part part);

/**
* Read partition size in bytes
*
* @param[in] part Hardware partition
*
* @return Partition size in bytes or a negative number on error
*/
ssize_t mmc_part_size(enum mmc_part part);

#endif
2 changes: 1 addition & 1 deletion include/drivers/partition/gpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define INCLUDE_DRIVERS_PARTITION_GPT_H

#include <stdint.h>
#include <drivers/block/bio.h>
#include <pb/bio.h>

#define GPT_PART_NAME_MAX_SIZE 36

Expand Down
4 changes: 2 additions & 2 deletions include/drivers/usb/pb_dev_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define INCLUDE_DRIVERS_USB_PB_DEV_CLS_H

int pb_dev_cls_init(void);
int pb_dev_cls_write(uintptr_t buf, size_t length);
int pb_dev_cls_read(uintptr_t buf, size_t length);
int pb_dev_cls_write(const void *buf, size_t length);
int pb_dev_cls_read(void *buf, size_t length);

#endif // INCLUDE_DRIVERS_USB_PB_DEV_CLS_H
2 changes: 1 addition & 1 deletion include/drivers/virtio/virtio_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <stdint.h>
#include <uuid.h>
#include <drivers/block/bio.h>
#include <pb/bio.h>

bio_dev_t virtio_block_init(uintptr_t base, const uuid_t uu);

Expand Down
4 changes: 2 additions & 2 deletions include/drivers/virtio/virtio_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <stdint.h>

int virtio_serial_init(uintptr_t base);
int virtio_serial_write(uintptr_t buf, size_t length);
int virtio_serial_read(uintptr_t buf, size_t length);
int virtio_serial_write(const void *buf, size_t length);
int virtio_serial_read(void *buf, size_t length);

#endif // DRIVERS_VIRTIO_SERIAL_H
Loading