GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* Authors:
|
||||
* Anup Patel <anup.patel@wdc.com>
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_ARCH_CLK_H
|
||||
#define __ASM_RISCV_ARCH_CLK_H
|
||||
|
||||
/* Note: This is a placeholder header for driver compilation. */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2019 SiFive, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _GPIO_SIFIVE_H
|
||||
#define _GPIO_SIFIVE_H
|
||||
|
||||
#define GPIO_INPUT_VAL 0x00
|
||||
#define GPIO_INPUT_EN 0x04
|
||||
#define GPIO_OUTPUT_EN 0x08
|
||||
#define GPIO_OUTPUT_VAL 0x0C
|
||||
#define GPIO_RISE_IE 0x18
|
||||
#define GPIO_RISE_IP 0x1C
|
||||
#define GPIO_FALL_IE 0x20
|
||||
#define GPIO_FALL_IP 0x24
|
||||
#define GPIO_HIGH_IE 0x28
|
||||
#define GPIO_HIGH_IP 0x2C
|
||||
#define GPIO_LOW_IE 0x30
|
||||
#define GPIO_LOW_IP 0x34
|
||||
#define GPIO_OUTPUT_XOR 0x40
|
||||
|
||||
#define NR_GPIOS 16
|
||||
|
||||
enum gpio_state {
|
||||
LOW,
|
||||
HIGH
|
||||
};
|
||||
|
||||
/* Details about a GPIO bank */
|
||||
struct sifive_gpio_platdata {
|
||||
void *base; /* address of registers in physical memory */
|
||||
};
|
||||
|
||||
#endif /* _GPIO_SIFIVE_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) 2015 Regents of the University of California
|
||||
*/
|
||||
|
||||
#ifndef _ASM_RISCV_ASM_H
|
||||
#define _ASM_RISCV_ASM_H
|
||||
|
||||
#ifdef __ASSEMBLY__
|
||||
#define __ASM_STR(x) x
|
||||
#else
|
||||
#define __ASM_STR(x) #x
|
||||
#endif
|
||||
|
||||
#if __riscv_xlen == 64
|
||||
#define __REG_SEL(a, b) __ASM_STR(a)
|
||||
#elif __riscv_xlen == 32
|
||||
#define __REG_SEL(a, b) __ASM_STR(b)
|
||||
#else
|
||||
#error "Unexpected __riscv_xlen"
|
||||
#endif
|
||||
|
||||
#define REG_L __REG_SEL(ld, lw)
|
||||
#define REG_S __REG_SEL(sd, sw)
|
||||
#define SZREG __REG_SEL(8, 4)
|
||||
#define LGREG __REG_SEL(3, 2)
|
||||
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
#ifdef __ASSEMBLY__
|
||||
#define RISCV_PTR .dword
|
||||
#define RISCV_SZPTR 8
|
||||
#define RISCV_LGPTR 3
|
||||
#else
|
||||
#define RISCV_PTR ".dword"
|
||||
#define RISCV_SZPTR "8"
|
||||
#define RISCV_LGPTR "3"
|
||||
#endif
|
||||
#elif __SIZEOF_POINTER__ == 4
|
||||
#ifdef __ASSEMBLY__
|
||||
#define RISCV_PTR .word
|
||||
#define RISCV_SZPTR 4
|
||||
#define RISCV_LGPTR 2
|
||||
#else
|
||||
#define RISCV_PTR ".word"
|
||||
#define RISCV_SZPTR "4"
|
||||
#define RISCV_LGPTR "2"
|
||||
#endif
|
||||
#else
|
||||
#error "Unexpected __SIZEOF_POINTER__"
|
||||
#endif
|
||||
|
||||
#if (__SIZEOF_INT__ == 4)
|
||||
#define RISCV_INT __ASM_STR(.word)
|
||||
#define RISCV_SZINT __ASM_STR(4)
|
||||
#define RISCV_LGINT __ASM_STR(2)
|
||||
#else
|
||||
#error "Unexpected __SIZEOF_INT__"
|
||||
#endif
|
||||
|
||||
#if (__SIZEOF_SHORT__ == 2)
|
||||
#define RISCV_SHORT __ASM_STR(.half)
|
||||
#define RISCV_SZSHORT __ASM_STR(2)
|
||||
#define RISCV_LGSHORT __ASM_STR(1)
|
||||
#else
|
||||
#error "Unexpected __SIZEOF_SHORT__"
|
||||
#endif
|
||||
|
||||
#endif /* _ASM_RISCV_ASM_H */
|
||||
@@ -0,0 +1,67 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2012 ARM Ltd.
|
||||
* Copyright (C) 2013 Regents of the University of California
|
||||
* Copyright (C) 2017 SiFive
|
||||
*
|
||||
* Taken from Linux arch/riscv/include/asm/barrier.h, which is based on
|
||||
* arch/arm/include/asm/barrier.h
|
||||
*/
|
||||
|
||||
#ifndef _ASM_RISCV_BARRIER_H
|
||||
#define _ASM_RISCV_BARRIER_H
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#define nop() __asm__ __volatile__ ("nop")
|
||||
|
||||
#define RISCV_FENCE(p, s) \
|
||||
__asm__ __volatile__ ("fence " #p "," #s : : : "memory")
|
||||
|
||||
/* These barriers need to enforce ordering on both devices or memory. */
|
||||
#define mb() RISCV_FENCE(iorw,iorw)
|
||||
#define rmb() RISCV_FENCE(ir,ir)
|
||||
#define wmb() RISCV_FENCE(ow,ow)
|
||||
|
||||
/* These barriers do not need to enforce ordering on devices, just memory. */
|
||||
#define __smp_mb() RISCV_FENCE(rw,rw)
|
||||
#define __smp_rmb() RISCV_FENCE(r,r)
|
||||
#define __smp_wmb() RISCV_FENCE(w,w)
|
||||
|
||||
#define __smp_store_release(p, v) \
|
||||
do { \
|
||||
compiletime_assert_atomic_type(*p); \
|
||||
RISCV_FENCE(rw,w); \
|
||||
WRITE_ONCE(*p, v); \
|
||||
} while (0)
|
||||
|
||||
#define __smp_load_acquire(p) \
|
||||
({ \
|
||||
typeof(*p) ___p1 = READ_ONCE(*p); \
|
||||
compiletime_assert_atomic_type(*p); \
|
||||
RISCV_FENCE(r,rw); \
|
||||
___p1; \
|
||||
})
|
||||
|
||||
/*
|
||||
* This is a very specific barrier: it's currently only used in two places in
|
||||
* the kernel, both in the scheduler. See include/linux/spinlock.h for the two
|
||||
* orderings it guarantees, but the "critical section is RCsc" guarantee
|
||||
* mandates a barrier on RISC-V. The sequence looks like:
|
||||
*
|
||||
* lr.aq lock
|
||||
* sc lock <= LOCKED
|
||||
* smp_mb__after_spinlock()
|
||||
* // critical section
|
||||
* lr lock
|
||||
* sc.rl lock <= UNLOCKED
|
||||
*
|
||||
* The AQ/RL pair provides a RCpc critical section, but there's not really any
|
||||
* way we can take advantage of that here because the ordering is only enforced
|
||||
* on that one lock. Thus, we're just doing a full fence.
|
||||
*/
|
||||
#define smp_mb__after_spinlock() RISCV_FENCE(rw,rw)
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* _ASM_RISCV_BARRIER_H */
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright 1995, Russell King.
|
||||
* Various bits and pieces copyrights include:
|
||||
* Linus Torvalds (test_bit).
|
||||
*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*
|
||||
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
|
||||
*
|
||||
* Please note that the code in this file should never be included
|
||||
* from user space. Many of these are not implemented in assembler
|
||||
* since they would be too costly. Also, they require priviledged
|
||||
* instructions (which are not available from user mode) to ensure
|
||||
* that they are atomic.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_BITOPS_H
|
||||
#define __ASM_RISCV_BITOPS_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#include <asm/system.h>
|
||||
#include <asm-generic/bitops/fls.h>
|
||||
#include <asm-generic/bitops/__fls.h>
|
||||
#include <asm-generic/bitops/fls64.h>
|
||||
#include <asm-generic/bitops/__ffs.h>
|
||||
|
||||
#define smp_mb__before_clear_bit() do { } while (0)
|
||||
#define smp_mb__after_clear_bit() do { } while (0)
|
||||
|
||||
/*
|
||||
* Function prototypes to keep gcc -Wall happy.
|
||||
*/
|
||||
static inline void __set_bit(int nr, void *addr)
|
||||
{
|
||||
int *a = (int *)addr;
|
||||
int mask;
|
||||
|
||||
a += nr >> 5;
|
||||
mask = 1 << (nr & 0x1f);
|
||||
*a |= mask;
|
||||
}
|
||||
|
||||
#define PLATFORM__SET_BIT
|
||||
|
||||
static inline void __clear_bit(int nr, void *addr)
|
||||
{
|
||||
int *a = (int *)addr;
|
||||
int mask;
|
||||
|
||||
a += nr >> 5;
|
||||
mask = 1 << (nr & 0x1f);
|
||||
*a &= ~mask;
|
||||
}
|
||||
|
||||
#define PLATFORM__CLEAR_BIT
|
||||
|
||||
static inline void __change_bit(int nr, void *addr)
|
||||
{
|
||||
int mask;
|
||||
unsigned long *ADDR = (unsigned long *)addr;
|
||||
|
||||
ADDR += nr >> 5;
|
||||
mask = 1 << (nr & 31);
|
||||
*ADDR ^= mask;
|
||||
}
|
||||
|
||||
static inline int __test_and_set_bit(int nr, void *addr)
|
||||
{
|
||||
int mask, retval;
|
||||
unsigned int *a = (unsigned int *)addr;
|
||||
|
||||
a += nr >> 5;
|
||||
mask = 1 << (nr & 0x1f);
|
||||
retval = (mask & *a) != 0;
|
||||
*a |= mask;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline int __test_and_clear_bit(int nr, void *addr)
|
||||
{
|
||||
int mask, retval;
|
||||
unsigned int *a = (unsigned int *)addr;
|
||||
|
||||
a += nr >> 5;
|
||||
mask = 1 << (nr & 0x1f);
|
||||
retval = (mask & *a) != 0;
|
||||
*a &= ~mask;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline int __test_and_change_bit(int nr, void *addr)
|
||||
{
|
||||
int mask, retval;
|
||||
unsigned int *a = (unsigned int *)addr;
|
||||
|
||||
a += nr >> 5;
|
||||
mask = 1 << (nr & 0x1f);
|
||||
retval = (mask & *a) != 0;
|
||||
*a ^= mask;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine doesn't need to be atomic.
|
||||
*/
|
||||
static inline int test_bit(int nr, const void *addr)
|
||||
{
|
||||
return ((unsigned char *)addr)[nr >> 3] & (1U << (nr & 7));
|
||||
}
|
||||
|
||||
/*
|
||||
* ffz = Find First Zero in word. Undefined if no zero exists,
|
||||
* so code should check against ~0UL first..
|
||||
*/
|
||||
static inline unsigned long ffz(unsigned long word)
|
||||
{
|
||||
int k;
|
||||
|
||||
word = ~word;
|
||||
k = 31;
|
||||
if (word & 0x0000ffff) {
|
||||
k -= 16; word <<= 16;
|
||||
}
|
||||
if (word & 0x00ff0000) {
|
||||
k -= 8; word <<= 8;
|
||||
}
|
||||
if (word & 0x0f000000) {
|
||||
k -= 4; word <<= 4;
|
||||
}
|
||||
if (word & 0x30000000) {
|
||||
k -= 2; word <<= 2;
|
||||
}
|
||||
if (word & 0x40000000)
|
||||
k -= 1;
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
/*
|
||||
* ffs: find first bit set. This is defined the same way as
|
||||
* the libc and compiler builtin ffs routines, therefore
|
||||
* differs in spirit from the above ffz (man ffs).
|
||||
*/
|
||||
|
||||
/*
|
||||
* redefined in include/linux/bitops.h
|
||||
* #define ffs(x) generic_ffs(x)
|
||||
*/
|
||||
|
||||
/*
|
||||
* hweightN: returns the hamming weight (i.e. the number
|
||||
* of bits set) of a N-bit word
|
||||
*/
|
||||
|
||||
#define hweight32(x) generic_hweight32(x)
|
||||
#define hweight16(x) generic_hweight16(x)
|
||||
#define hweight8(x) generic_hweight8(x)
|
||||
|
||||
#define ext2_set_bit test_and_set_bit
|
||||
#define ext2_clear_bit test_and_clear_bit
|
||||
#define ext2_test_bit test_bit
|
||||
#define ext2_find_first_zero_bit find_first_zero_bit
|
||||
#define ext2_find_next_zero_bit find_next_zero_bit
|
||||
|
||||
/* Bitmap functions for the minix filesystem. */
|
||||
#define minix_test_and_set_bit(nr, addr) test_and_set_bit(nr, addr)
|
||||
#define minix_set_bit(nr, addr) set_bit(nr, addr)
|
||||
#define minix_test_and_clear_bit(nr, addr) test_and_clear_bit(nr, addr)
|
||||
#define minix_test_bit(nr, addr) test_bit(nr, addr)
|
||||
#define minix_find_first_zero_bit(addr, size) find_first_zero_bit(addr, size)
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* __ASM_RISCV_BITOPS_H */
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* linux/include/asm-arm/byteorder.h
|
||||
*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*
|
||||
* ARM Endian-ness. In little endian mode, the data bus is connected such
|
||||
* that byte accesses appear as:
|
||||
* 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
|
||||
* and word accesses (data or instruction) appear as:
|
||||
* d0...d31
|
||||
*
|
||||
* When in big endian mode, byte accesses appear as:
|
||||
* 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
|
||||
* and word accesses (data or instruction) appear as:
|
||||
* d0...d31
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_BYTEORDER_H
|
||||
#define __ASM_RISCV_BYTEORDER_H
|
||||
|
||||
#include <asm/types.h>
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
|
||||
# define __BYTEORDER_HAS_U64__
|
||||
# define __SWAB_64_THRU_32__
|
||||
#endif
|
||||
|
||||
#ifdef __RISCVEB__
|
||||
#include <linux/byteorder/big_endian.h>
|
||||
#else
|
||||
#include <linux/byteorder/little_endian.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*/
|
||||
|
||||
#ifndef _ASM_RISCV_CACHE_H
|
||||
#define _ASM_RISCV_CACHE_H
|
||||
|
||||
/* cache */
|
||||
void cache_flush(void);
|
||||
|
||||
/*
|
||||
* The current upper bound for RISCV L1 data cache line sizes is 32 bytes.
|
||||
* We use that value for aligning DMA buffers unless the board config has
|
||||
* specified an alternate cache line size.
|
||||
*/
|
||||
#ifdef CONFIG_SYS_CACHELINE_SIZE
|
||||
#define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE
|
||||
#else
|
||||
#define ARCH_DMA_MINALIGN 32
|
||||
#endif
|
||||
|
||||
#endif /* _ASM_RISCV_CACHE_H */
|
||||
@@ -0,0 +1,13 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*/
|
||||
|
||||
#ifndef _ASM_CONFIG_H_
|
||||
#define _ASM_CONFIG_H_
|
||||
|
||||
#define CONFIG_LMB
|
||||
#define CONFIG_SYS_BOOT_RAMDISK_HIGH
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (C) 2015 Regents of the University of California
|
||||
*
|
||||
* Taken from Linux arch/riscv/include/asm/csr.h
|
||||
*/
|
||||
|
||||
#ifndef _ASM_RISCV_CSR_H
|
||||
#define _ASM_RISCV_CSR_H
|
||||
|
||||
#include <asm/asm.h>
|
||||
#include <linux/const.h>
|
||||
|
||||
/* Status register flags */
|
||||
#define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */
|
||||
#define SR_SPIE _AC(0x00000020, UL) /* Previous Supervisor IE */
|
||||
#define SR_SPP _AC(0x00000100, UL) /* Previously Supervisor */
|
||||
#define SR_SUM _AC(0x00040000, UL) /* Supervisor User Memory Access */
|
||||
|
||||
#define SR_FS _AC(0x00006000, UL) /* Floating-point Status */
|
||||
#define SR_FS_OFF _AC(0x00000000, UL)
|
||||
#define SR_FS_INITIAL _AC(0x00002000, UL)
|
||||
#define SR_FS_CLEAN _AC(0x00004000, UL)
|
||||
#define SR_FS_DIRTY _AC(0x00006000, UL)
|
||||
|
||||
#define SR_XS _AC(0x00018000, UL) /* Extension Status */
|
||||
#define SR_XS_OFF _AC(0x00000000, UL)
|
||||
#define SR_XS_INITIAL _AC(0x00008000, UL)
|
||||
#define SR_XS_CLEAN _AC(0x00010000, UL)
|
||||
#define SR_XS_DIRTY _AC(0x00018000, UL)
|
||||
|
||||
#ifndef CONFIG_64BIT
|
||||
#define SR_SD _AC(0x80000000, UL) /* FS/XS dirty */
|
||||
#else
|
||||
#define SR_SD _AC(0x8000000000000000, UL) /* FS/XS dirty */
|
||||
#endif
|
||||
|
||||
/* SATP flags */
|
||||
#ifndef CONFIG_64BIT
|
||||
#define SATP_PPN _AC(0x003FFFFF, UL)
|
||||
#define SATP_MODE_32 _AC(0x80000000, UL)
|
||||
#define SATP_MODE SATP_MODE_32
|
||||
#else
|
||||
#define SATP_PPN _AC(0x00000FFFFFFFFFFF, UL)
|
||||
#define SATP_MODE_39 _AC(0x8000000000000000, UL)
|
||||
#define SATP_MODE SATP_MODE_39
|
||||
#endif
|
||||
|
||||
/* SCAUSE */
|
||||
#define SCAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1))
|
||||
|
||||
#define IRQ_U_SOFT 0
|
||||
#define IRQ_S_SOFT 1
|
||||
#define IRQ_M_SOFT 3
|
||||
#define IRQ_U_TIMER 4
|
||||
#define IRQ_S_TIMER 5
|
||||
#define IRQ_M_TIMER 7
|
||||
#define IRQ_U_EXT 8
|
||||
#define IRQ_S_EXT 9
|
||||
#define IRQ_M_EXT 11
|
||||
|
||||
#define EXC_INST_MISALIGNED 0
|
||||
#define EXC_INST_ACCESS 1
|
||||
#define EXC_BREAKPOINT 3
|
||||
#define EXC_LOAD_ACCESS 5
|
||||
#define EXC_STORE_ACCESS 7
|
||||
#define EXC_SYSCALL 8
|
||||
#define EXC_INST_PAGE_FAULT 12
|
||||
#define EXC_LOAD_PAGE_FAULT 13
|
||||
#define EXC_STORE_PAGE_FAULT 15
|
||||
|
||||
/* SIE (Interrupt Enable) and SIP (Interrupt Pending) flags */
|
||||
#define MIE_MSIE (_AC(0x1, UL) << IRQ_M_SOFT)
|
||||
#define SIE_SSIE (_AC(0x1, UL) << IRQ_S_SOFT)
|
||||
#define SIE_STIE (_AC(0x1, UL) << IRQ_S_TIMER)
|
||||
#define SIE_SEIE (_AC(0x1, UL) << IRQ_S_EXT)
|
||||
|
||||
#define CSR_FCSR 0x003
|
||||
#define CSR_CYCLE 0xc00
|
||||
#define CSR_TIME 0xc01
|
||||
#define CSR_INSTRET 0xc02
|
||||
#define CSR_SSTATUS 0x100
|
||||
#define CSR_SIE 0x104
|
||||
#define CSR_STVEC 0x105
|
||||
#define CSR_SCOUNTEREN 0x106
|
||||
#define CSR_SSCRATCH 0x140
|
||||
#define CSR_SEPC 0x141
|
||||
#define CSR_SCAUSE 0x142
|
||||
#define CSR_STVAL 0x143
|
||||
#define CSR_SIP 0x144
|
||||
#define CSR_SATP 0x180
|
||||
#define CSR_MSTATUS 0x300
|
||||
#define CSR_MISA 0x301
|
||||
#define CSR_MIE 0x304
|
||||
#define CSR_MTVEC 0x305
|
||||
#define CSR_MCOUNTEREN 0x306
|
||||
#define CSR_MSCRATCH 0x340
|
||||
#define CSR_MEPC 0x341
|
||||
#define CSR_MCAUSE 0x342
|
||||
#define CSR_MTVAL 0x343
|
||||
#define CSR_MIP 0x344
|
||||
#define CSR_CYCLEH 0xc80
|
||||
#define CSR_TIMEH 0xc81
|
||||
#define CSR_INSTRETH 0xc82
|
||||
#define CSR_MHARTID 0xf14
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#define csr_swap(csr, val) \
|
||||
({ \
|
||||
unsigned long __v = (unsigned long)(val); \
|
||||
__asm__ __volatile__ ("csrrw %0, " __ASM_STR(csr) ", %1"\
|
||||
: "=r" (__v) : "rK" (__v) \
|
||||
: "memory"); \
|
||||
__v; \
|
||||
})
|
||||
|
||||
#define csr_read(csr) \
|
||||
({ \
|
||||
register unsigned long __v; \
|
||||
__asm__ __volatile__ ("csrr %0, " __ASM_STR(csr) \
|
||||
: "=r" (__v) : \
|
||||
: "memory"); \
|
||||
__v; \
|
||||
})
|
||||
|
||||
#define csr_write(csr, val) \
|
||||
({ \
|
||||
unsigned long __v = (unsigned long)(val); \
|
||||
__asm__ __volatile__ ("csrw " __ASM_STR(csr) ", %0" \
|
||||
: : "rK" (__v) \
|
||||
: "memory"); \
|
||||
})
|
||||
|
||||
#define csr_read_set(csr, val) \
|
||||
({ \
|
||||
unsigned long __v = (unsigned long)(val); \
|
||||
__asm__ __volatile__ ("csrrs %0, " __ASM_STR(csr) ", %1"\
|
||||
: "=r" (__v) : "rK" (__v) \
|
||||
: "memory"); \
|
||||
__v; \
|
||||
})
|
||||
|
||||
#define csr_set(csr, val) \
|
||||
({ \
|
||||
unsigned long __v = (unsigned long)(val); \
|
||||
__asm__ __volatile__ ("csrs " __ASM_STR(csr) ", %0" \
|
||||
: : "rK" (__v) \
|
||||
: "memory"); \
|
||||
})
|
||||
|
||||
#define csr_read_clear(csr, val) \
|
||||
({ \
|
||||
unsigned long __v = (unsigned long)(val); \
|
||||
__asm__ __volatile__ ("csrrc %0, " __ASM_STR(csr) ", %1"\
|
||||
: "=r" (__v) : "rK" (__v) \
|
||||
: "memory"); \
|
||||
__v; \
|
||||
})
|
||||
|
||||
#define csr_clear(csr, val) \
|
||||
({ \
|
||||
unsigned long __v = (unsigned long)(val); \
|
||||
__asm__ __volatile__ ("csrc " __ASM_STR(csr) ", %0" \
|
||||
: : "rK" (__v) \
|
||||
: "memory"); \
|
||||
})
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* _ASM_RISCV_CSR_H */
|
||||
@@ -0,0 +1,38 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (c) 2018 Western Digital Corporation or its affiliates.
|
||||
*
|
||||
* Authors:
|
||||
* Anup Patel <anup.patel@wdc.com>
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_DMA_MAPPING_H
|
||||
#define __ASM_RISCV_DMA_MAPPING_H
|
||||
|
||||
#include <linux/dma-direction.h>
|
||||
|
||||
#define dma_mapping_error(x, y) 0
|
||||
|
||||
static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
|
||||
{
|
||||
*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
|
||||
return (void *)*handle;
|
||||
}
|
||||
|
||||
static inline void dma_free_coherent(void *addr)
|
||||
{
|
||||
free(addr);
|
||||
}
|
||||
|
||||
static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
return (unsigned long)vaddr;
|
||||
}
|
||||
|
||||
static inline void dma_unmap_single(volatile void *vaddr, size_t len,
|
||||
unsigned long paddr)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* __ASM_RISCV_DMA_MAPPING_H */
|
||||
@@ -0,0 +1,159 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (c) 2017 Microsemi Corporation.
|
||||
* Padmarao Begari, Microsemi Corporation <padmarao.begari@microsemi.com>
|
||||
*/
|
||||
|
||||
#ifndef RISCV_CSR_ENCODING_H
|
||||
#define RISCV_CSR_ENCODING_H
|
||||
|
||||
#include <asm/csr.h>
|
||||
|
||||
#if CONFIG_IS_ENABLED(RISCV_SMODE)
|
||||
#define MODE_PREFIX(__suffix) s##__suffix
|
||||
#else
|
||||
#define MODE_PREFIX(__suffix) m##__suffix
|
||||
#endif
|
||||
|
||||
#define MSTATUS_UIE 0x00000001
|
||||
#define MSTATUS_SIE 0x00000002
|
||||
#define MSTATUS_HIE 0x00000004
|
||||
#define MSTATUS_MIE 0x00000008
|
||||
#define MSTATUS_UPIE 0x00000010
|
||||
#define MSTATUS_SPIE 0x00000020
|
||||
#define MSTATUS_HPIE 0x00000040
|
||||
#define MSTATUS_MPIE 0x00000080
|
||||
#define MSTATUS_SPP 0x00000100
|
||||
#define MSTATUS_HPP 0x00000600
|
||||
#define MSTATUS_MPP 0x00001800
|
||||
#define MSTATUS_FS 0x00006000
|
||||
#define MSTATUS_XS 0x00018000
|
||||
#define MSTATUS_MPRV 0x00020000
|
||||
#define MSTATUS_PUM 0x00040000
|
||||
#define MSTATUS_VM 0x1F000000
|
||||
#define MSTATUS32_SD 0x80000000
|
||||
#define MSTATUS64_SD 0x8000000000000000
|
||||
|
||||
#define MCAUSE32_CAUSE 0x7FFFFFFF
|
||||
#define MCAUSE64_CAUSE 0x7FFFFFFFFFFFFFFF
|
||||
#define MCAUSE32_INT 0x80000000
|
||||
#define MCAUSE64_INT 0x8000000000000000
|
||||
|
||||
#define SSTATUS_UIE 0x00000001
|
||||
#define SSTATUS_SIE 0x00000002
|
||||
#define SSTATUS_UPIE 0x00000010
|
||||
#define SSTATUS_SPIE 0x00000020
|
||||
#define SSTATUS_SPP 0x00000100
|
||||
#define SSTATUS_FS 0x00006000
|
||||
#define SSTATUS_XS 0x00018000
|
||||
#define SSTATUS_PUM 0x00040000
|
||||
#define SSTATUS32_SD 0x80000000
|
||||
#define SSTATUS64_SD 0x8000000000000000
|
||||
|
||||
#define MIP_SSIP BIT(IRQ_S_SOFT)
|
||||
#define MIP_MSIP BIT(IRQ_M_SOFT)
|
||||
#define MIP_STIP BIT(IRQ_S_TIMER)
|
||||
#define MIP_MTIP BIT(IRQ_M_TIMER)
|
||||
#define MIP_SEIP BIT(IRQ_S_EXT)
|
||||
#define MIP_MEIP BIT(IRQ_M_EXT)
|
||||
|
||||
#define SIP_SSIP MIP_SSIP
|
||||
#define SIP_STIP MIP_STIP
|
||||
|
||||
#define PRV_U 0
|
||||
#define PRV_S 1
|
||||
#define PRV_H 2
|
||||
#define PRV_M 3
|
||||
|
||||
#define VM_MBARE 0
|
||||
#define VM_MBB 1
|
||||
#define VM_MBBID 2
|
||||
#define VM_SV32 8
|
||||
#define VM_SV39 9
|
||||
#define VM_SV48 10
|
||||
|
||||
#define CAUSE_MISALIGNED_FETCH 0
|
||||
#define CAUSE_FETCH_ACCESS 1
|
||||
#define CAUSE_ILLEGAL_INSTRUCTION 2
|
||||
#define CAUSE_BREAKPOINT 3
|
||||
#define CAUSE_MISALIGNED_LOAD 4
|
||||
#define CAUSE_LOAD_ACCESS 5
|
||||
#define CAUSE_MISALIGNED_STORE 6
|
||||
#define CAUSE_STORE_ACCESS 7
|
||||
#define CAUSE_USER_ECALL 8
|
||||
#define CAUSE_SUPERVISOR_ECALL 9
|
||||
#define CAUSE_MACHINE_ECALL 11
|
||||
#define CAUSE_FETCH_PAGE_FAULT 12
|
||||
#define CAUSE_LOAD_PAGE_FAULT 13
|
||||
#define CAUSE_STORE_PAGE_FAULT 15
|
||||
|
||||
#define DEFAULT_RSTVEC 0x00001000
|
||||
#define DEFAULT_NMIVEC 0x00001004
|
||||
#define DEFAULT_MTVEC 0x00001010
|
||||
#define CONFIG_STRING_ADDR 0x0000100C
|
||||
#define EXT_IO_BASE 0x40000000
|
||||
#define DRAM_BASE 0x80000000
|
||||
|
||||
// page table entry (PTE) fields
|
||||
#define PTE_V 0x001 // Valid
|
||||
#define PTE_TYPE 0x01E // Type
|
||||
#define PTE_R 0x020 // Referenced
|
||||
#define PTE_D 0x040 // Dirty
|
||||
#define PTE_SOFT 0x380 // Reserved for Software
|
||||
|
||||
#define PTE_TYPE_TABLE 0x00
|
||||
#define PTE_TYPE_TABLE_GLOBAL 0x02
|
||||
#define PTE_TYPE_URX_SR 0x04
|
||||
#define PTE_TYPE_URWX_SRW 0x06
|
||||
#define PTE_TYPE_UR_SR 0x08
|
||||
#define PTE_TYPE_URW_SRW 0x0A
|
||||
#define PTE_TYPE_URX_SRX 0x0C
|
||||
#define PTE_TYPE_URWX_SRWX0x0E
|
||||
#define PTE_TYPE_SR 0x10
|
||||
#define PTE_TYPE_SRW 0x12
|
||||
#define PTE_TYPE_SRX 0x14
|
||||
#define PTE_TYPE_SRWX 0x16
|
||||
#define PTE_TYPE_SR_GLOBAL 0x18
|
||||
#define PTE_TYPE_SRW_GLOBAL 0x1A
|
||||
#define PTE_TYPE_SRX_GLOBAL 0x1C
|
||||
#define PTE_TYPE_SRWX_GLOBAL 0x1E
|
||||
|
||||
#define PTE_PPN_SHIFT 10
|
||||
|
||||
#define PTE_TABLE(PTE) ((0x0000000AU >> ((PTE) & 0x1F)) & 1)
|
||||
#define PTE_UR(PTE) ((0x0000AAA0U >> ((PTE) & 0x1F)) & 1)
|
||||
#define PTE_UW(PTE) ((0x00008880U >> ((PTE) & 0x1F)) & 1)
|
||||
#define PTE_UX(PTE) ((0x0000A0A0U >> ((PTE) & 0x1F)) & 1)
|
||||
#define PTE_SR(PTE) ((0xAAAAAAA0U >> ((PTE) & 0x1F)) & 1)
|
||||
#define PTE_SW(PTE) ((0x88888880U >> ((PTE) & 0x1F)) & 1)
|
||||
#define PTE_SX(PTE) ((0xA0A0A000U >> ((PTE) & 0x1F)) & 1)
|
||||
|
||||
#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)))
|
||||
|
||||
#ifdef __riscv
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
# define MSTATUS_SD MSTATUS64_SD
|
||||
# define SSTATUS_SD SSTATUS64_SD
|
||||
# define MCAUSE_INT MCAUSE64_INT
|
||||
# define MCAUSE_CAUSE MCAUSE64_CAUSE
|
||||
# define RISCV_PGLEVEL_BITS 9
|
||||
#else
|
||||
# define MSTATUS_SD MSTATUS32_SD
|
||||
# define SSTATUS_SD SSTATUS32_SD
|
||||
# define RISCV_PGLEVEL_BITS 10
|
||||
# define MCAUSE_INT MCAUSE32_INT
|
||||
# define MCAUSE_CAUSE MCAUSE32_CAUSE
|
||||
#endif
|
||||
|
||||
#define RISCV_PGSHIFT 12
|
||||
#define RISCV_PGSIZE BIT(RISCV_PGSHIFT)
|
||||
|
||||
#endif /* __riscv */
|
||||
|
||||
#endif /* RISCV_CSR_ENCODING_H */
|
||||
@@ -0,0 +1,39 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* Copyright (c) 2017 Microsemi Corporation.
|
||||
* Padmarao Begari, Microsemi Corporation <padmarao.begari@microsemi.com>
|
||||
*/
|
||||
|
||||
#ifndef __ASM_GBL_DATA_H
|
||||
#define __ASM_GBL_DATA_H
|
||||
|
||||
#include <asm/smp.h>
|
||||
|
||||
/* Architecture-specific global data */
|
||||
struct arch_global_data {
|
||||
long boot_hart; /* boot hart id */
|
||||
#ifdef CONFIG_SIFIVE_CLINT
|
||||
void __iomem *clint; /* clint base address */
|
||||
#endif
|
||||
#ifdef CONFIG_ANDES_PLIC
|
||||
void __iomem *plic; /* plic base address */
|
||||
#endif
|
||||
#ifdef CONFIG_ANDES_PLMT
|
||||
void __iomem *plmt; /* plmt base address */
|
||||
#endif
|
||||
#ifdef CONFIG_SMP
|
||||
struct ipi_data ipi[CONFIG_NR_CPUS];
|
||||
#endif
|
||||
#ifndef CONFIG_XIP
|
||||
ulong available_harts;
|
||||
#endif
|
||||
};
|
||||
|
||||
#include <asm-generic/global_data.h>
|
||||
|
||||
#define DECLARE_GLOBAL_DATA_PTR register gd_t *gd asm ("gp")
|
||||
|
||||
#endif /* __ASM_GBL_DATA_H */
|
||||
@@ -0,0 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright 2018 SiFive, Inc.
|
||||
*/
|
||||
|
||||
#include <asm-generic/gpio.h>
|
||||
@@ -0,0 +1,462 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*
|
||||
*/
|
||||
#ifndef __ASM_RISCV_IO_H
|
||||
#define __ASM_RISCV_IO_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <asm/barrier.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
static inline void sync(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_MAP_SYSMEM
|
||||
static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
|
||||
{
|
||||
if (paddr < PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE)
|
||||
paddr = paddr | 0x40000000;
|
||||
return (void *)(uintptr_t)paddr;
|
||||
}
|
||||
|
||||
static inline void *unmap_sysmem(const void *vaddr)
|
||||
{
|
||||
phys_addr_t paddr = (phys_addr_t)vaddr;
|
||||
|
||||
paddr = paddr & ~0x40000000;
|
||||
return (void *)(uintptr_t)paddr;
|
||||
}
|
||||
|
||||
static inline phys_addr_t map_to_sysmem(const void *ptr)
|
||||
{
|
||||
return (phys_addr_t)(uintptr_t)ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generic virtual read/write. Note that we don't support half-word
|
||||
* read/writes. We define __arch_*[bl] here, and leave __arch_*w
|
||||
* to the architecture specific code.
|
||||
*/
|
||||
#define __arch_getb(a) (*(unsigned char *)(a))
|
||||
#define __arch_getw(a) (*(unsigned short *)(a))
|
||||
#define __arch_getl(a) (*(unsigned int *)(a))
|
||||
#define __arch_getq(a) (*(unsigned long long *)(a))
|
||||
|
||||
#define __arch_putb(v, a) (*(unsigned char *)(a) = (v))
|
||||
#define __arch_putw(v, a) (*(unsigned short *)(a) = (v))
|
||||
#define __arch_putl(v, a) (*(unsigned int *)(a) = (v))
|
||||
#define __arch_putq(v, a) (*(unsigned long long *)(a) = (v))
|
||||
|
||||
#define __raw_writeb(v, a) __arch_putb(v, a)
|
||||
#define __raw_writew(v, a) __arch_putw(v, a)
|
||||
#define __raw_writel(v, a) __arch_putl(v, a)
|
||||
#define __raw_writeq(v, a) __arch_putq(v, a)
|
||||
|
||||
#define __raw_readb(a) __arch_getb(a)
|
||||
#define __raw_readw(a) __arch_getw(a)
|
||||
#define __raw_readl(a) __arch_getl(a)
|
||||
#define __raw_readq(a) __arch_getq(a)
|
||||
|
||||
#define dmb() mb()
|
||||
#define __iormb() rmb()
|
||||
#define __iowmb() wmb()
|
||||
|
||||
static inline void writeb(u8 val, volatile void __iomem *addr)
|
||||
{
|
||||
__iowmb();
|
||||
__arch_putb(val, addr);
|
||||
}
|
||||
|
||||
static inline void writew(u16 val, volatile void __iomem *addr)
|
||||
{
|
||||
__iowmb();
|
||||
__arch_putw(val, addr);
|
||||
}
|
||||
|
||||
static inline void writel(u32 val, volatile void __iomem *addr)
|
||||
{
|
||||
__iowmb();
|
||||
__arch_putl(val, addr);
|
||||
}
|
||||
|
||||
static inline void writeq(u64 val, volatile void __iomem *addr)
|
||||
{
|
||||
__iowmb();
|
||||
__arch_putq(val, addr);
|
||||
}
|
||||
|
||||
static inline u8 readb(const volatile void __iomem *addr)
|
||||
{
|
||||
u8 val;
|
||||
|
||||
val = __arch_getb(addr);
|
||||
__iormb();
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline u16 readw(const volatile void __iomem *addr)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
val = __arch_getw(addr);
|
||||
__iormb();
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline u32 readl(const volatile void __iomem *addr)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = __arch_getl(addr);
|
||||
__iormb();
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline u64 readq(const volatile void __iomem *addr)
|
||||
{
|
||||
u64 val;
|
||||
|
||||
val = __arch_getq(addr);
|
||||
__iormb();
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* The compiler seems to be incapable of optimising constants
|
||||
* properly. Spell it out to the compiler in some cases.
|
||||
* These are only valid for small values of "off" (< 1<<12)
|
||||
*/
|
||||
#define __raw_base_writeb(val, base, off) __arch_base_putb(val, base, off)
|
||||
#define __raw_base_writew(val, base, off) __arch_base_putw(val, base, off)
|
||||
#define __raw_base_writel(val, base, off) __arch_base_putl(val, base, off)
|
||||
|
||||
#define __raw_base_readb(base, off) __arch_base_getb(base, off)
|
||||
#define __raw_base_readw(base, off) __arch_base_getw(base, off)
|
||||
#define __raw_base_readl(base, off) __arch_base_getl(base, off)
|
||||
|
||||
#define out_arch(type, endian, a, v) __raw_write##type(cpu_to_##endian(v), a)
|
||||
#define in_arch(type, endian, a) endian##_to_cpu(__raw_read##type(a))
|
||||
|
||||
#define out_le32(a, v) out_arch(l, le32, a, v)
|
||||
#define out_le16(a, v) out_arch(w, le16, a, v)
|
||||
|
||||
#define in_le32(a) in_arch(l, le32, a)
|
||||
#define in_le16(a) in_arch(w, le16, a)
|
||||
|
||||
#define out_be32(a, v) out_arch(l, be32, a, v)
|
||||
#define out_be16(a, v) out_arch(w, be16, a, v)
|
||||
|
||||
#define in_be32(a) in_arch(l, be32, a)
|
||||
#define in_be16(a) in_arch(w, be16, a)
|
||||
|
||||
#define out_8(a, v) __raw_writeb(v, a)
|
||||
#define in_8(a) __raw_readb(a)
|
||||
|
||||
/*
|
||||
* Clear and set bits in one shot. These macros can be used to clear and
|
||||
* set multiple bits in a register using a single call. These macros can
|
||||
* also be used to set a multiple-bit bit pattern using a mask, by
|
||||
* specifying the mask in the 'clear' parameter and the new bit pattern
|
||||
* in the 'set' parameter.
|
||||
*/
|
||||
|
||||
#define clrbits(type, addr, clear) \
|
||||
out_##type((addr), in_##type(addr) & ~(clear))
|
||||
|
||||
#define setbits(type, addr, set) \
|
||||
out_##type((addr), in_##type(addr) | (set))
|
||||
|
||||
#define clrsetbits(type, addr, clear, set) \
|
||||
out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
|
||||
|
||||
#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
|
||||
#define setbits_be32(addr, set) setbits(be32, addr, set)
|
||||
#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
|
||||
|
||||
#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
|
||||
#define setbits_le32(addr, set) setbits(le32, addr, set)
|
||||
#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
|
||||
|
||||
#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
|
||||
#define setbits_be16(addr, set) setbits(be16, addr, set)
|
||||
#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
|
||||
|
||||
#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
|
||||
#define setbits_le16(addr, set) setbits(le16, addr, set)
|
||||
#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
|
||||
|
||||
#define clrbits_8(addr, clear) clrbits(8, addr, clear)
|
||||
#define setbits_8(addr, set) setbits(8, addr, set)
|
||||
#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
|
||||
|
||||
/*
|
||||
* Now, pick up the machine-defined IO definitions
|
||||
* #include <asm/arch/io.h>
|
||||
*/
|
||||
|
||||
/*
|
||||
* IO port access primitives
|
||||
* -------------------------
|
||||
*
|
||||
* The NDS32 doesn't have special IO access instructions just like ARM;
|
||||
* all IO is memory mapped.
|
||||
* Note that these are defined to perform little endian accesses
|
||||
* only. Their primary purpose is to access PCI and ISA peripherals.
|
||||
*
|
||||
* Note that for a big endian machine, this implies that the following
|
||||
* big endian mode connectivity is in place, as described by numerious
|
||||
* ARM documents:
|
||||
*
|
||||
* PCI: D0-D7 D8-D15 D16-D23 D24-D31
|
||||
* ARM: D24-D31 D16-D23 D8-D15 D0-D7
|
||||
*
|
||||
* The machine specific io.h include defines __io to translate an "IO"
|
||||
* address to a memory address.
|
||||
*
|
||||
* Note that we prevent GCC re-ordering or caching values in expressions
|
||||
* by introducing sequence points into the in*() definitions. Note that
|
||||
* __raw_* do not guarantee this behaviour.
|
||||
*
|
||||
* The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space.
|
||||
*/
|
||||
#ifdef __io
|
||||
#define outb(v, p) __raw_writeb(v, __io(p))
|
||||
#define outw(v, p) __raw_writew(cpu_to_le16(v), __io(p))
|
||||
#define outl(v, p) __raw_writel(cpu_to_le32(v), __io(p))
|
||||
|
||||
#define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; })
|
||||
#define inw(p) ({ unsigned int __v = le16_to_cpu(__raw_readw(__io(p))); __v; })
|
||||
#define inl(p) ({ unsigned int __v = le32_to_cpu(__raw_readl(__io(p))); __v; })
|
||||
|
||||
#define outsb(p, d, l) writesb(__io(p), d, l)
|
||||
#define outsw(p, d, l) writesw(__io(p), d, l)
|
||||
#define outsl(p, d, l) writesl(__io(p), d, l)
|
||||
|
||||
#define insb(p, d, l) readsb(__io(p), d, l)
|
||||
#define insw(p, d, l) readsw(__io(p), d, l)
|
||||
#define insl(p, d, l) readsl(__io(p), d, l)
|
||||
|
||||
static inline void readsb(unsigned int *addr, void *data, int bytelen)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
unsigned char *ptr2;
|
||||
|
||||
ptr = (unsigned char *)addr;
|
||||
ptr2 = (unsigned char *)data;
|
||||
|
||||
while (bytelen) {
|
||||
*ptr2 = *ptr;
|
||||
ptr2++;
|
||||
bytelen--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void readsw(unsigned int *addr, void *data, int wordlen)
|
||||
{
|
||||
unsigned short *ptr;
|
||||
unsigned short *ptr2;
|
||||
|
||||
ptr = (unsigned short *)addr;
|
||||
ptr2 = (unsigned short *)data;
|
||||
|
||||
while (wordlen) {
|
||||
*ptr2 = *ptr;
|
||||
ptr2++;
|
||||
wordlen--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void readsl(unsigned int *addr, void *data, int longlen)
|
||||
{
|
||||
unsigned int *ptr;
|
||||
unsigned int *ptr2;
|
||||
|
||||
ptr = (unsigned int *)addr;
|
||||
ptr2 = (unsigned int *)data;
|
||||
|
||||
while (longlen) {
|
||||
*ptr2 = *ptr;
|
||||
ptr2++;
|
||||
longlen--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void writesb(unsigned int *addr, const void *data, int bytelen)
|
||||
{
|
||||
unsigned char *ptr;
|
||||
unsigned char *ptr2;
|
||||
|
||||
ptr = (unsigned char *)addr;
|
||||
ptr2 = (unsigned char *)data;
|
||||
|
||||
while (bytelen) {
|
||||
*ptr = *ptr2;
|
||||
ptr2++;
|
||||
bytelen--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void writesw(unsigned int *addr, const void *data, int wordlen)
|
||||
{
|
||||
unsigned short *ptr;
|
||||
unsigned short *ptr2;
|
||||
|
||||
ptr = (unsigned short *)addr;
|
||||
ptr2 = (unsigned short *)data;
|
||||
|
||||
while (wordlen) {
|
||||
*ptr = *ptr2;
|
||||
ptr2++;
|
||||
wordlen--;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void writesl(unsigned int *addr, const void *data, int longlen)
|
||||
{
|
||||
unsigned int *ptr;
|
||||
unsigned int *ptr2;
|
||||
|
||||
ptr = (unsigned int *)addr;
|
||||
ptr2 = (unsigned int *)data;
|
||||
|
||||
while (longlen) {
|
||||
*ptr = *ptr2;
|
||||
ptr2++;
|
||||
longlen--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define outb_p(val, port) outb((val), (port))
|
||||
#define outw_p(val, port) outw((val), (port))
|
||||
#define outl_p(val, port) outl((val), (port))
|
||||
#define inb_p(port) inb((port))
|
||||
#define inw_p(port) inw((port))
|
||||
#define inl_p(port) inl((port))
|
||||
|
||||
#define outsb_p(port, from, len) outsb(port, from, len)
|
||||
#define outsw_p(port, from, len) outsw(port, from, len)
|
||||
#define outsl_p(port, from, len) outsl(port, from, len)
|
||||
#define insb_p(port, to, len) insb(port, to, len)
|
||||
#define insw_p(port, to, len) insw(port, to, len)
|
||||
#define insl_p(port, to, len) insl(port, to, len)
|
||||
|
||||
/*
|
||||
* DMA-consistent mapping functions. These allocate/free a region of
|
||||
* uncached, unwrite-buffered mapped memory space for use with DMA
|
||||
* devices. This is the "generic" version. The PCI specific version
|
||||
* is in pci.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* String version of IO memory access ops:
|
||||
*/
|
||||
|
||||
/*
|
||||
* If this architecture has PCI memory IO, then define the read/write
|
||||
* macros. These should only be used with the cookie passed from
|
||||
* ioremap.
|
||||
*/
|
||||
#ifdef __mem_pci
|
||||
|
||||
#define readb(c) ({ unsigned int __v = \
|
||||
__raw_readb(__mem_pci(c)); __v; })
|
||||
#define readw(c) ({ unsigned int __v = \
|
||||
le16_to_cpu(__raw_readw(__mem_pci(c))); __v; })
|
||||
#define readl(c) ({ unsigned int __v = \
|
||||
le32_to_cpu(__raw_readl(__mem_pci(c))); __v; })
|
||||
|
||||
#define writeb(v, c) __raw_writeb(v, __mem_pci(c))
|
||||
#define writew(v, c) __raw_writew(cpu_to_le16(v), __mem_pci(c))
|
||||
#define writel(v, c) __raw_writel(cpu_to_le32(v), __mem_pci(c))
|
||||
|
||||
#define memset_io(c, v, l) _memset_io(__mem_pci(c), (v), (l))
|
||||
#define memcpy_fromio(a, c, l) _memcpy_fromio((a), __mem_pci(c), (l))
|
||||
#define memcpy_toio(c, a, l) _memcpy_toio(__mem_pci(c), (a), (l))
|
||||
|
||||
#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(ulong io_addr, const uchar *s, int len)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
do {
|
||||
if (readb(io_addr) != *s)
|
||||
goto out;
|
||||
io_addr++;
|
||||
s++;
|
||||
len--;
|
||||
} while (len);
|
||||
retval = 1;
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
#endif /* __mem_pci */
|
||||
|
||||
/*
|
||||
* If this architecture has ISA IO, then define the isa_read/isa_write
|
||||
* macros.
|
||||
*/
|
||||
#ifdef __mem_isa
|
||||
|
||||
#define isa_readb(addr) __raw_readb(__mem_isa(addr))
|
||||
#define isa_readw(addr) __raw_readw(__mem_isa(addr))
|
||||
#define isa_readl(addr) __raw_readl(__mem_isa(addr))
|
||||
#define isa_writeb(val, addr) __raw_writeb(val, __mem_isa(addr))
|
||||
#define isa_writew(val, addr) __raw_writew(val, __mem_isa(addr))
|
||||
#define isa_writel(val, addr) __raw_writel(val, __mem_isa(addr))
|
||||
#define isa_memset_io(a, b, c) _memset_io(__mem_isa(a), (b), (c))
|
||||
#define isa_memcpy_fromio(a, b, c) _memcpy_fromio((a), __mem_isa(b), (c))
|
||||
#define isa_memcpy_toio(a, b, c) _memcpy_toio(__mem_isa((a)), (b), (c))
|
||||
|
||||
#define isa_eth_io_copy_and_sum(a, b, c, d) \
|
||||
eth_copy_and_sum((a), __mem_isa(b), (c), (d))
|
||||
|
||||
static inline int
|
||||
isa_check_signature(ulong io_addr, const uchar *s, int len)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
do {
|
||||
if (isa_readb(io_addr) != *s)
|
||||
goto out;
|
||||
io_addr++;
|
||||
s++;
|
||||
len--;
|
||||
} while (len);
|
||||
retval = 1;
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
#else /* __mem_isa */
|
||||
|
||||
#define isa_readb(addr) (__readwrite_bug("isa_readb"), 0)
|
||||
#define isa_readw(addr) (__readwrite_bug("isa_readw"), 0)
|
||||
#define isa_readl(addr) (__readwrite_bug("isa_readl"), 0)
|
||||
#define isa_writeb(val, addr) __readwrite_bug("isa_writeb")
|
||||
#define isa_writew(val, addr) __readwrite_bug("isa_writew")
|
||||
#define isa_writel(val, addr) __readwrite_bug("isa_writel")
|
||||
#define isa_memset_io(a, b, c) __readwrite_bug("isa_memset_io")
|
||||
#define isa_memcpy_fromio(a, b, c) __readwrite_bug("isa_memcpy_fromio")
|
||||
#define isa_memcpy_toio(a, b, c) __readwrite_bug("isa_memcpy_toio")
|
||||
|
||||
#define isa_eth_io_copy_and_sum(a, b, c, d) \
|
||||
__readwrite_bug("isa_eth_io_copy_and_sum")
|
||||
|
||||
#define isa_check_signature(io, sig, len) (0)
|
||||
|
||||
#endif /* __mem_isa */
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#include <asm-generic/io.h>
|
||||
|
||||
#endif /* __ASM_RISCV_IO_H */
|
||||
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* U-Boot - linkage.h
|
||||
*
|
||||
* Copyright (c) 2005-2007 Analog Devices Inc.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_LINKAGE_H
|
||||
#define __ASM_LINKAGE_H
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* linux/include/asm-arm/posix_types.h
|
||||
*
|
||||
* Copyright (C) 1996-1998 Russell King.
|
||||
*
|
||||
* Copyright (C) 2011 Andes Technology Corporation
|
||||
* Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
|
||||
* Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
|
||||
* Copyright (C) 2017 Rick Chen (rick@andestech.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* Changelog:
|
||||
* 27-06-1996 RMK Created
|
||||
* 25-10-2017 Modified for arch RISCV
|
||||
*/
|
||||
#ifndef __ARCH_RISCV_POSIX_TYPES_H
|
||||
#define __ARCH_RISCV_POSIX_TYPES_H
|
||||
|
||||
/*
|
||||
* This file is generally used by user-level software, so you need to
|
||||
* be a little careful about namespace pollution etc. Also, we cannot
|
||||
* assume GCC is being used.
|
||||
*/
|
||||
|
||||
typedef unsigned short __kernel_dev_t;
|
||||
typedef unsigned long __kernel_ino_t;
|
||||
typedef unsigned short __kernel_mode_t;
|
||||
typedef unsigned short __kernel_nlink_t;
|
||||
typedef long __kernel_off_t;
|
||||
typedef int __kernel_pid_t;
|
||||
typedef unsigned short __kernel_ipc_pid_t;
|
||||
typedef unsigned short __kernel_uid_t;
|
||||
typedef unsigned short __kernel_gid_t;
|
||||
#ifdef __GNUC__
|
||||
typedef __SIZE_TYPE__ __kernel_size_t;
|
||||
#else
|
||||
typedef unsigned long __kernel_size_t;
|
||||
#endif
|
||||
typedef long __kernel_ssize_t;
|
||||
typedef long __kernel_ptrdiff_t;
|
||||
typedef long __kernel_time_t;
|
||||
typedef long __kernel_suseconds_t;
|
||||
typedef long __kernel_clock_t;
|
||||
typedef int __kernel_daddr_t;
|
||||
typedef char *__kernel_caddr_t;
|
||||
typedef unsigned short __kernel_uid16_t;
|
||||
typedef unsigned short __kernel_gid16_t;
|
||||
typedef unsigned int __kernel_uid32_t;
|
||||
typedef unsigned int __kernel_gid32_t;
|
||||
|
||||
typedef unsigned short __kernel_old_uid_t;
|
||||
typedef unsigned short __kernel_old_gid_t;
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef long long __kernel_loff_t;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
#if defined(__KERNEL__) || defined(__USE_ALL)
|
||||
int val[2];
|
||||
#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
|
||||
int __val[2];
|
||||
#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
|
||||
} __kernel_fsid_t;
|
||||
|
||||
#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
|
||||
|
||||
#undef __FD_SET
|
||||
#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) \
|
||||
typeof(_fd) (fd) = (_fd); \
|
||||
(((fd_set *)fdsetp)->fds_bits[fd >> 5] &= ~(1 << (fd & 31)))
|
||||
|
||||
#undef __FD_ISSET
|
||||
#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) \
|
||||
typeof(_fdsetp) (fd) = (_fdsetp); \
|
||||
(memset(fdsetp, 0, sizeof(*(fd_set *)fdsetp)))
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_RISCV_POSIX_TYPES_H */
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* linux/include/asm-arm/processor.h
|
||||
*
|
||||
* Copyright (C) 1995-2002 Russell King
|
||||
*
|
||||
* Copyright (C) 2011 Andes Technology Corporation
|
||||
* Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
|
||||
* Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
|
||||
* Copyright (C) 2017 Rick Chen (rick@andestech.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_PROCESSOR_H
|
||||
#define __ASM_RISCV_PROCESSOR_H
|
||||
|
||||
/**************************************************************
|
||||
* CAUTION:
|
||||
* - do not implement for RISCV Arch yet.
|
||||
* - so far some files include /asm/processor.h, but
|
||||
* no one uses the macros defined in this head file.
|
||||
**************************************************************/
|
||||
|
||||
#endif /* __ASM_RISCV_PROCESSOR_H */
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Microsemi Corporation.
|
||||
* Copyright (c) 2017 Padmarao Begari <Padmarao.Begari@microsemi.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
#ifndef __ASM_RISCV_PTRACE_H
|
||||
#define __ASM_RISCV_PTRACE_H
|
||||
|
||||
struct pt_regs {
|
||||
unsigned long sepc;
|
||||
unsigned long ra;
|
||||
unsigned long sp;
|
||||
unsigned long gp;
|
||||
unsigned long tp;
|
||||
unsigned long t0;
|
||||
unsigned long t1;
|
||||
unsigned long t2;
|
||||
unsigned long s0;
|
||||
unsigned long s1;
|
||||
unsigned long a0;
|
||||
unsigned long a1;
|
||||
unsigned long a2;
|
||||
unsigned long a3;
|
||||
unsigned long a4;
|
||||
unsigned long a5;
|
||||
unsigned long a6;
|
||||
unsigned long a7;
|
||||
unsigned long s2;
|
||||
unsigned long s3;
|
||||
unsigned long s4;
|
||||
unsigned long s5;
|
||||
unsigned long s6;
|
||||
unsigned long s7;
|
||||
unsigned long s8;
|
||||
unsigned long s9;
|
||||
unsigned long s10;
|
||||
unsigned long s11;
|
||||
unsigned long t3;
|
||||
unsigned long t4;
|
||||
unsigned long t5;
|
||||
unsigned long t6;
|
||||
/* Supervisor CSRs */
|
||||
unsigned long sstatus;
|
||||
unsigned long sbadaddr;
|
||||
unsigned long scause;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#define REG_FMT "%016lx"
|
||||
#else
|
||||
#define REG_FMT "%08lx"
|
||||
#endif
|
||||
|
||||
#define user_mode(regs) (((regs)->sstatus & SR_PS) == 0)
|
||||
|
||||
/* Helpers for working with the instruction pointer */
|
||||
#define GET_IP(regs) ((regs)->sepc)
|
||||
#define SET_IP(regs, val) (GET_IP(regs) = (val))
|
||||
|
||||
static inline unsigned long instruction_pointer(struct pt_regs *regs)
|
||||
{
|
||||
return GET_IP(regs);
|
||||
}
|
||||
|
||||
static inline void instruction_pointer_set(struct pt_regs *regs, ulong val)
|
||||
{
|
||||
SET_IP(regs, val);
|
||||
}
|
||||
|
||||
#define profile_pc(regs) instruction_pointer(regs)
|
||||
|
||||
/* Helpers for working with the user stack pointer */
|
||||
#define GET_USP(regs) ((regs)->sp)
|
||||
#define SET_USP(regs, val) (GET_USP(regs) = (val))
|
||||
|
||||
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, ulong val)
|
||||
{
|
||||
SET_USP(regs, val);
|
||||
}
|
||||
|
||||
/* Helpers for working with the frame pointer */
|
||||
#define GET_FP(regs) ((regs)->s0)
|
||||
#define SET_FP(regs, val) (GET_FP(regs) = (val))
|
||||
|
||||
static inline unsigned long frame_pointer(struct pt_regs *regs)
|
||||
{
|
||||
return GET_FP(regs);
|
||||
}
|
||||
|
||||
static inline void frame_pointer_set(struct pt_regs *regs, ulong val)
|
||||
{
|
||||
SET_FP(regs, val);
|
||||
}
|
||||
|
||||
#endif /* __ASM_RISCV_PTRACE_H */
|
||||
@@ -0,0 +1,94 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2015 Regents of the University of California
|
||||
*
|
||||
* Taken from Linux arch/riscv/include/asm/sbi.h
|
||||
*/
|
||||
|
||||
#ifndef _ASM_RISCV_SBI_H
|
||||
#define _ASM_RISCV_SBI_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#define SBI_SET_TIMER 0
|
||||
#define SBI_CONSOLE_PUTCHAR 1
|
||||
#define SBI_CONSOLE_GETCHAR 2
|
||||
#define SBI_CLEAR_IPI 3
|
||||
#define SBI_SEND_IPI 4
|
||||
#define SBI_REMOTE_FENCE_I 5
|
||||
#define SBI_REMOTE_SFENCE_VMA 6
|
||||
#define SBI_REMOTE_SFENCE_VMA_ASID 7
|
||||
#define SBI_SHUTDOWN 8
|
||||
|
||||
#define SBI_CALL(which, arg0, arg1, arg2) ({ \
|
||||
register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0); \
|
||||
register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1); \
|
||||
register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2); \
|
||||
register uintptr_t a7 asm ("a7") = (uintptr_t)(which); \
|
||||
asm volatile ("ecall" \
|
||||
: "+r" (a0) \
|
||||
: "r" (a1), "r" (a2), "r" (a7) \
|
||||
: "memory"); \
|
||||
a0; \
|
||||
})
|
||||
|
||||
/* Lazy implementations until SBI is finalized */
|
||||
#define SBI_CALL_0(which) SBI_CALL(which, 0, 0, 0)
|
||||
#define SBI_CALL_1(which, arg0) SBI_CALL(which, arg0, 0, 0)
|
||||
#define SBI_CALL_2(which, arg0, arg1) SBI_CALL(which, arg0, arg1, 0)
|
||||
|
||||
static inline void sbi_console_putchar(int ch)
|
||||
{
|
||||
SBI_CALL_1(SBI_CONSOLE_PUTCHAR, ch);
|
||||
}
|
||||
|
||||
static inline int sbi_console_getchar(void)
|
||||
{
|
||||
return SBI_CALL_0(SBI_CONSOLE_GETCHAR);
|
||||
}
|
||||
|
||||
static inline void sbi_set_timer(uint64_t stime_value)
|
||||
{
|
||||
#if __riscv_xlen == 32
|
||||
SBI_CALL_2(SBI_SET_TIMER, stime_value, stime_value >> 32);
|
||||
#else
|
||||
SBI_CALL_1(SBI_SET_TIMER, stime_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void sbi_shutdown(void)
|
||||
{
|
||||
SBI_CALL_0(SBI_SHUTDOWN);
|
||||
}
|
||||
|
||||
static inline void sbi_clear_ipi(void)
|
||||
{
|
||||
SBI_CALL_0(SBI_CLEAR_IPI);
|
||||
}
|
||||
|
||||
static inline void sbi_send_ipi(const unsigned long *hart_mask)
|
||||
{
|
||||
SBI_CALL_1(SBI_SEND_IPI, hart_mask);
|
||||
}
|
||||
|
||||
static inline void sbi_remote_fence_i(const unsigned long *hart_mask)
|
||||
{
|
||||
SBI_CALL_1(SBI_REMOTE_FENCE_I, hart_mask);
|
||||
}
|
||||
|
||||
static inline void sbi_remote_sfence_vma(const unsigned long *hart_mask,
|
||||
unsigned long start,
|
||||
unsigned long size)
|
||||
{
|
||||
SBI_CALL_1(SBI_REMOTE_SFENCE_VMA, hart_mask);
|
||||
}
|
||||
|
||||
static inline void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
|
||||
unsigned long start,
|
||||
unsigned long size,
|
||||
unsigned long asid)
|
||||
{
|
||||
SBI_CALL_1(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (c) 2012 The Chromium OS Authors.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_SECTIONS_H
|
||||
#define __ASM_RISCV_SECTIONS_H
|
||||
|
||||
#include <asm-generic/sections.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2018 Alexander Graf <agraf@suse.de>
|
||||
*/
|
||||
|
||||
#ifndef _SETJMP_H_
|
||||
#define _SETJMP_H_ 1
|
||||
|
||||
/*
|
||||
* This really should be opaque, but the EFI implementation wrongly
|
||||
* assumes that a 'struct jmp_buf_data' is defined.
|
||||
*/
|
||||
struct jmp_buf_data {
|
||||
/* x2, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, sp */
|
||||
unsigned long s_regs[12]; /* s0 - s11 */
|
||||
unsigned long ra;
|
||||
unsigned long sp;
|
||||
};
|
||||
|
||||
typedef struct jmp_buf_data jmp_buf[1];
|
||||
|
||||
int setjmp(jmp_buf jmp);
|
||||
void longjmp(jmp_buf jmp, int ret);
|
||||
|
||||
#endif /* _SETJMP_H_ */
|
||||
@@ -0,0 +1,54 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Copyright (C) 2019 Fraunhofer AISEC,
|
||||
* Lukas Auer <lukas.auer@aisec.fraunhofer.de>
|
||||
*/
|
||||
|
||||
#ifndef _ASM_RISCV_SMP_H
|
||||
#define _ASM_RISCV_SMP_H
|
||||
|
||||
/**
|
||||
* struct ipi_data - Inter-processor interrupt (IPI) data structure
|
||||
*
|
||||
* IPIs are used for SMP support to communicate to other harts what function to
|
||||
* call. Functions are in the form
|
||||
* void (*addr)(ulong hart, ulong arg0, ulong arg1).
|
||||
*
|
||||
* The function address and the two arguments, arg0 and arg1, are stored in the
|
||||
* IPI data structure. The hart ID is inserted by the hart handling the IPI and
|
||||
* calling the function.
|
||||
*
|
||||
* @addr: Address of function
|
||||
* @arg0: First argument of function
|
||||
* @arg1: Second argument of function
|
||||
*/
|
||||
struct ipi_data {
|
||||
ulong addr;
|
||||
ulong arg0;
|
||||
ulong arg1;
|
||||
};
|
||||
|
||||
/**
|
||||
* handle_ipi() - interrupt handler for software interrupts
|
||||
*
|
||||
* The IPI interrupt handler must be called to handle software interrupts. It
|
||||
* calls the function specified in the hart's IPI data structure.
|
||||
*
|
||||
* @hart: Hart ID of the current hart
|
||||
*/
|
||||
void handle_ipi(ulong hart);
|
||||
|
||||
/**
|
||||
* smp_call_function() - Call a function on all other harts
|
||||
*
|
||||
* Send IPIs with the specified function call to all harts.
|
||||
*
|
||||
* @addr: Address of function
|
||||
* @arg0: First argument of function
|
||||
* @arg1: Second argument of function
|
||||
* @wait: Wait for harts to acknowledge request
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int smp_call_function(ulong addr, ulong arg0, ulong arg1, int wait);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Based on arch/mips/include/asm/spl.h.
|
||||
*
|
||||
* (C) Copyright 2012
|
||||
* Texas Instruments, <www.ti.com>
|
||||
*/
|
||||
#ifndef _ASM_RISCV_SPL_H_
|
||||
#define _ASM_RISCV_SPL_H_
|
||||
|
||||
enum {
|
||||
BOOT_DEVICE_RAM,
|
||||
BOOT_DEVICE_MMC1,
|
||||
BOOT_DEVICE_MMC2,
|
||||
BOOT_DEVICE_MMC2_2,
|
||||
BOOT_DEVICE_NAND,
|
||||
BOOT_DEVICE_ONENAND,
|
||||
BOOT_DEVICE_NOR,
|
||||
BOOT_DEVICE_UART,
|
||||
BOOT_DEVICE_SPI,
|
||||
BOOT_DEVICE_USB,
|
||||
BOOT_DEVICE_SATA,
|
||||
BOOT_DEVICE_I2C,
|
||||
BOOT_DEVICE_BOARD,
|
||||
BOOT_DEVICE_DFU,
|
||||
BOOT_DEVICE_XIP,
|
||||
BOOT_DEVICE_BOOTROM,
|
||||
BOOT_DEVICE_NONE
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Andes Technology Corporation
|
||||
* Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
|
||||
* Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
|
||||
* Copyright (C) 2017 Rick Chen (rick@andestech.com)
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_STRING_H
|
||||
#define __ASM_RISCV_STRING_H
|
||||
|
||||
/*
|
||||
* We don't do inline string functions, since the
|
||||
* optimised inline asm versions are not small.
|
||||
*/
|
||||
|
||||
#undef __HAVE_ARCH_STRRCHR
|
||||
#undef __HAVE_ARCH_STRCHR
|
||||
#undef __HAVE_ARCH_MEMCPY
|
||||
#undef __HAVE_ARCH_MEMMOVE
|
||||
#undef __HAVE_ARCH_MEMCHR
|
||||
#undef __HAVE_ARCH_MEMZERO
|
||||
#undef __HAVE_ARCH_MEMSET
|
||||
|
||||
#ifdef CONFIG_MARCO_MEMSET
|
||||
#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)); \
|
||||
else \
|
||||
memset((p), (v), (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 */
|
||||
@@ -0,0 +1,19 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _ASM_SYSCON_H
|
||||
#define _ASM_SYSCON_H
|
||||
|
||||
/*
|
||||
* System controllers in a RISC-V system
|
||||
*/
|
||||
enum {
|
||||
RISCV_NONE,
|
||||
RISCV_SYSCON_CLINT, /* Core Local Interruptor (CLINT) */
|
||||
RISCV_SYSCON_PLIC, /* Platform Level Interrupt Controller (PLIC) */
|
||||
RISCV_SYSCON_PLMT, /* Platform Level Machine Timer (PLMT) */
|
||||
};
|
||||
|
||||
#endif /* _ASM_SYSCON_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_SYSTEM_H
|
||||
#define __ASM_RISCV_SYSTEM_H
|
||||
|
||||
/*
|
||||
* Interrupt configuring macros.
|
||||
*
|
||||
* TODO
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __ASM_RISCV_SYSTEM_H */
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Andes Technology Corporation
|
||||
* Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
|
||||
* Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
|
||||
* Copyright (C) 2017 Rick Chen (rick@andestech.com)
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_RISCV_TYPES_H
|
||||
#define __ASM_RISCV_TYPES_H
|
||||
|
||||
#include <asm-generic/int-ll64.h>
|
||||
|
||||
typedef unsigned short umode_t;
|
||||
|
||||
/*
|
||||
* These aren't exported outside the kernel to avoid name space clashes
|
||||
*/
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#ifdef CONFIG_ARCH_RV64I
|
||||
#define BITS_PER_LONG 64
|
||||
#else
|
||||
#define BITS_PER_LONG 32
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef u32 dma_addr_t;
|
||||
|
||||
typedef unsigned long phys_addr_t;
|
||||
typedef unsigned long phys_size_t;
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Marius Groeger <mgroeger@sysgo.de>
|
||||
*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*/
|
||||
|
||||
#ifndef _U_BOOT_RISCV_H_
|
||||
#define _U_BOOT_RISCV_H_ 1
|
||||
|
||||
/* cpu/.../cpu.c */
|
||||
int cleanup_before_linux(void);
|
||||
|
||||
/* board/.../... */
|
||||
int board_init(void);
|
||||
void board_quiesce_devices(void);
|
||||
|
||||
#endif /* _U_BOOT_RISCV_H_ */
|
||||
@@ -0,0 +1,43 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Marius Groeger <mgroeger@sysgo.de>
|
||||
*
|
||||
* Copyright (C) 2017 Andes Technology Corporation
|
||||
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
|
||||
*
|
||||
********************************************************************
|
||||
* NOTE: This header file defines an interface to U-Boot. Including
|
||||
* this (unmodified) header file in another file is considered normal
|
||||
* use of U-Boot, and does *not* fall under the heading of "derived
|
||||
* work".
|
||||
********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _U_BOOT_H_
|
||||
#define _U_BOOT_H_ 1
|
||||
|
||||
#include <asm/u-boot-riscv.h>
|
||||
|
||||
|
||||
typedef struct bd_info {
|
||||
unsigned long bi_boot_params; /* where this board expects params */
|
||||
unsigned long bi_memstart; /* start of DRAM memory */
|
||||
unsigned long bi_memsize; /* size of DRAM memory in bytes */
|
||||
unsigned long bi_flashstart; /* start of FLASH memory */
|
||||
unsigned long bi_flashsize; /* size of FLASH memory */
|
||||
unsigned long bi_flashoffset; /* reserved area for startup monitor */
|
||||
unsigned char bi_enetaddr[6];
|
||||
|
||||
struct /* RAM configuration */
|
||||
{
|
||||
unsigned long start;
|
||||
unsigned long size;
|
||||
} bi_dram[CONFIG_NR_DRAM_BANKS];
|
||||
} bd_t;
|
||||
|
||||
/* For image.h:image_check_target_arch() */
|
||||
#define IH_ARCH_DEFAULT IH_ARCH_RISCV
|
||||
|
||||
#endif /* _U_BOOT_H_ */
|
||||
@@ -0,0 +1 @@
|
||||
#include <asm-generic/unaligned.h>
|
||||
Reference in New Issue
Block a user