fixed assembly format of read_time and write_mtimecmp

master
Anton Lydike 3 years ago
parent cfc1c5c74b
commit cfd74e66b4

@ -2,14 +2,18 @@
#ifdef TIMECMP_IN_MEMORY #ifdef TIMECMP_IN_MEMORY
#ifndef TIMECMP_MEM_ADDR
#error "You set TIMECMP_IN_MEMORY but did not provide a memory addres in TIMECMP_MEM_ADDR!"
#endif
void write_mtimecmp(unsigned long long int mtimecmp) { void write_mtimecmp(unsigned long long int mtimecmp) {
unsigned int lower = mtimecmp; unsigned int lo = mtimecmp;
unsigned int higher = mtimecmp >> 32; unsigned int hi = mtimecmp >> 32;
__asm__( __asm__(
"sw %1, 0(%0)\n" "li t0, %0\n"
"sw %2, 4(%0)" :: "sw %1, 0(t0)\n"
"r"(TIMECMP_MEM_ADDR), "sw %2, 4(t0)" ::
"r"(lower), "r"(higher) "i"(TIMECMP_MEM_ADDR), "r"(lo), "r"(hi)
); );
} }
@ -32,9 +36,10 @@ void write_mtimecmp(unsigned long long int mtimecmp) {
unsigned long long int read_time() { unsigned long long int read_time() {
unsigned int lower, higher; unsigned int lower, higher;
__asm__( __asm__(
"csrr %0, 0xC01\n" "csrr %0, %2\n"
"csrr %1, 0xC81\n" "csrr %1, %3\n"
: "=r"(lower), "=r"(higher) : "=r"(lower), "=r"(higher)
: "i"(CSR_TIME), "i"(CSR_TIMEH)
); );
return (unsigned long long) higher << 32 | lower; return (unsigned long long) higher << 32 | lower;
} }

Loading…
Cancel
Save