Data Structures | |||||
struct | console | ||||
Virtual console structure. More... | |||||
Typedefs | |||||
typedef console | console_t | ||||
Virtual console structure. | |||||
Functions | |||||
console_t * | get_console_addr (int c) | ||||
Get the address of a console structure.
| |||||
int | get_curr_console () | ||||
Get the current console id.
| |||||
bool | set_curr_console (int c) | ||||
Set the current console.
| |||||
bool | switch_to_console (int c) | ||||
Change the current console and refresh the screen.
| |||||
void | clrscr () | ||||
Clear the screen. | |||||
byte | get_color () | ||||
Get the current text color of the console.
| |||||
void | set_color (byte attrib) | ||||
Set the text color for the current console.
| |||||
void | scroll_up () | ||||
Scroll the console up. | |||||
void | gotoxy (int x, int y) | ||||
Place the cursor at the (x , y) coordinates.
| |||||
void | kputchar (int c) | ||||
Put a character on the current console.
| |||||
int | kprintf (const char *fmt,...) | ||||
Print a string to the current console.
| |||||
void | init_main_console () | ||||
Initialize the special console #0 as the video memory buffer. | |||||
void | create_virtual_console () | ||||
Allocate and initialize memory space for virtual consoles.
|
|
Virtual console structure.
|
|
Clear the screen.
Definition at line 101 of file console.c.
00102 { 00103 task_t *p; 00104 00105 if ( !(p=get_curr_task()) ) 00106 { 00107 // If there is no task clear the main console // 00108 k_clrscr( (console_t *)(&vir_cons[0]) ); 00109 return; 00110 } 00111 00112 if ( p->console==curr_cons ) 00113 // The task is running in the current console. // 00114 // So clear the main console // 00115 k_clrscr( (console_t *)(&vir_cons[0]) ); 00116 else 00117 // The task is not running in the current console. // 00118 // Clear the task console // 00119 k_clrscr( (console_t *)(&vir_cons[p->console]) ); 00120 } |
|
Allocate and initialize memory space for virtual consoles.
Definition at line 282 of file console.c.
00283 { 00284 int i; 00285 00286 for (i=1; i < (K_TOT_VIR_CONS+1); i++) 00287 { 00288 vir_cons[i].vid_buffer = kmalloc( VIDEO_BUF_DIM*sizeof(word) ); 00289 memsetw(vir_cons[i].vid_buffer, 0, VIDEO_BUF_DIM); 00290 vir_cons[i].cur_pos = 0; 00291 vir_cons[i].cur_color = DEFAULT_COLOR; 00292 } 00293 00294 // Copy the current video parameters into the first // 00295 // virtual console. // 00296 memcpyw(vir_cons[1].vid_buffer, vir_cons[0].vid_buffer, VIDEO_BUF_DIM); 00297 vir_cons[1].cur_pos = vir_cons[0].cur_pos; 00298 vir_cons[1].cur_color = vir_cons[0].cur_color; 00299 00300 // Automatic switch to the first virtual console // 00301 curr_cons = 1; 00302 } |
|
Get the current text color of the console.
Definition at line 124 of file console.c.
00125 { 00126 task_t *p; 00127 00128 if ( !(p=get_curr_task()) ) 00129 { 00130 // If there is no task return the main console color // 00131 return( k_get_color((console_t *)(&vir_cons[0])) ); 00132 } 00133 00134 if ( p->console==curr_cons ) 00135 // The task is running in the current console. // 00136 // So return the main console color // 00137 return( k_get_color((console_t *)(&vir_cons[0])) ); 00138 else 00139 // The task is not running in the current console. // 00140 // Return the task console color // 00141 return( k_get_color((console_t *)(&vir_cons[p->console])) ); 00142 } |
|
Get the address of a console structure.
Definition at line 37 of file console.c.
00038 { 00039 if ( (c>=0) && (c<=K_TOT_VIR_CONS) ) 00040 return( (console_t *)(&vir_cons[c]) ); 00041 00042 return((console_t *)NULL); 00043 } |
|
Get the current console id.
Definition at line 47 of file console.c.
00048 {
00049 return(curr_cons);
00050 }
|
|
Place the cursor at the (
Definition at line 193 of file console.c.
00194 { 00195 task_t *p; 00196 00197 if ( !(p=get_curr_task()) ) 00198 { 00199 // If there is no task print to the video buffer // 00200 k_gotoxy((console_t *)(&vir_cons[0]), x, y); 00201 return; 00202 } 00203 00204 if ( p->console==curr_cons ) 00205 // The task is running in the current console. // 00206 // So execute directly to the video memory // 00207 k_gotoxy((console_t *)(&vir_cons[0]), x, y); 00208 else 00209 // The task is not running in the current console. // 00210 // Execute into its video buffer // 00211 k_gotoxy((console_t *)(&vir_cons[p->console]), x, y); 00212 } |
|
Initialize the special console #0 as the video memory buffer.
Definition at line 268 of file console.c.
00269 { 00270 vir_cons[0].vid_buffer = (word *)VIDEO_BUFFER; 00271 vir_cons[0].cur_pos = 0; 00272 vir_cons[0].cur_color = DEFAULT_COLOR; 00273 00274 // Clear the screen // 00275 k_clrscr( (console_t *)(&vir_cons[0]) ); 00276 } |
|
Print a string to the current console.
Definition at line 245 of file console.c.
00246 { 00247 char buf[1024]; 00248 va_list args; 00249 int i; 00250 00251 va_start( args, fmt ); 00252 00253 vsnprintf( buf, sizeof(buf), fmt, args ); 00254 va_end( args ); 00255 00256 for( i=0; i<1024; i++ ) 00257 { 00258 if( !buf[i] ) break; 00259 kputchar( buf[i] ); 00260 } 00261 00262 return( i ); 00263 } |
|
Put a character on the current console.
Definition at line 216 of file console.c.
00217 { 00218 task_t *p = get_curr_task(); 00219 uint32_t IF = GET_IF(); 00220 00221 if ( !p ) 00222 { 00223 // If there is no task print to the video buffer. 00224 _kputchar((console_t *)(&vir_cons[0]), c); 00225 return; 00226 } 00227 00228 disable(); 00229 00230 if ( p->console==curr_cons ) 00231 // The task is running in the current console. 00232 // So print directly to the video memory. 00233 _kputchar((console_t *)(&vir_cons[0]), c); 00234 else 00235 // The task is not running in the current console. 00236 // Print into its video buffer. 00237 _kputchar((console_t *)(&vir_cons[p->console]), c); 00238 00239 SET_IF( IF ); 00240 } |
|
Scroll the console up.
Definition at line 168 of file console.c.
00169 { 00170 task_t *p; 00171 00172 if ( !(p=get_curr_task()) ) 00173 { 00174 // If there is no task execute in the video buffer // 00175 k_scroll_up( (console_t *)(&vir_cons[0]) ); 00176 return; 00177 } 00178 00179 if ( p->console==curr_cons ) 00180 // The task is running in the current console. // 00181 // So execute directly to the video memory // 00182 k_scroll_up( (console_t *)(&vir_cons[0]) ); 00183 else 00184 // The task is not running in the current console. // 00185 // Execute into its video buffer // 00186 k_scroll_up( (console_t *)(&vir_cons[p->console]) ); 00187 } |
|
Set the text color for the current console.
Definition at line 146 of file console.c.
00147 { 00148 task_t *p; 00149 00150 if ( !(p=get_curr_task()) ) 00151 { 00152 // If there is no task set the main console color // 00153 k_set_color( (console_t *)(&vir_cons[0]), attrib ); 00154 return; 00155 } 00156 00157 if ( p->console==curr_cons ) 00158 // The task is running in the current console. // 00159 // So set the main console color // 00160 k_set_color( (console_t *)(&vir_cons[0]), attrib ); 00161 else 00162 // The task is not running in the current console. // 00163 // Set the task console color // 00164 k_set_color( (console_t *)(&vir_cons[p->console]), attrib ); 00165 } |
|
Set the current console.
Definition at line 57 of file console.c.
00058 { 00059 if ( (c > 0) && (c <= K_TOT_VIR_CONS) ) 00060 curr_cons = c; 00061 else 00062 return(FALSE); 00063 00064 return(TRUE); 00065 } |
|
Change the current console and refresh the screen.
Definition at line 72 of file console.c.
00073 { 00074 if ( c == curr_cons) 00075 // Attempt to switch to the current console // 00076 return(TRUE); 00077 00078 // Copy old console parameters from video memory // 00079 memcpyw(vir_cons[curr_cons].vid_buffer, vir_cons[0].vid_buffer, VIDEO_BUF_DIM); 00080 vir_cons[curr_cons].cur_pos = vir_cons[0].cur_pos; 00081 vir_cons[curr_cons].cur_color = vir_cons[0].cur_color; 00082 00083 if ( set_curr_console(c) ) 00084 { 00085 // Set new console parameters to the video memory // 00086 memcpyw(vir_cons[0].vid_buffer, vir_cons[c].vid_buffer, VIDEO_BUF_DIM); 00087 k_set_cur_pos( (console_t *)(&vir_cons[0]), vir_cons[c].cur_pos ); 00088 k_set_color( (console_t *)(&vir_cons[0]), vir_cons[c].cur_color ); 00089 00090 // Set keyboard parameters of the new selected console // 00091 update_leds(); 00092 00093 return(TRUE); 00094 } 00095 return(FALSE); 00096 } |