green_saver.c revision 6628
1193326Sed/*- 2193326Sed * Copyright (c) 1995 S�ren Schmidt 3193326Sed * All rights reserved. 4193326Sed * 5193326Sed * Redistribution and use in source and binary forms, with or without 6193326Sed * modification, are permitted provided that the following conditions 7193326Sed * are met: 8193326Sed * 1. Redistributions of source code must retain the above copyright 9193326Sed * notice, this list of conditions and the following disclaimer 10193326Sed * in this position and unchanged. 11193326Sed * 2. Redistributions in binary form must reproduce the above copyright 12193326Sed * notice, this list of conditions and the following disclaimer in the 13193326Sed * documentation and/or other materials provided with the distribution. 14193326Sed * 3. The name of the author may not be used to endorse or promote products 15193326Sed * derived from this software withough specific prior written permission 16193326Sed * 17193326Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18193326Sed * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19193326Sed * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20193326Sed * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21193326Sed * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22193326Sed * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23193326Sed * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24193326Sed * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25193326Sed * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26193326Sed * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27193326Sed * 28193326Sed * $Id$ 29204962Srdivacky */ 30193326Sed 31204962Srdivacky#include <sys/param.h> 32204962Srdivacky#include <sys/systm.h> 33193326Sed#include <sys/conf.h> 34193326Sed#include <sys/exec.h> 35193326Sed#include <sys/sysent.h> 36193326Sed#include <sys/lkm.h> 37193326Sed#include <sys/errno.h> 38193326Sed#include <saver.h> 39193326Sed 40198092SrdivackyMOD_MISC("green_saver") 41193326Sed 42224145Sdimvoid (*current_saver)(); 43193326Sedvoid (*old_saver)(); 44193326Sed 45193326Sedstatic void 46193326Sedgreen_saver(int blank) 47193326Sed{ 48193326Sed u_char val; 49193326Sed if (blank) { 50193326Sed 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 65saver_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 74saver_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 82saver_init(struct lkm_table *lkmtp, int cmd, int ver) 83{ 84 DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys); 85} 86