Skip to content
Snippets Groups Projects
Commit 4e8ef5f3 authored by abinade2's avatar abinade2
Browse files

terminal switch working, but buffers are wrong

parent 1de64385
No related branches found
No related tags found
No related merge requests found
...@@ -193,8 +193,8 @@ void entry(unsigned long magic, unsigned long addr) { ...@@ -193,8 +193,8 @@ void entry(unsigned long magic, unsigned long addr) {
//launch_tests(); //launch_tests();
#endif #endif
/* Execute the first program ("shell") ... */ /* Execute the first program ("shell") ... */
//if(switch_terminal(0) == 0) switch_terminal(0);
execute((uint8_t*) "shell"); execute((uint8_t*) "shell");
/* Spin (nicely, so we don't chew up cycles) */ /* Spin (nicely, so we don't chew up cycles) */
asm volatile (".1: hlt; jmp .1;"); asm volatile (".1: hlt; jmp .1;");
......
...@@ -43,13 +43,37 @@ void paging_initi(void){ ...@@ -43,13 +43,37 @@ void paging_initi(void){
return; 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 /* remap_vidmem
* Inputs: PID number of process * Inputs: PID number of process
* Return Value: void * Return Value: void
* Function: Initialises page for video memory * Function: Initialises page for video memory
*/ */
uint8_t* remap_vidmem(uint32_t pid){ uint8_t* remap_vidmem(uint32_t pid){
int32_t addr = VIDEO_MEM + pid * 4 + 3; //3 = offset for multiple terminals int32_t addr = VIDEO_MEM + pid * 4 + 3; //3 = offset for multiple terminals
page_table[addr] = VIDEO_ADDR | USER | READ_WRITE | PRESENT; page_table[addr] = VIDEO_ADDR | USER | READ_WRITE | PRESENT;
...@@ -90,7 +114,9 @@ void remap_term(int32_t term_id){ ...@@ -90,7 +114,9 @@ void remap_term(int32_t term_id){
if (control.cur_terminal == term_id) if (control.cur_terminal == term_id)
addr = TERM_VID; 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
flush_tlb(); flush_tlb();
......
...@@ -58,6 +58,8 @@ void loadPageDirectory(unsigned int*); ...@@ -58,6 +58,8 @@ void loadPageDirectory(unsigned int*);
*/ */
void enablePaging(void); 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); extern uint8_t* remap_vidmem(uint32_t pid);
......
...@@ -202,11 +202,13 @@ int32_t switch_terminal(int32_t term_id) ...@@ -202,11 +202,13 @@ int32_t switch_terminal(int32_t term_id)
control.cur_terminal = term_id; control.cur_terminal = term_id;
control.visible_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 //store previous terminal data into memory
memcpy( (void*)control.terminal[prev_terminal].vid_mem, (const void*)TERM_VID, _4_KB ); 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(); //clear();
...@@ -214,7 +216,7 @@ int32_t switch_terminal(int32_t term_id) ...@@ -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 ); memcpy( (void*)TERM_VID, (const void*)control.terminal[control.cur_terminal].vid_mem, _4_KB );
//set new terminal to update to physical video memory //set new terminal to update to physical video memory
remap_term(control.cur_terminal); remap2(control.cur_terminal);
update_cursor(); update_cursor();
......
...@@ -15,6 +15,9 @@ extern int32_t terminal_write(int32_t fd, const void* buf, int32_t nbytes); ...@@ -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_open(const uint8_t* filename);
extern int32_t terminal_close(int32_t fd); 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); extern int32_t switch_terminal(int32_t term_id);
void init_terminal(void); void init_terminal(void);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment