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
#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) {
unsigned int lower = mtimecmp;
unsigned int higher = mtimecmp >> 32;
unsigned int lo = mtimecmp;
unsigned int hi = mtimecmp >> 32;
__asm__(
"sw %1, 0(%0)\n"
"sw %2, 4(%0)" ::
"r"(TIMECMP_MEM_ADDR),
"r"(lower), "r"(higher)
"li t0, %0\n"
"sw %1, 0(t0)\n"
"sw %2, 4(t0)" ::
"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 int lower, higher;
__asm__(
"csrr %0, 0xC01\n"
"csrr %1, 0xC81\n"
"csrr %0, %2\n"
"csrr %1, %3\n"
: "=r"(lower), "=r"(higher)
: "i"(CSR_TIME), "i"(CSR_TIMEH)
);
return (unsigned long long) higher << 32 | lower;
}

Loading…
Cancel
Save