diff options
author | Olof Johansson <olof@lixom.net> | 2019-04-11 03:41:52 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-04-24 07:19:46 +0300 |
commit | 10baa64c02f6746fd506136e0693aa2d592574fb (patch) | |
tree | da00e48f0cb5d1434cbc7c31bb6ca15efa7d4564 /platform | |
parent | fbf986ac2a0b926ae97e6796b87e366610d7589e (diff) | |
download | opensbi-10baa64c02f6746fd506136e0693aa2d592574fb.tar.xz |
all: run clang-format and update checked-in files
Noisy commit, no functional changes.
Generated with an current upstream clang-format and:
clang-format -i $(find . -name \*.[ch])
Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'platform')
22 files changed, 251 insertions, 304 deletions
diff --git a/platform/common/include/plat/irqchip/plic.h b/platform/common/include/plat/irqchip/plic.h index 6e18440..eb97123 100644 --- a/platform/common/include/plat/irqchip/plic.h +++ b/platform/common/include/plat/irqchip/plic.h @@ -14,10 +14,8 @@ void plic_fdt_fixup(void *fdt, const char *compat); -int plic_warm_irqchip_init(u32 target_hart, - int m_cntx_id, int s_cntx_id); +int plic_warm_irqchip_init(u32 target_hart, int m_cntx_id, int s_cntx_id); -int plic_cold_irqchip_init(unsigned long base, - u32 num_sources, u32 hart_count); +int plic_cold_irqchip_init(unsigned long base, u32 num_sources, u32 hart_count); #endif diff --git a/platform/common/include/plat/serial/sifive-uart.h b/platform/common/include/plat/serial/sifive-uart.h index 6a64595..f323392 100644 --- a/platform/common/include/plat/serial/sifive-uart.h +++ b/platform/common/include/plat/serial/sifive-uart.h @@ -16,7 +16,6 @@ void sifive_uart_putc(char ch); int sifive_uart_getc(void); -int sifive_uart_init(unsigned long base, - u32 in_freq, u32 baudrate); +int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate); #endif diff --git a/platform/common/include/plat/serial/uart8250.h b/platform/common/include/plat/serial/uart8250.h index 3d58050..0a1b5d3 100644 --- a/platform/common/include/plat/serial/uart8250.h +++ b/platform/common/include/plat/serial/uart8250.h @@ -16,8 +16,7 @@ void uart8250_putc(char ch); int uart8250_getc(void); -int uart8250_init(unsigned long base, - u32 in_freq, u32 baudrate, - u32 reg_shift, u32 reg_width); +int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, + u32 reg_width); #endif diff --git a/platform/common/include/plat/string.h b/platform/common/include/plat/string.h index 67ad3f2..8259ef5 100644 --- a/platform/common/include/plat/string.h +++ b/platform/common/include/plat/string.h @@ -18,7 +18,7 @@ size_t strlen(const char *str); size_t strnlen(const char *str, size_t count); -char *strcpy(char *dest,const char *src); +char *strcpy(char *dest, const char *src); char *strncpy(char *dest, const char *src, size_t count); @@ -26,13 +26,13 @@ char *strchr(const char *s, int c); char *strrchr(const char *s, int c); -void *memset(void *s,int c,size_t count); +void *memset(void *s, int c, size_t count); void *memcpy(void *dest, const void *src, size_t count); -void *memmove(void *dest,const void *src, size_t count); +void *memmove(void *dest, const void *src, size_t count); -int memcmp(const void *s1,const void *s2, size_t count); +int memcmp(const void *s1, const void *s2, size_t count); void *memchr(const void *s, int c, size_t count); diff --git a/platform/common/include/plat/tinyfdt.h b/platform/common/include/plat/tinyfdt.h index 8d21262..3a681d9 100644 --- a/platform/common/include/plat/tinyfdt.h +++ b/platform/common/include/plat/tinyfdt.h @@ -38,33 +38,27 @@ ulong fdt_strlen(const char *str); int fdt_strcmp(const char *a, const char *b); /* Find index of matching string from a list of strings */ -int fdt_prop_string_index(const struct fdt_prop *prop, - const char *str); +int fdt_prop_string_index(const struct fdt_prop *prop, const char *str); /* Iterate over each property of matching node */ int fdt_match_node_prop(void *fdt, int (*match)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *match_priv, void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *fn_priv); /* Iterate over each property of compatible node */ -int fdt_compat_node_prop(void *fdt, - const char *compat, +int fdt_compat_node_prop(void *fdt, const char *compat, void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *fn_priv); /* Iterate over each node and property */ int fdt_walk(void *fdt, void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *fn_priv); /* Get size of FDT */ diff --git a/platform/common/irqchip/plic.c b/platform/common/irqchip/plic.c index a9ff560..90a7820 100644 --- a/platform/common/irqchip/plic.c +++ b/platform/common/irqchip/plic.c @@ -14,12 +14,12 @@ #include <plat/tinyfdt.h> #include <plat/irqchip/plic.h> -#define PLIC_PRIORITY_BASE 0x0 -#define PLIC_PENDING_BASE 0x1000 -#define PLIC_ENABLE_BASE 0x2000 -#define PLIC_ENABLE_STRIDE 0x80 -#define PLIC_CONTEXT_BASE 0x200000 -#define PLIC_CONTEXT_STRIDE 0x1000 +#define PLIC_PRIORITY_BASE 0x0 +#define PLIC_PENDING_BASE 0x1000 +#define PLIC_ENABLE_BASE 0x2000 +#define PLIC_ENABLE_STRIDE 0x80 +#define PLIC_CONTEXT_BASE 0x200000 +#define PLIC_CONTEXT_STRIDE 0x1000 static u32 plic_hart_count; static u32 plic_num_sources; @@ -27,31 +27,27 @@ static volatile void *plic_base; static void plic_set_priority(u32 source, u32 val) { - volatile void *plic_priority = plic_base + - PLIC_PRIORITY_BASE + - 4 * source; + volatile void *plic_priority = + plic_base + PLIC_PRIORITY_BASE + 4 * source; writel(val, plic_priority); } static void plic_set_thresh(u32 cntxid, u32 val) { - volatile void *plic_thresh = plic_base + - PLIC_CONTEXT_BASE + - PLIC_CONTEXT_STRIDE * cntxid; + volatile void *plic_thresh = + plic_base + PLIC_CONTEXT_BASE + PLIC_CONTEXT_STRIDE * cntxid; writel(val, plic_thresh); } static void plic_set_ie(u32 cntxid, u32 word_index, u32 val) { - volatile void *plic_ie = plic_base + - PLIC_ENABLE_BASE + - PLIC_ENABLE_STRIDE * cntxid; + volatile void *plic_ie = + plic_base + PLIC_ENABLE_BASE + PLIC_ENABLE_STRIDE * cntxid; writel(val, plic_ie + word_index * 4); } static void plic_fdt_fixup_prop(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv) + const struct fdt_prop *prop, void *priv) { u32 *cells; u32 i, cells_count; @@ -61,15 +57,15 @@ static void plic_fdt_fixup_prop(const struct fdt_node *node, if (strcmp(prop->name, "interrupts-extended")) return; - cells = prop->value; + cells = prop->value; cells_count = prop->len / sizeof(u32); if (!cells_count) return; - for (i = 0; i < (cells_count/2); i++) { - if (fdt_rev32(cells[2*i+1]) == IRQ_M_EXT) - cells[2*i+1] = fdt_rev32(0xffffffff); + for (i = 0; i < (cells_count / 2); i++) { + if (fdt_rev32(cells[2 * i + 1]) == IRQ_M_EXT) + cells[2 * i + 1] = fdt_rev32(0xffffffff); } } @@ -78,14 +74,13 @@ void plic_fdt_fixup(void *fdt, const char *compat) fdt_compat_node_prop(fdt, compat, plic_fdt_fixup_prop, NULL); } -int plic_warm_irqchip_init(u32 target_hart, - int m_cntx_id, int s_cntx_id) +int plic_warm_irqchip_init(u32 target_hart, int m_cntx_id, int s_cntx_id) { size_t i, ie_words = plic_num_sources / 32 + 1; if (plic_hart_count <= target_hart) return -1; - + /* By default, disable all IRQs for M-mode of target HART */ if (m_cntx_id > -1) { for (i = 0; i < ie_words; i++) @@ -109,14 +104,13 @@ int plic_warm_irqchip_init(u32 target_hart, return 0; } -int plic_cold_irqchip_init(unsigned long base, - u32 num_sources, u32 hart_count) +int plic_cold_irqchip_init(unsigned long base, u32 num_sources, u32 hart_count) { int i; - plic_hart_count = hart_count; + plic_hart_count = hart_count; plic_num_sources = num_sources; - plic_base = (void *)base; + plic_base = (void *)base; /* Configure default priorities of all IRQs */ for (i = 1; i <= plic_num_sources; i++) diff --git a/platform/common/libc/string.c b/platform/common/libc/string.c index 7cc0fb7..6e273d0 100644 --- a/platform/common/libc/string.c +++ b/platform/common/libc/string.c @@ -17,7 +17,8 @@ int strcmp(const char *a, const char *b) { /* search first diff or end of string */ - for (; *a == *b && *a != '\0'; a++, b++); + for (; *a == *b && *a != '\0'; a++, b++) + ; return *a - *b; } @@ -51,7 +52,7 @@ char *strcpy(char *dest, const char *src) { char *ret = dest; - while(*src != '\0') { + while (*src != '\0') { *dest++ = *src++; } @@ -62,7 +63,7 @@ char *strncpy(char *dest, const char *src, size_t count) { char *ret = dest; - while(count-- && *src != '\0') { + while (count-- && *src != '\0') { *dest++ = *src++; } @@ -71,7 +72,7 @@ char *strncpy(char *dest, const char *src, size_t count) char *strchr(const char *s, int c) { - while(*s != '\0' && *s != (char)c) + while (*s != '\0' && *s != (char)c) s++; if (*s == '\0') @@ -96,7 +97,7 @@ void *memset(void *s, int c, size_t count) { char *temp = s; - while(count > 0 ){ + while (count > 0) { count--; *temp++ = c; } @@ -106,7 +107,7 @@ void *memset(void *s, int c, size_t count) void *memcpy(void *dest, const void *src, size_t count) { - char *temp1 = dest; + char *temp1 = dest; const char *temp2 = src; while (count > 0) { @@ -119,14 +120,14 @@ void *memcpy(void *dest, const void *src, size_t count) void *memmove(void *dest, const void *src, size_t count) { - char *temp1 = (char *)dest; + char *temp1 = (char *)dest; const char *temp2 = (char *)src; if (src == dest) return dest; if (dest < src) { - while(count > 0) { + while (count > 0) { *temp1++ = *temp2++; count--; } @@ -134,7 +135,7 @@ void *memmove(void *dest, const void *src, size_t count) temp1 = dest + count - 1; temp2 = src + count - 1; - while(count > 0) { + while (count > 0) { *temp1-- = *temp2--; count--; } @@ -165,7 +166,7 @@ void *memchr(const void *s, int c, size_t count) while (count > 0) { if ((unsigned char)c == *temp++) { - return (void *)(temp-1); + return (void *)(temp - 1); } count--; } diff --git a/platform/common/libfdt/libfdt.h b/platform/common/libfdt/libfdt.h index a470d1d..4d6e58b 100644 --- a/platform/common/libfdt/libfdt.h +++ b/platform/common/libfdt/libfdt.h @@ -51,8 +51,8 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <libfdt_env.h> #include <fdt.h> +#include <libfdt_env.h> #define FDT_FIRST_SUPPORTED_VERSION 0x02 #define FDT_LAST_SUPPORTED_VERSION 0x11 diff --git a/platform/common/libfdt/libfdt_env.h b/platform/common/libfdt/libfdt_env.h index 235a1fc..2428fd5 100644 --- a/platform/common/libfdt/libfdt_env.h +++ b/platform/common/libfdt/libfdt_env.h @@ -52,8 +52,8 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sbi/sbi_types.h> #include <plat/string.h> +#include <sbi/sbi_types.h> #define INT_MAX ((int)(~0U >> 1)) #define UINT_MAX ((unsigned int)~0U) diff --git a/platform/common/serial/sifive-uart.c b/platform/common/serial/sifive-uart.c index 9d9490c..de00272 100644 --- a/platform/common/serial/sifive-uart.c +++ b/platform/common/serial/sifive-uart.c @@ -68,7 +68,8 @@ static void set_reg(u32 num, u32 val) void sifive_uart_putc(char ch) { - while (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL); + while (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL) + ; set_reg(UART_REG_TXFIFO, ch); } @@ -81,11 +82,10 @@ int sifive_uart_getc(void) return -1; } -int sifive_uart_init(unsigned long base, - u32 in_freq, u32 baudrate) +int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate) { - uart_base = (volatile void *)base; - uart_in_freq = in_freq; + uart_base = (volatile void *)base; + uart_in_freq = in_freq; uart_baudrate = baudrate; /* Configure baudrate */ diff --git a/platform/common/serial/uart8250.c b/platform/common/serial/uart8250.c index ba67c73..ceefb53 100644 --- a/platform/common/serial/uart8250.c +++ b/platform/common/serial/uart8250.c @@ -70,7 +70,8 @@ static void set_reg(u32 num, u32 val) void uart8250_putc(char ch) { - while ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0); + while ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0) + ; set_reg(UART_THR_OFFSET, ch); } @@ -82,17 +83,16 @@ int uart8250_getc(void) return -1; } -int uart8250_init(unsigned long base, - u32 in_freq, u32 baudrate, - u32 reg_shift, u32 reg_width) +int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift, + u32 reg_width) { u16 bdiv; - uart8250_base = (volatile void *)base; + uart8250_base = (volatile void *)base; uart8250_reg_shift = reg_shift; uart8250_reg_width = reg_width; - uart8250_in_freq = in_freq; - uart8250_baudrate = baudrate; + uart8250_in_freq = in_freq; + uart8250_baudrate = baudrate; bdiv = uart8250_in_freq / (16 * uart8250_baudrate); diff --git a/platform/common/sys/clint.c b/platform/common/sys/clint.c index ee79a54..eba056f 100644 --- a/platform/common/sys/clint.c +++ b/platform/common/sys/clint.c @@ -74,8 +74,8 @@ int clint_cold_ipi_init(unsigned long base, u32 hart_count) { /* Figure-out CLINT IPI register address */ clint_ipi_hart_count = hart_count; - clint_ipi_base = (void *)base; - clint_ipi = (u32 *)clint_ipi_base; + clint_ipi_base = (void *)base; + clint_ipi = (u32 *)clint_ipi_base; return 0; } @@ -105,7 +105,7 @@ void clint_timer_event_stop(void) if (clint_time_hart_count <= target_hart) return; - /* Clear CLINT Time Compare */ + /* Clear CLINT Time Compare */ #if __riscv_xlen == 64 writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]); #else @@ -121,13 +121,14 @@ void clint_timer_event_start(u64 next_event) if (clint_time_hart_count <= target_hart) return; - /* Program CLINT Time Compare */ + /* Program CLINT Time Compare */ #if __riscv_xlen == 64 writeq_relaxed(next_event, &clint_time_cmp[target_hart]); #else u32 mask = -1UL; writel_relaxed(next_event & mask, &clint_time_cmp[target_hart]); - writel_relaxed(next_event >> 32, (void *)(&clint_time_cmp[target_hart]) + 0x04); + writel_relaxed(next_event >> 32, + (void *)(&clint_time_cmp[target_hart]) + 0x04); #endif } @@ -135,11 +136,10 @@ int clint_warm_timer_init(void) { u32 target_hart = sbi_current_hartid(); - if (clint_time_hart_count <= target_hart || - !clint_time_base) + if (clint_time_hart_count <= target_hart || !clint_time_base) return -1; - /* Clear CLINT Time Compare */ + /* Clear CLINT Time Compare */ #if __riscv_xlen == 64 writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]); #else @@ -154,9 +154,9 @@ int clint_cold_timer_init(unsigned long base, u32 hart_count) { /* Figure-out CLINT Time register address */ clint_time_hart_count = hart_count; - clint_time_base = (void *)base; - clint_time_val = (u64 *)(clint_time_base + 0xbff8); - clint_time_cmp = (u64 *)(clint_time_base + 0x4000); + clint_time_base = (void *)base; + clint_time_val = (u64 *)(clint_time_base + 0xbff8); + clint_time_cmp = (u64 *)(clint_time_base + 0x4000); return 0; } diff --git a/platform/common/tinyfdt.c b/platform/common/tinyfdt.c index e83f540..e62a809 100644 --- a/platform/common/tinyfdt.c +++ b/platform/common/tinyfdt.c @@ -10,8 +10,8 @@ #include <plat/string.h> #include <plat/tinyfdt.h> -#define FDT_MAGIC 0xd00dfeed -#define FDT_VERSION 17 +#define FDT_MAGIC 0xd00dfeed +#define FDT_VERSION 17 struct fdt_header { u32 magic; @@ -26,28 +26,25 @@ struct fdt_header { u32 size_dt_struct; } __attribute__((packed)); -#define FDT_BEGIN_NODE 1 -#define FDT_END_NODE 2 -#define FDT_PROP 3 -#define FDT_NOP 4 -#define FDT_END 9 +#define FDT_BEGIN_NODE 1 +#define FDT_END_NODE 2 +#define FDT_PROP 3 +#define FDT_NOP 4 +#define FDT_END 9 u32 fdt_rev32(u32 v) { - return ((v & 0x000000FF) << 24) | - ((v & 0x0000FF00) << 8) | - ((v & 0x00FF0000) >> 8) | - ((v & 0xFF000000) >> 24); + return ((v & 0x000000FF) << 24) | ((v & 0x0000FF00) << 8) | + ((v & 0x00FF0000) >> 8) | ((v & 0xFF000000) >> 24); } -int fdt_prop_string_index(const struct fdt_prop *prop, - const char *str) +int fdt_prop_string_index(const struct fdt_prop *prop, const char *str) { int i; ulong l = 0; const char *p, *end; - p = prop->value; + p = prop->value; end = p + prop->len; for (i = 0; p < end; i++, p += l) { @@ -62,14 +59,13 @@ int fdt_prop_string_index(const struct fdt_prop *prop, } struct recursive_iter_info { - void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, + void (*fn)(const struct fdt_node *node, const struct fdt_prop *prop, void *priv); void *fn_priv; const char *str; }; -#define DATA32(ptr) fdt_rev32(*((u32*)ptr)) +#define DATA32(ptr) fdt_rev32(*((u32 *)ptr)) static void recursive_iter(char **data, struct recursive_iter_info *info, const struct fdt_node *parent) @@ -85,7 +81,7 @@ static void recursive_iter(char **data, struct recursive_iter_info *info, (*data) += sizeof(u32); node.parent = parent; - node.name = *data; + node.name = *data; *data += strlen(*data) + 1; while ((ulong)(*data) % sizeof(u32) != 0) @@ -95,7 +91,7 @@ static void recursive_iter(char **data, struct recursive_iter_info *info, /* Default cell counts, as per the FDT spec */ node.address_cells = 2; - node.size_cells = 1; + node.size_cells = 1; info->fn(&node, NULL, info->fn_priv); @@ -129,19 +125,16 @@ static void recursive_iter(char **data, struct recursive_iter_info *info, } struct match_iter_info { - int (*match)(const struct fdt_node *node, - const struct fdt_prop *prop, + int (*match)(const struct fdt_node *node, const struct fdt_prop *prop, void *priv); void *match_priv; - void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, + void (*fn)(const struct fdt_node *node, const struct fdt_prop *prop, void *priv); void *fn_priv; const char *str; }; -static void match_iter(const struct fdt_node *node, - const struct fdt_prop *prop, +static void match_iter(const struct fdt_node *node, const struct fdt_prop *prop, void *priv) { char *data; @@ -185,12 +178,10 @@ static void match_iter(const struct fdt_node *node, int fdt_match_node_prop(void *fdt, int (*match)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *match_priv, void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *fn_priv) { char *data; @@ -201,23 +192,23 @@ int fdt_match_node_prop(void *fdt, if (!fdt || !match) return -1; - + header = fdt; if (fdt_rev32(header->magic) != FDT_MAGIC || fdt_rev32(header->last_comp_version) > FDT_VERSION) return -1; string_offset = fdt_rev32(header->off_dt_strings); - data_offset = fdt_rev32(header->off_dt_struct); + data_offset = fdt_rev32(header->off_dt_struct); - minfo.match = match; + minfo.match = match; minfo.match_priv = match_priv; - minfo.fn = fn; - minfo.fn_priv = fn_priv; - minfo.str = (const char *)(fdt + string_offset); + minfo.fn = fn; + minfo.fn_priv = fn_priv; + minfo.str = (const char *)(fdt + string_offset); - rinfo.fn = match_iter; + rinfo.fn = match_iter; rinfo.fn_priv = &minfo; - rinfo.str = minfo.str; + rinfo.str = minfo.str; data = (char *)(fdt + data_offset); recursive_iter(&data, &rinfo, NULL); @@ -230,8 +221,7 @@ struct match_compat_info { }; static int match_compat(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv) + const struct fdt_prop *prop, void *priv) { struct match_compat_info *cinfo = priv; @@ -247,21 +237,17 @@ static int match_compat(const struct fdt_node *node, return 1; } -int fdt_compat_node_prop(void *fdt, - const char *compat, +int fdt_compat_node_prop(void *fdt, const char *compat, void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *fn_priv) { struct match_compat_info cinfo = { .compat = compat }; - return fdt_match_node_prop(fdt, match_compat, &cinfo, - fn, fn_priv); + return fdt_match_node_prop(fdt, match_compat, &cinfo, fn, fn_priv); } -static int match_walk(const struct fdt_node *node, - const struct fdt_prop *prop, +static int match_walk(const struct fdt_node *node, const struct fdt_prop *prop, void *priv) { if (!prop) @@ -272,12 +258,10 @@ static int match_walk(const struct fdt_node *node, int fdt_walk(void *fdt, void (*fn)(const struct fdt_node *node, - const struct fdt_prop *prop, - void *priv), + const struct fdt_prop *prop, void *priv), void *fn_priv) { - return fdt_match_node_prop(fdt, match_walk, NULL, - fn, fn_priv); + return fdt_match_node_prop(fdt, match_walk, NULL, fn, fn_priv); } u32 fdt_size(void *fdt) diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index cba83da..136e58e 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -17,7 +17,7 @@ #include "platform.h" #include "uarths.h" -#define K210_UART_BAUDRATE 115200 +#define K210_UART_BAUDRATE 115200 static int k210_console_init(void) { @@ -42,16 +42,13 @@ static int k210_irqchip_init(bool cold_boot) u32 hartid = sbi_current_hartid(); if (cold_boot) { - rc = plic_cold_irqchip_init(PLIC_BASE_ADDR, - PLIC_NUM_SOURCES, + rc = plic_cold_irqchip_init(PLIC_BASE_ADDR, PLIC_NUM_SOURCES, K210_HART_COUNT); if (rc) return rc; } - return plic_warm_irqchip_init(hartid, - (2 * hartid), - (2 * hartid + 1)); + return plic_warm_irqchip_init(hartid, (2 * hartid), (2 * hartid + 1)); } static int k210_ipi_init(bool cold_boot) @@ -59,8 +56,7 @@ static int k210_ipi_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_ipi_init(CLINT_BASE_ADDR, - K210_HART_COUNT); + rc = clint_cold_ipi_init(CLINT_BASE_ADDR, K210_HART_COUNT); if (rc) return rc; } @@ -73,8 +69,7 @@ static int k210_timer_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_timer_init(CLINT_BASE_ADDR, - K210_HART_COUNT); + rc = clint_cold_timer_init(CLINT_BASE_ADDR, K210_HART_COUNT); if (rc) return rc; } @@ -100,11 +95,11 @@ static int k210_system_shutdown(u32 type) const struct sbi_platform platform = { - .name = "Kendryte K210", + .name = "Kendryte K210", .features = SBI_PLATFORM_HAS_TIMER_VALUE, - .hart_count = K210_HART_COUNT, - .hart_stack_size = K210_HART_STACK_SIZE, + .hart_count = K210_HART_COUNT, + .hart_stack_size = K210_HART_STACK_SIZE, .disabled_hart_mask = 0, .console_init = k210_console_init, @@ -113,16 +108,16 @@ const struct sbi_platform platform = { .irqchip_init = k210_irqchip_init, - .ipi_init = k210_ipi_init, - .ipi_send = clint_ipi_send, - .ipi_sync = clint_ipi_sync, + .ipi_init = k210_ipi_init, + .ipi_send = clint_ipi_send, + .ipi_sync = clint_ipi_sync, .ipi_clear = clint_ipi_clear, - .timer_init = k210_timer_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, + .timer_init = k210_timer_init, + .timer_value = clint_timer_value, + .timer_event_stop = clint_timer_event_stop, .timer_event_start = clint_timer_event_start, - .system_reboot = k210_system_reboot, + .system_reboot = k210_system_reboot, .system_shutdown = k210_system_shutdown }; diff --git a/platform/kendryte/k210/sysctl.c b/platform/kendryte/k210/sysctl.c index 8f8622d..3c07777 100644 --- a/platform/kendryte/k210/sysctl.c +++ b/platform/kendryte/k210/sysctl.c @@ -28,9 +28,9 @@ static u32 sysctl_pll0_get_freq(void) u32 freq_in, nr, nf, od; freq_in = SYSCTRL_CLOCK_FREQ_IN0; - nr = sysctl->pll0.clkr0 + 1; - nf = sysctl->pll0.clkf0 + 1; - od = sysctl->pll0.clkod0 + 1; + nr = sysctl->pll0.clkr0 + 1; + nf = sysctl->pll0.clkf0 + 1; + od = sysctl->pll0.clkod0 + 1; /* * Get final PLL output freq @@ -50,9 +50,8 @@ u32 sysctl_get_cpu_freq(void) return SYSCTRL_CLOCK_FREQ_IN0; case 1: return sysctl_pll0_get_freq() / - (2ULL << (int)sysctl->clk_sel0.aclk_divider_sel); + (2ULL << (int)sysctl->clk_sel0.aclk_divider_sel); default: return 0; } } - diff --git a/platform/kendryte/k210/sysctl.h b/platform/kendryte/k210/sysctl.h index 357acc5..40d4e8f 100644 --- a/platform/kendryte/k210/sysctl.h +++ b/platform/kendryte/k210/sysctl.h @@ -588,7 +588,7 @@ typedef struct _sysctl_clk_th6 { typedef struct _sysctl_misc { u32 debug_sel : 6; u32 reserved0 : 4; - u32 spi_dvp_data_enable: 1; + u32 spi_dvp_data_enable : 1; u32 reserved1 : 21; } __attribute__((packed, aligned(4))) sysctl_misc_t; diff --git a/platform/kendryte/k210/uarths.c b/platform/kendryte/k210/uarths.c index 3b3cbb9..67d5d1c 100644 --- a/platform/kendryte/k210/uarths.c +++ b/platform/kendryte/k210/uarths.c @@ -26,19 +26,19 @@ static volatile struct uarths *const uarths = void uarths_init(u32 baud_rate, enum uarths_stopbit stopbit) { u32 freq = sysctl_get_cpu_freq(); - u16 div = freq / baud_rate - 1; + u16 div = freq / baud_rate - 1; /* Set UART registers */ - uarths->div.div = div; + uarths->div.div = div; uarths->txctrl.nstop = stopbit; - uarths->txctrl.txen = 1; - uarths->rxctrl.rxen = 1; + uarths->txctrl.txen = 1; + uarths->rxctrl.rxen = 1; uarths->txctrl.txcnt = 0; uarths->rxctrl.rxcnt = 0; - uarths->ip.txwm = 1; - uarths->ip.rxwm = 0; - uarths->ie.txwm = 1; - uarths->ie.rxwm = 0; + uarths->ip.txwm = 1; + uarths->ip.rxwm = 0; + uarths->ie.txwm = 1; + uarths->ie.rxwm = 0; /* Clear input */ if (!uarths->rxdata.empty) @@ -47,7 +47,8 @@ void uarths_init(u32 baud_rate, enum uarths_stopbit stopbit) void uarths_putc(char c) { - while (uarths->txdata.full); + while (uarths->txdata.full) + ; uarths->txdata.data = (u8)c; } @@ -61,4 +62,3 @@ int uarths_getc(void) return rx.data; } - diff --git a/platform/kendryte/k210/uarths.h b/platform/kendryte/k210/uarths.h index 3bfb8d5..18b7e95 100644 --- a/platform/kendryte/k210/uarths.h +++ b/platform/kendryte/k210/uarths.h @@ -162,10 +162,7 @@ struct uarths { struct uarths_div div; } __attribute__((packed, aligned(4))); -enum uarths_stopbit { - UARTHS_STOP_1, - UARTHS_STOP_2 -}; +enum uarths_stopbit { UARTHS_STOP_1, UARTHS_STOP_2 }; void uarths_init(u32 baud_rate, enum uarths_stopbit stopbit); void uarths_putc(char c); diff --git a/platform/qemu/sifive_u/platform.c b/platform/qemu/sifive_u/platform.c index 9ea090a..1dca2a1 100644 --- a/platform/qemu/sifive_u/platform.c +++ b/platform/qemu/sifive_u/platform.c @@ -52,15 +52,15 @@ static u32 sifive_u_pmp_region_count(u32 hartid) return 1; } -static int sifive_u_pmp_region_info(u32 hartid, u32 index, - ulong *prot, ulong *addr, ulong *log2size) +static int sifive_u_pmp_region_info(u32 hartid, u32 index, ulong *prot, + ulong *addr, ulong *log2size) { int ret = 0; switch (index) { case 0: - *prot = PMP_R | PMP_W | PMP_X; - *addr = 0; + *prot = PMP_R | PMP_W | PMP_X; + *addr = 0; *log2size = __riscv_xlen; break; default: @@ -73,8 +73,8 @@ static int sifive_u_pmp_region_info(u32 hartid, u32 index, static int sifive_u_console_init(void) { - return sifive_uart_init(SIFIVE_U_UART0_ADDR, - SIFIVE_U_PERIPH_CLK, 115200); + return sifive_uart_init(SIFIVE_U_UART0_ADDR, SIFIVE_U_PERIPH_CLK, + 115200); } static int sifive_u_irqchip_init(bool cold_boot) @@ -90,9 +90,7 @@ static int sifive_u_irqchip_init(bool cold_boot) return rc; } - return plic_warm_irqchip_init(hartid, - (2 * hartid), - (2 * hartid + 1)); + return plic_warm_irqchip_init(hartid, (2 * hartid), (2 * hartid + 1)); } static int sifive_u_ipi_init(bool cold_boot) @@ -130,26 +128,26 @@ static int sifive_u_system_down(u32 type) } const struct sbi_platform platform = { - .name = "QEMU SiFive Unleashed", - .features = SBI_PLATFORM_DEFAULT_FEATURES, - .hart_count = SIFIVE_U_HART_COUNT, - .hart_stack_size = SIFIVE_U_HART_STACK_SIZE, + .name = "QEMU SiFive Unleashed", + .features = SBI_PLATFORM_DEFAULT_FEATURES, + .hart_count = SIFIVE_U_HART_COUNT, + .hart_stack_size = SIFIVE_U_HART_STACK_SIZE, .disabled_hart_mask = 0, - .pmp_region_count = sifive_u_pmp_region_count, - .pmp_region_info = sifive_u_pmp_region_info, - .final_init = sifive_u_final_init, - .console_putc = sifive_uart_putc, - .console_getc = sifive_uart_getc, - .console_init = sifive_u_console_init, - .irqchip_init = sifive_u_irqchip_init, - .ipi_send = clint_ipi_send, - .ipi_sync = clint_ipi_sync, - .ipi_clear = clint_ipi_clear, - .ipi_init = sifive_u_ipi_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, - .timer_init = sifive_u_timer_init, - .system_reboot = sifive_u_system_down, - .system_shutdown = sifive_u_system_down + .pmp_region_count = sifive_u_pmp_region_count, + .pmp_region_info = sifive_u_pmp_region_info, + .final_init = sifive_u_final_init, + .console_putc = sifive_uart_putc, + .console_getc = sifive_uart_getc, + .console_init = sifive_u_console_init, + .irqchip_init = sifive_u_irqchip_init, + .ipi_send = clint_ipi_send, + .ipi_sync = clint_ipi_sync, + .ipi_clear = clint_ipi_clear, + .ipi_init = sifive_u_ipi_init, + .timer_value = clint_timer_value, + .timer_event_stop = clint_timer_event_stop, + .timer_event_start = clint_timer_event_start, + .timer_init = sifive_u_timer_init, + .system_reboot = sifive_u_system_down, + .system_shutdown = sifive_u_system_down }; diff --git a/platform/qemu/virt/platform.c b/platform/qemu/virt/platform.c index df62991..96e375d 100644 --- a/platform/qemu/virt/platform.c +++ b/platform/qemu/virt/platform.c @@ -56,15 +56,15 @@ static u32 virt_pmp_region_count(u32 hartid) return 1; } -static int virt_pmp_region_info(u32 hartid, u32 index, - ulong *prot, ulong *addr, ulong *log2size) +static int virt_pmp_region_info(u32 hartid, u32 index, ulong *prot, ulong *addr, + ulong *log2size) { int ret = 0; switch (index) { case 0: - *prot = PMP_R | PMP_W | PMP_X; - *addr = 0; + *prot = PMP_R | PMP_W | PMP_X; + *addr = 0; *log2size = __riscv_xlen; break; default: @@ -77,8 +77,7 @@ static int virt_pmp_region_info(u32 hartid, u32 index, static int virt_console_init(void) { - return uart8250_init(VIRT_UART16550_ADDR, - VIRT_UART_SHIFTREG_ADDR, + return uart8250_init(VIRT_UART16550_ADDR, VIRT_UART_SHIFTREG_ADDR, VIRT_UART_BAUDRATE, 0, 1); } @@ -88,16 +87,13 @@ static int virt_irqchip_init(bool cold_boot) u32 hartid = sbi_current_hartid(); if (cold_boot) { - rc = plic_cold_irqchip_init(VIRT_PLIC_ADDR, - VIRT_PLIC_NUM_SOURCES, - VIRT_HART_COUNT); + rc = plic_cold_irqchip_init( + VIRT_PLIC_ADDR, VIRT_PLIC_NUM_SOURCES, VIRT_HART_COUNT); if (rc) return rc; } - return plic_warm_irqchip_init(hartid, - (2 * hartid), - (2 * hartid + 1)); + return plic_warm_irqchip_init(hartid, (2 * hartid), (2 * hartid + 1)); } static int virt_ipi_init(bool cold_boot) @@ -105,8 +101,7 @@ static int virt_ipi_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_ipi_init(VIRT_CLINT_ADDR, - VIRT_HART_COUNT); + rc = clint_cold_ipi_init(VIRT_CLINT_ADDR, VIRT_HART_COUNT); if (rc) return rc; } @@ -119,8 +114,7 @@ static int virt_timer_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_timer_init(VIRT_CLINT_ADDR, - VIRT_HART_COUNT); + rc = clint_cold_timer_init(VIRT_CLINT_ADDR, VIRT_HART_COUNT); if (rc) return rc; } @@ -139,26 +133,26 @@ static int virt_system_down(u32 type) } const struct sbi_platform platform = { - .name = "QEMU Virt Machine", - .features = SBI_PLATFORM_DEFAULT_FEATURES, - .hart_count = VIRT_HART_COUNT, - .hart_stack_size = VIRT_HART_STACK_SIZE, + .name = "QEMU Virt Machine", + .features = SBI_PLATFORM_DEFAULT_FEATURES, + .hart_count = VIRT_HART_COUNT, + .hart_stack_size = VIRT_HART_STACK_SIZE, .disabled_hart_mask = 0, - .pmp_region_count = virt_pmp_region_count, - .pmp_region_info = virt_pmp_region_info, - .final_init = virt_final_init, - .console_putc = uart8250_putc, - .console_getc = uart8250_getc, - .console_init = virt_console_init, - .irqchip_init = virt_irqchip_init, - .ipi_send = clint_ipi_send, - .ipi_sync = clint_ipi_sync, - .ipi_clear = clint_ipi_clear, - .ipi_init = virt_ipi_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, - .timer_init = virt_timer_init, - .system_reboot = virt_system_down, - .system_shutdown = virt_system_down + .pmp_region_count = virt_pmp_region_count, + .pmp_region_info = virt_pmp_region_info, + .final_init = virt_final_init, + .console_putc = uart8250_putc, + .console_getc = uart8250_getc, + .console_init = virt_console_init, + .irqchip_init = virt_irqchip_init, + .ipi_send = clint_ipi_send, + .ipi_sync = clint_ipi_sync, + .ipi_clear = clint_ipi_clear, + .ipi_init = virt_ipi_init, + .timer_value = clint_timer_value, + .timer_event_stop = clint_timer_event_stop, + .timer_event_start = clint_timer_event_start, + .timer_init = virt_timer_init, + .system_reboot = virt_system_down, + .system_shutdown = virt_system_down }; diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c index 9042d60..ee2e5a4 100644 --- a/platform/sifive/fu540/platform.c +++ b/platform/sifive/fu540/platform.c @@ -65,18 +65,19 @@ static void fu540_modify_dt(void *fdt) for (i = 0; i < FU540_HART_COUNT; i++) { sbi_sprintf(cpu_node, "/cpus/cpu@%d", i); cpu_offset = fdt_path_offset(fdt, cpu_node); - mmu_type = fdt_getprop(fdt, cpu_offset, "mmu-type", NULL); + mmu_type = fdt_getprop(fdt, cpu_offset, "mmu-type", NULL); if (mmu_type && (!strcmp(mmu_type, "riscv,sv39") || - !strcmp(mmu_type,"riscv,sv48"))) + !strcmp(mmu_type, "riscv,sv48"))) continue; else fdt_setprop_string(fdt, cpu_offset, "status", "masked"); memset(cpu_node, 0, sizeof(cpu_node)); } size = fdt_totalsize(fdt); - err = fdt_open_into(fdt, fdt, size + 256); + err = fdt_open_into(fdt, fdt, size + 256); if (err < 0) - sbi_printf("Device Tree can't be expanded to accmodate new node"); + sbi_printf( + "Device Tree can't be expanded to accmodate new node"); chosen_offset = fdt_path_offset(fdt, "/chosen"); fdt_setprop_string(fdt, chosen_offset, "stdout-path", @@ -103,15 +104,15 @@ static u32 fu540_pmp_region_count(u32 hartid) return 1; } -static int fu540_pmp_region_info(u32 hartid, u32 index, - ulong *prot, ulong *addr, ulong *log2size) +static int fu540_pmp_region_info(u32 hartid, u32 index, ulong *prot, + ulong *addr, ulong *log2size) { int ret = 0; switch (index) { case 0: - *prot = PMP_R | PMP_W | PMP_X; - *addr = 0; + *prot = PMP_R | PMP_W | PMP_X; + *addr = 0; *log2size = __riscv_xlen; break; default: @@ -128,14 +129,14 @@ static int fu540_console_init(void) if (readl((volatile void *)FU540_PRCI_BASE_ADDR + FU540_PRCI_CLKMUXSTATUSREG) & - FU540_PRCI_CLKMUX_STATUS_TLCLKSEL) { + FU540_PRCI_CLKMUX_STATUS_TLCLKSEL) { peri_in_freq = FU540_SYS_CLK; } else { peri_in_freq = FU540_SYS_CLK / 2; } - return sifive_uart_init(FU540_UART0_ADDR, - peri_in_freq, FU540_UART_BAUDRATE); + return sifive_uart_init(FU540_UART0_ADDR, peri_in_freq, + FU540_UART_BAUDRATE); } static int fu540_irqchip_init(bool cold_boot) @@ -151,9 +152,8 @@ static int fu540_irqchip_init(bool cold_boot) return rc; } - return plic_warm_irqchip_init(hartid, - (hartid) ? (2 * hartid - 1) : 0, - (hartid) ? (2 * hartid) : -1); + return plic_warm_irqchip_init(hartid, (hartid) ? (2 * hartid - 1) : 0, + (hartid) ? (2 * hartid) : -1); } static int fu540_ipi_init(bool cold_boot) @@ -161,11 +161,9 @@ static int fu540_ipi_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_ipi_init(FU540_CLINT_ADDR, - FU540_HART_COUNT); + rc = clint_cold_ipi_init(FU540_CLINT_ADDR, FU540_HART_COUNT); if (rc) return rc; - } return clint_warm_ipi_init(); @@ -176,8 +174,7 @@ static int fu540_timer_init(bool cold_boot) int rc; if (cold_boot) { - rc = clint_cold_timer_init(FU540_CLINT_ADDR, - FU540_HART_COUNT); + rc = clint_cold_timer_init(FU540_CLINT_ADDR, FU540_HART_COUNT); if (rc) return rc; } @@ -192,26 +189,26 @@ static int fu540_system_down(u32 type) } const struct sbi_platform platform = { - .name = "SiFive Freedom U540", - .features = SBI_PLATFORM_DEFAULT_FEATURES, - .hart_count = FU540_HART_COUNT, - .hart_stack_size = FU540_HART_STACK_SIZE, + .name = "SiFive Freedom U540", + .features = SBI_PLATFORM_DEFAULT_FEATURES, + .hart_count = FU540_HART_COUNT, + .hart_stack_size = FU540_HART_STACK_SIZE, .disabled_hart_mask = FU540_HARITD_DISABLED, - .pmp_region_count = fu540_pmp_region_count, - .pmp_region_info = fu540_pmp_region_info, - .final_init = fu540_final_init, - .console_putc = sifive_uart_putc, - .console_getc = sifive_uart_getc, - .console_init = fu540_console_init, - .irqchip_init = fu540_irqchip_init, - .ipi_send = clint_ipi_send, - .ipi_sync = clint_ipi_sync, - .ipi_clear = clint_ipi_clear, - .ipi_init = fu540_ipi_init, - .timer_value = clint_timer_value, - .timer_event_stop = clint_timer_event_stop, - .timer_event_start = clint_timer_event_start, - .timer_init = fu540_timer_init, - .system_reboot = fu540_system_down, - .system_shutdown = fu540_system_down + .pmp_region_count = fu540_pmp_region_count, + .pmp_region_info = fu540_pmp_region_info, + .final_init = fu540_final_init, + .console_putc = sifive_uart_putc, + .console_getc = sifive_uart_getc, + .console_init = fu540_console_init, + .irqchip_init = fu540_irqchip_init, + .ipi_send = clint_ipi_send, + .ipi_sync = clint_ipi_sync, + .ipi_clear = clint_ipi_clear, + .ipi_init = fu540_ipi_init, + .timer_value = clint_timer_value, + .timer_event_stop = clint_timer_event_stop, + .timer_event_start = clint_timer_event_start, + .timer_init = fu540_timer_init, + .system_reboot = fu540_system_down, + .system_shutdown = fu540_system_down }; diff --git a/platform/template/platform.c b/platform/template/platform.c index 866d273..b8c627d 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -44,8 +44,8 @@ static u32 platform_pmp_region_count(u32 hartid) * Get PMP regions details (namely: protection, base address, and size) for * a given HART. */ -static int platform_pmp_region_info(u32 hartid, u32 index, - ulong *prot, ulong *addr, ulong *log2size) +static int platform_pmp_region_info(u32 hartid, u32 index, ulong *prot, + ulong *addr, ulong *log2size) { return 0; } @@ -56,8 +56,7 @@ static int platform_pmp_region_info(u32 hartid, u32 index, static int platform_console_init(void) { /* Example if the generic UART8250 driver is used */ - return uart8250_init(PLATFORM_UART_ADDR, - PLATFORM_UART_SHIFTREG_ADDR, + return uart8250_init(PLATFORM_UART_ADDR, PLATFORM_UART_SHIFTREG_ADDR, PLATFORM_UART_BAUDRATE, 0, 1); } @@ -209,34 +208,33 @@ static int platform_system_shutdown(u32 type) */ const struct sbi_platform platform = { - .name = "platform-name", - .features = SBI_PLATFORM_DEFAULT_FEATURES, - .hart_count = 1, - .hart_stack_size = 4096, + .name = "platform-name", + .features = SBI_PLATFORM_DEFAULT_FEATURES, + .hart_count = 1, + .hart_stack_size = 4096, .disabled_hart_mask = 0, .early_init = platform_early_init, .final_init = platform_final_init, .pmp_region_count = platform_pmp_region_count, - .pmp_region_info = platform_pmp_region_info, + .pmp_region_info = platform_pmp_region_info, .console_init = platform_console_init, .console_putc = platform_console_putc, .console_getc = platform_console_getc, .irqchip_init = platform_irqchip_init, - .ipi_init = platform_ipi_init, - .ipi_send = platform_ipi_send, - .ipi_sync = platform_ipi_sync, - .ipi_clear = platform_ipi_clear, + .ipi_init = platform_ipi_init, + .ipi_send = platform_ipi_send, + .ipi_sync = platform_ipi_sync, + .ipi_clear = platform_ipi_clear, - .timer_init = platform_timer_init, - .timer_value = platform_timer_value, + .timer_init = platform_timer_init, + .timer_value = platform_timer_value, .timer_event_start = platform_timer_event_start, - .timer_event_stop = platform_timer_event_stop, + .timer_event_stop = platform_timer_event_stop, - .system_reboot = platform_system_reboot, + .system_reboot = platform_system_reboot, .system_shutdown = platform_system_shutdown }; - |