Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yhzhang0128 committed Dec 30, 2022
1 parent 69d9f92 commit a8071db
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
11 changes: 5 additions & 6 deletions earth/cpu_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ void trap_entry() {
asm("csrr %0, mcause" : "=r"(mcause));

int id = mcause & 0x3FF;
if (mcause & (1 << 31)) {
(intr_handler != 0)? intr_handler(id) :
FATAL("trap_entry: interrupt handler not registered");
} else {
(excp_handler != 0)? excp_handler(id) :
if (mcause & (1 << 31))
(intr_handler)? intr_handler(id) :
FATAL("trap_entry: intr_handler not registered");
else
(excp_handler)? excp_handler(id) :
FATAL("trap_entry: exception handler not registered");
}
}

int intr_enable() {
Expand Down
10 changes: 8 additions & 2 deletions earth/cpu_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ void pagetable_identity_mapping(int pid) {
}

int page_table_map(int pid, int page_no, int frame_id) {
if (pid >= MAX_ROOT_PAGE_TABLES)
FATAL("page_table_map: too many page table allocations");
if (pid >= MAX_ROOT_PAGE_TABLES) FATAL("page_table_map: pid too large");

/* Student's code goes here (page table translation). */

Expand All @@ -137,6 +136,12 @@ int page_table_map(int pid, int page_no, int frame_id) {
/* Student's code ends here. */
}

int page_table_translate(int pid, int page_no) {
/* Student's code goes here (page table translation). */

/* Student's code ends here. */
}

int page_table_switch(int pid) {
/* Student's code goes here (page table translation). */

Expand Down Expand Up @@ -183,5 +188,6 @@ void mmu_init() {

earth->mmu_map = page_table_map;
earth->mmu_switch = page_table_switch;
earth->mmu_translate = page_table_translate;
}
}
1 change: 0 additions & 1 deletion grass/grass.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ int main() {

void (*sys_proc_entry)() = (void*)APPS_ENTRY;
asm("mv a0, %0" ::"r"(APPS_ARG));
asm("mv a1, %0" ::"r"(APPS_ARG + 4));
sys_proc_entry();
}
1 change: 0 additions & 1 deletion grass/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ struct process{

void *mepc; /* machine exception program counter (mepc) */
void *sp_vaddr; /* used to switch between user and kernel stacks */
void *stack_paddr; /* used in the page table translation project */
};

#define MAX_NPROCESS 16
Expand Down
9 changes: 5 additions & 4 deletions library/egos.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct earth {
int (*mmu_free)(int pid);
int (*mmu_map)(int pid, int page_no, int frame_no);
int (*mmu_switch)(int pid);
int (*mmu_translate)(int pid, int page_no);

/* Devices interface */
int (*disk_read)(int block_no, int nblocks, char* dst);
Expand All @@ -31,6 +32,10 @@ struct earth {
};

struct grass {
/* Shell environment variables */
int workdir_ino;
char workdir[128];

/* Process control interface */
int (*proc_alloc)();
void (*proc_free)(int pid);
Expand All @@ -40,10 +45,6 @@ struct grass {
void (*sys_exit)(int status);
int (*sys_send)(int pid, char* msg, int size);
int (*sys_recv)(int* pid, char* buf, int size);

/* Shell environment variables */
int workdir_ino;
char workdir[128];
};

extern struct earth *earth;
Expand Down

0 comments on commit a8071db

Please sign in to comment.