summaryrefslogtreecommitdiff
path: root/core/minute-ia
diff options
context:
space:
mode:
Diffstat (limited to 'core/minute-ia')
-rw-r--r--core/minute-ia/atomic.h10
-rw-r--r--core/minute-ia/build.mk6
-rw-r--r--core/minute-ia/config_core.h4
-rw-r--r--core/minute-ia/cpu.c3
-rw-r--r--core/minute-ia/cpu.h5
-rw-r--r--core/minute-ia/ec.lds.S12
-rw-r--r--core/minute-ia/ia_structs.h72
-rw-r--r--core/minute-ia/include/fpu.h125
-rw-r--r--core/minute-ia/init.S2
-rw-r--r--core/minute-ia/interrupts.c108
-rw-r--r--core/minute-ia/interrupts.h32
-rw-r--r--core/minute-ia/irq_handler.h48
-rw-r--r--core/minute-ia/irq_handler_common.S2
-rw-r--r--core/minute-ia/mia_panic_internal.h11
-rw-r--r--core/minute-ia/mpu.c2
-rw-r--r--core/minute-ia/panic.c35
-rw-r--r--core/minute-ia/switch.S2
-rw-r--r--core/minute-ia/task.c122
-rw-r--r--core/minute-ia/task_defs.h30
-rw-r--r--core/minute-ia/toolchain.mk7
20 files changed, 299 insertions, 339 deletions
diff --git a/core/minute-ia/atomic.h b/core/minute-ia/atomic.h
index dbcd04b7de..e722d799c8 100644
--- a/core/minute-ia/atomic.h
+++ b/core/minute-ia/atomic.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -13,13 +13,13 @@
#include "util.h"
static inline int bool_compare_and_swap_u32(uint32_t *var, uint32_t old_value,
- uint32_t new_value)
+ uint32_t new_value)
{
uint32_t _old_value = old_value;
__asm__ __volatile__(ASM_LOCK_PREFIX "cmpxchgl %2, %1"
- : "=a" (old_value), "+m" (*var)
- : "r" (new_value), "0" (old_value)
+ : "=a"(old_value), "+m"(*var)
+ : "r"(new_value), "0"(old_value)
: "memory");
return (_old_value == old_value);
@@ -65,4 +65,4 @@ static inline atomic_val_t atomic_clear(atomic_t *addr)
return __atomic_exchange_n(addr, 0, __ATOMIC_SEQ_CST);
}
-#endif /* __CROS_EC_ATOMIC_H */
+#endif /* __CROS_EC_ATOMIC_H */
diff --git a/core/minute-ia/build.mk b/core/minute-ia/build.mk
index b51512c16e..cd92c5618f 100644
--- a/core/minute-ia/build.mk
+++ b/core/minute-ia/build.mk
@@ -1,15 +1,11 @@
# -*- makefile -*-
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
+# Copyright 2016 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Minute-IA core build
#
-# Select Minute-IA bare-metal toolchain
-$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_i386),\
- /opt/coreboot-sdk/bin/i386-elf-)
-
# FPU compilation flags
CFLAGS_FPU-$(CONFIG_FPU)=
diff --git a/core/minute-ia/config_core.h b/core/minute-ia/config_core.h
index 47121642a4..1dce51720d 100644
--- a/core/minute-ia/config_core.h
+++ b/core/minute-ia/config_core.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -29,6 +29,6 @@
/*
* Flag indicates the task uses FPU H/W
*/
-#define MIA_TASK_FLAG_USE_FPU 0x00000001
+#define MIA_TASK_FLAG_USE_FPU 0x00000001
#endif /* __CROS_EC_CONFIG_CORE_H */
diff --git a/core/minute-ia/cpu.c b/core/minute-ia/cpu.c
index cef39fe1ce..0157fec90b 100644
--- a/core/minute-ia/cpu.c
+++ b/core/minute-ia/cpu.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -7,7 +7,6 @@
#include <cpu.h>
-
void cpu_init(void)
{
/* Nothing to do now */
diff --git a/core/minute-ia/cpu.h b/core/minute-ia/cpu.h
index 09eb50e4ca..bf5f3c5bbd 100644
--- a/core/minute-ia/cpu.h
+++ b/core/minute-ia/cpu.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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,5 @@
#ifndef __CROS_EC_CPU_H
#define __CROS_EC_CPU_H
-
void cpu_init(void);
-#endif /* __CROS_EC_CPU_H */
+#endif /* __CROS_EC_CPU_H */
diff --git a/core/minute-ia/ec.lds.S b/core/minute-ia/ec.lds.S
index beda1dbfae..be3e0fbf2e 100644
--- a/core/minute-ia/ec.lds.S
+++ b/core/minute-ia/ec.lds.S
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -156,6 +156,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 = .;
KEEP(*(.rodata.deferred))
__deferred_funcs_end = .;
@@ -216,6 +220,12 @@ SECTIONS
__bss_end = .;
__bss_size_words = ABSOLUTE((__bss_end - __bss_start) / 4);
+ /*
+ * _sbrk in newlib expects "end" symbol to point to start of
+ * free memory.
+ */
+ end = .;
+
/*
* Shared memory buffer must be at the end of
* preallocated RAM, so it can expand to use all the
diff --git a/core/minute-ia/ia_structs.h b/core/minute-ia/ia_structs.h
index 29bbb6c005..83214e2c1b 100644
--- a/core/minute-ia/ia_structs.h
+++ b/core/minute-ia/ia_structs.h
@@ -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.
*/
@@ -10,7 +10,6 @@
#include "common.h"
-
/**
* IA32/x86 architecture related data structure definitions.
* including: Global Descriptor Table (GDT), Local Descriptor Table (LDT),
@@ -24,16 +23,16 @@
struct gdt_entry {
union {
struct {
- uint32_t dword_lo; /* lower dword */
- uint32_t dword_up; /* upper dword */
+ uint32_t dword_lo; /* lower dword */
+ uint32_t dword_up; /* upper dword */
};
struct {
- uint16_t limit_lw; /* limit (0:15) */
- uint16_t base_addr_lw; /* base address (0:15) */
- uint8_t base_addr_mb; /* base address (16:23) */
- uint8_t flags; /* flags */
- uint8_t limit_ub; /* limit (16:19) */
- uint8_t base_addr_ub; /* base address (24:31) */
+ uint16_t limit_lw; /* limit (0:15) */
+ uint16_t base_addr_lw; /* base address (0:15) */
+ uint8_t base_addr_mb; /* base address (16:23) */
+ uint8_t flags; /* flags */
+ uint8_t limit_ub; /* limit (16:19) */
+ uint8_t base_addr_ub; /* base address (24:31) */
};
};
@@ -43,32 +42,32 @@ typedef struct gdt_entry ldt_entry;
/* GDT header */
struct gdt_header {
- uint16_t limit; /* GDT limit size */
- struct gdt_entry *entries; /* pointer to GDT entries */
+ uint16_t limit; /* GDT limit size */
+ struct gdt_entry *entries; /* pointer to GDT entries */
} __packed;
/* IDT entry descriptor */
struct idt_entry {
union {
struct {
- uint32_t dword_lo; /* lower dword */
- uint32_t dword_up; /* upper dword */
+ uint32_t dword_lo; /* lower dword */
+ uint32_t dword_up; /* upper dword */
};
struct {
- uint16_t offset_lw; /* offset (0:15) */
- uint16_t seg_selector; /* segment selector */
- uint8_t zero; /* must be set to zero */
- uint8_t flags; /* flags */
- uint16_t offset_uw; /* offset (16:31) */
+ uint16_t offset_lw; /* offset (0:15) */
+ uint16_t seg_selector; /* segment selector */
+ uint8_t zero; /* must be set to zero */
+ uint8_t flags; /* flags */
+ uint16_t offset_uw; /* offset (16:31) */
};
};
} __packed;
/* IDT header */
struct idt_header {
- uint16_t limit; /* IDT limit size */
- struct idt_entry *entries; /* pointer to IDT entries */
+ uint16_t limit; /* IDT limit size */
+ struct idt_entry *entries; /* pointer to IDT entries */
} __packed;
/* TSS entry descriptor */
@@ -117,22 +116,22 @@ struct tss_entry {
#endif
/* code segment flag, E/R, Present = 1, DPL = 0, Acesssed = 1 */
-#define GDT_DESC_CODE_FLAGS (0x9B)
+#define GDT_DESC_CODE_FLAGS (0x9B)
/* data segment flag, R/W, Present = 1, DPL = 0, Acesssed = 1 */
-#define GDT_DESC_DATA_FLAGS (0x93)
+#define GDT_DESC_DATA_FLAGS (0x93)
/* TSS segment limit size */
-#define GDT_DESC_TSS_LIMIT (0x67)
+#define GDT_DESC_TSS_LIMIT (0x67)
/* TSS segment flag, Present = 1, DPL = 0, Acesssed = 1 */
-#define GDT_DESC_TSS_FLAGS (0x89)
+#define GDT_DESC_TSS_FLAGS (0x89)
/* LDT segment flag, Present = 1, DPL = 0 */
-#define GDT_DESC_LDT_FLAGS (0x82)
+#define GDT_DESC_LDT_FLAGS (0x82)
/* IDT descriptor flag, Present = 1, DPL = 0, 32-bit interrupt gate */
-#define IDT_DESC_FLAGS (0x8E)
+#define IDT_DESC_FLAGS (0x8E)
/**
* macros helper to create a GDT entry descriptor
@@ -141,21 +140,20 @@ struct tss_entry {
* limit: 32bit limit size of bytes (will covert to unit of 4096-byte pages)
* flags: 8bit flags
*/
-#define GEN_GDT_DESC_LO(base, limit, flags) \
- ((((limit) >> 12) & 0xFFFF) | (((base) & 0xFFFF) << 16))
-
-#define GEN_GDT_DESC_UP(base, limit, flags) \
- ((((base) >> 16) & 0xFF) | (((flags) << 8) & 0xFF00) | \
- (((limit) >> 12) & 0xFF0000) | ((base) & 0xFF000000) | 0xc00000)
+#define GEN_GDT_DESC_LO(base, limit, flags) \
+ ((((limit) >> 12) & 0xFFFF) | (((base)&0xFFFF) << 16))
+#define GEN_GDT_DESC_UP(base, limit, flags) \
+ ((((base) >> 16) & 0xFF) | (((flags) << 8) & 0xFF00) | \
+ (((limit) >> 12) & 0xFF0000) | ((base)&0xFF000000) | 0xc00000)
/**
* macro helper to create a IDT entry descriptor
*/
-#define GEN_IDT_DESC_LO(offset, selector, flags) \
- (((uint32_t)(offset) & 0xFFFF) | (((selector) & 0xFFFF) << 16))
+#define GEN_IDT_DESC_LO(offset, selector, flags) \
+ (((uint32_t)(offset)&0xFFFF) | (((selector)&0xFFFF) << 16))
-#define GEN_IDT_DESC_UP(offset, selector, flags) \
- (((uint32_t)(offset) & 0xFFFF0000) | (((flags) & 0xFF) << 8))
+#define GEN_IDT_DESC_UP(offset, selector, flags) \
+ (((uint32_t)(offset)&0xFFFF0000) | (((flags)&0xFF) << 8))
#endif /* __CROS_EC_IA_STRUCTS_H */
diff --git a/core/minute-ia/include/fpu.h b/core/minute-ia/include/fpu.h
index 553807352a..9c0e818099 100644
--- a/core/minute-ia/include/fpu.h
+++ b/core/minute-ia/include/fpu.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,19 +12,15 @@
#ifdef CONFIG_FPU
-#define M_PI 3.14159265358979323846
-#define M_PI_2 1.57079632679489661923
+#define M_PI 3.14159265358979323846
+#define M_PI_2 1.57079632679489661923
static inline float sqrtf(float v)
{
float root;
/* root = fsqart (v); */
- asm volatile(
- "fsqrt"
- : "=t" (root)
- : "0" (v)
- );
+ asm volatile("fsqrt" : "=t"(root) : "0"(v));
return root;
}
@@ -34,11 +30,7 @@ static inline float fabsf(float v)
float root;
/* root = fabs (v); */
- asm volatile(
- "fabs"
- : "=t" (root)
- : "0" (v)
- );
+ asm volatile("fabs" : "=t"(root) : "0"(v));
return root;
}
@@ -51,12 +43,11 @@ static inline float logf(float v)
{
float res;
- asm volatile(
- "fldln2\n"
- "fxch\n"
- "fyl2x\n"
- : "=t" (res)
- : "0" (v));
+ asm volatile("fldln2\n"
+ "fxch\n"
+ "fyl2x\n"
+ : "=t"(res)
+ : "0"(v));
return res;
}
@@ -70,20 +61,19 @@ static inline float expf(float v)
{
float res;
- asm volatile(
- "fldl2e\n"
- "fmulp\n"
- "fld %%st(0)\n"
- "frndint\n"
- "fsubr %%st(0),%%st(1)\n" /* bug-binutils/19054 */
- "fxch %%st(1)\n"
- "f2xm1\n"
- "fld1\n"
- "faddp\n"
- "fscale\n"
- "fstp %%st(1)\n"
- : "=t" (res)
- : "0" (v));
+ asm volatile("fldl2e\n"
+ "fmulp\n"
+ "fld %%st(0)\n"
+ "frndint\n"
+ "fsubr %%st(0),%%st(1)\n" /* bug-binutils/19054 */
+ "fxch %%st(1)\n"
+ "f2xm1\n"
+ "fld1\n"
+ "faddp\n"
+ "fscale\n"
+ "fstp %%st(1)\n"
+ : "=t"(res)
+ : "0"(v));
return res;
}
@@ -97,24 +87,23 @@ static inline float powf(float x, float y)
{
float res;
- asm volatile(
- "fyl2x\n"
- "fld %%st(0)\n"
- "frndint\n"
- "fsub %%st,%%st(1)\n"
- "fxch\n"
- "fchs\n"
- "f2xm1\n"
- "fld1\n"
- "faddp\n"
- "fxch\n"
- "fld1\n"
- "fscale\n"
- "fstp %%st(1)\n"
- "fmulp\n"
- : "=t" (res)
- : "0" (x), "u" (y)
- : "st(1)");
+ asm volatile("fyl2x\n"
+ "fld %%st(0)\n"
+ "frndint\n"
+ "fsub %%st,%%st(1)\n"
+ "fxch\n"
+ "fchs\n"
+ "f2xm1\n"
+ "fld1\n"
+ "faddp\n"
+ "fxch\n"
+ "fld1\n"
+ "fscale\n"
+ "fstp %%st(1)\n"
+ "fmulp\n"
+ : "=t"(res)
+ : "0"(x), "u"(y)
+ : "st(1)");
return res;
}
@@ -125,16 +114,15 @@ static inline float ceilf(float v)
float res;
unsigned short control_word, control_word_tmp;
- asm volatile("fnstcw %0" : "=m" (control_word));
+ asm volatile("fnstcw %0" : "=m"(control_word));
/* Set Rounding Mode to 10B, round up toward +infinity */
control_word_tmp = (control_word | 0x0800) & 0xfbff;
- asm volatile(
- "fld %3\n"
- "fldcw %1\n"
- "frndint\n"
- "fldcw %2"
- : "=t" (res)
- : "m" (control_word_tmp), "m"(control_word), "m" (v));
+ asm volatile("fld %3\n"
+ "fldcw %1\n"
+ "frndint\n"
+ "fldcw %2"
+ : "=t"(res)
+ : "m"(control_word_tmp), "m"(control_word), "m"(v));
return res;
}
@@ -144,7 +132,7 @@ static inline float atan2f(float y, float x)
{
float res;
- asm volatile("fpatan" : "=t" (res) : "0" (x), "u" (y) : "st(1)");
+ asm volatile("fpatan" : "=t"(res) : "0"(x), "u"(y) : "st(1)");
return res;
}
@@ -154,11 +142,10 @@ static inline float atanf(float v)
{
float res;
- asm volatile(
- "fld1\n"
- "fpatan\n"
- : "=t" (res)
- : "0" (v));
+ asm volatile("fld1\n"
+ "fpatan\n"
+ : "=t"(res)
+ : "0"(v));
return res;
}
@@ -168,7 +155,7 @@ static inline float sinf(float v)
{
float res;
- asm volatile("fsin" : "=t" (res) : "0" (v));
+ asm volatile("fsin" : "=t"(res) : "0"(v));
return res;
}
@@ -178,7 +165,7 @@ static inline float cosf(float v)
{
float res;
- asm volatile("fcos" : "=t" (res) : "0" (v));
+ asm volatile("fcos" : "=t"(res) : "0"(v));
return res;
}
@@ -189,5 +176,5 @@ static inline float acosf(float v)
return atan2f(sqrtf(1.0 - v * v), v);
}
-#endif /* CONFIG_FPU */
-#endif /* __CROS_EC_FPU_H */
+#endif /* CONFIG_FPU */
+#endif /* __CROS_EC_FPU_H */
diff --git a/core/minute-ia/init.S b/core/minute-ia/init.S
index b8e51ccc91..4d3ac47da6 100644
--- a/core/minute-ia/init.S
+++ b/core/minute-ia/init.S
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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/minute-ia/interrupts.c b/core/minute-ia/interrupts.c
index 2d55d3129e..34baa68fa8 100644
--- a/core/minute-ia/interrupts.c
+++ b/core/minute-ia/interrupts.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -20,8 +20,8 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
/* The IDT - initialized in init.S */
extern struct idt_entry __idt[NUM_VECTORS];
@@ -54,7 +54,7 @@ static void set_ioapic_redtbl_raw(const uint32_t irq, const uint32_t val)
* bitmap for current IRQ's mask status
* ISH support max 64 IRQs, 64 bit bitmap value is ok
*/
-#define ISH_MAX_IOAPIC_IRQS (64)
+#define ISH_MAX_IOAPIC_IRQS (64)
uint64_t ioapic_irq_mask_bitmap;
/**
@@ -70,7 +70,7 @@ uint64_t disable_all_interrupts(void)
uint64_t saved_map;
int i;
- saved_map = ioapic_irq_mask_bitmap;
+ saved_map = ioapic_irq_mask_bitmap;
for (i = 0; i < ISH_MAX_IOAPIC_IRQS; i++) {
if (((uint64_t)0x1 << i) & saved_map)
@@ -179,27 +179,27 @@ static const irq_desc_t system_irqs[] = {
* and go directly to the CPU core, so get_current_interrupt_vector
* cannot be used.
*/
-#define DEFINE_EXN_HANDLER(vector) \
+#define DEFINE_EXN_HANDLER(vector) \
_DEFINE_EXN_HANDLER(vector, exception_panic_##vector)
-#define _DEFINE_EXN_HANDLER(vector, name) \
- void __keep name(void); \
- noreturn void name(void) \
- { \
- __asm__ ("push $0\n" \
- "push $" #vector "\n" \
- "call exception_panic\n"); \
- __builtin_unreachable(); \
+#define _DEFINE_EXN_HANDLER(vector, name) \
+ void __keep name(void); \
+ noreturn void name(void) \
+ { \
+ __asm__("push $0\n" \
+ "push $" #vector "\n" \
+ "call exception_panic\n"); \
+ __builtin_unreachable(); \
}
-#define DEFINE_EXN_HANDLER_W_ERRORCODE(vector) \
+#define DEFINE_EXN_HANDLER_W_ERRORCODE(vector) \
_DEFINE_EXN_HANDLER_W_ERRORCODE(vector, exception_panic_##vector)
-#define _DEFINE_EXN_HANDLER_W_ERRORCODE(vector, name) \
- void __keep name(void); \
- noreturn void name(void) \
- { \
- __asm__ ("push $" #vector "\n" \
- "call exception_panic\n"); \
- __builtin_unreachable(); \
+#define _DEFINE_EXN_HANDLER_W_ERRORCODE(vector, name) \
+ void __keep name(void); \
+ noreturn void name(void) \
+ { \
+ __asm__("push $" #vector "\n" \
+ "call exception_panic\n"); \
+ __builtin_unreachable(); \
}
DEFINE_EXN_HANDLER(0);
@@ -228,15 +228,10 @@ DEFINE_EXN_HANDLER(20);
* watchdog timer expiration. However, this time, hardware does not
* push errorcode, and we must account for that by pushing zero.
*/
-noreturn __keep
-void exception_panic_wdt(uint32_t cs)
+noreturn __keep void exception_panic_wdt(uint32_t cs)
{
- exception_panic(
- CONFIG_MIA_WDT_VEC,
- 0,
- (uint32_t)__builtin_return_address(0),
- cs,
- 0);
+ exception_panic(CONFIG_MIA_WDT_VEC, 0,
+ (uint32_t)__builtin_return_address(0), cs, 0);
}
void set_interrupt_gate(uint8_t num, isr_handler_t func, uint8_t flags)
@@ -244,7 +239,7 @@ void set_interrupt_gate(uint8_t num, isr_handler_t func, uint8_t flags)
uint16_t code_segment;
/* When the flat model is used the CS will never change. */
- __asm volatile ("mov %%cs, %0":"=r" (code_segment));
+ __asm volatile("mov %%cs, %0" : "=r"(code_segment));
__idt[num].dword_lo = GEN_IDT_DESC_LO(func, code_segment, flags);
__idt[num].dword_up = GEN_IDT_DESC_UP(func, code_segment, flags);
@@ -384,26 +379,28 @@ void handle_lapic_lvt_error(void)
/* LAPIC LVT error is not an IRQ and can not use DECLARE_IRQ() to call. */
void _lapic_error_handler(void);
-__asm__ (
- ".section .text._lapic_error_handler\n"
+__asm__(".section .text._lapic_error_handler\n"
"_lapic_error_handler:\n"
- "pusha\n"
- ASM_LOCK_PREFIX "addl $1, __in_isr\n"
- "movl %esp, %eax\n"
- "movl $stack_end, %esp\n"
- "push %eax\n"
+ "pusha\n" ASM_LOCK_PREFIX "addl $1, __in_isr\n"
+ "movl %esp, %eax\n"
+ "movl $stack_end, %esp\n"
+ "push %eax\n"
#ifdef CONFIG_TASK_PROFILING
- "push $" STRINGIFY(CONFIG_IRQ_COUNT) "\n"
- "call task_start_irq_handler\n"
- "addl $0x04, %esp\n"
+ "push $" STRINGIFY(
+ CONFIG_IRQ_COUNT) "\n"
+ "call task_start_irq_handler\n"
+ "addl $0x04, %esp\n"
#endif
- "call handle_lapic_lvt_error\n"
- "pop %esp\n"
- "movl $0x00, (0xFEE000B0)\n" /* Set EOI for LAPIC */
- ASM_LOCK_PREFIX "subl $1, __in_isr\n"
- "popa\n"
- "iret\n"
- );
+ "call handle_lapic_lvt_error\n"
+ "pop %esp\n"
+ "movl $0x00, (0xFEE000B0)\n" /* Set
+ EOI
+ for
+ LAPIC
+ */
+ ASM_LOCK_PREFIX "subl $1, __in_isr\n"
+ "popa\n"
+ "iret\n");
/* Should only be called in interrupt context */
void unhandled_vector(void)
@@ -411,7 +408,7 @@ void unhandled_vector(void)
uint32_t vec = get_current_interrupt_vector();
CPRINTF("Ignoring vector 0x%0x!\n", vec);
/* Put the vector number in eax so default_int_handler can use it */
- asm("" : : "a" (vec));
+ asm("" : : "a"(vec));
}
/**
@@ -454,8 +451,7 @@ void init_interrupts(void)
/* Setup gates for IRQs declared by drivers using DECLARE_IRQ */
for (p = __irq_data; p < __irq_data_end; p++)
- set_interrupt_gate(IRQ_TO_VEC(p->irq),
- p->handler,
+ set_interrupt_gate(IRQ_TO_VEC(p->irq), p->handler,
IDT_DESC_FLAGS);
/* Software generated IRQ */
@@ -474,11 +470,11 @@ void init_interrupts(void)
for (entry = 0; entry < num_system_irqs; entry++)
set_ioapic_redtbl_raw(system_irqs[entry].irq,
system_irqs[entry].vector |
- IOAPIC_REDTBL_DELMOD_FIXED |
- IOAPIC_REDTBL_DESTMOD_PHYS |
- IOAPIC_REDTBL_MASK |
- system_irqs[entry].polarity |
- system_irqs[entry].trigger);
+ IOAPIC_REDTBL_DELMOD_FIXED |
+ IOAPIC_REDTBL_DESTMOD_PHYS |
+ IOAPIC_REDTBL_MASK |
+ system_irqs[entry].polarity |
+ system_irqs[entry].trigger);
set_interrupt_gate(ISH_TS_VECTOR, __switchto, IDT_DESC_FLAGS);
diff --git a/core/minute-ia/interrupts.h b/core/minute-ia/interrupts.h
index 3a951a5ddb..65b26c437e 100644
--- a/core/minute-ia/interrupts.h
+++ b/core/minute-ia/interrupts.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -11,7 +11,7 @@
#ifndef __ASSEMBLER__
#include <stdint.h>
-#define USHRT_MAX 0xFFFF
+#define USHRT_MAX 0xFFFF
typedef struct {
unsigned irq;
unsigned trigger;
@@ -19,13 +19,11 @@ typedef struct {
unsigned vector;
} irq_desc_t;
-#define INTR_DESC(__irq,__vector,__trig) \
- { \
- .irq = __irq, \
- .trigger = __trig, \
- .polarity = IOAPIC_REDTBL_INTPOL_HIGH, \
- .vector = __vector \
- }
+#define INTR_DESC(__irq, __vector, __trig) \
+ { \
+ .irq = __irq, .trigger = __trig, \
+ .polarity = IOAPIC_REDTBL_INTPOL_HIGH, .vector = __vector \
+ }
#define LEVEL_INTR(__irq, __vector) \
INTR_DESC(__irq, __vector, IOAPIC_REDTBL_TRIGGER_LEVEL)
@@ -34,18 +32,18 @@ typedef struct {
#endif
/* ISH has a single core processor */
-#define DEST_APIC_ID 0
-#define NUM_VECTORS 256
+#define DEST_APIC_ID 0
+#define NUM_VECTORS 256
/* APIC bit definitions. */
-#define APIC_DIV_16 0x03
-#define APIC_ENABLE_BIT (1UL << 8UL)
-#define APIC_SPURIOUS_INT REG32(ISH_LAPIC_BASE + 0xF0UL )
-#define APIC_LVT_ERROR REG32(ISH_LAPIC_BASE + 0x370UL)
+#define APIC_DIV_16 0x03
+#define APIC_ENABLE_BIT (1UL << 8UL)
+#define APIC_SPURIOUS_INT REG32(ISH_LAPIC_BASE + 0xF0UL)
+#define APIC_LVT_ERROR REG32(ISH_LAPIC_BASE + 0x370UL)
#ifndef __ASSEMBLER__
-typedef void (*isr_handler_t) (void);
+typedef void (*isr_handler_t)(void);
void init_interrupts(void);
void mask_interrupt(unsigned int irq);
@@ -66,4 +64,4 @@ void restore_interrupts(uint64_t irq_map);
uint32_t get_current_interrupt_vector(void);
#endif
-#endif /* __CROS_EC_IA32_INTERRUPTS_H */
+#endif /* __CROS_EC_IA32_INTERRUPTS_H */
diff --git a/core/minute-ia/irq_handler.h b/core/minute-ia/irq_handler.h
index 30106603d6..deb8048e12 100644
--- a/core/minute-ia/irq_handler.h
+++ b/core/minute-ia/irq_handler.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,7 +12,7 @@
#include "task.h"
#include "task_defs.h"
-asm (".include \"core/minute-ia/irq_handler_common.S\"");
+asm(".include \"core/minute-ia/irq_handler_common.S\"");
/* Helper macros to build the IRQ handler and priority struct names */
#define IRQ_HANDLER(irqname) CONCAT3(_irq_, irqname, _handler)
@@ -30,26 +30,24 @@ asm (".include \"core/minute-ia/irq_handler_common.S\"");
* Each irq has a irq_data structure placed in .rodata.irqs section,
* to be used for dynamically setting up interrupt gates
*/
-#define DECLARE_IRQ_(irq_, routine_, vector) \
- static void __keep routine_(void); \
- void IRQ_HANDLER(irq_)(void); \
- __asm__ (".section .rodata.irqs\n"); \
- const struct irq_def __keep CONCAT4(__irq_, irq_, _, routine_) \
- __attribute__((section(".rodata.irqs"))) = { \
- .irq = irq_, \
- .routine = routine_, \
- .handler = IRQ_HANDLER(irq_) \
- }; \
- __asm__ ( \
- ".section .text._irq_" #irq_ "_handler\n" \
- "_irq_" #irq_ "_handler:\n" \
- "pusha\n" \
- ASM_LOCK_PREFIX "addl $1, __in_isr\n" \
- "irq_handler_common $0 $0 $" #irq_ "\n" \
- "movl $"#vector ", " STRINGIFY(IOAPIC_EOI_REG_ADDR) "\n" \
- "movl $0x00, " STRINGIFY(LAPIC_EOI_REG_ADDR) "\n" \
- ASM_LOCK_PREFIX "subl $1, __in_isr\n" \
- "popa\n" \
- "iret\n" \
- )
-#endif /* __CROS_EC_IRQ_HANDLER_H */
+#define DECLARE_IRQ_(irq_, routine_, vector) \
+ static void __keep routine_(void); \
+ void IRQ_HANDLER(irq_)(void); \
+ __asm__(".section .rodata.irqs\n"); \
+ const struct irq_def __keep CONCAT4(__irq_, irq_, _, routine_) \
+ __attribute__((section( \
+ ".rodata.irqs"))) = { .irq = irq_, \
+ .routine = routine_, \
+ .handler = IRQ_HANDLER(irq_) }; \
+ __asm__(".section .text._irq_" #irq_ "_handler\n" \
+ "_irq_" #irq_ "_handler:\n" \
+ "pusha\n" ASM_LOCK_PREFIX "addl $1, __in_isr\n" \
+ "irq_handler_common $0 $0 $" #irq_ "\n" \
+ "movl $" #vector ", " STRINGIFY( \
+ IOAPIC_EOI_REG_ADDR) "\n" \
+ "movl $0x00, " STRINGIFY( \
+ LAPIC_EOI_REG_ADDR) "\n" ASM_LOCK_PREFIX \
+ "subl $1, __in_isr\n" \
+ "popa\n" \
+ "iret\n")
+#endif /* __CROS_EC_IRQ_HANDLER_H */
diff --git a/core/minute-ia/irq_handler_common.S b/core/minute-ia/irq_handler_common.S
index e07cf26ce1..2445f83730 100644
--- a/core/minute-ia/irq_handler_common.S
+++ b/core/minute-ia/irq_handler_common.S
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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/minute-ia/mia_panic_internal.h b/core/minute-ia/mia_panic_internal.h
index 748ccbf2dd..d9d213ca85 100644
--- a/core/minute-ia/mia_panic_internal.h
+++ b/core/minute-ia/mia_panic_internal.h
@@ -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.
*/
@@ -8,10 +8,5 @@
* convenientely in the same order as pushed by hardwared during a
* processor exception.
*/
-noreturn
-void exception_panic(
- uint32_t vector,
- uint32_t errorcode,
- uint32_t eip,
- uint32_t cs,
- uint32_t eflags);
+noreturn void exception_panic(uint32_t vector, uint32_t errorcode, uint32_t eip,
+ uint32_t cs, uint32_t eflags);
diff --git a/core/minute-ia/mpu.c b/core/minute-ia/mpu.c
index 389668ea6f..d91d71f99c 100644
--- a/core/minute-ia/mpu.c
+++ b/core/minute-ia/mpu.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/core/minute-ia/panic.c b/core/minute-ia/panic.c
index b4299d9e17..d02778891d 100644
--- a/core/minute-ia/panic.c
+++ b/core/minute-ia/panic.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -57,13 +57,12 @@ void panic_data_print(const struct panic_data *pdata)
else if (pdata->x86.vector <= 20)
panic_printf("Reason: %s\n", panic_reason[pdata->x86.vector]);
else if (panic_sw_reason_is_valid(pdata->x86.vector)) {
- panic_printf("Software panic reason %s\n",
- panic_sw_reasons[pdata->x86.vector -
- PANIC_SW_BASE]);
+ panic_printf(
+ "Software panic reason %s\n",
+ panic_sw_reasons[pdata->x86.vector - PANIC_SW_BASE]);
panic_printf("Software panic info 0x%x\n",
pdata->x86.error_code);
- }
- else
+ } else
panic_printf("Interrupt vector number: 0x%08X (unknown)\n",
pdata->x86.vector);
panic_printf("\n");
@@ -91,12 +90,8 @@ void panic_data_print(const struct panic_data *pdata)
* order pushed to the stack by hardware: see "Intel 64 and IA-32
* Architectures Software Developer's Manual", Volume 3A, Figure 6-4.
*/
-void exception_panic(
- uint32_t vector,
- uint32_t error_code,
- uint32_t eip,
- uint32_t cs,
- uint32_t eflags)
+void exception_panic(uint32_t vector, uint32_t error_code, uint32_t eip,
+ uint32_t cs, uint32_t eflags)
{
/*
* If a panic were to occur during the reset procedure, we want
@@ -176,26 +171,22 @@ void exception_panic(
__builtin_unreachable();
}
-noreturn
-void software_panic(uint32_t reason, uint32_t info)
+noreturn void software_panic(uint32_t reason, uint32_t info)
{
uint16_t code_segment;
/* Get the current code segment */
- __asm__ volatile ("movw %%cs, %0":"=m" (code_segment));
+ __asm__ volatile("movw %%cs, %0" : "=m"(code_segment));
- exception_panic(reason,
- info,
- (uint32_t)__builtin_return_address(0),
- code_segment,
- 0);
+ exception_panic(reason, info, (uint32_t)__builtin_return_address(0),
+ code_segment, 0);
__builtin_unreachable();
}
void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
{
- struct panic_data * const pdata = get_panic_data_write();
+ struct panic_data *const pdata = get_panic_data_write();
/* Setup panic data structure */
memset(pdata, 0, CONFIG_PANIC_DATA_SIZE);
@@ -212,7 +203,7 @@ void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
void panic_get_reason(uint32_t *reason, uint32_t *info, uint8_t *exception)
{
- struct panic_data * const pdata = panic_get_data();
+ struct panic_data *const pdata = panic_get_data();
if (pdata && pdata->struct_version == 2) {
*reason = pdata->x86.vector;
diff --git a/core/minute-ia/switch.S b/core/minute-ia/switch.S
index cec3f904f9..b014bb4c29 100644
--- a/core/minute-ia/switch.S
+++ b/core/minute-ia/switch.S
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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/minute-ia/task.c b/core/minute-ia/task.c
index 4eb33e295a..79ce82fd89 100644
--- a/core/minute-ia/task.c
+++ b/core/minute-ia/task.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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 @@
#define TEST_TASK_EXTRA_ARGS 0
#include "atomic.h"
+#include "builtin/assert.h"
#include "common.h"
#include "console.h"
#include "link_defs.h"
@@ -26,8 +27,8 @@
/* Console output macros */
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
/* Value to store in unused stack */
#define STACK_UNUSED_VALUE 0xdeadd00d
@@ -43,11 +44,9 @@ CONFIG_TEST_TASK_LIST
extern volatile uint32_t __in_isr;
/* Task names for easier debugging */
-#define TASK(n, r, d, s, f) #n,
-static const char * const task_names[] = {
- "<< idle >>",
- CONFIG_TASK_LIST
- CONFIG_TEST_TASK_LIST
+#define TASK(n, r, d, s, f) #n,
+static const char *const task_names[] = {
+ "<< idle >>", CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST
};
#undef TASK
@@ -57,12 +56,12 @@ static uint64_t task_start_time; /* Time task scheduling started */
* We only keep 32-bit values for exception start/end time, to avoid
* accounting errors when we service interrupt when the timer wraps around.
*/
-static uint32_t exc_start_time; /* Time of task->exception transition */
-static uint32_t exc_end_time; /* Time of exception->task transition */
-static uint64_t exc_total_time; /* Total time in exceptions */
-static atomic_t svc_calls; /* Number of service calls */
-static uint32_t task_switches; /* Number of times active task changed */
-static uint32_t irq_dist[CONFIG_IRQ_COUNT]; /* Distribution of IRQ calls */
+static uint32_t exc_start_time; /* Time of task->exception transition */
+static uint32_t exc_end_time; /* Time of exception->task transition */
+static uint64_t exc_total_time; /* Total time in exceptions */
+static atomic_t svc_calls; /* Number of service calls */
+static uint32_t task_switches; /* Number of times active task changed */
+static uint32_t irq_dist[CONFIG_IRQ_COUNT]; /* Distribution of IRQ calls */
#endif
void __schedule(int desched, int resched);
@@ -97,22 +96,20 @@ static void task_exit_trap(void)
}
/* Startup parameters for all tasks. */
-#define TASK(n, r, d, s, f) { \
- .r0 = (uint32_t)d, \
- .pc = (uint32_t)r, \
- .stack_size = s, \
- .flags = f, \
-},
+#define TASK(n, r, d, s, f) \
+ { \
+ .r0 = (uint32_t)d, \
+ .pc = (uint32_t)r, \
+ .stack_size = s, \
+ .flags = f, \
+ },
static const struct {
uint32_t r0;
uint32_t pc;
uint16_t stack_size;
uint32_t flags;
-} tasks_init[] = {
- TASK(IDLE, __idle, 0, IDLE_TASK_STACK_SIZE, 0)
- CONFIG_TASK_LIST
- CONFIG_TEST_TASK_LIST
-};
+} tasks_init[] = { TASK(IDLE, __idle, 0, IDLE_TASK_STACK_SIZE, 0)
+ CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST };
#undef TASK
@@ -122,18 +119,13 @@ static task_ tasks[TASK_ID_COUNT];
BUILD_ASSERT(TASK_ID_COUNT <= sizeof(unsigned) * 8);
BUILD_ASSERT(TASK_ID_COUNT < (1 << (sizeof(task_id_t) * 8)));
-
/* Stacks for all tasks */
-#define TASK(n, r, d, s, f) + s
-uint8_t task_stacks[0
- TASK(IDLE, __idle, 0, IDLE_TASK_STACK_SIZE, 0)
- CONFIG_TASK_LIST
- CONFIG_TEST_TASK_LIST
-] __aligned(8);
+#define TASK(n, r, d, s, f) +s
+uint8_t task_stacks[0 TASK(IDLE, __idle, 0, IDLE_TASK_STACK_SIZE, 0)
+ CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST] __aligned(8);
#undef TASK
-
task_ *current_task, *next_task;
/*
@@ -151,7 +143,7 @@ static atomic_t tasks_ready = BIT(TASK_ID_HOOKS);
*/
static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE);
-static int start_called; /* Has task swapping started */
+static int start_called; /* Has task swapping started */
static inline task_ *__task_id_to_ptr(task_id_t id)
{
@@ -160,7 +152,7 @@ static inline task_ *__task_id_to_ptr(task_id_t id)
void interrupt_disable(void)
{
- __asm__ __volatile__ ("cli");
+ __asm__ __volatile__("cli");
}
void interrupt_enable(void)
@@ -170,16 +162,16 @@ void interrupt_enable(void)
*/
ASSERT(task_start_called() != 1);
- __asm__ __volatile__ ("sti");
+ __asm__ __volatile__("sti");
}
inline bool is_interrupt_enabled(void)
{
uint32_t eflags = 0;
- __asm__ __volatile__ ("pushfl\n"
- "popl %0\n"
- : "=r"(eflags));
+ __asm__ __volatile__("pushfl\n"
+ "popl %0\n"
+ : "=r"(eflags));
/* Check Interrupt Enable flag */
return eflags & 0x200;
@@ -251,8 +243,7 @@ uint32_t switch_handler(int desched, task_id_t resched)
next = __task_id_to_ptr(__fls(tasks_ready & tasks_enabled));
/* Only the first ISR on the (nested IRQ) stack calculates time */
- if (IS_ENABLED(CONFIG_TASK_PROFILING) &&
- __in_isr == 1) {
+ if (IS_ENABLED(CONFIG_TASK_PROFILING) && __in_isr == 1) {
/* Track time in interrupts */
uint32_t t = get_time().le.lo;
@@ -465,11 +456,10 @@ void mutex_lock(struct mutex *mtx)
do {
old_val = 0;
- __asm__ __volatile__(
- ASM_LOCK_PREFIX "cmpxchg %1, %2\n"
- : "=a" (old_val)
- : "r" (value), "m" (mtx->lock), "a" (old_val)
- : "memory");
+ __asm__ __volatile__(ASM_LOCK_PREFIX "cmpxchg %1, %2\n"
+ : "=a"(old_val)
+ : "r"(value), "m"(mtx->lock), "a"(old_val)
+ : "memory");
if (old_val != 0) {
/* Contention on the mutex */
@@ -486,11 +476,10 @@ void mutex_unlock(struct mutex *mtx)
uint32_t old_val = 1, val = 0;
task_ *tsk = current_task;
- __asm__ __volatile__(
- ASM_LOCK_PREFIX "cmpxchg %1, %2\n"
- : "=a" (old_val)
- : "r" (val), "m" (mtx->lock), "a" (old_val)
- : "memory");
+ __asm__ __volatile__(ASM_LOCK_PREFIX "cmpxchg %1, %2\n"
+ : "=a"(old_val)
+ : "r"(val), "m"(mtx->lock), "a"(old_val)
+ : "memory");
if (old_val == 1)
waiters = mtx->waiters;
/* else? Does unlock fail - what to do then ? */
@@ -532,13 +521,13 @@ void task_print_list(void)
if (IS_ENABLED(CONFIG_FPU)) {
char use_fpu = tasks[i].use_fpu ? 'Y' : 'N';
- ccprintf("%4d %c %-16s %08x %11.6lld %3d/%3d %c\n",
- i, is_ready, task_get_name(i),
+ ccprintf("%4d %c %-16s %08x %11.6lld %3d/%3d %c\n", i,
+ is_ready, task_get_name(i),
(int)tasks[i].events, tasks[i].runtime,
stackused, tasks_init[i].stack_size, use_fpu);
} else {
- ccprintf("%4d %c %-16s %08x %11.6lld %3d/%3d\n",
- i, is_ready, task_get_name(i),
+ ccprintf("%4d %c %-16s %08x %11.6lld %3d/%3d\n", i,
+ is_ready, task_get_name(i),
(int)tasks[i].events, tasks[i].runtime,
stackused, tasks_init[i].stack_size);
}
@@ -547,7 +536,7 @@ 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();
@@ -577,12 +566,9 @@ static int command_task_info(int argc, char **argv)
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(taskinfo, command_task_info,
- NULL,
- "Print task info");
+DECLARE_CONSOLE_COMMAND(taskinfo, command_task_info, NULL, "Print task info");
-__maybe_unused
-static int command_task_ready(int argc, char **argv)
+__maybe_unused static int command_task_ready(int argc, const char **argv)
{
if (argc < 2) {
ccprintf("tasks_ready: 0x%08x\n", (int)tasks_ready);
@@ -596,8 +582,7 @@ static int command_task_ready(int argc, char **argv)
}
#ifdef CONFIG_CMD_TASKREADY
-DECLARE_CONSOLE_COMMAND(taskready, command_task_ready,
- "[setmask]",
+DECLARE_CONSOLE_COMMAND(taskready, command_task_ready, "[setmask]",
"Print/set ready tasks");
#endif
@@ -606,7 +591,7 @@ void task_pre_init(void)
int i, cs;
uint32_t *stack_next = (uint32_t *)task_stacks;
- __asm__ __volatile__ ("movl %%cs, %0":"=r" (cs));
+ __asm__ __volatile__("movl %%cs, %0" : "=r"(cs));
/* Fill the task memory with initial values */
for (i = 0; i < TASK_ID_COUNT; i++) {
@@ -638,12 +623,12 @@ void task_pre_init(void)
sp[7] = 0xea; /* EAX */
#endif
/* For IRET */
- sp[8] = tasks_init[i].pc; /* pc */
+ sp[8] = tasks_init[i].pc; /* pc */
sp[9] = cs;
sp[10] = INITIAL_EFLAGS;
- sp[11] = (uint32_t) task_exit_trap;
- sp[12] = tasks_init[i].r0; /* task argument */
+ sp[11] = (uint32_t)task_exit_trap;
+ sp[12] = tasks_init[i].r0; /* task argument */
sp[13] = 0x00;
sp[14] = 0x00;
sp[15] = 0x00;
@@ -656,7 +641,8 @@ void task_pre_init(void)
0x00, 0x00, /* Status[0-15] */
0xff, 0xff, /* unused */
0xff, 0xff, /* Tag[0-15] */
- 0xff, 0xff};/* unused */
+ 0xff, 0xff
+ }; /* unused */
/* Copy default x86 FPU state for each task */
memcpy(tasks[i].fp_ctx, default_fp_ctx,
diff --git a/core/minute-ia/task_defs.h b/core/minute-ia/task_defs.h
index 18458b1533..dac80e0eb9 100644
--- a/core/minute-ia/task_defs.h
+++ b/core/minute-ia/task_defs.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,9 +7,9 @@
#define __CROS_EC_TASK_DEFS_H
#ifdef CONFIG_FPU
-#define FPU_CTX_SZ 108 /* 28 bytes header + 80 bytes registers */
-#define USE_FPU_OFFSET 20 /* offsetof(task_, use_fpu */
-#define FPU_CTX_OFFSET 24 /* offsetof(task_, fp_ctx) */
+#define FPU_CTX_SZ 108 /* 28 bytes header + 80 bytes registers */
+#define USE_FPU_OFFSET 20 /* offsetof(task_, use_fpu */
+#define FPU_CTX_OFFSET 24 /* offsetof(task_, fp_ctx) */
/*
* defines for inline asm
@@ -18,11 +18,11 @@
#include "atomic.h"
#include "common.h"
-#define USE_FPU_OFFSET_STR STRINGIFY(USE_FPU_OFFSET) /* "20" */
-#define FPU_CTX_OFFSET_STR STRINGIFY(FPU_CTX_OFFSET) /* "24" */
+#define USE_FPU_OFFSET_STR STRINGIFY(USE_FPU_OFFSET) /* "20" */
+#define FPU_CTX_OFFSET_STR STRINGIFY(FPU_CTX_OFFSET) /* "24" */
-asm (".equ USE_FPU_OFFSET, "USE_FPU_OFFSET_STR);
-asm (".equ FPU_CTX_OFFSET, "FPU_CTX_OFFSET_STR);
+asm(".equ USE_FPU_OFFSET, " USE_FPU_OFFSET_STR);
+asm(".equ FPU_CTX_OFFSET, " FPU_CTX_OFFSET_STR);
#endif
#endif /* CONFIG_FPU */
@@ -34,12 +34,12 @@ typedef union {
* Note that sp must be the first element in the task struct
* for __switchto() to work.
*/
- uint32_t sp; /* Saved stack pointer for context switch */
- atomic_t events; /* Bitmaps of received events */
- uint64_t runtime; /* Time spent in task */
- uint32_t *stack; /* Start of stack */
+ uint32_t sp; /* Saved stack pointer for context switch */
+ atomic_t events; /* Bitmaps of received events */
+ uint64_t runtime; /* Time spent in task */
+ uint32_t *stack; /* Start of stack */
#ifdef CONFIG_FPU
- uint32_t use_fpu; /* set if task uses FPU */
+ uint32_t use_fpu; /* set if task uses FPU */
uint8_t fp_ctx[FPU_CTX_SZ]; /* x87 FPU context */
#endif
};
@@ -50,7 +50,7 @@ void __switchto(void);
void sw_irq_handler(void);
/* Only the IF bit is set so tasks start with interrupts enabled. */
-#define INITIAL_EFLAGS (0x200UL)
+#define INITIAL_EFLAGS (0x200UL)
/* LAPIC ICR bit fields
* 7:0 - vector
@@ -61,7 +61,7 @@ void sw_irq_handler(void);
* 15 - Trigger mode (0 = edge)
* 20:18 - Destination (1 = self)
*/
-#define LAPIC_ICR_BITS 0x44000
+#define LAPIC_ICR_BITS 0x44000
#endif /* __ASSEMBLER__ */
#endif /* __CROS_EC_TASK_DEFS_H */
diff --git a/core/minute-ia/toolchain.mk b/core/minute-ia/toolchain.mk
new file mode 100644
index 0000000000..ed7ebfb2c8
--- /dev/null
+++ b/core/minute-ia/toolchain.mk
@@ -0,0 +1,7 @@
+# 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.
+
+# Select Minute-IA bare-metal toolchain
+$(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_i386),\
+ /opt/coreboot-sdk/bin/i386-elf-)