blank_saver.c revision 6628
16628Ssos/*-
26628Ssos * Copyright (c) 1995 S�ren Schmidt
36628Ssos * All rights reserved.
46628Ssos *
56628Ssos * Redistribution and use in source and binary forms, with or without
66628Ssos * modification, are permitted provided that the following conditions
76628Ssos * are met:
86628Ssos * 1. Redistributions of source code must retain the above copyright
96628Ssos *    notice, this list of conditions and the following disclaimer
106628Ssos *    in this position and unchanged.
116628Ssos * 2. Redistributions in binary form must reproduce the above copyright
126628Ssos *    notice, this list of conditions and the following disclaimer in the
136628Ssos *    documentation and/or other materials provided with the distribution.
146628Ssos * 3. The name of the author may not be used to endorse or promote products
156628Ssos *    derived from this software withough specific prior written permission
166628Ssos *
176628Ssos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
186628Ssos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
196628Ssos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
206628Ssos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
216628Ssos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
226628Ssos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236628Ssos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246628Ssos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256628Ssos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
266628Ssos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276628Ssos *
286628Ssos *	$Id$
296628Ssos */
306628Ssos
316628Ssos#include <sys/param.h>
326628Ssos#include <sys/systm.h>
336628Ssos#include <sys/conf.h>
346628Ssos#include <sys/exec.h>
356628Ssos#include <sys/sysent.h>
366628Ssos#include <sys/lkm.h>
376628Ssos#include <sys/errno.h>
386628Ssos#include <saver.h>
396628Ssos
406628SsosMOD_MISC("blank_saver")
416628Ssos
426628Ssosvoid (*current_saver)();
436628Ssosvoid (*old_saver)();
446628Ssos
456628Ssosstatic void
466628Ssosblank_saver(int blank)
476628Ssos{
486628Ssos	u_char val;
496628Ssos	if (blank) {
506628Ssos		scrn_blanked = 1;
516628Ssos		outb(TSIDX, 0x01); val = inb(TSREG);
526628Ssos		outb(TSIDX, 0x01); outb(TSREG, val | 0x20);
536628Ssos	}
546628Ssos	else {
556628Ssos		outb(TSIDX, 0x01); val = inb(TSREG);
566628Ssos		outb(TSIDX, 0x01); outb(TSREG, val & 0xDF);
576628Ssos		scrn_blanked = 0;
586628Ssos	}
596628Ssos}
606628Ssos
616628Ssossaver_load(struct lkm_table *lkmtp, int cmd)
626628Ssos{
636628Ssos	(*current_saver)(0);
646628Ssos	old_saver = current_saver;
656628Ssos	current_saver = blank_saver;
666628Ssos	uprintf("blank screen saver installed\n");
676628Ssos	return 0;
686628Ssos}
696628Ssos
706628Ssossaver_unload(struct lkm_table *lkmtp, int cmd)
716628Ssos{
726628Ssos	(*current_saver)(0);
736628Ssos	current_saver = old_saver;
746628Ssos	uprintf("blank screen saver removed\n");
756628Ssos	return 0;
766628Ssos}
776628Ssos
786628Ssossaver_init(struct lkm_table *lkmtp, int cmd, int ver)
796628Ssos{
806628Ssos	DISPATCH(lkmtp, cmd, ver, saver_load, saver_unload, nosys);
816628Ssos}
82