VCONS(9)
π NAME π
okay so bestie, meet vcons β the generic virtual console framework. This is the VCONS(9) page from the Kernel Developer's Manual, and it's here to explain the setup-and-control functions for virtual consoles. periodt π
π SYNOPSIS π
#include <wscons/wsdisplay_vconsvar.h>
int
vcons_init(struct vcons_data *vd, void *cookie,
struct wsscreen_descr *desc, struct wsdisplay_accessops *accops);
int
vcons_init_screen(struct vcons_data *vd, struct vcons_screen *scr,
int exists, long *defattr);
void
vcons_redraw_screen(struct vcons_screen *scr);
β¨ DESCRIPTION β¨
These functions are used to setup and control the generic virtual console framework. No cap, that's the whole vibe.
vcons_init()β initializes the framework; it needs to be called for each driver that's going to usevcons. It's the main-character init moment β¨.vcons_init_screen()β adds a virtual screen to a display. slay.vcons_redraw_screen()β redraws a screen. A driver should call it when returning to terminal emulation mode, for instance when X exits. iykyk.
struct vcons_data contains all information needed to manage virtual consoles on a display; usually it will be a member of the driver's softc.
struct vcons_screen describes a virtual screen.
πΈ USAGE πΈ
To use vcons with a driver, it needs to be initialized by calling vcons_init(), usually in the driver's attach function. Here are the args, bestie:
vdβ should be a pointer to the driver'sstruct vcons_data.cookieβ should be a pointer to the driver's softc.descβ should point to astruct wsscreen_descrdescribing the default screen type for this display.accopsβ points to the driver'sstruct wsdisplay_accessopssovcons_init()can fill it in with its own implementations ofalloc_screen(),free_screen(), andshow_screen().
A driver should however provide its own ioctl() and mmap() implementations. Both will receive a pointer to the driver's struct vcons_data as first parameter. no cap, that first param matters.
After initialization the driver needs to provide a callback function that will be called whenever a screen is added. Its purpose is to set up the struct rasops_info describing the screen. After that the drawing methods in struct rasops_info will be replaced with wrappers which call the original drawing functions (which may or may not be provided by the driver) only when the respective screen is visible. It's giving invisible-screen protection π
.
To add a virtual screen the driver should call vcons_init_screen(), which will call the callback function described above, allocate storage for characters and attributes based on whatever the callback set up in struct rasops_info, and add the screen to a list kept in struct vcons_data. obsessed with the organization.
The callback needs to have this form:
void init_screen(void *cookie, struct vcons_screen *scr, int existing, long *defattr)
and should be stored in the init_screen member found in struct vcons_data. The arguments are:
cookieβ is the cookie passed tovcons_init().scrβ points to thestruct vcons_screenbeing added; itsscr_rimember, astruct rasops_info, needs to be filled in.existingβ is non-zero if the screen already exists and is only added to the list.defattrβ points to the screen's default text attribute. It's filled in byvcons_init_screen()by calling thealloc_attr()method found instruct rasops_info.
When attaching a wsdisplay(9) the accesscookie member of the struct wsemuldisplaydev_attach_args passed to config_found() needs to be a pointer to the driver's struct vcons_data. Don't forget this, bestie.
The following members of struct vcons_screen may be of interest to drivers:
scr_riβ contains thestruct rasops_infodescribing the screen's geometry, access methods and so on.scr_cookieβ the value passed ascookietovcons_init(). Usually the driver's softc.scr_vdβ the driver'sstruct vcons_data.scr_flagsβ can be zero or any combination of:VCONS_NO_REDRAWβ don't callvcons_redraw_screen()when this screen becomes visible.VCONS_SCREEN_IS_STATICβ don'tfree(9)this screen'sstruct vcons_screeninfree_screen()β useful if the screen has been statically allocated.
scr_statusβ currently contains only one flag,VCONS_IS_VISIBLE, which is set when the screen is visible.
π₯ SEE ALSO π₯
mwah π β source/version: Debian, date: February 12, 2006. byeee bestie, go be iconic with your virtual consoles π«Άπ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2006 Michael Lorenz
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms