initial commit
This commit is contained in:
32
port/moonlight/hwtimer.h
Normal file
32
port/moonlight/hwtimer.h
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef RISCV_HWTIMER_H
|
||||
#define RISCV_HWTIMER_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#define TICKNUM_PER_SECOND 32768
|
||||
#define TICKNUM_PER_TIMER (TICKNUM_PER_SECOND / 1000)
|
||||
|
||||
static inline int hwtimer_init(void) {
|
||||
uint64_t time = get_aclint_mtime(aclint);
|
||||
set_aclint_mtimecmp(aclint, time + TICKNUM_PER_TIMER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int hwtimer_handler(void) {
|
||||
uint64_t time = get_aclint_mtime(aclint);
|
||||
set_aclint_mtimecmp(aclint, time + TICKNUM_PER_TIMER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user