console.c File Reference

#include "../drivers.h"
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/vm.h>
#include <minix/callnr.h>
#include <minix/com.h>
#include "tty.h"
#include "../../kernel/const.h"
#include "../../kernel/config.h"
#include "../../kernel/type.h"

Include dependency graph for console.c:

Go to the source code of this file.

Data Structures

struct  console
struct  sequence

Defines

#define MONO_BASE   0xB0000L
#define COLOR_BASE   0xB8000L
#define MONO_SIZE   0x1000
#define COLOR_SIZE   0x4000
#define EGA_SIZE   0x8000
#define BLANK_COLOR   0x0700
#define SCROLL_UP   0
#define SCROLL_DOWN   1
#define BLANK_MEM   ((u16_t *) 0)
#define CONS_RAM_WORDS   80
#define MAX_ESC_PARMS   4
#define M_6845   0x3B4
#define C_6845   0x3D4
#define INDEX   0
#define DATA   1
#define STATUS   6
#define VID_ORG   12
#define CURSOR   14
#define TIMER_FREQ   1193182L
#define BEEP_FREQ   0x0533
#define B_TIME   3
#define GA_SEQUENCER_INDEX   0x3C4
#define GA_SEQUENCER_DATA   0x3C5
#define GA_GRAPHICS_INDEX   0x3CE
#define GA_GRAPHICS_DATA   0x3CF
#define GA_VIDEO_ADDRESS   0xA0000L
#define GA_FONT_SIZE   8192
#define color   (vid_port == C_6845)
#define COM1_BASE   0x3F8
#define COM1_THR   (COM1_BASE + 0)
#define LSR_THRE   0x20
#define COM1_LSR   (COM1_BASE + 5)

Typedefs

typedef console console_t

Functions

FORWARD _PROTOTYPE (int cons_write,(struct tty *tp, int try))
FORWARD _PROTOTYPE (void cons_echo,(tty_t *tp, int c))
FORWARD _PROTOTYPE (void out_char,(console_t *cons, int c))
FORWARD _PROTOTYPE (void cons_putk,(int c))
FORWARD _PROTOTYPE (void beep,(void))
FORWARD _PROTOTYPE (void flush,(console_t *cons))
FORWARD _PROTOTYPE (void scroll_screen,(console_t *cons, int dir))
FORWARD _PROTOTYPE (void set_6845,(int reg, unsigned val))
FORWARD _PROTOTYPE (void get_6845,(int reg, unsigned *val))
FORWARD _PROTOTYPE (void stop_beep,(timer_t *tmrp))
FORWARD _PROTOTYPE (int ga_program,(struct sequence *seq))
FORWARD _PROTOTYPE (int cons_ioctl,(tty_t *tp, int))
PRIVATE _PROTOTYPE (void ser_putc,(char c))
PRIVATE int cons_write (struct tty *tp, int try)
PRIVATE void cons_echo (tty_t *tp, int c)
PRIVATE void out_char (console_t *cons, int c)
PRIVATE void scroll_screen (console_t *cons, int dir)
PRIVATE void flush (console_t *cons)
PRIVATE void parse_escape (console_t *cons, char c)
PRIVATE void do_escape (console_t *cons, char c)
PRIVATE void set_6845 (int reg, unsigned val)
PRIVATE void get_6845 (int reg, unsigned *val)
PRIVATE void beep ()
PUBLIC void do_video (message *m)
PUBLIC void beep_x (unsigned freq, clock_t dur)
PRIVATE void stop_beep (timer_t *tmrp)
PUBLIC void scr_init (tty_t *tp)
PUBLIC void kputc (int c)
PUBLIC void do_new_kmess (message *m)
PUBLIC void do_diagnostics (message *m_ptr)
PUBLIC void do_get_kmess (message *m_ptr)
PRIVATE void cons_putk (int c)
PUBLIC void toggle_scroll ()
PUBLIC void cons_stop ()
PRIVATE void cons_org0 ()
PUBLIC void select_console (int cons_line)
PUBLIC int con_loadfont (message *m)
PRIVATE int ga_program (struct sequence *seq)
PRIVATE int cons_ioctl (tty_t *tp, int try)
PRIVATE void ser_putc (char c)

