summaryrefslogtreecommitdiff
path: root/core/host
diff options
context:
space:
mode:
Diffstat (limited to 'core/host')
-rw-r--r--core/host/atomic.h4
-rw-r--r--core/host/build.mk2
-rw-r--r--core/host/cpu.h6
-rw-r--r--core/host/disabled.c7
-rw-r--r--core/host/host_exe.lds6
-rw-r--r--core/host/host_task.h4
-rw-r--r--core/host/irq_handler.h28
-rw-r--r--core/host/main.c6
-rw-r--r--core/host/panic.c6
-rw-r--r--core/host/stack_trace.c11
-rw-r--r--core/host/task.c28
-rw-r--r--core/host/timer.c8
-rw-r--r--core/host/toolchain.mk9
13 files changed, 67 insertions, 58 deletions
diff --git a/core/host/atomic.h b/core/host/atomic.h
index a8d6882d0e..0d27e1bc6f 100644
--- a/core/host/atomic.h
+++ b/core/host/atomic.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.
*/
@@ -40,4 +40,4 @@ static inline atomic_val_t atomic_and(atomic_t *addr, atomic_val_t bits)
{
return __atomic_fetch_and(addr, bits, __ATOMIC_SEQ_CST);
}
-#endif /* __CROS_EC_ATOMIC_H */
+#endif /* __CROS_EC_ATOMIC_H */
diff --git a/core/host/build.mk b/core/host/build.mk
index 503aa5538a..3995e7e4e4 100644
--- a/core/host/build.mk
+++ b/core/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/core/host/cpu.h b/core/host/cpu.h
index d990e06afa..f63e0b9d23 100644
--- a/core/host/cpu.h
+++ b/core/host/cpu.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.
*/
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_CPU_H
#define __CROS_EC_CPU_H
-static inline void cpu_init(void) { }
+static inline void cpu_init(void)
+{
+}
#endif /* __CROS_EC_CPU_H */
diff --git a/core/host/disabled.c b/core/host/disabled.c
index 759c215ebd..8f05e5e1d6 100644
--- a/core/host/disabled.c
+++ b/core/host/disabled.c
@@ -1,10 +1,13 @@
-/* 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.
*/
/* Disabled functions */
-#define DISABLED(proto) proto { }
+#define DISABLED(proto) \
+ proto \
+ { \
+ }
DISABLED(void clock_init(void));
diff --git a/core/host/host_exe.lds b/core/host/host_exe.lds
index ab8d352ecc..b4c94c12ff 100644
--- a/core/host/host_exe.lds
+++ b/core/host/host_exe.lds
@@ -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.
*/
@@ -113,6 +113,10 @@ SECTIONS {
KEEP(*(.rodata.HOOK_USB_PD_CONNECT))
__hooks_usb_pd_connect_end = .;
+ __hooks_power_supply_change = .;
+ KEEP(*(.rodata.HOOK_POWER_SUPPLY_CHANGE))
+ __hooks_power_supply_change_end = .;
+
__deferred_funcs = .;
*(.rodata.deferred)
__deferred_funcs_end = .;
diff --git a/core/host/host_task.h b/core/host/host_task.h
index 30cd2ff594..82b33f96c5 100644
--- a/core/host/host_task.h
+++ b/core/host/host_task.h
@@ -1,4 +1,4 @@
-/* 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.
*/
@@ -34,4 +34,4 @@ void task_register_interrupt(void);
*/
pid_t getpid(void);
-#endif /* __CROS_EC_HOST_TASK_H */
+#endif /* __CROS_EC_HOST_TASK_H */
diff --git a/core/host/irq_handler.h b/core/host/irq_handler.h
index 17e3df52d9..8bbf596a57 100644
--- a/core/host/irq_handler.h
+++ b/core/host/irq_handler.h
@@ -1,4 +1,4 @@
-/* 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.
*/
@@ -15,16 +15,16 @@
* Macro to connect the interrupt handler "routine" to the irq number "irq" and
* ensure it is enabled in the interrupt controller with the right priority.
*/
-#define DECLARE_IRQ(irq, routine, priority) \
- static void __keep routine(void); \
- void IRQ_HANDLER(irq)(void) \
- { \
- void *ret = __builtin_return_address(0); \
- task_start_irq_handler(ret); \
- routine(); \
- task_resched_if_needed(ret); \
- } \
- const struct irq_priority __keep IRQ_PRIORITY(irq) \
- __attribute__((section(".rodata.irqprio"))) \
- = {irq, priority}
-#endif /* __CROS_EC_IRQ_HANDLER_H */
+#define DECLARE_IRQ(irq, routine, priority) \
+ static void __keep routine(void); \
+ void IRQ_HANDLER(irq)(void) \
+ { \
+ void *ret = __builtin_return_address(0); \
+ task_start_irq_handler(ret); \
+ routine(); \
+ task_resched_if_needed(ret); \
+ } \
+ const struct irq_priority __keep IRQ_PRIORITY(irq) \
+ __attribute__((section(".rodata.irqprio"))) = { irq, \
+ priority }
+#endif /* __CROS_EC_IRQ_HANDLER_H */
diff --git a/core/host/main.c b/core/host/main.c
index ed7032eb63..1af5fa928c 100644
--- a/core/host/main.c
+++ b/core/host/main.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,7 +19,7 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
const char *__prog_name;
@@ -85,7 +85,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
* We lose the program name as LLVM fuzzer takes over main function:
* make up one.
*/
- static const char *name = STRINGIFY(PROJECT)".exe";
+ static const char *name = STRINGIFY(PROJECT) ".exe";
if (!initialized) {
__prog_name = name;
diff --git a/core/host/panic.c b/core/host/panic.c
index 7b0829989d..ed1994f82e 100644
--- a/core/host/panic.c
+++ b/core/host/panic.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,8 +11,8 @@
void panic_assert_fail(const char *msg, const char *func, const char *fname,
int linenum)
{
- fprintf(stderr, "ASSERTION FAIL: %s:%d:%s - %s\n",
- fname, linenum, func, msg);
+ fprintf(stderr, "ASSERTION FAIL: %s:%d:%s - %s\n", fname, linenum, func,
+ msg);
task_dump_trace();
puts("Fail!"); /* Inform test runner */
diff --git a/core/host/stack_trace.c b/core/host/stack_trace.c
index adef66dd44..f8918b1c57 100644
--- a/core/host/stack_trace.c
+++ b/core/host/stack_trace.c
@@ -1,4 +1,4 @@
-/* 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.
*/
@@ -44,9 +44,8 @@ static void __attribute__((noinline)) _task_dump_trace_impl(int offset)
for (i = 0; i < sz - offset; ++i) {
fprintf(stderr, "#%-2d %s\n", i, messages[i]);
- /* %p is correct (as opposed to %pP) since this is the host */
- sprintf(buf, "addr2line %p -e %s",
- trace[i + offset], __get_prog_name());
+ sprintf(buf, "addr2line %p -e %s", trace[i + offset],
+ __get_prog_name());
file = popen(buf, "r");
if (file) {
nb = fread(buf, 1, sizeof(buf) - 1, file);
@@ -77,8 +76,8 @@ static void __attribute__((noinline)) _task_dump_trace_dispatch(int sig)
} else if (in_interrupt_context()) {
fprintf(stderr, "Stack trace of ISR:\n");
} else {
- fprintf(stderr, "Stack trace of task %d (%s):\n",
- running, task_get_name(running));
+ fprintf(stderr, "Stack trace of task %d (%s):\n", running,
+ task_get_name(running));
}
if (need_dispatch) {
diff --git a/core/host/task.c b/core/host/task.c
index f8f8dfb661..3ba241198b 100644
--- a/core/host/task.c
+++ b/core/host/task.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.
*/
@@ -96,22 +96,18 @@ void _run_test(void *d)
run_test(0, NULL);
}
-#define TASK(n, r, d, s) {r, d},
+#define TASK(n, r, d, s) { r, d },
const struct task_args task_info[TASK_ID_COUNT] = {
- {__idle, NULL},
- CONFIG_TASK_LIST
- CONFIG_TEST_TASK_LIST
- CONFIG_CTS_TASK_LIST
- {_run_test, NULL},
+ { __idle, NULL },
+ CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST CONFIG_CTS_TASK_LIST{ _run_test,
+ NULL },
};
#undef TASK
#define TASK(n, r, d, s) #n,
-static const char * const task_names[] = {
+static const char *const task_names[] = {
"<< idle >>",
- CONFIG_TASK_LIST
- CONFIG_TEST_TASK_LIST
- CONFIG_CTS_TASK_LIST
+ CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST CONFIG_CTS_TASK_LIST
"<< test runner >>",
};
#undef TASK
@@ -319,14 +315,13 @@ void task_print_list(void)
}
}
-static int command_task_info(int argc, char **argv)
+static int command_task_info(int argc, const char **argv)
{
task_print_list();
return EC_SUCCESS;
}
-DECLARE_SAFE_CONSOLE_COMMAND(taskinfo, command_task_info,
- NULL,
+DECLARE_SAFE_CONSOLE_COMMAND(taskinfo, command_task_info, NULL,
"Print task info");
static void _wait_for_task_started(int can_sleep)
@@ -519,8 +514,8 @@ int task_start(void)
*/
pthread_mutex_lock(&interrupt_lock);
- pthread_create(&interrupt_thread, NULL,
- _task_int_generator_start, NULL);
+ pthread_create(&interrupt_thread, NULL, _task_int_generator_start,
+ NULL);
/*
* Tell the hooks task to continue so that it can call back to enable
@@ -557,7 +552,6 @@ static void task_enable_all_tasks_callback(void)
pthread_mutex_unlock(&interrupt_lock);
pthread_cond_wait(&scheduler_cond, &run_lock);
}
-
}
void task_enable_all_tasks(void)
diff --git a/core/host/timer.c b/core/host/timer.c
index 3c3695cad4..66f047cd4d 100644
--- a/core/host/timer.c
+++ b/core/host/timer.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.
*/
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <stdio.h>
+#include "builtin/assert.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -90,15 +91,12 @@ int timestamp_expired(timestamp_t deadline, const timestamp_t *now)
void timer_init(void)
{
-
if (!time_set) {
/*
* Start the timer just before the 64-bit rollover to try
* and catch 32-bit rollover/truncation bugs.
*/
- timestamp_t ts = {
- .val = 0xFFFFFFF0
- };
+ timestamp_t ts = { .val = 0xFFFFFFF0 };
force_time(ts);
}
diff --git a/core/host/toolchain.mk b/core/host/toolchain.mk
new file mode 100644
index 0000000000..168d0e24c2
--- /dev/null
+++ b/core/host/toolchain.mk
@@ -0,0 +1,9 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CROSS_COMPILE_HOST_DEFAULT:=x86_64-pc-linux-gnu-
+
+$(call set-option,CROSS_COMPILE,\
+ $(CROSS_COMPILE_host),\
+ $(CROSS_COMPILE_HOST_DEFAULT))