diff --git a/src/sys/include/ubixos/tty.h b/src/sys/include/ubixos/tty.h index 0077774..2ea2255 100644 --- a/src/sys/include/ubixos/tty.h +++ b/src/sys/include/ubixos/tty.h @@ -38,7 +38,6 @@ char *tty_buffer; char *tty_pointer; uInt8 tty_colour; - uInt16 current; uInt16 tty_x; uInt16 tty_y; } tty_term; @@ -48,10 +47,15 @@ tty_term *tty_find(uInt16); int tty_print(char *,tty_term *); +extern tty_term *tty_foreground; + #endif /*** $Log$ + Revision 1.4 2004/08/06 22:32:16 reddawg + Ubix Works Again + Revision 1.2 2004/08/04 08:17:57 reddawg tty: we have primative ttys try f1-f5 so it is easier to use and debug ubixos diff --git a/src/sys/kernel/file.c b/src/sys/kernel/file.c index 74c55c6..2ab131b 100644 --- a/src/sys/kernel/file.c +++ b/src/sys/kernel/file.c @@ -214,7 +214,7 @@ while (_current->term->current == 0x0) schedYield(); */ - if (_current->term->current == 0x0) + if (_current->term != tty_foreground) ptr[0] = '\0'; else ptr[0] = (int) getch(); @@ -280,6 +280,9 @@ /*** $Log$ + Revision 1.13 2004/08/06 22:32:16 reddawg + Ubix Works Again + Revision 1.11 2004/08/04 08:17:57 reddawg tty: we have primative ttys try f1-f5 so it is easier to use and debug ubixos diff --git a/src/sys/kernel/tty.c b/src/sys/kernel/tty.c index 4074688..95c9b60 100644 --- a/src/sys/kernel/tty.c +++ b/src/sys/kernel/tty.c @@ -34,47 +34,76 @@ #include #include -static tty_term *terms = 0x0; -static uInt16 tty_current = 0x0; -static spinLock_t tty_spinLock = SPIN_LOCK_INITIALIZER; +static tty_term *terms = 0x0; +tty_term *tty_foreground = 0x0; +static spinLock_t tty_spinLock = SPIN_LOCK_INITIALIZER; int tty_init() { int i = 0x0; /* Allocate memory for terminals */ - terms = (tty_term *)kmalloc(sizeof(tty_term)*TTY_MAX_TERMS); if (terms == 0x0) - kpanic("tty_init: Failed to allocate memory\n"); + kpanic("tty_init: Failed to allocate memory. File: %s, Line: %i\n",__FILE__,__LINE__); + /* Set up all default terminal information */ for (i = 0;i < TTY_MAX_TERMS;i++) { terms[i].tty_buffer = (char *)kmalloc(80*60*2); if (terms[i].tty_buffer == 0x0) - kpanic("tty_init: Failed to allocate buffer memory\n"); - terms[i].tty_pointer = terms[i].tty_buffer; - terms[i].tty_x = 0x0; - terms[i].tty_y = 0x0; - terms[i].current = 0x0; - terms[i].tty_colour = 0x0A + i; + kpanic("tty_init: Failed to allocate buffer memory. File: %s, Line: %i\n",__FILE__,__LINE__); + + terms[i].tty_pointer = terms[i].tty_buffer; /* Set up tty pointer to internal buffer */ + terms[i].tty_x = 0x0; /* Set up default X position */ + terms[i].tty_y = 0x0; /* Set up default Y position */ + terms[i].tty_colour = 0x0A + i; /* Set up default tty text colour */ } - terms[0].tty_pointer = (char *)0xB8000; - terms[0].current = 0x1; + + /* Set up pointer for the foreground tty */ + tty_foreground = &terms[0]; + + /* Set up the foreground ttys information */ + tty_foreground->tty_pointer = (char *)0xB8000; + + /* Return to let kernel know initialization is complete */ kprintf("tty0 - Initialized\n"); return(0x0); } + + /* + This will change the specified tty. It ultimately copies the screen + to the foreground buffer copies the new ttys buffer to the screen and + adjusts a couple pointers and we are good to go. + */ int tty_change(uInt16 tty) { - memcpy(terms[tty_current].tty_buffer,(char *)0xB8000,(80*60*2)); + + if (tty > TTY_MAX_TERMS) + kpanic("Error: Changing to an invalid tty. File: %s, Line: %i\n",__FILE__,__LINE__); + + /* Copy display buffer to tty buffer */ + memcpy(tty_foreground->tty_buffer,(char *)0xB8000,(80*60*2)); + + /* Copy new tty buffer to display buffer */ memcpy((char *)0xB8000,terms[tty].tty_buffer,(80*60*2)); - terms[tty_current].tty_pointer = terms[tty_current].tty_buffer; - terms[tty_current].current = 0x0; + + /* + Set the tty_pointer to the internal buffer so I can continue + writing to what it believes is the screen + */ + tty_foreground->tty_point = tty_foreground->tty_buffer; + terms[tty].tty_pointer = (char *)0xB8000; terms[tty].current = 0x1; - tty_current = tty; + + /* set new foreground tty */ + tty_foreground = &terms[tty]; + return(0x0); } + + int tty_print(char *string,tty_term *term) { unsigned int bufferOffset = 0x0, character = 0x0, i = 0x0; @@ -124,6 +153,9 @@ /*** $Log$ + Revision 1.4 2004/08/06 22:32:16 reddawg + Ubix Works Again + Revision 1.2 2004/08/04 08:17:57 reddawg tty: we have primative ttys try f1-f5 so it is easier to use and debug ubixos