//------------------------------------------------------------------- // ioctl.c // // This module implements a character device-driver which lets // an application invoke 'ioctl()' system-calls that will hide // or show the graphics hardware's cursor (for SiS 315 only). // // programmer: ALLAN CRUSE // written on: 19 NOV 2004 //------------------------------------------------------------------- #include // for init_module() #include // for pci_find_device() #define VENDOR_ID 0x1039 #define DEVICE_ID 0x6325 #define HIDE_CURSOR 0 #define SHOW_CURSOR 1 static char modname[] = "vram"; static int my_major = 99; static unsigned long mmio_base; static int my_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg ) { unsigned long *cursor_control, *cursor_pos_x, *cursor_pos_y; unsigned long command, pos_x, pos_y; void *vaddr; vaddr = ioremap_nocache( mmio_base + 0x8000, PAGE_SIZE ); cursor_control = vaddr + 0x500; cursor_pos_x = vaddr + 0x50C; cursor_pos_y = vaddr + 0x510; command = *cursor_control; pos_x = *cursor_pos_x; pos_y = *cursor_pos_y; switch ( cmd ) { case HIDE_CURSOR: command &= 0x3FFFFFFF; command |= 0x80000000; break; case SHOW_CURSOR: command &= 0x3FFFFFFF; command |= 0xC0000000; break; } *cursor_control = command; *cursor_pos_x = pos_x; *cursor_pos_y = pos_y; iounmap( vaddr ); return 0; // SUCCESS } static struct file_operations my_fops = { owner: THIS_MODULE, ioctl: my_ioctl, }; int init_module( void ) { struct pci_dev *devp = NULL; printk( "<1>\nInstalling \'%s\' module\n", modname ); devp = pci_find_device( VENDOR_ID, DEVICE_ID, devp ); if ( !devp ) return -ENODEV; printk( " %s \n", devp->name ); mmio_base = pci_resource_start( devp, 1 ); printk( " mmio_base=%08X \n", mmio_base ); register_chrdev( my_major, modname, &my_fops ); return 0; // SUCCESS } void cleanup_module( void ) { unregister_chrdev( my_major, modname ); printk( "<1>Removing \'%s\' module\n", modname ); } MODULE_LICENSE("GPL");