Skip to content

Commit

Permalink
Merge pull request #22 from jonasblixt/v1.0-review-fixes
Browse files Browse the repository at this point in the history
V1.0 review fixes
  • Loading branch information
jonasblixt committed Apr 24, 2023
2 parents 06c82ac + 46a3dcd commit d5af7a5
Show file tree
Hide file tree
Showing 59 changed files with 481 additions and 442 deletions.
3 changes: 2 additions & 1 deletion Makefile
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
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
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
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
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
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
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
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
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
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
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
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
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

0 comments on commit d5af7a5

Please sign in to comment.