Changeset 70253688 in mainline for uspace/srv
- Timestamp:
- 2012-09-07T08:12:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e0c836e8
- Parents:
- 131d9a4 (diff), 8cf4823 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/srv
- Files:
-
- 15 added
- 12 edited
-
fs/udf/Makefile (added)
-
fs/udf/udf.c (added)
-
fs/udf/udf.h (added)
-
fs/udf/udf_cksum.c (added)
-
fs/udf/udf_cksum.h (added)
-
fs/udf/udf_file.c (added)
-
fs/udf/udf_file.h (added)
-
fs/udf/udf_idx.c (added)
-
fs/udf/udf_idx.h (added)
-
fs/udf/udf_ops.c (added)
-
fs/udf/udf_osta.c (added)
-
fs/udf/udf_osta.h (added)
-
fs/udf/udf_types.h (added)
-
fs/udf/udf_volume.c (added)
-
fs/udf/udf_volume.h (added)
-
hid/compositor/compositor.c (modified) (35 diffs)
-
hid/compositor/compositor.h (modified) (1 diff)
-
hid/console/console.c (modified) (18 diffs)
-
hid/remcons/remcons.c (modified) (8 diffs)
-
hid/remcons/user.c (modified) (3 diffs)
-
hid/remcons/user.h (modified) (3 diffs)
-
net/ethip/pdu.c (modified) (2 diffs)
-
net/tcp/conn.c (modified) (2 diffs)
-
net/tcp/segment.c (modified) (1 diff)
-
net/tcp/sock.c (modified) (3 diffs)
-
net/tcp/tqueue.c (modified) (1 diff)
-
net/udp/sock.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/compositor/compositor.c
r131d9a4 r70253688 49 49 #include <adt/prodcons.h> 50 50 #include <adt/list.h> 51 #include <io/input.h> 51 52 #include <ipc/graph.h> 52 #include <ipc/input.h>53 53 #include <ipc/window.h> 54 54 … … 92 92 sysarg_t id; 93 93 uint8_t state; 94 sysarg_t hpos; 95 sysarg_t vpos; 94 desktop_point_t pos; 96 95 sysarg_t btn_num; 97 sysarg_t btn_hpos; 98 sysarg_t btn_vpos; 99 int accum_dx; 100 int accum_dy; 96 desktop_point_t btn_pos; 97 desktop_vector_t accum; 101 98 sysarg_t grab_flags; 102 99 bool pressed; … … 135 132 vslmode_t mode; 136 133 async_sess_t *sess; 137 sysarg_t hpos; 138 sysarg_t vpos; 134 desktop_point_t pos; 139 135 surface_t *surface; 140 136 } viewport_t; … … 143 139 static LIST_INITIALIZE(viewport_list); 144 140 145 static async_sess_t *input_sess; 141 /** Input server proxy */ 142 static input_t *input; 143 144 static int comp_key_press(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t); 145 static int comp_mouse_move(input_t *, int, int); 146 static int comp_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 147 static int comp_mouse_button(input_t *, int, int); 148 149 static input_ev_ops_t input_ev_ops = { 150 .key = comp_key_press, 151 .move = comp_mouse_move, 152 .abs_move = comp_abs_move, 153 .button = comp_mouse_button 154 }; 155 156 static void input_disconnect(void); 157 158 159 static pointer_t *input_pointer(input_t *input) 160 { 161 return input->user; 162 } 146 163 147 164 static pointer_t *pointer_create() … … 153 170 154 171 link_initialize(&p->link); 155 p-> hpos= coord_origin;156 p-> vpos= coord_origin;172 p->pos.x = coord_origin; 173 p->pos.y = coord_origin; 157 174 p->btn_num = 1; 158 p->btn_hpos = p->hpos; 159 p->btn_vpos = p->vpos; 160 p->accum_dx = 0; 161 p->accum_dy = 0; 175 p->btn_pos = p->pos; 176 p->accum.x = 0; 177 p->accum.y = 0; 162 178 p->grab_flags = GF_EMPTY; 163 179 p->pressed = false; … … 286 302 bool isec_vp = rectangle_intersect( 287 303 x_dmg_glob, y_dmg_glob, w_dmg_glob, h_dmg_glob, 288 vp-> hpos, vp->vpos, w_dmg_vp, h_dmg_vp,304 vp->pos.x, vp->pos.y, w_dmg_vp, h_dmg_vp, 289 305 &x_dmg_vp, &y_dmg_vp, &w_dmg_vp, &h_dmg_vp); 290 306 … … 292 308 293 309 /* Paint background color. */ 294 for (sysarg_t y = y_dmg_vp - vp-> vpos; y < y_dmg_vp - vp->vpos+ h_dmg_vp; ++y) {295 for (sysarg_t x = x_dmg_vp - vp-> hpos; x < x_dmg_vp - vp->hpos+ w_dmg_vp; ++x) {310 for (sysarg_t y = y_dmg_vp - vp->pos.y; y < y_dmg_vp - vp->pos.y + h_dmg_vp; ++y) { 311 for (sysarg_t x = x_dmg_vp - vp->pos.x; x < x_dmg_vp - vp->pos.x + w_dmg_vp; ++x) { 296 312 surface_put_pixel(vp->surface, x, y, bg_color); 297 313 } … … 331 347 * coordinates. */ 332 348 transform = win->transform; 333 double hpos = vp->hpos; 334 double vpos = vp->vpos; 335 transform_translate(&transform, -hpos, -vpos); 349 double_point_t pos; 350 pos.x = vp->pos.x; 351 pos.y = vp->pos.y; 352 transform_translate(&transform, -pos.x, -pos.y); 336 353 337 354 source_set_transform(&source, transform); … … 340 357 341 358 drawctx_transfer(&context, 342 x_dmg_win - vp-> hpos, y_dmg_win - vp->vpos, w_dmg_win, h_dmg_win);359 x_dmg_win - vp->pos.x, y_dmg_win - vp->pos.y, w_dmg_win, h_dmg_win); 343 360 } 344 361 } … … 354 371 bool isec_ptr = rectangle_intersect( 355 372 x_dmg_vp, y_dmg_vp, w_dmg_vp, h_dmg_vp, 356 ptr-> hpos, ptr->vpos, w_dmg_ptr, h_dmg_ptr,373 ptr->pos.x, ptr->pos.y, w_dmg_ptr, h_dmg_ptr, 357 374 &x_dmg_ptr, &y_dmg_ptr, &w_dmg_ptr, &h_dmg_ptr); 358 375 … … 365 382 366 383 pixel_t pix = 0; 367 sysarg_t x_vp = x_dmg_ptr - vp-> hpos;368 sysarg_t y_vp = y_dmg_ptr - vp-> vpos;369 sysarg_t x_ptr = x_dmg_ptr - ptr-> hpos;370 sysarg_t y_ptr = y_dmg_ptr - ptr-> vpos;384 sysarg_t x_vp = x_dmg_ptr - vp->pos.x; 385 sysarg_t y_vp = y_dmg_ptr - vp->pos.y; 386 sysarg_t x_ptr = x_dmg_ptr - ptr->pos.x; 387 sysarg_t y_ptr = y_dmg_ptr - ptr->pos.y; 371 388 372 389 for (sysarg_t y = 0; y < h_dmg_ptr; ++y) { … … 759 776 fibril_mutex_unlock(&viewport_list_mtx); 760 777 loc_service_unregister(winreg_id); 761 async_hangup(input_sess);778 input_disconnect(); 762 779 763 780 /* Close all clients and their windows. */ … … 880 897 881 898 link_initialize(&vp->link); 882 vp-> hpos= coord_origin;883 vp-> vpos= coord_origin;899 vp->pos.x = coord_origin; 900 vp->pos.y = coord_origin; 884 901 885 902 /* Establish output bidirectional connection. */ … … 981 998 /* window_list_mtx locked by caller */ 982 999 983 int dx = pointer->accum _dx;984 int dy = pointer->accum _dy;985 pointer->accum _dx = 0;986 pointer->accum _dy = 0;1000 int dx = pointer->accum.x; 1001 int dy = pointer->accum.y; 1002 pointer->accum.x = 0; 1003 pointer->accum.y = 0; 987 1004 988 1005 bool move = (pointer->grab_flags & GF_MOVE_X) || (pointer->grab_flags & GF_MOVE_Y); … … 1055 1072 } 1056 1073 1057 static void comp_mouse_move(pointer_t *pointer, ipc_callid_t iid, ipc_call_t *icall) 1058 { 1059 int dx = (int) IPC_GET_ARG1(*icall); 1060 int dy = (int) IPC_GET_ARG2(*icall); 1074 static int comp_abs_move(input_t *input, unsigned x , unsigned y, 1075 unsigned max_x, unsigned max_y) 1076 { 1077 /* XXX TODO Use absolute coordinates directly */ 1078 1079 pointer_t *pointer = input_pointer(input); 1080 1081 sysarg_t width, height; 1082 1083 fibril_mutex_lock(&viewport_list_mtx); 1084 if (list_empty(&viewport_list)) { 1085 printf("No viewport found\n"); 1086 fibril_mutex_unlock(&viewport_list_mtx); 1087 return EOK; /* XXX */ 1088 } 1089 link_t *link = list_first(&viewport_list); 1090 viewport_t *vp = list_get_instance(link, viewport_t, link); 1091 surface_get_resolution(vp->surface, &width, &height); 1092 desktop_point_t vp_pos = vp->pos; 1093 fibril_mutex_unlock(&viewport_list_mtx); 1094 1095 desktop_point_t pos_in_viewport; 1096 pos_in_viewport.x = x * width / max_x; 1097 pos_in_viewport.y = y * height / max_y; 1098 1099 /* Calculate offset from pointer */ 1100 fibril_mutex_lock(&pointer_list_mtx); 1101 desktop_vector_t delta; 1102 delta.x = (vp_pos.x + pos_in_viewport.x) - pointer->pos.x; 1103 delta.y = (vp_pos.y + pos_in_viewport.y) - pointer->pos.y; 1104 fibril_mutex_unlock(&pointer_list_mtx); 1105 1106 return comp_mouse_move(input, delta.x, delta.y); 1107 } 1108 1109 static int comp_mouse_move(input_t *input, int dx, int dy) 1110 { 1111 pointer_t *pointer = input_pointer(input); 1061 1112 1062 1113 /* Update pointer position. */ 1063 1114 fibril_mutex_lock(&pointer_list_mtx); 1064 sysarg_t old_hpos = pointer->hpos; 1065 sysarg_t old_vpos = pointer->vpos; 1115 desktop_point_t old_pos = pointer->pos; 1066 1116 sysarg_t cursor_width; 1067 1117 sysarg_t cursor_height; 1068 1118 surface_get_resolution(pointer->cursor.states[pointer->state], 1069 1119 &cursor_width, &cursor_height); 1070 pointer-> hpos+= dx;1071 pointer-> vpos+= dy;1120 pointer->pos.x += dx; 1121 pointer->pos.y += dy; 1072 1122 fibril_mutex_unlock(&pointer_list_mtx); 1073 comp_damage(old_ hpos, old_vpos, cursor_width, cursor_height);1074 comp_damage(old_ hpos + dx, old_vpos+ dy, cursor_width, cursor_height);1123 comp_damage(old_pos.x, old_pos.y, cursor_width, cursor_height); 1124 comp_damage(old_pos.x + dx, old_pos.y + dy, cursor_width, cursor_height); 1075 1125 1076 1126 fibril_mutex_lock(&window_list_mtx); … … 1084 1134 sysarg_t width, height; 1085 1135 surface_get_resolution(top->surface, &width, &height); 1086 within_client = comp_coord_to_client(pointer-> hpos, pointer->vpos,1136 within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y, 1087 1137 top->transform, width, height, &point_x, &point_y); 1088 1138 fibril_mutex_unlock(&window_list_mtx); … … 1103 1153 } else { 1104 1154 /* Pointer is grabbed by top-level window action. */ 1105 pointer->accum _dx += dx;1106 pointer->accum _dy += dy;1155 pointer->accum.x += dx; 1156 pointer->accum.y += dy; 1107 1157 #if ANIMATE_WINDOW_TRANSFORMS == 1 1108 1158 sysarg_t x, y, width, height; … … 1118 1168 } 1119 1169 1120 async_answer_0(iid, EOK); 1121 } 1122 1123 static void comp_mouse_button(pointer_t *pointer, ipc_callid_t iid, ipc_call_t *icall) 1124 { 1125 sysarg_t btn_num = IPC_GET_ARG1(*icall); 1126 bool pressed = (bool) IPC_GET_ARG2(*icall); 1127 1128 if (pressed) { 1129 pointer->btn_hpos = pointer->hpos; 1130 pointer->btn_vpos = pointer->vpos; 1131 pointer->btn_num = btn_num; 1170 return EOK; 1171 } 1172 1173 static int comp_mouse_button(input_t *input, int bnum, int bpress) 1174 { 1175 pointer_t *pointer = input_pointer(input); 1176 1177 if (bpress) { 1178 pointer->btn_pos = pointer->pos; 1179 pointer->btn_num = bnum; 1132 1180 pointer->pressed = true; 1133 1181 … … 1137 1185 if (!win || !win->surface) { 1138 1186 fibril_mutex_unlock(&window_list_mtx); 1139 async_answer_0(iid, EOK); 1140 return; 1187 return EOK; 1141 1188 } 1142 1189 sysarg_t x, y, width, height; 1143 1190 surface_get_resolution(win->surface, &width, &height); 1144 bool within_client = comp_coord_to_client(pointer-> hpos, pointer->vpos,1191 bool within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y, 1145 1192 win->transform, width, height, &x, &y); 1146 1193 fibril_mutex_unlock(&window_list_mtx); … … 1154 1201 event->data.pos.pos_id = pointer->id; 1155 1202 event->data.pos.type = POS_PRESS; 1156 event->data.pos.btn_num = b tn_num;1203 event->data.pos.btn_num = bnum; 1157 1204 event->data.pos.hpos = x; 1158 1205 event->data.pos.vpos = y; 1159 1206 comp_post_event(event); 1160 1207 } else { 1161 async_answer_0(iid, ENOMEM); 1162 return; 1163 } 1164 } 1165 } else if (pointer->pressed && pointer->btn_num == btn_num) { 1208 return ENOMEM; 1209 } 1210 } 1211 } else if (pointer->pressed && pointer->btn_num == (unsigned)bnum) { 1166 1212 pointer->pressed = false; 1167 1213 … … 1178 1224 if (win->surface) { 1179 1225 surface_get_resolution(win->surface, &width, &height); 1180 within_client = comp_coord_to_client(pointer-> hpos, pointer->vpos,1226 within_client = comp_coord_to_client(pointer->pos.x, pointer->pos.y, 1181 1227 win->transform, width, height, &point_x, &point_y); 1182 1228 } … … 1191 1237 pointer->grab_flags = GF_EMPTY; 1192 1238 fibril_mutex_unlock(&window_list_mtx); 1193 async_answer_0(iid, EOK); 1194 return; 1239 return EOK; 1195 1240 } 1196 1241 … … 1257 1302 event->data.pos.pos_id = pointer->id; 1258 1303 event->data.pos.type = POS_RELEASE; 1259 event->data.pos.btn_num = b tn_num;1304 event->data.pos.btn_num = bnum; 1260 1305 event->data.pos.hpos = point_x; 1261 1306 event->data.pos.vpos = point_y; … … 1263 1308 pointer->grab_flags = GF_EMPTY; 1264 1309 1265 } else if (within_client && (pointer->grab_flags == GF_EMPTY) && (b tn_num == 1)) {1310 } else if (within_client && (pointer->grab_flags == GF_EMPTY) && (bnum == 1)) { 1266 1311 1267 1312 /* Bring the window to the foreground. */ … … 1286 1331 } 1287 1332 1288 async_answer_0(iid, EOK); 1289 } 1290 1291 static void comp_key_press(ipc_callid_t iid, ipc_call_t *icall) 1292 { 1293 kbd_event_type_t type = IPC_GET_ARG1(*icall); 1294 keycode_t key = IPC_GET_ARG2(*icall); 1295 keymod_t mods = IPC_GET_ARG3(*icall); 1296 wchar_t c = IPC_GET_ARG4(*icall); 1297 1333 return EOK; 1334 } 1335 1336 static int comp_key_press(input_t *input, kbd_event_type_t type, keycode_t key, 1337 keymod_t mods, wchar_t c) 1338 { 1298 1339 bool win_transform = (mods & KM_ALT) && ( 1299 1340 key == KC_W || key == KC_S || key == KC_A || key == KC_D || … … 1378 1419 if (event == NULL) { 1379 1420 fibril_mutex_unlock(&window_list_mtx); 1380 async_answer_0(iid, ENOMEM); 1381 return; 1421 return ENOMEM; 1382 1422 } 1383 1423 … … 1448 1488 } else if (win_close) { 1449 1489 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 1450 if (event == NULL) { 1451 async_answer_0(iid, ENOMEM); 1452 return; 1453 } 1490 if (event == NULL) 1491 return ENOMEM; 1454 1492 1455 1493 link_initialize(&event->link); … … 1502 1540 switch (key) { 1503 1541 case KC_I: 1504 vp-> hpos+= 0;1505 vp-> vpos+= -20;1542 vp->pos.x += 0; 1543 vp->pos.y += -20; 1506 1544 break; 1507 1545 case KC_K: 1508 vp-> hpos+= 0;1509 vp-> vpos+= 20;1546 vp->pos.x += 0; 1547 vp->pos.y += 20; 1510 1548 break; 1511 1549 case KC_J: 1512 vp-> hpos+= -20;1513 vp-> vpos+= 0;1550 vp->pos.x += -20; 1551 vp->pos.y += 0; 1514 1552 break; 1515 1553 case KC_L: 1516 vp-> hpos+= 20;1517 vp-> vpos+= 0;1554 vp->pos.x += 20; 1555 vp->pos.y += 0; 1518 1556 break; 1519 1557 default: 1520 vp-> hpos+= 0;1521 vp-> vpos+= 0;1558 vp->pos.x += 0; 1559 vp->pos.y += 0; 1522 1560 break; 1523 1561 } 1524 1562 1525 sysarg_t x = vp-> hpos;1526 sysarg_t y = vp-> vpos;1563 sysarg_t x = vp->pos.x; 1564 sysarg_t y = vp->pos.y; 1527 1565 sysarg_t width, height; 1528 1566 surface_get_resolution(vp->surface, &width, &height); … … 1594 1632 } else { 1595 1633 window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t)); 1596 if (event == NULL) { 1597 async_answer_0(iid, ENOMEM); 1598 return; 1599 } 1634 if (event == NULL) 1635 return ENOMEM; 1600 1636 1601 1637 link_initialize(&event->link); … … 1609 1645 } 1610 1646 1611 async_answer_0(iid, EOK); 1612 } 1613 1614 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 1615 { 1647 return EOK; 1648 } 1649 1650 static int input_connect(const char *svc) 1651 { 1652 async_sess_t *sess; 1653 service_id_t dsid; 1654 1655 int rc = loc_service_get_id(svc, &dsid, 0); 1656 if (rc != EOK) { 1657 printf("%s: Input service %s not found\n", NAME, svc); 1658 return rc; 1659 } 1660 1661 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 1662 if (sess == NULL) { 1663 printf("%s: Unable to connect to input service %s\n", NAME, 1664 svc); 1665 return EIO; 1666 } 1667 1616 1668 fibril_mutex_lock(&pointer_list_mtx); 1617 1669 pointer_t *pointer = pointer_create(); … … 1622 1674 fibril_mutex_unlock(&pointer_list_mtx); 1623 1675 1624 /* Ignore parameters, the connection is already opened. */ 1625 while (true) { 1626 ipc_call_t call; 1627 ipc_callid_t callid = async_get_call(&call); 1628 1629 if (!IPC_GET_IMETHOD(call)) { 1630 fibril_mutex_lock(&pointer_list_mtx); 1631 if (pointer != NULL) { 1632 list_remove(&pointer->link); 1633 pointer_destroy(pointer); 1634 } 1635 fibril_mutex_unlock(&pointer_list_mtx); 1636 async_hangup(input_sess); 1637 return; 1638 } 1639 1640 switch (IPC_GET_IMETHOD(call)) { 1641 case INPUT_EVENT_KEY: 1642 comp_key_press(callid, &call); 1643 break; 1644 case INPUT_EVENT_MOVE: 1645 comp_mouse_move(pointer, callid, &call); 1646 break; 1647 case INPUT_EVENT_BUTTON: 1648 comp_mouse_button(pointer, callid, &call); 1649 break; 1650 default: 1651 async_answer_0(callid, EINVAL); 1652 } 1653 } 1654 } 1655 1656 static async_sess_t *input_connect(const char *svc) 1657 { 1658 async_sess_t *sess; 1659 service_id_t dsid; 1660 1661 int rc = loc_service_get_id(svc, &dsid, 0); 1662 if (rc == EOK) { 1663 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 1664 if (sess == NULL) { 1665 printf("%s: Unable to connect to input service %s\n", NAME, svc); 1666 return NULL; 1667 } 1668 } else 1669 return NULL; 1670 1671 async_exch_t *exch = async_exchange_begin(sess); 1672 rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL); 1673 async_exchange_end(exch); 1674 1676 if (pointer == NULL) { 1677 printf("%s: Cannot create pointer.\n", NAME); 1678 async_hangup(sess); 1679 return ENOMEM; 1680 } 1681 1682 rc = input_open(sess, &input_ev_ops, pointer, &input); 1675 1683 if (rc != EOK) { 1676 1684 async_hangup(sess); 1677 printf("%s: Unable to c reate callback connection toservice %s (%s)\n",1685 printf("%s: Unable to communicate with service %s (%s)\n", 1678 1686 NAME, svc, str_error(rc)); 1679 return NULL; 1680 } 1681 1682 return sess; 1687 return rc; 1688 } 1689 1690 return EOK; 1691 } 1692 1693 static void input_disconnect(void) 1694 { 1695 pointer_t *pointer = input->user; 1696 input_close(input); 1697 pointer_destroy(pointer); 1683 1698 } 1684 1699 … … 1733 1748 1734 1749 /* Establish input bidirectional connection. */ 1735 input_sess = input_connect(input_svc); 1736 if (input_sess == NULL) { 1737 return -1; 1738 } 1750 rc = input_connect(input_svc); 1751 if (rc != EOK) 1752 return rc; 1739 1753 1740 1754 /* Create viewports and connect them to visualizers. */ … … 1742 1756 rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING); 1743 1757 if (rc != EOK) { 1744 async_hangup(input_sess);1758 input_disconnect(); 1745 1759 return -1; 1746 1760 } … … 1750 1764 rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt); 1751 1765 if (rc != EOK || svcs_cnt == 0) { 1752 async_hangup(input_sess);1766 input_disconnect(); 1753 1767 return -1; 1754 1768 } … … 1766 1780 1767 1781 if (list_empty(&viewport_list)) { 1768 async_hangup(input_sess);1782 input_disconnect(); 1769 1783 return -1; 1770 1784 } -
uspace/srv/hid/compositor/compositor.h
r131d9a4 r70253688 36 36 #define COMPOSITOR_COMPOSITOR_H_ 37 37 38 typedef native_t desktop_coord_t; 39 typedef struct { 40 desktop_coord_t x; 41 desktop_coord_t y; 42 } desktop_point_t; 43 typedef desktop_point_t desktop_vector_t; 44 45 /* TODO remove? */ 46 typedef struct { 47 double x; 48 double y; 49 } double_point_t; 50 typedef double_point_t double_vector_t; 51 38 52 #endif 39 53 -
uspace/srv/hid/console/console.c
r131d9a4 r70253688 36 36 #include <stdio.h> 37 37 #include <adt/prodcons.h> 38 #include <ipc/input.h> 39 #include <ipc/console.h> 38 #include <io/input.h> 40 39 #include <ipc/vfs.h> 41 40 #include <errno.h> … … 43 42 #include <loc.h> 44 43 #include <event.h> 44 #include <io/con_srv.h> 45 #include <io/kbd_event.h> 45 46 #include <io/keycode.h> 46 47 #include <io/chargrid.h> 47 #include <io/console.h>48 48 #include <io/output.h> 49 49 #include <align.h> … … 79 79 chargrid_t *frontbuf; /**< Front buffer */ 80 80 frontbuf_handle_t fbid; /**< Front buffer handle */ 81 con_srvs_t srvs; /**< Console service setup */ 81 82 } console_t; 82 83 83 /** Session to the input server*/84 static async_sess_t *input_sess;84 /** Input server proxy */ 85 static input_t *input; 85 86 86 87 /** Session to the output server */ … … 101 102 static console_t *kernel_console = &consoles[KERNEL_CONSOLE]; 102 103 104 static int input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t); 105 static int input_ev_move(input_t *, int, int); 106 static int input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 107 static int input_ev_button(input_t *, int, int); 108 109 static input_ev_ops_t input_ev_ops = { 110 .key = input_ev_key, 111 .move = input_ev_move, 112 .abs_move = input_ev_abs_move, 113 .button = input_ev_button 114 }; 115 116 static int cons_open(con_srvs_t *, con_srv_t *); 117 static int cons_close(con_srv_t *); 118 static int cons_read(con_srv_t *, void *, size_t); 119 static int cons_write(con_srv_t *, void *, size_t); 120 static void cons_sync(con_srv_t *); 121 static void cons_clear(con_srv_t *); 122 static void cons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row); 123 static int cons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *); 124 static int cons_get_size(con_srv_t *, sysarg_t *, sysarg_t *); 125 static int cons_get_color_cap(con_srv_t *, console_caps_t *); 126 static void cons_set_style(con_srv_t *, console_style_t); 127 static void cons_set_color(con_srv_t *, console_color_t, console_color_t, 128 console_color_attr_t); 129 static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t); 130 static void cons_set_cursor_visibility(con_srv_t *, bool); 131 static int cons_get_event(con_srv_t *, kbd_event_t *); 132 133 static con_ops_t con_ops = { 134 .open = cons_open, 135 .close = cons_close, 136 .read = cons_read, 137 .write = cons_write, 138 .sync = cons_sync, 139 .clear = cons_clear, 140 .set_pos = cons_set_pos, 141 .get_pos = cons_get_pos, 142 .get_size = cons_get_size, 143 .get_color_cap = cons_get_color_cap, 144 .set_style = cons_set_style, 145 .set_color = cons_set_color, 146 .set_rgb_color = cons_set_rgb_color, 147 .set_cursor_visibility = cons_set_cursor_visibility, 148 .get_event = cons_get_event 149 }; 150 151 static console_t *srv_to_console(con_srv_t *srv) 152 { 153 return srv->srvs->sarg; 154 } 155 103 156 static void cons_update(console_t *cons) 104 157 { … … 125 178 fibril_mutex_unlock(&cons->mtx); 126 179 fibril_mutex_unlock(&switch_mtx); 127 }128 129 static void cons_clear(console_t *cons)130 {131 fibril_mutex_lock(&cons->mtx);132 chargrid_clear(cons->frontbuf);133 fibril_mutex_unlock(&cons->mtx);134 135 cons_update(cons);136 180 } 137 181 … … 195 239 } 196 240 197 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 198 { 199 /* Ignore parameters, the connection is already opened */ 200 while (true) { 201 ipc_call_t call; 202 ipc_callid_t callid = async_get_call(&call); 203 204 if (!IPC_GET_IMETHOD(call)) { 205 /* TODO: Handle hangup */ 206 async_hangup(input_sess); 207 return; 208 } 209 210 kbd_event_type_t type; 211 keycode_t key; 212 keymod_t mods; 213 wchar_t c; 214 215 switch (IPC_GET_IMETHOD(call)) { 216 case INPUT_EVENT_KEY: 217 type = IPC_GET_ARG1(call); 218 key = IPC_GET_ARG2(call); 219 mods = IPC_GET_ARG3(call); 220 c = IPC_GET_ARG4(call); 221 222 if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) && 223 ((mods & KM_CTRL) == 0)) 224 cons_switch(&consoles[key - KC_F1]); 225 else { 226 /* Got key press/release event */ 227 kbd_event_t *event = 228 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 229 if (event == NULL) { 230 async_answer_0(callid, ENOMEM); 231 break; 232 } 233 234 link_initialize(&event->link); 235 event->type = type; 236 event->key = key; 237 event->mods = mods; 238 event->c = c; 239 240 /* 241 * Kernel console does not read events 242 * from us, so we will redirect them 243 * to the (last) active userspace console 244 * if necessary. 245 */ 246 console_t *target_console = cons_get_active_uspace(); 247 248 prodcons_produce(&target_console->input_pc, 249 &event->link); 250 } 251 252 async_answer_0(callid, EOK); 253 break; 254 case INPUT_EVENT_MOVE: 255 async_answer_0(callid, EOK); 256 break; 257 case INPUT_EVENT_BUTTON: 258 async_answer_0(callid, EOK); 259 break; 260 default: 261 async_answer_0(callid, EINVAL); 262 } 263 } 241 static int input_ev_key(input_t *input, kbd_event_type_t type, keycode_t key, 242 keymod_t mods, wchar_t c) 243 { 244 if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) && 245 ((mods & KM_CTRL) == 0)) { 246 cons_switch(&consoles[key - KC_F1]); 247 } else { 248 /* Got key press/release event */ 249 kbd_event_t *event = 250 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 251 if (event == NULL) { 252 return ENOMEM; 253 } 254 255 link_initialize(&event->link); 256 event->type = type; 257 event->key = key; 258 event->mods = mods; 259 event->c = c; 260 261 /* 262 * Kernel console does not read events 263 * from us, so we will redirect them 264 * to the (last) active userspace console 265 * if necessary. 266 */ 267 console_t *target_console = cons_get_active_uspace(); 268 269 prodcons_produce(&target_console->input_pc, 270 &event->link); 271 } 272 273 return EOK; 274 } 275 276 static int input_ev_move(input_t *input, int dx, int dy) 277 { 278 return EOK; 279 } 280 281 static int input_ev_abs_move(input_t *input, unsigned x , unsigned y, 282 unsigned max_x, unsigned max_y) 283 { 284 return EOK; 285 } 286 287 static int input_ev_button(input_t *input, int bnum, int bpress) 288 { 289 return EOK; 264 290 } 265 291 … … 293 319 } 294 320 295 static void cons_set_cursor (console_t *cons, sysarg_t col, sysarg_t row)296 { 297 fibril_mutex_lock(&cons->mtx); 298 chargrid_set_cursor (cons->frontbuf, col, row);321 static void cons_set_cursor_vis(console_t *cons, bool visible) 322 { 323 fibril_mutex_lock(&cons->mtx); 324 chargrid_set_cursor_visibility(cons->frontbuf, visible); 299 325 fibril_mutex_unlock(&cons->mtx); 300 326 … … 302 328 } 303 329 304 static void cons_set_cursor_visibility(console_t *cons, bool visible) 305 { 306 fibril_mutex_lock(&cons->mtx); 307 chargrid_set_cursor_visibility(cons->frontbuf, visible); 308 fibril_mutex_unlock(&cons->mtx); 309 310 cons_update_cursor(cons); 311 } 312 313 static void cons_get_cursor(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 314 { 315 sysarg_t col; 316 sysarg_t row; 317 318 fibril_mutex_lock(&cons->mtx); 319 chargrid_get_cursor(cons->frontbuf, &col, &row); 320 fibril_mutex_unlock(&cons->mtx); 321 322 async_answer_2(iid, EOK, col, row); 323 } 324 325 static void cons_write(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 326 { 327 void *buf; 328 size_t size; 329 int rc = async_data_write_accept(&buf, false, 0, 0, 0, &size); 330 331 if (rc != EOK) { 332 async_answer_0(iid, rc); 333 return; 334 } 335 336 size_t off = 0; 337 while (off < size) 338 cons_write_char(cons, str_decode(buf, &off, size)); 339 340 async_answer_1(iid, EOK, size); 341 free(buf); 342 } 343 344 static void cons_read(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 345 { 346 ipc_callid_t callid; 347 size_t size; 348 if (!async_data_read_receive(&callid, &size)) { 349 async_answer_0(callid, EINVAL); 350 async_answer_0(iid, EINVAL); 351 return; 352 } 353 354 char *buf = (char *) malloc(size); 355 if (buf == NULL) { 356 async_answer_0(callid, ENOMEM); 357 async_answer_0(iid, ENOMEM); 358 return; 359 } 360 330 static int cons_open(con_srvs_t *srvs, con_srv_t *srv) 331 { 332 return EOK; 333 } 334 335 static int cons_close(con_srv_t *srv) 336 { 337 return EOK; 338 } 339 340 static int cons_read(con_srv_t *srv, void *buf, size_t size) 341 { 342 uint8_t *bbuf = buf; 343 console_t *cons = srv_to_console(srv); 361 344 size_t pos = 0; 362 345 … … 369 352 /* Copy to the buffer remaining characters. */ 370 353 while ((pos < size) && (cons->char_remains_len > 0)) { 371 b uf[pos] = cons->char_remains[0];354 bbuf[pos] = cons->char_remains[0]; 372 355 pos++; 373 356 … … 394 377 } 395 378 } 396 397 (void) async_data_read_finalize(callid, buf, size); 398 async_answer_1(iid, EOK, size); 399 free(buf); 400 } 401 402 static void cons_set_style(console_t *cons, console_style_t style) 403 { 379 380 return size; 381 } 382 383 static int cons_write(con_srv_t *srv, void *data, size_t size) 384 { 385 console_t *cons = srv_to_console(srv); 386 387 size_t off = 0; 388 while (off < size) 389 cons_write_char(cons, str_decode(data, &off, size)); 390 return size; 391 } 392 393 static void cons_sync(con_srv_t *srv) 394 { 395 console_t *cons = srv_to_console(srv); 396 397 cons_update(cons); 398 } 399 400 static void cons_clear(con_srv_t *srv) 401 { 402 console_t *cons = srv_to_console(srv); 403 404 fibril_mutex_lock(&cons->mtx); 405 chargrid_clear(cons->frontbuf); 406 fibril_mutex_unlock(&cons->mtx); 407 408 cons_update(cons); 409 } 410 411 static void cons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row) 412 { 413 console_t *cons = srv_to_console(srv); 414 415 fibril_mutex_lock(&cons->mtx); 416 chargrid_set_cursor(cons->frontbuf, col, row); 417 fibril_mutex_unlock(&cons->mtx); 418 419 cons_update_cursor(cons); 420 } 421 422 static int cons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row) 423 { 424 console_t *cons = srv_to_console(srv); 425 426 fibril_mutex_lock(&cons->mtx); 427 chargrid_get_cursor(cons->frontbuf, col, row); 428 fibril_mutex_unlock(&cons->mtx); 429 430 return EOK; 431 } 432 433 static int cons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows) 434 { 435 console_t *cons = srv_to_console(srv); 436 437 fibril_mutex_lock(&cons->mtx); 438 *cols = cons->cols; 439 *rows = cons->rows; 440 fibril_mutex_unlock(&cons->mtx); 441 442 return EOK; 443 } 444 445 static int cons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps) 446 { 447 console_t *cons = srv_to_console(srv); 448 449 fibril_mutex_lock(&cons->mtx); 450 *ccaps = cons->ccaps; 451 fibril_mutex_unlock(&cons->mtx); 452 453 return EOK; 454 } 455 456 static void cons_set_style(con_srv_t *srv, console_style_t style) 457 { 458 console_t *cons = srv_to_console(srv); 459 404 460 fibril_mutex_lock(&cons->mtx); 405 461 chargrid_set_style(cons->frontbuf, style); … … 407 463 } 408 464 409 static void cons_set_color(con sole_t *cons, console_color_t bgcolor,465 static void cons_set_color(con_srv_t *srv, console_color_t bgcolor, 410 466 console_color_t fgcolor, console_color_attr_t attr) 411 467 { 468 console_t *cons = srv_to_console(srv); 469 412 470 fibril_mutex_lock(&cons->mtx); 413 471 chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr); … … 415 473 } 416 474 417 static void cons_set_rgb_color(con sole_t *cons, pixel_t bgcolor,475 static void cons_set_rgb_color(con_srv_t *srv, pixel_t bgcolor, 418 476 pixel_t fgcolor) 419 477 { 478 console_t *cons = srv_to_console(srv); 479 420 480 fibril_mutex_lock(&cons->mtx); 421 481 chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor); … … 423 483 } 424 484 425 static void cons_get_event(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 426 { 485 static void cons_set_cursor_visibility(con_srv_t *srv, bool visible) 486 { 487 console_t *cons = srv_to_console(srv); 488 489 cons_set_cursor_vis(cons, visible); 490 } 491 492 static int cons_get_event(con_srv_t *srv, kbd_event_t *event) 493 { 494 console_t *cons = srv_to_console(srv); 427 495 link_t *link = prodcons_consume(&cons->input_pc); 428 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 429 430 async_answer_4(iid, EOK, event->type, event->key, event->mods, event->c); 431 free(event); 496 kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link); 497 498 *event = *kevent; 499 free(kevent); 500 return EOK; 432 501 } 433 502 … … 452 521 453 522 if (atomic_postinc(&cons->refcnt) == 0) 454 cons_set_cursor_visibility(cons, true); 455 456 /* Accept the connection */ 457 async_answer_0(iid, EOK); 458 459 while (true) { 460 ipc_call_t call; 461 ipc_callid_t callid = async_get_call(&call); 462 463 if (!IPC_GET_IMETHOD(call)) 464 return; 465 466 switch (IPC_GET_IMETHOD(call)) { 467 case VFS_OUT_READ: 468 cons_read(cons, callid, &call); 469 break; 470 case VFS_OUT_WRITE: 471 cons_write(cons, callid, &call); 472 break; 473 case VFS_OUT_SYNC: 474 cons_update(cons); 475 async_answer_0(callid, EOK); 476 break; 477 case CONSOLE_CLEAR: 478 cons_clear(cons); 479 async_answer_0(callid, EOK); 480 break; 481 case CONSOLE_GOTO: 482 cons_set_cursor(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 483 async_answer_0(callid, EOK); 484 break; 485 case CONSOLE_GET_POS: 486 cons_get_cursor(cons, callid, &call); 487 break; 488 case CONSOLE_GET_SIZE: 489 async_answer_2(callid, EOK, cons->cols, cons->rows); 490 break; 491 case CONSOLE_GET_COLOR_CAP: 492 async_answer_1(callid, EOK, cons->ccaps); 493 break; 494 case CONSOLE_SET_STYLE: 495 cons_set_style(cons, IPC_GET_ARG1(call)); 496 async_answer_0(callid, EOK); 497 break; 498 case CONSOLE_SET_COLOR: 499 cons_set_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call), 500 IPC_GET_ARG3(call)); 501 async_answer_0(callid, EOK); 502 break; 503 case CONSOLE_SET_RGB_COLOR: 504 cons_set_rgb_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 505 async_answer_0(callid, EOK); 506 break; 507 case CONSOLE_CURSOR_VISIBILITY: 508 cons_set_cursor_visibility(cons, IPC_GET_ARG1(call)); 509 async_answer_0(callid, EOK); 510 break; 511 case CONSOLE_GET_EVENT: 512 cons_get_event(cons, callid, &call); 513 break; 514 default: 515 async_answer_0(callid, EINVAL); 516 } 517 } 518 } 519 520 static async_sess_t *input_connect(const char *svc) 523 cons_set_cursor_vis(cons, true); 524 525 con_conn(iid, icall, &cons->srvs); 526 } 527 528 529 static int input_connect(const char *svc) 521 530 { 522 531 async_sess_t *sess; … … 524 533 525 534 int rc = loc_service_get_id(svc, &dsid, 0); 526 if (rc == EOK) { 527 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 528 if (sess == NULL) { 529 printf("%s: Unable to connect to input service %s\n", NAME, 530 svc); 531 return NULL; 532 } 533 } else 534 return NULL; 535 536 async_exch_t *exch = async_exchange_begin(sess); 537 rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL); 538 async_exchange_end(exch); 539 535 if (rc != EOK) { 536 printf("%s: Input service %s not found\n", NAME, svc); 537 return rc; 538 } 539 540 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 541 if (sess == NULL) { 542 printf("%s: Unable to connect to input service %s\n", NAME, 543 svc); 544 return EIO; 545 } 546 547 rc = input_open(sess, &input_ev_ops, NULL, &input); 540 548 if (rc != EOK) { 541 549 async_hangup(sess); 542 printf("%s: Unable to c reate callback connection toservice %s (%s)\n",550 printf("%s: Unable to communicate with service %s (%s)\n", 543 551 NAME, svc, str_error(rc)); 544 return NULL;545 } 546 547 return sess;552 return rc; 553 } 554 555 return EOK; 548 556 } 549 557 … … 574 582 static bool console_srv_init(char *input_svc, char *output_svc) 575 583 { 584 int rc; 585 576 586 /* Connect to input service */ 577 input_sess= input_connect(input_svc);578 if ( input_sess == NULL)587 rc = input_connect(input_svc); 588 if (rc != EOK) 579 589 return false; 580 590 … … 586 596 /* Register server */ 587 597 async_set_client_connection(client_connection); 588 intrc = loc_server_register(NAME);598 rc = loc_server_register(NAME); 589 599 if (rc != EOK) { 590 600 printf("%s: Unable to register server (%s)\n", NAME, … … 628 638 } 629 639 640 con_srvs_init(&consoles[i].srvs); 641 consoles[i].srvs.ops = &con_ops; 642 consoles[i].srvs.sarg = &consoles[i]; 643 630 644 char vc[LOC_NAME_MAXLEN + 1]; 631 645 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); -
uspace/srv/hid/remcons/remcons.c
r131d9a4 r70253688 34 34 35 35 #include <async.h> 36 #include <errno.h> 37 #include <io/con_srv.h> 36 38 #include <stdio.h> 37 #include <adt/prodcons.h> 38 #include <ipc/input.h> 39 #include <ipc/console.h> 40 #include <ipc/vfs.h> 41 #include <errno.h> 39 #include <stdlib.h> 42 40 #include <str_error.h> 43 41 #include <loc.h> … … 45 43 #include <io/keycode.h> 46 44 #include <align.h> 47 #include <malloc.h>48 #include <as.h>49 45 #include <fibril_synch.h> 50 46 #include <task.h> … … 75 71 sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t); 76 72 77 78 /** Handling client requests (VFS and console interface). 79 * 80 * @param user Telnet user the requests belong to. 81 */ 82 static void client_connection_message_loop(telnet_user_t *user) 83 { 84 while (true) { 85 ipc_call_t call; 86 ipc_callid_t callid = 0; 87 88 /* 89 * The getterm task might terminate while we are here, 90 * waiting for a call. Also, the socket might be closed 91 * meanwhile. 92 * We want to detect this situation early, so we use a 93 * timeout variant of async_get_call(). 94 */ 95 while (callid == 0) { 96 callid = async_get_call_timeout(&call, 1000); 97 98 if (telnet_user_is_zombie(user)) { 99 if (callid != 0) { 100 async_answer_0(callid, EINTR); 101 } 102 return; 103 } 104 } 105 106 if (!IPC_GET_IMETHOD(call)) { 107 return; 108 } 109 110 switch (IPC_GET_IMETHOD(call)) { 111 case CONSOLE_GET_SIZE: 112 async_answer_2(callid, EOK, 100, 1); 113 break; 114 case CONSOLE_GET_POS: 115 fibril_mutex_lock(&user->guard); 116 async_answer_2(callid, EOK, user->cursor_x, 0); 117 fibril_mutex_unlock(&user->guard); 118 break; 119 case CONSOLE_GET_EVENT: { 120 kbd_event_t event; 121 int rc = telnet_user_get_next_keyboard_event(user, &event); 122 if (rc != EOK) { 123 /* Silently ignore. */ 124 async_answer_0(callid, EOK); 125 break; 126 } 127 async_answer_4(callid, EOK, event.type, event.key, event.mods, event.c); 128 break; 129 } 130 case CONSOLE_GOTO: { 131 int new_x = IPC_GET_ARG1(call); 132 telnet_user_update_cursor_x(user, new_x); 133 async_answer_0(callid, ENOTSUP); 134 break; 135 } 136 case VFS_OUT_READ: 137 async_answer_0(callid, ENOTSUP); 138 break; 139 case VFS_OUT_WRITE: { 140 uint8_t *buf; 141 size_t size; 142 int rc = async_data_write_accept((void **)&buf, false, 0, 0, 0, &size); 143 144 if (rc != EOK) { 145 async_answer_0(callid, rc); 146 break; 147 } 148 149 rc = telnet_user_send_data(user, buf, size); 150 free(buf); 151 152 if (rc != EOK) { 153 async_answer_0(callid, rc); 154 break; 155 } 156 157 async_answer_1(callid, EOK, size); 158 break; 159 } 160 case VFS_OUT_SYNC: 161 async_answer_0(callid, EOK); 162 break; 163 case CONSOLE_CLEAR: 164 async_answer_0(callid, EOK); 165 break; 166 167 case CONSOLE_GET_COLOR_CAP: 168 async_answer_1(callid, EOK, CONSOLE_CAP_NONE); 169 break; 170 case CONSOLE_SET_STYLE: 171 async_answer_0(callid, ENOTSUP); 172 break; 173 case CONSOLE_SET_COLOR: 174 async_answer_0(callid, ENOTSUP); 175 break; 176 case CONSOLE_SET_RGB_COLOR: 177 async_answer_0(callid, ENOTSUP); 178 break; 179 180 case CONSOLE_CURSOR_VISIBILITY: 181 async_answer_0(callid, ENOTSUP); 182 break; 183 184 default: 185 async_answer_0(callid, EINVAL); 186 break; 187 } 188 } 73 static int remcons_open(con_srvs_t *, con_srv_t *); 74 static int remcons_close(con_srv_t *); 75 static int remcons_write(con_srv_t *, void *, size_t); 76 static void remcons_sync(con_srv_t *); 77 static void remcons_clear(con_srv_t *); 78 static void remcons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row); 79 static int remcons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *); 80 static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *); 81 static int remcons_get_color_cap(con_srv_t *, console_caps_t *); 82 static int remcons_get_event(con_srv_t *, kbd_event_t *); 83 84 static con_ops_t con_ops = { 85 .open = remcons_open, 86 .close = remcons_close, 87 .read = NULL, 88 .write = remcons_write, 89 .sync = remcons_sync, 90 .clear = remcons_clear, 91 .set_pos = remcons_set_pos, 92 .get_pos = remcons_get_pos, 93 .get_size = remcons_get_size, 94 .get_color_cap = remcons_get_color_cap, 95 .set_style = NULL, 96 .set_color = NULL, 97 .set_rgb_color = NULL, 98 .set_cursor_visibility = NULL, 99 .get_event = remcons_get_event 100 }; 101 102 static telnet_user_t *srv_to_user(con_srv_t *srv) 103 { 104 return srv->srvs->sarg; 105 } 106 107 static int remcons_open(con_srvs_t *srvs, con_srv_t *srv) 108 { 109 telnet_user_t *user = srv_to_user(srv); 110 111 telnet_user_log(user, "New client connected (%p).", srv); 112 113 /* Force character mode. */ 114 send(user->socket, (void *)telnet_force_character_mode_command, 115 telnet_force_character_mode_command_count, 0); 116 117 return EOK; 118 } 119 120 static int remcons_close(con_srv_t *srv) 121 { 122 telnet_user_t *user = srv_to_user(srv); 123 124 telnet_user_notify_client_disconnected(user); 125 telnet_user_log(user, "Client disconnected (%p).", srv); 126 127 return EOK; 128 } 129 130 static int remcons_write(con_srv_t *srv, void *data, size_t size) 131 { 132 telnet_user_t *user = srv_to_user(srv); 133 int rc; 134 135 rc = telnet_user_send_data(user, data, size); 136 if (rc != EOK) 137 return rc; 138 139 return size; 140 } 141 142 static void remcons_sync(con_srv_t *srv) 143 { 144 (void) srv; 145 } 146 147 static void remcons_clear(con_srv_t *srv) 148 { 149 (void) srv; 150 } 151 152 static void remcons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row) 153 { 154 telnet_user_t *user = srv_to_user(srv); 155 156 telnet_user_update_cursor_x(user, col); 157 } 158 159 static int remcons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row) 160 { 161 telnet_user_t *user = srv_to_user(srv); 162 163 *col = user->cursor_x; 164 *row = 0; 165 166 return EOK; 167 } 168 169 static int remcons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows) 170 { 171 (void) srv; 172 173 *cols = 100; 174 *rows = 1; 175 176 return EOK; 177 } 178 179 static int remcons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps) 180 { 181 (void) srv; 182 *ccaps = CONSOLE_CAP_NONE; 183 184 return EOK; 185 } 186 187 static int remcons_get_event(con_srv_t *srv, kbd_event_t *event) 188 { 189 telnet_user_t *user = srv_to_user(srv); 190 int rc; 191 192 rc = telnet_user_get_next_keyboard_event(user, event); 193 if (rc != EOK) { 194 /* XXX What? */ 195 memset(event, 0, sizeof(*event)); 196 return EOK; 197 } 198 199 return EOK; 189 200 } 190 201 … … 198 209 return; 199 210 } 200 async_answer_0(iid, EOK);201 202 telnet_user_log(user, "New client connected (%" PRIxn").", iid);203 204 /* Force character mode. */205 send(user->socket, (void *)telnet_force_character_mode_command,206 telnet_force_character_mode_command_count, 0);207 211 208 212 /* Handle messages. */ 209 client_connection_message_loop(user); 210 211 telnet_user_notify_client_disconnected(user); 212 telnet_user_log(user, "Client disconnected (%" PRIxn").", iid); 213 con_conn(iid, icall, &user->srvs); 213 214 } 214 215 … … 232 233 fibril_mutex_lock(&user->guard); 233 234 user->task_finished = true; 235 user->srvs.aborted = true; 234 236 fibril_condvar_signal(&user->refcount_cv); 235 237 fibril_mutex_unlock(&user->guard); … … 251 253 fibril_mutex_lock(&user->guard); 252 254 user->task_finished = true; 255 user->srvs.aborted = true; 253 256 fibril_condvar_signal(&user->refcount_cv); 254 257 fibril_mutex_unlock(&user->guard); … … 295 298 closesocket(user->socket); 296 299 user->socket_closed = true; 300 user->srvs.aborted = true; 297 301 continue; 298 302 } else if (user->socket_closed) { … … 380 384 assert(user); 381 385 386 con_srvs_init(&user->srvs); 387 user->srvs.ops = &con_ops; 388 user->srvs.sarg = user; 389 user->srvs.abort_timeout = 1000; 390 391 telnet_user_add(user); 392 382 393 fid_t fid = fibril_create(network_user_fibril, user); 383 394 assert(fid); -
uspace/srv/hid/remcons/user.c
r131d9a4 r70253688 35 35 #include <stdio.h> 36 36 #include <adt/prodcons.h> 37 #include <ipc/input.h>38 #include <ipc/console.h>39 #include <ipc/vfs.h>40 37 #include <errno.h> 41 38 #include <str_error.h> … … 95 92 user->locsrv_connection_count = 0; 96 93 97 94 user->cursor_x = 0; 95 96 return user; 97 } 98 99 void telnet_user_add(telnet_user_t *user) 100 { 98 101 fibril_mutex_lock(&users_guard); 99 102 list_append(&user->link, &users); 100 103 fibril_mutex_unlock(&users_guard); 101 102 user->cursor_x = 0;103 104 return user;105 104 } 106 105 … … 199 198 if ((recv_length == 0) || (recv_length == ENOTCONN)) { 200 199 user->socket_closed = true; 200 user->srvs.aborted = true; 201 201 return ENOENT; 202 202 } -
uspace/srv/hid/remcons/user.h
r131d9a4 r70253688 36 36 #define TELNET_USER_H_ 37 37 38 #include <adt/prodcons.h> 38 39 #include <fibril_synch.h> 39 40 #include <inttypes.h> 41 #include <io/con_srv.h> 40 42 #include "remcons.h" 41 43 … … 55 57 /** Path name of the service. */ 56 58 char *service_name; 59 /** Console service setup */ 60 con_srvs_t srvs; 57 61 58 62 /** Producer-consumer of kbd_event_t. */ … … 77 81 78 82 extern telnet_user_t *telnet_user_create(int); 83 extern void telnet_user_add(telnet_user_t *); 79 84 extern void telnet_user_destroy(telnet_user_t *); 80 85 extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t); -
uspace/srv/net/ethip/pdu.c
r131d9a4 r70253688 69 69 frame->size); 70 70 71 log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoding Ethernet frame src=%llx dest=%llx etype=%x", 72 frame->src, frame->dest, frame->etype_len); 71 log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoding Ethernet frame " 72 "src=%" PRIx64 " dest=%" PRIx64 " etype=%x", 73 frame->src.addr, frame->dest.addr, frame->etype_len); 73 74 log_msg(LOG_DEFAULT, LVL_DEBUG, "Encoded Ethernet frame (%zu bytes)", size); 74 75 … … 104 105 frame->size); 105 106 106 log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoding Ethernet frame src=%llx dest=%llx etype=%x", 107 frame->src, frame->dest, frame->etype_len); 107 log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoding Ethernet frame " 108 "src=%" PRIx64 " dest=%" PRIx64 " etype=%x", 109 frame->src.addr, frame->dest.addr, frame->etype_len); 108 110 log_msg(LOG_DEFAULT, LVL_DEBUG, "Decoded Ethernet frame payload (%zu bytes)", frame->size); 109 111 -
uspace/srv/net/tcp/conn.c
r131d9a4 r70253688 999 999 } else { 1000 1000 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: Nothing left in segment, dropping " 1001 "(xfer_size=%zu, SEG.LEN=% zu, seg->ctrl=%u)",1002 conn->name, xfer_size, seg->len, (unsigned )seg->ctrl);1001 "(xfer_size=%zu, SEG.LEN=%" PRIu32 ", seg->ctrl=%u)", 1002 conn->name, xfer_size, seg->len, (unsigned int) seg->ctrl); 1003 1003 /* Nothing left in segment */ 1004 1004 tcp_segment_delete(seg); … … 1146 1146 void tcp_conn_segment_arrived(tcp_conn_t *conn, tcp_segment_t *seg) 1147 1147 { 1148 log_msg(LOG_DEFAULT, LVL_DEBUG, "% c: tcp_conn_segment_arrived(%p)",1148 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_segment_arrived(%p)", 1149 1149 conn->name, seg); 1150 1150 -
uspace/srv/net/tcp/segment.c
r131d9a4 r70253688 250 250 log_msg(LOG_DEFAULT, LVL_DEBUG2, "Segment dump:"); 251 251 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - ctrl = %u", (unsigned)seg->ctrl); 252 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - seq = % " PRIu32, seg->seq);253 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - ack = % " PRIu32, seg->ack);254 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - len = % " PRIu32, seg->len);255 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - wnd = % " PRIu32, seg->wnd);256 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - up = % " PRIu32, seg->up);252 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - seq = %" PRIu32, seg->seq); 253 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - ack = %" PRIu32, seg->ack); 254 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - len = %" PRIu32, seg->len); 255 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - wnd = %" PRIu32, seg->wnd); 256 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - up = %" PRIu32, seg->up); 257 257 } 258 258 -
uspace/srv/net/tcp/sock.c
r131d9a4 r70253688 114 114 *rsock = NULL; 115 115 116 sock = calloc( sizeof(tcp_sockdata_t), 1);116 sock = calloc(1, sizeof(tcp_sockdata_t)); 117 117 if (sock == NULL) 118 118 return ENOMEM; … … 277 277 278 278 socket->backlog = backlog; 279 socket->lconn = calloc( sizeof(tcp_conn_t *), backlog);279 socket->lconn = calloc(backlog, sizeof(tcp_conn_t *)); 280 280 if (socket->lconn == NULL) { 281 281 fibril_mutex_unlock(&socket->lock); … … 293 293 for (i = 0; i < backlog; i++) { 294 294 295 lconn = calloc( sizeof(tcp_sock_lconn_t), 1);295 lconn = calloc(1, sizeof(tcp_sock_lconn_t)); 296 296 if (lconn == NULL) { 297 297 /* XXX Clean up */ -
uspace/srv/net/tcp/tqueue.c
r131d9a4 r70253688 172 172 173 173 xfer_seqlen = min(snd_buf_seqlen, avail_wnd); 174 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: snd_buf_seqlen = %zu, SND.WND = % zu, "174 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: snd_buf_seqlen = %zu, SND.WND = %" PRIu32 ", " 175 175 "xfer_seqlen = %zu", conn->name, snd_buf_seqlen, conn->snd_wnd, 176 176 xfer_seqlen); -
uspace/srv/net/udp/sock.c
r131d9a4 r70253688 104 104 105 105 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_socket()"); 106 sock = calloc( sizeof(udp_sockdata_t), 1);106 sock = calloc(1, sizeof(udp_sockdata_t)); 107 107 if (sock == NULL) { 108 108 async_answer_0(callid, ENOMEM);
Note:
See TracChangeset
for help on using the changeset viewer.