Variables

PUBLIC int vid_index
PUBLIC u16_t vid_seg
PUBLIC vir_bytes vid_off
PUBLIC unsigned vid_size
PUBLIC unsigned vid_mask
PUBLIC unsigned blank_color = BLANK_COLOR
PRIVATE int vid_port
PRIVATE int wrap
PRIVATE int softscroll
PRIVATE int beeping
PRIVATE unsigned font_lines
PRIVATE unsigned scr_width
PRIVATE unsigned scr_lines
PRIVATE unsigned scr_size
PRIVATE int nr_cons = 1
PRIVATE console_t cons_table [NR_CONS]
PRIVATE console_tcurcons
PRIVATE int ansi_colors [8] = {0, 4, 2, 6, 1, 5, 3, 7}


Define Documentation

#define B_TIME   3
 

Definition at line 58 of file console.c.

Referenced by beep().

#define BEEP_FREQ   0x0533
 

Definition at line 57 of file console.c.

Referenced by beep().

#define BLANK_COLOR   0x0700
 

Definition at line 37 of file console.c.

Referenced by cons_stop(), do_escape(), and scr_init().

#define BLANK_MEM   ((u16_t *) 0)
 

Definition at line 40 of file console.c.

Referenced by do_escape(), scr_init(), and scroll_screen().

#define C_6845   0x3D4
 

Definition at line 46 of file console.c.

#define color   (vid_port == C_6845)
 

Definition at line 111 of file console.c.

Referenced by con_loadfont(), do_escape(), and scr_init().

#define COLOR_BASE   0xB8000L
 

Definition at line 33 of file console.c.

#define COLOR_SIZE   0x4000
 

Definition at line 35 of file console.c.

Referenced by scr_init().

#define COM1_BASE   0x3F8
 

Definition at line 1251 of file console.c.

#define COM1_LSR   (COM1_BASE + 5)
 

Definition at line 1254 of file console.c.

Referenced by ser_putc().

#define COM1_THR   (COM1_BASE + 0)
 

Definition at line 1252 of file console.c.

Referenced by ser_putc().

#define CONS_RAM_WORDS   80
 

Definition at line 41 of file console.c.

#define CURSOR   14
 

Definition at line 51 of file console.c.

#define DATA   1
 

Definition at line 48 of file console.c.

Referenced by add(), get_6845(), set_6845(), and slave().

#define EGA_SIZE   0x8000
 

Definition at line 36 of file console.c.

Referenced by scr_init().

#define GA_FONT_SIZE   8192
 

Definition at line 66 of file console.c.

Referenced by con_loadfont().

#define GA_GRAPHICS_DATA   0x3CF
 

Definition at line 64 of file console.c.

#define GA_GRAPHICS_INDEX   0x3CE
 

Definition at line 63 of file console.c.

Referenced by con_loadfont().

#define GA_SEQUENCER_DATA   0x3C5
 

Definition at line 62 of file console.c.

#define GA_SEQUENCER_INDEX   0x3C4
 

Definition at line 61 of file console.c.

Referenced by con_loadfont().

#define GA_VIDEO_ADDRESS   0xA0000L
 

Definition at line 65 of file console.c.

Referenced by con_loadfont().

#define INDEX   0
 

Definition at line 47 of file console.c.

#define LSR_THRE   0x20
 

Definition at line 1253 of file console.c.

Referenced by ser_putc().

#define M_6845   0x3B4
 

Definition at line 45 of file console.c.

#define MAX_ESC_PARMS   4
 

Definition at line 42 of file console.c.

#define MONO_BASE   0xB0000L
 

Definition at line 32 of file console.c.

#define MONO_SIZE   0x1000
 

Definition at line 34 of file console.c.

Referenced by scr_init().

#define SCROLL_DOWN   1
 

Definition at line 39 of file console.c.

Referenced by do_escape().

#define SCROLL_UP   0
 

Definition at line 38 of file console.c.

Referenced by out_char(), scr_init(), and scroll_screen().

#define STATUS   6
 

