Skip site navigation (1)Skip section navigation (2)
Date:      13 Dec 1998 22:52:04 +0100
From:      Dag-Erling Smorgrav <des@flood.ping.uio.no>
To:        hackers@FreeBSD.ORG
Subject:   Screensaver KLDs
Message-ID:  <xzpaf0r1zi3.fsf@flood.ping.uio.no>

next in thread | raw e-mail | index | archive | help
Well, I got itchy fingers again and tried to write a graphical
screensaver KLD. I used one of the existing screensaver modules as a
template; it compiles fine, and I'm pretty sure that the code is
mostly correct, but kldload refuses to load it:

root@niobe /sys/modules/syscons/vga# make
Warning: Object directory not changed from original /usr/src/sys/modules/syscons/vga
@ -> /usr/src/sys
machine -> /usr/src/sys/i386/include
cc -O -pipe -I/usr/src/sys/modules/syscons/vga/..  -DKERNEL -Wreturn-type -Wcomment -Wredundant-decls -Wimplicit  -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes  -Wpointer-arith -Winline -Wuninitialized -Wformat  -fformat-extensions -ansi -DKLD_MODULE -nostdinc -I- -I/usr/src/sys/modules/syscons/vga/.. -I/usr/src/sys/modules/syscons/vga -I/usr/src/sys/modules/syscons/vga/@ -c vga_saver.c
vga_saver.c:102: warning: initialization from incompatible pointer type
gensetdefs vga_saver.o
cc -O -pipe -I/usr/src/sys/modules/syscons/vga/..  -DKERNEL -Wreturn-type -Wcomment -Wredundant-decls -Wimplicit  -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes  -Wpointer-arith -Winline -Wuninitialized -Wformat  -fformat-extensions -ansi -DKLD_MODULE -nostdinc -I- -I/usr/src/sys/modules/syscons/vga/.. -I/usr/src/sys/modules/syscons/vga -I/usr/src/sys/modules/syscons/vga/@ -c setdef0.c
cc -O -pipe -I/usr/src/sys/modules/syscons/vga/..  -DKERNEL -Wreturn-type -Wcomment -Wredundant-decls -Wimplicit  -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes  -Wpointer-arith -Winline -Wuninitialized -Wformat  -fformat-extensions -ansi -DKLD_MODULE -nostdinc -I- -I/usr/src/sys/modules/syscons/vga/.. -I/usr/src/sys/modules/syscons/vga -I/usr/src/sys/modules/syscons/vga/@ -c setdef1.c
ld -Bshareable  -o vga_saver_mod.ko setdef0.o vga_saver.o setdef1.o
root@niobe /sys/modules/syscons/vga# kldload vga_saver
kldload: can't load vga_saver: Exec format error

The other screensaver KLDs work fine (and they all produce the same
warning when compiling). I'm running a bleeding-edge 3.0 Elf kernel.

Here's the source:

/*-
 * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer
 *    in this position and unchanged.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *	$Id$
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>

#include <machine/md_var.h>

#include <saver.h>

static int saved_mode;
static u_char *vid;
static int counter;

static void
vga_saver(int blank)
{
    scr_stat *scp = cur_console;

    /* foo! */
    if (!vid)
	return;
    
    if (blank) {
	/* switch to graphics mode */
	if (scrn_blanked <= 0) {
	    scp->status |= SAVER_RUNNING;
	    saved_mode = scp->mode;
	    if (sc_set_graphics_mode(scp, NULL, SW_VGA_CG320)) {
		scp->status &= ~SAVER_RUNNING;
		saved_mode = 0;
		return;
	    }
	    fillw(1, vid, 320);
	}

	/* update display */
	vid[counter++] = 1;
	if (counter >= 320)
	    counter = 0;
	vid[counter] = 15;
    } else {
	/* return to previous video mode */
	if (scrn_blanked > 0) {
	    if (saved_mode)
		sc_set_graphics_mode(scp, NULL, saved_mode);
	    scrn_blanked = 0;
	    scp->status &= ~SAVER_RUNNING;
	    saved_mode = 0;
	}
    }
}

static int
vga_saver_load(void)
{
    video_info_t info;

    /* check that the console is capable of running in 320x200x256 */
    if ((*biosvidsw.get_info)(cur_console->adp, SW_VGA_CG320, &info))
	return ENODEV;
    vid = (u_char *)info.vi_window;
    
    return add_scrn_saver(vga_saver);
}

static int
vga_saver_unload(void)
{
    return remove_scrn_saver(vga_saver);
}

SAVER_MODULE(vga_saver);

DES
-- 
Dag-Erling Smorgrav - des@flood.ping.uio.no

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpaf0r1zi3.fsf>