From owner-freebsd-hackers Fri Oct 30 01:43:09 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id BAA10770 for freebsd-hackers-outgoing; Fri, 30 Oct 1998 01:43:09 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id BAA10765 for ; Fri, 30 Oct 1998 01:43:07 -0800 (PST) (envelope-from dfr@nlsystems.com) Received: from herring.nlsystems.com (herring.nlsystems.com [10.0.0.2]) by nlsystems.com (8.9.1/8.8.5) with SMTP id JAA02509; Fri, 30 Oct 1998 09:44:35 GMT Date: Fri, 30 Oct 1998 09:44:35 +0000 (GMT) From: Doug Rabson To: Kazutaka YOKOTA cc: John Hay , FreeBSD-hackers Subject: Re: kld screensavers In-Reply-To: <199810291457.XAA12116@zodiac.mech.utsunomiya-u.ac.jp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 29 Oct 1998, Kazutaka YOKOTA wrote: > > >It looks about right and SI_SUB_PSEUDO is sufficiently late that it > >shouldn't disturb anything. Any time after SI_SUB_CONFIGURE should work I > >think. > > > >It would be nice if the add_scrn_saver/remove_scrn_saver goop was factored > >into a generic module event handler which can be used by all screen > >savers. Have a look at the CDEV_MODULE #define in sys/conf.h for a > >possible way of doing this. > > > >If the generic module handler chains onto an optional user-supplied > >handler, then extra initialisation (allocating message in this case) can > >be done by each saver without repeating the registration code. > > You mean something like this? > > 1. Define generic_screen_saver_module_handler() in syscons.c or somewhere. > 2. Each screen saver module define its own event handler. It will call > the generic handler first and then do its own extra house keeping. Thats more or less what I was suggesting. Simple screen savers wouldn't even need an event handler. Maybe something like: struct saver_module_data { modeventhand_t chainevh; void* chainarg; void (*saver)(int); }; #defined SAVER_MODULE(name, fn, evh, arg) \ static struct saver_module_data name##_saver_mod = { \ evh, arg, fn \ }; \ \ static moduledata_t name##_mod = { \ #name, \ saver_module_handler, \ &name##_saver_mod \ }; \ DECLARE_MODULE(name, name##_mod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE) static int saver_module_handler(module_t mod, modeventtype_t type, void *arg) { struct saver_module_data *data = arg; switch (type) { case MOD_LOAD: return add_scrn_saver(data->saver); case MOD_UNLOAD: return remove_scrn_saver(data->saver); default: printf("star_saver module unknown event: 0x%x\n", type); } if (data->chainevh) return data->chainevh(mod, what, data->chainarg); else return 0; } -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 951 1891 Fax: +44 181 381 1039 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message