applied uncrustify to csr source

master
Anton Lydike 3 years ago
parent c5afa93bb3
commit 5128b0376f

@ -6,27 +6,31 @@
#error "You set TIMECMP_IN_MEMORY but did not provide a memory addres in TIMECMP_MEM_ADDR!" #error "You set TIMECMP_IN_MEMORY but did not provide a memory addres in TIMECMP_MEM_ADDR!"
#endif #endif
void write_mtimecmp(unsigned long long int mtimecmp) { void write_mtimecmp(unsigned long long int mtimecmp)
{
unsigned int lo = mtimecmp; unsigned int lo = mtimecmp;
unsigned int hi = mtimecmp >> 32; unsigned int hi = mtimecmp >> 32;
__asm__(
"li t0, %0\n" __asm__ (
"sw %1, 0(t0)\n" "li t0, %0\n"
"sw %2, 4(t0)" :: "sw %1, 0(t0)\n"
"i"(TIMECMP_MEM_ADDR), "r"(lo), "r"(hi) "sw %2, 4(t0)" ::
"i"(TIMECMP_MEM_ADDR), "r"(lo), "r"(hi)
); );
} }
#else #else
void write_mtimecmp(unsigned long long int mtimecmp) { void write_mtimecmp(unsigned long long int mtimecmp)
{
unsigned int lower = mtimecmp; unsigned int lower = mtimecmp;
unsigned int higher = mtimecmp >> 32; unsigned int higher = mtimecmp >> 32;
__asm__(
"csrw %0, %2\n" __asm__ (
"csrw %1, %3" :: "csrw %0, %2\n"
"I"(CSR_MTIMECMP),"I"(CSR_MTIMECMPH), "csrw %1, %3" ::
"r"(lower), "r"(higher) "I"(CSR_MTIMECMP),"I"(CSR_MTIMECMPH),
"r"(lower), "r"(higher)
); );
} }

@ -23,31 +23,33 @@
// do not define C macros and other C stuff when this is included inside assembly // do not define C macros and other C stuff when this is included inside assembly
#ifndef __assembly #ifndef __assembly
#define CSR_READ(csr_id, result) {\ #define CSR_READ(csr_id, result) { \
__asm__ ("csrr %0, %1" : "=r"((result)) : "I"((csr_id))); \ __asm__ ("csrr %0, %1" : "=r"((result)) : "I"((csr_id))); \
} }
#define CSR_WRITE(csr_id, val) {\ #define CSR_WRITE(csr_id, val) { \
__asm__ ("csrw %0, %1" :: "I"((csr_id)), "r"((val))); \ __asm__ ("csrw %0, %1" :: "I"((csr_id)), "r"((val))); \
} }
#define HALT(code) {\ #define HALT(code) { \
__asm__("csrw %0, %1" :: "I"(CSR_HALT), "I"(code)); \ __asm__ ("csrw %0, %1" :: "I"(CSR_HALT), "I"(code)); \
} }
void write_mtimecmp(unsigned long long int mtimecmp); void write_mtimecmp(unsigned long long int mtimecmp);
inline __attribute__((always_inline)) unsigned long long int read_time() { inline __attribute__((always_inline)) unsigned long long int read_time()
{
unsigned int lower, higher; unsigned int lower, higher;
__asm__(
"csrr %0, %2\n" __asm__ (
"csrr %1, %3\n" "csrr %0, %2\n"
: "=r"(lower), "=r"(higher) "csrr %1, %3\n"
: "i"(CSR_TIME), "i"(CSR_TIMEH) : "=r"(lower), "=r"(higher)
: "i"(CSR_TIME), "i"(CSR_TIMEH)
); );
return (unsigned long long) higher << 32 | lower; return (unsigned long long) higher << 32 | lower;
} }
#endif #endif
#endif #endif

Loading…
Cancel
Save