> compile NEMU

221220000 张三
Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
 23:17:41 up 6 days, 18:23,  1 user,  load average: 0.69, 1.00, 0.95
This commit is contained in:
tracer-ics2023
2024-09-23 23:17:45 +08:00
committed by zzy
parent bc2c321ba9
commit 1f84807833
2 changed files with 12 additions and 3 deletions

View File

@ -11,8 +11,8 @@ size_t _write(int fd, const void *buf, size_t count) {
return count;
}
void _sbrk(intptr_t increment) {
int _brk(void* addr) {
return 0;
}
void do_syscall(Context *c) {
@ -26,6 +26,7 @@ void do_syscall(Context *c) {
switch (a[0]) {
case SYS_yield: yield(); break;
case SYS_write: c->GPRx = _write((int)a[1], (const char*)a[2], (size_t)a[3]); break;
case SYS_brk: c->GPRx = _brk((void*)a[1]);
case SYS_exit: halt(0); break;
default: panic("Unhandled syscall ID = %d", a[0]);
}

View File

@ -71,7 +71,15 @@ int _write(int fd, void *buf, size_t count) {
}
void *_sbrk(intptr_t increment) {
return (void *)-1;
extern char _end;
static char* brk = &_end;
char* prev_brk = brk;
brk += increment;
char buf[128];
if (_syscall_(SYS_brk, (intptr_t)brk, 0, 0) != 0) {
return (void*)-1;
}
return prev_brk;
}
int _read(int fd, void *buf, size_t count) {