diff --git a/student-distrib/idt.c b/student-distrib/idt.c index a6de4c286747dfc61a9735fe1142ea9c5604d604..c3decf2b2b4dcbb79ee2b1357437fb7efc17413b 100644 --- a/student-distrib/idt.c +++ b/student-distrib/idt.c @@ -68,7 +68,7 @@ void exception_handler(int interrupt_index) printf("GENERAL PROTECTION EXCEPTION\n"); break; case -15: - printf("PAGE FAULT EXCEPTION"); + printf("PAGE FAULT EXCEPTION\n"); break; case -17: printf("MATH FAULT EXCEPTION\n"); @@ -84,8 +84,10 @@ void exception_handler(int interrupt_index) break; } - cli(); - while(1); // halt the kernel, since an exception occurs + printf("Squashing user level program...\n"); + + //return control to shell + halt(-1); } /* diff --git a/student-distrib/keyboard.c b/student-distrib/keyboard.c index dd10fb2129a13dd2ff0620072ef72968b5667287..047361a959af73218792180dd8b47cac25e94b61 100644 --- a/student-distrib/keyboard.c +++ b/student-distrib/keyboard.c @@ -373,8 +373,7 @@ void KB_handler(void) { } - page_table[0xB8] = ((uint32_t)0xB8000) | USER | READ_WRITE | PRESENT; - flush_tlb(); + remap1(); // 0x15 = scancode for L // check if ctrl-L is pressed diff --git a/student-distrib/paging.c b/student-distrib/paging.c index 4be459aacc52db98da5eefd2d80b8ae4a7741cc9..cd6ee8ee3d013f0232ebd63ff85a76562f41059e 100644 --- a/student-distrib/paging.c +++ b/student-distrib/paging.c @@ -49,7 +49,7 @@ void paging_initi(void){ //term_id = current -void remap1(int32_t term_id){ +void remap1(void){ page_table[0xB8] = (uint32_t)(0xB8000) | USER | READ_WRITE | PRESENT; flush_tlb(); return; diff --git a/student-distrib/paging.h b/student-distrib/paging.h index 8db45b5ef9ba012d2817d45e9f81eb20994a4369..8f3ce4b422a602fdccee5406f42c3f609b89236c 100644 --- a/student-distrib/paging.h +++ b/student-distrib/paging.h @@ -58,7 +58,7 @@ void loadPageDirectory(unsigned int*); */ void enablePaging(void); -extern void remap1(int32_t term_id); +extern void remap1(void); extern void remap2(int32_t term_id); diff --git a/student-distrib/syscall.c b/student-distrib/syscall.c index b1e412d6e9cb5ff2d51154b7c0021c5a73e76a2c..30b9d1873fd40e7619169ab6081d3070e42ddff8 100644 --- a/student-distrib/syscall.c +++ b/student-distrib/syscall.c @@ -102,7 +102,6 @@ int32_t execute(const uint8_t* command) uint8_t argv[MAX_ARGUMENT_NUM][MAX_ARGUMENT_SIZE]; int32_t ret, arg_num; //number that indicated special command - int32_t pid = set_pid(); //if( pid == -1) return -1; // reach max process ret = parse_cmd(command, parsed_cmd, argv); @@ -141,6 +140,8 @@ int32_t execute(const uint8_t* command) return -1; } + int32_t pid = set_pid(); + // Get a new pid total_prog_count++; terminal[running_terminal].terminal_prog_count++; diff --git a/student-distrib/terminal.c b/student-distrib/terminal.c index 94bb3e570297d1394dbddbc13a0f4bcb3ad2854f..6d400719684ce7a4d85c7e8c747efe7fcc5b5f0a 100644 --- a/student-distrib/terminal.c +++ b/student-distrib/terminal.c @@ -218,7 +218,7 @@ int32_t switch_terminal(int32_t term_id) visible_terminal = term_id; //restore paging from 0xb8000 to prev_terminal video mapping - remap1(prev_terminal); + remap1(); //store previous terminal data into memory memcpy( (void*) terminal[prev_terminal].vid_mem, (const void*)TERM_VID, _4_KB ); @@ -234,29 +234,3 @@ int32_t switch_terminal(int32_t term_id) //check if shell is running on that terminal return ( terminal[term_id].terminal_prog_count == 0) ? 0 : 1; } - -// NOT IN USE ANYMORE -/* - * FUNCTIONALITY: helper function for copying terminal video memory data - * - * INPUT: term_id -- the terminal id of the ther terminal that we want to switch to - * cmd: 0 -- copy from video memory to terminal info storage - * 1 -- copy from terminal info storage to video memory - * OUTPUT: None - */ -void copy_term_data(int32_t term_id, int32_t cmd) -{ - //validate parameters - if(cmd != 0 || cmd != 1 || term_id < 0 || term_id > 2) - { - printf("[copy_term_data] break early - cmd = %d, term_id = %d\n", cmd, term_id); - return; - } - - if(cmd) - memcpy( (void*)TERM_VID, (const void*) terminal[term_id].vid_mem, _4_KB ); - else - memcpy( (void*) terminal[term_id].vid_mem, (const void*)TERM_VID, _4_KB ); - - return; -} diff --git a/student-distrib/terminal.h b/student-distrib/terminal.h index 103e1e1de479b62da09f598ac53fbfe51840e22f..117569c5d6afcab56c4937133b38c1c26fdd58f3 100644 --- a/student-distrib/terminal.h +++ b/student-distrib/terminal.h @@ -16,7 +16,7 @@ extern int32_t terminal_write(int32_t fd, const void* buf, int32_t nbytes); extern int32_t terminal_open(const uint8_t* filename); extern int32_t terminal_close(int32_t fd); -void remap1(int32_t term_id); +void remap1(void); void remap2(int32_t term_id); extern int32_t switch_terminal(int32_t term_id); diff --git a/student-distrib/types.h b/student-distrib/types.h index 0c9c9dc1ca4c5bf9bf43ede7087e36000cc7dbf3..110fb31005a3c28061d45d28e5501360e0285169 100644 --- a/student-distrib/types.h +++ b/student-distrib/types.h @@ -20,7 +20,7 @@ #define MAX_FILE_NUM 8 #define MIN_FILE_NUM 0 #define MAX_COMMAND_SIZE 10 -#define MAX_ARGUMENT_NUM 2 +#define MAX_ARGUMENT_NUM 1 #define MAX_ARGUMENT_SIZE 40 //for terminal