summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons/syscons.c
Commit message (Collapse)AuthorAgeFilesLines
* Convert files to UTF-8uqs2012-01-151-1/+1
|
* sc_cngrab: switch to console vty when possibleavg2011-12-211-0/+7
| | | | | | | | | | | In the future we may want to perform the switch even if the console is currently in the graphics mode by trying to reset the video adapter first (e.g. by executing vesa/vga bios post). That would probably require some sort of a one-way flag as returning the control of the console back to the interrupted application most likely would result in a mess. Reviewed by: emaste MFC after: 2 months
* syscons: provide a first iteration of cngrab/cnungrab implementationavg2011-12-171-19/+35
| | | | | | | | | | - put underlying keyboard(s) into the polling mode for the whole duration of the grab, instead of the previous behavior of going into and out of the polling mode around each polling attempt - ditto for setting K_XLATE mode and enabling a disabled keyboard Inspired by: bde MFC after: 2 months
* kern cons: introduce infrastructure for console grabbing by kernelavg2011-12-171-0/+12
| | | | | | | | | | | | At the moment grab and ungrab methods of all console drivers are no-ops. Current intended meaning of the calls is that the kernel takes control of console input. In the future the semantics may be extended to mean that the calling thread takes full ownership of the console (e.g. console output from other threads could be suspended). Inspired by: bde MFC after: 2 months
* syscons: make sc_puts static as it is used only privatelyavg2011-12-111-1/+2
| | | | | | | Perhaps sc_puts should also be renamed to scputs to follow the implied naming conventions in the file... MFC after: 2 weeks
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.ed2011-11-071-2/+2
| | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static.
* In order to maximize the re-usability of kernel code in user space thiskmacy2011-09-161-2/+2
| | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz)
* Add support for alternative break-to-debugger to syscons(4). While mostrwatson2011-08-271-0/+4
| | | | | | | | | | keyboards allow console break sequences (such as ctrl-alt-esc) to be entered, alternative break can prove useful under virtualisation and remote console systems where entering control sequences can be difficult or unreliable. MFC after: 3 weeks Approved by: re (bz)
* Attempt to make break-to-debugger and alternative break-to-debugger morerwatson2011-08-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | accessible: (1) Always compile in support for breaking into the debugger if options KDB is present in the kernel. (2) Disable both by default, but allow them to be enabled via tunables and sysctls debug.kdb.break_to_debugger and debug.kdb.alt_break_to_debugger. (3) options BREAK_TO_DEBUGGER and options ALT_BREAK_TO_DEBUGGER continue to behave as before -- only now instead of compiling in break-to-debugger support, they change the default values of the above sysctls to enable those features by default. Current kernel configurations should, therefore, continue to behave as expected. (4) Migrate alternative break-to-debugger state machine logic out of individual device drivers into centralised KDB code. This has a number of upsides, but also one downside: it's now tricky to release sio spin locks when entering the debugger, so we don't. However, similar logic does not exist in other device drivers, including uart. (5) dcons requires some special handling; unlike other console types, it allows overriding KDB's own debugger selection, so we need a new interface to KDB to allow that to work. GENERIC kernels in -CURRENT will now support break-to-debugger as long as appropriate boot/run-time options are set, which should improve the debuggability of BETA kernels significantly. MFC after: 3 weeks Reviewed by: kib, nwhitehorn Approved by: re (bz)
* Restore binary compatibility for GIO_KEYMAP and PIO_KEYMAP.ed2011-07-171-0/+2
| | | | | | | | | Back in 2009 I changed the ABI of the GIO_KEYMAP and PIO_KEYMAP ioctls to support wide characters. I created a patch to add ABI compatibility for the old calls, but I didn't get any feedback to that. It seems now people are upgrading from 8 to 9 they experience this issue, so add it anyway.
* Move VT switching hack for suspend/resume from bus drivers to syscons.cjkim2011-05-091-16/+82
| | | | | | using event handlers. A different version was Submitted by: Taku YAMAMOTO (taku at tackymt dot homeip dot net)
* Rename a variable to match scvidctl.c.jkim2010-11-301-11/+11
|
* Stop hardcoding default font size.jkim2010-11-301-1/+1
|
* Clean up code a bit to make it more readable.jkim2010-11-291-18/+9
|
* Honor font size for the video mode when default fonts are compiled in kerneljkim2010-11-291-9/+35
| | | | and VESA mode is enabled from loader.
* Explicitly tell the compiler that we don't care about the return valuerpaulo2010-10-131-11/+11
| | | | of kbdd_ioctl().
* Suspend screen updates when the video controller is powered down.jkim2010-05-221-2/+2
|
* Refine r204265. We want the standard VGA palette for packed pixel mode.jkim2010-03-291-2/+2
|
* Improve VESA mode switching via loader tunable `hint.sc.0.vesa_mode'.jkim2010-02-241-36/+79
| | | | The most notable change is history buffer is fully saved/restored now.
* Yet another attempt to make palette loading more safer:jkim2010-02-231-4/+16
| | | | | | | | | - Add a separate palette data for 8-bit DAC mode when SC_PIXEL_MODE is set and fill it up with default gray-scale palette data for text. Now we don't have to set `hint.sc.0.vesa_mode' to get the default palette data. - Add a new adapter flag, V_ADP_DAC8 to track whether the controller is using 8-bit palette format and load correct palette when switching modes. - Set 8-bit DAC mode only for non-VGA compatible graphics mode.
* Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.rnoland2009-12-291-2/+3
| | | | | | | | | | | | | This replaces d_mmap() with the d_mmap2() implementation and also changes the type of offset to vm_ooffset_t. Purge d_mmap2(). All driver modules will need to be rebuilt since D_VERSION is also bumped. Reviewed by: jhb@ MFC after: Not in this lifetime...
* Allow Syscons terminal emulators to provide function key strings.ed2009-11-111-5/+15
| | | | | | | | | xterm and cons25 have some incompatibilities when it comes to escape sequences for special keys, such as F1 to F12, home, end, etc. Add a new te_fkeystr() that can be used to override the strings. scterm-sck won't do anything with this, but scterm-teken will use teken_get_sequences() to obtain the proper sequence.
* Fix VESA color palette corruption:jkim2009-11-031-0/+3
| | | | | | | | | | | | - VBE 3.0 says palette format resets to 6-bit mode when video mode changes. We simply set 8-bit mode when we switch modes if the adapter supports it. - VBE 3.0 also says if the mode is not VGA compatible, we must use VBE function to save/restore palette. Otherwise, VGA function may be used. Thus, reinstate the save/load palette functions only for non-VGA compatible modes regardless of its palette format. - Let vesa(4) set VESA modes even if vga(4) claims to support it. - Reset default palette if VESA pixel mode is set initially. - Fix more style nits.
* Search for default 800x600 graphics mode from supported VESA mode list.jkim2009-10-231-18/+46
| | | | Many video controllers do not support 800x600x24 mode any more.
* Add support for VT200-style mouse input.ed2009-09-271-7/+6
| | | | | | | | | | | | | | | | | | | Right now if applications want to use the mouse on the command line, they use sysmouse(4) and install a signal handler in the kernel to deliver signals when mouse events arrive. This conflicts with my plan to change to TERM=xterm, so implement proper VT200-style mouse input. Because mouse input is now streamed through the TTY, it means you can now SSH to another system on the console and use the mouse there as well. The disadvantage of the VT200 mouse protocol, is that it doesn't seem to generate events when moving the cursor. Only when pressing and releasing mouse buttons. There are different protocols as well, but this one seems to be most commonly supported. Reported by: Paul B. Mahol <onemda gmail com> Tested with: vim(1)
* Just use ttydisc_rint_simple() instead of doing it ourselves.ed2009-09-181-8/+2
| | | | | | | This code seems to do exactly the same as ttydisc_rint_simple() does nowadays. Just remove it. Obtained from: //depot/user/ed/newcons/sys/dev/syscons/syscons.c
* Make use of the more flexable device hints by adding a new field,delphij2009-09-121-2/+3
| | | | vesa_mode to specify VESA mode, as suggested by jhb@.
* Extend the usage of sc(4)'s hint variable 'flag'. Bit 0x80 now meansdelphij2009-09-111-7/+14
| | | | | | | | | | "set vesa mode" and higher 16bits of the flag would be the desired mode. One can now set, for instance, hint.sc.0.flags=0x01680180, which means that the system should set VESA mode 0x168 upon boot. Submitted by: paradox <ddkprog yahoo com>, swell k at gmail.com with some minor changes.
* Last minute TTY API change: remove mutex argument from tty_alloc().ed2009-05-291-1/+1
| | | | | | | | | | I don't want people to override the mutex when allocating a TTY. It has to be there, to keep drivers like syscons happy. So I'm creating a tty_alloc_mutex() which can be used in those cases. tty_alloc_mutex() should eventually be removed. The advantage of this approach, is that we can just remove a function, without breaking the regular API in the future.
* Turn consolectl into a simple device node, not a TTY.ed2009-05-151-20/+26
| | | | | | | | | | | Apart from the 16 virtual terminals, Syscons allocates two device nodes that should not really be TTYs, even though they are. One of them is consolectl. In RELENG_7 and before, these device nodes are used in single user mode. After I simplified input path, we only use this device node to call ioctl() on (moused, Xorg, vidcontrol). When you call ioctl() on consolectl, it will behave the same as being called on the first window.
* Remove obsolete/bogus layering.emax2009-04-091-8/+1
| | | | | Reviewed by: freebsd-current@, freebsd-hackers@ MFC after: 1 week
* Make a 1:1 mapping between syscons stats and terminal emulators.ed2009-03-101-32/+7
| | | | | | | | | | | | | | | | | | | | After I imported libteken into the source tree, I noticed syscons didn't store the cursor position inside the terminal emulator, but inside the virtual terminal stat. This is not very useful, because when you implement more complex forms of line wrapping, you need to keep track of more state than just the cursor position. Because the kernel messages didn't share the same terminal emulator as ttyv0, this caused a lot of strange things, like kernel messages being misplaced and a missing notification to resize the terminal emulator for kernel messages never to be resized when using vidcontrol. This patch just removes kernel_console_ts and adds a special parameter to te_puts to determine whether messages should be printed using regular colors or the ones for kernel messages. Reported by: ache Tested by: nyan, garga (older version)
* Don't call into the TTY layer when inside kdb.ed2009-03-091-1/+1
| | | | | | | We should just leave the underlying TTY objects alone when scrolling around in KDB. It should be handled by Syscons exclusively. Reported by: pluknet gmail com
* Replace syscons terminal renderer by a new renderer that uses libteken.ed2009-01-011-10/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some time ago I started working on a library called libteken, which is terminal emulator. It does not buffer any screen contents, but only keeps terminal state, such as cursor position, attributes, etc. It should implement all escape sequences that are implemented by the cons25 terminal emulator, but also a fair amount of sequences that are present in VT100 and xterm. A lot of random notes, which could be of interest to users/developers: - Even though I'm leaving the terminal type set to `cons25', users can do experiments with placing `xterm-color' in /etc/ttys. Because we only implement a subset of features of xterm, this may cause artifacts. We should consider extending libteken, because in my opinion xterm is the way to go. Some missing features: - Keypad application mode (DECKPAM) - Character sets (SCS) - libteken is filled with a fair amount of assertions, but unfortunately we cannot go into the debugger anymore if we fail them. I've done development of this library almost entirely in userspace. In sys/dev/syscons/teken there are two applications that can be helpful when debugging the code: - teken_demo: a terminal emulator that can be started from a regular xterm that emulates a terminal using libteken. This application can be very useful to debug any rendering issues. - teken_stress: a stress testing application that emulates random terminal output. libteken has literally survived multiple terabytes of random input. - libteken also includes support for UTF-8, but unfortunately our input layer and font renderer don't support this. If users want to experiment with UTF-8 support, they can enable `TEKEN_UTF8' in teken.h. If you recompile your kernel or the teken_demo application, you can hold some nice experiments. - I've left PC98 the way it is right now. The PC98 platform has a custom syscons renderer, which supports some form of localised input. Maybe we should port PC98 to libteken by the time syscons supports UTF-8? - I've removed the `dumb' terminal emulator. It has been broken for years. It hasn't survived the `struct proc' -> `struct thread' conversion. - To prevent confusion among people that want to hack on libteken: unlike syscons, the state machines that parse the escape sequences are machine generated. This means that if you want to add new escape sequences, you have to add an entry to the `sequences' file. This will cause new entries to be added to `teken_state.h'. - Any rendering artifacts that didn't occur prior to this commit are by accident. They should be reported to me, so I can fix them. Discussed on: current@, hackers@ Discussed with: philip (at 25C3)
* Undo revision 185013 until better solution is found.emax2008-11-171-4/+0
| | | | Pointed out by: bde
* More locking for syscons(4). This should prevent races with sckbdevent().emax2008-11-161-0/+4
| | | | | PR: kern/127446 Submitted by: Eygene Ryabinkin rea-fbsd at codelabs dot ru
* Disable processing of output data after disabling scroll lock by force.ed2008-08-311-0/+9
| | | | | | | | | | | | | The syscons code disabled scroll lock inside sc_cnputs() if it's going to print a system message. The code currently wants to process any TTY output data as well, but we cannot do this, because the TTY lock is a sleep mutex, while cnputs() picks up a spin mutex. Disable the code for now. It solves a panic when a console message is printed while scroll lock is enabled. One solution would be to initialize a task structure here. Reported by: Paul B. Mahol <onemda gmail com>
* Make syscons(4) use ttyv0 instead of consolectl as its primary window.ed2008-08-241-11/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When I was hacking on uart(4) to make it work with the MPSAFE TTY layer, I noticed there was a difference between the way syscons and uart work with respect to consoles: - The uart(4) driver sets cn_name to the corresponding ttyu%r node, which means init(8) (which opens /dev/console) will have its output redirected to /dev/ttyu%r. After /etc/rc is done, it can spawn a getty on that device node as well. - Syscons used a little different approach. Apart from the /dev/ttyv%r nodes, it creates a /dev/consolectl node. This device node is used by moused and others to deliver their data, but for some reason it also acts as a TTY, which shares its stat structure with ttyv0. This device node is used as a console (run conscontrol). There are a couple advantages of this approach: - Because we use two different TTY's to represent the 0th syscons window, we allocate two sets of TTY buffers. Even if you don't use /dev/consolectl after the system has booted (systems that don't run moused), it seems the buffers are still allocated. - We have to apply an evil hack to redirect input to /dev/consolectl. Because each window (stat) is associated not associated with one TTY, syscons solves this by redirecting all input to closed TTY's to consolectl. This means that opening /dev/ttyv0 while in single user mode will probably cause strange things to happen with respect to keyboard input redirection. The first patch that I discussed with philip@ turned consolectl into a symlink to ttyv0, but this was not a good idea, because in theory we would want consolectl to be a simple device node, which contains all the `privileged' ioctl()'s. Apart from that, it didn't work, because each time /dev/ttyv0 got revoked, moused also lost its descriptor to deliver input, which meant you had to plug out/in your mouse to make it work again. This version just leaves the consolectl device the way it is. It can still be used to write output to ttyv0, but it can no longer receive any input. In my opinion this patch is not a complete solution, but it's already a step in the good direction. It would allow us to turn consolectl into a special (non-TTY) device node in the far future. It shaves off 15 KB of wasted TTY buffer space. Discussed with: philip
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.ed2008-08-201-171/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last half year I've been working on a replacement TTY layer for the FreeBSD kernel. The new TTY layer was designed to improve the following: - Improved driver model: The old TTY layer has a driver model that is not abstract enough to make it friendly to use. A good example is the output path, where the device drivers directly access the output buffers. This means that an in-kernel PPP implementation must always convert network buffers into TTY buffers. If a PPP implementation would be built on top of the new TTY layer (still needs a hooks layer, though), it would allow the PPP implementation to directly hand the data to the TTY driver. - Improved hotplugging: With the old TTY layer, it isn't entirely safe to destroy TTY's from the system. This implementation has a two-step destructing design, where the driver first abandons the TTY. After all threads have left the TTY, the TTY layer calls a routine in the driver, which can be used to free resources (unit numbers, etc). The pts(4) driver also implements this feature, which means posix_openpt() will now return PTY's that are created on the fly. - Improved performance: One of the major improvements is the per-TTY mutex, which is expected to improve scalability when compared to the old Giant locking. Another change is the unbuffered copying to userspace, which is both used on TTY device nodes and PTY masters. Upgrading should be quite straightforward. Unlike previous versions, existing kernel configuration files do not need to be changed, except when they reference device drivers that are listed in UPDATING. Obtained from: //depot/projects/mpsafetty/... Approved by: philip (ex-mentor) Discussed: on the lists, at BSDCan, at the DevSummit Sponsored by: Snow B.V., the Netherlands dcons(4) fixed by: kan
* Lower the priority of the sleep in the syscons for "waitvt" wchan tokib2008-08-041-1/+1
| | | | | | | | | PZERO + 1. The sleeping process at the priority <= PZERO is counted as blocked, or, as comment states, 'disk wait'. PZERO + 1 works as well, and does not cause user confusion. Reported by: sam <samflanker at gmail com> MFC after: 1 week
* The "free-lance" timer in the i8254 is only used for the speakerphk2008-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | these days, so de-generalize the acquire_timer/release_timer api to just deal with speakers. The new (optional) MD functions are: timer_spkr_acquire() timer_spkr_release() and timer_spkr_setfreq() the last of which configures the timer to generate a tone of a given frequency, in Hz instead of 1/1193182th of seconds. Drop entirely timer2 on pc98, it is not used anywhere at all. Move sysbeep() to kern/tty_cons.c and use the timer_spkr*() if they exist, and do nothing otherwise. Remove prototypes and empty acquire-/release-timer() and sysbeep() functions from the non-beeping archs. This eliminate the need for the speaker driver to know about i8254frequency at all. In theory this makes the speaker driver MI, contingent on the timer_spkr_*() functions existing but the driver does not know this yet and still attaches to the ISA bus. Syscons is more tricky, in one function, sc_tone(), it knows the hz and things are just fine. In the other function, sc_bell() it seems to get the period from the KDMKTONE ioctl in terms if 1/1193182th second, so we hardcode the 1193182 and leave it at that. It's probably not important. Change a few other sysbeep() uses which obviously knew that the argument was in terms of i8254 frequency, and leave alone those that look like people thought sysbeep() took frequency in hertz. This eliminates the knowledge of i8254_freq from all but the actual clock.c code and the prof_machdep.c on amd64 and i386, where I think it would be smart to ask for help from the timecounters anyway [TBD].
* Improve VT_WAITACTIVE semantics.bland2008-03-201-13/+6
| | | | | | | | - Wait for requested vty activation regardless its open state. - Remove redundant console cleanup. Approved by: kib MFC after: 1 week
* Do not dereference NULL scp in the case the screen is not opened.kib2008-01-241-0/+2
| | | | | | | | Instead, return ENXIO to the ioctl caller. Reported and tested by: Pawel Worach <pawel.worach gmail com> Discussed with: markus MFC after: 3 days
* Replace explicit calls to video methods with their respective variantswkoszek2007-12-291-17/+15
| | | | | | | | | | | | | | | implemented with macros. This patch improves code readability. Reasoning behind vidd_* is a sort of "video discipline". List of macros is supposed to be complete--all methods of video_switch ought to have their respective macros from now on. Functionally, this code should be no-op. My intention is to leave current behaviour of touched code as is. No objections: rwatson Silence on: freebsd-current@ Approved by: cognet
* Remove explicit calls to keyboard methods with their respective variantswkoszek2007-12-291-28/+28
| | | | | | | | | | | | | | | implemented with macros. This patch improves code readability. Reasoning behind kbdd_* is a "keyboard discipline". List of macros is supposed to be complete--all methods of keyboard_switch should have their respective macros from now on. Functionally, this code should be no-op. My intention is to leave current behaviour of code as is. Glanced at by: rwatson Reviewed by: emax, marcel Approved by: cognet
* Add a new 'why' argument to kdb_enter(), and a set of constants to userwatson2007-12-251-1/+1
| | | | | | | | | for that argument. This will allow DDB to detect the broad category of reason why the debugger has been entered, which it can use for the purposes of deciding which DDB script to run. Assign approximate why values to all current consumers of the kdb_enter() interface.
* Serialize output routine of terminal emulator (te_puts()) by a lock.simokawa2007-09-201-1/+13
| | | | | | | | | | | | | | - The output routine of low level console is not protected by any lock by default. - Increment and decrement of sc->write_in_progress are not atomic and this may cause console hang. - We also have many other states used by emulator that should be protected by the lock. - This change does not fix interspersed messages which PRINTF_BUFR_SIZE kernel option should fix. Approved by: re (bmah) MFC after: 1 week
* Fix a bug that will cause a process that calls the VT_WAITACTIVE ioctlmarcus2007-09-191-2/+1
| | | | | | | | | | | to become unkillable when that process is sent a termination signal. The process will sit in waitvt looping in the kernel, and chewing up all available CPU until the system is rebooted. Submitted by: Jilles Tjoelker <jilles@stack.nl> Reviewed by: bde Approved by: re (kensmith) MFC after: 1 week
* - Change comments and asserts to reflect the removal of the globaljeff2007-06-041-2/+2
| | | | | | | | scheduler lock. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
* Replace magic numbers for console bell types with defines.ru2006-11-161-2/+2
|
OpenPOWER on IntegriCloud