Changeset 8b97256 in mainline
- Timestamp:
- 2008-12-18T12:23:39Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d99b3f2
- Parents:
- 8231246
- Location:
- uspace/srv/fb
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fb/msim.c
r8231246 r8b97256 37 37 38 38 #include <async.h> 39 #include <ipc/fb.h>40 #include <ipc/ipc.h>41 39 #include <libc.h> 42 #include <errno.h>43 #include <string.h>44 #include <libc.h>45 #include <stdio.h>46 #include <ipc/fb.h>47 40 #include <sysinfo.h> 48 41 #include <as.h> 49 #include <align.h>50 42 #include <ddi.h> 51 43 … … 56 48 #define HEIGHT 25 57 49 58 #define MAX_CONTROL 2059 60 /* Allow only 1 connection */61 static int client_connected = 0;62 63 50 static char *virt_addr; 64 51 … … 66 53 { 67 54 *virt_addr = c; 68 }69 70 static void msim_client_connection(ipc_callid_t iid, ipc_call_t *icall)71 {72 int retval;73 ipc_callid_t callid;74 ipc_call_t call;75 char c;76 int lastcol = 0;77 int lastrow = 0;78 int newcol;79 int newrow;80 int fgcolor;81 int bgcolor;82 int i;83 84 if (client_connected) {85 ipc_answer_0(iid, ELIMIT);86 return;87 }88 89 client_connected = 1;90 ipc_answer_0(iid, EOK);91 92 /* Clear the terminal, set scrolling region93 to 0 - 25 lines */94 serial_clrscr();95 serial_goto(0, 0);96 serial_puts("\033[0;25r");97 98 while (true) {99 callid = async_get_call(&call);100 switch (IPC_GET_METHOD(call)) {101 case IPC_M_PHONE_HUNGUP:102 client_connected = 0;103 ipc_answer_0(callid, EOK);104 return;105 case FB_PUTCHAR:106 c = IPC_GET_ARG1(call);107 newrow = IPC_GET_ARG2(call);108 newcol = IPC_GET_ARG3(call);109 if ((lastcol != newcol) || (lastrow != newrow))110 serial_goto(newrow, newcol);111 lastcol = newcol + 1;112 lastrow = newrow;113 msim_putc(c);114 retval = 0;115 break;116 case FB_CURSOR_GOTO:117 newrow = IPC_GET_ARG1(call);118 newcol = IPC_GET_ARG2(call);119 serial_goto(newrow, newcol);120 lastrow = newrow;121 lastcol = newcol;122 retval = 0;123 break;124 case FB_GET_CSIZE:125 ipc_answer_2(callid, EOK, HEIGHT, WIDTH);126 continue;127 case FB_CLEAR:128 serial_clrscr();129 retval = 0;130 break;131 case FB_SET_STYLE:132 fgcolor = IPC_GET_ARG1(call);133 bgcolor = IPC_GET_ARG2(call);134 if (fgcolor < bgcolor)135 serial_set_style(0);136 else137 serial_set_style(7);138 retval = 0;139 break;140 case FB_SCROLL:141 i = IPC_GET_ARG1(call);142 if ((i > HEIGHT) || (i < -HEIGHT)) {143 retval = EINVAL;144 break;145 }146 serial_scroll(i);147 serial_goto(lastrow, lastcol);148 retval = 0;149 break;150 case FB_CURSOR_VISIBILITY:151 if(IPC_GET_ARG1(call))152 serial_cursor_enable();153 else154 serial_cursor_disable();155 retval = 0;156 break;157 default:158 retval = ENOENT;159 }160 ipc_answer_0(callid, retval);161 }162 55 } 163 56 … … 171 64 serial_console_init(msim_putc, WIDTH, HEIGHT); 172 65 173 async_set_client_connection( msim_client_connection);66 async_set_client_connection(serial_client_connection); 174 67 return 0; 175 68 } -
uspace/srv/fb/serial_console.c
r8231246 r8b97256 39 39 40 40 #include <stdio.h> 41 #include <ipc/ipc.h> 42 #include <async.h> 43 #include <ipc/fb.h> 44 #include <bool.h> 45 #include <errno.h> 41 46 42 47 #include "serial_console.h" … … 44 49 #define MAX_CONTROL 20 45 50 46 static uint32_t width;47 static uint32_t height;51 static int width; 52 static int height; 48 53 static putc_function_t putc_function; 54 55 /* Allow only 1 connection */ 56 static int client_connected = 0; 49 57 50 58 void serial_puts(char *str) … … 89 97 } 90 98 99 /** Set scrolling region. */ 100 void serial_set_scroll_region(unsigned last_row) 101 { 102 char control[MAX_CONTROL]; 103 snprintf(control, MAX_CONTROL, "\033[0;%ur", last_row); 104 serial_puts(control); 105 } 106 91 107 void serial_cursor_disable(void) 92 108 { … … 106 122 } 107 123 124 /** 125 * Main function of the thread serving client connections. 126 */ 127 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall) 128 { 129 int retval; 130 ipc_callid_t callid; 131 ipc_call_t call; 132 char c; 133 int lastcol = 0; 134 int lastrow = 0; 135 int newcol; 136 int newrow; 137 int fgcolor; 138 int bgcolor; 139 int i; 140 141 if (client_connected) { 142 ipc_answer_0(iid, ELIMIT); 143 return; 144 } 145 146 client_connected = 1; 147 ipc_answer_0(iid, EOK); 148 149 /* Clear the terminal, set scrolling region 150 to 0 - height rows. */ 151 serial_clrscr(); 152 serial_goto(0, 0); 153 serial_set_scroll_region(height); 154 155 while (true) { 156 callid = async_get_call(&call); 157 switch (IPC_GET_METHOD(call)) { 158 case IPC_M_PHONE_HUNGUP: 159 client_connected = 0; 160 ipc_answer_0(callid, EOK); 161 return; 162 case FB_PUTCHAR: 163 c = IPC_GET_ARG1(call); 164 newrow = IPC_GET_ARG2(call); 165 newcol = IPC_GET_ARG3(call); 166 if ((lastcol != newcol) || (lastrow != newrow)) 167 serial_goto(newrow, newcol); 168 lastcol = newcol + 1; 169 lastrow = newrow; 170 (*putc_function)(c); 171 retval = 0; 172 break; 173 case FB_CURSOR_GOTO: 174 newrow = IPC_GET_ARG1(call); 175 newcol = IPC_GET_ARG2(call); 176 serial_goto(newrow, newcol); 177 lastrow = newrow; 178 lastcol = newcol; 179 retval = 0; 180 break; 181 case FB_GET_CSIZE: 182 ipc_answer_2(callid, EOK, height, width); 183 continue; 184 case FB_CLEAR: 185 serial_clrscr(); 186 retval = 0; 187 break; 188 case FB_SET_STYLE: 189 fgcolor = IPC_GET_ARG1(call); 190 bgcolor = IPC_GET_ARG2(call); 191 if (fgcolor < bgcolor) 192 serial_set_style(0); 193 else 194 serial_set_style(7); 195 retval = 0; 196 break; 197 case FB_SCROLL: 198 i = IPC_GET_ARG1(call); 199 if ((i > height) || (i < -height)) { 200 retval = EINVAL; 201 break; 202 } 203 serial_scroll(i); 204 serial_goto(lastrow, lastcol); 205 retval = 0; 206 break; 207 case FB_CURSOR_VISIBILITY: 208 if(IPC_GET_ARG1(call)) 209 serial_cursor_enable(); 210 else 211 serial_cursor_disable(); 212 retval = 0; 213 break; 214 default: 215 retval = ENOENT; 216 } 217 ipc_answer_0(callid, retval); 218 } 219 } 220 108 221 /** 109 222 * @} -
uspace/srv/fb/serial_console.h
r8231246 r8b97256 39 39 #define FB_SERIAL_CONSOLE_H_ 40 40 41 #include <ipc/ipc.h> 42 41 43 typedef void (*putc_function_t)(char); 42 44 … … 48 50 void serial_cursor_disable(void); 49 51 void serial_cursor_enable(void); 52 void serial_set_scroll_region(unsigned height); 50 53 void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h); 54 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall); 55 51 56 52 57 #endif -
uspace/srv/fb/sgcn.c
r8231246 r8b97256 37 37 38 38 #include <async.h> 39 #include <ipc/ipc.h>40 #include <ipc/fb.h>41 39 #include <sysinfo.h> 42 40 #include <as.h> … … 60 58 */ 61 59 static uintptr_t sram_buffer_offset; 62 63 /* Allow only 1 connection */64 static int client_connected = 0;65 60 66 61 /** … … 123 118 124 119 /** 125 * Main function of the thread serving client connections.126 */127 static void sgcn_client_connection(ipc_callid_t iid, ipc_call_t *icall)128 {129 int retval;130 ipc_callid_t callid;131 ipc_call_t call;132 char c;133 int lastcol = 0;134 int lastrow = 0;135 int newcol;136 int newrow;137 int fgcolor;138 int bgcolor;139 int i;140 141 if (client_connected) {142 ipc_answer_0(iid, ELIMIT);143 return;144 }145 146 client_connected = 1;147 ipc_answer_0(iid, EOK);148 149 /* Clear the terminal, set scrolling region150 to 0 - 24 lines */151 serial_clrscr();152 serial_goto(0, 0);153 serial_puts("\033[0;24r");154 155 while (true) {156 callid = async_get_call(&call);157 switch (IPC_GET_METHOD(call)) {158 case IPC_M_PHONE_HUNGUP:159 client_connected = 0;160 ipc_answer_0(callid, EOK);161 return;162 case FB_PUTCHAR:163 c = IPC_GET_ARG1(call);164 newrow = IPC_GET_ARG2(call);165 newcol = IPC_GET_ARG3(call);166 if ((lastcol != newcol) || (lastrow != newrow))167 serial_goto(newrow, newcol);168 lastcol = newcol + 1;169 lastrow = newrow;170 sgcn_putc(c);171 retval = 0;172 break;173 case FB_CURSOR_GOTO:174 newrow = IPC_GET_ARG1(call);175 newcol = IPC_GET_ARG2(call);176 serial_goto(newrow, newcol);177 lastrow = newrow;178 lastcol = newcol;179 retval = 0;180 break;181 case FB_GET_CSIZE:182 ipc_answer_2(callid, EOK, HEIGHT, WIDTH);183 continue;184 case FB_CLEAR:185 serial_clrscr();186 retval = 0;187 break;188 case FB_SET_STYLE:189 fgcolor = IPC_GET_ARG1(call);190 bgcolor = IPC_GET_ARG2(call);191 if (fgcolor < bgcolor)192 serial_set_style(0);193 else194 serial_set_style(7);195 retval = 0;196 break;197 case FB_SCROLL:198 i = IPC_GET_ARG1(call);199 if ((i > HEIGHT) || (i < -HEIGHT)) {200 retval = EINVAL;201 break;202 }203 serial_scroll(i);204 serial_goto(lastrow, lastcol);205 retval = 0;206 break;207 case FB_CURSOR_VISIBILITY:208 if(IPC_GET_ARG1(call))209 serial_cursor_enable();210 else211 serial_cursor_disable();212 retval = 0;213 break;214 default:215 retval = ENOENT;216 }217 ipc_answer_0(callid, retval);218 }219 }220 221 /**222 120 * Initializes the SGCN serial driver. 223 121 */ … … 241 139 sram_buffer_offset = sysinfo_value("sram.buffer.offset"); 242 140 243 async_set_client_connection(s gcn_client_connection);141 async_set_client_connection(serial_client_connection); 244 142 return 0; 245 143 }
Note:
See TracChangeset
for help on using the changeset viewer.