diff options
Diffstat (limited to 'arch/riscv')
-rw-r--r-- | arch/riscv/cpu/nx25/start.S | 2 | ||||
-rw-r--r-- | arch/riscv/dts/ae250.dts | 1 | ||||
-rw-r--r-- | arch/riscv/include/asm/bootm.h | 49 | ||||
-rw-r--r-- | arch/riscv/include/asm/encoding.h | 16 | ||||
-rw-r--r-- | arch/riscv/include/asm/global_data.h | 2 | ||||
-rw-r--r-- | arch/riscv/include/asm/io.h | 23 | ||||
-rw-r--r-- | arch/riscv/include/asm/posix_types.h | 12 | ||||
-rw-r--r-- | arch/riscv/include/asm/ptrace.h | 9 | ||||
-rw-r--r-- | arch/riscv/include/asm/setup.h | 10 | ||||
-rw-r--r-- | arch/riscv/include/asm/string.h | 12 | ||||
-rw-r--r-- | arch/riscv/lib/bootm.c | 185 | ||||
-rw-r--r-- | arch/riscv/lib/interrupts.c | 2 |
12 files changed, 58 insertions, 265 deletions
diff --git a/arch/riscv/cpu/nx25/start.S b/arch/riscv/cpu/nx25/start.S index 6a076639d3..cd0a66360d 100644 --- a/arch/riscv/cpu/nx25/start.S +++ b/arch/riscv/cpu/nx25/start.S @@ -45,6 +45,8 @@ trap_vector: .global trap_entry handle_reset: + li t0, CONFIG_SYS_SDRAM_BASE + SREG a2, 0(t0) la t0, trap_entry csrw mtvec, t0 csrwi mstatus, 0 diff --git a/arch/riscv/dts/ae250.dts b/arch/riscv/dts/ae250.dts index 5dc4fb04be..9a38345e36 100644 --- a/arch/riscv/dts/ae250.dts +++ b/arch/riscv/dts/ae250.dts @@ -74,6 +74,7 @@ fifo-depth = <0x10>; reg = <0xf0e00000 0x1000>; interrupts = <17 4>; + cap-sd-highspeed; }; spi: spi@f0b00000 { diff --git a/arch/riscv/include/asm/bootm.h b/arch/riscv/include/asm/bootm.h index 0a644bb58b..9a90f23a22 100644 --- a/arch/riscv/include/asm/bootm.h +++ b/arch/riscv/include/asm/bootm.h @@ -13,53 +13,4 @@ #include <asm/setup.h> -#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ - defined(CONFIG_CMDLINE_TAG) || \ - defined(CONFIG_INITRD_TAG) || \ - defined(CONFIG_SERIAL_TAG) || \ - defined(CONFIG_REVISION_TAG) -# define BOOTM_ENABLE_TAGS 1 -#else -# define BOOTM_ENABLE_TAGS 0 -#endif - -#ifdef CONFIG_SETUP_MEMORY_TAGS -# define BOOTM_ENABLE_MEMORY_TAGS 1 -#else -# define BOOTM_ENABLE_MEMORY_TAGS 0 -#endif - -#ifdef CONFIG_CMDLINE_TAG - #define BOOTM_ENABLE_CMDLINE_TAG 1 -#else - #define BOOTM_ENABLE_CMDLINE_TAG 0 -#endif - -#ifdef CONFIG_INITRD_TAG - #define BOOTM_ENABLE_INITRD_TAG 1 -#else - #define BOOTM_ENABLE_INITRD_TAG 0 -#endif - -#ifdef CONFIG_SERIAL_TAG - #define BOOTM_ENABLE_SERIAL_TAG 1 -void get_board_serial(struct tag_serialnr *serialnr); -#else - #define BOOTM_ENABLE_SERIAL_TAG 0 -static inline void get_board_serial(struct tag_serialnr *serialnr) -{ -} -#endif - -#ifdef CONFIG_REVISION_TAG - #define BOOTM_ENABLE_REVISION_TAG 1 -u32 get_board_rev(void); -#else - #define BOOTM_ENABLE_REVISION_TAG 0 -static inline u32 get_board_rev(void) -{ - return 0; -} -#endif - #endif diff --git a/arch/riscv/include/asm/encoding.h b/arch/riscv/include/asm/encoding.h index 5ff6d59149..dbf8d45fb7 100644 --- a/arch/riscv/include/asm/encoding.h +++ b/arch/riscv/include/asm/encoding.h @@ -121,7 +121,9 @@ #define PTE_SW(PTE) ((0x88888880U >> ((PTE) & 0x1F)) & 1) #define PTE_SX(PTE) ((0xA0A0A000U >> ((PTE) & 0x1F)) & 1) -#define PTE_CHECK_PERM(PTE, SUPERVISOR, STORE, FETCH) \ +#define PTE_CHECK_PERM(_PTE, _SUPERVISOR, STORE, FETCH) \ + typeof(_PTE) (PTE) = (_PTE); \ + typeof(_SUPERVISOR) (SUPERVISOR) = (_SUPERVISOR); \ ((STORE) ? ((SUPERVISOR) ? PTE_SW(PTE) : PTE_UW(PTE)) : \ (FETCH) ? ((SUPERVISOR) ? PTE_SX(PTE) : PTE_UX(PTE)) : \ ((SUPERVISOR) ? PTE_SR(PTE) : PTE_UR(PTE))) @@ -151,27 +153,31 @@ asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \ __tmp; }) -#define write_csr(reg, val) ({ \ +#define write_csr(reg, _val) ({ \ +typeof(_val) (val) = (_val); \ if (__builtin_constant_p(val) && (unsigned long)(val) < 32) \ asm volatile ("csrw " #reg ", %0" :: "i"(val)); \ else \ asm volatile ("csrw " #reg ", %0" :: "r"(val)); }) -#define swap_csr(reg, val) ({ unsigned long __tmp; \ +#define swap_csr(reg, _val) ({ unsigned long __tmp; \ +typeof(_val) (val) = (_val); \ if (__builtin_constant_p(val) && (unsigned long)(val) < 32) \ asm volatile ("csrrw %0, " #reg ", %1" : "=r"(__tmp) : "i"(val)); \ else \ asm volatile ("csrrw %0, " #reg ", %1" : "=r"(__tmp) : "r"(val)); \ __tmp; }) -#define set_csr(reg, bit) ({ unsigned long __tmp; \ +#define set_csr(reg, _bit) ({ unsigned long __tmp; \ +typeof(_bit) (bit) = (_bit); \ if (__builtin_constant_p(bit) && (unsigned long)(bit) < 32) \ asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "i"(bit)); \ else \ asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "r"(bit)); \ __tmp; }) -#define clear_csr(reg, bit) ({ unsigned long __tmp; \ +#define clear_csr(reg, _bit) ({ unsigned long __tmp; \ +typeof(_bit) (bit) = (_bit); \ if (__builtin_constant_p(bit) && (unsigned long)(bit) < 32) \ asm volatile ("csrrc %0, " #reg ", %1" : "=r"(__tmp) : "i"(bit)); \ else \ diff --git a/arch/riscv/include/asm/global_data.h b/arch/riscv/include/asm/global_data.h index 0cce98ab53..bd352c2cda 100644 --- a/arch/riscv/include/asm/global_data.h +++ b/arch/riscv/include/asm/global_data.h @@ -17,6 +17,6 @@ struct arch_global_data { #include <asm-generic/global_data.h> -#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("gp") +#define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("gp") #endif /* __ASM_GBL_DATA_H */ diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h index e7f63ed8a9..1df6b1b2bf 100644 --- a/arch/riscv/include/asm/io.h +++ b/arch/riscv/include/asm/io.h @@ -416,19 +416,17 @@ static inline void writesl(unsigned int *addr, const void *data, int longlen) #define eth_io_copy_and_sum(s, c, l, b) \ eth_copy_and_sum((s), __mem_pci(c), (l), (b)) -static inline int -check_signature(unsigned long io_addr, const unsigned char *signature, - int length) +static inline int check_signature(ulong io_addr, const uchar *s, int len) { int retval = 0; do { - if (readb(io_addr) != *signature) + if (readb(io_addr) != *s) goto out; io_addr++; - signature++; - length--; - } while (length); + s++; + len--; + } while (len); retval = 1; out: return retval; @@ -455,18 +453,17 @@ out: eth_copy_and_sum((a), __mem_isa(b), (c), (d)) static inline int -isa_check_signature(unsigned long io_addr, const unsigned char *signature, - int length) +isa_check_signature(ulong io_addr, const uchar *s, int len) { int retval = 0; do { - if (isa_readb(io_addr) != *signature) + if (isa_readb(io_addr) != *s) goto out; io_addr++; - signature++; - length--; - } while (length); + s++; + len--; + } while (len); retval = 1; out: return retval; diff --git a/arch/riscv/include/asm/posix_types.h b/arch/riscv/include/asm/posix_types.h index 6892b66814..7438dbeb03 100644 --- a/arch/riscv/include/asm/posix_types.h +++ b/arch/riscv/include/asm/posix_types.h @@ -69,19 +69,23 @@ typedef struct { #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) #undef __FD_SET -#define __FD_SET(fd, fdsetp) \ +#define __FD_SET(_fd, fdsetp) \ + typeof(_fd) (fd) = (_fd); \ (((fd_set *)fdsetp)->fds_bits[fd >> 5] |= (1 << (fd & 31))) #undef __FD_CLR -#define __FD_CLR(fd, fdsetp) \ +#define __FD_CLR(_fd, fdsetp) \ + typeof(_fd) (fd) = (_fd); \ (((fd_set *)fdsetp)->fds_bits[fd >> 5] &= ~(1 << (fd & 31))) #undef __FD_ISSET -#define __FD_ISSET(fd, fdsetp) \ +#define __FD_ISSET(_fd, fdsetp) \ + typeof(_fd) (fd) = (_fd); \ ((((fd_set *)fdsetp)->fds_bits[fd >> 5] & (1 << (fd & 31))) != 0) #undef __FD_ZERO -#define __FD_ZERO(fdsetp) \ +#define __FD_ZERO(_fdsetp) \ + typeof(_fdsetp) (fd) = (_fdsetp); \ (memset(fdsetp, 0, sizeof(*(fd_set *)fdsetp))) #endif diff --git a/arch/riscv/include/asm/ptrace.h b/arch/riscv/include/asm/ptrace.h index 76d68698bb..651078fcfd 100644 --- a/arch/riscv/include/asm/ptrace.h +++ b/arch/riscv/include/asm/ptrace.h @@ -65,8 +65,7 @@ static inline unsigned long instruction_pointer(struct pt_regs *regs) return GET_IP(regs); } -static inline void instruction_pointer_set(struct pt_regs *regs, - unsigned long val) +static inline void instruction_pointer_set(struct pt_regs *regs, ulong val) { SET_IP(regs, val); } @@ -82,8 +81,7 @@ static inline unsigned long user_stack_pointer(struct pt_regs *regs) return GET_USP(regs); } -static inline void user_stack_pointer_set(struct pt_regs *regs, - unsigned long val) +static inline void user_stack_pointer_set(struct pt_regs *regs, ulong val) { SET_USP(regs, val); } @@ -97,8 +95,7 @@ static inline unsigned long frame_pointer(struct pt_regs *regs) return GET_FP(regs); } -static inline void frame_pointer_set(struct pt_regs *regs, - unsigned long val) +static inline void frame_pointer_set(struct pt_regs *regs, ulong val) { SET_FP(regs, val); } diff --git a/arch/riscv/include/asm/setup.h b/arch/riscv/include/asm/setup.h index 731b0d96aa..4b182432f1 100644 --- a/arch/riscv/include/asm/setup.h +++ b/arch/riscv/include/asm/setup.h @@ -145,14 +145,18 @@ struct tagtable { int (*parse)(const struct tag *); }; -#define tag_member_present(tag, member) \ +#define tag_member_present(_tag, member) \ + typeof(_tag) (tag) = (_tag); \ ((unsigned long)(&((struct tag *)0L)->member + 1) \ <= (tag)->hdr.size * 4) -#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) +#define tag_next(_t) \ + typeof(_t) (t) = (_t); \ + ((struct tag *)((u32 *)(t) + (t)->hdr.size)) #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) -#define for_each_tag(t, base) \ +#define for_each_tag(_t, base) \ + typeof(_t) (t) = (_t); \ for (t = base; t->hdr.size; t = tag_next(t)) #ifdef __KERNEL__ diff --git a/arch/riscv/include/asm/string.h b/arch/riscv/include/asm/string.h index 038cdaea72..0fc3424a2f 100644 --- a/arch/riscv/include/asm/string.h +++ b/arch/riscv/include/asm/string.h @@ -26,8 +26,11 @@ #undef __HAVE_ARCH_MEMSET #ifdef CONFIG_MARCO_MEMSET -#define memset(p, v, n) \ - ({ \ +#define memset(_p, _v, _n) \ + (typeof(_p) (p) = (_p); \ + typeof(_v) (v) = (_v); \ + typeof(_n) (n) = (_n); \ + { \ if ((n) != 0) { \ if (__builtin_constant_p((v)) && (v) == 0) \ __memzero((p), (n)); \ @@ -37,7 +40,10 @@ (p); \ }) -#define memzero(p, n) ({ if ((n) != 0) __memzero((p), (n)); (p); }) +#define memzero(_p, _n) \ + (typeof(_p) (p) = (_p); \ + typeof(_n) (n) = (_n); \ + { if ((n) != 0) __memzero((p), (n)); (p); }) #endif #endif /* __ASM_RISCV_STRING_H */ diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index 44ce38b614..9242fa891a 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -21,36 +21,12 @@ int arch_fixup_fdt(void *blob) return 0; } -#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ - defined(CONFIG_CMDLINE_TAG) || \ - defined(CONFIG_INITRD_TAG) || \ - defined(CONFIG_SERIAL_TAG) || \ - defined(CONFIG_REVISION_TAG) -static void setup_start_tag(bd_t *bd); - -# ifdef CONFIG_SETUP_MEMORY_TAGS -static void setup_memory_tags(bd_t *bd); -# endif -static void setup_commandline_tag(bd_t *bd, char *commandline); - -# ifdef CONFIG_INITRD_TAG -static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end); -# endif -static void setup_end_tag(bd_t *bd); - -static struct tag *params; -#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ - int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; - void (*theKernel)(int zero, int arch, uint params); - -#ifdef CONFIG_CMDLINE_TAG - char *commandline = env_get("bootargs"); -#endif + void (*theKernel)(int arch, uint params); /* * allow the PREP bootm subcommand, it is required for bootm to work @@ -61,7 +37,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; - theKernel = (void (*)(int, int, uint))images->ep; + theKernel = (void (*)(int, uint))images->ep; s = env_get("machid"); if (s) { @@ -82,167 +58,16 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) hang(); } #endif - } else if (BOOTM_ENABLE_TAGS) { -#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ - defined(CONFIG_CMDLINE_TAG) || \ - defined(CONFIG_INITRD_TAG) || \ - defined(CONFIG_SERIAL_TAG) || \ - defined(CONFIG_REVISION_TAG) - setup_start_tag(bd); -#ifdef CONFIG_SERIAL_TAG - setup_serial_tag(¶ms); -#endif -#ifdef CONFIG_REVISION_TAG - setup_revision_tag(¶ms); -#endif -#ifdef CONFIG_SETUP_MEMORY_TAGS - setup_memory_tags(bd); -#endif -#ifdef CONFIG_CMDLINE_TAG - setup_commandline_tag(bd, commandline); -#endif -#ifdef CONFIG_INITRD_TAG - if (images->rd_start && images->rd_end) - setup_initrd_tag(bd, images->rd_start, images->rd_end); -#endif - setup_end_tag(bd); -#endif + } /* we assume that the kernel is in place */ printf("\nStarting kernel ...\n\n"); -#ifdef CONFIG_USB_DEVICE - { - extern void udc_disconnect(void); - udc_disconnect(); - } -#endif - } cleanup_before_linux(); if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) - theKernel(0, machid, (unsigned long)images->ft_addr); - else - theKernel(0, machid, bd->bi_boot_params); + theKernel(machid, (unsigned long)images->ft_addr); + /* does not return */ return 1; } - -#if defined(CONFIG_SETUP_MEMORY_TAGS) || \ - defined(CONFIG_CMDLINE_TAG) || \ - defined(CONFIG_INITRD_TAG) || \ - defined(CONFIG_SERIAL_TAG) || \ - defined(CONFIG_REVISION_TAG) -static void setup_start_tag(bd_t *bd) -{ - params = (struct tag *)bd->bi_boot_params; - - params->hdr.tag = ATAG_CORE; - params->hdr.size = tag_size(tag_core); - - params->u.core.flags = 0; - params->u.core.pagesize = 0; - params->u.core.rootdev = 0; - - params = tag_next(params); -} - -#ifdef CONFIG_SETUP_MEMORY_TAGS -static void setup_memory_tags(bd_t *bd) -{ - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - params->hdr.tag = ATAG_MEM; - params->hdr.size = tag_size(tag_mem32); - - params->u.mem.start = bd->bi_dram[i].start; - params->u.mem.size = bd->bi_dram[i].size; - - params = tag_next(params); - } -} -#endif /* CONFIG_SETUP_MEMORY_TAGS */ - -static void setup_commandline_tag(bd_t *bd, char *commandline) -{ - char *p; - - if (!commandline) - return; - - /* eat leading white space */ - for (p = commandline; *p == ' '; p++) - ; - - /* skip non-existent command lines so the kernel will still - * use its default command line. - */ - if (*p == '\0') - return; - - params->hdr.tag = ATAG_CMDLINE; - params->hdr.size = - (sizeof(struct tag_header) + strlen(p) + 1 + 4) >> 2; - - strcpy(params->u.cmdline.cmdline, p) - ; - - params = tag_next(params); -} - -#ifdef CONFIG_INITRD_TAG -static void setup_initrd_tag(bd_t *bd, ulong initrd_start, ulong initrd_end) -{ - /* an ATAG_INITRD node tells the kernel where the compressed - * ramdisk can be found. ATAG_RDIMG is a better name, actually. - */ - params->hdr.tag = ATAG_INITRD2; - params->hdr.size = tag_size(tag_initrd); - - params->u.initrd.start = initrd_start; - params->u.initrd.size = initrd_end - initrd_start; - - params = tag_next(params); -} -#endif /* CONFIG_INITRD_TAG */ - -#ifdef CONFIG_SERIAL_TAG -void setup_serial_tag(struct tag **tmp) -{ - struct tag *params; - struct tag_serialnr serialnr; - void get_board_serial(struct tag_serialnr *serialnr); - - params = *tmp; - get_board_serial(&serialnr); - params->hdr.tag = ATAG_SERIAL; - params->hdr.size = tag_size(tag_serialnr); - params->u.serialnr.low = serialnr.low; - params->u.serialnr.high = serialnr.high; - params = tag_next(params); - *tmp = params; -} -#endif - -#ifdef CONFIG_REVISION_TAG -void setup_revision_tag(struct tag **in_params) -{ - u32 rev; - u32 get_board_rev(void); - - rev = get_board_rev(); - params->hdr.tag = ATAG_REVISION; - params->hdr.size = tag_size(tag_revision); - params->u.revision.rev = rev; - params = tag_next(params); -} -#endif /* CONFIG_REVISION_TAG */ - -static void setup_end_tag(bd_t *bd) -{ - params->hdr.tag = ATAG_NONE; - params->hdr.size = 0; -} - -#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ diff --git a/arch/riscv/lib/interrupts.c b/arch/riscv/lib/interrupts.c index 075db8ba46..923f75275b 100644 --- a/arch/riscv/lib/interrupts.c +++ b/arch/riscv/lib/interrupts.c @@ -63,7 +63,7 @@ __attribute__((weak)) void timer_interrupt(struct pt_regs *regs) static void _exit_trap(int code, uint epc, struct pt_regs *regs) { - static const char *exception_code[] = { + static const char * const exception_code[] = { "Instruction address misaligned", "Instruction access fault", "Illegal instruction", |