1 /*- 2 * Copyright (c) 1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer 10 * in this position and unchanged. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software withough specific prior written permission 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * $Id: green_saver.c,v 1.2 1995/05/30 06:06:17 rgrimes Exp $ 29 */ 30 31 #include <sys/param.h> 32 #include <sys/systm.h> 33 #include <sys/conf.h> 34 #include <sys/exec.h> 35 #include <sys/sysent.h> 36 #include <sys/lkm.h> 37 #include <sys/errno.h> 38 #include <saver.h> 39 40 MOD_MISC("green_saver") 41 42 void (*current_saver)(); 43 void (*old_saver)(); 44 45 static void 46 green_saver(int blank) 47 { 48 u_char val; 49 if (blank) { 50 scrn_blanked = 1; 51 outb(TSIDX, 0x01); val = inb(TSREG); 52 outb(TSIDX, 0x01); outb(TSREG, val | 0x20); 53 outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); 54 outb(crtc_addr + 1, val & ~0x80); 55 } 56 else { 57 outb(TSIDX, 0x01); val = inb(TSREG); 58 outb(TSIDX, 0x01); outb(TSREG, val & 0xDF); 59 outb(crtc_addr, 0x17); val = inb(crtc_addr + 1); 60 outb(crtc_addr + 1, val | 0x80); 61 scrn_blanked = 0; 62 } 63 } 64 65 green_saver_load(struct lkm_table *lkmtp, int cmd) 66 { 67 (*current_saver)(0); 68 old_saver = current_saver; 69 current_saver = green_saver; 70 uprintf("green screen saver installed\n"); 71 return 0; 72 } 73 74 green_saver_unload(struct lkm_table *lkmtp, int cmd) 75 { 76 (*current_saver)(0); 77 current_saver = old_saver; 78 uprintf("green screen saver removed\n"); 79 return 0; 80 } 81 82 green_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) 83 { 84 DISPATCH(lkmtp, cmd, ver, green_saver_load, green_saver_unload, nosys); 85 } 86