Definition at line 49 of file console.c.

Referenced by c_complete(), emacs(), insert_char(), and last_argument().

#define TIMER_FREQ   1193182L
 

Definition at line 54 of file console.c.

Referenced by beep_x().

#define VID_ORG   12
 

Definition at line 50 of file console.c.

Referenced by scroll_screen(), and select_console().


Typedef Documentation

typedef struct console console_t
 


Function Documentation

PRIVATE _PROTOTYPE void  ser_putc,
(char c
 

FORWARD _PROTOTYPE int  cons_ioctl,
(tty_t *tp, int) 
 

FORWARD _PROTOTYPE int  ga_program,
(struct sequence *seq) 
 

FORWARD _PROTOTYPE void  stop_beep,
(timer_t *tmrp) 
 

FORWARD _PROTOTYPE void  get_6845,
(int reg, unsigned *val
 

FORWARD _PROTOTYPE void  set_6845,
(int reg, unsigned val
 

FORWARD _PROTOTYPE void  scroll_screen,
(console_t *cons, int dir
 

FORWARD _PROTOTYPE void  flush,
(console_t *cons) 
 

FORWARD _PROTOTYPE void  beep,
(void) 
 

FORWARD _PROTOTYPE void  cons_putk,
(int c
 

FORWARD _PROTOTYPE void  out_char,
(console_t *cons, int c
 

FORWARD _PROTOTYPE void  cons_echo,
(tty_t *tp, int c
 

FORWARD _PROTOTYPE int  cons_write,
(struct tty *tp, int try) 
 

PRIVATE void beep  ) 
 

Definition at line 739 of file console.c.

References B_TIME, BEEP_FREQ, beeping, BYTE, getuptime(), now, NULL, OK, panic, PORT_B, pv_set, s, sys_inb, sys_outb, sys_setalarm(), sys_voutb(), TIMER2, TIMER_MODE, timer::tmr_exp_time, tmrs_settimer(), TRUE, tty_next_timeout, and tty_timers.

PUBLIC void beep_x unsigned  freq,
clock_t  dur
 

Definition at line 833 of file console.c.

References beeping, BYTE, getuptime(), now, NULL, OK, panic, PORT_B, pv_set, s, sys_inb, sys_outb, sys_setalarm(), sys_voutb(), TIMER2, TIMER_FREQ, TIMER_MODE, timer::tmr_exp_time, tmrs_settimer(), TRUE, tty_next_timeout, and tty_timers.

Referenced by handle_req().

PUBLIC int con_loadfont message m  ) 
 

Definition at line 1183 of file console.c.

References color, D, ENOTTY, GA_FONT_SIZE, GA_GRAPHICS_INDEX, ga_program(), GA_SEQUENCER_INDEX, GA_VIDEO_ADDRESS, NONE, PHYS_SEG, result, sys_physcopy(), and sequence::value.

Referenced by do_ioctl().

PRIVATE void cons_echo tty_t tp,
int  c
 

Definition at line 212 of file console.c.

References cons(), flush, and out_char().

PRIVATE int cons_ioctl tty_t tp,
int  try
 

Definition at line 1239 of file console.c.

References font_lines, scr_lines, and scr_width.

Referenced by scr_init().

PRIVATE void cons_org0  ) 
 

Definition at line 1145 of file console.c.

References cons(), cons_table, if(), n, nr_cons, scr_size, and vid_size.

Referenced by cons_stop(), and toggle_scroll().

PRIVATE void cons_putk int  c  ) 
 

Definition at line 1105 of file console.c.

References cons_table, flush, and out_char().

Referenced by do_diagnostics(), do_new_kmess(), and kputc().

PUBLIC void cons_stop  ) 
 

Definition at line 1133 of file console.c.

References BLANK_COLOR, console::c_attr, console::c_blank, cons_org0(), cons_table, select_console(), and softscroll.

Referenced by main().

PRIVATE int cons_write struct tty tp,
int  try
 

Definition at line 143 of file console.c.

References buflen, BYTE, cons(), count, D, flush, OK, out_char(), result, scr_width, SELF, sys_vircopy(), and tty_reply().

PUBLIC void do_diagnostics message m_ptr  ) 
 

Definition at line 1058 of file console.c.

References c, cons_putk(), count, D, EFAULT, OK, proc_nr, result, SELF, send, and sys_vircopy().

PRIVATE void do_escape console_t cons,
char  c
 

Definition at line 459 of file console.c.

References ansi_colors, BLANK_COLOR, blank_color, BLANK_MEM, bufend, color, count, FALSE, flush, n, scr_lines, scr_size, scr_width, SCROLL_DOWN, scroll_screen(), and TRUE.

Referenced by parse_escape().

PUBLIC void do_get_kmess message m_ptr  ) 
 

