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