-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] add basic OS interface operation symbols
A working sbrk is implemented. Signed-off-by: Avimitin <[email protected]>
- Loading branch information
Showing
4 changed files
with
42 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 |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
go | ||
buddy-mlir | ||
rvv-codegen | ||
rv32-gnu-toolchain | ||
]; | ||
|
||
emulatorDeps = with pkgs; [ | ||
|
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,34 @@ | ||
extern char* heap_end; | ||
char *heap_ptr; | ||
|
||
char *_sbrk(int nbytes) { | ||
char *base; | ||
|
||
if (!heap_ptr) | ||
heap_ptr = (char *)&heap_end; | ||
base = heap_ptr; | ||
heap_ptr += nbytes; | ||
|
||
return base; | ||
} | ||
|
||
void _exit(int code) { | ||
__asm__("csrwi 0x7cc, 0"); | ||
__builtin_unreachable(); | ||
} | ||
|
||
int _close(int file) { | ||
return -1; | ||
} | ||
|
||
int _lseek(int file, int ptr, int dir) { | ||
return -1; | ||
} | ||
|
||
int _read(int file, char* ptr, int len) { | ||
return -1; | ||
} | ||
|
||
int _write(int file, char* ptr, int len) { | ||
return -1; | ||
} |