Skip to content

Commit

Permalink
pb: Rename SZ_ -macros to reflect that it's a power of two
Browse files Browse the repository at this point in the history
SZ_MB -> SZ_MiB
SZ_kB -> SZ_KiB
SZ_GB -> SZ_GiB
  • Loading branch information
jonasblixt committed Apr 24, 2023
1 parent e864bb9 commit d7998ba
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -96,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
6 changes: 3 additions & 3 deletions configs/imx8qxmek_defconfig
Expand Up @@ -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,7 +67,7 @@ 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

#
Expand Down Expand Up @@ -152,7 +152,7 @@ CONFIG_DRIVER_USB_PB_CLS=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
6 changes: 3 additions & 3 deletions configs/jiffy_defconfig
Expand Up @@ -47,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 @@ -57,7 +57,7 @@ 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

#
Expand Down Expand Up @@ -142,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
6 changes: 3 additions & 3 deletions configs/test_defconfig
Expand Up @@ -41,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 @@ -51,7 +51,7 @@ 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

#
Expand Down Expand Up @@ -126,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
6 changes: 3 additions & 3 deletions include/pb/utils_def.h
Expand Up @@ -161,9 +161,9 @@
#define membersof(array) (sizeof(array) / sizeof((array)[0]))


#define SZ_kB(x) ((size_t) (x) << 10)
#define SZ_MB(x) ((size_t) (x) << 20)
#define SZ_GB(x) ((size_t) (x) << 30)
#define SZ_KiB(x) ((size_t) (x) << 10)
#define SZ_MiB(x) ((size_t) (x) << 20)
#define SZ_GiB(x) ((size_t) (x) << 30)
#define MHz(x) (x * 1000000UL)

#endif // INCLUDE_UTILS_DEF_H
4 changes: 2 additions & 2 deletions src/Kconfig
Expand Up @@ -91,8 +91,8 @@ config DEBUG_SYMBOLS
config STACK_USAGE
bool "Generate stack usage information"

config STACK_SIZE_KB
int "Stack size in Kbyte"
config STACK_SIZE_KiB
int "Stack size in KiB"
default 2

endmenu
Expand Down
22 changes: 11 additions & 11 deletions src/board/imx8qxmek/board.c
Expand Up @@ -56,22 +56,22 @@ static const struct gpt_part_table gpt_tbl_default[]=
{
.uu = UUID_2af755d8_8de5_45d5_a862_014cfa735ce0,
.description = "System A",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_c046ccd8_0f2e_4036_984d_76c14dc73992,
.description = "System B",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_c284387a_3377_4c0f_b5db_1bcbcff1ba1a,
.description = "Root A",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_ac6a1b62_7bd0_460b_9e6a_9a7831ccbfbb,
.description = "Root B",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_f5f8c9ae_efb5_4071_9ba9_d313b082281e,
Expand All @@ -86,37 +86,37 @@ static const struct gpt_part_table gpt_tbl_default[]=
{
.uu = UUID_4581af22_99e6_4a94_b821_b60c42d74758,
.description = "Root overlay A",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_da2ca04f_a693_4284_b897_3906cfa1eb13,
.description = "Root overlay B",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_23477731_7e33_403b_b836_899a0b1d55db,
.description = "RoT extension A",
.size = SZ_kB(128),
.size = SZ_KiB(128),
},
{
.uu = UUID_6ffd077c_32df_49e7_b11e_845449bd8edd,
.description = "RoT extension B",
.size = SZ_kB(128),
.size = SZ_KiB(128),
},
{
.uu = UUID_9697399d_e2da_47d9_8eb5_88daea46da1b,
.description = "System storage A",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_c5b8b41c_0fb5_494d_8b0e_eba400e075fa,
.description = "System storage B",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_39792364_d3e3_4013_ac51_caaea65e4334,
.description = "Mass storage",
.size = SZ_GB(1),
.size = SZ_GiB(1),
},
};

