Charles.Forsyth20060303-partialeea662d19 years agoHistory
312 lines · 8.0 KB · Text
RawDownload
.TH CONS 3 .SH NAMEcons \- console device.SH SYNOPSIS.nf.B bind #c /dev .B /dev/cons.B /dev/consctl.B /dev/drivers.B /dev/jit.B /dev/keyboard.B /dev/klog.B /dev/kprint.B /dev/memory.B /dev/msec.B /dev/null.B /dev/notquiterandom.B /dev/pin.B /dev/pointer.B /dev/random.B /dev/scancode.B /dev/sysctl.B /dev/sysname.B /dev/time.B /dev/user.fi.SH DESCRIPTIONThe console device serves a one-level directorygiving access to the console andmiscellaneous information..PPReading the.B consfile returns characters typed on the keyboard.Normally, characters are buffered to enable erase and kill processing.A control-U,.LR ^U ,typed at the keyboard.I killsthe current input line (removes all charactersfrom the buffer of charactersnot yet read via.BR cons ),and a backspace.I erasesthe previous non-kill, non-erase character from the input buffer.Killing and erasing only delete characters back to, but not including,the last newline.Typed keystrokes produce 16-bit charactersthat are translated into the variable-length.SM UTFencoding (see.IR utf (6))before putting them into the buffer.A.B readof length greater than zero causes the process to wait until anewline or a.L ^Dends the buffer, and then returns as much of the buffer as the argumentto.B readallows, but only up to one complete line.A terminating.L ^Dis not put into the buffer.If part of the line remains, the next.B readwill return bytes from that remainder and not part of any new linethat has been typed since. A single line containing a.L ^Dcan be used as an end of file indication to programs that take interactive input..PPIfthe string.B rawonhas been written to the.B consctlfile and the file is still open,.B consis in.IR "raw mode" :characters are not echoed as they are typed,backspace and.L ^Dare not treated specially,and characters are available to.B readas soon as they are typed.Ordinary mode is reentered when.B rawoffis written to.B consctlor this file is closed..PPA.B writeto.B conscauses the characters to be printed on the console screen..PPThe.B keyboardfile returns the underlying tokens produced by the keyboard hardware as theyare produced; in the emulation environment, it is like an always-raw.B consfile..PPThe.B nullfile throws away anything written to itand always returns zero bytes when read..PPThe.B klogfilereturns the tail of messages written by the native kernel debugging function.B kprint(mainly used when debugging interrupt handlers in device drivers).It is available only in native kernel implementations..PPThe.B kprintfilereturns console output: messages written by kernel print statements and messageswritten by processes to this driver's.B consfile.Until.B kprintis opened, system console output is handled normally.Once.B kprinthas been opened,if the machine's console is a serial line, the data is sent both tothe serial console and to.BR kprint ;if the console is a graphics screen, the data is sent only to.BR kprint ..PPA read of the.B pointerfile returns the status of the mouse or other pointing device:its position and button state.The read blocks until the state has changed since the last read.The read returns 49 bytes: the letter.B mfollowed by four fields containing decimal integers, each 11 characters wide followed by a blank.The integers are: x and y,coordinates of the pointer on the screen; a bit mask with the1, 2, and 4 bits when the pointer's left, middle, and rightbuttons, respectively, are down; and a time stamp in units of milliseconds..PPWriting to the.B pointerfile, using the same format,causes the pointer to move to the specified x, y position(the button and millisecond fields are ignored, and optional).If there is a visible image representing the pointer's position,that will move too..PPThe.B pinfile, when read, returns either the string.B "no pinif no PIN has been set for authentication, or.B "pin setif one has.The.B pinfile may be written once with a decimal representation of the PINto use on this Inferno machine..PPThe.B randomdevice returns as many bytes of random data as are requested in the.BR read ..PPThe.B notquiterandomdevice returns as many bytes of pseudo-random data as are requested in the.BR read ;this is typically faster than.B randombut the results are more predictable..PPThe.B scancodedevice provides access to the raw scan codes of the primary.B keyboard .While it is open, key strokes are diverted from.B consand.B keyboard .The first.IR read (2)after opening returns an identifier string which defines the format of data deliveredby subsequentreads. Known ones are defined in.IR scancode (6).The most common format is a single byte per scan code, where the top bit is 1 forup and 0 for down, and the bottom 7 bits are the scan code. Some input deviceshave a larger scan code space; in this case scan codes are often delivered as two bytelittle endian quantities, where the top bit is the up/down signifier, and the bottom15 bits are the scan code. In all cases the meaning of the individual scan codes isdevice specific..PPThe rest of the files contain (mostly) read-only strings.Each string has a fixed length: a.I read(see.IR sys-read (2))of more than that gives a result of that fixed length (the result does notinclude a terminating zero byte);a.I readof less than that length leaves the file offset so therest of the string (but no more) will be read the next time.To reread the file without closing it,.I seekmust be used to reset the offset.When the file contains numeric data, each number is formattedin decimal as an 11-digit number with leading blanks andone trailing blank: twelve bytes total..PPThe.B sysctlfile can be read to return the current Inferno version. Writing the string.B rebootto it attempts to reboot the system, writing.B haltattempts to halt the system. Writing.B nobrokenensures that broken processes have all associated memory freed beforebeing destroyed,writing.B brokenensures that they are left in this state to allow debugging (the default).Only the privileged user is allowed to write to this file..PPThe.B sysnamefile holds the textual name of the machine.It can only be written by the privileged user..PPThe.B userfile contains the name of the user associated with the current process.It can only be written by the privileged user. In the emulation environment,writing to this file also attempts to set the user id in the host operatingsystem to the specified value..PPThe.B memoryfile returns a formatted presentation of the state of the memoryallocation pools in the system.Each line of output returned reports, for a single pool,the amount of memory in use,the upper size limit,the high water mark,the number of allocations done,the number of frees done,the number of extensions done,the largest chunk availableand the name of the pool..PPThe.B driversfile returns a list of the device drivers loaded in the system.Each line gives the name of the device for.IR bind (1),such as.BR #c ,followed by the name of the driver as used in the system configuration file..PPThe other files served by the.I consdevice are all single numbers:.TP.B jitnon-zero if `just in time' compilation is configured (can be written to change the state). Writing 0 turns off JIT compilation, 1 turns it on and larger values give increasinglydetailed traces of the compilation for debugging purposes..TP.B msecthe value of a millisecond counter.TP.B timenumber of microseconds since the epoch 00:00:00 GMT, Jan. 1, 1970.(Can be written once by the privileged user, to set at boot time.).SH SOURCE.B /emu/port/devcons.c.br.B /os/port/devcons.c.SH SEE ALSO.IR draw (3),.IR keyboard (6),.IR utf (6),.IR eve (10.2).SH BUGSFor debugging, on native systems only,two control-T's followed by a lettergenerate console output:.L ^T^Tpprints data about kernel processes,.L ^T^Tsprints the kernel stack,.L ^T^Txprints data about memory allocation..PPThe system can be rebooted by typing.LR ^T^Tr .