x68kInit.c revision ba64b02e
1/* $NetBSD: x68kInit.c,v 1.1 2014/03/01 19:34:47 tsutsui Exp $ */
2/*-------------------------------------------------------------------------
3 * Copyright (c) 1996 Yasushi Yamasaki
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
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. All advertising materials mentioning features or use of this software
15 *    must display the following acknowledgement:
16 *      This product includes software developed by Yasushi Yamasaki
17 * 4. The name of the author may not be used to endorse or promote products
18 *    derived from this software without specific prior written permission
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *-----------------------------------------------------------------------*/
31
32/*
33 *
34 * Copyright (c) 1987 by the Regents of the University of California
35 *
36 * Permission to use, copy, modify, and distribute this
37 * software and its documentation for any purpose and without
38 * fee is hereby granted, provided that the above copyright
39 * notice appear in all copies.  The University of California
40 * makes no representations about the suitability of this
41 * software for any purpose.  It is provided "as is" without
42 * express or implied warranty.
43 *
44 *
45 */
46
47/************************************************************
48Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
49
50                    All Rights Reserved
51
52Permission  to  use,  copy,  modify,  and  distribute   this
53software  and  its documentation for any purpose and without
54fee is hereby granted, provided that the above copyright no-
55tice  appear  in all copies and that both that copyright no-
56tice and this permission notice appear in  supporting  docu-
57mentation,  and  that the names of Sun or X Consortium
58not be used in advertising or publicity pertaining to
59distribution  of  the software  without specific prior
60written permission. Sun and X Consortium make no
61representations about the suitability of this software for
62any purpose. It is provided "as is" without any express or
63implied warranty.
64
65SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
66INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
67NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
68ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
69ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
70PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
71OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
72THE USE OR PERFORMANCE OF THIS SOFTWARE.
73
74*******************************************************/
75
76#include "Xos.h"
77#include "x68k.h"
78#include "mi.h"
79
80EventList *x68kEvents = NULL;
81
82static int nscreens;
83
84void
85OsVendorInit(void)
86{
87}
88
89/*-------------------------------------------------------------------------
90 * function "InitOutput"                                [ called by DIX ]
91 *
92 *  purpose:  initialize outputs ( screens )
93 *  argument: (ScreenInfo *)pScreenInfo  : screen info struct
94 *            (int)argc, (char *)argv    : standard arguments
95 *  returns:  nothing
96 *-----------------------------------------------------------------------*/
97void
98InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
99{
100    int i;
101    X68kScreenRec *screen;
102    X68kFbProcRec *fb;
103
104    pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
105    pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
106    pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
107    pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
108
109    /* read configuration file */
110    nscreens = x68kConfig();
111
112    /* register pixmap formats */
113    x68kRegisterPixmapFormats(pScreenInfo);
114
115    /* open and initialize frame buffer for each screen */
116    for (i = 0; i < nscreens; i++) {
117        screen = x68kGetScreenRec(i);
118        fb = x68kGetFbProcRec(i);
119        if ( !(*fb->open)(screen) )
120            return;
121        if ( AddScreen(fb->init, argc, argv) < 0 )
122            FatalError("AddScreen failed\n");
123    }
124}
125
126/*-------------------------------------------------------------------------
127 * function "InitInput"                                 [ called by DIX ]
128 *
129 *  purpose:  initialize inputs ( keyboard and mouse )
130 *  argument: (int)argc, (char *)argv    : standard arguments
131 *  returns:  nothing
132 *-----------------------------------------------------------------------*/
133void
134InitInput(int argc, char *argv[])
135{
136    x68kPointerDevice = AddInputDevice(serverClient, x68kMouseProc, TRUE);
137    x68kKeyboardDevice = AddInputDevice(serverClient, x68kKbdProc, TRUE);
138    GetEventList(&x68kEvents);
139
140    if ( !mieqInit() )
141        FatalError("mieqInit failed\n");
142
143    /* setup SIGIO handler for asynchronous event handling */
144    (void)OsSignal(SIGIO, x68kSigIOHandler);
145}
146
147void
148CloseInput(void)
149{
150}
151
152/*-------------------------------------------------------------------------
153 * function "AbortDDX"                                 [ called by OS ]
154 *
155 *  purpose:  free signal handler and close frame buffers
156 *  argument: nothing
157 *  returns:  nothing
158 *-----------------------------------------------------------------------*/
159void
160AbortDDX(void)
161{
162    int i;
163    X68kScreenRec *screen;
164    X68kFbProcRec *fb;
165
166    /* give up SIGIO handling */
167    (void) OsSignal(SIGIO, SIG_IGN);
168
169    /* close all frame buffers */
170    for (i = 0; i < nscreens; i++) {
171        screen = x68kGetScreenRec(i);
172        fb = x68kGetFbProcRec(i);
173        (*fb->close)(screen);
174    }
175}
176
177/*-------------------------------------------------------------------------
178 * function "ddxGiveUp"                                 [ called by DIX ]
179 *
180 *  purpose:  do nothing but call AbortDDX.
181 *  argument: nothing
182 *  returns:  nothing
183 *-----------------------------------------------------------------------*/
184void
185ddxGiveUp(void)
186{
187    AbortDDX();
188}
189
190/*-------------------------------------------------------------------------
191 * function "ddxProcessArgument"                        [ called by OS ]
192 *
193 *  purpose:  process X68k dependent arguments
194 *            currently only `x68kconfig' will be recognized.
195 *  argument: (int)argc, (char **)argv: standard C arguments
196 *            (int)i                  : index of current argument
197 *  returns:  number of arguments eaten
198 *-----------------------------------------------------------------------*/
199int
200ddxProcessArgument(int argc, char *argv[], int i)
201{
202
203    if (strcmp(argv[i], "-x68kconfig") == 0) {
204        if (++i >= argc)
205            UseMsg();
206        configFilename = strdup(argv[i]);
207        return 2;
208    }
209    return 0;
210}
211
212/*-------------------------------------------------------------------------
213 * function "ddxUseMsg"                                 [ called by OS ]
214 *
215 *  purpose:  print X68k dependent usage
216 *  argument: nothing
217 *  returns:  nothing
218 *-----------------------------------------------------------------------*/
219void
220ddxUseMsg(void)
221{
222    ErrorF("\nX68k dependent options\n");
223    ErrorF("-x68kconfig filename   specify configuration file\n");
224}
225
226void
227OsVendorFatalError(void)
228{
229}
230
231/* EOF x68kInit.c */
232