diff options
| author | Frédéric Desbiens <[email protected]> | 2025-02-24 15:43:49 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-02-24 15:43:49 -0500 |
| commit | 06dabb0ad0403f59889ce85eeb3d48dbd9d3759b (patch) | |
| tree | 55c635ef6650198af9edf00e063c916124cfa816 /ports/risc-v64/gnu/example_build/qemu_virt/hwtimer.c | |
| parent | 98c9172d01dcfdd0026ee3f5c6259dea6a12f253 (diff) | |
| parent | f0a44ad3914da1ce8429e55ff74f59eca11b6ec7 (diff) | |
Merge pull request #442 from eclipse-threadx/devv6.4.2_rel
Release ThreadX 6.4.2
Diffstat (limited to 'ports/risc-v64/gnu/example_build/qemu_virt/hwtimer.c')
| -rw-r--r-- | ports/risc-v64/gnu/example_build/qemu_virt/hwtimer.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ports/risc-v64/gnu/example_build/qemu_virt/hwtimer.c b/ports/risc-v64/gnu/example_build/qemu_virt/hwtimer.c new file mode 100644 index 00000000..29cf1117 --- /dev/null +++ b/ports/risc-v64/gnu/example_build/qemu_virt/hwtimer.c @@ -0,0 +1,25 @@ +#include "tx_port.h" +#include "csr.h" +#include "hwtimer.h" + +#define CLINT (0x02000000L) +#define CLINT_TIME (CLINT+0xBFF8) +#define CLINT_TIMECMP(hart_id) (CLINT+0x4000+8*(hart_id)) + + +int hwtimer_init(void) +{ + int hart = riscv_get_core(); + uint64_t time = *((uint64_t*)CLINT_TIME); + *((uint64_t*)CLINT_TIMECMP(hart)) = time + TICKNUM_PER_TIMER; + return 0; +} + +int hwtimer_handler(void) +{ + int hart = riscv_get_core(); + uint64_t time = *((uint64_t*)CLINT_TIME); + *((uint64_t*)CLINT_TIMECMP(hart)) = time + TICKNUM_PER_TIMER; + return 0; +} + |
