-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hexagon: add utimer impl for userspace
Signed-off-by: Brian Cain <bcain@quicinc.com>
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright(c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include <stdio.h> | ||
|
||
static int err; | ||
|
||
#include "hex_test.h" | ||
|
||
static uint64_t get_time() | ||
{ | ||
uint64_t time; | ||
asm volatile("%0 = utimer\n\t" | ||
: "=r"(time) | ||
: | ||
: | ||
); | ||
return time; | ||
} | ||
|
||
static uint64_t get_time_from_regs() | ||
{ | ||
uint32_t time_low; | ||
uint32_t time_high; | ||
asm volatile("%0 = utimerhi\n\t" | ||
"%1 = utimerlo\n\t" | ||
: "=r"(time_high), "=r"(time_low) | ||
: | ||
: | ||
); | ||
return ((uint64_t)time_high << 32) | (uint64_t)time_low; | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
err = 0; | ||
|
||
uint64_t t0 = get_time(); | ||
check64_ne(t0, 0); | ||
|
||
uint64_t t1 = get_time_from_regs(); | ||
check64_ne(t1, 0); | ||
|
||
puts(err ? "FAIL" : "PASS"); | ||
return err; | ||
} |