From 4187fcbe36d6c4aeafb8b8be569f01e169b3155b Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 9 Dec 2019 16:48:54 +0100 Subject: Make local functions static --- src/cc20rng/main.c | 35 ++++++++++++++++++----------------- src/entropy/main.c | 26 +++++++++++++------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/cc20rng/main.c b/src/cc20rng/main.c index 2c2650c..e478409 100644 --- a/src/cc20rng/main.c +++ b/src/cc20rng/main.c @@ -40,8 +40,8 @@ extern DMA_HandleTypeDef hdma_tim; -UART_HandleTypeDef *huart; -__IO ITStatus UartReady = RESET; +static UART_HandleTypeDef *huart; +static __IO ITStatus UartReady = RESET; static union { uint8_t rnd[257]; /* 256 bytes + 1 for use in the POST */ @@ -71,15 +71,16 @@ static struct DMA_params DMA = { /* The main work horse functions */ -void get_entropy32(uint32_t num_bytes, uint32_t buf_idx); +static void get_entropy32(uint32_t num_bytes, uint32_t buf_idx); /* Various support functions */ -inline uint32_t get_one_bit(void) __attribute__((__always_inline__)); -volatile uint32_t *restart_DMA(void); -inline volatile uint32_t *get_DMA_read_buf(void); -inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx); -void check_uart_rx(UART_HandleTypeDef *this); +static inline uint32_t get_one_bit(void) __attribute__((__always_inline__)); +static volatile uint32_t *restart_DMA(void); +static inline volatile uint32_t *get_DMA_read_buf(void); +static inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx); +static void check_uart_rx(UART_HandleTypeDef *this); +static void cc_reseed(struct cc20_state *cc); + void Error_Handler(void); -void cc_reseed(struct cc20_state *cc); int @@ -169,7 +170,7 @@ main() * @param cc: ChaCha20 state * @retval None */ -void +static void cc_reseed(struct cc20_state *cc) { HAL_GPIO_WritePin(LED_PORT, LED_BLUE, GPIO_PIN_SET); @@ -187,7 +188,7 @@ cc_reseed(struct cc20_state *cc) * @param start: Start index value into buf.rnd32. * @retval None */ -inline void get_entropy32(uint32_t count, const uint32_t start) +static inline void get_entropy32(uint32_t count, const uint32_t start) { uint32_t i, bits, buf_idx; @@ -212,7 +213,7 @@ inline void get_entropy32(uint32_t count, const uint32_t start) * @param None * @retval One bit, in the LSB of an uint32_t since this is a 32 bit MCU. */ -inline uint32_t get_one_bit() +static inline uint32_t get_one_bit() { register uint32_t a, b, temp; /* Start at end of buffer so restart_DMA() is called. */ @@ -263,7 +264,7 @@ inline uint32_t get_one_bit() * @param None * @retval Pointer to buffer currently being read from. */ -inline volatile uint32_t *get_DMA_read_buf(void) +static inline volatile uint32_t *get_DMA_read_buf(void) { return DMA.write_buf ? DMA.buf0 : DMA.buf1; } @@ -273,7 +274,7 @@ inline volatile uint32_t *get_DMA_read_buf(void) * @param None * @retval Pointer to buffer currently being written to. */ -inline volatile uint32_t *get_DMA_write_buf(void) +static inline volatile uint32_t *get_DMA_write_buf(void) { return DMA.write_buf ? DMA.buf1 : DMA.buf0; } @@ -283,7 +284,7 @@ inline volatile uint32_t *get_DMA_write_buf(void) * @param None * @retval Pointer to buffer full of Timer IC values ready to be consumed. */ -volatile uint32_t *restart_DMA(void) +static volatile uint32_t *restart_DMA(void) { /* Wait for transfer complete flag to become SET. Trying to change the * M0AR register while the DMA is running is a no-no. @@ -310,7 +311,7 @@ volatile uint32_t *restart_DMA(void) * @param dmabuf_idx: Word index into `dmabuf'. * @retval One Timer IC counter value. */ -inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx) { +static inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx) { register uint32_t a; /* Prevent re-use of values. DMA stored values are <= 0xffff. */ do { @@ -333,7 +334,7 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UH) /* * If a newline is received on UART1 or UART2, redirect output to that UART. */ -void check_uart_rx(UART_HandleTypeDef *this) { +static void check_uart_rx(UART_HandleTypeDef *this) { uint8_t rx = 0; if (HAL_UART_Receive(this, &rx, 1, 0) == HAL_OK) { if (rx == '\n') { diff --git a/src/entropy/main.c b/src/entropy/main.c index f7663f5..11ec788 100644 --- a/src/entropy/main.c +++ b/src/entropy/main.c @@ -42,8 +42,8 @@ extern DMA_HandleTypeDef hdma_tim; -UART_HandleTypeDef *huart; -__IO ITStatus UartReady = RESET; +static UART_HandleTypeDef *huart; +static __IO ITStatus UartReady = RESET; static union { uint8_t rnd[257]; /* 256 bytes + 1 for use in the POST */ @@ -73,14 +73,14 @@ static struct DMA_params DMA = { /* The main work horse functions */ -void get_entropy32(uint32_t num_bytes, uint32_t buf_idx); -void perform_delta32(uint32_t count, const uint32_t start); +static void get_entropy32(uint32_t num_bytes, uint32_t buf_idx); +static void perform_delta32(uint32_t count, const uint32_t start); /* Various support functions */ -inline uint32_t get_one_bit(void) __attribute__((__always_inline__)); -volatile uint32_t *restart_DMA(void); -inline volatile uint32_t *get_DMA_read_buf(void); -inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx); -void check_uart_rx(UART_HandleTypeDef *this); +static inline uint32_t get_one_bit(void) __attribute__((__always_inline__)); +static volatile uint32_t *restart_DMA(void); +static inline volatile uint32_t *get_DMA_read_buf(void); +static inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx); +static void check_uart_rx(UART_HandleTypeDef *this); /* static void Error_Handler(void); */ @@ -247,7 +247,7 @@ inline void get_entropy32(uint32_t count, const uint32_t start) * @param None * @retval One bit, in the LSB of an uint32_t since this is a 32 bit MCU. */ -inline uint32_t get_one_bit() +static inline uint32_t get_one_bit() { register uint32_t a, b, temp; /* Start at end of buffer so restart_DMA() is called. */ @@ -298,7 +298,7 @@ inline uint32_t get_one_bit() * @param None * @retval Pointer to buffer currently being read from. */ -inline volatile uint32_t *get_DMA_read_buf(void) +static inline volatile uint32_t *get_DMA_read_buf(void) { return DMA.write_buf ? DMA.buf0 : DMA.buf1; } @@ -308,7 +308,7 @@ inline volatile uint32_t *get_DMA_read_buf(void) * @param None * @retval Pointer to buffer currently being written to. */ -inline volatile uint32_t *get_DMA_write_buf(void) +static inline volatile uint32_t *get_DMA_write_buf(void) { return DMA.write_buf ? DMA.buf1 : DMA.buf0; } @@ -345,7 +345,7 @@ volatile uint32_t *restart_DMA(void) * @param dmabuf_idx: Word index into `dmabuf'. * @retval One Timer IC counter value. */ -inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx) { +static inline uint32_t safe_get_counter(volatile uint32_t *dmabuf, const uint32_t dmabuf_idx) { register uint32_t a; /* Prevent re-use of values. DMA stored values are <= 0xffff. */ do { -- cgit v1.2.3