#include <const.h>
#include <stdarg.h>
#include <arch/i386.h>
#include <arch/mem.h>
#include <arch/paging.h>
#include <kernel/console.h>
#include <kernel/semaphore.h>
#include <kernel/speaker.h>
#include <kernel/task.h>
#include <kernel/video.h>
Go to the source code of this file.
Functions | |||||||
bool | move_cur (console_t *console) | ||||||
Refresh cursor position for a selected console.
| |||||||
void | k_clrscr (console_t *console) | ||||||
Clear the screen of the selected console.
| |||||||
word | k_get_cur_pos (console_t *console) | ||||||
Get the cursor position of the selected console.
| |||||||
bool | k_set_cur_pos (console_t *console, word pos) | ||||||
Set the cursor position of the selected console.
| |||||||
byte | k_get_color (console_t *console) | ||||||
Get the current color of the selected console.
| |||||||
void | k_set_color (console_t *console, byte attrib) | ||||||
Set the current color of the selected console.
| |||||||
void | k_scroll_up (console_t *console) | ||||||
Scroll up the screen of the selected console.
| |||||||
void | k_gotoxy (console_t *console, int x, int y) | ||||||
Set the (x, y) coordinates as the current position in the selected console.
| |||||||
void | _kputchar (console_t *console, byte c) | ||||||
Put a character in the selected console.
| |||||||
byte | k_get_crt_height () | ||||||
Get the CRT height (in characters).
| |||||||
byte | k_get_crt_width () | ||||||
Get the CRT width (in characters).
| |||||||
void | init_video () | ||||||
Initialize the video parameters. | |||||||
Variables | |||||||
word | crt_port | ||||||
Video base address port. | |||||||
byte | crt_width | ||||||
Video width (columns). | |||||||
byte | crt_height | ||||||
Video height (rows). |
Definition in file video.c.
|
Put a character in the selected console.
Definition at line 185 of file video.c.
00186 { 00187 switch (c) 00188 { 00189 case '\n': 00190 (console->cur_pos)+=crt_width; 00191 (console->cur_pos)-=(console->cur_pos)%crt_width; 00192 break; 00193 case '\r': 00194 (console->cur_pos)-=(console->cur_pos)%crt_width; 00195 break; 00196 case '\b': 00197 if ((console->cur_pos) > 0) 00198 { 00199 (console->vid_buffer)[--(console->cur_pos)] = 00200 ((console->cur_color) <<8 ) | ' '; 00201 } 00202 break; 00203 case '\t': 00204 (console->cur_pos)+=8; 00205 break; 00206 case '\a': // CTRL+G => system beep! // 00207 beep(); 00208 return; 00209 break; 00210 00211 default: 00212 { 00213 (console->vid_buffer)[console->cur_pos] = ((console->cur_color) << 8) | c; 00214 (console->cur_pos)++; 00215 } 00216 } 00217 00218 // Check if cursor is at the bottom of the screen // 00219 if ( console->cur_pos >= (crt_width * crt_height) ) 00220 k_scroll_up(console); 00221 00222 move_cur(console); 00223 } |
|
Initialize the video parameters.
Definition at line 240 of file video.c.
00241 { 00242 crt_port=0x3D4; 00243 crt_width=80; 00244 crt_height=25; 00245 } |
|
Clear the screen of the selected console.
Definition at line 70 of file video.c.
|
|
Get the current color of the selected console.
Definition at line 116 of file video.c.
00117 { 00118 return(console->cur_color); 00119 } |
|
Get the CRT height (in characters).
Definition at line 227 of file video.c.
00228 {
00229 return( crt_height );
00230 }
|
|
Get the CRT width (in characters).
Definition at line 234 of file video.c.
00235 {
00236 return( crt_width );
00237 }
|
|
Get the cursor position of the selected console.
Definition at line 89 of file video.c.
00090 { 00091 return(console->cur_pos); 00092 } |
|
Set the (x, y) coordinates as the current position in the selected console.
Definition at line 159 of file video.c.
00160 { 00161 dword IF = GET_IF(); 00162 00163 // Round x, y to CRT bounds // 00164 if (x != -1) 00165 x = x % crt_width; 00166 else 00167 x = console->cur_pos % crt_width; 00168 00169 if (y != -1) 00170 y = y % crt_height; 00171 else 00172 y = console->cur_pos / crt_width; 00173 00174 disable(); 00175 console->cur_pos = y*crt_width + x; 00176 00177 SET_IF(IF); 00178 00179 move_cur(console); 00180 } |
|
Scroll up the screen of the selected console.
Definition at line 131 of file video.c.
00132 { 00133 dword IF = GET_IF(); 00134 00135 disable(); 00136 00137 // Scroll up // 00138 memcpy( (void *)(console->vid_buffer), 00139 ((void *)(console->vid_buffer))+crt_width*2, 00140 crt_width*(crt_height-1)*2 ); 00141 00142 // Blank the bottom line of the screen // 00143 memsetw((void *)( ((void *)(console->vid_buffer)) + crt_width*(crt_height-1)*2), 00144 BLANK, crt_width); 00145 00146 (console->cur_pos)-=crt_width; 00147 00148 SET_IF(IF); 00149 00150 move_cur(console); 00151 } |
|
Set the current color of the selected console.
Definition at line 124 of file video.c.
|
|
Set the cursor position of the selected console.
Definition at line 102 of file video.c.
00103 { 00104 if ( pos < (crt_width*crt_height) ) 00105 { 00106 console->cur_pos = pos; 00107 move_cur(console); 00108 return(TRUE); 00109 } 00110 return(FALSE); 00111 } |
|
Refresh cursor position for a selected console.
Definition at line 44 of file video.c.
00045 { 00046 dword IF = GET_IF(); 00047 00048 disable(); 00049 00050 // Move the cursor only in the current console // 00051 if ( (console == get_console_addr(0)) ) 00052 { 00053 // Refresh video cursor position with cur_pos value. // 00054 // Registers 14-15 tell the 6845 where to put the // 00055 // cursor. // 00056 outportb(crt_port + 0, 14); 00057 outportb(crt_port + 1, (console->cur_pos) >> 8); 00058 outportb(crt_port + 0, 15); 00059 outportb(crt_port + 1, (console->cur_pos)); 00060 SET_IF(IF); 00061 return(TRUE); 00062 } 00063 SET_IF(IF); 00064 return(FALSE); 00065 } |