diff --git a/student-distrib/kernel.c b/student-distrib/kernel.c index e5f8a61c13dc7966c865b92ed1df87dfa86eb7ec..00b9854297201d9d813ca7b1b37122129dd2c589 100644 --- a/student-distrib/kernel.c +++ b/student-distrib/kernel.c @@ -193,8 +193,8 @@ void entry(unsigned long magic, unsigned long addr) { //launch_tests(); #endif /* Execute the first program ("shell") ... */ - //if(switch_terminal(0) == 0) - execute((uint8_t*) "shell"); + switch_terminal(0); + execute((uint8_t*) "shell"); /* Spin (nicely, so we don't chew up cycles) */ asm volatile (".1: hlt; jmp .1;"); diff --git a/student-distrib/paging.c b/student-distrib/paging.c index 86698e20246819b1eb45b643ed4f8142d8b7bf10..9bdd3d68a9ee354ba47e2fca9767e6e7ff916f88 100644 --- a/student-distrib/paging.c +++ b/student-distrib/paging.c @@ -43,13 +43,37 @@ void paging_initi(void){ return; } + + + + + +//term_id = current +void remap1(int32_t term_id){ + page_table[ 0xB8 + term_id + 1] = ((uint32_t)(0xB8000 + (term_id+1)*0x1000 )) | USER | READ_WRITE | PRESENT; + flush_tlb(); + return; +} + + +//term_id = ther terminal we want to display +void remap2(int32_t term_id){ + page_table[ 0xB8 + term_id + 1] = ((uint32_t)0xB8000) | USER | READ_WRITE | PRESENT; + flush_tlb(); + return; +} + + + + + /* remap_vidmem * Inputs: PID number of process * Return Value: void * Function: Initialises page for video memory */ uint8_t* remap_vidmem(uint32_t pid){ - + int32_t addr = VIDEO_MEM + pid * 4 + 3; //3 = offset for multiple terminals page_table[addr] = VIDEO_ADDR | USER | READ_WRITE | PRESENT; @@ -90,7 +114,9 @@ void remap_term(int32_t term_id){ if (control.cur_terminal == term_id) addr = TERM_VID; - page_table[VIDEO_MEM] = addr | USER | READ_WRITE | PRESENT; + //page_table[VIDEO_MEM] = addr | USER | READ_WRITE | PRESENT; + page_directory[33] = ((uint32_t)vid_table) | USER | READ_WRITE | PRESENT ; + vid_table[VIDEO_MEM] = addr | USER | READ_WRITE | PRESENT; // flush TLB flush_tlb(); diff --git a/student-distrib/paging.h b/student-distrib/paging.h index 1711f89b82bcd647b9350ba0e4d1bb1ecd967608..3bae8d9ed19b08f59e2290e7e9ed2f66cc89a716 100644 --- a/student-distrib/paging.h +++ b/student-distrib/paging.h @@ -58,6 +58,8 @@ void loadPageDirectory(unsigned int*); */ void enablePaging(void); +extern void remap1(int32_t term_id); +extern void remap2(int32_t term_id); extern uint8_t* remap_vidmem(uint32_t pid); diff --git a/student-distrib/terminal.c b/student-distrib/terminal.c index 39b7bfa9e2847f313ffabd324796d8a19f4a83b0..c18b3fa237d24c877049b3e7bc42ced2fe8ce4d7 100644 --- a/student-distrib/terminal.c +++ b/student-distrib/terminal.c @@ -202,11 +202,13 @@ int32_t switch_terminal(int32_t term_id) control.cur_terminal = term_id; control.visible_terminal = term_id; + //restore paging from 0xb8000 to prev_terminal video mapping + remap1(prev_terminal); + //store previous terminal data into memory memcpy( (void*)control.terminal[prev_terminal].vid_mem, (const void*)TERM_VID, _4_KB ); - //restore paging from 0xb8000 to prev_terminal video mapping - remap_term(prev_terminal); + //clear(); @@ -214,7 +216,7 @@ int32_t switch_terminal(int32_t term_id) memcpy( (void*)TERM_VID, (const void*)control.terminal[control.cur_terminal].vid_mem, _4_KB ); //set new terminal to update to physical video memory - remap_term(control.cur_terminal); + remap2(control.cur_terminal); update_cursor(); diff --git a/student-distrib/terminal.h b/student-distrib/terminal.h index 17b2648b2abe57d9c83ddaadfec52b1f2c584b9d..6709b04f30768d32aea2ba7c18ec79b711cc7388 100644 --- a/student-distrib/terminal.h +++ b/student-distrib/terminal.h @@ -15,6 +15,9 @@ 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 remap2(int32_t term_id); + extern int32_t switch_terminal(int32_t term_id); void init_terminal(void);