-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea04c31
commit 25a16cb
Showing
2 changed files
with
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <cap.h> | ||
|
||
void test_mem_valid1 (void) | ||
{ | ||
cap_t mem = mk_memory(0x10, 0x2000, 0x3); | ||
assert(cap_is_valid(parent)); | ||
} | ||
|
||
void test_mem_valid2 (void) | ||
{ | ||
cap_t mem = mk_memory(0x1000, 0x2000, 0x7); | ||
assert(cap_is_valid(parent)); | ||
} | ||
|
||
void test_mem_invalid1 (void) | ||
{ | ||
cap_t mem = mk_memory(0x2000, 0x2000, 0x7); | ||
assert(!cap_is_valid(parent)); | ||
} |
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,34 @@ | ||
// Here we implement an emulation of the hardware. | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
static uint64_t mtime; | ||
static uint64_t mtimecmp[4]; | ||
|
||
uint64_t time_get(void) | ||
{ | ||
mtime += 10; | ||
return mtime; | ||
} | ||
|
||
void time_set(uint64_t val) | ||
{ | ||
mtime = val; | ||
} | ||
|
||
uint64_t timeout_get(uint64_t hartid) | ||
{ | ||
return mtimecmp[hartid]; | ||
} | ||
|
||
uint64_t timeout_set(uint64_t hartid, uint64_t val) | ||
{ | ||
mtimecmp[hartid] = val; | ||
} | ||
|
||
bool timeout_check(uint64_t hartid) | ||
{ | ||
mtime += 10; | ||
return mtime >= mtimecmp[hartid]; | ||
} |