Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions abstract-machine/am/src/x86/nemu/cte.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Context* __am_irq_handle(Context* c) {
ev.event = EVENT_IRQ_TIMER;
break;
case 0x80:
if(c->eax == 9)
printf("Int trap, a[1] == %x\n", c->ebx);
ev.event = EVENT_SYSCALL;
break;
case 0x81:
Expand Down
2 changes: 1 addition & 1 deletion nanos-lite/src/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void free_page(void *p) {
// if brk exceed current->max_brk, we allocate new_page()
void map(AddrSpace* as, void* va, void* pa, int prot);
int mm_brk(uintptr_t brk) {
printf("brk == %x\n", brk);
printf("mm_brk, brk == %x\n", brk);
printf("current->max_brk == %x\n", current->max_brk);
if(brk > current->max_brk){
uintptr_t vaddr = current->max_brk;
Expand Down
1 change: 1 addition & 0 deletions nanos-lite/src/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void do_syscall(Context* c) {
}
case SYS_brk:
//c->GPRx = 0;
printf("nanos, brk == %x\n", a[1]);
c->GPRx = mm_brk(a[1]);
break;
case SYS_open:
Expand Down
27 changes: 26 additions & 1 deletion navy-apps/libs/libos/src/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "syscall.h"
Expand Down Expand Up @@ -48,6 +49,14 @@
#endif

intptr_t _syscall_(intptr_t type, intptr_t a0, intptr_t a1, intptr_t a2) {
if(type == 9){
char tmp[69] = {};
sprintf(tmp, "navy, brk _syscall_, brk == %p\n", (char*)a0);
write(1, tmp, sizeof(tmp));
memset(tmp, 0, 69);
sprintf(tmp, "navy, brk _syscall_, brk == %lu\n", a0);
write(1, tmp, sizeof(tmp));
}
register intptr_t _gpr1 asm(GPR1) = type;
register intptr_t _gpr2 asm(GPR2) = a0;
register intptr_t _gpr3 asm(GPR3) = a1;
Expand Down Expand Up @@ -76,14 +85,30 @@ int _write(int fd, void* buf, size_t count) {
extern char _end;
static char* proc_brk = &_end;
void* _sbrk(intptr_t increment) {
char tmp[69] = {};
sprintf(tmp, "navy, proc_brk == %p\n", proc_brk);
write(1, tmp, sizeof(tmp));
memset(tmp, 0, 69);
sprintf(tmp, "navy, increment == %p\n", (char*)increment);
write(1, tmp, sizeof(tmp));
memset(tmp, 0, 69);
sprintf(tmp, "navy, increment == %lu\n", increment);
write(1, tmp, sizeof(tmp));
memset(tmp, 0, 69);
intptr_t pre_brk = (intptr_t)proc_brk;
intptr_t req_brk = (intptr_t)proc_brk + increment;
sprintf(tmp, "navy, req_brk == %p\n", (char*)req_brk);
write(1, tmp, sizeof(tmp));
memset(tmp, 0, 69);
sprintf(tmp, "navy, req_brk == %lu\n", req_brk);
write(1, tmp, sizeof(tmp));
memset(tmp, 0, 69);
// Attention for the argument passed to the system call.
if((char *)req_brk < &_end){
return (void*)-1;
}

if(!_syscall_(SYS_brk, (intptr_t)&req_brk, 0, 0)){
if(!_syscall_(SYS_brk, (intptr_t)req_brk, 0, 0)){
proc_brk += increment;
return (void*)pre_brk;
} else {
Expand Down
2 changes: 1 addition & 1 deletion nemu/src/device/intr.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <isa.h>

void dev_raise_intr() {
//cpu.INTR = true;
cpu.INTR = true;
}
9 changes: 6 additions & 3 deletions nemu/tools/gen-expr/gen-expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ static inline void gen_rand_op() {
gen_rand_expr();
break;
}
} else {
gen_rand_num();
}
}
/*
*else {
* gen_rand_num();
*}
*/
buf[strlen(buf)] = '\0';
}

Expand Down