|
From: Aivils S. <ai...@us...> - 2003-09-16 06:54:47
|
Update of /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char
In directory sc8-pr-cvs1:/tmp/cvs-serv14542/ruby-2.6/drivers/char
Modified Files:
Makefile keyboard.c vt.c
Added Files:
vt_proc.c
Log Message:
/proc/bus/console, hack of /proc/bus/pci, dummy console 2 VCs
--- NEW FILE: vt_proc.c ---
/*
* $Id: vt_proc.c,v 1.1 2003/09/16 06:54:42 aivils Exp $
*
* Procfs interface for the VT-handler.
*
* Aivils Stoss <>
*/
#include <linux/config.h>
#ifdef CONFIG_PROC_FS
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/vt_kern.h>
#include <linux/input.h>
#include <asm/uaccess.h>
#include <linux/module.h>
#define VT_PROC_DIR "console"
#define WRITE_BUF_MAX_LEN 256
typedef struct _vt_proc_entry {
char *name;
read_proc_t *read_proc;
write_proc_t *write_proc;
unsigned long offset;
} vt_proc_entry;
static int
generic_read(char *page, char **start, off_t off, int count, int *eof, int len)
{
if (len <= off + count)
*eof = 1;
*start = page + off;
len -= off;
if (len > count)
len = count;
if (len < 0)
len = 0;
return len;
}
static int
read_kbd_phys(char *page, char **start, off_t off, int count, int *eof, void *data)
{
struct vt_struct *vt = (struct vt_struct*) data;
int len;
if(!vt || !vt->keyboard) return 0;
len = sprintf(page, "%s\n", vt->keyboard->dev->phys ? vt->keyboard->dev->phys : "");
return generic_read(page, start, off, count, eof, len);
}
static int
write_kbd_phys(struct file *file, const char *buffer,
unsigned long count, void *data)
{
struct vt_struct *vt = (struct vt_struct*) data;
struct input_handle *handle;
char phys_descr[WRITE_BUF_MAX_LEN + 1];
int add_next = 0;
if (!vt || !buffer)
return -EINVAL;
if (count > WRITE_BUF_MAX_LEN) {
count = WRITE_BUF_MAX_LEN;
}
if (copy_from_user(phys_descr, buffer, count))
return -EFAULT;
if(phys_descr[count-1] == 0x0A) phys_descr[count-1] = '\0';
else phys_descr[count] = '\0';
if(phys_descr[0] == 0x2B) //1st is "+" sign
add_next = 1;
handle = input_find_handle(phys_descr+add_next);
if(handle) {
if(handle->private) ((struct vt_struct*)handle->private)->keyboard = NULL;
if(!add_next) {
if(vt->keyboard) vt->keyboard->private = NULL;
vt->keyboard = handle;
}
handle->private = vt;
}
return count;
}
static vt_proc_entry vt_proc_list[] = {
{"keyboard", read_kbd_phys, write_kbd_phys, 0},
{"", 0, 0, 0}
};
static struct proc_dir_entry *
create_proc_rw(char *name, void *data, struct proc_dir_entry *parent,
read_proc_t * read_proc, write_proc_t * write_proc)
{
struct proc_dir_entry *pdep;
mode_t mode = S_IFREG;
if (write_proc) {
mode |= S_IWUSR;
if (read_proc) {
mode |= S_IRUGO;
}
} else if (read_proc) {
mode |= S_IRUGO;
}
if (!(pdep = create_proc_entry(name, mode, parent)))
return NULL;
pdep->read_proc = read_proc;
pdep->write_proc = write_proc;
pdep->data = data;
return pdep;
}
struct proc_dir_entry *proc_bus_console_dir;
int vt_proc_attach(struct vt_struct *vt)
{
struct proc_dir_entry *de;
vt_proc_entry *pe;
char name[16];
if (!(de = vt->procdir)) {
sprintf(name, "%02x", vt->vt_num);
de = vt->procdir = proc_mkdir(name, proc_bus_console_dir);
if (!de)
return -ENOMEM;
}
for (pe = vt_proc_list; pe->name[0]; pe++) {
if (pe->name[0] == '\n')
continue;
if (!(create_proc_rw(pe->name, (void*) vt, vt->procdir,
pe->read_proc, pe->write_proc))) {
return -ENOMEM;
}
}
return 0;
}
EXPORT_SYMBOL(vt_proc_attach);
int vt_proc_detach(struct vt_struct *vt)
{
struct proc_dir_entry *e;
vt_proc_entry *pe;
if ((e = vt->procdir)) {
for (pe = vt_proc_list; pe->name[0]; pe++) {
if (pe->name[0] == '\n')
continue;
remove_proc_entry(pe->name, vt->procdir);
vt->procdir = NULL;
}
remove_proc_entry(e->name, proc_bus_console_dir);
}
return 0;
}
EXPORT_SYMBOL(vt_proc_detach);
int __init vt_proc_init(void)
{
struct vt_struct *vt=vt_cons;
if (vt) {
proc_bus_console_dir = proc_mkdir(VT_PROC_DIR, proc_bus);
while(vt) {
vt_proc_attach(vt);
vt=vt->next;
}
}
return 0;
}
#endif /* CONFIG_PROC_FS */
Index: Makefile
===================================================================
RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile 11 Aug 2003 16:26:46 -0000 1.1
+++ Makefile 16 Sep 2003 06:54:41 -0000 1.2
@@ -9,7 +9,7 @@
obj-y += mem.o tty_io.o n_tty.o tty_ioctl.o pty.o misc.o random.o
-obj-$(CONFIG_VT) += vt_ioctl.o decvte.o vc_screen.o consolemap.o consolemap_deftbl.o selection.o keyboard.o
+obj-$(CONFIG_VT) += vt_ioctl.o decvte.o vc_screen.o consolemap.o consolemap_deftbl.o selection.o keyboard.o vt_proc.o
obj-$(CONFIG_HW_CONSOLE) += vt.o defkeymap.o
obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o
obj-$(CONFIG_ATARI_DSP56K) += dsp56k.o
Index: keyboard.c
===================================================================
RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/keyboard.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- keyboard.c 12 Sep 2003 08:33:21 -0000 1.2
+++ keyboard.c 16 Sep 2003 06:54:42 -0000 1.3
@@ -1145,7 +1145,6 @@
* beeper is independent we can share it with all VTs that don't
* have one.
*/
- //if(strncmp(dev->phys,"isa0061",7))
if (i != BTN_MISC) {
while (vt) {
if (vt->next && !vt->next->keyboard) {
@@ -1159,15 +1158,19 @@
dev->name,
vt->first_vc,
vt->first_vc + vt->vc_count - 1);
+ if(test_bit(EV_SND, dev->evbit)) {
+ vt->beeper = handle;
+ vt_map_input(vt);
+ }
break;
}
vt = vt->next;
}
kbd_refresh_leds(handle);
}
- if (test_bit(EV_SND, dev->evbit)) {
- vt->beeper = handle;
- vt_map_input(vt);
+ else if (test_bit(EV_SND, dev->evbit) && admin_vt && !admin_vt->beeper) {
+ admin_vt->beeper = handle;
+ vt_map_input(admin_vt);
}
return handle;
}
Index: vt.c
===================================================================
RCS file: /cvsroot/linuxconsole/ruby/ruby-2.6/drivers/char/vt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vt.c 12 Sep 2003 08:33:21 -0000 1.2
+++ vt.c 16 Sep 2003 06:54:42 -0000 1.3
@@ -128,9 +128,13 @@
#if defined (CONFIG_PROM_CONSOLE)
extern void prom_con_init(void);
#endif
+#ifdef CONFIG_PROC_FS
+extern int vt_proc_init(void);
+#endif
struct tty_driver *console_driver; /* TTY driver for all VT consoles */
static unsigned int current_vc; /* Which /dev/vc/X to allocate next */
+static unsigned int current_vt; /* Which VT to allocate next */
struct vt_struct *admin_vt; /* Administrative VT */
struct vt_struct *vt_cons; /* Head to link list of VTs */
@@ -835,7 +839,7 @@
*/
static int pm_con_request(struct pm_dev *dev, pm_request_t rqst, void *data)
{
- struct vt_struct *vt = vt_cons; /*FIXME*/
+ struct vt_struct *vt = admin_vt; /*FIXME*/
if (vt) {
switch (rqst)
@@ -998,6 +1002,11 @@
kmalloced = 1;
if (!*vc->vc_uni_pagedir_loc)
con_set_default_unimap(vc);
+ if (!vt->pm_con) {
+ vt->pm_con = pm_register(PM_SYS_DEV,
+ PM_SYS_VGA,
+ pm_con_request);
+ }
} else {
screenbuf = (unsigned short *) alloc_bootmem(screenbuf_size);
if (!screenbuf) {
@@ -1010,11 +1019,6 @@
if ((vt->first_vc + 1) == currcons)
vt->want_vc = vt->fg_console = vt->last_console = vc;
vc_init(vc, 1);
-/* if (!vt->pm_con) { */
-/* vt->pm_con = pm_register(PM_SYS_DEV, */
-/* PM_SYS_VGA, */
-/* pm_con_request); */
-/* } */
return vc;
}
@@ -1737,6 +1741,7 @@
/* Now to setup VT */
init_MUTEX(&vt->lock);
+ vt->vt_num = current_vt;
vt->first_vc = current_vc;
vt->vc_count = vc_count;
vt->next = vt_cons;
@@ -1767,6 +1772,7 @@
vte_ed(vt->fg_console, 0);
update_screen(vt->fg_console);
current_vc += vc_count;
+ current_vt += 1;
return display_desc;
}
@@ -1846,6 +1852,9 @@
kbd_init();
console_map_init();
vcs_init();
+#ifdef CONFIG_PROC_FS
+ vt_proc_init();
+#endif
return 0;
}
|