Expand Down
22 changes: 11 additions & 11 deletions src/board/jiffy/board.c
Expand Up @@ -38,22 +38,22 @@ static const struct gpt_part_table default_gpt_tbl[]=
{
.uu = UUID_2af755d8_8de5_45d5_a862_014cfa735ce0,
.description = "System A",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_c046ccd8_0f2e_4036_984d_76c14dc73992,
.description = "System B",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_c284387a_3377_4c0f_b5db_1bcbcff1ba1a,
.description = "Root A",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_ac6a1b62_7bd0_460b_9e6a_9a7831ccbfbb,
.description = "Root B",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_f5f8c9ae_efb5_4071_9ba9_d313b082281e,
Expand All @@ -68,37 +68,37 @@ static const struct gpt_part_table default_gpt_tbl[]=
{
.uu = UUID_4581af22_99e6_4a94_b821_b60c42d74758,
.description = "Root overlay A",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_da2ca04f_a693_4284_b897_3906cfa1eb13,
.description = "Root overlay B",
.size = SZ_MB(30),
.size = SZ_MiB(30),
},
{
.uu = UUID_23477731_7e33_403b_b836_899a0b1d55db,
.description = "RoT extension A",
.size = SZ_kB(128),
.size = SZ_KiB(128),
},
{
.uu = UUID_6ffd077c_32df_49e7_b11e_845449bd8edd,
.description = "RoT extension B",
.size = SZ_kB(128),
.size = SZ_KiB(128),
},
{
.uu = UUID_9697399d_e2da_47d9_8eb5_88daea46da1b,
.description = "System storage A",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_c5b8b41c_0fb5_494d_8b0e_eba400e075fa,
.description = "System storage B",
.size = SZ_MB(128),
.size = SZ_MiB(128),
},
{
.uu = UUID_39792364_d3e3_4013_ac51_caaea65e4334,
.description = "Mass storage",
.size = SZ_GB(1),
.size = SZ_GiB(1),
},
};

Expand Down
16 changes: 8 additions & 8 deletions src/board/test/board.c
Expand Up @@ -34,12 +34,12 @@ static const struct gpt_part_table gpt_tbl_default[]=
{
.uu = UUID_2af755d8_8de5_45d5_a862_014cfa735ce0,
.description = "System A",
.size = SZ_kB(512),
.size = SZ_KiB(512),
},
{
.uu = UUID_c046ccd8_0f2e_4036_984d_76c14dc73992,
.description = "System B",
.size = SZ_kB(512),
.size = SZ_KiB(512),
},
{
.uu = UUID_f5f8c9ae_efb5_4071_9ba9_d313b082281e,
Expand All @@ -59,7 +59,7 @@ static const struct gpt_part_table gpt_tbl_default[]=
{
.uu = UUID_ff4ddc6c_ad7a_47e8_8773_6729392dd1b5,
.description = "Readable",
.size = SZ_MB(1),
.size = SZ_MiB(1),
},
};

Expand All @@ -68,12 +68,12 @@ static const struct gpt_part_table gpt_tbl_var1[]=
{
.uu = UUID_2af755d8_8de5_45d5_a862_014cfa735ce0,
.description = "System A",
.size = SZ_kB(512),
.size = SZ_KiB(512),
},
{
.uu = UUID_c046ccd8_0f2e_4036_984d_76c14dc73992,
.description = "System B",
.size = SZ_kB(512),
.size = SZ_KiB(512),
},
{
.uu = UUID_f5f8c9ae_efb5_4071_9ba9_d313b082281e,
Expand All @@ -93,7 +93,7 @@ static const struct gpt_part_table gpt_tbl_var1[]=
{
.uu = UUID_ff4ddc6c_ad7a_47e8_8773_6729392dd1b5,
.description = "Readable",
.size = SZ_MB(8),
.size = SZ_MiB(8),
},
};

Expand All @@ -105,7 +105,7 @@ static const struct gpt_part_table gpt_tbl_var2[]=
{
.uu = UUID_2af755d8_8de5_45d5_a862_014cfa735ce0,
.description = "Large",
.size = SZ_kB(32734),
.size = SZ_KiB(32734),
},
};

Expand All @@ -115,7 +115,7 @@ static const struct gpt_part_table gpt_tbl_var3[]=
{
.uu = UUID_2af755d8_8de5_45d5_a862_014cfa735ce0,
.description = "Too large",
.size = SZ_kB(32735),
.size = SZ_KiB(32735),
},
};

Expand Down
4 changes: 2 additions & 2 deletions src/cm/Kconfig
Expand Up @@ -2,8 +2,8 @@ config CM
bool "Command mode support"
default y

config CM_BUF_SIZE_KB
int "Command buffer size in kB"
config CM_BUF_SIZE_KiB
int "Command buffer size in KiB"
default 4096
depends on CM

Expand Down

0 comments on commit d7998ba

Please sign in to comment.