Lines Matching +full:console +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0
3 * Provide access to virtual console memory.
13 * /dev/vcsuN: similar to /dev/vcsaN but using 4-byte unicode values
14 * instead of 1-byte screen glyph values.
22 * [email protected] - efter Friedas begravelse - 950211
24 * [email protected] - modified not to send characters to wrong console
25 * - fixed some fatal off-by-one bugs (0-- no longer == -1 -> looping and looping and looping...)
26 * - making it shorter - scr_readw are macros which expand in PRETTY long code
40 #include <linux/console.h>
65 * with minors 0, 64, 128 and 192 being proxies for the foreground console.
71 #define console(inode) (iminor(inode) & 63) macro
88 struct vc_data *vc = param->vc; in vcs_notifier()
91 int currcons = poll->cons_num; in vcs_notifier()
108 currcons--; in vcs_notifier()
109 if (currcons != vc->vc_num) in vcs_notifier()
112 poll->event = code; in vcs_notifier()
113 wake_up_interruptible(&poll->waitq); in vcs_notifier()
114 kill_fasync(&poll->fasync, SIGIO, fa_band); in vcs_notifier()
121 unregister_vt_notifier(&poll->notifier); in vcs_poll_data_free()
128 struct vcs_poll_data *poll = file->private_data, *kill = NULL; in vcs_poll_data_get()
136 poll->cons_num = console(file_inode(file)); in vcs_poll_data_get()
137 init_waitqueue_head(&poll->waitq); in vcs_poll_data_get()
138 poll->notifier.notifier_call = vcs_notifier; in vcs_poll_data_get()
146 poll->event = VT_UPDATE; in vcs_poll_data_get()
148 if (register_vt_notifier(&poll->notifier) != 0) { in vcs_poll_data_get()
154 * This code may be called either through ->poll() or ->fasync(). in vcs_poll_data_get()
161 spin_lock(&file->f_lock); in vcs_poll_data_get()
162 if (!file->private_data) { in vcs_poll_data_get()
163 file->private_data = poll; in vcs_poll_data_get()
167 poll = file->private_data; in vcs_poll_data_get()
169 spin_unlock(&file->f_lock); in vcs_poll_data_get()
177 * vcs_vc - return VC for @inode
179 * @viewed: returns whether this console is currently foreground (viewed)
185 unsigned int currcons = console(inode); in vcs_vc()
194 currcons--; in vcs_vc()
202 * vcs_size - return size for a VC in @vc
211 int size; in vcs_size() local
215 size = vc->vc_rows * vc->vc_cols; in vcs_size()
219 return -EOPNOTSUPP; in vcs_size()
221 size = 2 * size + HEADER_SIZE; in vcs_size()
223 size *= 4; in vcs_size()
225 return size; in vcs_size()
232 int size; in vcs_lseek() local
238 return -ENXIO; in vcs_lseek()
241 size = vcs_size(vc, use_attributes(inode), use_unicode(inode)); in vcs_lseek()
243 if (size < 0) in vcs_lseek()
244 return size; in vcs_lseek()
245 return fixed_size_llseek(file, offset, orig, size); in vcs_lseek()
251 unsigned int nr, row, col, maxcol = vc->vc_cols; in vcs_read_buf_uni()
261 nr = maxcol - col; in vcs_read_buf_uni()
267 count -= nr * 4; in vcs_read_buf_uni()
280 unsigned int col, maxcol = vc->vc_cols; in vcs_read_buf_noattr()
284 pos += maxcol - col; in vcs_read_buf_noattr()
286 while (count-- > 0) { in vcs_read_buf_noattr()
301 unsigned int col, maxcol = vc->vc_cols; in vcs_read_buf()
306 con_buf[0] = min(vc->vc_rows, 0xFFu); in vcs_read_buf()
307 con_buf[1] = min(vc->vc_cols, 0xFFu); in vcs_read_buf()
314 filled = count - pos; in vcs_read_buf()
318 count -= min(HEADER_SIZE, count); in vcs_read_buf()
331 filled--; in vcs_read_buf()
337 pos -= HEADER_SIZE; in vcs_read_buf()
342 pos += maxcol - col; in vcs_read_buf()
353 count--; in vcs_read_buf()
378 return -ENOMEM; in vcs_read()
382 /* Select the proper current console and verify in vcs_read()
383 * sanity of the situation under the console lock. in vcs_read()
390 ret = -EINVAL; in vcs_read()
393 /* we enforce 32-bit alignment for pos and count in unicode mode */ in vcs_read()
397 poll = file->private_data; in vcs_read()
399 poll->event = 0; in vcs_read()
404 int size; in vcs_read() local
408 ret = -ENXIO; in vcs_read()
412 /* Check whether we are above size each round, in vcs_read()
416 size = vcs_size(vc, attr, uni_mode); in vcs_read()
417 if (size < 0) { in vcs_read()
418 ret = size; in vcs_read()
421 if (pos >= size) in vcs_read()
423 if (count > size - pos) in vcs_read()
424 count = size - pos; in vcs_read()
431 * Then we can drop the console spinlock and safely in vcs_read()
448 /* Finally, release the console semaphore while we push in vcs_read()
460 read += this_round - ret; in vcs_read()
461 ret = -EFAULT; in vcs_read()
467 count -= this_round; in vcs_read()
482 unsigned int col, maxcol = vc->vc_cols; in vcs_write_buf_noattr()
486 pos += maxcol - col; in vcs_write_buf_noattr()
491 count--; in vcs_write_buf_noattr()
522 unsigned int col, maxcol = vc->vc_cols; in vcs_write_buf()
531 count--; in vcs_write_buf()
541 pos -= HEADER_SIZE; in vcs_write_buf()
546 /* odd pos -- the first single character */ in vcs_write_buf()
548 count--; in vcs_write_buf()
561 pos += maxcol - col; in vcs_write_buf()
563 /* even pos -- handle attr+character pairs */ in vcs_write_buf()
570 count -= 2; in vcs_write_buf()
581 /* odd pos -- the remaining character */ in vcs_write_buf()
597 int size; in vcs_write() local
603 return -EOPNOTSUPP; in vcs_write()
607 return -ENOMEM; in vcs_write()
611 /* Select the proper current console and verify in vcs_write()
612 * sanity of the situation under the console lock. in vcs_write()
617 ret = -ENXIO; in vcs_write()
622 size = vcs_size(vc, attr, false); in vcs_write()
623 if (size < 0) { in vcs_write()
624 ret = size; in vcs_write()
627 ret = -EINVAL; in vcs_write()
628 if (pos < 0 || pos > size) in vcs_write()
630 if (count > size - pos) in vcs_write()
631 count = size - pos; in vcs_write()
639 /* Temporarily drop the console lock so that we can read in vcs_write()
647 this_round -= ret; in vcs_write()
650 * fail with -EFAULT. in vcs_write()
654 ret = -EFAULT; in vcs_write()
667 ret = -ENXIO; in vcs_write()
670 size = vcs_size(vc, attr, false); in vcs_write()
671 if (size < 0) { in vcs_write()
674 ret = size; in vcs_write()
677 if (pos >= size) in vcs_write()
679 if (this_round > size - pos) in vcs_write()
680 this_round = size - pos; in vcs_write()
682 /* OK, now actually push the write to the console in vcs_write()
693 count -= this_round; in vcs_write()
698 update_region(vc, (unsigned long)(org0), org - org0); in vcs_write()
718 poll_wait(file, &poll->waitq, wait); in vcs_poll()
719 switch (poll->event) { in vcs_poll()
737 struct vcs_poll_data *poll = file->private_data; in vcs_fasync()
745 return -ENOMEM; in vcs_fasync()
748 return fasync_helper(fd, file, on, &poll->fasync); in vcs_fasync()
754 unsigned int currcons = console(inode); in vcs_open()
761 return -EOPNOTSUPP; in vcs_open()
764 if(currcons && !vc_cons_allocated(currcons-1)) in vcs_open()
765 ret = -ENXIO; in vcs_open()
772 struct vcs_poll_data *poll = file->private_data; in vcs_release()