x68kInit.c revision 909daefd
1/* $NetBSD: x68kInit.c,v 1.2 2016/08/30 07:50:55 mrg 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
80InternalEvent *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
139    if ( !mieqInit() )
140        FatalError("mieqInit failed\n");
141
142    /* setup SIGIO handler for asynchronous event handling */
143    (void)OsSignal(SIGIO, x68kSigIOHandler);
144}
145
146void
147CloseInput(void)
148{
149}
150
151/*-------------------------------------------------------------------------
152 * function "AbortDDX"                                 [ called by OS ]
153 *
154 *  purpose:  free signal handler and close frame buffers
155 *  argument: ExitCode
156 *  returns:  nothing
157 *-----------------------------------------------------------------------*/
158void
159AbortDDX(enum ExitCode error)
160{
161    int i;
162    X68kScreenRec *screen;
163    X68kFbProcRec *fb;
164
165    /* give up SIGIO handling */
166    (void) OsSignal(SIGIO, SIG_IGN);
167
168    /* close all frame buffers */
169    for (i = 0; i < nscreens; i++) {
170        screen = x68kGetScreenRec(i);
171        fb = x68kGetFbProcRec(i);
172        (*fb->close)(screen);
173    }
174}
175
176/*-------------------------------------------------------------------------
177 * function "ddxGiveUp"                                 [ called by DIX ]
178 *
179 *  purpose:  do nothing but call AbortDDX.
180 *  argument: nothing
181 *  returns:  nothing
182 *-----------------------------------------------------------------------*/
183void
184ddxGiveUp(enum ExitCode error)
185{
186    AbortDDX(error);
187}
188
189/*-------------------------------------------------------------------------
190 * function "ddxProcessArgument"                        [ called by OS ]
191 *
192 *  purpose:  process X68k dependent arguments
193 *            currently only `x68kconfig' will be recognized.
194 *  argument: (int)argc, (char **)argv: standard C arguments
195 *            (int)i                  : index of current argument
196 *  returns:  number of arguments eaten
197 *-----------------------------------------------------------------------*/
198int
199ddxProcessArgument(int argc, char *argv[], int i)
200{
201
202    if (strcmp(argv[i], "-x68kconfig") == 0) {
203        if (++i >= argc)
204            UseMsg();
205        configFilename = strdup(argv[i]);
206        return 2;
207    }
208    return 0;
209}
210
211/*-------------------------------------------------------------------------
212 * function "ddxUseMsg"                                 [ called by OS ]
213 *
214 *  purpose:  print X68k dependent usage
215 *  argument: nothing
216 *  returns:  nothing
217 *-----------------------------------------------------------------------*/
218void
219ddxUseMsg(void)
220{
221    ErrorF("\nX68k dependent options\n");
222    ErrorF("-x68kconfig filename   specify configuration file\n");
223}
224
225_X_EXPORT void
226OsVendorFatalError(const char *f, va_list args)
227{
228}
229
230/* EOF x68kInit.c */
231