00001
00002
00003 #ifndef _CORE_TELETYPE_HPP
00004 #define _CORE_TELETYPE_HPP
00005
00006 #include "src/ipc/lock.hpp"
00007 #include "src/ipc/sem.hpp"
00008
00009
00010 struct ChCol
00011 {
00012 uint8 ch, col;
00013 };
00014
00015 namespace Teletype {
00016 extern ChCol *vidmem;
00017 void init();
00018 };
00019
00020
00021 extern bool volatile TTYDisableLock;
00022
00023
00024
00025 class teletype
00026 {
00027 friend void Teletype::init();
00028 friend void tty_switch(teletype*, char*);
00029 friend void coutnum(teletype *tty, uint32 n, uint32 radix, uint32 n_pos, char first_letter, char EmptyLetter);
00030 friend void poke_str(char *ch, uint8 color, int x, int y, uint32 limit);
00031 friend void poke_char(char ch, uint8 color, int x, int y);
00032 friend void writehere(char *ch, uint8 color, uint32 limit);
00033 friend void putch(char ch);
00034 friend void cout (char *ch, uint8 color);
00035 friend void cout(teletype *tty, char *ch);
00036 friend void coutnum(teletype *tty, uint32 n, uint32 radix, uint32 n_pos, char first_letter, uint8 col);
00037
00038 ChCol *video;
00039 int start, lgth;
00040 int x, y;
00041 int xsize, ysize, lines;
00042 int yoffset;
00043 int yfocus;
00044 uint8 color;
00045
00046 struct sem_t sem_tty;
00047
00048 teletype *HW;
00049
00050 int (*kbd_handler)();
00051
00052
00053 int line (int n);
00054 ChCol *lineptr (int n);
00055 void movecurs(int n);
00056
00057 void llock();
00058 void lulock();
00059
00060 void repaint(teletype *tty);
00061
00062 void del_top(int n);
00063 public:
00064 teletype(ChCol *buffer, int _xsize, int _ysize, int _lines, teletype *vHW, int (*kbd_h)(), uint8 col);
00065
00066 private:
00067 void gotoxy(int px, int py);
00068 void showtop(int py);
00069 void setcol(uint8 col);
00070 void scroll(int i);
00071
00072
00073
00074
00075 void clrscr();
00076
00077 void poke (char ch, int px, int py, uint8 col);
00078 void put(char ch, uint8 col);
00079
00080 void put(char ch);
00081
00082 void putch(char ch, uint8 col);
00083
00084 void putch(char ch);
00085
00086 void poke_str(char *ch, int px, int py, uint8 col, uint32 limit);
00087
00088 int getx(); int gety();
00089
00090 int getxsize(); int getysize();
00091
00092 void tab(int i);
00093 };
00094
00095
00096 const uint32 VIRTCONS_LINES = 240;
00097 const uint32 CONSOLE_XSIZE = 80;
00098 const uint32 CONSOLE_YSIZE = 24;
00099 const uint32 VIRTCONS_COUNT = 10;
00100 const uint32 VIDEO_MEMORY = 0xB8000;
00101 const uint8 CONSOLE_COLOR = 7;
00102 const uint8 TTY_PANEL_COLOR = 7<<4;
00103 const uint8 LOGOUT_COLOR = 8;
00104 const uint32 TTY_NO_X = 12;
00105 const uint32 GOTOXY_ADDEND = CONSOLE_XSIZE;
00106
00107
00108 #define VERBOSE_TTY (&tty3)
00109
00110 #define TECHNICAL_TTY (&tty4)
00111
00112 #define NOTICE_TTY (&tty5)
00113
00114 extern teletype videoHW;
00115 extern teletype tty_panel;
00116 extern teletype tty1, tty2, tty3, tty4, tty5, tty6, tty7, tty8, tty9, tty0;
00117 extern teletype *active_console;
00118
00119 extern ChCol tty1_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00120 extern ChCol tty2_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00121 extern ChCol tty3_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00122 extern ChCol tty4_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00123 extern ChCol tty5_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00124 extern ChCol tty6_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00125 extern ChCol tty7_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00126 extern ChCol tty8_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00127 extern ChCol tty9_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00128 extern ChCol tty0_buf [VIRTCONS_LINES * CONSOLE_XSIZE];
00129
00132
00133 void cout (char const *ch);
00134 void cout(teletype *tty, char *ch);
00135 void cout (char *ch, uint8 color);
00136 void cout (uint32 i);
00137 void cout (uint32 i,uint8 col);
00138 void cout (teletype *tty, uint32 i);
00139 void coutnum(uint32 n, uint32 radix, uint32 n_pos, char first_letter);
00140 void coutnum(teletype *tty, uint32 n, uint32 radix, uint32 n_pos, char first_letter, char EmptyLetter);
00141 void coutnum(teletype *tty, uint32 n, uint32 radix, uint32 n_pos, char first_letter, uint8 col);
00142 void coutnum(teletype *tty, uint32 n, uint32 radix, uint32 n_pos, char first_letter);
00143 void coutDec(uint32 i);
00144
00145 void coutb(uint8 ch);
00146 void putch(char ch);
00147 void writehere(char *ch, uint8 color, uint32 limit);
00148 void poke_char(char ch, uint8 color, int x, int y);
00149 void poke_str(char *ch, uint8 color, int x, int y, uint32 limit);
00151 void kprintf(const char *fmt, ...);
00152 void kprintf_alert(char *fmt, ...);
00153 void kprintf(teletype *tty, char *fmt, ...);
00154 void videoHW_gotoxy(int n);
00155 void videoHW_toggle_cursor(bool on);
00156
00157
00158 void ksnprintf(char *str, size_t size, char *format, ...);
00161
00162 int tui_kbd_handler();
00163 void tty_switch(teletype *tty,char *name);
00164
00165 #endif