Definition at line 1085 of file console.c.

References D, EFAULT, if(), kmess, OK, r, SELF, send, and sys_vircopy().

Referenced by main().

PUBLIC void do_new_kmess message m  ) 
 

Definition at line 1009 of file console.c.

References bytes, cons_putk(), kmessages::km_buf, kmessages::km_next, kmessages::km_size, kmess, KMESS_BUF_SIZE, next, OK, printf, r, size, and sys_getkmessages.

PUBLIC void do_video message m  ) 
 

Definition at line 778 of file console.c.

References c, D, DEV_CLOSE, DEV_IOCTL, DEV_OPEN, EINVAL, ENOTTY, i, m, MIOCMAP, MIOCUNMAP, n, OK, ops, printf, r, SELF, sys_vircopy(), sys_vm_map(), TASK_REPLY, and tty_reply().

Referenced by main().

PRIVATE void flush console_t cons  ) 
 

Definition at line 366 of file console.c.

References curcons, CURSOR, scr_lines, scr_width, set_6845(), tp, and TRUE.

PRIVATE int ga_program struct sequence seq  ) 
 

Definition at line 1223 of file console.c.

References i, pvb_pair_t::port, pv_set, and pvb_pair_t::value.

Referenced by con_loadfont().

PRIVATE void get_6845 int  reg,
unsigned *  val
 

Definition at line 720 of file console.c.

References DATA, INDEX, sys_inb, sys_outb, and vid_port.

PUBLIC void kputc int  c  ) 
 

Definition at line 983 of file console.c.

References cons_putk(), kmessages::km_buf, kmessages::km_next, kmessages::km_size, kmess, KMESS_BUF_SIZE, LOG_PROC_NR, notify, panicing, and ser_putc().

PRIVATE void out_char console_t cons,
int  c
 

Definition at line 226 of file console.c.

References beep(), buflen, BYTE, flush, LINEWRAP, OPOST, parse_escape(), scr_lines, scr_width, scroll_screen(), SCROLL_UP, TAB_MASK, and TAB_SIZE.

PRIVATE void parse_escape console_t cons,
char  c
 

Definition at line 400 of file console.c.

References bufend, and do_escape().

Referenced by out_char().

PUBLIC void scr_init tty_t tp  ) 
 

Definition at line 890 of file console.c.

References BIOS_SEG, blank_color, BLANK_COLOR, BLANK_MEM, color, COLOR_BASE, COLOR_SIZE, cons(), cons_ioctl(), cons_table, D, EGA_SIZE, font_lines, i, MONO_BASE, MONO_SIZE, n, NR_CONS, nr_cons, page_size(), s, scr_lines, scr_size, scr_width, scroll_screen(), SCROLL_UP, select_console(), SELF, sys_segctl(), sys_vircopy(), tty_table, VDU_CRT_BASE_ADDR, VDU_CRT_BASE_SIZE, VDU_FONTLINES_ADDR, VDU_FONTLINES_SIZE, VDU_SCREEN_COLS_ADDR, VDU_SCREEN_COLS_SIZE, VDU_SCREEN_ROWS_ADDR, VDU_SCREEN_ROWS_SIZE, vid_index, vid_mask, vid_off, vid_port, vid_seg, vid_size, and wrap.

Referenced by tty_init().

PRIVATE void scroll_screen console_t cons,
int  dir
 

Definition at line 312 of file console.c.

