Skip to content

Commit

Permalink
[tests] add basic OS interface operation symbols
Browse files Browse the repository at this point in the history
A working sbrk is implemented.

Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Oct 20, 2023
1 parent feeeb2b commit f0b1e04
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
go
buddy-mlir
rvv-codegen
rv32-gnu-toolchain
];

emulatorDeps = with pkgs; [
Expand Down
1 change: 1 addition & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ in
buddy-mlir = final.callPackage ./nix/buddy-mlir.nix { };
rvv-codegen = final.callPackage ./nix/rvv-codegen.nix { };
rvv-testcase = final.callPackage ./nix/rvv-testcase-unwrapped.nix { };
rv32-gnu-toolchain = final.callPackage ./nix/riscv-gnu-toolchain.nix { };

inherit rv32-clang my-cc-wrapper;
}
6 changes: 6 additions & 0 deletions tests/intrinsic/main.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.globl start
.globl heap_end
start:
li a0, 0x2200 # MSTATUS_VS & (MSTATUS_VS >> 1)
csrs mstatus, a0
Expand All @@ -14,3 +15,8 @@ stack_start:
.zero 0x10000

stack_end:

heap_start:
.zero 0x100000

heap_end:
34 changes: 34 additions & 0 deletions tests/intrinsic/sys.c
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;
}

0 comments on commit f0b1e04

Please sign in to comment.