/* * linux/drivers/misc/tcsm.c * * Virtual device driver with tricky appoach to manage TCSM * * Copyright (C) 2006 Ingenic Semiconductor Inc. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include MODULE_AUTHOR("Jianli Wei"); MODULE_DESCRIPTION("Virtual Driver of TCSM"); MODULE_LICENSE("GPL"); /* * fops routines */ static int tcsm_open(struct inode *inode, struct file *filp); static int tcsm_release(struct inode *inode, struct file *filp); static ssize_t tcsm_read(struct file *filp, char *buf, size_t size, loff_t *l); static ssize_t tcsm_write(struct file *filp, const char *buf, size_t size, loff_t *l); static int tcsm_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); static struct file_operations tcsm_fops = { open: tcsm_open, release: tcsm_release, read: tcsm_read, write: tcsm_write, ioctl: tcsm_ioctl, }; static int tcsm_open(struct inode *inode, struct file *filp) { struct pt_regs *info = task_pt_regs(current); printk("pt_regs =%p\n", info); printk("cp0 status=0x%08x\n", (unsigned int)info->cp0_status); info->cp0_status &= ~0x10; info->cp0_status |= 0x08000000; // a tricky printk("cp0 status=0x%08x\n", (unsigned int)info->cp0_status); return 0; } static int tcsm_release(struct inode *inode, struct file *filp) { struct pt_regs *info = task_pt_regs(current); info->cp0_status |= 0x10; info->cp0_status &= ~0x08000000; // a tricky return 0; } static ssize_t tcsm_read(struct file *filp, char *buf, size_t size, loff_t *l) { printk("tcsm: read is not implemented\n"); return -1; } static ssize_t tcsm_write(struct file *filp, const char *buf, size_t size, loff_t *l) { printk("tcsm: write is not implemented\n"); return -1; } static int tcsm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { int ret = 0; printk("tcsm: ioctl is not implemented\n"); return ret; } static struct miscdevice tcsm_dev = { TCSM_MINOR, "tcsm", &tcsm_fops }; /* * Module init and exit */ static int __init tcsm_init(void) { int ret; ret = misc_register(&tcsm_dev); if (ret < 0) { return ret; } printk("Virtual Driver of JZ TCSM registered\n"); return 0; } static void __exit tcsm_exit(void) { misc_deregister(&tcsm_dev); } module_init(tcsm_init); module_exit(tcsm_exit);