Angel Pons | 585495e | 2020-04-03 01:21:38 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 2 | |
| 3 | #include <mcall.h> |
Philipp Hug | 934ae21 | 2019-09-04 09:24:45 -0700 | [diff] [blame] | 4 | #include <device/mmio.h> |
Philipp Hug | 2ef569a | 2018-12-31 14:13:47 +0100 | [diff] [blame] | 5 | #include <mainboard/addressmap.h> |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 6 | |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 7 | /* This function is used to initialize HLS()->time/HLS()->timecmp */ |
| 8 | void mtime_init(void) |
| 9 | { |
Philipp Hug | 2ef569a | 2018-12-31 14:13:47 +0100 | [diff] [blame] | 10 | long hart_id = read_csr(mhartid); |
| 11 | HLS()->time = (uint64_t *)(QEMU_VIRT_CLINT + 0xbff8); |
| 12 | HLS()->timecmp = (uint64_t *)(QEMU_VIRT_CLINT + 0x4000 + 8 * hart_id); |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 13 | } |
Philipp Hug | 934ae21 | 2019-09-04 09:24:45 -0700 | [diff] [blame] | 14 | |
| 15 | void set_msip(int hartid, int val) |
| 16 | { |
| 17 | write32((void *)(QEMU_VIRT_CLINT + 4 * (uintptr_t)hartid), !!val); |
| 18 | } |