Advertisement
rayddteam

Untitled

Jun 1st, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.75 KB | None | 0 0
  1. Index: sys/dev/vt/vt.h
  2. ===================================================================
  3. --- sys/dev/vt/vt.h (revision 266903)
  4. +++ sys/dev/vt/vt.h (working copy)
  5. @@ -259,6 +259,7 @@
  6. #define VWF_CONSOLE 0x8 /* Kernel message console window. */
  7. #define VWF_VTYLOCK 0x10 /* Prevent window switch. */
  8. #define VWF_MOUSE_HIDE 0x20 /* Disable mouse events processing. */
  9. +#define VWF_READY 0x40 /* Window fully initialized. */
  10. #define VWF_SWWAIT_REL 0x10000 /* Program wait for VT acquire is done. */
  11. #define VWF_SWWAIT_ACQ 0x20000 /* Program wait for VT release is done. */
  12. pid_t vw_pid; /* Terminal holding process */
  13. Index: sys/dev/vt/vt_core.c
  14. ===================================================================
  15. --- sys/dev/vt/vt_core.c (revision 266903)
  16. +++ sys/dev/vt/vt_core.c (working copy)
  17. @@ -120,9 +120,10 @@
  18. VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode");
  19. VT_SYSCTL_INT(suspendswitch, 1, "Switch to VT0 before suspend");
  20.  
  21. +static struct vt_device vt_consdev;
  22. static unsigned int vt_unit = 0;
  23. static MALLOC_DEFINE(M_VT, "vt", "vt device");
  24. -struct vt_device *main_vd = NULL;
  25. +struct vt_device *main_vd = &vt_consdev;
  26.  
  27. /* Boot logo. */
  28. extern unsigned int vt_logo_width;
  29. @@ -214,12 +215,16 @@
  30. vt_update_static(void *dummy)
  31. {
  32.  
  33. - if (main_vd != NULL) {
  34. - printf("VT: running with driver \"%s\".\n",
  35. - main_vd->vd_driver->vd_name);
  36. +// if (main_vd != NULL) {
  37. + if (main_vd->vd_driver != NULL)
  38. + printf("VT: running with driver \"%s\".\n",
  39. + main_vd->vd_driver->vd_name);
  40. + else
  41. + printf("VT: init without driver.\n");
  42. +
  43. mtx_init(&main_vd->vd_lock, "vtdev", NULL, MTX_DEF);
  44. cv_init(&main_vd->vd_winswitch, "vtwswt");
  45. - }
  46. +// }
  47. }
  48.  
  49. static void
  50. @@ -633,11 +638,9 @@
  51. keyboard_t *k0, *k;
  52. keyboard_info_t ki;
  53.  
  54. - idx0 = kbd_allocate("kbdmux", -1, (void *)&vd->vd_keyboard,
  55. - vt_kbdevent, vd);
  56. - /* XXX: kb_token lost */
  57. + idx0 = kbd_allocate("kbdmux", -1, vd, vt_kbdevent, vd);
  58. vd->vd_keyboard = idx0;
  59. - if (idx0 != -1) {
  60. + if (idx0 >= 0) {
  61. DPRINTF(20, "%s: kbdmux allocated, idx = %d\n", __func__, idx0);
  62. k0 = kbd_get_keyboard(idx0);
  63.  
  64. @@ -657,8 +660,11 @@
  65. }
  66. } else {
  67. DPRINTF(20, "%s: no kbdmux allocated\n", __func__);
  68. - idx0 = kbd_allocate("*", -1, (void *)&vd->vd_keyboard,
  69. - vt_kbdevent, vd);
  70. + idx0 = kbd_allocate("*", -1, vd, vt_kbdevent, vd);
  71. + if (idx0 < 0) {
  72. + DPRINTF(10, "%s: No keyboard found.\n", __func__);
  73. + return (-1);
  74. + }
  75. }
  76. DPRINTF(20, "%s: vd_keyboard = %d\n", __func__, vd->vd_keyboard);
  77.  
  78. @@ -970,15 +976,17 @@
  79. if (vtdbest == NULL) {
  80. cp->cn_pri = CN_DEAD;
  81. vd->vd_flags |= VDF_DEAD;
  82. - return;
  83. +// return;
  84. }
  85.  
  86. - vd->vd_driver = vtdbest;
  87. + if (vtdbest != NULL) {
  88. + vd->vd_driver = vtdbest;
  89. + cp->cn_pri = vd->vd_driver->vd_init(vd);
  90. + }
  91.  
  92. - cp->cn_pri = vd->vd_driver->vd_init(vd);
  93. if (cp->cn_pri == CN_DEAD) {
  94. vd->vd_flags |= VDF_DEAD;
  95. - return;
  96. +// return;
  97. }
  98.  
  99. /* Initialize any early-boot keyboard drivers */
  100. @@ -995,12 +1003,14 @@
  101. vt_winsize(vd, vw->vw_font, &wsz);
  102. terminal_set_winsize(tm, &wsz);
  103.  
  104. + if (vtdbest != NULL) {
  105. #ifdef DEV_SPLASH
  106. - vtterm_splash(vd);
  107. + vtterm_splash(vd);
  108. #endif
  109.  
  110. - vd->vd_flags |= VDF_INITIALIZED;
  111. - main_vd = vd;
  112. + vd->vd_flags |= VDF_INITIALIZED;
  113. + }
  114. +// main_vd = vd;
  115. }
  116.  
  117. static int
  118. @@ -1988,28 +1998,27 @@
  119. unsigned int i;
  120.  
  121. /* Device didn't pass vd_init() or already upgraded. */
  122. - if (vd->vd_flags & (VDF_ASYNC|VDF_DEAD)) {
  123. - /* Refill settings with new sizes anyway. */
  124. - vt_resize(vd);
  125. - return;
  126. - }
  127. - vd->vd_flags |= VDF_ASYNC;
  128. -
  129. +// if (vd->vd_flags & (VDF_ASYNC|VDF_DEAD)) {
  130. +// /* Refill settings with new sizes anyway. */
  131. +// vt_resize(vd);
  132. +// return;
  133. +// }
  134. for (i = 0; i < VT_MAXWINDOWS; i++) {
  135. vw = vd->vd_windows[i];
  136. if (vw == NULL) {
  137. /* New window. */
  138. vw = vt_allocate_window(vd, i);
  139. - } else if (vw->vw_flags & VWF_CONSOLE) {
  140. - /* For existing console window. */
  141. + }
  142. + if (!(vw->vw_flags & VWF_READY)) {
  143. callout_init(&vw->vw_proc_dead_timer, 0);
  144. + terminal_maketty(vw->vw_terminal, "v%r", VT_UNIT(vw));
  145. + vw->vw_flags |= VWF_READY;
  146. + if (vw->vw_flags & VWF_CONSOLE) {
  147. + /* For existing console window. */
  148. + EVENTHANDLER_REGISTER(shutdown_pre_sync,
  149. + vt_window_switch, vw, SHUTDOWN_PRI_DEFAULT);
  150. + }
  151. }
  152. - if (i == VT_CONSWINDOW) {
  153. - /* Console window. */
  154. - EVENTHANDLER_REGISTER(shutdown_pre_sync,
  155. - vt_window_switch, vw, SHUTDOWN_PRI_DEFAULT);
  156. - }
  157. - terminal_maketty(vw->vw_terminal, "v%r", VT_UNIT(vw));
  158.  
  159. }
  160. VT_LOCK(vd);
  161. @@ -2016,15 +2025,19 @@
  162. if (vd->vd_curwindow == NULL)
  163. vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW];
  164.  
  165. + if (!(vd->vd_flags & VDF_ASYNC)) {
  166. /* Attach keyboard. */
  167. vt_allocate_keyboard(vd);
  168. DPRINTF(20, "%s: vd_keyboard = %d\n", __func__, vd->vd_keyboard);
  169.  
  170. - /* Init 25 Hz timer. */
  171. - callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0);
  172. + /* Init 25 Hz timer. */
  173. + callout_init_mtx(&vd->vd_timer, &vd->vd_lock, 0);
  174.  
  175. - /* Start timer when everything ready. */
  176. - callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd);
  177. + /* Start timer when everything ready. */
  178. + vd->vd_flags |= VDF_ASYNC;
  179. + callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd);
  180. + }
  181. +
  182. VT_UNLOCK(vd);
  183.  
  184. /* Refill settings with new sizes. */
  185. @@ -2055,18 +2068,24 @@
  186. struct vt_device *vd;
  187. struct winsize wsz;
  188.  
  189. - if (main_vd == NULL) {
  190. - main_vd = malloc(sizeof *vd, M_VT, M_WAITOK|M_ZERO);
  191. - printf("VT: initialize with new VT driver \"%s\".\n",
  192. - drv->vd_name);
  193. - mtx_init(&main_vd->vd_lock, "vtdev", NULL, MTX_DEF);
  194. - cv_init(&main_vd->vd_winswitch, "vtwswt");
  195. -
  196. - } else {
  197. +// if (main_vd == NULL) {
  198. +// main_vd = malloc(sizeof *vd, M_VT, M_WAITOK|M_ZERO);
  199. +// printf("VT: initialize with new VT driver \"%s\".\n",
  200. +// drv->vd_name);
  201. +// mtx_init(&main_vd->vd_lock, "vtdev", NULL, MTX_DEF);
  202. +// cv_init(&main_vd->vd_winswitch, "vtwswt");
  203. +//
  204. +// } else {
  205. /*
  206. * Check if have rights to replace current driver. For example:
  207. * it is bad idea to replace KMS driver with generic VGA one.
  208. */
  209. + if (main_vd->vd_driver == NULL) {
  210. + main_vd->vd_driver = drv;
  211. + printf("VT: initialize with new VT driver \"%s\".\n",
  212. + drv->vd_name);
  213. + } else {
  214. +
  215. if (drv->vd_priority <= main_vd->vd_driver->vd_priority) {
  216. printf("VT: Driver priority %d too low. Current %d\n ",
  217. drv->vd_priority, main_vd->vd_driver->vd_priority);
  218. @@ -2075,6 +2094,8 @@
  219. printf("VT: Replacing driver \"%s\" with new \"%s\".\n",
  220. main_vd->vd_driver->vd_name, drv->vd_name);
  221. }
  222. +
  223. +// }
  224. vd = main_vd;
  225. VT_LOCK(vd);
  226. if (drv->vd_maskbitbltchr == NULL)
  227. @@ -2117,7 +2138,8 @@
  228.  
  229. /* Update console window sizes to actual. */
  230. vt_winsize(vd, vd->vd_windows[VT_CONSWINDOW]->vw_font, &wsz);
  231. - terminal_set_winsize(vd->vd_windows[VT_CONSWINDOW]->vw_terminal, &wsz);
  232. + terminal_set_winsize_blank(vd->vd_windows[VT_CONSWINDOW]->vw_terminal,
  233. + &wsz, 0);
  234. }
  235.  
  236. void
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement