43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#include "encoding.h"
|
|
#include "platform.h"
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
void handle_m_time_interrupt() {
|
|
uint64_t time = get_aclint_mtime(aclint);
|
|
time += MTIMER_NEXT_TICK_INC;
|
|
set_aclint_mtimecmp(aclint, time);
|
|
puts("m_time_irq");
|
|
}
|
|
|
|
int main() {
|
|
puts("in main");
|
|
// avoid getting interrupt upon enabling MIP/MIE_MTI
|
|
set_aclint_mtimecmp(aclint, 0xffffffffffffffff);
|
|
// enable global interrupt
|
|
csr_set_bits_mstatus(MSTATUS_MIE_BIT_MASK);
|
|
|
|
puts("after enable MSTATUS_MIE/MPP");
|
|
// enable MIE
|
|
csr_set_bits_mie(MIE_MTI_BIT_MASK | MIE_MSI_BIT_MASK | MIE_MEI_BIT_MASK);
|
|
puts("after enable MIE");
|
|
|
|
uint64_t time = get_aclint_mtime(aclint);
|
|
printf("in main() get_aclint_mtime return %lu \n", (uint32_t)time);
|
|
set_aclint_mtime(aclint, 9);
|
|
time = get_aclint_mtime(aclint);
|
|
printf("in main() get_aclint_mtime after set 9, return %lu \n", (uint32_t)time);
|
|
|
|
set_aclint_mtimecmp(aclint, (time + 3));
|
|
puts("set mtimecmp");
|
|
|
|
uint64_t timecmp = get_aclint_mtimecmp(aclint);
|
|
printf("in main() get_aclint_mtimecmp return %d \n", timecmp);
|
|
|
|
puts(" finshed ");
|
|
return 0;
|
|
}
|