References blank_color, BLANK_MEM, chars, curcons, flush, new_line(), scr_size, scr_width, SCROLL_UP, set_6845(), softscroll, vid_mask, VID_ORG, and wrap.

Referenced by do_escape(), out_char(), and scr_init().

PUBLIC void select_console int  cons_line  ) 
 

Definition at line 1169 of file console.c.

References console::c_cur, console::c_org, ccurrent, cons_table, curcons, CURSOR, nr_cons, set_6845(), and VID_ORG.

Referenced by cons_stop(), kb_read(), and scr_init().

PRIVATE void ser_putc char  c  ) 
 

Definition at line 1256 of file console.c.

References b, COM1_LSR, COM1_THR, i, LSR_THRE, and sys_inb.

Referenced by kputc().

PRIVATE void set_6845 int  reg,
unsigned  val
 

Definition at line 701 of file console.c.

References BYTE, DATA, INDEX, pv_set, sys_voutb(), and vid_port.

Referenced by flush(), scroll_screen(), and select_console().

PRIVATE void stop_beep timer_t tmrp  ) 
 

Definition at line 877 of file console.c.

References beeping, FALSE, OK, PORT_B, sys_inb, and sys_outb.

PUBLIC void toggle_scroll  ) 
 

Definition at line 1121 of file console.c.

References cons_org0(), printf, and softscroll.

Referenced by kb_read().


Variable Documentation

PRIVATE int ansi_colors[8] = {0, 4, 2, 6, 1, 5, 3, 7}
 

Definition at line 114 of file console.c.

Referenced by do_escape().

PRIVATE int beeping
 

Definition at line 80 of file console.c.

Referenced by beep(), beep_x(), and stop_beep().

PUBLIC unsigned blank_color = BLANK_COLOR
 

Definition at line 74 of file console.c.

Referenced by do_escape(), scr_init(), and scroll_screen().

PRIVATE console_t cons_table[NR_CONS]
 

Definition at line 107 of file console.c.

Referenced by cons_org0(), cons_putk(), cons_stop(), scr_init(), and select_console().

PRIVATE console_t* curcons
 

Definition at line 108 of file console.c.

Referenced by flush(), scroll_screen(), and select_console().

PRIVATE unsigned font_lines
 

Definition at line 81 of file console.c.

Referenced by cons_ioctl(), and scr_init().

PRIVATE int nr_cons = 1
 

Definition at line 106 of file console.c.

Referenced by cons_org0(), scr_init(), and select_console().

PRIVATE unsigned scr_lines
 

Definition at line 83 of file console.c.

Referenced by cons_ioctl(), do_escape(), flush(), out_char(), and scr_init().

PRIVATE unsigned scr_size
 

Definition at line 84 of file console.c.

Referenced by cons_org0(), do_escape(), scr_init(), and scroll_screen().

PRIVATE unsigned scr_width
 

Definition at line 82 of file console.c.

Referenced by cons_ioctl(), cons_write(), do_escape(), flush(), out_char(), scr_init(), and scroll_screen().

PRIVATE int softscroll
 

Definition at line 79 of file console.c.

Referenced by cons_stop(), scroll_screen(), and toggle_scroll().

PUBLIC int vid_index
 

Definition at line 69 of file console.c.

Referenced by scr_init().

PUBLIC unsigned vid_mask
 

Definition at line 73 of file console.c.

Referenced by scr_init(), and scroll_screen().

PUBLIC vir_bytes vid_off
 

Definition at line 71 of file console.c.

Referenced by scr_init().

PRIVATE int vid_port
 

Definition at line 77 of file console.c.

Referenced by get_6845(), scr_init(), and set_6845().

PUBLIC u16_t vid_seg
 

Definition at line 70 of file console.c.

Referenced by scr_init().

PUBLIC unsigned vid_size
 

Definition at line 72 of file console.c.

Referenced by cons_org0(), and scr_init().

PRIVATE int wrap
 

Definition at line 78 of file console.c.

Referenced by deflateInit2_(), inflateBack9(), scr_init(), and scroll_screen().


Generated on Fri Apr 14 23:09:26 2006 for minix by  doxygen 1.4.6