Main Page | Directories | File List | Globals

terminal.c File Reference

#include <agnix/agnix.h>
#include <agnix/adi/adi.h>
#include <agnix/fs.h>
#include <agnix/terminal.h>
#include <agnix/resources.h>
#include <agnix/list.h>
#include <agnix/spinlock.h>
#include <agnix/sprintf.h>
#include <agnix/console.h>

Include dependency graph for terminal.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "TERM: "

Functions

 LIST_HEAD (terminal_list)
 LIST_HEAD (terminal_sys_list)
int terminal_switch (int term_switch)
int terminal_open (struct file_s *file, int flag, int mode)
int terminal_read (struct file_s *file, char *buf, int count)
int terminal_write (struct file_s *file, char *buf, int count)
int put_free_terminal (int terminal_desc)
int get_free_terminal (void)
int set_terminal_var (int term_nr, struct terminal_var_s *term_var)
int register_terminal (struct terminal_s *term)
int register_sys_terminal (struct terminal_s *term)
int register_terminal_driver (struct terminal_s *term, struct terminal_driver_s *term_driver)
int terminals_init (void)

Variables

spinlock_t terminal_list_lock
terminal_s term_sys [MAX_TERMINALS]
int term_cur
int term_nr = 0
file_ops_s term_file_ops
adi_chrdev_s term_chrdev


Define Documentation

#define MOD_NAME   "TERM: "
 

Definition at line 24 of file terminal.c.


Function Documentation

int get_free_terminal void   ) 
 

Definition at line 88 of file terminal.c.

References term_nr.

Referenced by register_terminal().

00089 {
00090     return term_nr++;
00091 }

LIST_HEAD terminal_sys_list   ) 
 

LIST_HEAD terminal_list   ) 
 

int put_free_terminal int  terminal_desc  ) 
 

Definition at line 83 of file terminal.c.

00084 {
00085     return 0;
00086 }

int register_sys_terminal struct terminal_s *  term  ) 
 

Definition at line 124 of file terminal.c.

References terminal_list_lock.

00125 {
00126     spin_lock(&terminal_list_lock);
00127     list_add(&term->term_list, &terminal_sys_list);
00128     spin_unlock(&terminal_list_lock);
00129 
00130     return 0;
00131 }

int register_terminal struct terminal_s *  term  ) 
 

Definition at line 108 of file terminal.c.

References adi_register_chrdev(), get_free_terminal(), sprintf(), and term_chrdev.

Referenced by adi_sysconsole_init().

00109 {
00110     term->term_nr = get_free_terminal();
00111 
00112     if (term->ops && term->ops->init)
00113         term->ops->init(term);
00114 
00115     list_add(&term->term_list, &terminal_list);
00116 
00117     sprintf(term_chrdev.dev_name, "tty%d", term->term_nr);
00118     term_chrdev.dev_nr = (DEV_TTY_MAJOR << 8) | (u8)term->term_nr;
00119     adi_register_chrdev(&term_chrdev);
00120 
00121     return term->term_nr;
00122 }

Here is the call graph for this function:

int register_terminal_driver struct terminal_s *  term,
struct terminal_driver_s *  term_driver
 

Definition at line 133 of file terminal.c.

Referenced by adi_sysconsole_init().

00134 {
00135     term->term_driver = term_driver;
00136     
00137     if (term_driver->ops && term_driver->ops->init)
00138         term_driver->ops->init();
00139 
00140     return 0;
00141 }

int set_terminal_var int  term_nr,
struct terminal_var_s *  term_var
 

Definition at line 93 of file terminal.c.

00094 {
00095     return 0;    
00096 }

int terminal_open struct file_s *  file,
int  flag,
int  mode
 

Definition at line 49 of file terminal.c.

References term_sys.

00050 {
00051     int tty_nr = (int)file->file_data;
00052 
00053     if (term_sys[tty_nr].term_pgrp != 0)
00054         return -1;
00055 
00056     term_sys[tty_nr].term_pgrp = current_task->t_pid;
00057     current_task->term    = &term_sys[tty_nr];
00058     file->file_data       = (void *)&term_sys[tty_nr];
00059     
00060     return 0;
00061 }

int terminal_read struct file_s *  file,
char *  buf,
int  count
 

Definition at line 63 of file terminal.c.

References syscons_read().

00064 {
00065     struct terminal_s *term = (struct terminal_s *)file->file_data;
00066 
00067     if (term == NULL)
00068         return -1;
00069 
00070     return syscons_read(term, buf, count);
00071 }

Here is the call graph for this function:

int terminal_switch int  term_switch  ) 
 

Definition at line 34 of file terminal.c.

References term_cur, and term_sys.

Referenced by kbd_irq_handler().

00035 {
00036     struct terminal_s *term = &term_sys[term_cur];
00037     struct terminal_s *term_new = &term_sys[term_switch];
00038     
00039     if (term_new->term_driver && term_new->term_driver->ops->refresh) {
00040         term_cur                = term_switch;
00041         term_new->term_driver->ops->refresh(term_new, 0);
00042         term->term_active       = 0;
00043         term_new->term_active   = 1;
00044     }
00045     
00046     return 0;    
00047 }

int terminal_write struct file_s *  file,
char *  buf,
int  count
 

Definition at line 73 of file terminal.c.

References syscons_write().

00074 {
00075     struct terminal_s *term = (struct terminal_s *)file->file_data;
00076 
00077     if (term == NULL)
00078         return -1;
00079 
00080     return syscons_write(term, buf, count);
00081 }

Here is the call graph for this function:

int terminals_init void   ) 
 

Definition at line 143 of file terminal.c.

References terminal_list_lock.

Referenced by start_kernel().

00144 {
00145     spin_lock_init(&terminal_list_lock);
00146     
00147     return 0;
00148 }


Variable Documentation

struct adi_chrdev_s term_chrdev
 

Initial value:

 {
    .file_ops = &term_file_ops,
}

Definition at line 104 of file terminal.c.

Referenced by register_terminal().

int term_cur
 

Definition at line 29 of file syscons.c.

struct file_ops_s term_file_ops
 

Initial value:

 {
    .open      = terminal_open,
    .read      = terminal_read,
    .write     = terminal_write,
}

Definition at line 98 of file terminal.c.

int term_nr = 0
 

Definition at line 32 of file terminal.c.

Referenced by get_free_terminal().

struct terminal_s term_sys[MAX_TERMINALS]
 

Definition at line 31 of file syscons.c.

spinlock_t terminal_list_lock
 

Definition at line 28 of file terminal.c.

Referenced by register_sys_terminal(), and terminals_init().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix