summaryrefslogtreecommitdiff
path: root/chip/host
diff options
context:
space:
mode:
Diffstat (limited to 'chip/host')
-rw-r--r--chip/host/adc_chip.h2
-rw-r--r--chip/host/build.mk2
-rw-r--r--chip/host/clock.c2
-rw-r--r--chip/host/config_chip.h12
-rw-r--r--chip/host/flash.c14
-rw-r--r--chip/host/gpio.c8
-rw-r--r--chip/host/host_test.h4
-rw-r--r--chip/host/i2c.c21
-rw-r--r--chip/host/keyboard_raw.c2
-rw-r--r--chip/host/lpc.c2
-rw-r--r--chip/host/persistence.c20
-rw-r--r--chip/host/persistence.h2
-rw-r--r--chip/host/reboot.c7
-rw-r--r--chip/host/reboot.h5
-rw-r--r--chip/host/registers.h2
-rw-r--r--chip/host/spi_controller.c2
-rw-r--r--chip/host/system.c14
-rw-r--r--chip/host/trng.c10
-rw-r--r--chip/host/uart.c6
-rw-r--r--chip/host/usb_pd_phy.c10
20 files changed, 74 insertions, 73 deletions
diff --git a/chip/host/adc_chip.h b/chip/host/adc_chip.h
index 8754be266e..cd55e1b5fb 100644
--- a/chip/host/adc_chip.h
+++ b/chip/host/adc_chip.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chip/host/build.mk b/chip/host/build.mk
index ce4fc8f704..b4a75cf3c6 100644
--- a/chip/host/build.mk
+++ b/chip/host/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright 2013 The Chromium OS Authors. All rights reserved.
+# Copyright 2013 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
diff --git a/chip/host/clock.c b/chip/host/clock.c
index 2c3c48661e..4f90067f3a 100644
--- a/chip/host/clock.c
+++ b/chip/host/clock.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
diff --git a/chip/host/config_chip.h b/chip/host/config_chip.h
index 84e254d8a0..323fb83d33 100644
--- a/chip/host/config_chip.h
+++ b/chip/host/config_chip.h
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -20,11 +20,11 @@
extern char __host_flash[CONFIG_FLASH_SIZE_BYTES];
#define CONFIG_PROGRAM_MEMORY_BASE ((uintptr_t)__host_flash)
-#define CONFIG_FLASH_ERASE_SIZE 0x0010 /* erase bank size */
-#define CONFIG_FLASH_WRITE_SIZE 0x0002 /* minimum write size */
+#define CONFIG_FLASH_ERASE_SIZE 0x0010 /* erase bank size */
+#define CONFIG_FLASH_WRITE_SIZE 0x0002 /* minimum write size */
#define CONFIG_FLASH_WRITE_IDEAL_SIZE 0x0080 /* ideal write size */
-#define CONFIG_RAM_BASE 0x0 /* Not supported */
-#define CONFIG_RAM_SIZE 0x0 /* Not supported */
+#define CONFIG_RAM_BASE 0x0 /* Not supported */
+#define CONFIG_RAM_SIZE 0x0 /* Not supported */
#define CONFIG_FPU
@@ -43,7 +43,7 @@ extern char __host_flash[CONFIG_FLASH_SIZE_BYTES];
/* Interval between HOOK_TICK notifications */
#define HOOK_TICK_INTERVAL_MS 250
-#define HOOK_TICK_INTERVAL (HOOK_TICK_INTERVAL_MS * MSEC)
+#define HOOK_TICK_INTERVAL (HOOK_TICK_INTERVAL_MS * MSEC)
/* Do NOT use common panic code (designed to output information on the UART) */
#undef CONFIG_COMMON_PANIC_OUTPUT
diff --git a/chip/host/flash.c b/chip/host/flash.c
index 75212737e0..209489162c 100644
--- a/chip/host/flash.c
+++ b/chip/host/flash.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,6 +7,7 @@
#include <stdio.h>
+#include "builtin/assert.h"
#include "common.h"
#include "config_chip.h"
#include "flash.h"
@@ -26,8 +27,7 @@ test_mockable int flash_pre_op(void)
static int flash_check_protect(int offset, int size)
{
int first_bank = offset / CONFIG_FLASH_BANK_SIZE;
- int last_bank = DIV_ROUND_UP(offset + size,
- CONFIG_FLASH_BANK_SIZE);
+ int last_bank = DIV_ROUND_UP(offset + size, CONFIG_FLASH_BANK_SIZE);
int bank;
for (bank = first_bank; bank < last_bank; ++bank)
@@ -124,8 +124,7 @@ int crec_flash_physical_protect_now(int all)
uint32_t crec_flash_physical_get_valid_flags(void)
{
- return EC_FLASH_PROTECT_RO_AT_BOOT |
- EC_FLASH_PROTECT_RO_NOW |
+ return EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW |
EC_FLASH_PROTECT_ALL_NOW;
}
@@ -163,8 +162,9 @@ int crec_flash_pre_init(void)
*/
if ((prot_flags & EC_FLASH_PROTECT_RO_AT_BOOT) &&
!(prot_flags & EC_FLASH_PROTECT_RO_NOW)) {
- int rv = crec_flash_set_protect(EC_FLASH_PROTECT_RO_NOW,
- EC_FLASH_PROTECT_RO_NOW);
+ int rv =
+ crec_flash_set_protect(EC_FLASH_PROTECT_RO_NOW,
+ EC_FLASH_PROTECT_RO_NOW);
if (rv)
return rv;
diff --git a/chip/host/gpio.c b/chip/host/gpio.c
index 3c15205ad5..b74bec52a1 100644
--- a/chip/host/gpio.c
+++ b/chip/host/gpio.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -19,8 +19,8 @@ static int gpio_interrupt_enabled[GPIO_COUNT];
/* Create a dictionary of names for debug console print */
#define GPIO_INT(name, pin, flags, signal) #name,
#define GPIO(name, pin, flags) #name,
-const char * gpio_names[GPIO_COUNT] = {
- #include "gpio.wrap"
+const char *gpio_names[GPIO_COUNT] = {
+#include "gpio.wrap"
};
#undef GPIO
#undef GPIO_INT
@@ -92,7 +92,7 @@ test_mockable void gpio_set_flags_by_mask(uint32_t port, uint32_t mask,
}
test_mockable void gpio_set_alternate_function(uint32_t port, uint32_t mask,
- enum gpio_alternate_func func)
+ enum gpio_alternate_func func)
{
/* Nothing */
}
diff --git a/chip/host/host_test.h b/chip/host/host_test.h
index e2bf5448c3..39516f751e 100644
--- a/chip/host/host_test.h
+++ b/chip/host/host_test.h
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -14,4 +14,4 @@
/* Get emulator executable name */
const char *__get_prog_name(void);
-#endif /* __CROS_EC_HOST_TEST_H */
+#endif /* __CROS_EC_HOST_TEST_H */
diff --git a/chip/host/i2c.c b/chip/host/i2c.c
index ba4ab376d2..3fddbbbac5 100644
--- a/chip/host/i2c.c
+++ b/chip/host/i2c.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -52,8 +52,7 @@ int test_attach_i2c(const int port, const uint16_t addr_flags)
int i;
for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
- if (detached_devs[i].valid &&
- detached_devs[i].port == port &&
+ if (detached_devs[i].valid && detached_devs[i].port == port &&
detached_devs[i].addr_flags == addr_flags)
break;
@@ -64,22 +63,19 @@ int test_attach_i2c(const int port, const uint16_t addr_flags)
return EC_SUCCESS;
}
-static int test_check_detached(const int port,
- const uint16_t addr_flags)
+static int test_check_detached(const int port, const uint16_t addr_flags)
{
int i;
for (i = 0; i < MAX_DETACHED_DEV_COUNT; ++i)
- if (detached_devs[i].valid &&
- detached_devs[i].port == port &&
+ if (detached_devs[i].valid && detached_devs[i].port == port &&
detached_devs[i].addr_flags == addr_flags)
return 1;
return 0;
}
-int chip_i2c_xfer(const int port, const uint16_t addr_flags,
- const uint8_t *out, int out_size,
- uint8_t *in, int in_size, int flags)
+int chip_i2c_xfer(const int port, const uint16_t addr_flags, const uint8_t *out,
+ int out_size, uint8_t *in, int in_size, int flags)
{
const struct test_i2c_xfer *p;
int rv;
@@ -87,9 +83,8 @@ int chip_i2c_xfer(const int port, const uint16_t addr_flags,
if (test_check_detached(port, addr_flags))
return EC_ERROR_UNKNOWN;
for (p = __test_i2c_xfer; p < __test_i2c_xfer_end; ++p) {
- rv = p->routine(port, addr_flags,
- out, out_size,
- in, in_size, flags);
+ rv = p->routine(port, addr_flags, out, out_size, in, in_size,
+ flags);
if (rv != EC_ERROR_INVAL)
return rv;
}
diff --git a/chip/host/keyboard_raw.c b/chip/host/keyboard_raw.c
index 3e1f755f7f..47b9a7dda0 100644
--- a/chip/host/keyboard_raw.c
+++ b/chip/host/keyboard_raw.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chip/host/lpc.c b/chip/host/lpc.c
index dd64be9275..78619c5b75 100644
--- a/chip/host/lpc.c
+++ b/chip/host/lpc.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chip/host/persistence.c b/chip/host/persistence.c
index 44d60f1bb8..4d8ef09df1 100644
--- a/chip/host/persistence.c
+++ b/chip/host/persistence.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
+#include "builtin/assert.h"
#include "util.h"
/* The longest path in a chroot seems to be about 280 characters (as of
@@ -60,9 +61,10 @@ static void get_storage_path(char *out)
current = strchr(current, '/');
}
+ sz = snprintf(out, PATH_MAX - 1, "/dev/shm/EC_persist_%.*s", max_len,
+ buf);
+ ASSERT(sz > 0);
- sz = snprintf(out, PATH_MAX - 1, "/dev/shm/EC_persist_%.*s",
- max_len, buf);
out[PATH_MAX - 1] = '\0';
ASSERT(sz <= max_len + max_prefix_len);
@@ -72,6 +74,7 @@ FILE *get_persistent_storage(const char *tag, const char *mode)
{
char buf[PATH_MAX];
char path[PATH_MAX];
+ int sz;
/* There's no longer tag in use right now, and there shouldn't be. */
ASSERT(strlen(tag) < 32);
@@ -81,8 +84,9 @@ FILE *get_persistent_storage(const char *tag, const char *mode)
* be named 'bar_persist_foo'
*/
get_storage_path(buf);
- snprintf(path, PATH_MAX - 1, "%.*s_%32s",
- max_len + max_prefix_len, buf, tag);
+ sz = snprintf(path, PATH_MAX - 1, "%.*s_%32s", max_len + max_prefix_len,
+ buf, tag);
+ ASSERT(sz > 0);
path[PATH_MAX - 1] = '\0';
return fopen(path, mode);
@@ -97,13 +101,15 @@ void remove_persistent_storage(const char *tag)
{
char buf[PATH_MAX];
char path[PATH_MAX];
+ int sz;
/* There's no longer tag in use right now, and there shouldn't be. */
ASSERT(strlen(tag) < 32);
get_storage_path(buf);
- snprintf(path, PATH_MAX - 1, "%.*s_%32s",
- max_len + max_prefix_len, buf, tag);
+ sz = snprintf(path, PATH_MAX - 1, "%.*s_%32s", max_len + max_prefix_len,
+ buf, tag);
+ ASSERT(sz > 0);
path[PATH_MAX - 1] = '\0';
unlink(path);
diff --git a/chip/host/persistence.h b/chip/host/persistence.h
index a473f8dfb0..479788815f 100644
--- a/chip/host/persistence.h
+++ b/chip/host/persistence.h
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chip/host/reboot.c b/chip/host/reboot.c
index e932c5f11a..24d90d943d 100644
--- a/chip/host/reboot.c
+++ b/chip/host/reboot.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -20,10 +20,9 @@ void emulator_reboot(void)
ccprints("Emulator would reboot here. Fuzzing: doing nothing.");
}
#else /* !TEST_FUZZ */
-noreturn
-void emulator_reboot(void)
+noreturn void emulator_reboot(void)
{
- char *argv[] = {strdup(__get_prog_name()), NULL};
+ char *argv[] = { strdup(__get_prog_name()), NULL };
emulator_flush();
execv(__get_prog_name(), argv);
while (1)
diff --git a/chip/host/reboot.h b/chip/host/reboot.h
index 1c1201f451..1541e42334 100644
--- a/chip/host/reboot.h
+++ b/chip/host/reboot.h
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -13,6 +13,7 @@
#ifndef TEST_FUZZ
noreturn
#endif
-void emulator_reboot(void);
+ void
+ emulator_reboot(void);
#endif
diff --git a/chip/host/registers.h b/chip/host/registers.h
index 7347ce04d3..3c75686b40 100644
--- a/chip/host/registers.h
+++ b/chip/host/registers.h
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/chip/host/spi_controller.c b/chip/host/spi_controller.c
index c7afea5d39..a1df53d935 100644
--- a/chip/host/spi_controller.c
+++ b/chip/host/spi_controller.c
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
diff --git a/chip/host/system.c b/chip/host/system.c
index bf63af8bf0..4a480faf77 100644
--- a/chip/host/system.c
+++ b/chip/host/system.c
@@ -1,10 +1,11 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* System module for emulator */
+#include "builtin/assert.h"
#include "common.h"
#include "ec_commands.h"
#include "host_test.h"
@@ -44,8 +45,7 @@ static void ramdata_get_persistent(void)
FILE *f = get_persistent_storage("ramdata", "rb");
if ((f == NULL) || (fread(__ram_data, RAM_DATA_SIZE, 1, f) != 1)) {
- fprintf(stderr,
- "No RAM data found. Initializing to 0x00.\n");
+ fprintf(stderr, "No RAM data found. Initializing to 0x00.\n");
memset(__ram_data, 0, RAM_DATA_SIZE);
return;
}
@@ -129,14 +129,14 @@ static int load_time(timestamp_t *t)
test_mockable struct panic_data *panic_get_data(void)
{
- return (struct panic_data *)
- (__ram_data + RAM_DATA_SIZE - sizeof(struct panic_data));
+ return (struct panic_data *)(__ram_data + RAM_DATA_SIZE -
+ sizeof(struct panic_data));
}
test_mockable uintptr_t get_panic_data_start(void)
{
- return (uintptr_t)
- (__ram_data + RAM_DATA_SIZE - sizeof(struct panic_data));
+ return (uintptr_t)(__ram_data + RAM_DATA_SIZE -
+ sizeof(struct panic_data));
}
test_mockable void system_reset(int flags)
diff --git a/chip/host/trng.c b/chip/host/trng.c
index 8407aa6ea1..ef3df1ad5f 100644
--- a/chip/host/trng.c
+++ b/chip/host/trng.c
@@ -1,5 +1,5 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -21,20 +21,20 @@
static unsigned int seed;
-test_mockable void init_trng(void)
+test_mockable void trng_init(void)
{
seed = 0;
srand(seed);
}
-test_mockable void exit_trng(void)
+test_mockable void trng_exit(void)
{
}
-test_mockable void rand_bytes(void *buffer, size_t len)
+test_mockable void trng_rand_bytes(void *buffer, size_t len)
{
uint8_t *b, *end;
- for (b = buffer, end = b+len; b != end; b++)
+ for (b = buffer, end = b + len; b != end; b++)
*b = (uint8_t)rand_r(&seed);
}
diff --git a/chip/host/uart.c b/chip/host/uart.c
index 578924612f..9e70a6005c 100644
--- a/chip/host/uart.c
+++ b/chip/host/uart.c
@@ -1,4 +1,4 @@
-/* Copyright 2013 The Chromium OS Authors. All rights reserved.
+/* Copyright 2013 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -11,6 +11,7 @@
#include <termio.h>
#include <unistd.h>
+#include "builtin/assert.h"
#include "common.h"
#include "queue.h"
#include "task.h"
@@ -55,7 +56,6 @@ static void test_capture_char(char c)
capture_buf[capture_size++] = c;
}
-
const char *test_get_captured_console(void)
{
return (const char *)capture_buf;
@@ -190,6 +190,6 @@ void uart_init(void)
pthread_mutex_unlock(&mutex);
#endif
- stopped = 1; /* Not transmitting yet */
+ stopped = 1; /* Not transmitting yet */
init_done = 1;
}
diff --git a/chip/host/usb_pd_phy.c b/chip/host/usb_pd_phy.c
index ba81b986ad..aa5f022f3e 100644
--- a/chip/host/usb_pd_phy.c
+++ b/chip/host/usb_pd_phy.c
@@ -1,8 +1,9 @@
-/* Copyright 2014 The Chromium OS Authors. All rights reserved.
+/* Copyright 2014 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "builtin/assert.h"
#include "common.h"
#include "console.h"
#include "crc.h"
@@ -37,9 +38,9 @@ static struct pd_physical {
int verified_idx;
} pd_phy[CONFIG_USB_PD_PORT_MAX_COUNT];
-static const uint16_t enc4b5b[] = {
- 0x1E, 0x09, 0x14, 0x15, 0x0A, 0x0B, 0x0E, 0x0F, 0x12, 0x13, 0x16,
- 0x17, 0x1A, 0x1B, 0x1C, 0x1D};
+static const uint16_t enc4b5b[] = { 0x1E, 0x09, 0x14, 0x15, 0x0A, 0x0B,
+ 0x0E, 0x0F, 0x12, 0x13, 0x16, 0x17,
+ 0x1A, 0x1B, 0x1C, 0x1D };
/* Test utilities */
static void pd_test_reset_phy(int port)
@@ -216,7 +217,6 @@ int pd_test_tx_msg_verify_crc(int port)
return pd_test_tx_msg_verify_word(port, crc32_result());
}
-
/* Mock functions */
void pd_init_dequeue(int port)