ibmasmfs.c (b8acb808468a88a188d7c5aba3681c583a5785f9) | ibmasmfs.c (278d72ae8803ffcd16070c95fe1d53f4466dc741) |
---|---|
1/* 2 * IBM ASM Service Processor Device Driver 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * --- 23 unchanged lines hidden (view full) --- 32 * dymamically when mounted from user space: 33 * 34 * /ibmasm 35 * |-- 0 36 * | |-- command 37 * | |-- event 38 * | |-- reverse_heartbeat 39 * | `-- remote_video | 1/* 2 * IBM ASM Service Processor Device Driver 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * --- 23 unchanged lines hidden (view full) --- 32 * dymamically when mounted from user space: 33 * 34 * /ibmasm 35 * |-- 0 36 * | |-- command 37 * | |-- event 38 * | |-- reverse_heartbeat 39 * | `-- remote_video |
40 * | |-- connected | |
41 * | |-- depth | 40 * | |-- depth |
42 * | |-- events | |
43 * | |-- height 44 * | `-- width 45 * . 46 * . 47 * . 48 * `-- n 49 * |-- command 50 * |-- event 51 * |-- reverse_heartbeat 52 * `-- remote_video | 41 * | |-- height 42 * | `-- width 43 * . 44 * . 45 * . 46 * `-- n 47 * |-- command 48 * |-- event 49 * |-- reverse_heartbeat 50 * `-- remote_video |
53 * |-- connected | |
54 * |-- depth | 51 * |-- depth |
55 * |-- events | |
56 * |-- height 57 * `-- width 58 * 59 * For each service processor the following files are created: 60 * 61 * command: execute dot commands 62 * write: execute a dot command on the service processor 63 * read: return the result of a previously executed dot command --- 6 unchanged lines hidden (view full) --- 70 * read: sleep (interruptible) until the reverse heartbeat fails 71 * write: wakeup sleeping heartbeat listener 72 * 73 * remote_video/width 74 * remote_video/height 75 * remote_video/width: control remote display settings 76 * write: set value 77 * read: read value | 52 * |-- height 53 * `-- width 54 * 55 * For each service processor the following files are created: 56 * 57 * command: execute dot commands 58 * write: execute a dot command on the service processor 59 * read: return the result of a previously executed dot command --- 6 unchanged lines hidden (view full) --- 66 * read: sleep (interruptible) until the reverse heartbeat fails 67 * write: wakeup sleeping heartbeat listener 68 * 69 * remote_video/width 70 * remote_video/height 71 * remote_video/width: control remote display settings 72 * write: set value 73 * read: read value |
78 * 79 * remote_video/connected 80 * read: return "1" if web browser VNC java applet is connected, 81 * "0" otherwise 82 * 83 * remote_video/events 84 * read: sleep until a remote mouse or keyboard event occurs, then return 85 * then event. | |
86 */ 87 88#include <linux/fs.h> 89#include <linux/pagemap.h> 90#include <asm/uaccess.h> 91#include <asm/io.h> 92#include "ibmasm.h" 93#include "remote.h" --- 494 unchanged lines hidden (view full) --- 588 589 value = simple_strtoul(buff, NULL, 10); 590 writel(value, address); 591 kfree(buff); 592 593 return count; 594} 595 | 74 */ 75 76#include <linux/fs.h> 77#include <linux/pagemap.h> 78#include <asm/uaccess.h> 79#include <asm/io.h> 80#include "ibmasm.h" 81#include "remote.h" --- 494 unchanged lines hidden (view full) --- 576 577 value = simple_strtoul(buff, NULL, 10); 578 writel(value, address); 579 kfree(buff); 580 581 return count; 582} 583 |
596static int remote_event_file_open(struct inode *inode, struct file *file) 597{ 598 struct service_processor *sp; 599 unsigned long flags; 600 struct remote_queue *q; 601 602 file->private_data = inode->u.generic_ip; 603 sp = file->private_data; 604 q = &sp->remote_queue; 605 606 /* allow only one event reader */ 607 spin_lock_irqsave(&sp->lock, flags); 608 if (q->open) { 609 spin_unlock_irqrestore(&sp->lock, flags); 610 return -EBUSY; 611 } 612 q->open = 1; 613 spin_unlock_irqrestore(&sp->lock, flags); 614 615 enable_mouse_interrupts(sp); 616 617 return 0; 618} 619 620static int remote_event_file_close(struct inode *inode, struct file *file) 621{ 622 struct service_processor *sp = file->private_data; 623 624 disable_mouse_interrupts(sp); 625 wake_up_interruptible(&sp->remote_queue.wait); 626 sp->remote_queue.open = 0; 627 628 return 0; 629} 630 631static ssize_t remote_event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) 632{ 633 struct service_processor *sp = file->private_data; 634 struct remote_queue *q = &sp->remote_queue; 635 size_t data_size; 636 struct remote_event *reader = q->reader; 637 size_t num_events; 638 639 if (*offset < 0) 640 return -EINVAL; 641 if (count == 0 || count > 1024) 642 return 0; 643 if (*offset != 0) 644 return 0; 645 646 if (wait_event_interruptible(q->wait, q->reader != q->writer)) 647 return -ERESTARTSYS; 648 649 /* only get multiples of struct remote_event */ 650 num_events = min((count/sizeof(struct remote_event)), ibmasm_events_available(q)); 651 if (!num_events) 652 return 0; 653 654 data_size = num_events * sizeof(struct remote_event); 655 656 if (copy_to_user(buf, reader, data_size)) 657 return -EFAULT; 658 659 ibmasm_advance_reader(q, num_events); 660 661 return data_size; 662} 663 664 | |
665static struct file_operations command_fops = { 666 .open = command_file_open, 667 .release = command_file_close, 668 .read = command_file_read, 669 .write = command_file_write, 670}; 671 672static struct file_operations event_fops = { --- 12 unchanged lines hidden (view full) --- 685 686static struct file_operations remote_settings_fops = { 687 .open = remote_settings_file_open, 688 .release = remote_settings_file_close, 689 .read = remote_settings_file_read, 690 .write = remote_settings_file_write, 691}; 692 | 584static struct file_operations command_fops = { 585 .open = command_file_open, 586 .release = command_file_close, 587 .read = command_file_read, 588 .write = command_file_write, 589}; 590 591static struct file_operations event_fops = { --- 12 unchanged lines hidden (view full) --- 604 605static struct file_operations remote_settings_fops = { 606 .open = remote_settings_file_open, 607 .release = remote_settings_file_close, 608 .read = remote_settings_file_read, 609 .write = remote_settings_file_write, 610}; 611 |
693static struct file_operations remote_event_fops = { 694 .open = remote_event_file_open, 695 .release = remote_event_file_close, 696 .read = remote_event_file_read, 697}; | |
698 | 612 |
699 | |
700static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) 701{ 702 struct list_head *entry; 703 struct service_processor *sp; 704 705 list_for_each(entry, &service_processors) { 706 struct dentry *dir; 707 struct dentry *remote_dir; --- 8 unchanged lines hidden (view full) --- 716 717 remote_dir = ibmasmfs_create_dir(sb, dir, "remote_video"); 718 if (!remote_dir) 719 continue; 720 721 ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); 722 ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); 723 ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); | 613static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) 614{ 615 struct list_head *entry; 616 struct service_processor *sp; 617 618 list_for_each(entry, &service_processors) { 619 struct dentry *dir; 620 struct dentry *remote_dir; --- 8 unchanged lines hidden (view full) --- 629 630 remote_dir = ibmasmfs_create_dir(sb, dir, "remote_video"); 631 if (!remote_dir) 632 continue; 633 634 ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); 635 ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); 636 ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); |
724 ibmasmfs_create_file(sb, remote_dir, "connected", &remote_settings_fops, (void *)vnc_status(sp), S_IRUSR); 725 ibmasmfs_create_file(sb, remote_dir, "events", &remote_event_fops, (void *)sp, S_IRUSR); | |
726 } 727} | 637 } 638} |